query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
Only allow a list of trusted parameters through. | def formula_herb_action_params
params.require(:formula_herb_action).permit(:formula_herb_id, :formula_named_action_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\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 strong_params\n params.require(:user).permit(param_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 allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); 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 param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\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 allowed?(*_)\n true\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 allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\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 permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; 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 url_allowlist=(_arg0); 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 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 list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def safelist; end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\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 shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.6326454",
"0.63140553",
"0.6299814",
"0.62642586",
"0.626006",
"0.62578833",
"0.6236823",
"0.6227561",
"0.6221758",
"0.62200165",
"0.620879",
"0.61983657",
"0.6195055",
"0.6172993",
"0.6156856",
"0.61558664",
"0.61521494",
"0.6135789",
"0.6121145",
"0.61118174",
"0.60736513",
"0.6071645",
"0.60632104",
"0.60549796",
"0.6043906",
"0.6034662",
"0.60207325",
"0.6018568",
"0.6016575",
"0.60103434",
"0.60084206",
"0.600763",
"0.6007443",
"0.6003619",
"0.6003619",
"0.5995791",
"0.5993301",
"0.5993231",
"0.5984926",
"0.597122",
"0.5968121",
"0.5965808",
"0.59640145",
"0.59632224",
"0.59602356",
"0.59332967",
"0.5927556",
"0.5922805",
"0.5909745",
"0.5905083",
"0.5904304",
"0.5893434",
"0.58888215",
"0.58823985",
"0.58823985",
"0.58823985",
"0.5873434",
"0.58619875",
"0.58533794",
"0.5845531",
"0.58426666",
"0.58360124",
"0.583218",
"0.5828041",
"0.5827927",
"0.5816121",
"0.5814705",
"0.5812719",
"0.581121",
"0.5803423",
"0.5803423",
"0.57995003",
"0.5794207",
"0.5784923",
"0.5781365",
"0.5776385",
"0.5774859",
"0.57671493",
"0.5766998",
"0.57618684",
"0.5758038"
] | 0.0 | -1 |
GET /subscriptions GET /subscriptions.json | def index
@subscriptions = Subscription.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscriptions\n url = url_with_api_version(@base_url, 'subscriptions')\n resp = rest_get(url)\n JSON.parse(resp.body)[\"value\"]\n end",
"def all_subscriptions\n get(url_(\"subscription\"))\n end",
"def list_subscriptions(user)\n get(\"/#{user}/lists/subscriptions.json\")\n end",
"def list_my_subscriptions() path = \"/api/v2/utilities/subscriptions\"\n get(path, {}, AvaTax::VERSION) end",
"def user_vendor_subscriptions\n get(\"/api/v1/oauth_user_vendor_subscriptions.json\")\n end",
"def index\n @subscriptions = current_user.subscriptions.order(:created_at)\n @user = current_user\n\n if not current_user.fitbit.nil?\n begin\n @fitbit_subscriptions = JSON.parse(current_user.fitbit.client.get('/1/user/-/apiSubscriptions.json').body)['apiSubscriptions']\n rescue SocketError\n logger.error \"Can not talk to fitbit\"\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\n end\n end",
"def list_subscription\n response = Faraday.get(@subscription_api_url)\n response_json = JSON.parse(response.body)\n fix_response(response_json)\n end",
"def subscriptions( params={} )\n subscriptions = get_connections(\"subscriptions\", params)\n return map_connections subscriptions, :to => Facebook::Graph::Subscription\n end",
"def index\r\n @subscriptions = current_business_user.subscriptions.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @subscriptions }\r\n end\r\n end",
"def index\n @subscriptions = Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\n end\n end",
"def show\n @subscription = current_user.subscriptions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @subscription = current_user.subscriptions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def get_subscriptions(opts = {})\n data, _status_code, _headers = get_subscriptions_with_http_info(opts)\n return data\n end",
"def list_subscriptions(options = {})\n api.graph_call(subscription_path, {}, \"get\", options)\n end",
"def get_subscriptions(id:, order: nil)\n if order\n get_json(\"#{endpoint}/subscribers/#{uri_encode(id)}/subscriptions?order=#{uri_encode(order)}\")\n else\n get_json(\"#{endpoint}/subscribers/#{uri_encode(id)}/subscriptions\")\n end\n end",
"def get_subscriptions(id:, order: nil)\n if order\n get_json(\"#{endpoint}/subscribers/#{uri_encode(id)}/subscriptions?order=#{uri_encode(order)}\")\n else\n get_json(\"#{endpoint}/subscribers/#{uri_encode(id)}/subscriptions\")\n end\n end",
"def index\n @subscriptions = current_user.subscriptions.all\n end",
"def index\n @api_subscriptions = Api::Subscription.all\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 :organization_key => HttpClient::Preconditions.assert_class_or_nil('organization_key', opts.delete(:organization_key), String),\n :user_guid => HttpClient::Preconditions.assert_class_or_nil('user_guid', HttpClient::Helper.to_uuid(opts.delete(:user_guid)), String),\n :publication => HttpClient::Preconditions.assert_class_or_nil('publication', opts[:publication].nil? ? nil : (opts[:publication].is_a?(Apidoc::Models::Publication) ? opts.delete(:publication) : Apidoc::Models::Publication.apply(opts.delete(:publication))), Apidoc::Models::Publication),\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(\"/subscriptions\").with_query(query).get.map { |hash| Apidoc::Models::Subscription.new(hash) }\n end",
"def subscriptions\n @subscriptions ||= begin\n resp = @client.access_token.get('/reader/api/0/subscription/list?output=json')\n raise \"unable to retrieve the list of subscription for user \\\"#{user_id}\\\": #{resp.inspect}\" unless resp.code_type == Net::HTTPOK\n JSON.parse(resp.body)['subscriptions'].collect do |hash|\n Google::Reader::Subscription.new(hash.merge({:client => @client}))\n end\n end\n end",
"def index\n if params[:client_id].blank?\n @subscriptions = Subscription.all\n else\n @subscriptions = Client.find(params[:client_id]).subscriptions\n end\n end",
"def list_subs\n \t@subs = instagram_client.subscriptions\n end",
"def index\n @my_subscriptions = current_user.active_subscriptions\n end",
"def subscriptions\n @subscriptions ||= {}\n end",
"def subscriptions(page = 1)\n Dropio::Resource.client.subscriptions(self, page)\n end",
"def subscriptions\n update_subscriptions(params[:types]) if params[:types]\n @types = build_notification_types\n render :json => @types\n end",
"def index\n\n @category_subscriptions = CategorySubscription.all\n\n render json: @category_subscriptions\n\n end",
"def show\n @subscription = Subscription.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def index\n @subscriptions = Subscription.where(:binder_id => params[:binder_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\n end\n end",
"def get_all_subscriptions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SubscriptionsApi.get_all_subscriptions ...\"\n end\n # resource path\n local_var_path = \"/subscriptions\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'uid'] = opts[:'uid'] if !opts[:'uid'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['artikcloud_oauth']\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 => 'SubscriptionsEnvelope')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SubscriptionsApi#get_all_subscriptions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\r\n @subscription = Subscription.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @subscription }\r\n end\r\n end",
"def user_subscriptions(user_id, options={})\n response = connection.get do |req|\n req.url \"/user/#{user_id}/subscriptions\", simple_params(options)\n end\n response.body\n end",
"def subscriptions(user_id)\n response = rest_client.get(signature_url(\"/subscription/?user_id=#{user_id}\"))\n process_response(response)\n end",
"def list_subscriptions options = {}\n paged_enum = subscriber.list_subscriptions project: project_path(options),\n page_size: options[:max],\n page_token: options[:token]\n\n paged_enum.response\n end",
"def index\n if is_client_app?\n if params[:user_id].present?\n t = Subscription.arel_table\n s = Subscription.statuses\n @subscriptions = Subscription.where(user_id: params[:user_id]).where(t[:status].eq(s[:authorized]).or(t[:status].eq(s[:paused])))\n else\n @subscriptions = Subscription.all\n end\n\n render json: @subscriptions\n else\n response.headers['X-Total-Count'] = @subscriptions.count.to_s\n @subscriptions = @subscriptions.page(params[:page]) if params[:page].present?\n @subscriptions = @subscriptions.per(params[:per]) if params[:per].present?\n\n _render collection: @subscriptions, flag: params[:flag].try(:to_sym)\n end\n end",
"def show\n json_response(@user_subscription)\n end",
"def index\n @crytosubscriptions = Crytosubscription.all\n end",
"def get_subscriptions\n get_subscriptions_from(@nodename)\n end",
"def index\n @q = ::Pushar::Core::Subscription.unscoped.search(params[:q])\n @q.sorts = 'created_at desc' if @q.sorts.empty?\n @subscriptions = @q.result(distinct: true).page(params[:page]).per(50)\n end",
"def getAllSubscriptions\n if @subscriptionLists.hasKey(\"subscriptions\")\n return @subscriptionLists.getRepositoryObject(\"subscriptions\").getObject\n end\n end",
"def get_subscriptions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SubscriptionApi.get_subscriptions ...\"\n end\n if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 10000000\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling SubscriptionApi.get_subscriptions, must be smaller than or equal to 10000000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling SubscriptionApi.get_subscriptions, must be greater than or equal to 1.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'size'].nil? && opts[:'size'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"size\"]\" when calling SubscriptionApi.get_subscriptions, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'size'].nil? && opts[:'size'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"size\"]\" when calling SubscriptionApi.get_subscriptions, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = \"/v1/subscription\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['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 => 'SubscriptionSearch')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SubscriptionApi#get_subscriptions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def subscriptions\n\t\t@subscriptions = current_user.customer.subjects\n\tend",
"def index\n @subscriptions = nil #the load_and_authorize_resource cancan method is loading all the subscriptions and we want to start with a clean slate here.\n if params[:company_id]\n @owner = Company.find(params[:company_id])\n @subscriptions = Subscription.where(owner_type: 'Company', owner_id: params[:company_id])\n end\n if params[:person_id]\n @owner = Person.find(params[:person_id])\n @subscriptions ||= Subscription.where(owner_type: 'Person', owner_id: params[:person_id])\n end\n \n @subscriptions ||= Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\n end\n end",
"def subscriptions\n ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Subscription)\n end",
"def subscription_info(subscription_id = @subscription_id)\n url = url_with_api_version(@base_url, 'subscriptions', subscription_id)\n resp = rest_get(url)\n JSON.parse(resp.body)\n end",
"def index\n @subscriptions = @user.subscriptions.order(updated_at: :desc)\n end",
"def get_subscription(subscription_id)\n get(url_(\"subscription\", subscription_id))\n end",
"def index\n\n if @notification\n json_response(@notification.user_subscriptions)\n end\n if request.path_parameters.has_key?(:user_id)\n json_response(@user.user_subscriptions)\n end\n end",
"def index\n @subscriptions = Subscription.all\nend",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def index\n session[:sub_delete_return_to] = request.fullpath\n @subscriptions = Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\n end\n end",
"def subscription\n ret = nil\n if type == 'S'\n ret = @mc2p.subscription('id' => @json_body['id'])\n ret.retrieve\n end\n ret\n end",
"def subscriptions\n @subscriptions ||= get_roster || {}\n end",
"def index\n @panel_subscriptions = Panel::Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @panel_subscriptions }\n end\n end",
"def index\n @subscriptions = @screen.subscriptions.all\n auth!\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subscriptions }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @subscription }\n end\n end",
"def show\n @list_subscription = ListSubscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list_subscription }\n end\n end",
"def get_subscription subscription_name, options = {}\n subscriber.get_subscription subscription: subscription_path(subscription_name, options)\n end",
"def new\n @subscription = current_user.subscriptions.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subscription }\n end\n end",
"def subscription(repo, options = {})\n get \"#{Repository.path repo}/subscription\", options\n end",
"def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end",
"def index\n @admin_subscriptions = Subscription.all\n end",
"def subscriptions\n iq = connection.iq_stanza({'to'=>jid.bare},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSubOwner},\n x('subscriptions',:node => node_id)\n )\n )\n send_iq_stanza_fibered iq\n end",
"def index\n @subscriptions = Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subscriptions }\n end\n end",
"def index\n @subscriptions = Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subscriptions }\n end\n end",
"def index\n\t\tindex_\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @subscriptions }\n\t\tend\n\tend",
"def service_subscriptions\n iq = connection.iq_stanza({'to'=>jid.bare},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSub},\n x('subscriptions')\n )\n )\n send_iq_stanza_fibered iq\n end",
"def subscriptions()\n return MicrosoftGraph::Subscriptions::SubscriptionsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def subscribe\n Socky.send( {:action => \"subscribe\",\n :channel => params[:channel],\n :client => (params[:client_id] || '')}.to_json)\n render :text => \"ok\"\n end",
"def all_subscriptions(&block)\n subscriptions.list(&block)\n end",
"def subscription(options = {})\n Subscription.new(options.merge(:url => url)).to_hash\n end",
"def index\n @vendor_subscriptions = VendorSubscription.all\n end",
"def subscriber_list(statuspage_id)\n request :method => :get,\n :url => @url + 'subscriber/list/' + statuspage_id\n end",
"def subscription\n Zapi::Models::Subscription.new\n end",
"def subscribed(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Recipients/Subscribed\", params: params)\n end",
"def subscriptions; end",
"def subscriptions; end",
"def subscriptions; end",
"def index\n if @view = params[:view].allow(ALLOWED_VIEW)\n unless @subscriptions = Subscription.try(@view)\n raise_404\n end\n else\n @subscriptions = Subscription.all\n end\n end",
"def subscription(id)\n Sensit::Api::Subscription.new id, @http_client\n end",
"def index\n @subscriptions = current_user.subscriptions.select{|s| s.manga !=nil && s.manga.display_name != nil && s.manga.name!=nil}.sort_by{|s| s.manga.display_name}\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\n end\n end",
"def subscriptions\n @channels\n end",
"def index\n @misuration_subscriptions = current_user.misuration_subscriptions.all\n end",
"def index\n @subscriptions = @screen.subscriptions.where(field_id: @field.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @subscriptions }\n end\n end",
"def subscriptions\n # subscriber entries are embedded in subscriptions inside of an\n # org. We'll flip this, so that we only return subscriber entries\n # for the account\n orgs = Org.all(:conditions=>{ \"subscriptions.subscribers.account_id\"=> self.id})\n subscribers = []\n orgs.each do |org|\n org.subscriptions.each do |subscription|\n subscribers += subscription.subscribers.select { |subscriber| subscriber.account_id.to_s == self.id.to_s }\n end\n end\n subscribers.flatten!\n subs = []\n subscribers.each do |subscriber|\n subscript = subscriber.subscription\n org = subscript.org\n subs << AccountSubscription.new(org.id.to_s, org.name, subscript.product, subscript.billing_level, subscriber.role)\n end\n subs\n end",
"def list_topics_subscriptions topic, options = {}\n publisher.list_topic_subscriptions topic: topic_path(topic, options),\n page_size: options[:max],\n page_token: options[:token]\n end",
"def all\n get(\"#{domain}/unsubscribes\")\n end",
"def index\n @user_to_channel_subscriptions = UserToChannelSubscription.all\n end",
"def get_subscription\n @subscriptions = Subscription.all\n @my_subscription = current_user.user_subscriptions.includes(:subscription).where(\"user_subscriptions.id = ? and user_subscriptions.status = ?\", params[:id], \"active\").first\n\n if @my_subscription.blank?\n\n respond_to do |format|\n format.html{ flash[:error] = \"Sorry, You are not authorized for this subscription.\" }\n format.js{ render js: %{location.reload();} }\n end\n\n redirect_to main_app.profile_users_path and return\n end\n\n end",
"def get_all_subscriptions(opts = {})\n data, _status_code, _headers = get_all_subscriptions_with_http_info(opts)\n return data\n end",
"def subscribed_subreddits(options = {})\n options = options.clone\n\n category = options[:category] or 'subscriber'\n path = \"subreddits/mine/#{category}.json\"\n options.delete :category\n\n objects_from_response(:get, path, options)\n end",
"def subscriber(id_or_email)\n make_json_api_request :get, \"v2/#{account_id}/subscribers/#{CGI.escape id_or_email}\"\n end",
"def get(subscription_key)\n args = ZAPIArgs.new\n args.uri = Resource_Endpoints::GET_SUBSCRIPTION.gsub(\"{subscription-key}\", ERB::Util.url_encode(subscription_key))\n\n puts \"========== GET A SUBSCRIPTION ============\"\n\n begin\n @z_client.get(args) do |resp|\n ap resp\n return resp if resp.httpStatusCode.to_i == 200 && resp.success\n end\n rescue ArgumentError => e\n puts e.message\n rescue RuntimeError => e\n puts e.message\n end\n\n nil\n end",
"def index\n @category_subscriptions = CategorySubscription.all\n end"
] | [
"0.8179333",
"0.80743414",
"0.7945015",
"0.7691383",
"0.7650296",
"0.758197",
"0.7512477",
"0.74939454",
"0.7430707",
"0.74138576",
"0.7406093",
"0.7406093",
"0.7406041",
"0.7387691",
"0.7374919",
"0.7374919",
"0.7365163",
"0.7320913",
"0.7300906",
"0.7266754",
"0.72661877",
"0.71958923",
"0.7184",
"0.7106231",
"0.7096005",
"0.70795166",
"0.7072021",
"0.7031293",
"0.7025373",
"0.7025373",
"0.7025373",
"0.7025373",
"0.7019644",
"0.7018017",
"0.7016331",
"0.70006377",
"0.69888353",
"0.69850427",
"0.6975847",
"0.6973235",
"0.6949478",
"0.6939306",
"0.6936244",
"0.6907129",
"0.68940026",
"0.68872774",
"0.6885926",
"0.6857466",
"0.6845652",
"0.68400306",
"0.68222594",
"0.6817309",
"0.6812091",
"0.68110806",
"0.68034214",
"0.6746401",
"0.67420435",
"0.672124",
"0.6717644",
"0.6698077",
"0.6674296",
"0.66741604",
"0.6645112",
"0.6638774",
"0.6633938",
"0.6624758",
"0.6606791",
"0.6599121",
"0.6599121",
"0.6588843",
"0.6588654",
"0.6576305",
"0.6573508",
"0.65670544",
"0.6550187",
"0.65425676",
"0.65267736",
"0.6519686",
"0.65185183",
"0.65059537",
"0.65059537",
"0.65059537",
"0.6495356",
"0.6491172",
"0.64726776",
"0.64703363",
"0.6467376",
"0.6466498",
"0.64652306",
"0.6450026",
"0.64387006",
"0.6434886",
"0.6428663",
"0.6406863",
"0.64038694",
"0.63811713",
"0.63795364",
"0.6373219"
] | 0.7114169 | 25 |
GET /subscriptions/1 GET /subscriptions/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscriptions\n url = url_with_api_version(@base_url, 'subscriptions')\n resp = rest_get(url)\n JSON.parse(resp.body)[\"value\"]\n end",
"def show\n @subscription = current_user.subscriptions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @subscription = current_user.subscriptions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def list_subscriptions(user)\n get(\"/#{user}/lists/subscriptions.json\")\n end",
"def all_subscriptions\n get(url_(\"subscription\"))\n end",
"def list_my_subscriptions() path = \"/api/v2/utilities/subscriptions\"\n get(path, {}, AvaTax::VERSION) end",
"def index\n @subscriptions = current_user.subscriptions.order(:created_at)\n @user = current_user\n\n if not current_user.fitbit.nil?\n begin\n @fitbit_subscriptions = JSON.parse(current_user.fitbit.client.get('/1/user/-/apiSubscriptions.json').body)['apiSubscriptions']\n rescue SocketError\n logger.error \"Can not talk to fitbit\"\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\n end\n end",
"def get_subscriptions(id:, order: nil)\n if order\n get_json(\"#{endpoint}/subscribers/#{uri_encode(id)}/subscriptions?order=#{uri_encode(order)}\")\n else\n get_json(\"#{endpoint}/subscribers/#{uri_encode(id)}/subscriptions\")\n end\n end",
"def get_subscriptions(id:, order: nil)\n if order\n get_json(\"#{endpoint}/subscribers/#{uri_encode(id)}/subscriptions?order=#{uri_encode(order)}\")\n else\n get_json(\"#{endpoint}/subscribers/#{uri_encode(id)}/subscriptions\")\n end\n end",
"def user_vendor_subscriptions\n get(\"/api/v1/oauth_user_vendor_subscriptions.json\")\n end",
"def show\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @subscription = Subscription.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\r\n @subscription = Subscription.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @subscription }\r\n end\r\n end",
"def index\n if params[:client_id].blank?\n @subscriptions = Subscription.all\n else\n @subscriptions = Client.find(params[:client_id]).subscriptions\n end\n end",
"def index\n @subscriptions = Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\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 :organization_key => HttpClient::Preconditions.assert_class_or_nil('organization_key', opts.delete(:organization_key), String),\n :user_guid => HttpClient::Preconditions.assert_class_or_nil('user_guid', HttpClient::Helper.to_uuid(opts.delete(:user_guid)), String),\n :publication => HttpClient::Preconditions.assert_class_or_nil('publication', opts[:publication].nil? ? nil : (opts[:publication].is_a?(Apidoc::Models::Publication) ? opts.delete(:publication) : Apidoc::Models::Publication.apply(opts.delete(:publication))), Apidoc::Models::Publication),\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(\"/subscriptions\").with_query(query).get.map { |hash| Apidoc::Models::Subscription.new(hash) }\n end",
"def index\r\n @subscriptions = current_business_user.subscriptions.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @subscriptions }\r\n end\r\n end",
"def get_subscription(subscription_id)\n get(url_(\"subscription\", subscription_id))\n end",
"def index\n @api_subscriptions = Api::Subscription.all\n end",
"def subscription\n ret = nil\n if type == 'S'\n ret = @mc2p.subscription('id' => @json_body['id'])\n ret.retrieve\n end\n ret\n end",
"def show\n json_response(@user_subscription)\n end",
"def index\n @subscriptions = current_user.subscriptions.all\n end",
"def list_subscription\n response = Faraday.get(@subscription_api_url)\n response_json = JSON.parse(response.body)\n fix_response(response_json)\n end",
"def index\n @my_subscriptions = current_user.active_subscriptions\n end",
"def index\n @subscriptions = Subscription.where(:binder_id => params[:binder_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription }\n end\n end",
"def subscriptions( params={} )\n subscriptions = get_connections(\"subscriptions\", params)\n return map_connections subscriptions, :to => Facebook::Graph::Subscription\n end",
"def index\n @subscriptions = Subscription.all\n end",
"def index\n @subscriptions = Subscription.all\n end",
"def index\n @subscriptions = Subscription.all\n end",
"def get_subscription subscription_name, options = {}\n subscriber.get_subscription subscription: subscription_path(subscription_name, options)\n end",
"def list_subs\n \t@subs = instagram_client.subscriptions\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @subscription }\n end\n end",
"def subscription_info(subscription_id = @subscription_id)\n url = url_with_api_version(@base_url, 'subscriptions', subscription_id)\n resp = rest_get(url)\n JSON.parse(resp.body)\n end",
"def subscriptions(page = 1)\n Dropio::Resource.client.subscriptions(self, page)\n end",
"def show_single_webhook_subscription(id,opts={})\n query_param_keys = [\n \n\n ]\n\n form_param_keys = [\n \n\n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id\n\n )\n\n # resource path\n path = path_replace(\"/lti/subscriptions/{id}\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_query_params(options, query_param_keys)\n\n response = mixed_request(:get, path, query_params, form_params, headers)\n response\n \n\n end",
"def new\n @subscription = current_user.subscriptions.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subscription }\n end\n end",
"def show\n @list_subscription = ListSubscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list_subscription }\n end\n end",
"def subscriptions\n update_subscriptions(params[:types]) if params[:types]\n @types = build_notification_types\n render :json => @types\n end",
"def subscriptions(user_id)\n response = rest_client.get(signature_url(\"/subscription/?user_id=#{user_id}\"))\n process_response(response)\n end",
"def index\n @crytosubscriptions = Crytosubscription.all\n end",
"def index\n\n @category_subscriptions = CategorySubscription.all\n\n render json: @category_subscriptions\n\n end",
"def index\n\n if @notification\n json_response(@notification.user_subscriptions)\n end\n if request.path_parameters.has_key?(:user_id)\n json_response(@user.user_subscriptions)\n end\n end",
"def subscription(id)\n Sensit::Api::Subscription.new id, @http_client\n end",
"def subscription\n Zapi::Models::Subscription.new\n end",
"def subscribe\n Socky.send( {:action => \"subscribe\",\n :channel => params[:channel],\n :client => (params[:client_id] || '')}.to_json)\n render :text => \"ok\"\n end",
"def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end",
"def index\n session[:sub_delete_return_to] = request.fullpath\n @subscriptions = Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\n end\n end",
"def list_subscriptions(options = {})\n api.graph_call(subscription_path, {}, \"get\", options)\n end",
"def index\n if is_client_app?\n if params[:user_id].present?\n t = Subscription.arel_table\n s = Subscription.statuses\n @subscriptions = Subscription.where(user_id: params[:user_id]).where(t[:status].eq(s[:authorized]).or(t[:status].eq(s[:paused])))\n else\n @subscriptions = Subscription.all\n end\n\n render json: @subscriptions\n else\n response.headers['X-Total-Count'] = @subscriptions.count.to_s\n @subscriptions = @subscriptions.page(params[:page]) if params[:page].present?\n @subscriptions = @subscriptions.per(params[:per]) if params[:per].present?\n\n _render collection: @subscriptions, flag: params[:flag].try(:to_sym)\n end\n end",
"def subscriptions\n @subscriptions ||= {}\n end",
"def get_subscriptions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SubscriptionApi.get_subscriptions ...\"\n end\n if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 10000000\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling SubscriptionApi.get_subscriptions, must be smaller than or equal to 10000000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling SubscriptionApi.get_subscriptions, must be greater than or equal to 1.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'size'].nil? && opts[:'size'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"size\"]\" when calling SubscriptionApi.get_subscriptions, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'size'].nil? && opts[:'size'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"size\"]\" when calling SubscriptionApi.get_subscriptions, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = \"/v1/subscription\"\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['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 => 'SubscriptionSearch')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SubscriptionApi#get_subscriptions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_all_subscriptions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SubscriptionsApi.get_all_subscriptions ...\"\n end\n # resource path\n local_var_path = \"/subscriptions\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'uid'] = opts[:'uid'] if !opts[:'uid'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['artikcloud_oauth']\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 => 'SubscriptionsEnvelope')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SubscriptionsApi#get_all_subscriptions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @subscription_request = SubscriptionRequest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscription_request }\n end\n end",
"def index\n @subscriptions = Subscription.all\nend",
"def subscriptions\n @subscriptions ||= begin\n resp = @client.access_token.get('/reader/api/0/subscription/list?output=json')\n raise \"unable to retrieve the list of subscription for user \\\"#{user_id}\\\": #{resp.inspect}\" unless resp.code_type == Net::HTTPOK\n JSON.parse(resp.body)['subscriptions'].collect do |hash|\n Google::Reader::Subscription.new(hash.merge({:client => @client}))\n end\n end\n end",
"def get(subscription_key)\n args = ZAPIArgs.new\n args.uri = Resource_Endpoints::GET_SUBSCRIPTION.gsub(\"{subscription-key}\", ERB::Util.url_encode(subscription_key))\n\n puts \"========== GET A SUBSCRIPTION ============\"\n\n begin\n @z_client.get(args) do |resp|\n ap resp\n return resp if resp.httpStatusCode.to_i == 200 && resp.success\n end\n rescue ArgumentError => e\n puts e.message\n rescue RuntimeError => e\n puts e.message\n end\n\n nil\n end",
"def user_subscriptions(user_id, options={})\n response = connection.get do |req|\n req.url \"/user/#{user_id}/subscriptions\", simple_params(options)\n end\n response.body\n end",
"def index\n @subscriptions = @user.subscriptions.order(updated_at: :desc)\n end",
"def get_subscription\n @subscriptions = Subscription.all\n @my_subscription = current_user.user_subscriptions.includes(:subscription).where(\"user_subscriptions.id = ? and user_subscriptions.status = ?\", params[:id], \"active\").first\n\n if @my_subscription.blank?\n\n respond_to do |format|\n format.html{ flash[:error] = \"Sorry, You are not authorized for this subscription.\" }\n format.js{ render js: %{location.reload();} }\n end\n\n redirect_to main_app.profile_users_path and return\n end\n\n end",
"def retrieve_subscription(subscription_id:,\n include: nil)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::GET,\n '/v2/subscriptions/{subscription_id}',\n 'default')\n .template_param(new_parameter(subscription_id, key: 'subscription_id')\n .should_encode(true))\n .query_param(new_parameter(include, key: 'include'))\n .header_param(new_parameter('application/json', key: 'accept'))\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def get_subscriptions\n get_subscriptions_from(@nodename)\n end",
"def subscription(repo, options = {})\n get \"#{Repository.path repo}/subscription\", options\n end",
"def index\n @panel_subscriptions = Panel::Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @panel_subscriptions }\n end\n end",
"def index\n @subscriptions = nil #the load_and_authorize_resource cancan method is loading all the subscriptions and we want to start with a clean slate here.\n if params[:company_id]\n @owner = Company.find(params[:company_id])\n @subscriptions = Subscription.where(owner_type: 'Company', owner_id: params[:company_id])\n end\n if params[:person_id]\n @owner = Person.find(params[:person_id])\n @subscriptions ||= Subscription.where(owner_type: 'Person', owner_id: params[:person_id])\n end\n \n @subscriptions ||= Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subscriptions }\n end\n end",
"def get_subscriptions(opts = {})\n data, _status_code, _headers = get_subscriptions_with_http_info(opts)\n return data\n end",
"def index\n @q = ::Pushar::Core::Subscription.unscoped.search(params[:q])\n @q.sorts = 'created_at desc' if @q.sorts.empty?\n @subscriptions = @q.result(distinct: true).page(params[:page]).per(50)\n end",
"def show\n @subscriber = Subscriber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscriber }\n end\n end",
"def show\n @subscriber = Subscriber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscriber }\n end\n end",
"def show\n @subscriber = Subscriber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscriber }\n end\n end",
"def show\n\n @subscriber = Subscriber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subscriber }\n end\n end",
"def subscription\n subscriptions.last\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 @subscriptions = Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subscriptions }\n end\n end",
"def index\n @subscriptions = Subscription.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subscriptions }\n end\n end",
"def new\r\n @subscription = Subscription.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @subscription }\r\n end\r\n end",
"def index\n @subscriptions = @screen.subscriptions.all\n auth!\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @subscriptions }\n end\n end",
"def subscriber_list(statuspage_id)\n request :method => :get,\n :url => @url + 'subscriber/list/' + statuspage_id\n end",
"def index\n @subscriptions = @screen.subscriptions.where(field_id: @field.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @subscriptions }\n end\n end",
"def subscriber(id_or_email)\n make_json_api_request :get, \"v2/#{account_id}/subscribers/#{CGI.escape id_or_email}\"\n end",
"def show\n @subscription = Subscription.find(params[:id])\n @product_subscription = ProductSubscription.new\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @subscription }\n end\n end",
"def show\n @panel_subscription = Panel::Subscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @panel_subscription }\n end\n end",
"def new\n @subscription = Subscription.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subscription }\n end\n end",
"def new\n @subscription = Subscription.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subscription }\n end\n end",
"def new\n @subscription = Subscription.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subscription }\n end\n end",
"def new\n @subscription = Subscription.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subscription }\n end\n end",
"def new\n @subscription = Subscription.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subscription }\n end\n end",
"def subscription(options = {})\n Subscription.new(options.merge(:url => url)).to_hash\n end",
"def subscriptions; end",
"def subscriptions; end",
"def subscriptions; end",
"def index\n @admin_subscriptions = Subscription.all\n end",
"def show\n @product_subscription = ProductSubscription.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_subscription }\n end\n end",
"def new\n @subscription = Subscription.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @subscription }\n end\n end",
"def show\n render json: @event_subscription\n end",
"def index\n\t\tindex_\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @subscriptions }\n\t\tend\n\tend",
"def getAllSubscriptions\n if @subscriptionLists.hasKey(\"subscriptions\")\n return @subscriptionLists.getRepositoryObject(\"subscriptions\").getObject\n end\n end",
"def fetch_subscription(_params) \n subscription_id = _params['subscription_id']\n if subscription_id.blank? == true \n return false\n end \n begin\n result = ChargeBee::Subscription.retrieve(subscription_id)\n session[:subscription_id] = result.subscription.id\n session[:customer_id] = result.customer.id\n return true\n rescue ChargeBee::APIError => e\n if e.api_error_code == \"resource_not_found\"\n return false\n end\n throw e\n end\n end"
] | [
"0.7861968",
"0.75837445",
"0.75837445",
"0.75720704",
"0.75669205",
"0.74484855",
"0.73489445",
"0.7335316",
"0.7335316",
"0.7256615",
"0.7242413",
"0.7242413",
"0.7242413",
"0.7242413",
"0.7234326",
"0.7231307",
"0.7203007",
"0.7198185",
"0.7190798",
"0.71879846",
"0.71845037",
"0.7112767",
"0.7092921",
"0.70831174",
"0.705916",
"0.6973441",
"0.69704753",
"0.69638747",
"0.6962186",
"0.69037825",
"0.6899183",
"0.6899183",
"0.6899183",
"0.68930566",
"0.6874643",
"0.68634206",
"0.685618",
"0.6854532",
"0.68500227",
"0.6823275",
"0.6820894",
"0.6818846",
"0.67801803",
"0.6779472",
"0.6763143",
"0.67616194",
"0.67422765",
"0.67421204",
"0.6733953",
"0.6725104",
"0.67236733",
"0.669295",
"0.6690468",
"0.6688097",
"0.6682883",
"0.6681368",
"0.6680384",
"0.6670703",
"0.66680336",
"0.66488606",
"0.66453123",
"0.6644094",
"0.66199774",
"0.66178787",
"0.66086453",
"0.66000104",
"0.65642655",
"0.65627176",
"0.6562331",
"0.65246385",
"0.6509309",
"0.6509309",
"0.6509309",
"0.6508349",
"0.6493997",
"0.6482886",
"0.6481314",
"0.6481314",
"0.64782554",
"0.64700174",
"0.6460649",
"0.6456938",
"0.64559186",
"0.64492154",
"0.64486593",
"0.64484245",
"0.64484245",
"0.64484245",
"0.64484245",
"0.64484245",
"0.64381456",
"0.6434642",
"0.6434642",
"0.6434642",
"0.6428576",
"0.6425105",
"0.64228594",
"0.64201427",
"0.64074135",
"0.64002955",
"0.6393935"
] | 0.0 | -1 |
POST /subscriptions POST /subscriptions.json 127.0.0.1:3000/subscriptions/update | def toggle
# put user_id business_id in params
user = User.where(:unique_id => params[:device_id])
if user.empty?
user = User.new(:unique_id => params[:device_id])
user.save
else
user = user.first #WHERE RETURNS AN ARRAY
end
user_id = user.id
@subscription = Subscription.where(:business_id => params[:business_id], :user_id => user_id)
if @subscription.empty?
@subscription = Subscription.new(:business_id => params[:business_id], :user_id => user_id)
@subscription.save
render :json => "subscribed"
else
@subscription.first.destroy
render :json => "unsubscribed"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @subscription = Subscription.find(params[:id])\n\n if @subscription.update(subscription_params)\n head :no_content\n else\n render json: @subscription.errors, status: :unprocessable_entity\n end\n end",
"def update\n @subscription = Subscription.get(params[:id])\n @subscription.update(params[:subscription])\n respond_with(@subscription.reload)\n end",
"def create / update_subscriptions\n end",
"def update\n @subscription = current_user.subscriptions.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to @subscription, notice: 'Subscription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n # TODO: Modify subscription (refund remainder of current, prorate new)\n \n respond_to do |format|\n if @subscription.update(subscription_params)\n format.html { redirect_to subscriptions_url, success: 'Subscription was successfully updated.' }\n format.json { head :no_content }\n format.js { redirect_to subscriptions_url, :format => :html, success: 'Subscription was successfully updated.' }\n else\n format.html { render action: 'edit' }\n format.js { render action: 'edit' }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n flash[:success] = \"Subscription was successfully updated.\"\n format.html { redirect_to @subscription }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to @subscription, notice: 'Subscription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to @subscription, notice: 'Subscription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to @subscription, notice: 'Subscription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscription.update(subscription_params)\n format.html { redirect_to @subscription, notice: (I18n.t :subscription_updated) }\n format.json { render :show, status: :ok, location: @subscription }\n else\n format.html { render :edit }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to @subscription.owner, notice: 'Subscription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @subscription = Subscription.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @subscription.update_attributes(subscription_params)\r\n format.html { redirect_to business_user_subscriptions_path, notice: 'Subscription was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @subscription.update(subscription_params)\n format.html { redirect_to @subscription, notice: 'Subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscription }\n else\n format.html { render :edit }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscription.update(subscription_params)\n format.html { redirect_to @subscription, notice: 'Subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscription }\n else\n format.html { render :edit }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to @subscription.layer, notice: 'Subscription updated OK' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription.assign_attributes(subscription_params)\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to @subscription, notice: t('controller.successfully_updated', model: t('activerecord.models.subscription')) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_subscription.update(api_subscription_params)\n format.html { redirect_to @api_subscription, notice: 'Subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_subscription }\n else\n format.html { render :edit }\n format.json { render json: @api_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n \n respond_to do |format|\n \n \n if @subscription.update_attributes(params[:subscription])\n flash[:notice] = 'Subscription was successfully updated.'\n format.html { redirect_to(@subscription) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@subscription = Subscription.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tif @subscription.update_attributes(params[:subscription])\n\t\t\t\tflash[:notice] = 'Subscription was successfully updated.'\n\t\t\t\tshow_\n\t\t\t\tformat.html { render :action => \"show\" }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\t@ingroups = Group.all\n\t\t\t\t@inprojects = Project.all\n\t\t\t\t@fortypesobjects=Typesobject.get_from_observer\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update_webhook_subscription(id,opts={})\n query_param_keys = [\n \n\n ]\n\n form_param_keys = [\n \n\n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id\n\n )\n\n # resource path\n path = path_replace(\"/lti/subscriptions/{id}\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_query_params(options, query_param_keys)\n\n response = mixed_request(:put, path, query_params, form_params, headers)\n response\n \n\n end",
"def update\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to(subscriptions_url, :notice => 'Subscription was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to campaign_subscriptions_path(@campaign), :notice => 'Subscription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n flash[:notice] = 'Subscription was successfully updated.'\n format.html { redirect_to(@subscription) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to(@subscription, :notice => 'Subscription was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to @subscription.transaction, notice: 'Subscription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription = Subscription.find(params[:id])\n auth!\n\n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to(manage_screen_field_subscriptions_path(@screen, @field), :notice => t(:subscription_updated)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if session[:user_id] \n @subscription = Subscription.find(params[:id])\n \n respond_to do |format|\n if @subscription.update_attributes(params[:subscription])\n format.html { redirect_to(@subscription, :notice => 'Subscription was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def update\n @subscription = Subscription.by_user_channel_ids(current_user.id, params[:channel_id])\n\n respond_to do |format|\n if @subscription and @subscription.update_attributes(params[:subscription])\n @channel = Channel.find(params[:channel_id])\n format.html { redirect_to @subscription, notice: I18n.t('subscription_updated') }\n format.json { render json: { name: @channel.subscription_name(current_user) }, status: :ok}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def subscription_update\n data = request.body.read\n @verified = verify_webhook(data, request)\n if @verified\n ReserveInventory.delay(:retry => false).update_reserve_inventory\n head :ok\n else\n head :error\n end\n end",
"def update\n @panel_subscription = Panel::Subscription.find(params[:id])\n respond_to do |format|\n if @panel_subscription.update_attributes(params[:panel_subscription])\n format.html { redirect_to(@panel_subscription, :notice => 'Subscription was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @panel_subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscription.update_with_author(subscription_params, current_user)\n record_activity :update, @subscription\n format.html { redirect_to @subscription, notice: 'Subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscription }\n else\n format.html { render :edit }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscribe.update(subscribe_params)\n format.html { redirect_to @subscribe, notice: 'Subscribe was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscribe }\n else\n format.html { render :edit }\n format.json { render json: @subscribe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscribe.update(subscribe_params)\n format.html { redirect_to @subscribe, notice: 'Subscribe was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscribe }\n else\n format.html { render :edit }\n format.json { render json: @subscribe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n@subscription = current_user.subscriptions.build(subscription_params)\n\nrespond_to do |format|\n if @subscription.save\n\n format.html { redirect_to users_profile_url(current_user.id), notice: 'Your pet was successfully created.' }\n format.json { render :show, status: :created, location: @subscription }\n else\n format.html { render :new }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n\nend\n\n# PATCH/PUT /subscriptions/1\n# PATCH/PUT /subscriptions/1.json\ndef update\nrespond_to do |format|\n if @subscription.update(subscription_params)\n format.html { redirect_to users_profile_url(current_user.id), notice: 'Your pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscription }\n else\n format.html { render :edit }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\nend\nend\n\n# DELETE /subscriptions/1\n# DELETE /subscriptions/1.json\ndef destroy\[email protected]\nrespond_to do |format|\n format.html { redirect_to :back, notice: 'Your pet was successfully destroyed.' }\n format.json { head :no_content }\nend\n\nprivate\n# Use callbacks to share common setup or constraints between actions.\ndef set_subscription\n @subscription = Subscription.find(params[:id])\nend\n\n# Never trust parameters from the scary internet, only allow the white list through.\ndef subscription_params\n params.require(:subscription).permit(:title, :company, :url, :start_time, :end_time, :phone_number, :time, :pet_name, :breed, :animal, :notes, :pet_image, :option_1, :option_2, :gender)\nend\n\ndef correct_user\n @subscriptions = current_user.subscriptions.find_by(id: params[:id])\n redirect_to users_profile_url, notice: \"Not authorized to edit this pet\" if @subscription.nil?\nend\n\nend\nend",
"def update_subscriptions(email, attrs = {})\n attrs['email'] = email\n Iterable.request(conf, '/users/updateSubscriptions').post(attrs)\n end",
"def update\nrespond_to do |format|\n if @subscription.update(subscription_params)\n format.html { redirect_to users_profile_url(current_user.id), notice: 'Your pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscription }\n else\n format.html { render :edit }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\nend\nend",
"def update\n @newsletter_subscription = NewsletterSubscription.find(params[:id])\n\n respond_to do |format|\n if @newsletter_subscription.update_attributes(params[:newsletter_subscription])\n format.html { redirect_to newsletter_subscriptions_path, notice: 'Subscription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @newsletter_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscribe.update(subscribe_params)\n format.html { redirect_to @subscribe, notice: t('controller.successfully_updated', model: t('activerecord.models.subscribe')) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscribe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscription_request = SubscriptionRequest.find(params[:id])\n\n respond_to do |format|\n if @subscription_request.update_attributes(params[:subscription_request])\n format.html { redirect_to @subscription_request, notice: 'Subscription request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscription_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscribe.update(subscribe_params)\n format.html {redirect_to @subscribe, notice: 'Subscribe was successfully updated.'}\n format.json {render json: @subscribe, status: :ok}\n else\n format.html {render :edit}\n format.json {render json: @subscribe.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update_subscription(subscription_id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/subscriptions/{subscription_id}',\n 'default')\n .template_param(new_parameter(subscription_id, key: 'subscription_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def update!(**args)\n @subscription = args[:subscription] if args.key?(:subscription)\n end",
"def update!(**args)\n @subscription = args[:subscription] if args.key?(:subscription)\n end",
"def update!(**args)\n @subscription = args[:subscription] if args.key?(:subscription)\n end",
"def update\n respond_to do |format|\n if @email_newsletter_subscription.update(email_newsletter_subscription_params)\n format.html { redirect_to @email_newsletter_subscription, notice: 'Email newsletter subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @email_newsletter_subscription }\n else\n format.html { render :edit }\n format.json { render json: @email_newsletter_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @list_subscription = ListSubscription.find(params[:id])\n\n respond_to do |format|\n if @list_subscription.update_attributes(params[:list_subscription])\n format.html { redirect_to @list_subscription, notice: 'List subscription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @list_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\nrespond_to do |format|\n if @subscription.update(subscription_params)\n format.html { redirect_to user_profile_url(current_user.id), notice: 'Pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscription }\n else\n format.html { render :edit }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\nend\nend",
"def update\n respond_to do |format|\n if @crytosubscription.update(crytosubscription_params)\n format.html { redirect_to @crytosubscription, notice: 'Thanks for seeking for expert Advice. You will hear from us.' }\n format.json { render :show, status: :ok, location: @crytosubscription }\n else\n format.html { render :edit }\n format.json { render json: @crytosubscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def stripe_customer_subscription_updated(event, req)\n subscription = event['data']['object']\n subs = Lynr::Model::Subscription.new({\n canceled_at: subscription['canceled_at'],\n plan: subscription['plan']['id'],\n status: subscription['status'],\n })\n dealership = dealer_dao.get_by_customer_id(subscription['customer']).set('subscription' => subs)\n dealer_dao.save(dealership)\n end",
"def update_webhook_subscription(subscription_id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/webhooks/subscriptions/{subscription_id}',\n 'default')\n .template_param(new_parameter(subscription_id, key: 'subscription_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def subscribe_to_updates\n if @subscription = @requestor.find_or_create_subscriptions(@target.id)\n @subscription.update_attributes(blocked: false) if @subscription.blocked?\n render json: { success: true }\n else\n render json: {message: @subscription.errors&.full_messages || 'Unable to subscriber updates, please try again'}, status: 202\n end\n end",
"def create\n s_params = params[:subscription]\n s_params.delete(:id)\n @subscription = Subscription.new(s_params)\n @subscription.save\n respond_with(@subscription)\n end",
"def update\n\n @subscription.subscribe(current_user.account, subscription_params[:stripe_plan_id], coupon: subscription_params[:coupon_code])\n\n if @subscription.save\n redirect_to @subscription, notice: 'Subscription was successfully updated.'\n else\n @verrors = @subscription.errors.full_messages\n render 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @user_to_channel_subscription.update(user_to_channel_subscription_params)\n format.html { redirect_to @user_to_channel_subscription, notice: 'User to channel subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_to_channel_subscription }\n else\n format.html { render :edit }\n format.json { render json: @user_to_channel_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n @service_subscription = ServiceSubscription.find(params[:id])\n \n respond_to do |format|\n if @service_subscription.update_attributes(params[:service_subscription])\n format.html { redirect_to(service_subscriptions_path, :notice => 'Your settings were successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @service_subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(subscription_form)\n HttpClient::Preconditions.assert_class('subscription_form', subscription_form, Apidoc::Models::SubscriptionForm)\n @client.request(\"/subscriptions\").with_json(subscription_form.to_json).post { |hash| Apidoc::Models::Subscription.new(hash) }\n end",
"def post body=nil, headers={}\n @connection.post \"subscriptions.json\", body, headers\n end",
"def edit_subscription(subscription_id, payload)\n put(url_(\"subscription\", subscription_id), payload)\n end",
"def create\n megam_rest.post_subscriptions(to_hash)\n end",
"def update\n respond_to do |format|\n if @premium_subscription.update(premium_subscription_params)\n format.html { redirect_to @premium_subscription, notice: 'Premium subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @premium_subscription }\n else\n format.html { render :edit }\n format.json { render json: @premium_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @vendor_subscription.update(vendor_subscription_params)\n format.html { redirect_to @vendor_subscription, notice: 'Vendor subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @vendor_subscription }\n else\n format.html { render :edit }\n format.json { render json: @vendor_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscriber = Subscriber.find(params[:id])\n\n respond_to do |format|\n if @subscriber.update_attributes(params[:subscriber])\n format.html { redirect_to @subscriber, notice: 'Subscriber was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscriber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscriber = Subscriber.find(params[:id])\n\n respond_to do |format|\n if @subscriber.update_attributes(params[:subscriber])\n format.html { redirect_to @subscriber, notice: 'Subscriber was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscriber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_subscription.update(admin_subscription_params)\n format.html { redirect_to [:admin, @admin_subscription], notice: 'L\\'abonnement a bien été mis à jour !' }\n format.json { render :show, status: :ok, location: @admin_subscription }\n else\n format.html { render :edit }\n format.json { render json: @admin_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category_subscription.update(category_subscription_params)\n format.html { redirect_to @category_subscription, notice: 'Category subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @category_subscription }\n else\n format.html { render :edit }\n format.json { render json: @category_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @subscriber = Subscriber.find(params[:id])\n\n respond_to do |format|\n if @subscriber.update_attributes(params[:subscriber])\n format.html { redirect_to @subscriber, notice: 'Subscriber was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscriber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_subscriptions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: StreamsApi.update_subscriptions ...'\n end\n # resource path\n local_var_path = '/users/me/subscriptions'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'delete'] = @api_client.build_collection_param(opts[:'delete'], :multi) if !opts[:'delete'].nil?\n query_params[:'add'] = @api_client.build_collection_param(opts[:'add'], :multi) if !opts[:'add'].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[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'JsonSuccessBase'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"StreamsApi.update_subscriptions\",\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(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StreamsApi#update_subscriptions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n @unsubscribe = Unsubscribe.find(params[:id])\n\n respond_to do |format|\n if @unsubscribe.update_attributes(params[:unsubscribe])\n flash[:notice] = 'Unsubscribe was successfully updated.'\n format.html { redirect_to(@unsubscribe) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unsubscribe.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscription_user.update(subscription_user_params)\n format.html { redirect_to @subscription_user, notice: 'Subscription user was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscription_user }\n else\n format.html { render :edit }\n format.json { render json: @subscription_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscription_type.update(subscription_type_params)\n format.html { redirect_to @subscription_type, notice: 'Subscription types was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscription_type }\n else\n format.html { render :edit }\n format.json { render json: @subscription_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bulk_update_subscriptions(subscriptions = [])\n attrs = { updateSubscriptionsRequests: subscriptions }\n Iterable.request(conf, '/users/bulkUpdateSubscriptions').post(attrs)\n end",
"def update\n @subscriber = Subscriber.find(params[:id])\n\n respond_to do |format|\n if @subscriber.update_attributes(params[:subscriber])\n format.html { redirect_to account_subscriber_path(@account, @subscriber), notice: 'Subscriber was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subscriber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subscription = Subscription.new(subscription_params)\n\n if @subscription.save\n render json: @subscription, status: :created, location: @subscription\n else\n render json: @subscription.errors, status: :unprocessable_entity\n end\n end",
"def update\n @subscription_type = SubscriptionType.find(params[:id])\n\n respond_to do |format|\n if @subscription_type.update_attributes(params[:subscription_type])\n flash[:notice] = 'SubscriptionType was successfully updated.'\n format.html { redirect_to(@subscription_type) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @subscription_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # checking a new method\n # @subscribe = Subscribe.update_sub(@item, @user)\n @subscribe = Subscribe.new(subscribe_params)\n respond_to do |format|\n if @subscribe.save\n format.html { redirect_to @subscribe}#, notice: 'Subscribe was successfully created.' }\n format.json { render :show, status: :created, location: @subscribe }\n else\n format.html { render :new }\n format.json { render json: @subscribe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unsubscription.update(unsubscription_params)\n flash[:success] = \"Le traitement a bien été modifié!\"\n format.html { redirect_to @unsubscription }\n format.json { render :show, status: :ok, location: @unsubscription }\n else\n format.html { render :edit }\n format.json { render json: @unsubscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_subscription\n success = stripe_call do\n customer = Stripe::Customer.retrieve(@user.stripe_id)\n subscription = customer.subscriptions.retrieve(@user.stripe_subscription_id)\n subscription.source = @params[:stripeToken] if @params[:stripeToken]\n # Update plan if one is provided, otherwise use user's existing plan\n # TODO providing plan_id is untested\n plan_stripe_id = @params[:plan_id] ? Plan.find(@params[:plan_id]).stripe_id : @user.plan.stripe_id\n subscription.items = [{\n id: subscription.items.data[0].id,\n plan: plan_stripe_id\n }]\n subscription.save\n end\n return false unless success\n user_attributes_to_update = {}\n # This is updated by the stripe webhook customer.updated\n # But we can update it here for a faster optimistic 'response'\n assign_card_details(user_attributes_to_update, @params)\n user_attributes_to_update[:plan_id] = @params[:plan_id].to_i if @params[:plan_id]\n @user.update(user_attributes_to_update) if user_attributes_to_update.any?\n return true if success\n end",
"def update_subscriptions(opts = {})\n data, _status_code, _headers = update_subscriptions_with_http_info(opts)\n data\n end",
"def update\n respond_to do |format|\n if @subscriber.update(subscriber_params)\n format.html { redirect_to @subscriber, notice: 'Subscriber was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscriber }\n else\n format.html { render :edit }\n format.json { render json: @subscriber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n content = get_content('email_notifications.yml')\n user = User.where(unsubscription_token: params[:unsubscription_token]).first\n\n unless user\n flash[:error] = \"Could not find user\"\n redirect_to root_path and return\n end\n\n user.subscriptions.update_all(unsubscribe_reason: reason_param)\n\n render 'email_notifications/update', layout: 'notification', status: :accepted, locals: {\n content: content['update'],\n }\n end",
"def update\n @subscription.activity :params => {:composite_key => \"#{@subscription.game_id},#{@subscription.player_id}\"}\n respond_to do |format|\n if @subscription.update(subscription_params) \n format.html { redirect_to @subscription.game, notice: 'Subscription was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscription }\n else\n format.html { render :edit }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_subscription(subscription_id:,\n body:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/subscriptions/{subscription_id}'\n _query_builder = APIHelper.append_url_with_template_parameters(\n _query_builder,\n 'subscription_id' => { 'value' => subscription_id, 'encode' => true }\n )\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json',\n 'content-type' => 'application/json; charset=utf-8'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.put(\n _query_url,\n headers: _headers,\n parameters: body.to_json\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end",
"def update\n friend = current_user.friends.find params[:id]\n return render json: { error: \"This doesn't seem to be your friend\" } if friend.nil?\n subscribed = !friend.subscribed\n change = subscribed ? 1 : -1\n friend.update subscribed: subscribed\n notify friend, change, 'subscribe'\n render json: {success: subscribed == friend.subscribed}\n end",
"def update\n @product_subscription = ProductSubscription.find(params[:id])\n\n respond_to do |format|\n if @product_subscription.update_attributes(params[:product_subscription])\n format.html { redirect_to campaign_subscription_path(@product_subscription.subscription.campaign, @product_subscription.subscription), :notice => 'Product subscription was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product_subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @subscription = Subscription.new(subscription_params)\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to @subscription, notice: (I18n.t :subscription_created) }\n format.json { render :show, status: :created, location: @subscription }\n else\n format.html { render :new }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @category_subscription.update(category_subscription_params)\n format.html { redirect_to [:admin, @category_subscription], notice: 'Подписка на категорию был успешно обновлена.' }\n format.json { render :show, status: :ok, location: @category_subscription }\n else\n format.html { render :edit }\n format.json { render json: @category_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @panel_subscription_transaction = Panel::SubscriptionTransaction.find(params[:id])\n\n respond_to do |format|\n if @panel_subscription_transaction.update_attributes(params[:panel_subscription_transaction])\n format.html { redirect_to(@panel_subscription_transaction, :notice => 'Subscription transaction was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @panel_subscription_transaction.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_subscriber_list_details(slug:, params: {})\n patch_json(\n \"#{endpoint}/subscriber-lists/#{slug}\",\n params,\n )\n end",
"def new\n # trying to implement a new way of updating the table\n # Subscribe.update_sub(@item, @user)\n # creating a new subscribe and saving it into the table\n @subscribe = Subscribe.new(:item_id => @item.id, :user_id => @user.id)\n respond_to do |format|\n if @subscribe.save\n format.html { redirect_to @item, notice: 'Subscribe was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @subscribe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @subscriber.update(subscriber_params)\n format.html { redirect_to @subscriber, notice: 'Subscriber was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @subscriber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n@subscription = current_user.subscriptions.build(subscription_params)\n\nrespond_to do |format|\n if @subscription.save\n\n format.html { redirect_to user_profile_url(current_user.id), notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @subscription }\n else\n format.html { render :new }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\nend\nend",
"def set_subscription\n @subscription = Subscription.find(params[:id])\nend",
"def set_subscription\n @subscription = Subscription.find(params[:id])\nend",
"def subscription_params\n params.require(:subscription).permit(:subscribed_id)\n end",
"def create\n @subscription = Subscription.new(subscription_params)\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to root_url, notice: 'Subscription was successfully created.' }\n format.json { render action: 'show', status: :created, location: @subscription }\n else\n format.html { render action: 'new' }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # params[:id] is the knowmadics id\n\n @api_subscription = Api::Subscription.new(api_subscription_params)\n\n respond_to do |format|\n if @api_subscription.save\n format.html { redirect_to @api_subscription, notice: 'Subscription was successfully created.' }\n format.json { render :show, status: :created, location: @api_subscription }\n else\n format.html { render :new }\n format.json { render json: @api_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subscription_new_main.update(subscription_new_main_params)\n format.html { redirect_to @subscription_new_main, notice: 'Subscription new main was successfully updated.' }\n format.json { render :show, status: :ok, location: @subscription_new_main }\n else\n format.html { render :edit }\n format.json { render json: @subscription_new_main.errors, status: :unprocessable_entity }\n end\n end\n end",
"def webhook_subscribe\n # verify the string parameters\n if params['hub.mode'] == 'subscribe' &&\n params['hub.topic'] == @feed.url &&\n params['hub.challenge'].present?\n\n @feed.status = 'subscription_requested' # 17 mins\n if params['hub.lease_seconds'].present? && params['hub.lease_seconds'].to_i > 0\n @feed.expiration_date = DateTime.now + Rational(params['hub.lease_seconds'].to_i, 86_400)\n unless @feed.save\n # log error\n logger.error \"FEED SAVE TO DB ERROR:#{@feed.inspect}\"\n end\n end\n\n render status: 200, plain: params['hub.challenge']\n else\n render status: 422, plain: 'Invalid parameters'\n end\n end"
] | [
"0.75670075",
"0.74948996",
"0.74905753",
"0.74732214",
"0.7418818",
"0.74143976",
"0.7390735",
"0.7390735",
"0.7390735",
"0.7354441",
"0.7330095",
"0.73239106",
"0.7310953",
"0.7310953",
"0.7290768",
"0.72902995",
"0.728721",
"0.72593945",
"0.7243102",
"0.72309256",
"0.7228922",
"0.71640795",
"0.7158872",
"0.7154091",
"0.7149686",
"0.7128113",
"0.7117255",
"0.710058",
"0.70172787",
"0.70132333",
"0.69905525",
"0.6985747",
"0.6985747",
"0.69857395",
"0.6943096",
"0.68979204",
"0.68881804",
"0.683958",
"0.68315977",
"0.6776048",
"0.6769702",
"0.6766448",
"0.67654055",
"0.67654055",
"0.6741972",
"0.6733143",
"0.67316586",
"0.67236334",
"0.671728",
"0.67073816",
"0.6696912",
"0.6676334",
"0.6673983",
"0.6651919",
"0.6651765",
"0.662928",
"0.6627606",
"0.6626069",
"0.6605948",
"0.65903014",
"0.65836984",
"0.6581512",
"0.6581512",
"0.65810645",
"0.65394455",
"0.65371823",
"0.6516417",
"0.65124124",
"0.64976656",
"0.64937645",
"0.6483543",
"0.6482484",
"0.6474299",
"0.64597213",
"0.6459349",
"0.64495295",
"0.6447543",
"0.6433608",
"0.6412833",
"0.6396283",
"0.6393449",
"0.6387796",
"0.63747597",
"0.6373616",
"0.63710976",
"0.63484114",
"0.6347016",
"0.63423604",
"0.63401145",
"0.63358253",
"0.63358253",
"0.63358253",
"0.6320513",
"0.6299501",
"0.6298014",
"0.6298014",
"0.6295945",
"0.6276255",
"0.62674755",
"0.62423104",
"0.6238196"
] | 0.0 | -1 |
DELETE /subscriptions/1 DELETE /subscriptions/1.json | def destroy
@subscription.destroy
respond_to do |format|
format.html { redirect_to subscriptions_url, notice: 'Subscription was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete options={}, headers={}\n @connection.delete \"subscriptions.json\", options, headers\n end",
"def destroy\n subscription = current_user.subscriptions.find(params[:id])\n subscription.destroy!\n\n render json: { status: 'success'}\n end",
"def delete_subscriptions\n end",
"def destroy\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to subscriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription.destroy\n respond_to do |format|\n format.html { redirect_to subscriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to subscriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to subscriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to subscriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to subscriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription = current_user.subscriptions.find(params[:id])\n #TODO move to model Subscription\n if not current_user.fitbit.nil?\n path = ['/1/user/-', @subscription.collection_path, 'apiSubscriptions', @subscription.subscription_id + '-' + @subscription.collection_path]\n current_user.fitbit.client.delete(path.join('/') + '.json')\n flash[:success] = 'Subscription successfully removed from Fitbit.'\n else\n flash[:error] = 'Can not remove subscription from Fitbit, because you are not connected.'\n end\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to subscriptions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @subscription.destroy\n respond_to do |format|\n format.html { redirect_to subscriptions_url, notice: (I18n.t :subscription_deleted) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription.destroy\n\n head :no_content\n end",
"def destroy\n @api_subscription.destroy\n respond_to do |format|\n format.html { redirect_to api_subscriptions_url, notice: 'Subscription was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription.destroy\n respond_to do |format|\n format.html { redirect_to root_url}\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @subscription = Subscription.find(params[:id])\r\n @subscription.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to business_user_subscriptions_path }\r\n format.json { head :ok }\r\n end\r\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to campaign_subscriptions_path(@campaign) }\n format.json { head :no_content }\n end\n end",
"def delete_webhook_subscription(id,opts={})\n query_param_keys = [\n \n\n ]\n\n form_param_keys = [\n \n\n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id\n\n )\n\n # resource path\n path = path_replace(\"/lti/subscriptions/{id}\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_query_params(options, query_param_keys)\n\n response = mixed_request(:delete, path, query_params, form_params, headers)\n response\n \n\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to(subscriptions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to(subscriptions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to(subscriptions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @subscription_request = SubscriptionRequest.find(params[:id])\n @subscription_request.destroy\n\n respond_to do |format|\n format.html { redirect_to subscription_requests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n auth!\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to(manage_screen_field_subscriptions_url(@screen, @field)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @subscription.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Subscription was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crytosubscription.destroy\n respond_to do |format|\n format.html { redirect_to crytosubscriptions_url, notice: 'Crytosubscription was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription = current_user.subscriptions.find(params[:id])\n\t\tmanga = Manga.find(@subscription.manga_id)\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to mangas_url, notice: 'Successfully unsubscribed to '+ manga.display_name.to_s}\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to @subscription.transaction }\n format.json { head :no_content }\n end\n end",
"def remove_subscription\n buyer = @current_user\n customer_id = buyer.stripe_customer_id\n customer = Stripe::Customer.retrieve(customer_id)\n subscription.delete\n render json: { message: 'Unsubscribed succesfully' }, status: 200\n end",
"def destroy\n @subscribe.destroy\n\n respond_to do |format|\n format.html { redirect_to subscribes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if session[:user_id] \n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n \n respond_to do |format|\n format.html { redirect_to(subscriptions_url) }\n format.xml { head :ok }\n end\n end\n end",
"def delete_subscription(id)\n delete(\"/subscriptions/#{id}\")\n end",
"def destroy \n Instagram.delete_subscription({:id => params[:id]})\n local_subscription = Subscription.find_by_original_id params[:id]\n local_subscription.destroy if local_subscription\n redirect_to :admin_subscriptions\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @owner = @subscription.owner\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to polymorphic_url([@owner, :subscriptions]) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscribe.destroy\n respond_to do |format|\n format.html { redirect_to subscribes_url, notice: 'Subscribe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscribe.destroy\n respond_to do |format|\n format.html { redirect_to subscribes_url, notice: 'Subscribe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscribe.destroy\n respond_to do |format|\n format.html { redirect_to subscribes_url, notice: 'Subscribe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_subscription.destroy\n respond_to do |format|\n format.html { redirect_to admin_subscriptions_url, notice: 'L\\'abonnement a bien été créé supprimé.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to artist_subscription_path }\n format.json { head :ok }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to request.env[\"HTTP_REFERER\"] }\n format.xml { head :ok }\n end\n end",
"def destroy\n @panel_subscription = Panel::Subscription.find(params[:id])\n @panel_subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to(panel_subscriptions_url) }\n format.json { head :ok }\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 @newsletter_subscription = NewsletterSubscription.find(params[:id])\n @newsletter_subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to newsletter_subscriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n auth!\n @subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to(screen_field_subscription_path(@screen, @field)) }\n format.xml { head :ok }\n format.js { head :ok }\n end\n end",
"def destroy\n @service_subscription = ServiceSubscription.find(params[:id])\n @service_subscription.destroy\n \n redirect_to service_subscriptions_path\n\n # respond_to do |format|\n # format.html { redirect_to(service_subscriptions_url) }\n # format.xml { head :ok }\n # end\n end",
"def destroy\n return error_message(['Access denied'], 403) unless current_user?(@user)\n\n course = fetch_cache(Course, params[:id])\n @user.subscriptions_to_courses.destroy(course)\n render json: {status: 'Ok'}\n end",
"def destroy!\n Dropio::Resource.client.delete_subscription(self)\n nil\n end",
"def destroy\n @subscriber = Subscriber.find(params[:id])\n @subscriber.destroy\n\n respond_to do |format|\n format.html { redirect_to account_subscribers_url(@account) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_subscription = ListSubscription.find(params[:id])\n @list_subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to list_subscriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscriber = Subscriber.find(params[:id])\n @subscriber.destroy\n\n respond_to do |format|\n format.html { redirect_to subscribers_url }\n format.json { head :ok }\n end\n end",
"def delete_webhook_subscription(subscription_id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::DELETE,\n '/v2/webhooks/subscriptions/{subscription_id}',\n 'default')\n .template_param(new_parameter(subscription_id, key: 'subscription_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'accept'))\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def destroy\n\n @subscriber = Subscriber.find(params[:id])\n @subscriber.destroy\n\n respond_to do |format|\n format.html { redirect_to subscribers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @subscriber = Subscriber.find(params[:id])\n @subscriber.destroy\n\n respond_to do |format|\n format.html { redirect_to subscribers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @email_newsletter_subscription.destroy\n respond_to do |format|\n format.html { redirect_to email_newsletter_subscriptions_url, notice: 'Email newsletter subscription was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription_user.destroy\n respond_to do |format|\n format.html { redirect_to subscription_users_url, notice: 'Subscription user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscriptions = []\n\n # query parameter with the ids of all the necessarily deleted subscriptions\n subscription_id_string = params[:subscription][:subscriptions]\n\n # converts the query parameter string into an array. Query parameter gets sent like this \"[1,2,3]\"\n all_ids = subscription_id_string[subscription_id_string.index(\"[\") + 1, subscription_id_string.index(\"]\") - 1].split(\",\")\n\n # for each id in the array of ids, find the Subscription with that id, add it to the array of deleted subscriptions\n # for the view, and then destroy the subscription\n all_ids.each do |id|\n this_subscription = Subscription.find(id)\n @subscriptions << this_subscription\n\n # decrement subscription count of corresponding dept/club/team\n if this_subscription.category == \"department\"\n dept = Department.find(this_subscription.subscribed_to)\n dept.subscriber_count -= 1\n dept.save\n elsif this_subscription.category == \"club\"\n club = Club.find(this_subscription.subscribed_to)\n club.subscriber_count -= 1\n club.save\n else\n team = AthleticTeam.find(this_subscription.subscribed_to)\n team.subscriber_count -= 1\n team.save\n end\n\n this_subscription.destroy\n end\n end",
"def destroy\n @subscription_type = SubscriptionType.find(params[:id])\n @subscription_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(subscription_types_url) }\n format.xml { head :ok }\n end\n end",
"def clear_subs\n instagram_client.subscriptions.each do |sub|\n instagram_client.delete_subscription(id: sub.id)\n end\n\n redirect_to list_subs_path\n end",
"def destroy\n @vendor_subscription.destroy\n respond_to do |format|\n format.html { redirect_to vendor_subscriptions_url, notice: 'Vendor subscription was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscribe.destroy\n respond_to do |format|\n format.html {redirect_to subscribes_url, notice: 'Subscribe was successfully destroyed.'}\n format.json {render json: @subscribe, status: :ok}\n end\n end",
"def destroy\n @event_subscription.destroy\n head :no_content\n end",
"def destroy\n @unsubscription.destroy\n respond_to do |format|\n flash[:success] = \"Le traitement a bien été supprimé!\"\n format.html { redirect_to unsubscriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n @subscription.destroy\n\n respond_to do |format|\n format.html {\n if request.referrer == subscription_url(@subscription)\n redirect_to session[:sub_delete_return_to]\n else\n redirect_to :back\n end\n }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscriber.destroy\n respond_to do |format|\n format.html { redirect_to subscribers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription.destroy\n return_back_or_ajax\n end",
"def delete_subscription(entity)\r\n subscriptions.delete(entity)\r\n end",
"def destroy\n @subscription_type.destroy\n respond_to do |format|\n format.html { redirect_to subscription_types_path, notice: 'Subscription types was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription_history = SubscriptionHistory.find(params[:id])\n @subscription_history.destroy\n\n respond_to do |format|\n format.html { redirect_to(subscription_histories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\t @subscription = Subscription.find(params[:id])\n\t @subscription.remove if @subscription\n\n\t redirect_to plans_path\t \t\n\tend",
"def destroy\n @premium_subscription.destroy\n respond_to do |format|\n format.html { redirect_to premium_subscriptions_url, notice: 'Premium subscription was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n\n @subscription.status = 'canceled'\n\n redirect_to subscriptions_path, notice: \"Your #{@subscription.category.name} subscription has been canceled.\"\n @subscription.save\n end",
"def delete_subscription subscription\n subscriber.delete_subscription subscription: subscription_path(subscription)\n end",
"def delete\n result = Hash.new\n begin # try\n result = SubscribesHlp.delete(params[:id])\n rescue # catch\n result['status'] = false\n result['error'] = \"#{$!}\"\n ensure # finally\n render json: result\n end\n end",
"def delete_webhook_subscription(id)\n\t\tputs \"Attempting to delete subscription for webhook: #{id}.\"\n\n\t\tif @api_tier == 'premium'\n\t\t\t@uri_path = \"#{@uri_path}/all/#{id}/subscriptions/all.json\"\n\t else\n\t\t\t@uri_path = \"#{@uri_path}/webhooks/#{id}/subscriptions.json\"\n\t\tend\n\n\t\tresponse = @twitter_api.make_delete_request(@uri_path)\n\n\t\tif response == '204'\n\t\t\tputs \"Webhook subscription for #{id} was successfully deleted.\"\n\t\telse\n\t\t\tputs response\n\t\tend\n\t\t\n\t\tresponse\n\tend",
"def destroy\n @user_to_channel_subscription.destroy\n respond_to do |format|\n format.html { redirect_to user_to_channel_subscriptions_url, notice: 'User to channel subscription was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subscriber = Subscriber.find(params[:id])\n @subscriber.destroy\n\n respond_to do |format|\n format.html { redirect_to subscribers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @panel_subscription_transaction = Panel::SubscriptionTransaction.find(params[:id])\n @panel_subscription_transaction.destroy\n\n respond_to do |format|\n format.html { redirect_to(panel_subscription_transactions_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n @subscription_list.destroy\n respond_to do |format|\n format.html { redirect_to subscription_lists_url, notice: 'La Lista de Entrega se borró exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @misuration_subscription.destroy\n respond_to do |format|\n format.html { redirect_to misuration_subscriptions_url, notice: 'Iscrizione al sensore eliminata correttamente' }\n format.json { head :no_content }\n end\n end",
"def delete(mirror=@mirror)\n result = client.execute(\n :api_method => mirror.subscriptions.delete,\n :parameters => { 'id' => collection })\n if result.error?\n puts \"An error occurred: #{result.data['error']['message']}\"\n end\n end",
"def deletesubscriber\n\n\tparams[\"phone\"] = params[\"phone\"].gsub(\"\\s\",\"\").gsub(/^0044/, \"\").gsub(/^\\+44/, \"\")\n\tif params[\"phone\"].length == 10\n\t\tparams[\"phone\"] = '0' + params[\"phone\"]\n\tend\n\n\tif (Subscriber.exists?(:phone => params[:phone]))\n\t\tsubscriber = Subscriber.where(:phone => params[:phone]).first\n\t\tsubscriber.destroy\n\n\t\trespond_to do |format|\n\t\t format.html # deletesubscriber.html.erb\n\t\tend\n\telse\n\t\tredirect_to :action => \"unsubscribe\", phone: params[:phone]\n end\n end",
"def destroy\n @subscriber.destroy\n respond_to do |format|\n format.html { redirect_to subscribers_url, notice: 'Subscriber was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def unsubscribe_subscriber(id)\n delete_json(\"#{endpoint}/subscribers/#{uri_encode(id)}\")\n end",
"def unsubscribe_subscriber(id)\n delete_json(\"#{endpoint}/subscribers/#{uri_encode(id)}\")\n end",
"def destroy\n # First cancel the Stripe subscription\n\n @subscription.cancel_subscription(current_user.account)\n # Then destroy the subscription record\n @subscription.delete\n\n redirect_to subscriptions_url\n end",
"def unsubscribe\n email = Base64.decode64(params[:token])\n Subscription.where(email: email).destroy_all\n end",
"def cancel\n success = current_subscriber.cancel_subscription\n render json: { success: success }\n end",
"def deleteSubscription(subscr)\n subscriptions = Hash.new\n if @subscriptionLists.hasKey(\"subscriptions\")\n subscriptions = @subscriptionLists.getRepositoryObject(\"subscriptions\").getObject\n end\n #subscriptions[subscr] = Array.new\n #@subscriptionLists.commitObject(\"subscriptions\", subscriptions, false)\n subscriptions.delete(subscr)\n @subscriptionLists.commitObject(\"subscriptions\", subscriptions, false)\n end",
"def destroy\n @subscription_group = SubscriptionGroup.find(params[:id])\n @subscription_group.destroy\n\n respond_to do |format|\n format.html { redirect_to subscription_groups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n targets = Subscription.where(ordinal: (@subscription.ordinal + 1)..Float::INFINITY)\n\n targets.each do |target|\n target.update(ordinal: target.ordinal - 1)\n end\n\n @subscription.destroy\n respond_to do |format|\n format.html { redirect_to owner_subscriptions_url(owner_id: @owner.id), notice: 'サブスクショップを削除しました' }\n format.json { head :no_content }\n end\n end",
"def destroy\n transaction do\n clean\n connection.delete \"DELETE FROM user_subscriptions WHERE subscription_id = #{id}\"\n connection.delete \"DELETE FROM subscriptions WHERE id = #{id}\"\n end\n end",
"def destroy\n @category_subscription.destroy\n respond_to do |format|\n format.html { redirect_to category_subscriptions_url, notice: 'Category subscription was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\[email protected]\nrespond_to do |format|\n format.html { redirect_to :back, notice: 'Pet was successfully destroyed.' }\n format.json { head :no_content }\nend\nend",
"def destroy\n @category_subscription.destroy\n respond_to do |format|\n format.html { redirect_to admin_category_subscriptions_url, notice: 'Подписка на категорию была успешно удалена.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n event = Subscription.find(params[:id]).event\n current_user.unsubscribe(event)\n redirect_to event\n end",
"def destroy\n @product_subscription = ProductSubscription.find(params[:id])\n @product_subscription.destroy\n\n respond_to do |format|\n format.html { redirect_to campaign_subscription_path(@product_subscription.subscription.campaign, @product_subscription.subscription) , :notice => 'Product subscription was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def unsubscribe(uuid)\n post_json(\"#{endpoint}/unsubscribe/#{uri_encode(uuid)}\")\n end",
"def unsubscribe(uuid)\n post_json(\"#{endpoint}/unsubscribe/#{uri_encode(uuid)}\")\n end"
] | [
"0.8083839",
"0.7971518",
"0.7749676",
"0.77227986",
"0.76973474",
"0.76788694",
"0.76788694",
"0.76788694",
"0.76788694",
"0.766344",
"0.75745755",
"0.75494754",
"0.75242066",
"0.7512467",
"0.74898785",
"0.7430863",
"0.7402852",
"0.7389791",
"0.7389791",
"0.7389791",
"0.73481774",
"0.7345754",
"0.7341421",
"0.7334125",
"0.7328218",
"0.7315209",
"0.72989845",
"0.72939456",
"0.72885406",
"0.72582734",
"0.71930397",
"0.7180277",
"0.7174165",
"0.7174165",
"0.7174165",
"0.7169685",
"0.71584594",
"0.71415883",
"0.7106714",
"0.7106371",
"0.7053827",
"0.70474845",
"0.70270944",
"0.7017797",
"0.70120806",
"0.7010806",
"0.7009525",
"0.7000163",
"0.6999704",
"0.6994056",
"0.6978384",
"0.6928824",
"0.69250244",
"0.690034",
"0.6893621",
"0.68918157",
"0.68900865",
"0.6882974",
"0.6880508",
"0.68732697",
"0.6855283",
"0.68506974",
"0.68364197",
"0.6834784",
"0.6825377",
"0.6824307",
"0.6813649",
"0.6813254",
"0.68043864",
"0.67935514",
"0.67930984",
"0.67714334",
"0.6769921",
"0.6768724",
"0.6756108",
"0.6747615",
"0.67351985",
"0.6734292",
"0.6723186",
"0.6701433",
"0.6693665",
"0.6693665",
"0.66927797",
"0.66847116",
"0.66740596",
"0.66574746",
"0.66559565",
"0.66548216",
"0.6653988",
"0.66247725",
"0.66168004",
"0.65775114",
"0.65743136",
"0.6557313",
"0.65516657",
"0.65516657"
] | 0.74766344 | 19 |
it would be nice to use flagged_as_spam? directly but GuideTaxon is a weird case of something that is spam only because of association its not directly flagged | def known_spam?
if is_a?( GuideTaxon )
# guide taxa can have many sections, each of which could be spam,
# so when one is spam consider the entire GuideTaxon as spam
if guide_sections.any?( &:flagged_as_spam? )
return true
end
return false
end
if respond_to?( :flagged_as_spam? ) && flagged_as_spam?
return true
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_as_spam!\n update_attribute(:approved, false)\n Akismetor.submit_spam(akismet_attributes)\n end",
"def check_for_spam\n if self.spam?\n self.update_column(:approved, false)\n elsif !approved\n self.update_column(:approved, true)\n end\n end",
"def mark_as_spam!\n update_attribute(:approved, true)\n Akismetor.submit_spam(akismet_attributes)\n end",
"def is_spam?\n if self.owner and self.owner.spammer?\n return true\n else\n return false\n end\n end",
"def spam?\n @spam\n end",
"def spam?\n !! spam\n end",
"def test_mark_as_spam\n comment = create_comment\n assert comment.mark_as_spam!\n assert !comment.approved\n # TODO - what happens if a signed comment is marked as spam? can it even be done?\n end",
"def spam?(message)\n message['X-Mailgun-Sflag'] && message['X-Mailgun-Sflag'].value == 'Yes'\n end",
"def is_spam? \n # You'll need to get your own Akismet API key from www.akismet.com\n \n #return false;\n \n @akismet = Akismet.new('key', 'webpage') \n \n return nil unless @akismet.verifyAPIKey\n \n return self.spam!(:exempt => true) if @akismet.commentCheck(\n self.author_ip, # remote IP\n self.user_agent, # user agent\n self.referrer, # http referer\n self.page.url, # permalink\n 'comment', # comment type\n self.author, # author name\n self.author_email, # author email\n self.author_url, # author url\n self.content, # comment text\n {}) # other\n end",
"def mark_as_spam_or_ham(is_spam, options={})\n is_spam ? mark_as_spam(options) : mark_as_ham(options)\n end",
"def spam?(message)\n false\n end",
"def spam!\n @checked = @spam = true\n akismet :spam!\n save\n end",
"def is_spam?\n #if we've got another comment marked as spam from this ip address, then spam it instantly\n if Comment.filter([\"ip = ? and reported_as_spam = ?\", self.ip, true]).first\n self.reported_as_spam = true\n return true\n else\n old = self.reported_as_spam \n self.reported_as_spam = Thoth::Plugin::ThothAkismet.new_client.check self.ip || \"\", 'user_agent', self.akismet_options \n if self.reported_as_spam != old || !self.spam_checked\n self.spam_checked = true\n self.save if self.id #only save the comment if it's already been saved\n end\n return self.reported_as_spam\n end\n end",
"def spam?(message)\n message.spam_score.to_f > @spamassassin_threshold\n end",
"def spam?\n if @spam == \"True\" || @spam == \"Yes\"\n return true;\n else\n return false\n end\n end",
"def spam?(message)\n begin\n @bayes.classify(message) == 'spam' \n rescue BayesError => e # no training data available :(\n false\n end\n end",
"def check_spam( options = {} )\n before_action :set_akismet_params_on_record, only: options[:only], except: options[:except]\n\n define_method( :set_akismet_params_on_record ) do\n return unless record = instance_variable_get( \"@\" + options[:instance].to_s )\n # if we checking for spam when creating / updating a user and the\n # current user is not that user (e.g. curator or admin action), we\n # don't want to send akismet the current user's info\n if record.is_a?( User ) && current_user && current_user != record\n return\n end\n # No point in setting this info if we know this user isn't a spammer\n return if current_user && current_user.known_non_spammer?\n record.acts_as_spammable_user_ip = Logstasher.ip_from_request_env( request.env )\n record.acts_as_spammable_user_agent = request.user_agent\n record.acts_as_spammable_referrer = request.referrer\n end\n end",
"def spam_status\n return 'NotChecked' unless inspected == 1\n spam == 1 ? 'Spam' : 'NotSpam'\n end",
"def can_flag?\n !sent? && !flagged?\n end",
"def spam?\n p [:spam, @spam]\n (@spam == \"True\" || @spam == \"Yes\") ? true : false\n end",
"def ham?\n ! spam\n end",
"def test_check_for_spam\n comment = new_comment(:pseud_id => create_pseud)\n assert !comment.approved\n assert comment.check_for_spam # should always return true\n assert comment.approved\n # TODO - test for actual spam\n end",
"def needs_address?\n !flagged? && !sent?\n end",
"def mark_as_spam(options={})\n return false if invalid_options?\n {:message => call_akismet('submit-spam', options)}\n end",
"def convert_to_spam_email\n email = Email.find(email_id)\n email.spam = true\n email.save\n end",
"def not_approved?\n self.moderation_status != 'approved'\n end",
"def spam?\n texts.count > 0\n end",
"def flagged?\n @flagged\n end",
"def flagged?\n @flagged\n end",
"def is_approved?\n moderation_flag ? true : false\n end",
"def is_approved?\n moderation_flag ? true : false\n end",
"def is_spam(message)\n tell(message, 'spam')\n end",
"def spam?(content, honeypot)\n honeypot.present? || link_tags?(content) || too_many_urls?(content)\n end",
"def appellant_email_sent_flag\n should_send_email = updates_requiring_email? ||\n appellant_email.present? ||\n appellant_timezone.present?\n\n # Note: Don't set flag if hearing disposition is cancelled, postponed, or scheduled in error\n !should_send_email || hearing.postponed_or_cancelled_or_scheduled_in_error?\n end",
"def recommendable?() false end",
"def spam?(env)\n\t\t\tparams = { blog: 'http://sivers.org/',\n\t\t\t\tuser_ip: env['REMOTE_ADDR'],\n\t\t\t\tuser_agent: env['HTTP_USER_AGENT'],\n\t\t\t\treferrer: env['HTTP_REFERER'],\n\t\t\t\tcomment_type: 'comment',\n\t\t\t\tcomment_author: env['rack.request.form_hash']['name'],\n\t\t\t\tcomment_author_email: env['rack.request.form_hash']['email'],\n\t\t\t\tcomment_content: env['rack.request.form_hash']['comment'] }\n\t\t\tparams.each {|k,v| params[k] = URI.encode_www_form_component(v)}\n\t\t\tkey = Sivers.config['akismet']\n\t\t\turi = URI(\"http://#{key}.rest.akismet.com/1.1/comment-check\")\n\t\t\t'true' == Net::HTTP.post_form(uri, params).body\n\t\tend",
"def is_approved?\n self.approved == 'approved'\n end",
"def ignored?\n marking == \"IGNORED\"\n end",
"def ill_item?(instance)\n instance['source'] == 'FOLIO' &&\n instance['discoverySuppress'] == true &&\n instance['staffSuppress'] == false\n end",
"def call\n @message.spam?\n end",
"def appellant_is_veteran\n !veteran_is_not_claimant\n end",
"def not_spam\n errors.add(:base, \"invalid reply\") if check_field.present?\n end",
"def approved?\n self.is_approved == true \n end",
"def is_spam?(args)\n return call_akismet('comment-check', args)\n end",
"def tons_of_spam(emphasis = \"!\")\n super\n end",
"def check_for_spamming\n #first check if it is a new conversation\n if !params[:message][:conversation_id]\n if current_user.conversations.recent.count < 5 #max 5 new convos/hour\n false\n else\n true\n end\n else\n false #limit_replies\n end\n end",
"def possibly_include_hidden?; end",
"def has_ta_for_marking?\n ta_memberships.count > 0\n end",
"def representative_email_sent_flag\n should_send_email = updates_requiring_email? ||\n representative_email.present? ||\n representative_timezone.present?\n\n # Note: Don't set flag if hearing disposition is cancelled, postponed, or scheduled in error\n !should_send_email || hearing.postponed_or_cancelled_or_scheduled_in_error?\n end",
"def flagged?\n\t\t\t@flagged\n\t\tend",
"def tasty_unflagged_in_curr\n log \"Finding messages re-marked bland\"\n\n @bland_flagged = @imap.search [\n 'NOT', 'FLAGGED',\n 'KEYWORD', TASTY_KEYWORD\n ]\n\n update_db @tasty_unflagged, :remove_tasty, :add_bland\n \n @bland_flagged.length\n end",
"def check!\n if @activity.valid?\n @activity.schedule_for_review!\n # Idnet::Core::Activity::SpamCheckServiceConnection.new(@activity).spam?.tap do |spam_check_result|\n # case spam_check_result\n # when true\n # @activity.schedule_for_review!\n # when false\n # @activity.mark_as_not_spam!\n # end\n # end\n end\n end",
"def approved?\n !approved_on.nil?\n end",
"def needs_fix?\n active? && flagged?\n end",
"def destroy_if_no_non_spam_email?\n mails.all? { |mail| mail.spam }\n end",
"def has_additional_terms_of_use\n false\n end",
"def is_spammer?(id)\n where(guess_type(id) => id).any?\n end",
"def spam?( env ); raise NotImplementedError; end",
"def approved?\n !pending\n end",
"def is_favoritable?\n true\n end",
"def advised?\n advisor_company_affiliations.with_access.present?\n end",
"def is_spam_new\r\n ret = false\r\n em = @e.client_email\r\n name = @e.client_name\r\n phon = @e.client_phone\r\n info = @e.info_req\r\n view = @e.viewing_info\r\n\r\n spams = SpamCheck.find(:all)\r\n @log.debug \"Found #{spams.size} spam check records\"\r\n\r\n spams.each {|sp|\r\n if sp.client_email_regex and em\r\n regex = Regexp.new(sp.client_email_regex)\r\n ret = true if em =~ regex\r\n end\r\n if sp.client_name_regex and name\r\n regex = Regexp.new(sp.client_name_regex)\r\n ret = true if name =~ regex\r\n end\r\n if sp.client_phone_regex and phon\r\n regex = Regexp.new(sp.client_phone_regex)\r\n ret = true if phon =~ regex\r\n end\r\n if sp.info_regex and info\r\n regex = Regexp.new(sp.info_regex)\r\n ret = true if info =~ regex\r\n end\r\n if sp.viewing_regex and view\r\n regex = Regexp.new(sp.viewing_regex)\r\n ret = true if view =~ regex\r\n end\r\n\r\n if sp.client_email_string and em\r\n ret = true if em.include?(sp.client_email_string)\r\n end\r\n if sp.client_name_string and name\r\n ret = true if name.include?(sp.client_name_string)\r\n end\r\n if sp.client_phone_string and phon\r\n ret = true if phon.include?(sp.client_phone_string)\r\n end\r\n if sp.info_string and info\r\n ret = true if info.include?(sp.info_string)\r\n end\r\n if sp.viewing_string and view\r\n ret = true if view.include?(sp.viewing_string)\r\n end\r\n }\r\n\r\n @log.debug \"Enquiry #{@i}: Spam check returning #{ret}\"\r\n return ret\r\n end",
"def ensure_not_spam!(params, feedback_form)\n if spam?(params[:content], params[:title])\n flash[:error] = t(\"layouts.notifications.feedback_considered_spam\")\n return render_form(feedback_form)\n else\n false\n end\n end",
"def liked_idea?(idea)\n liked_ideas.include?(idea)\n end",
"def judge_email_sent_flag\n flag = !(updates_requiring_email? || virtual_hearing_attributes&.key?(:judge_email) || judge_id.present?)\n flag || virtual_hearing_cancelled?\n end",
"def allow_fixation? \n @fixation\n end",
"def needs_sending?\n !sent? && !flagged?\n end",
"def bland_flagged_in_curr\n log \"Finding messages re-marked tasty\"\n @bland_flagged = @imap.search [\n 'FLAGGED',\n 'KEYWORD', BLAND_KEYWORD\n ]\n\n update_db @bland_flagged, :remove_bland, :add_tasty\n\n @bland_flagged.length\n end",
"def markbot()\n merge(markbot: 'true')\n end",
"def is_pending?\n moderation_flag.nil?\n end",
"def is_pending?\n moderation_flag.nil?\n end",
"def ignored?\n self.friendship_status == IGNORED\n end",
"def flagged_by?(user)\n !!flags.find_by_user_id(user.id) if user\n end",
"def flagged?(name)\n @flagged.include?(name.to_s)\n end",
"def taxable?\n self.taxable\n end",
"def judge_email_sent_flag\n should_send_email = updates_requiring_email? ||\n judge_id.present? ||\n virtual_hearing_attributes&.key?(:judge_email)\n\n # Note: Don't set flag if hearing disposition is cancelled, postponed, or scheduled in error\n !should_send_email || virtual_hearing_cancelled? || hearing.postponed_or_cancelled_or_scheduled_in_error?\n end",
"def silly_adjective; end",
"def accompaniment?\n self.participant_role == 'accompanist'\n end",
"def send_urgent?; preference == EmailSetting::OPTIONS[:'All Urgent Requests'] || preference.nil?; end",
"def mentioning?\n # Skip send notification if Doc not in publishing\n if instance_of?(Doc)\n publishing?\n else\n true\n end\n end",
"def remark_submitted?\n !submitted_remark.nil?\n end",
"def mandate_given?\n !self.given_mandates.empty?\n end",
"def approve?\n user && user.able_to?(:moderate_any_forum, record.forum)\n end",
"def is_flagged?\n return self.flags.unresolved.count > 0\n end",
"def suppress_reminders?\n [\n SUBJECT_CSP_TEACHER_CON,\n SUBJECT_CSP_FIT,\n SUBJECT_CSD_TEACHER_CON,\n SUBJECT_CSD_FIT\n ].include? subject\n end",
"def can_disable_affiliate_branding?\n !self.invitation.nil? && \n !self.affiliate.nil? && \n (!self.subscription.trial? || !self.invitation_subscription?)\n end",
"def people_for_mailing\n self.people.select(&:ok_conf_mails?)\n end",
"def advising?(other_user)\n advisees.include?(other_user)\n end",
"def is_denied?\n (moderation_flag == false) ? true : false\n end",
"def unlearned_flagged_in_curr\n log \"Finding unlearned, flagged messages\"\n\n @unlearned_flagged = @imap.search [\n 'FLAGGED',\n 'NOT', 'KEYWORD', LEARN_KEYWORD\n ]\n\n update_db @unlearned_flagged, :add_tasty\n\n @unlearned_flagged.length\n end",
"def is_groupblog?\n !self.user_id\n end",
"def goodcomments\n User.isliked(self)\n end",
"def referred_by?(agent)\n self.referred? && agent.to_s == self.referrer.to_s\n end",
"def has_badge?\n !!self.badge\n end",
"def hidden?\n self.privacy == HIDDEN\n end",
"def flag\n @flagged != @flagged = true unless @revealed\n end",
"def deny\n self.granted = -1\n restaurant = Restaurant.find(self.restaurant_id)\n restaurant.mark_collaborative\n end",
"def may_note?\n false\n end",
"def auto_approve?\n return user.auto_approve_comment?\n end",
"def approved?\n !self.pending\n end"
] | [
"0.69001424",
"0.6811213",
"0.6809065",
"0.6678388",
"0.6649906",
"0.6620109",
"0.6425489",
"0.6271691",
"0.62688047",
"0.62554777",
"0.6250683",
"0.6248758",
"0.6159642",
"0.61051667",
"0.6083339",
"0.6060099",
"0.60578305",
"0.60532117",
"0.60508287",
"0.5966958",
"0.59660935",
"0.5948935",
"0.59487444",
"0.58317274",
"0.5824698",
"0.5788137",
"0.5775385",
"0.5771054",
"0.5771054",
"0.5723353",
"0.5723353",
"0.5699962",
"0.56900823",
"0.56623656",
"0.5599602",
"0.5596016",
"0.5579722",
"0.5572194",
"0.5564603",
"0.55263525",
"0.5508266",
"0.55079055",
"0.55077434",
"0.55054414",
"0.54983836",
"0.5479865",
"0.5472299",
"0.5471344",
"0.5450004",
"0.5448196",
"0.54366153",
"0.54240346",
"0.54209125",
"0.541872",
"0.53892195",
"0.5385304",
"0.53843725",
"0.5380278",
"0.53764826",
"0.5371583",
"0.53698033",
"0.5369754",
"0.53633904",
"0.53598225",
"0.5355062",
"0.53459144",
"0.5344707",
"0.53433686",
"0.53349125",
"0.5317239",
"0.5317239",
"0.5313824",
"0.5313221",
"0.53114027",
"0.530399",
"0.52992743",
"0.5293478",
"0.52832615",
"0.52753514",
"0.5273781",
"0.52730435",
"0.5263764",
"0.52590686",
"0.5255209",
"0.52479213",
"0.5247288",
"0.5239824",
"0.52365315",
"0.52342033",
"0.5231809",
"0.5219217",
"0.5218109",
"0.52105004",
"0.5210383",
"0.5195856",
"0.5194398",
"0.51941276",
"0.51830447",
"0.51797163",
"0.5179525"
] | 0.7278442 | 0 |
Objective: This method takes in an array of stock prices, where position 0 is day 1, position 1 is day 2, etc. The method identifies the highest stock value, purchases the lowest stock value that occurs before the stock hits that highest value, and then sells at the highest for a profit. | def stock_picker(stock_prices)
lowest, highest = 9999999999, 0
index_of_highest, index_of_lowest = 0
stock_prices.each_with_index do |price, index|
if price > highest
highest, index_of_highest = price, index
end
end
index = 0
while index < index_of_highest
if stock_prices[index] < lowest
lowest, index_of_lowest = stock_prices[index], index
end
index += 1
end
puts "You bought stock on Day #{index_of_lowest + 1}, for $#{lowest}, and sold it on Day #{index_of_highest + 1} for $#{highest}. Your profit is $#{highest - lowest}."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stock_picker(array)\n best_buy = 0\n best_sell = 0\n max_profit = 0\n\n #first iterate through the array to find a buy day\n (0..(array.length-2)).each do |buy_date|\n\n #for each possible buy day, iterate through each sell day\n ((buy_date + 1)..array.length - 1).each do |sell_date|\n\n #check the price difference for those two days\n price_difference = array[sell_date] - array[buy_date]\n\n #if price diff is larger than the current max profit, store those days and max profit\n if price_difference > max_profit\n best_buy = buy_date\n best_sell = sell_date\n max_profit = price_difference\n end\n end\n end\n puts \"day #{best_buy}: buy at #{array[best_buy]}\"\n puts \"day #{best_sell}: sell at #{array[best_sell]}\"\n puts \"profit of #{max_profit}\"\n\n return [best_buy, best_sell]\nend",
"def stock_picker daily_prices_array\n best_buy_day = 0\n best_sell_day = 0\n best_profit = 0\n for buy_day in 0...daily_prices_array.length\n for sell_day in buy_day...daily_prices_array.length\n if daily_prices_array[sell_day] - daily_prices_array[buy_day] > best_profit\n best_profit = daily_prices_array[sell_day] - daily_prices_array[buy_day]\n best_sell_day = sell_day\n best_buy_day = buy_day\n end\n end\n end\n [best_buy_day, best_sell_day]\nend",
"def stock_picker(price_arr)\n\n profit = 0\n \n # Handles edge case of first price being a low point\n if price_arr[0] < price_arr[1]\n if price_arr.max - price_arr[0] > profit\n profit = price_arr.max - price_arr[0]\n best_range = [0, price_arr.index(price_arr.max)]\n end\n end\n \n #finds low points and their max earning potential updating the best range as it goes\n index = 1 # index is stepped up each loop to keep up with the index of the price\n price_arr[1..-2].each do |price|\n remaining_prices = price_arr[index..-1]\n if price_arr[index - 1] > price && price_arr[index + 1] > price\n if remaining_prices.max - price > profit\n profit = remaining_prices.max - price\n best_range = [price_arr.index(price), remaining_prices.index(remaining_prices.max) + index]\n end\n end\n index +=1 # index stepper\n end\n \n puts \"profit = #{profit}$\"\n best_range\n end",
"def stock_picker(prices) \n min_price = Float::INFINITY\n day_min_cost = 0\n max_price = -Float::INFINITY\n profit = -Float::INFINITY\n best_days = []\n\n prices.each_with_index do |price, day|\n if price < min_price \n min_price = price\n day_min_cost = day\n end\n \n if price - min_price > profit && day > day_min_cost\n max_price = price\n profit = price - min_price\n best_days = [day_min_cost, day]\n end\n end\n\n if best_days.empty?\n # In the case that the prices are decreasing order and there are no duplicates, the best days \n # to buy is the second to last day and the best day to sell is the last day\n best_days = [prices.length - 2, prices.length - 1]\n else\n best_days\n end\nend",
"def stock_picker(number_array)\n #Stores current profit to be gained\n profit = 0\n #Stores the maximum profit from the combination of previous days\n max_profit = 0\n #Stores the days in which max profit can be had. stored_days[0] is buy day. stored_days[1] is sell day\n stored_days = [0, 0]\n\n #Loops through all numbers in array. Compares each iteration against all numbers from the iteration to the end of the array for max profit\n for i in 0..number_array.length-1\n # p \"Day #{i}: \"\n for j in i..number_array.length-1\n if number_array[j] < number_array[i]\n break\n else\n profit = number_array[j] - number_array[i]\n # p \"buy: \" + number_array[i].to_s + \" sell: \" + number_array[j].to_s + \" profit: \" + profit.to_s\n if profit > max_profit\n max_profit = profit\n stored_days[0] = i\n stored_days[1] = j\n end\n end\n end\n end\n return stored_days\nend",
"def pick_stocks(prices)\n profits = []\n pairs = []\n prices.each_with_index do |price_b, buy_date|\n prices.each_with_index do |price_s, sell_date|\n if sell_date > buy_date\n profits << price_s - price_b\n pairs << [buy_date, sell_date]\n end\n end\n end\n pairs[profits.index(profits.max)]\nend",
"def stock_picker(prices)\n acc_profit = 0\n acc_buy_date = 0\n acc_sell_date = 0\n \n profits = prices.map.with_index do |price, index|\n remaining_days = prices[index..-1] # to create an array that becomes smaller each iteration from index 0\n maximum = remaining_days.max # to identify the maximum number in that iteration's array\n highest_value = maximum - price # price is at index 0, so maximum minus minimum for each one will help identify the best buy/sell dates\n \n # create accumilator for index and value of highest profit\n if highest_value > acc_profit\n acc_profit = highest_value\n acc_buy_date = prices.index(price)\n acc_sell_date = prices.index(maximum)\n end\n\n end\n \n p \"Buy on day #{acc_buy_date} and sell on day #{acc_sell_date} for a profit of $#{acc_profit}.\"\n end",
"def stock_prices(array)\n i = 0\n \n max_profit = -1\n buy_day = nil\n sell_day = nil\n \n length = array.length\n \n while i < length - 1\n j = i + 1\n \n while j < length\n profit = array[j] - array[i]\n \n if profit > max_profit\n max_profit = profit\n buy_day = i\n sell_day = j\n end\n \n j += 1\n end\n \n i += 1\n end\n \n return \"Buy day: #{buy_day}. Sell day: #{sell_day}.\"\nend",
"def stock_picker(array)\n sorted_stocks = array.sort.reverse\n profit = 0\n days_buy_sell = []\n sorted_stocks.each do |price_sell|\n array.each do |price_buy|\n if price_buy < price_sell && array.index(price_sell) > array.index(price_buy) && price_sell - price_buy > profit\n days_buy_sell = [array.index(price_buy), array.index(price_sell)]\n profit = price_sell - price_buy\n end\n end\n end\n days_buy_sell\nend",
"def stock_picker(stock_arr)\n highest_profit = 0 \n best_day_to_buy = 0 \n best_day_to_sell = 0 \n\n # Return 0- 9 but due to \"...\" it means it will exclude running the last number \n for i in 0...stock_arr.length \n #I am using a nested array so I can keep track of one number and use the other to iterate \n # Ex. [0, 1-8],[1, 2-8], [2, 3-8], .. [8, 8-8] and so on \n #I am doing this so I can use the i index postion to keep track of each day \n # Then I will use the second for loop to iterate through the stock_arr again and compare and calculate\n # those value to what I have in i(the tracked day) \n # I keep the calculation in profit_calculating until I find the profit_calculating becomes a number with the highest_profit \n for j in i+1...stock_arr.length do \n profit_calculating = stock_arr[j] - stock_arr[i]\n if highest_profit < profit_calculating\n highest_profit = profit_calculating\n best_day_to_buy = i \n best_day_to_sell = j \n end\n end \n end\n return \"[#{best_day_to_buy}, #{best_day_to_sell}] with a profit of #{highest_profit}\"\n\nend",
"def stock_picker(array)\n max_profit = 0\n buy_sell_days = [0,0]\n array.each_with_index do |buy_price, buy_day|\n array.each_with_index do |sell_price, sell_day|\n if buy_day > sell_day\n next\n end\n if sell_price - buy_price > max_profit\n max_profit = sell_price - buy_price\n buy_sell_days = [buy_day, sell_day]\n end\n end \n end \n p buy_sell_days\nend",
"def stock_picker(array)\n best_days = Hash.new(0)\n\n array.each_with_index do |buy_price, idx1|\n buy_day = idx1\n (idx1 + 1...array.length).each do |idx2|\n sell_day = idx2\n sell_price = array[idx2]\n if buy_price <= sell_price\n best_days[[buy_day, sell_day]] = sell_price - buy_price\n end\n end\n end\n result = greatest_value_in_hash(best_days)\n\n # Days start at 0, wchich is the very first day of the prices\n return \"Best day to buy: #{result[0]}\\nBest day to sell: #{result[1]}\\nProfit: $#{result[2]}\"\nend",
"def best_profit_from_yesterday_greedy(prices_array)\n\n lowest_thus_far = prices_array[0]\n max_profit = 0\n\n prices_array.each do |price|\n if price < lowest_thus_far\n lowest_thus_far = price\n end\n\n potential_profit = price - lowest_thus_far\n if(potential_profit > max_profit)\n max_profit = potential_profit\n end\n end\n max_profit\nend",
"def stock_picker(prices)\n profits_per_day = {}\n prices.each_with_index do |value, index|\n break if index == prices.length - 1\n profit = prices[index + 1] - value\n if (index + 1 == prices.length - 1)\n profits_per_day[profit] = [index, index + 1]\n break\n end\n for i in (index + 2..prices.length - 1)\n profit = prices[i] - value > profit ? prices[i] - value : profit\n end\n profits_per_day[value] = profit\n end\n return profits_per_day.max_by{|k,v| v}\nend",
"def computeBuySellToMaximizeProfit()\n currentStock = \"\"\n i = 0 # Loop counter\n while i < @days.size do # Traverse the data for each date to find price differences\n if i == @days.size - 1 # For the final week\n puts \"#{@days[i]} SELL #{currentStock}\"\n break\n end\n weeklyDifferences = [] # Stores the price differences between closing prices for all stocks in a particular week\n @data.each_with_index do |(key, value), index| # Traverse the data corresponding to current date for each key (stock)\n stockDifferences = {} # Stores the price difference between closing prices for a stock in a particular week\n stockDifferences[:stock] = key\n stockDifferences[:difference] = (value[i+1][:close].to_f - value[i][:close].to_f).round(5) # value[i+1] represents the next date for the stock data\n weeklyDifferences << stockDifferences\n end\n mostProfitableStock = getMostProfitableStock(weeklyDifferences)\n if i == 0 # For week 1\n puts \"#{@days[i]} BUY #{mostProfitableStock}\"\n currentStock = mostProfitableStock\n elsif mostProfitableStock == currentStock # If the stock already bought is more profitable\n puts \"#{@days[i]} HOLD #{mostProfitableStock}\"\n else\n puts \"#{@days[i]} SELL #{currentStock}, BUY #{mostProfitableStock}\"\n currentStock = mostProfitableStock \n end\n i = i + 1\n end\n end",
"def stock_picker prices\n max_profit = 0-Float::INFINITY\n buy_day = 0\n sell_day = 0\n\n prices.each.with_index do |first_price,first_index|\n profits_for_day = prices.map.with_index do |second_price,second_index|\n if first_index < second_index\n second_price - first_price\n else\n 0-Float::INFINITY\n end\n end\n max_profit_for_day = profits_for_day.max\n if max_profit_for_day > max_profit\n max_profit = max_profit_for_day\n buy_day = first_index\n sell_day = profits_for_day.index(max_profit_for_day)\n end\n end\n\n return [buy_day,sell_day]\nend",
"def get_max_profit(stock_prices_yesterday)\n # check for at least 2 prices\n if stock_prices_yesterday.length < 2\n raise IndexError, 'Need at least 2 prices to test.'\n end\n # initialize first price and the first possible profit\n min_price = stock_prices_yesterday[0]\n max_profit = stock_prices_yesterday[1] - stock_prices_yesterday[0]\n\n stock_prices_yesterday.each_with_index do |current_price, index|\n if index == 0 then next end\n # see what our profit would be if we bought at the\n # min price and sold at the current price\n potential_profit = current_price - min_price\n # update max_profit\n max_profit = [max_profit, potential_profit].max\n # update min_price\n min_price = [min_price, current_price].min\n end\n return max_profit\nend",
"def stock_picker(prices)\n\n\t# Best available [buy, sell] days for each buy day\n\tbest_days = []\n\tprices.each_index do |i|\n\t\tavailable_days = prices[i...prices.size] # only same day or after are valid sell days\n\t\tbest_days << [i, prices.index(available_days.max)]\n\tend\n\n\t# Calculates profit of each best day, same size and index as best_days\n\tprofits = []\n\tbest_days.each {|i| profits << prices[i[1]] - prices[i[0]] }\n\n\t# Returns [buy, sell] day pair matching index of highest profit\n\tbest_days[profits.index(profits.max)]\nend",
"def stock_picker stock_prices\n coll = Hash.new \n stock_prices.each_index do |i|\n stock_prices.map.with_index(i) do |e, j|\n if stock_prices[j] && stock_prices[j] > stock_prices[i]\n coll[[i, j]] = stock_prices[j] - stock_prices[i]\n end\n end\n end\n\n coll = coll.key(coll.values.max)\n puts \"Buy on day:\\t#{coll[0]} \\nSell on day:\\t#{coll[1]}\"\n puts \"Profit ($):\\t#{stock_prices[coll[1]] - stock_prices[coll[0]]}\"\nend",
"def stock_picker(arr)\n lowest = [arr[0],0]\n highest = [arr[0],0]\n lowest_i = highest_i = nil\n max_gain = 0\n \n for i in 1...arr.count\n # Every time see a price drop compare to previous price\n # 1. calculate the max gain from all previous time span\n # 2. if this current max gain is greater than all time max gain, it becomes the new all time max gain\n # 3. record lowest and highest price index\n if arr[i] < arr[i-1]\n if max_gain < highest[0] - lowest[0]\n max_gain = highest[0] - lowest[0]\n lowest_i, highest_i = lowest[1], highest[1]\n end\n end\n # This is the tricky part. Whenever found a new lowest price:\n # Reset highest price, because previous highest price don't matter no more\n highest = lowest = [arr[i], i] if arr[i] < lowest[0]\n # This is just every time it found a higher highest price, will use the higher price\n highest = [arr[i], i] if arr[i] > highest[0]\n end\n [lowest_i, highest_i]\nend",
"def get_max_profit_v3(yesterday_stock_prices)\n\n min_price = yesterday_stock_prices[0]\n max_profit = 0\n\n # go through every price on the list\n yesterday_stock_prices.each do |current_price|\n\n # ensure min price is lowest price we've seen so far\n min_price = [min_price, current_price].min\n\n # see what our profit woudl be if we bought at the\n # min price and sold at the current price\n potential_profit = current_price - min_price\n\n # update max_profit if we can do better\n max_profit = [max_profit, potential_profit].max\n\n end\n\n max_profit\n\n end",
"def stock_picker(prices)\n buy_date = 0\n sell_date = 0\n max_profit = 0\n \n (0...prices.size).each do |buy|\n ((buy + 1)...prices.size).each do |sell|\n \n profit = prices[sell] - prices[buy] \n if max_profit < profit\n max_profit = profit\n buy_date = buy\n sell_date = sell\n end\n end\n end\n [buy_date, sell_date]\nend",
"def stock_picker(stocks)\n biggest_price = 0\n profitable_days = []\n (0...stocks.length).each do |i|\n (i + 1...stocks.length).each do |j|\n day = stocks[i][0]\n price = stocks[i][1]\n other_day = stocks[j][0]\n other_price = stocks[j][1]\n stock_price = price - other_price\n if stock_price.abs > biggest_price\n biggest_price = stock_price\n profitable_days = [day, other_day]\n end\n end\n end\n\n profitable_days\nend",
"def stock_prices(array)\n\tlargest_difference = 0\n\tarray.each_with_index {| value, index| \n\t\tarray.each { |i|\n\t\t\tdifference = value - i\n\t\t\tif (difference <= largest_difference) && (index < array.rindex(i))\n\t\t\t\tnegative_array = [] << difference\n\t\t\t\tnegatives = [index, array.rindex(i)]\n\t\t\t\tlargest_difference = difference\n\t\t\tend\n\t\t\t}\n\t\t}\n\t\tif negative_array.nil?\n\t\t\tputs \"Buy/sell [0,1]\"\n\t\telse\n\t\t\tputs \"Buy/sell #{negatives}\"\n\t\tend\n\tend",
"def stock_picker(prices)\n\tgreatest_profit = 0\n\tbuy_day, sell_day = nil, nil\n\n\t(prices.length - 1).times do |day|\n\t\t((day+1)..(prices.length - 1)).each do |day2|\n\t\t\tcurrent_profit = prices[day2] - prices[day]\n\n\t\t\tif current_profit > greatest_profit\n\t\t\t\tbuy_sell = [day,day2] \n\t\t\t\tgreatest_profit = profit\n\t\t\tend\n\t\tend\n\tend\n\n\treturn [buy_day, sell_day]\nend",
"def stock_picker(prices)\n index = 0\n lowest = 0\n best_value = []\n for i in prices\n for j in prices[index..prices.length-1]\n if i - j < lowest\n lowest = i - j # lowest will be equal to the greatest price difference (greatest negative number)\n min = prices.index(i) # index of buy date\n max = prices.index(j) # index of sell date\n end\n end\n index += 1 # increments each iteration to ensure sell dates cannot be past dates\n end \n best_value << min\n best_value << max\n puts \"#{best_value} If you buy on day #{min} and sell on day #{max},\n you will make $#{lowest.abs} profit.\"\nend",
"def get_max_profit(stocks)\n min_price = stocks[0]\n biggest_diff = stocks[1] - min_price\n\n # keep track of biggest difference, and smallest price\n stocks.each_with_index do |stock, i|\n next if i == 0 # skip first\n curr_diff = stock - min_price\n biggest_diff = curr_diff if curr_diff > biggest_diff\n\n min_price = stock if stock < min_price\n end\n\n biggest_diff\nend",
"def stock_picker(arr)\n best_days = []\n arr.each do |i|\n arr.each do |x|\n if arr.index(x) > arr.index(i)\n if x - i > 0\n best_days.insert(x - i, \"Buying day #{arr.index(i)} and selling day #{arr.index(x)} gives the highest possible profit of #{x - i}\")\n end\n end\n end\n end\n best_days.last\nend",
"def get_max_profit_v2(yesterday_stock_prices)\n\n max_profit = 0\n\n # go through every price (with its index as the time)\n yesterday_stock_prices.each_with_index do |earlier_price, earlier_time|\n\n # and go through all Later Prices\n (yesterday_stock_prices[+1..-1]).each do |later_price|\n\n # see what our profit will be if we bought at the\n # earlier price and sold at the later price\n potential_profit = later_price - earlier_price\n\n # update max_profit if we can do better\n max_profit = [max_profit, potential_profit].max\n\n end\n\n end\n\n max_profit\n end",
"def find_greatest_profit\n\n @stock_prices_yesterday.each.with_index do |buy_amount, index|\n\n #Set biggest profit to the first transaction to avoid errors caused by a comparision with nil.\n @biggest_profit ||= @stock_prices_yesterday[0] - @stock_prices_yesterday[1]\n\n counter = 1\n while index + counter < 480\n if (@stock_prices_yesterday[index + counter] - buy_amount) > @biggest_profit\n @biggest_profit = @stock_prices_yesterday[index + counter] - buy_amount\n @buy_price = @stock_prices_yesterday[index]\n @buy_time = index\n @sell_price = @stock_prices_yesterday[index + counter]\n @sell_time = index + counter\n counter += 1\n puts counter\n else\n counter +=1\n puts counter\n end\n end\n end\n @biggest_profit\n end",
"def stock_picker(prices)\n\t# Empty hash for saving the buy & sell days (key) and the proffit (value)\n\tbuy_sell = Hash.new\n\n\tprices.each do |buy|\n\t\t# loop inside the loop that caluclates proffit ONLY IF the sell date has higher index than the buy date in the array.\n\t\tprices.each do |sell|\n\t\t\tif prices.index(sell) > prices.index(buy)\n\t\t\t\tproffit = sell - buy\n\t\t\t\t# Saves the buy index, sell index and proffit into our hash\n\t\t\t\tbuy_sell[\"#{prices.index(buy)}, #{prices.index(sell)}\"] = proffit\n\t\t\tend\n\t\tend\n\tend\n\t# lists the hash key (buy & sell day) that had the highest proffit value.\n\tputs buy_sell.key(buy_sell.values.max)\nend",
"def max_profit(stocks)\n max = 0\n buy = stocks[0]\n\n stocks.each_with_index do |sell, index|\n # ignore the first index just because already set it above\n next if index == 0\n\n current_profit = sell - buy\n\n # if the current profit is less than 0, there is no way the\n # prices could possibly be used to generate the max profit\n # therefore start making new comparisons from this point\n # forward\n if current_profit < 0\n buy = sell\n end\n\n # evaluate the max everytime\n max = [max, current_profit].max\n end\n\n if max == 0\n return -1\n end\n\n return max\nend",
"def stock_picker(stock_prices)\n\n max_profit = 0\n best_days = []\n\n stock_prices.each_with_index do |buying_price, index|\n (index+1).upto(stock_prices.length - 1) do |selling_index|\n selling_price = stock_prices[selling_index]\n profit = selling_price - buying_price\n if profit > max_profit\n max_profit = profit\n best_days = [index, selling_index]\n end\n\n end\n end\n best_days\nend",
"def stock_picker(arr)\n profits = []\n arr.each_with_index do |price, day|\n arr[day + 1..-1].each do |price2, day2|\n profit = price - price2\n profits << profit.abs if profit.negative?\n end\n end\n profits.empty? ? -1 : profits.max\nend",
"def stock_picker(array)\n\n\n\ti = 0 \n\tj = 1\n\n\tprofit_list = Array.new\n\n\twhile i < array.length do\n\t\twhile (j <= array.length && j > i) do\n\t\t\tprofit = array[j].to_i - array[i].to_i\n\t\t\tprofit_list << profit\n\t\t\tif profit_list.max == profit\n\t\t\t\tbuy = i\n\t\t\t\tsell = j\n\t\t\tend\n\t\t\t\n\t\t\tj += 1\n\t\tend\n\t\ti += 1\n\t\tj = i + 1\n\tend\n\tputs [buy,sell]\nend",
"def stock_picker(stocks)\n buy_day, sell_day, max_profit = 0, 0, 0\n for i in (0...stocks.length - 1)\n buy, possible_sales = stocks[i], stocks[i+1..-1]\n best_sale = possible_sales.max # Find the best price we can still sell for\n current_profit = best_sale - buy\n if current_profit > max_profit\n max_profit = current_profit # New standard we'll have to beat\n buy_day = i + 1 # If i is 0, we should buy on day 1\n sell_day = sales.index(best_sale) + buy_day + 1 # Add 1 in both cases to correct for indexing\n end\n end\n print [buy_day,sell_day]\nend",
"def stock_picker prices\n\tbest_days = []\n\tbest_profit = 0\n\n\tprices.length.times do |i|\n\t\tj = i\n\t\tfor j in i...prices.length\n\t\t\tif prices[j] - prices[i] > best_profit\n\t\t\t\tbest_profit = prices[j] - prices[i]\n\t\t\t\tbest_days[0] = i\n\t\t\t\tbest_days[1] = j\n\t\t\tend\n\t\tend\n\tend\n\tbest_days\nend",
"def stock_profit(stocks)\n minimum = stocks[0]\n profit = stocks[1] - stocks[0]\n\n (1...stocks.size).each do |price|\n current_price = stocks[price]\n current_profit = current_price - minimum\n\n minimum = [minimum, current_price].min\n\n profit = [profit, current_profit].max\n end\n\n profit\nend",
"def get_max_profit(stock_prices_yesterday)\n min_price = stock_prices_yesterday.first\n max_profit = stock_prices_yesterday[1] - min_price\n stock_prices_yesterday.each.with_index do |price, idx|\n next if idx == 0\n potential_profit = price - min_price\n max_profit = potential_profit if potential_profit > max_profit\n min_price = price if price < min_price\n end\n max_profit\nend",
"def stock_picker(arr)\n final_profit = 0\n current_profit = 0\n final_dates = []\n\n arr.each do |buy_price|\n buy_date = arr.index(buy_price)\n \n arr.each do |sell_price| \n sell_date = arr.index(sell_price)\n \n if (sell_date > buy_date && sell_price > buy_price) \n current_profit = sell_price - buy_price\n if current_profit > final_profit\n final_profit = current_profit\n final_dates = [buy_date, sell_date]\n end\n end \n end\n end\n puts final_dates\nend",
"def stock_picker(input)\n \n best_profit = 0\n buy_sell_days = [0,0]\n \n# Since we need to buy before we can sell, we should only consider\n# buying up until the second-to-last day:\n \n for x in 0..input.length-2\n \n# We'll always sell after we buy, so we use nested 'for' loops to\n# check our sell value against our buy value and store our max profit:\n \n for y in 1+x..input.length-1\n \n profit = (input[y] - input[x])\n \n if profit > best_profit\n best_profit = profit\n buy_sell_days = [x,y]\n end\n \n end\n \n end\n \n return buy_sell_days\n \nend",
"def stock_picker(arr)\n\n max_profit = 0 \n\n days = []\n\n arr.each.with_index do |num1, idx1|\n arr.each.with_index do |num2, idx2|\n if idx1 < idx2 && (num2 - num1) > max_profit\n max_profit = num2 - num1\n days = [idx1, idx2]\n end\n end\n end\n\n # return most profitable days \n days \n \n end",
"def stock_picker(arr)\n answer = []\n highest_value = 0\n buy = 0\n sell = 0\n\n for i in 0..(arr.length-1) do\n for j in (i+1)..(arr.length-1) do\n if arr[j] - arr[i] > highest_value\n highest_value = arr[j] - arr[i]\n buy = i\n sell = j\n end\n end\n end\n\n answer.push(buy)\n answer.push(sell)\n\n puts answer\nend",
"def get_max_profit_v4(yesterday_stock_prices)\n\n # make sur we have at least two prices\n if yesterday_stock_prices.length < 2\n #raise ArgumentError, 'Getting a profit requires at least 2 prices'\n return 'Getting a profit requires at least 2 prices'\n end\n\n # we'll greedly min_price and max_profit, so we initialize\n # them to the first price and first possible profit\n min_price = yesterday_stock_prices[0]\n max_profit = yesterday_stock_prices[1] - yesterday_stock_prices[0]\n\n # go through every price\n yesterday_stock_prices.each_with_index do |current_price, index|\n\n # skip the first time since we already used it\n # when we initialize min_price and max_profit\n next if index.zero?\n\n # see what profit will be if we bought at min_price\n # and sold at the current_price\n potential_profit = current_price - min_price\n\n # update max_profit if we can do better\n max_profit = [max_profit, potential_profit].max\n\n # update min_price so it's always the\n # lowest price we've seen so far\n min_price = [min_price, current_price].min\n\n end\n\n max_profit\n\n end",
"def max_profit(prices)\n i = 0\n valley = prices.first\n peak = prices.first\n max_profit = 0\n\n while i < prices.length - 1\n while i < prices.length - 1 && prices[i] >= prices[i + 1]\n i += 1\n end\n valley = prices[i]\n\n while i < prices.length - 1 && prices[i] <= prices[i + 1]\n i += 1\n end\n peak = prices[i]\n\n max_profit = peak - valley\n end\n\n max_profit\nend",
"def max_profit(stock_prices)\n\tmin_buying_point = stock_prices[0]\n\tmax_profit = 0;\n\n\tstock_prices.each do |price|\n\t\tmin_buying_point = [min_buying_point, price].min()\n\n\t\tcurrent_profit = price - min_buying_point \n\n\t\tmax_profit = [max_profit, current_profit].max()\n\tend\n\n\treturn max_profit\nend",
"def stock_picker(stock_prices)\n\n\tstock_prices.map!{|price| price.to_i}\t#Convert array values to integers\n\n#Empty array for buy-low and sell-high differences\n\tdifference = []\n\n#Each day is considered a (low_price) and respective (high_price) is determined\n\tstock_prices.map.with_index do |price, i|\n\t\tlow_price = price\n\t\thigh_price = stock_prices[i+1..-1].max\n#The differnces array collects all high-low differences\t\t\n\t\tdifference.push(high_price.to_i - low_price.to_i)\n\tend\n\n\tday_1 = difference.index(difference.max)\t#Get day of highest difference possible\n\tday_2 = stock_prices.index(stock_prices[day_1+1..-1].max)\t#Calculate correspoinding high value\n\n\ta = [day_1]\n\tb = [day_2]\n\n\tprint a + b\nend",
"def stock_picker(prices)\n\tmax_diffs_for_each_day = []\n\tsecond_days_for_each_max_diff = []\n\t# the - 1 ignores buys on the last day, which can't be sold\n\t# also keeps the remaining_prices range beginning from overshooting its end\n\tfor day in (0...(prices.length - 1)) \n\t\tremaining_prices = prices[(day + 1)...prices.length]\n\t\tmax_remaining_price = remaining_prices.max\n\t\tmax_diffs_for_each_day << (max_remaining_price - prices[day])\n\t\t# for tied maxes, index will return the earliest day, which we want\n\t\t# the + 1 accounts for zero-indexing of remaining_prices\n\t\tsecond_days_for_each_max_diff << (remaining_prices.index(max_remaining_price) + day + 1)\n\tend\n\tmaxest_diff = max_diffs_for_each_day.max\n\t# for tied maxes, index will return the earliest day, which we want\n\tfirst_day = max_diffs_for_each_day.index(maxest_diff)\n\tsecond_day = second_days_for_each_max_diff[first_day]\n\t[first_day, second_day]\nend",
"def stock_picker(stock_values)\n n = stock_values.length\n max_profit = 0;\n start_day = nil\n end_day = nil\n\n for i in (0...n)\n for j in (i + 1...n)\n potential_profit = stock_values[j] - stock_values[i]\n if potential_profit > max_profit\n max_profit = potential_profit\n start_day = i\n end_day = j\n end\n end\n end\n\n [start_day, end_day]\nend",
"def stock_picker prices\n\tbest_buy_date = nil\n\tbest_sell_date = nil\n\tbest_profit = 0\n\tprices.each_index do |buy_date|\n\t\t(buy_date+1...prices.length).each do |sell_date|\n\t\t\tprofit = prices[sell_date] - prices[buy_date]\n\t\t\tif profit > best_profit\n\t\t\t\tbest_profit = profit\n\t\t\t\tbest_buy_date = buy_date\n\t\t\t\tbest_sell_date = sell_date\n\t\t\tend\n\t\tend\n\tend\n\t[best_buy_date,best_sell_date]\nend",
"def stockPicker(prices)\n pair = [0,0]\n profit = 0\n prices.each_with_index do |buy, i|\n # Find highest sell day\n sell = prices[i..-1].max\n if profit < (sell-buy)\n pair[0] = i\n pair[1] = prices[i..-1].index(sell)+i # Find index of that sell day\n profit = sell-buy\n end\n end\n pair\nend",
"def get_max_profit_2(array)\n\n max_profit = 0\n\n # go through every price (with it's index as the time)\n array.each_with_index do |number, index|\n\n # and go through all the LATER prices\n for later_price in array[index+1..-1]\n\n # see what our profit would be if we bought at the\n # earlier price and sold at the later price\n potential_profit = later_price - number\n\n # update max_profit if we can do better\n max_profit = [max_profit, potential_profit].max\n end\n end\n\n return max_profit\nend",
"def stock_picker(prices)\n\t# Storing variables what I use later\n\t$d = 0\n\t$small = 0\n\t$big = 0\n\tprices.each do |x|\t\t\t# iterating through all prices elements\n\t\ty = prices.index(x)+1 \t# y is the next element in prices array\n\t\twhile y < (prices.length)\t# it runs till we have something in the array\n\t\t\tif (x-prices[y]) < $d \t# only runs when the difference of x element and the next one is lower than the previous pair's (which is stored in $d)\n\t\t\t\t$d = x-prices[y] \t# so we store the lowest difference in $d\n\t\t\t\t$small = prices.index(x) \t# we store in $small the index number of x in the array, that is the day when we need to buy, the lowest price\n\t\t\t\t$big = y \t\t\t\t\t# y is the index number in the array of the number, which is the highest, and have the biggest difference with x\n\t\t\t\ty += 1 \t\t\t\t\t\t# add +1 to y so we can loop through the array\n\t\t\telse\n\t\t\t\ty += 1 \t\t\t\t\t\t# if the difference of the following pair is not smaller than the previous ones then we just move on and don't change $small and $big and $d\n\t\t\tend\n\t\tend\n\tend\n\tresult = []\n\tresult.push($small, $big) \t\t\t# pushing the results into result array\n\tputs result\nend",
"def stock_picker(prices)\n\n profit = 0\n\n (prices.length - 1).times do |i|\n\n curr_buy_price = prices[0]\n prices.delete_at(0)\n\n if prices.max - curr_buy_price > profit\n profit = prices.max - curr_buy_price\n buy_index = i\n sell_index = i + prices.index(prices.max) + 1\n @best_days = [buy_index, sell_index]\n end\n\n end\n\n p @best_days\n \nend",
"def best_profit (stock_prices_yesterday)\n min_price = stock_prices_yesterday[0]\n max_profit = stock_prices_yesterday[1] - stock_prices_yesterday[0]\n\n stock_prices_yesterday.each do |stock_price|\n if stock_price <= min_price\n min_price = stock_price\n elsif (stock_price - min_price) > max_profit\n max_profit = stock_price - min_price\n end\n end\n max_profit\nend",
"def stock_picker(stock_array)\n\n day_hash = Hash.new(0)\n day_index = 0\n stock_array.each { |day_number|\n day_hash[day_index] = day_number\n day_index += 1\n }\n\n day_hash_sell = day_hash.clone\n profit_best = Hash.new(0)\n profit_best_counter = nil\n day_hash.each do |key, value|\n\n buy = -value \n day_hash_sell.each do |key_sell, value_sell|\n\n #ensure day is only in futue\n if key_sell <= key then \n next\n end\n\n profit = buy + value_sell \n if profit_best_counter == nil || profit > profit_best_counter then \n #reset hash to ensure only 1 answer given\n profit_best = Hash.new(0)\n\n #track best days to buy/sell in array\n profit_best[key] = key_sell\n\n #keep track of best profit so far\n profit_best_counter = profit\n end \n end \n end\n puts profit_best\nend",
"def stock_picker(stock_prices)\n buying_price = 0\n buying_index = 0\n selling_price = 0\n max_profit = -1\n max_buy_index = 0\n max_sell_index = 0\n\n change_buy = true\n\n stock_prices.each_with_index do |price, day|\n selling_price = stock_prices[day + 1].to_i\n\n if change_buy\n buying_price = price.to_i\n buying_index = day\n end\n\n if buying_price > selling_price\n change_buy = true;\n else\n profit = selling_price - buying_price\n if profit > max_profit\n max_profit = profit\n max_sell_index = day + 1\n max_buy_index = buying_index\n end\n change_buy = false;\n end\n\n end\n\n [max_buy_index, max_sell_index]\n\nend",
"def max_stock_profit(stock_prices)\n\tlocal_min = stock_prices[0]\n\tlocal_max = stock_prices[1]\n\tmax_profit_so_far = local_max - local_min\n\n\tstock_prices[2..-1].each do |price|\n\n\t\tif local_max == nil || price > local_max\n\t\t\tlocal_max = price\n\t\t\tprofit = local_max - local_min\n\t\t\tmax_profit_so_far = profit if profit > max_profit_so_far\n\n\t\t# must 'reset' the max when the min is reset\n\t\t# I set the max to nil because you can't buy and sell\n\t\t# at the same time\n\t\telsif price < local_min\n\t\t\tlocal_min = price\n\t\t\tlocal_max = nil \n\t\tend \n\t\t# log(local_min, local_max, max_profit_so_far)\n\tend\n\t\treturn max_profit_so_far\nend",
"def max_profit(prices)\n current_profit = 0\n buy = 0\n sell = 0\n in_trade = false\n arr_idx_length = prices.length - 1\n\n prices.each_with_index do |value,index|\n if index == arr_idx_length && in_trade == true\n sell = value\n puts \"last day must sell. at #{value}\"\n current_profit += (sell-buy)\n puts \"current_profit: #{current_profit}\"\n break\n elsif index == arr_idx_length && in_trade == false\n break\n else\n end\n\n if in_trade == false\n if value < prices[index+1]\n buy = value\n in_trade = true\n puts \"buy at #{value}\"\n end\n else\n if value > prices[index+1]\n sell = value\n in_trade = false\n puts \"sell at #{value}\"\n current_profit += (sell-buy)\n puts \"current_profit: #{current_profit}\"\n end\n end\n end\n\n puts \"total profit: #{current_profit}\"\n\nend",
"def stock_picker(array)\n\n#store 2 numbered arrays that consist of every combination of numbers in the passed array\n manipulate_array = array.combination(2).to_a\n\n# change each array's 2 index to contain the difference of the two numbers\n manipulate_array.each do |i|\n i.push(i.max - i.min) \n end\n \n# sort the array by thier difference from largest to smalles \n sorted_array = manipulate_array.sort {|a,b| b[2] <=> a[2]}\n \n sorted_array.each do |i|\n# delete the sum from each combonation \n i.delete_at(2)\n# return the position of the smallest price that comes before the postion of the highest price (returning day to buy low then return the day to buy high)\n if array.index(i.min) < array.index(i.max)\n return [array.index(i.min),array.index(i.max)]\n break\n elsif i == sorted_array.last\n return \"There are no buy opportunities in this set of stock prices\"\n end\n end\nend",
"def get_max_profit(stocks)\n profit = 0\n transaction = Array.new(2)\n stocks.each_with_index do |buy, i|\n stocks[i+1..-1].each do |sell|\n potential_profit = sell - buy\n if potential_profit > profit\n profit = potential_profit \n transaction[0] = buy\n transaction[1] = sell\n end\n end\n end\n p \"Buy: #{transaction[0]}, Sell: #{transaction[1]} for Profit: #{profit}\"\nend",
"def max_profit(stock_prices_yesterday)\n max_diff = stock_prices_yesterday[1] - stock_prices_yesterday[0]\n stock_prices_yesterday[2..-1].each_with_index do |price, index|\n index += 1\n diff = stock_prices_yesterday[0..(index - 1)].map { |x| price - x }.max\n max_diff = diff if diff > max_diff\n end\n max_diff\nend",
"def stock_picker(arr)\n profit = 0\n bestdays = []\n\n arr.each_with_index do |buyp, buyi|\n arr.each_with_index do |sellp, selli|\n next unless buyi < selli && (sellp - buyp) > profit\n\n profit = sellp - buyp\n bestdays[0] = buyi\n bestdays[1] = selli\n end\n end\n puts \"#{bestdays[0]} and #{bestdays[1]}\"\nend",
"def get_max_profit(prices)\n raise IndexError(\"Must be at least 2 prices\") if prices.length < 2\n #initialize a current_max_profit and current_min\n current_min = prices[0]\n current_max_profit = prices[1] - prices[0]\n\n prices.each do |price|\n #calculate the potential profit and check if it's larger than current max profit\n potential_profit = price - current_min\n current_max_profit = [potential_profit, current_max_profit].max\n #update current_min\n current_min = [current_min, price].min\n end\n current_max_profit\nend",
"def stock_picker(arr)\n\thighestGain = 0\n\tbuyDay = 0\n\tsellDay = 0\n\n\tarr.each_index do |i|\n\t\tbiggestGainDayFrom = findDayWithHighestGainFrom(i, arr)\n\t\tif arr[biggestGainDayFrom] - arr[i] > highestGain\n\t\t\thighestGain = arr[biggestGainDayFrom] - arr[i]\n\t\t\tbuyDay = i\n\t\t\tsellDay = biggestGainDayFrom\n\t\tend\n\tend\n\treturn [buyDay,sellDay]\nend",
"def get_max_profit_3(array)\n\n min_price = array[0] #sets the minimum price starting at index 0\n max_price = 0\n\n max_profit = 0 #sets current max_profit to 0\n min_loss = 0\n\n\n array.each do |current_price| #simple iteration\n\n # ensure min_price is the lowest price we've seen so far\n min_price = [min_price, current_price].min\n max_price = [min_price, current_price].max\n\n # see what our profit would be if we bought at the\n # min price and sold at the current price\n potential_profit = current_price - min_price\n potential_loss = current_price - max_price\n\n # update max_profit if we can do better\n max_profit = [max_profit, potential_profit].max\n min_loss = [min_loss, potential_loss].min\n\n print \"current-price: #{current_price}\\n\"\n print \"min_price: #{min_price}\\n\"\n print \"max_price: #{max_price}\\n\"\n print \"-----------------------------\\n\"\n print \"potential_profit: #{potential_profit}\\n\"\n print \"potential_loss: #{potential_loss}\\n\"\n print \"-----------------------------\\n\"\n print \"max_profit: #{max_profit}\\n\"\n print \"min_loss: #{min_loss}\\n\"\n print \"\\n\"\n end\n\n return max_profit\nend",
"def getMostProfitableStock(weeklyValues)\n max = -1.0/0.0 \n mostProfitableStock = \"\"\n weeklyValues.each do |row| # Traverses through array of hashes to find maximum value\n if row[:difference] > max\n max = row[:difference]\n mostProfitableStock = row[:stock]\n end\n end\n mostProfitableStock\n end",
"def stock_picker (array)\n\tb = [] # Contains index of all valid max numbers\n\tpalce_holder = []\n\tvalid_max = nil\n\tmax_finder = 0\n\tmin = nil\n\tmax = nil\n\n\tif array.length == 0\n\t\tputs \"No Data Available.\"\n\t\treturn nil \n\tend\n\n\tif array.max == array[0]\n\t\twhile array[max_finder] == (array[max_finder..array.length-1]).max\n\t\t\tif (array[max_finder..array.length-1]).max == array.min\n\t\t\t\tputs \"An investment strategy could not be formulated based on the information supplied.\"\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\tmax_finder += 1\n\t\tend\n\t\tvalid_max = array[max_finder..array.length-1].max\n\telse \n\t\tvalid_max = array.max\n\tend\n\n\t#unless valid_max == array.min\n\n\t0.upto(array.length-1) do |x|\n\t\tif array[x] == valid_max\n\t\t\tb << x\n\t\tend\n\tend\n\t\n\tmax = b.last\n\n\tmin = array.index(array[0..max].min)\n\tputs \"#{[min,max]} for a profit of $#{array[max] - array[min]}\"\n\t[min,max]\n\n\nend",
"def stock_picker(prices)\n\t# Initialize everything to 0\n\tmin = 0\t\t\t# Day with lowest price so far\t\t\t\t\t\n\tbuy = 0\t\t\t# Buy day with best max_diff so far\n\tsell = 0\t\t# Sell day with best max_diff so far\n\tmax_diff = 0\t# Best value of prices[sell]-prices[buy]\n\t(1...prices.length).each do |i|\n\t\t# Go through each day - not necessary to do the first\n\t\tif prices[i] < prices[min]\n\t\t\t# If current price is less than current min:\n\t\t\tmin = i\t\t\t\t\t\t# Set as current min\n\t\tend\n\t\tdiff = prices[i] - prices[min]\t# Compare difference to current min\n\t\tif diff > max_diff\n\t\t\t# If it's better:\n\t\t\tbuy = min\t\t\t\t\t# Record min as day to buy\n\t\t\tsell = i\t\t\t\t\t# Record current day as day to sell\n\t\t\tmax_diff = diff\t\t\t\t# Record new max difference\n\t\tend\n\tend\n\t[buy, sell]\nend",
"def stock_picker(array)\n result = 0\n largest = 0\n# count is the value of the array to check against the arrays proceeding values, which are represented by step\n count = 0\n step = 1\n while count < array.length - 1\n while step < array.length\n result = array[step] - array[count]\n if result > largest && result > 0\n largest = result\n low = count\n high = step\n end\n step += 1\n end\n count += 1\n step = count + 1\n end\n if low == nil\n puts \"There was never a good day to buy and sell the stock\"\n else\n puts \"The best day to buy the stock was day #{low.to_s} at #{array[low].to_s}, and the best day to sell was day #{high.to_s} at #{array[high].to_s}\"\n end\nend",
"def get_max_profit(stock_prices)\n return 0 if stock_prices.length < 2\n \n min_stock = stock_prices[0]\n max_profit = stock_prices[1] - stock_prices[0]\n puts \"\\n#{min_stock}\"\n puts \"#{max_profit}\"\n stock_prices[1...stock_prices.length].each do |price|\n min_stock = [min_stock, price].min \n puts \"\\n#{min_stock}\"\n pot_max_profit = price - min_stock\n puts \"#{max_profit}\"\n max_profit = [max_profit, pot_max_profit].max\n puts \"#{max_profit}\"\n end\n \n max_profit\nend",
"def max_profit(prices)\n max_profit = 0\n min_price = 1_000_000\n\n 0.upto(prices.length - 1) do |i|\n if prices[i] < min_price\n min_price = prices[i]\n elsif prices[i] - min_price > max_profit\n max_profit = prices[i] - min_price\n end\n end\n\n max_profit\nend",
"def stock_picker(stock_array)\n buy_sell_output = []\n real_output = []\n largest_difference = 0\n \n for i in 0...stock_array.length() \n for j in 0...stock_array.length()\n if j > i and stock_array[j] - stock_array[i] > largest_difference\n largest_difference = stock_array[j] - stock_array[i]\n buy_sell_output.push(stock_array[i])\n buy_sell_output.push(stock_array[j])\n end\n \n end\n end\n buy_sell_output.sort!()\n #print buy_sell_output[0]\n # = 3\n #print buy_sell_output.last\n # = 15\n\n real_output.push(stock_array.index(buy_sell_output[0]))\n real_output.push(stock_array.index(buy_sell_output.last))\n print real_output\nend",
"def best_profit (stock_prices_yesterday)\n possible_sale_combinations = stock_prices_yesterday.combination(2).to_a\n profits = []\n possible_sale_combinations.each do |pair|\n buy_price = pair[0]\n sell_price = pair[1]\n profit = sell_price - buy_price\n profits << profit\n end\n profits.sort!\n profits.count\n max_profit = profits[-1]\n if max_profit < 0\n return 0\n else\n return max_profit\n end\nend",
"def stock_picker(arr)\n \n max = 0\n day1 = 0\n day2 = 0\n\n arr.length.times do |buy|\n arr.length.times do |sell|\n if buy < sell && (arr[sell] - arr[buy] > max)\n day1 = buy\n day2 = sell\n max = arr[day2] - arr[day1]\n end\n end\n end\n\n return [day1, day2]\nend",
"def stock_picker(prices)\n combinations = prices.combination(2).to_a\n profits = combinations.map { |days| days[1] - days[0] }\n (0...prices.size).to_a.combination(2).to_a[profits.index(profits.max)]\nend",
"def max_profit2(prices)\n max_profit, min_price = 0, +1.0/0.0\n profits_array = [0]*prices.length\n prices.each_with_index do |price,i|\n min_price = [price, min_price].min\n max_profit = [max_profit, price-min_price].max\n profits_array[i] = max_profit\n end\n max_profit, max_price = 0, -1.0/0.0\n reverse_max_profit = [0]*prices.length\n prices.reverse.each_with_index do |price,i|\n max_price = [price,max_price].max\n max_profit = [max_profit, max_price-price].max\n reverse_max_profit[prices.length-i-1] = max_profit\n end\n counter = 0\n max_profit = -1.0/0.0\n profits_array.each_with_index do |el,idx|\n max_profit = [max_profit,el+reverse_max_profit[idx]].max\n end\n max_profit\nend",
"def stock_picker(arr)\n\tbuy_day = 0\n\tsell_day = 0\n\told_profit = -999\n\n\tarr.each_with_index do |buy_price, buy_index|\n\t\tarr.each_with_index do |sell_price, sell_index|\n\t\t\tif sell_index <= buy_index\n\t\t\t\tnext\n\t\t\tend\n\t\t\tnew_profit = sell_price - buy_price\n\t\t\tif new_profit > old_profit\n\t\t\t\told_profit = new_profit\n\t\t\t\tbuy_day = buy_index\n\t\t\t\tsell_day = sell_index\n\t\t\tend\n\t\tend\n\tend\n\treturn [buy_day,sell_day]\nend",
"def stock_picker(prices, best_profit = -(2**(0.size * 8 -2)) )\t\n\tabs_max_sell = prices[1..-1].max\n\n\tmin_buy = prices[0..-2].min\n\tmin_buy_index = prices.index(min_buy)\n\n\tmax_sell = prices[(min_buy_index+1)..-1].max\n\tmax_sell_index = (min_buy_index + 1) + prices[(min_buy_index+1)..-1].index(max_sell)\n\n\tprofit = max_sell - min_buy\n\t\n\tif (profit > best_profit)\n\t\tbest_profit = profit\n\tend\n\tif (max_sell == abs_max_sell || prices[0..(min_buy_index-1)].length == 1)\n\t\tputs \"Best profit is #{best_profit}, buying on day #{min_buy_index} and selling on day #{max_sell_index}\"\n\telse\n\t\tprices = prices[0..(min_buy_index-1)]\n\t\tstock_picker(prices, best_profit)\n\tend\nend",
"def stock_prices(arr)\n min = arr[0]\n max = arr[0]\n big_gain = 0\n\n arr.each do |n|\n if n < min\n min = n\n max = n\n elsif n > max\n max = n\n end\n big_gain = max - min if max - min > big_gain\n end\n\n big_gain\nend",
"def stock_picker(prices)\n\n buy = 0\n sell = 0\n max = 0\n \n prices.each_index do |x|\n prices.each_index do |y|\n if prices[y] - prices[x] > 0 and prices[y] - prices[x] > max and y > x\n buy = x\n sell = y\n max = prices[y] - prices[x]\n end\n end\n end\n \n [buy, sell]\nend",
"def bestonetradeprofit(prices)\n # find highest difference between price and subsequent price\n # starting best is second - first\n max = prices[1] - prices[0]\n while prices.length > 1\n e = prices.shift\n prices.each {|v| \n if (v - e) > max \n max=(v-e)\n end\n }\n end\n return max\nend",
"def stock_picker(arr)\n buy = \"\"\n sell = \"\"\n biggest_difference = 0\n profit = 0\n arr.each_with_index do |day, index|\n #no days after last day so last day can't be the buy day\n if (day != arr[-1])\n #sell date must be after purchase date, therefore only want indicies after current\n future_date = (index +1)\n while future_date < arr.length\n profit = arr[future_date] - arr[index]\n if profit > biggest_difference\n buy = index\n sell = future_date\n biggest_difference = profit\n end\n future_date += 1\n end\n end\n end\n [buy,sell]\nend",
"def max_profit(prices)\n max = 0\n min = (2**(0.size * 8 -2) -1)\n\n prices.each do |price|\n if price < min\n min = price\n else\n max = [max, price - min].max\n end\n end\n\n max\nend",
"def single_profit(prices)\n profit = 0\n i = 0\n while i < prices.length do\n remainder = prices.slice(i+1, prices.length-1)\n if remainder.length > 0\n value = remainder.max - prices[i]\n if value > profit\n profit = value\n end\n end\n i+=1\n end\n profit\n \nend",
"def stock_picker(prices)\n i = 0\n diff = 0\n best_days = []\n (i...prices.length).each do |index_one|\n (i + 1...prices.length).each do |index_two|\n if prices[index_two] - prices[index_one] > diff\n diff = prices[index_two] - prices[index_one]\n best_days = [index_one, index_two]\n end\n end\n end\n best_days\n end",
"def on_2(prices)\n max_profit = 0\n min_valley = prices.max\n\n prices.each do |number|\n if number < min_valley\n min_valley = number\n elsif number - min_valley > max_profit\n max_profit = number - min_valley\n end\n end\n\n max_profit\n end",
"def stock_picker(prices_arr)\n buy_price = prices_arr[0]\n buy_index = 0\n profit = 0\n range = [0, 0]\n\n prices_arr.each_with_index do |price, index|\n if price < buy_price\n buy_price = price\n buy_index = index\n next\n end\n\n if price - buy_price > profit\n profit = price - buy_price\n range = [buy_index, index]\n end\n end\n return range\nend",
"def sell(stonks)\n \nreversed = stonks.reverse\nstocks_you_can_sell = stonks.slice(selling_array(stonks),100)\nbiggest = stocks_you_can_sell.max\nsell_day = stocks_you_can_sell.find {|stock| stock <= biggest}\n \nreturn sell_day\n\nend",
"def on2(prices)\n max_profit = 0\n\n prices.each_with_index do |number, index|\n prices.each_with_index do |another_number, another_index|\n next if index >= another_index\n\n max_profit = [another_number - number, max_profit].max\n end\n end\n\n max_profit\n end",
"def max_profit(prices)\n sell_one, sell_two = 0, 0\n buy_one, buy_two = Float::INFINITY, Float::INFINITY\n \n prices.each do |price|\n buy_one = [buy_one, price].min\n sell_one = [sell_one, price - buy_one].max\n buy_two = [buy_two, price - sell_one].min\n sell_two = [sell_two, price - buy_two].max\n end\n sell_two\nend",
"def stock_picker(array)\n # loop through array twice. Once to take value, 2nd to compare, store index into result\n result = []\n profit, buy_day, sell_day = 0, 0, 0\n\n array.size.times do |n|\n (n + 1).upto (array.size - 1) do |i|\n if (array[n] - array[i]) > profit\n profit = array[n] - array[i]\n buy_day = n\n sell_day = i\n end\n end\n end\n [buy_day, sell_day]\nend",
"def on2_2(prices)\n max_profit = 0\n\n return max_profit if prices.empty?\n\n prices.each_with_index do |number, index|\n max_price_after_date = prices[index..-1].max\n\n next if max_price_after_date <= number\n\n max_profit = [max_price_after_date - number, max_profit].max\n end\n\n max_profit\n end",
"def stock_picker(prices)\n current_max = 0\n buy_index = 0\n sell_index = 1\n (0...prices.length - 1).each do |buy|\n (buy + 1...prices.length).each do |sell|\n if prices[sell] - prices[buy] > current_max\n current_max = prices[sell] - prices[buy]\n buy_index = buy\n sell_index = sell\n end\n end\n end\n [buy_index, sell_index]\nend",
"def stock_picker(array)\n profit = -999999\n counter = 0\n result = []\n while counter < array.length - 1\n array.each_with_index do |el, index|\n if counter < index && profit < (el - array[counter])\n profit = el - array[counter]\n result[0] = counter\n result[1] = index\n end\n end\n counter += 1\n end\n result\nend",
"def stock_picker(prices)\n #results array indicates the best time to buy and then sell the stock\n results = [0, 0]\n #this variable keeps tabs of the best positive price difference\n greatest_price_difference = 0\n prices.each_with_index do |price, current_index|\n #index_counter keeps track of the index in the array as it's being\n #looped in the while loop\n \n index_counter = current_index + 1\n #the while loop loops through the array starting with the first \n #potential day to buy and compares the potential difference\n #each day going forward to determine which day would be best to sell on\n #should they buy the stock today\n while index_counter < prices.length\n \n price_difference = prices[index_counter] - prices[current_index]\n if price_difference > greatest_price_difference\n #price difference is updated if a greater difference is found\n greatest_price_difference = price_difference\n results[0] = current_index \n results[1] = index_counter \n end\n index_counter += 1\n end\n end\n\n\n\n puts results\nend",
"def max_profit(prices)\n max_profit = 0\n min_price = prices[0]\n \n prices.each do |price|\n min_price = [min_price, price].min\n max_profit = [max_profit, price - min_price].max\n end\n \n max_profit\nend",
"def max_profit(prices)\n min_price = prices[0]\n max_pro = 0 \n price.each do |price|\n if price <= min_price\n min_price = price\n elsif price - min_price > max_pro\n max_pro = price - min_price\n end\n end\n max_pro\nend",
"def max_profit(prices)\n # Test for boundary conditions\n return 0 if prices.length <= 1\n profit = 0\n for i in 1..(prices.length-1) do\n if prices[i] > prices[i-1]\n profit = profit + (prices[i] - prices[i-1])\n end\n end\n return profit\nend",
"def stock_picker(price_arr)\n profit = 0\n trade_days = [0,0]\n price_arr.each_with_index do |buy_value, buy_day|\n price_arr.each_with_index do |sell_value, sell_day|\n if (sell_value - buy_value) > profit\n profit = (sell_value - buy_value)\n trade_days[0] = buy_day\n trade_days[1] = sell_day\n end\n end\n end\n \"buy on #{trade_days[0]} and sell on #{trade_days[1]} for a profit of #{profit}\"\nend"
] | [
"0.81271076",
"0.795692",
"0.7864436",
"0.7828624",
"0.7785256",
"0.77725315",
"0.77601504",
"0.77523786",
"0.7751751",
"0.77350444",
"0.77242064",
"0.77165604",
"0.77150345",
"0.77058905",
"0.7683098",
"0.7680521",
"0.766874",
"0.7650591",
"0.76504564",
"0.7630014",
"0.7628029",
"0.761773",
"0.7614379",
"0.7608056",
"0.7605171",
"0.7604565",
"0.76044047",
"0.76031417",
"0.7595533",
"0.7582932",
"0.7577912",
"0.7567869",
"0.75550395",
"0.75547975",
"0.7549144",
"0.75473374",
"0.7543332",
"0.74579674",
"0.7443515",
"0.7443344",
"0.74414194",
"0.74361783",
"0.7430495",
"0.74304765",
"0.74248534",
"0.74241173",
"0.7410781",
"0.74070936",
"0.7406346",
"0.7398355",
"0.73680127",
"0.73413336",
"0.73406273",
"0.733386",
"0.7331683",
"0.7331498",
"0.7330439",
"0.7330245",
"0.7294305",
"0.7293835",
"0.72906923",
"0.7286089",
"0.7282826",
"0.725532",
"0.7255191",
"0.72453845",
"0.7239831",
"0.7238649",
"0.7229199",
"0.72238684",
"0.7210743",
"0.72062135",
"0.72033507",
"0.7201054",
"0.71615726",
"0.7159482",
"0.7159086",
"0.7144966",
"0.7144055",
"0.71405816",
"0.71366656",
"0.7134734",
"0.71301097",
"0.7124156",
"0.7104866",
"0.709269",
"0.708321",
"0.7081641",
"0.70807785",
"0.70793134",
"0.707237",
"0.70662487",
"0.70657754",
"0.7064471",
"0.7027592",
"0.7021517",
"0.7020671",
"0.7020418",
"0.70005566",
"0.6999617"
] | 0.7285116 | 62 |
Pass by reference vs value 8 January 2014 sort array, immutable way | def foo arr
arr.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def using_sort(array)\narray.sort\nend",
"def using_sort(array)\narray.sort\nend",
"def my_array_sorting_method(array)\n\t@array=array\n\[email protected]\n\treturn @array\nend",
"def using_sort(array)\n sorted_array=array.sort\nend",
"def bar arr\n arr.sort!\nend",
"def sort arr\r\n\trec_sort arr, []\r\nend",
"def using_sort(array)\n array.sort\nend",
"def using_sort(array)\n array.sort\nend",
"def using_sort(array)\n array.sort\nend",
"def sort1(array)\n\nend",
"def sort(arr)\n\tnew_arr = arr.sort\n\tp new_arr\nend",
"def sort arr \n\trec_sort arr, []\nend",
"def dub_sort(arr)\nend",
"def sort arr\n rec_sort arr, []\nend",
"def mothrah_sort (an_array)\n\tdef move_to_end (value, array)\n\t\tarray.delete(value)\n\t\tarray.push(value)\n\tend\n\tpos = 0\n\twhile pos < an_array.length \n\t\tif an_array[pos] > an_array[pos + 1]\n\t\t\tmove_to_end(an_array[pos], an_array)\n\t\telse\n\t\t\tpos += 1\n\t\tend\n\tend\n\tan_array\nend",
"def array_2(array2)\n array2.sort!\n return array2\nend",
"def sort_rever(array)\n p array.sort.reverse\nend",
"def sort some_array # This \"wraps\" rec_sort so you don't have to pass rec_sort an empty array each iteration \n rec_sort some_array, []\nend",
"def sort(array)\n for index in (1...array.size)\n stored = array[index]\n position = index\n while position > 0 && array[position - 1] > stored\n array[position] = array[position - 1]\n position -= 1\n end\n array[position] = stored\n end\n array\nend",
"def insertion_sort(arr)\n<<<<<<< HEAD\n\tarr.each_with_index do |num, i|\n if i > 0\n while arr[i] < arr[i-1] && i > 0\n arr[i], arr[i-1] = arr[i-1], arr[i]\n i -= 1\n end\n \tend\n end\n=======\n>>>>>>> upstream/master\n return arr\nend",
"def sort some_array\n\tsorted_array = []\n\trecursive_sort some_array, sorted_array\nend",
"def my_array_sorting_method(source) \n # sorted = source.dup\n sorted_array = source.sort {|a, b| a.to_s <=> b.to_s}\nend",
"def take_array(array)\r\n array.sort\r\nend",
"def sorting(arr)\n#display orig array\n p arr \n p \"**************************************************\"\n # do something to the array\n # compare each value of an array to the value on its left\n # if the value is less than the value on its left, switch places\n # do this by placing the lesser value in a holder and then moving the greater\n # value to the lesser value's former position in the array, then rewrite the\n # greater value's former position, with the holder value.\n # do this until the value is greater than the value on its left for \n # the entire array \n#Here is our brute force attempt at making our own .sort! method\n#we used the .sort! method from the Array class.\narr.length.times do\n |x|\n holder = \"\"\n if arr[x] > arr[x-1]\n holder = arr[x-1]\n arr[x-1] = arr[x]\n arr[x] = holder\n end \n end\nputs \"this is the one we made #{arr} \"\n # if arr[1] > arr[0]\n p arr.sort!\n p \"above is the sorting method\"\n#rerturn the changed array\nend",
"def bigSorting(unsorted)\n\nend",
"def sort some_array \n\tsortingRec some_array, []\nend",
"def qsort(arr)\nend",
"def orderly(array)\n p array.sort\nend",
"def sort a\r\n sort_rec a, []\r\nend",
"def sort a\r\n sort_rec a, []\r\nend",
"def del_sort(array)\n end",
"def get_sorted_array\n @ary.sort\n end",
"def selection_sort(arr)\n<<<<<<< HEAD\n\tto_sort = arr.dup\n\tsorted = []\n\tuntil sorted.length == arr.length\n\t\tmin = to_sort[0]\n\t\tto_sort.length.times do |i|\n\t\t\tmin = to_sort[i] if to_sort[i] < min\n\t\tend\n\t\tsorted.push(min)\n\t\tto_sort.delete_at(to_sort.index(min))\n\tend\n\tarr = sorted\n\treturn arr\n=======\n return arr\n>>>>>>> upstream/master\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def bubble_sort(&prc)\n self.dup.bubble_sort!(&prc)\n end",
"def sortarray (sort_me)\n counter = sort_me.length\n a = 0\n b = 1\n while a < (counter-1)\n b = a+1\n while b < (counter)\n if sort_me[a] > sort_me[b]\n temp = sort_me[a]\n sort_me[a] = sort_me[b]\n sort_me[b] = temp\n end\n b += 1\n end\n a += 1\n end\n return sort_me\nend",
"def selection_sort(arr)\n return arr\nend",
"def two(array)\n array.sort\nend",
"def sort_array_plus_one(a)\n # Q2 CODE HERE\n a.sort.map {|elem| elem + 1}\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n\tarray.sort\nend",
"def rec_sort unsorted, sorted \n\tif unsorted.length <= 0\n\n# sorted is an array\n\treturn sorted \n\tend\n\n# So if we got here, then it means we still have work to do.\n# take last one out of unsorted, call it smallest\nsmallest = unsorted.pop\n#create en empty 'still unsorted' array \nstill_unsorted = []\n\n#testing if each object in unsorted is smaller than 'smallest' \n\tunsorted.each do |tested_object| \n\t#if tested object is smaller than smallest then push them in still unsorted\n\t\tif tested_object.downcase < smallest.downcase\n\t\t\tstill_unsorted.push smallest\n\t\t\tsmallest = tested_object\n\t\telse\n\t\t\tstill_unsorted.push tested_object\n\t\tend \n\tend\n# Now \"smallest\" really does point to the\n# smallest element that \"unsorted\" contained,\n# and all the rest of it is in \"still_unsorted\". \nsorted.push smallest\n\nrec_sort still_unsorted, sorted\nend",
"def sort array\n\t\tarray = array.clone\n\t\tfinished = false\n\t\t##\n\t\t# Ok, should be an easy one. Compare the current and next value\n\t\t##\n\t\twhile !finished\n\t\t\t#Flag to track whether an iteration edited the array\n\t\t\twasSorted\t= false\n\t\t\t# Compare value pairs from input array\n\t\t\t(1...array.length).each{|idx|\n\t\t\t\t# Get the target values\n\t\t\t\tcurrentValue\t\t= array[idx]\n\t\t\t\tpreviousValue\t\t= array[idx - 1]\n\t\t\t\t# Figure out if the previous and current value arein the correct order\n\t\t\t\tcurrentVsPrevious\t= @sorter.predict([previousValue, currentValue]).first.round\n\t\t\t\t# If they aren't (as best we know at least), swap the two values\n\t\t\t\tif currentVsPrevious == 0\n\t\t\t\t\tarray[idx]\t\t= previousValue\n\t\t\t\t\tarray[idx - 1]\t= currentValue\n\t\t\t\t\twasSorted\t\t= true\n\t\t\t\tend\n\t\t\t}\n\t\t\t# If no sort action was taken, the array must be sorted.\n\t\t\tfinished = !wasSorted\n\t\tend\n\t\t# Return to caller\n\t\tarray\n\tend",
"def sort_array_asc(array)\n asc_array = array.sort\n asc_array\nend",
"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 bubble_sort(array)\n clone = array.clone\n clone.length.times do |i|\n (clone.length - 1).times do |j|\n if clone[j] > clone[j+1]\n clone[j], clone[j+1] = clone[j+1], clone[j]\n end\n end\n end\n clone\nend",
"def sort_array_desc(array)\n new = array.sort\n new.reverse\nend",
"def manipulating_arrays(array)\n puts array.reverse\n puts array.sort\n return array.sort.reverse\nend",
"def insertion_sort(arr)\n return arr\nend",
"def bubble_sort(arr)\n\tbubble_sort_by(arr) { |a,b| b-a }\nend",
"def bubblesort\n arr = self.dup\n arr.bubblesort!\n end",
"def sort some_array\n\trecursive_sort some_array, []\nend",
"def sort some_array\n\trecursive_sort some_array, []\nend",
"def bubble_sort!(&prc)\n \n end",
"def sort_array_plus_one(a)\n # Q2 CODE HERE\n return a.each_index { |i| a[i] += 1}.sort\nend",
"def quick_sort(array)\nend",
"def sort(unsorted_array)\n @sorted_array << unsorted_array.delete_at(unsorted_array.min)\n sort(unsorted_array) until unsorted_array.length == 0\n# This is the RECURSION - latest value of unsorted_array after each iteration\n# is then re-run through the sort method until everything is sorted.\n @sorted_array\nend",
"def array_sort(arr)\nx = arr.length\nif x == 1\nelsif x == 2\n if arr[0] > arr[1]\n arr[0], arr[1] = arr[1], arr[0]\n end\nelse\n loop do\n modified = FALSE\n (x-2).times do |x|\n if (arr[x] < arr[x + 1]) && (arr[x] < arr[x + 2])\n if arr[x + 2] < arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x], arr [x + 2], arr[x + 1]\n modified = TRUE\n end\n elsif (arr[x + 1] < arr[x]) && (arr[x + 1] < arr[x + 2])\n if arr[x] < arr[x + 2]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr[x], arr[x + 2]\n modified = TRUE\n elsif arr[x + 2] < arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr [x + 2], arr[x]\n modified = TRUE\n elsif arr[x + 2] == arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 1], arr[x], arr[x + 2]\n modified = TRUE\n end\n elsif (arr[x + 2] < arr[x]) && (arr[x + 2] < arr[x + 1])\n if arr[x] < arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x], arr[x + 1]\n modified = TRUE\n elsif arr[x + 1] < arr[x]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x + 1], arr[x]\n modified = TRUE\n elsif arr[x] == arr[x + 1]\n arr[x], arr[x + 1], arr[x + 2] = arr[x + 2], arr[x], arr[x + 1]\n modified = TRUE\n end\n end\n end\n break if modified == FALSE\n end\nend\n arr\nend",
"def bubble_sort!(&prc)\n end",
"def bubble_sort!(&prc)\n end",
"def bubble_sort!(&prc)\n\n end",
"def bubble_sort(a)\n array = a.clone\n \n final = false\n while !final\n final = true\n 1.upto(array.length-1) do |index|\n if array[index] < array[index-1]\n array[index], array[index-1] = array[index-1], array[index]\n final = false\n end\n end\n end\n \n array\nend",
"def sort_nums_ascending(arr)\n return arr.sort\nend",
"def sort3(num_array)\n for i in 0..num_array.length - 1\n key = num_array[i]\n j = i - 1\n\n # move elements of num_array[0..i-1] that are greater than key,\n # to one position ahead of their current position\n while j >= 0 && num_array[j] > key\n num_array[j + 1] = num_array[j]\n j -= 1\n end\n num_array[j + 1] = key\n end\n return num_array\nend",
"def rearrange(array, less, array_length, highest_value)\n sorted = []\n for i in (0..(array_length - 1))\n key = array[i]\n index = less[key]\n sorted[index] = array[i]\n less[key] += 1\n end\n return sorted\nend",
"def grand_sorting_machine(array)\n\n\n\nend",
"def quick_sort(arr)\n return arr if arr.length <= 1\n\n ref = arr.shift\n left = quick_sort(arr.select{|x| x.length <= ref.length})\n right = quick_sort(arr.select{|x| x.length > ref.length})\n\n left + [ref] + right\nend",
"def sorter(arr)\n\nreturn arr if arr.length <= 1\n\nnot_sorted = true\n\n while not_sorted\n not_sorted = false\n (arr.length-1).times do |i|\n if arr[i] > arr[i+1]\n arr[i], arr[i+1] = arr[i+1], arr[i]\n not_sorted = true\n p arr\n p \"swap occurred\"\n end\n end\n end\n arr\nend",
"def sorter(arr)\n\nreturn arr if arr.length <= 1\n\nnot_sorted = true\n\n while not_sorted\n not_sorted = false\n (arr.length-1).times do |i|\n if arr[i] > arr[i+1]\n arr[i], arr[i+1] = arr[i+1], arr[i]\n not_sorted = true\n p arr\n p \"swap occurred\"\n end\n end\n end\n arr\nend",
"def bubble_sort(&prc)\n arr = self.dup\n sorted = false\n\n while !sorted\n sorted = true\n\n (0...self.length - 1).each do |idx1|\n num1, num2 = arr[idx1], arr[idx1 + 1]\n\n if prc.call(num1, num2) == 1\n arr[idx1], arr[idx1 + 1] = num2, num1\n sorted = false\n end\n end\n end\n \n arr\n end",
"def sort2(array, max_value)\n\nend",
"def swap_elements(array)\n array.sort do |a,b|\n a[1] <=> b[2]\n end \nend",
"def bubble_sort_by_concept_one(array)\n n = array.length\n\n while n.positive?\n\n j = 0\n\n (1..n - 1).each do |k|\n compare_result = yield array[j], array[k]\n\n # if array[j] > array[k], swap these two values\n if compare_result.positive?\n store = array[j]\n array[j] = array[k]\n array[k] = store\n end\n j += 1\n end\n n -= 1; # last element is now sorted\n end\n\n array\nend",
"def sort_and_fill\n \treturn @array if array_is_too_small\n\n diffs = differences_between_elements\n return @array if differences_are_same diffs\n\n insert_new_elements(diffs)\n @array\n end",
"def bubble_sort(&prc)\n prc = prc || Proc.new{|a,b| a <=> b}\n sorted = false\n\n until sorted\n sorted = true\n (0...self.length-1).each do |idx|\n if prc.call(self[idx], self[idx + 1]) > 0\n self[idx], self[idx + 1] = self[idx + 1], self[idx]\n sorted = false\n end\n end\n end\n self # return the sorted array\n end",
"def sort!( & block )\n \n block ||= @sort_order_reversed ? ::Array::ReverseSortBlock\n : ::Array::SortBlock\n \n new_local_sort_order = [ ]\n @internal_array.size.times { |this_time| new_local_sort_order.push( this_time ) }\n new_local_sort_order.sort! do |index_one, index_two| \n block.call( @internal_array[ index_one ], @internal_array[ index_two ] )\n end\n\n reorder_from_sort( new_local_sort_order )\n \n return self\n\n end",
"def insertionsort! arr\n (1..arr.size - 1).each do |i|\n j = i\n while j > 0 && arr[j] < arr[j - 1] do\n arr[j], arr[j - 1] = arr[j - 1], arr[j]\n j -= 1\n end\n end\n arr\nend",
"def bubble_sort_rec(&prc)\n end",
"def bubble_sort arr\n result = arr.clone\n unsorted = true\n while unsorted\n unsorted = false\n (0...result.length - 1).each do |i| \n if result[i] > result[i + 1]\n unsorted = true\n result[i] , result[i+1] = result[i+1], result[i]\n end\n end\n end\n result\nend",
"def sort_problem (arr1, arr2)\n\n i1 = arr1.length - 1\n i2 = arr2.length - 1\n i2_non0 = arr1.length - 1\n\n while i1 >= 0 && i2 >= 0 do \n if arr1[i1] > arr2[i2_non0]\n arr2[i2] = arr1[i1]\n i2 -=1\n i1 -= 1\n else \n arr2[i2] = arr2[i2_non0]\n i2_non0 -= 1\n i2 -= 1\n end\n end\n\n return arr2\n \nend",
"def sort array # This \"wraps\" recursive_sort.\n recursive_sort array, []\nend",
"def quick_sort(&prc)\n end",
"def my_sort(arr)\n\n i = 0\n while i < arr.length\n j = i + 1\n while j < arr.length\n if arr[i] > arr[j]\n arr[i], arr[j] = arr[j], arr[i] # HERE!!!!\n end\n\n j += 1\n end\n\n i += 1\n end\n\n return arr\nend",
"def bubble_sort(unsorted_array)\n\t# Copy the array (arrays are mutable)\n\tsorted_array = Array.new(unsorted_array)\n\t\n\tarray_length = unsorted_array.length\n\t(array_length - 1).times do |num_sorted|\n\t\t(array_length - num_sorted - 1).times do |idx|\n\t\t\tif sorted_array[idx] > sorted_array[idx + 1]\n\t\t\t\tswap(sorted_array, idx, idx + 1)\n\t\t\tend\n\t\tend\n\tend\n\n\tsorted_array\nend",
"def insert(x,a)\r\n c = a.dup\r\n c.push(x)\r\n c = c.sort\r\nend",
"def dictionary_sort arr ## this is a wrapper method ..\r\n\trec_dict_sort arr, [] ## when trying to sort an array,\r\nend",
"def sort_array_asc int_arr\n new_arr = []\n int_arr.each {|integer| new_arr.unshift(integer)}\n new_arr\nend",
"def recursive_sort_wrap some_array\n recursive_sort some_array, []\nend",
"def sort(num_array)\r\n new_num_arr = num_array.each_with_object([]) { |num, arr|\r\n [*arr].each_with_index do |new_arr_num, index|\r\n if arr[0] > num\r\n arr.prepend(num)\r\n elsif arr[index + 1].nil?\r\n arr.push(num)\r\n elsif num >= new_arr_num && num < arr[index + 1]\r\n arr.insert(index + 1, num)\r\n break\r\n end\r\n end\r\n if arr.empty?\r\n arr.push(num)\r\n end\r\n }\r\n return new_num_arr\r\nend",
"def sort_array_asc(integers)\n integers.sort\nend",
"def my_array_sorting_method(array, number)\n\nend",
"def sort_array_desc (integers)\n integers.sort.reverse\nend",
"def insertion_sort(arr)\n\t# step 1 - set variables. Placeholder_index starts at index 1 rather than index 0 because you\n\t# are always comparing the placeholder to what is to the left of the placeholder\n\tplaceholder_index = 1\n\t# until the placeholder_index is at the index value as the length of the array...\n\t\tuntil placeholder_index > (arr.length - 1)\n\t\t\tcurrent_index = placeholder_index\n\t\t\t# the compare_index is the value to the right of the placeholder/compare_index\n\t\t\tcompare_index = current_index - 1\n\t\t\t# until the current_index is greater than or equal to the compare_index\n\t\t\tuntil arr[current_index] >= arr[compare_index]\n\t\t\t\t# swap the two numbers\n\t\t\t\tarr[current_index], arr[compare_index] = arr[compare_index], arr[current_index]\n\t\t\t\t# compare left number and right\n\t\t\t\tcurrent_index -= 1\n\t\t\t\tcompare_index -= 1 unless compare_index == 0\n\t\t\tend\n\t\t\tplaceholder_index += 1\n\t\tend\nreturn arr\nend",
"def bozosort!(arr)\n while not arr.sort == arr\n a, b = rand(arr.length), rand(arr.length)\n arr[a], arr[b] = arr[b], arr[a]\n end\n return arr\nend",
"def sorting(teamsarrayswins)\n rec_sorting(teamsarrayswins, [])\nend"
] | [
"0.7191132",
"0.7191132",
"0.71701574",
"0.7117478",
"0.71114975",
"0.71004623",
"0.7098862",
"0.7098862",
"0.7098862",
"0.70960903",
"0.70762867",
"0.7046668",
"0.70443517",
"0.70016634",
"0.69939274",
"0.69921017",
"0.6954474",
"0.69530416",
"0.68441963",
"0.6828034",
"0.68253136",
"0.6824254",
"0.6812645",
"0.68079",
"0.6806663",
"0.67974186",
"0.67924434",
"0.6789437",
"0.6787171",
"0.6787171",
"0.67742336",
"0.67426383",
"0.67406523",
"0.6726403",
"0.67240596",
"0.6719777",
"0.6697309",
"0.66923225",
"0.66894525",
"0.6684763",
"0.6684763",
"0.6684763",
"0.6684763",
"0.6684763",
"0.6684763",
"0.6675164",
"0.6669462",
"0.6664596",
"0.66567856",
"0.6654501",
"0.66516614",
"0.66470647",
"0.6638295",
"0.66305256",
"0.6616556",
"0.6614243",
"0.6613688",
"0.6613688",
"0.66088724",
"0.6604832",
"0.66036284",
"0.65959144",
"0.65855706",
"0.65813166",
"0.65813166",
"0.65793025",
"0.6571429",
"0.6568672",
"0.6566694",
"0.65666157",
"0.6564807",
"0.6560007",
"0.6552545",
"0.6552545",
"0.65441865",
"0.6542154",
"0.65327376",
"0.65197355",
"0.6497419",
"0.6479328",
"0.64510745",
"0.6435588",
"0.6431659",
"0.64275634",
"0.6425687",
"0.6418284",
"0.6416905",
"0.6412005",
"0.64037824",
"0.6400761",
"0.6399995",
"0.63937426",
"0.6387467",
"0.63830745",
"0.638197",
"0.63794565",
"0.6378607",
"0.6378543",
"0.6375142",
"0.637433"
] | 0.70188576 | 13 |
sort array, non immutable way | def bar arr
arr.sort!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort arr \n\trec_sort arr, []\nend",
"def sort arr\r\n\trec_sort arr, []\r\nend",
"def using_sort(array)\narray.sort\nend",
"def using_sort(array)\narray.sort\nend",
"def sort1(array)\n\nend",
"def sort arr\n rec_sort arr, []\nend",
"def using_sort(array)\n sorted_array=array.sort\nend",
"def my_array_sorting_method(array)\n\t@array=array\n\[email protected]\n\treturn @array\nend",
"def sort(arr)\n\tnew_arr = arr.sort\n\tp new_arr\nend",
"def del_sort(array)\n end",
"def using_sort(array)\n array.sort\nend",
"def using_sort(array)\n array.sort\nend",
"def using_sort(array)\n array.sort\nend",
"def sort_array_asc(array)\n\tarray.sort\nend",
"def mothrah_sort (an_array)\n\tdef move_to_end (value, array)\n\t\tarray.delete(value)\n\t\tarray.push(value)\n\tend\n\tpos = 0\n\twhile pos < an_array.length \n\t\tif an_array[pos] > an_array[pos + 1]\n\t\t\tmove_to_end(an_array[pos], an_array)\n\t\telse\n\t\t\tpos += 1\n\t\tend\n\tend\n\tan_array\nend",
"def array_2(array2)\n array2.sort!\n return array2\nend",
"def orderly(array)\n p array.sort\nend",
"def take_array(array)\r\n array.sort\r\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def qsort(arr)\nend",
"def my_array_sorting_method(source) \n # sorted = source.dup\n sorted_array = source.sort {|a, b| a.to_s <=> b.to_s}\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def sort_array_asc(array)\n array.sort\nend",
"def foo arr\n arr.sort\nend",
"def sort_array_asc(array)\n asc_array = array.sort\n asc_array\nend",
"def sort arr\r\n\treturn arr if arr.length <= 1\r\n\r\n\tmiddle = arr.pop\r\n\tless = arr.select{|x| x < middle}\r\n\tmore = arr.select{|x| x >= middle}\r\n\r\n\tsort(less) + [middle] + sort(more)\r\nend",
"def sort(arr)\n\tarr.reduce([]) do |sorted, element|\n\t\tindex = sorted.find_index do |item|\n\t\t\telement< item\n\t\tend\n\t\tindex ||= sorted.length\n\t\tsorted.insert(index, element) \n\tend\nend",
"def two(array)\n array.sort\nend",
"def get_sorted_array\n @ary.sort\n end",
"def sort some_array\n\tsorted_array = []\n\trecursive_sort some_array, sorted_array\nend",
"def sort\n limit = array.size - 1\n (0..limit).each do |index|\n min = index\n (index..limit).each do |target|\n min = target if array[min] > array[target]\n end\n array[index], array[min] = array[min], array[index]\n end\n array\n end",
"def sort some_array\n\trecursive_sort some_array, []\nend",
"def sort some_array\n\trecursive_sort some_array, []\nend",
"def sort(arr)\n return arr if arr.length < 1\n\n pivot = arr.pop\n less = arr.select { |item| item < pivot}\n more = arr.select { |item| item >= pivot}\n\n sort(less) + [pivot] + sort(more)\nend",
"def sort a\r\n sort_rec a, []\r\nend",
"def sort a\r\n sort_rec a, []\r\nend",
"def dub_sort(arr)\nend",
"def sort(array)\n for index in (1...array.size)\n stored = array[index]\n position = index\n while position > 0 && array[position - 1] > stored\n array[position] = array[position - 1]\n position -= 1\n end\n array[position] = stored\n end\n array\nend",
"def swap_elements(array)\n array.sort do |a,b|\n a[1] <=> b[2]\n end \nend",
"def sort_rever(array)\n p array.sort.reverse\nend",
"def sort(array)\n return array if array.length <= 1\n less, more = [], []\n # first element as pivot value\n pivot = array.delete_at(0)\n\n array.each { |el| el < pivot ? less << el : more << el}\n\n sort(less) + [pivot] + sort(more)\n end",
"def sort_array array\n sorted=[]\n a=0\n b=0\n until a==(array.length-1)||b==(array.length)\n if array[a] <= array[b]\n b+=1\n else\n a+=1\n b=0\n end\n end\n sorted.push array[a]\n array.delete(array[a])\n \n while true\n if array.length==1\n sorted.push array[0]\n break\n else\n a=0\n b=0\n until a==(array.length-1)||b==(array.length)\n if array[a]<=array[b]\n b+=1\n else\n a+=1\n b=0\n end\n end\n sorted.push array[a]\n array.delete_at(a)\n end\n end\n sorted\nend",
"def sortarray (sort_me)\n counter = sort_me.length\n a = 0\n b = 1\n while a < (counter-1)\n b = a+1\n while b < (counter)\n if sort_me[a] > sort_me[b]\n temp = sort_me[a]\n sort_me[a] = sort_me[b]\n sort_me[b] = temp\n end\n b += 1\n end\n a += 1\n end\n return sort_me\nend",
"def selection_sort(arr)\n<<<<<<< HEAD\n\tto_sort = arr.dup\n\tsorted = []\n\tuntil sorted.length == arr.length\n\t\tmin = to_sort[0]\n\t\tto_sort.length.times do |i|\n\t\t\tmin = to_sort[i] if to_sort[i] < min\n\t\tend\n\t\tsorted.push(min)\n\t\tto_sort.delete_at(to_sort.index(min))\n\tend\n\tarr = sorted\n\treturn arr\n=======\n return arr\n>>>>>>> upstream/master\nend",
"def sort_array_desc(a)\n a.sort {|b, c|c<=>b}\nend",
"def sort_array\n @data.sorted_by.inject([]) do |memo, (key, value)|\n memo << [@data.columns.index(key), value == 'descending' ? 0 : 1]\n end\n end",
"def sort_array_desc(array)\n array.sort do |a,b|\n b <=> a\n end\nend",
"def sort_array_desc(array)\n array.sort do |a,b|\n b <=> a\n end\nend",
"def unique_sort(arr)\n\tp arr.uniq.sort\nend",
"def sort_array_desc(array)\n\tarray.sort do |a, b|\n\t\tb <=> a\n\tend\nend",
"def my_array_sorting_method(source)\n source.map {|array_Element| array_Element.to_s}.sort.uniq\n end",
"def sort some_array \n\tsortingRec some_array, []\nend",
"def sort_array_desc(arry)\n arry.sort do |num1, num2|\n num2 <=> num1\n end\nend",
"def quick_sort(array)\nend",
"def sort_array_desc(array)\n new = array.sort\n new.reverse\nend",
"def sort_array_desc(array)\n array.sort do | left, right|\n right <=> left\n end\nend",
"def sort_array_desc(array)\n array.sort do |a, b|\n b<=>a\n end\nend",
"def bubble_sort(arr)\n\tbubble_sort_by(arr) { |a,b| b-a }\nend",
"def sort_array_desc(array)\n array.sort {|x,y| y <=>x }\nend",
"def sort_array_asc(integers)\n integers.sort\nend",
"def sort(array_of_nodes, order); end",
"def sort_array_desc(array)\n array.sort {|a,b| b <=> a}\nend",
"def sort_array_desc(arr)\n arr.sort{|a,b| b<=>a}\nend",
"def array_sort_city(array)\n array.sort do |a, b|\n a.city <=> b.city\n end\nend",
"def sort_array_desc(array)\n return array.sort{ |a, b| b <=> a }\nend",
"def my_array_sorting_method(source)\n # sort by converting the integers, if there are, into strings for the purpose of sorting only\n return source.sort {|a,b| a.to_s <=> b.to_s }\nend",
"def sort arr\n return arr if arr.length <= 1\n \n middle = arr.pop\n less = arr.select{|x| x < middle}\n more = arr.select{|x| x >= middle}\n\n sort(less) + [middle] + sort(more)\nend",
"def sort arr\n return arr if arr.length <= 1\n \n middle = arr.pop\n less = arr.select{|x| x < middle}\n more = arr.select{|x| x >= middle}\n\n sort(less) + [middle] + sort(more)\nend",
"def sort_array_desc(array)\n array.sort {|x,y| y <=> x}\nend",
"def sort some_array # This \"wraps\" rec_sort so you don't have to pass rec_sort an empty array each iteration \n rec_sort some_array, []\nend",
"def my_array_sorting_method(source)\n\treturn source.uniq.map{|element| element.to_s}.sort\nend",
"def my_array_sorting_method(source)\n source.map {|i| i.to_s}.sort.uniq\nend",
"def sort_array_desc(array)\n array.sort do |a, b|\n if a == b\n 0\n elsif a > b\n -1\n elsif a < b\n 1\n end\n end\nend",
"def sort arr\n return arr if arr.length <= 1\n middle = arr.pop\n less = arr.select{|x| x < middle}\n more = arr.select{|x| x >= middle}\n sort(less) + [middle] + sort(more)\nend",
"def improved_poorly_written_ruby(*arrays)\n sorted = []\n arrays.flatten.each do |v|\n size = sorted.size\n if sorted.empty?\n sorted.push(v)\n else\n i = 0\n while i < size\n item = sorted[i]\n if item > v\n sorted.insert(i, v)\n break\n elsif i == size - 1\n sorted.push(v)\n break\n end\n i += 1\n end\n end\n end\n sorted\nend",
"def sort_array_desc (array)\n array.sort_by do |sort|\n -sort\n end\nend",
"def sort(unsorted_array)\n @sorted_array << unsorted_array.delete_at(unsorted_array.min)\n sort(unsorted_array) until unsorted_array.length == 0\n# This is the RECURSION - latest value of unsorted_array after each iteration\n# is then re-run through the sort method until everything is sorted.\n @sorted_array\nend",
"def my_array_sorting_method(source)\n p source.sort {|x,y| x.to_s <=> y.to_s}\nend",
"def sort_array_desc(array)\n desc_array = array.sort {|a, b| b <=> a}\n desc_array\nend",
"def sort_array_asc int_arr\n new_arr = []\n int_arr.each {|integer| new_arr.unshift(integer)}\n new_arr\nend",
"def merge_sort (array, &prc)\n return array if array.length <= 1\n\n mid_idx = array.length / 2\n merge(\n merge_sort(array.take(mid_idx), &prc),\n merge_sort(array.drop(mid_idx), &prc),\n &prc\n )\nend",
"def sort array\n\t\tarray = array.clone\n\t\tfinished = false\n\t\t##\n\t\t# Ok, should be an easy one. Compare the current and next value\n\t\t##\n\t\twhile !finished\n\t\t\t#Flag to track whether an iteration edited the array\n\t\t\twasSorted\t= false\n\t\t\t# Compare value pairs from input array\n\t\t\t(1...array.length).each{|idx|\n\t\t\t\t# Get the target values\n\t\t\t\tcurrentValue\t\t= array[idx]\n\t\t\t\tpreviousValue\t\t= array[idx - 1]\n\t\t\t\t# Figure out if the previous and current value arein the correct order\n\t\t\t\tcurrentVsPrevious\t= @sorter.predict([previousValue, currentValue]).first.round\n\t\t\t\t# If they aren't (as best we know at least), swap the two values\n\t\t\t\tif currentVsPrevious == 0\n\t\t\t\t\tarray[idx]\t\t= previousValue\n\t\t\t\t\tarray[idx - 1]\t= currentValue\n\t\t\t\t\twasSorted\t\t= true\n\t\t\t\tend\n\t\t\t}\n\t\t\t# If no sort action was taken, the array must be sorted.\n\t\t\tfinished = !wasSorted\n\t\tend\n\t\t# Return to caller\n\t\tarray\n\tend",
"def sort arr\n return arr if arr.length <= 1\n middle = arr.pop\n lesss = arr.select{|x| x < middle}\n more = arr.select{|x| x>= middle}\n\n sort(less) + [middle] + sort(more)\nend",
"def bozosort!(arr)\n while not arr.sort == arr\n a, b = rand(arr.length), rand(arr.length)\n arr[a], arr[b] = arr[b], arr[a]\n end\n return arr\nend",
"def insertion_sort(arr)\n<<<<<<< HEAD\n\tarr.each_with_index do |num, i|\n if i > 0\n while arr[i] < arr[i-1] && i > 0\n arr[i], arr[i-1] = arr[i-1], arr[i]\n i -= 1\n end\n \tend\n end\n=======\n>>>>>>> upstream/master\n return arr\nend",
"def bubble_sort ary\n bubble_sort_by(ary) {|l,r| l <=> r}\nend",
"def my_array_sorting_method(source)\n source.sort { |a, b| a.to_s <=> b.to_s } \nend",
"def poorly_written_sort(*arrays)\n combined_array = []\n arrays.each do |array|\n array.each do |value|\n combined_array << value\n end\n end\n\n sorted_array = [combined_array.delete_at(combined_array.length-1)]\n\n for val in combined_array\n i = 0\n while i < sorted_array.length\n if val <= sorted_array[i]\n sorted_array.insert(i, val)\n break\n elsif i == sorted_array.length - 1\n sorted_array.insert(i, val)\n break\n end\n i+=1\n end\n end\n\n # Return the sorted array\n sorted_array\nend",
"def sort_array_desc(array)\n array.sort do |a,b|\n if a == b\n 0\n elsif a > b\n -1\n elsif a < b\n 1\n end\n end\nend",
"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 my_array_sorting_method(source)\n result = source.sort { |a, b| a.to_s <=> b.to_s }\nend",
"def sort3(num_array)\n for i in 0..num_array.length - 1\n key = num_array[i]\n j = i - 1\n\n # move elements of num_array[0..i-1] that are greater than key,\n # to one position ahead of their current position\n while j >= 0 && num_array[j] > key\n num_array[j + 1] = num_array[j]\n j -= 1\n end\n num_array[j + 1] = key\n end\n return num_array\nend",
"def my_array_sorting_method(source)\n p source.sort_by { |a| a.to_s }\nend",
"def sort_by_luck(arr)\n arr.sort! { |a,b|\n b[0] <=> a[0]\n }\n return arr\nend",
"def my_array_sorting_method(source)\n # Convert each element in the array to a string, for comparison/sorting purposes\n for index in 0...source.length\n source[index] = source[index].to_s\n end\n\n sorted_array = source.sort_by do |element|\n element\n end\n\n return sorted_array\nend",
"def rearrange(array, less, array_length, highest_value)\n sorted = []\n for i in (0..(array_length - 1))\n key = array[i]\n index = less[key]\n sorted[index] = array[i]\n less[key] += 1\n end\n return sorted\nend"
] | [
"0.7905387",
"0.78058445",
"0.7604979",
"0.7604979",
"0.75994635",
"0.7559644",
"0.74847424",
"0.74668956",
"0.7457611",
"0.7444893",
"0.7334978",
"0.7334978",
"0.7334978",
"0.7321632",
"0.73134655",
"0.72790354",
"0.7277577",
"0.7243714",
"0.7241533",
"0.721947",
"0.71927184",
"0.717446",
"0.717446",
"0.717446",
"0.717446",
"0.717446",
"0.717446",
"0.7171288",
"0.71669275",
"0.7142552",
"0.7138054",
"0.7130072",
"0.71128803",
"0.7109628",
"0.70951056",
"0.70697767",
"0.70697767",
"0.7052782",
"0.70386726",
"0.70386726",
"0.7030678",
"0.7014725",
"0.70145816",
"0.70036715",
"0.69956",
"0.6991543",
"0.699023",
"0.6976084",
"0.69713384",
"0.69651955",
"0.696073",
"0.696073",
"0.6954088",
"0.6951134",
"0.69487786",
"0.69356143",
"0.69326067",
"0.6931703",
"0.6927012",
"0.6921763",
"0.69057715",
"0.6903747",
"0.68987703",
"0.6898227",
"0.6892633",
"0.6891974",
"0.6891139",
"0.68900293",
"0.6889507",
"0.68871146",
"0.68827164",
"0.68827164",
"0.687857",
"0.6857974",
"0.6837834",
"0.68281645",
"0.6827883",
"0.6827679",
"0.6823435",
"0.68233156",
"0.68219644",
"0.6818041",
"0.68145186",
"0.68141794",
"0.6814148",
"0.68131113",
"0.6810256",
"0.6806845",
"0.67979103",
"0.67934334",
"0.67846936",
"0.67833334",
"0.6782498",
"0.6780683",
"0.6778136",
"0.6762441",
"0.6762306",
"0.6758706",
"0.6757518",
"0.6748526"
] | 0.7166119 | 29 |
Check if user is authorized by minimum role Using the power value to determine if user has sufficent privileges | def is_authorized(min_role)
@roles = Role.all.group(:name)
authorized = false
if @roles[self[:name]] >= @roles[min_role]
authorized = true
end
return authorized
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin? ; user.instance_of? User and user.role >= 2 ; end",
"def level! min\n level = @connection.users[@msg.nick].level\n\n return true if level >= min\n\n raise 'Insufficient access level.'\n end",
"def admin_authorized?\n\t\tif @user\n\t\t\[email protected] >= ADMIN_USER_LEVEL \n\t\telse\n\t\t\tnil\n\t\tend\n\tend",
"def more_powerful(than, user)\n if than\n return self.role > user.role\n else\n return self.role >= user.role\n end\n end",
"def admin?(user, target_level: 100)\n level = user_powerlevel(user, use_default: false)\n return false unless level\n\n level >= target_level\n end",
"def check_normal_user\n result = current_user.is_normal?\n \n if (!result)\n # If it doesn't meet the minimum privilege level, redirect.\n flash[:error] = t(\"ui.error.forbidden\")\n redirect_to root_path()\n end\n\n return result\n end",
"def auth_as(min = :none)\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n case min\n when :admin\n is_atleast_admin(@current_user)\n when :member\n is_atleast_member(@current_user)\n when :guest\n is_atleast_guest(@current_user)\n else\n is_atleast_member(@current_user)\n end\n end",
"def admin_assistant?\n if self.role and self.role < 3 \n true\n end\n end",
"def menu_accessible?(required_role_rank)\r\n @current_user_rank = Role.find(current_admin_user.role_id).rank\r\n if required_role_rank > @current_user_rank\r\n return false\r\n end\r\n return true\r\n end",
"def user_permission_greater? page, level \n return true if admin\n \n # access for non-members is not permitted\n as_member = Member.first(:conditions => { :user_id => id, :project_id => page.project.id })\n return false if as_member.nil?\n\n # user specific permissions have preference\n #Rails.logger.info \"Accessing user permission for user #{id} / member #{as_member.id} and page #{page.id}\"\n user_permission = WikiPageUserPermission.first(\n :conditions => {\n :wiki_page_id => page.id,\n :member_id => as_member.id\n }\n )\n\n unless user_permission.nil?\n Rails.logger.info \"Level: #{user_permission.level} => #{level}\"\n return user_permission.level >= level\n end\n \n # check whether the user belongs to a role that has permissions set\n role_permissions = WikiPageRolePermission.find(:all, :conditions => {:wiki_page_id => page.id})\n unless role_permissions.nil? or as_member.roles.empty?\n roles_ids = as_member.roles.map { |x| x.id }\n Rails.logger.info \"Accessing role permission\"\n \n role_permissions.each do |role|\n if roles_ids.index(role.role_id)\n Rails.logger.info \"Role.level #{role.level} >= #{level}\"\n return role.level >= level\n end\n end\n end\n\n # check default permission\n Rails.logger.info \"Checking default\"\n (default = page.default_permission) ? default.level >= level : true\n end",
"def allowed?(required_level)\n \t# Required level is level and all levels above (1=low, 4=high)\n \t# level 1: customer\n \t# level 2: user\n \t# level 3: company_admin\n \t# level 4: admin\n case required_level\n \t\twhen 'user'\n\t\t return true if self.role == 'user' || self.role == 'company_admin' || self.role == 'admin'\n \t\twhen 'company_admin'\n\t\t return true if self.role == 'company_admin' || self.role == 'admin'\n \t\twhen 'admin'\n\t\t return true if self.role == 'admin'\n else\n return false\n\t\tend\n end",
"def staff?\n if self.role and self.role < 4 \n true\n end\n end",
"def check_user(current_user, clearance_level)\n if current_user.nil?\n return false\n end\n if clearance_level == \"admin\"\n return current_user.role == \"admin\"\n end\n if clearance_level == \"chair\"\n (current_user.role == \"admin\" || current_user.role == \"chair\")\n end\n end",
"def restriction_level\n return 0 # only user itself is allowed\n end",
"def authorize_admin\n\t\tauthorize( ADMIN_USER_LEVEL ) \n\tend",
"def is_admin?\n level >= USER_LEVELS[\"system_admin\"]\n end",
"def check_administrator_user\n result = current_user.is_administrator?\n\n if (!result)\n # If it doesn't meet the minimum privilege level, redirect.\n flash[:error] = t(\"ui.error.forbidden\")\n redirect_to root_path()\n end\n\n return result\n end",
"def admin?\n role & Role::ADMIN > 0\n end",
"def rights?(level)\n logged_in? and @user.role_id >= level\n end",
"def check_user_role \t \n redirect_to root_path unless current_user.roles.first.name == \"empleado\" or current_user.roles.first.name == \"supervisor\"or current_user.roles.first.name == \"admin\" \n end",
"def authorize?(user)\n user && user.moderator?\n end",
"def check_chair\n if (!current_user.superadmin_role)\n redirect_to root_path, notice: 'You do not have permissions to do that'\n end\n end",
"def check_admin\n\t\tif current_user && current_user.role == 2\n\t\telsif current_user && current_user.role != 2\n\t\t\tredirect_to buildings_url, notice: 'You are not authorized'\n\t\telse\n\t\t\tredirect_to buildings_url, notice: 'You are not logged in'\n\t\tend\n\tend",
"def role_allowed?(required_role)\n if role_hierarchy.find_index(required_role.to_sym)\n role_hierarchy.find_index(role.to_sym) >= role_hierarchy.find_index(required_role.to_sym)\n else\n false\n end\n end",
"def admin?\n role == 1\n end",
"def can?(thing)\n return true if admin?\n # Check if user is granted the function\n return true if granted?(thing)\n # Check if user is denied the function\n return false if denied?(thing)\n # Ignore \"System Admin\" function from CSUM/CSEM users\n return false if thing.include?(\"System Admin\")\n roles.include?(thing)\n end",
"def authorized?(role)\n current_user[:role] >= User.roles[role]\n end",
"def is_admin?(user)\n user.admin > 0\n end",
"def admin_required\n self.current_user != :false && \n self.current_user.is_admin? ? true : access_denied\n end",
"def is_at_least_level?(level)\n return false if !ADMIN_RANKING[level] or !ADMIN_RANKING[self.role]\n return ADMIN_RANKING[self.role] >= ADMIN_RANKING[level]\n end",
"def verify_super_admin\n redirect_to admin_path unless current_user.user_level == \"super_admin_access\"\n\n end",
"def checkrole\n if roles_mask == 4\n 'User'\n elsif roles_mask == 6\n 'Administrator'\n end\n end",
"def user_admin\n user_role.in? [\"Department Admin\",\"College Admin\",\"Tech User\"] if user_role\n end",
"def verify_admin\n redirect_to root_url unless current_user.role_id == 1 || current_user.role_id == 2\n end",
"def admin?\n if current_user.read_attribute(:permiso) != 1\n redirect_to current_user\n end\n end",
"def admin?\n if role == \"admin\"\n return true\n end\nend",
"def has_access?(level)\n if (level || 0) > (current_user.try(:admin_level) || 0) then return false else return true end\n end",
"def check_access_level(role)\n redirect_to root_path unless current_user && current_user.role?(role)\n end",
"def authorize?(user)\n user && user.admin?\n end",
"def admin?\n self.role == 53\n end",
"def is_administrator?(user)\n user.admin == 2\n end",
"def admin_required\n session[:user_id] && (user = User.find(session[:user_id])) && user.is_admin\n end",
"def check_admin_user\n unless current_user && current_user.privilege_admin?\n flash[:danger] = \"You do not have permission to perform this operation\"\n redirect_to root_path\n end\n end",
"def super_admin?\n #logged_in? && current_user.has_role?('super_admin')\n logged_in? && (current_user.roles.map{|role| role.name}).include?('super_admin')\n end",
"def is_user_admin?\n user_active && user_active.permission_level == 2\n end",
"def verify_super_admin\r\n redirect_to admin_path unless current_user.user_level == \"super_admin_access\"\r\n end",
"def is_admin?\n (self.role =~ /admin/) == 0 ? true : false\n end",
"def admin?\n if (User.find session[:user_id]).role == \"Admin\"\n true\n end\n end",
"def moderator?(user, target_level: 50)\n level = user_powerlevel(user, use_default: false)\n return false unless level\n\n level >= target_level\n end",
"def admin_required\n current_user.is_admin? || access_denied\n end",
"def is_admin?\n self.role =~ /patissier/\n end",
"def user_is_admin?\n\tbegin\n\t `gpresult /r /scope user`.split.include? \"Admin\"\n\trescue\n\t false\n\tend\n end",
"def is_superadmin\n user = UserAdmin.find_by_user_id(current_user.id)\n if user and user.level == 3\n return true || false\n end\n end",
"def user_authorized?(user)\n user == current_user || is_admin?\n end",
"def check_privilege(i = 0)\n floor_i = i.floor\n if floor_i == 1\n 'seller'\n elsif floor_i == 2\n 'manager'\n elsif floor_i >= 3\n 'admin'\n else\n 'user'\n end\nend",
"def admin()\n @data[\"access\"][\"user\"][\"roles\"].each do |role|\n if role[\"name\"].eql?(\"admin\")\n return true\n end\n end\n return false\n end",
"def deny_admin_suicide\n raise 'admin suicided' if User.count(&:admin) <= 1\n end",
"def deny_admin_suicide\n raise 'admin suicided' if User.count(&:admin) <= 1\n end",
"def authorize?(user)\n true\n #user.login == \"administrador\"\n end",
"def check_manager_or_admin\n unless current_user && (current_user.privilege_manager? || current_user.privilege_admin?)\n flash[:danger] = \"You do not have permission to perform this operation\"\n redirect_to root_path\n end\n end",
"def admin?\n role == \"admin\"\n end",
"def admin? \n role == 'admin'\n end",
"def admin_required\n current_user.respond_to?('is_admin') && current_user.send('is_admin') || access_denied\n end",
"def check_authorization\n unless @user and @user.role.name == 'admin'\n flash[:notice] = \"Not authorized!\"\n redirect_to root_path\n end\n end",
"def superadmin?\n\t\trole == \"superadmin\"\n\tend",
"def admin?\n user = check_user\n user.role == User.role_types['Admin']\n end",
"def eventunscrape?\n @user.is_admin?\n end",
"def authorization_checking\n authorize!(:authorization_checking,current_user) unless current_user.role?(:livia_admin) || current_user.role?(:lawfirm_admin)\n end",
"def admin?\n role == 'admin'\n end",
"def admin?\n role == 'admin'\n end",
"def admin?\n role?('admin')\n end",
"def authorized?\n authorized = nil\n user && user.role_symbols.each do |role|\n (permissions[role] || {}).each do |act, opt|\n if act == action\n break if (authorized = opt.any? ? eval_expr(opt) : true)\n end\n end\n break if authorized\n end\n authorized\n end",
"def admin?\n (session[:drupal_user_role] && (session[:drupal_user_role].values.include?('administrator') || session[:drupal_user_role].values.include?('staff'))) ? true : false\n end",
"def authenticate_admin_hr_pm\n unless current_user && (get_loging_permission ==1 || get_loging_permission ==2 || get_loging_permission ==3)\n redirect_to sign_in_path\n return \n end\n end",
"def limited_curator?\n %w[superuser curator tenant_curator limited_curator].include?(role)\n end",
"def show\n authorize RoleCutoff\n end",
"def manage_brandreach?\n user.admin? || user.super_admin?\n end",
"def verify_admin\n :authenticate_user!\n have_no_rights('restricted area') unless current_user.isAdmin?\nend",
"def authorized?\n current_user.login == \"Admin\"\n end",
"def line_count_authorized?\n return true if current_user.is_an_admin_or_operator?\n return false\nend",
"def restricted?\n return ( self.user_type == User::USER_TYPE_NORMAL )\n end",
"def has_privilege?(desired_privilege, club)\n raise ArgumentError, \"desired_privilege must not be nil\" if desired_privilege.nil?\n\n privilege_level = 0\n if club.nil?\n privilege_level = max_privilege_level\n else\n privilege_level = privilege_level(club)\n end\n\n (privilege_level >= desired_privilege)\n end",
"def profile_admin?\r\n self.popv_admin? || self.admin? || self.warehouse_admin? || self.requesting_admin?\r\n end",
"def is_normal_user? #Signo de insterrogacion representa q un metodo booleano.\n\t\tself.permission_level >= 1\n\tend",
"def check_authorization\n if current_user && current_user.admin_role.present?\n return true\n end\n render nothing: true, status: :unauthorized\n false\n end",
"def admin?\n isAdmin = false ; \n self.role.each { |r|\n if r.name == 'Administrator'\n isAdmin = true\n end\n \n }\n return isAdmin\n end",
"def verify_super_admin(user)\n if user.role.blank? || user.role.nome != \"SuperAdmin\"\n return true\n end\n\n if current_user.role.nome == \"SuperAdmin\"\n return true\n end\n\n return false\n end",
"def facility_admin\n facility_controller_check\n unless current_user.role == \"site_admin\" || (@facility_role_access.present? && current_user.role == \"facility_admin\")\n flash[:error] = 'You are not authorized. Please request access from your manager'\n redirect_to root_url\n end\n end",
"def admin?\n self.role == 'admin'\n end",
"def admin?\n self.role == 'admin'\n end",
"def admin?\n self.role == 'admin'\n end",
"def admin?\n role.to_s == \"admin\"\n end",
"def authorize_user\n\t if !current_user.admin_user? then\n\t redirect_to '/', notice: 'You have attempted to access a function that is not available for basic users.'\n\t end\n\tend",
"def administration?\n self.privileges == PRIVILEGE_CODES[:administration]\n end",
"def admin?\n role= current_user ? current_user.role : \"\"\n role.upcase.split(\",\").include?(\"A\")\n rescue\n false\n end",
"def profile_authorization\n #if view admins' profile, allow only admin\n return false unless(params[:id])\n user = User.find(params[:id])\n return false unless user\n return admin_authorization if user.admin?\n return true if GraderConfiguration[\"right.user_view_submission\"]\n\n #finally, we allow only admin\n admin_authorization\n end",
"def super_admin?\n self.role.role_name == \"super_admin\"\n end",
"def restrict_user_by_role\n unless current_user.has_role_in_roles_list?(ADMINISTRATION_ROLES)\n flash[:error] = 'You do not have permission to view this page'\n redirect_to root_path\n end\n end",
"def admin?\n self.role == 'Admin'\n end",
"def check_level\n if current_user.role_id == 1 || current_user.role_id == 2\n @the_client_id = params[:client_id]\n the_num = User.where(client_id: @the_client_id).count()\n payment_id = ClientInfo.where(id: @the_client_id).pluck(:payment_type)[0]\n the_set_count = PaymentType.where(id: payment_id).pluck(:users)[0]\n if the_set_count <= the_num\n respond_to do |format|\n format.html { redirect_to client_user_list_path, alert: 'Sorry! Client has exhausted his allowance, he should upgrade his package.' }\n end\n end\n else\n @the_client_id = current_user.client_id\n the_num = User.where(client_id: @the_client_id).count()\n payment_id = ClientInfo.where(id: @the_client_id).pluck(:payment_type)[0]\n the_set_count = PaymentType.where(id: payment_id).pluck(:users)[0]\n if the_set_count <= the_num\n respond_to do |format|\n format.html { redirect_to client_users_path, alert: 'Sorry! You have exhausted your allowance, please upgrade your package.' }\n end\n end\n end\n end"
] | [
"0.6755913",
"0.6736553",
"0.67134863",
"0.6619026",
"0.6614342",
"0.6607437",
"0.65995127",
"0.6598425",
"0.6540702",
"0.6496781",
"0.6478794",
"0.6419712",
"0.6412473",
"0.63778853",
"0.63186556",
"0.63133794",
"0.63118696",
"0.6297386",
"0.6295865",
"0.6261967",
"0.62514377",
"0.6239406",
"0.6238007",
"0.62359697",
"0.62324005",
"0.62251955",
"0.62178993",
"0.6199201",
"0.61987555",
"0.6188725",
"0.618647",
"0.6177982",
"0.6175054",
"0.61506313",
"0.6143507",
"0.6142256",
"0.61270475",
"0.6123288",
"0.6102736",
"0.6101115",
"0.60943353",
"0.6091904",
"0.60861516",
"0.60795903",
"0.6075236",
"0.607511",
"0.607234",
"0.60715026",
"0.6067479",
"0.60668623",
"0.6063431",
"0.6057658",
"0.60547185",
"0.60488147",
"0.6034532",
"0.6032634",
"0.6025019",
"0.6025019",
"0.6024624",
"0.6021084",
"0.6017548",
"0.601662",
"0.60164934",
"0.6012887",
"0.60112435",
"0.6011063",
"0.60106564",
"0.60100317",
"0.60035044",
"0.60035044",
"0.6002646",
"0.59968555",
"0.59963334",
"0.5993607",
"0.59778357",
"0.59708685",
"0.5970731",
"0.5968764",
"0.59642935",
"0.5959354",
"0.59514695",
"0.5950382",
"0.594809",
"0.594658",
"0.5941888",
"0.59406126",
"0.5933473",
"0.59302604",
"0.592524",
"0.592524",
"0.592524",
"0.5921313",
"0.59204626",
"0.5917569",
"0.59128076",
"0.59075165",
"0.59057623",
"0.59036875",
"0.5893946",
"0.5889359"
] | 0.7311992 | 0 |
:tie, :dealer, :player, :dealer_busted, :player_busted | def detect_result(dealer_total, player_total)
# player_total = total(player_cards)
# dealer_total = total(dealer_cards)
if player_total > 21
:player_busted
elsif dealer_total > 21
:dealer_busted
elsif dealer_total < player_total
:player
elsif dealer_total > player_total
:dealer
else
:tie
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def affichage_player\n\n\n end",
"def human_and_human_player(size)\n\t@player1 = \"player\"\n @player2 = \"player\"\nend",
"def detect_result\n case\n when player.busted? then :player_busted\n when dealer.busted? then :dealer_busted\n when player.total > dealer.total then :player_higher\n when dealer.total > player.total then :dealer_higher\n else :tie\n end\n end",
"def witcher; end",
"def player_base\n @wealth = 0\n @fame = 0\n @current_exp = 0\n @exp_needed = 100\n @available_attribute_points = 30\n @total_proficiency_points = 1\n @available_proficiency_points = 1\n end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def players; [@hunter, @prey] end",
"def human_player_and_ai(size)\n\tif first?()\n @player1 = \"player\"\n @player2 = difficulty(size,\"o\")\n else\n @player1 = difficulty(size,\"x\")\n @player2 = \"player\"\n end\nend",
"def deal\n self.player.receive_card hit \n self.dealer.receive_card hit \n self.player.receive_card hit \n self.dealer.receive_card hit \n end",
"def loser\n losing_players\n end",
"def outcome\n if (pl_high? || session[:dealer].bust?) && !session[:player].bust?\n outcome = :player\n elsif session[:player].blackjack? && !session[:dealer].blackjack?\n outcome = :blackjack\n session[:player].qualities << \"lucky\"\n elsif push?\n outcome = :push\n else\n outcome = :dealer\n end\n outcome\n end",
"def two_player_mode\nend",
"def weapon; end",
"def weapon; end",
"def weapon; end",
"def melee_weapon; end",
"def get_tie_confirmation()\n return \"Both players tie with #{@player.get_weapon()}!\"\n end",
"def min_players\n # Implementing classes should override\n 0\n end",
"def setup\n @all_players.each do |player|\n deal(player, 2)\n end\n end",
"def initialize(player)\n @en_passant = false\n super(player)\n end",
"def detect_result(player, dealer)\n if player > WINNING_SCORE\n :player_busted\n elsif dealer > WINNING_SCORE\n :dealer_busted\n elsif dealer < player\n :player\n elsif dealer > player\n :dealer\n else\n :tie\n end\nend",
"def change_player\n\n end",
"def set_player\n\n end",
"def next_player!\n end",
"def one_player_mode\nend",
"def play_sports\n end",
"def switch_players\n \n if @current_asker == @player1\n @current_asker = @player2\n @current_responder = @player1\n else\n @current_asker = @player1\n @current_responder = @player2\n end\n\n end",
"def initialize\n @player1wins = 0\n @player2wins = 0\n @ties = 0\n end",
"def get_players\n\n end",
"def data_battler\n enemy\n end",
"def setup_player\n self.points = 0\n Match.all.each do |m|\n self.bets.build(match: m, result: Match::TIE)\n end\n end",
"def hit_stay\n\[email protected]_key {\n\t\t|player|\n\t\t\tplayer_hit_or_stay(player)\t\t\t\n\t}\n\nend",
"def give_bonus player\n player.add_1_life\n end",
"def switch_player\nif @player == PIECE[:x]\n@player = PIECE[:o]\nelse\n@player = PIECE[:x]\nend\nend",
"def reset_player_weapons()\n set_weapon()\n set_other_weapon()\n end",
"def switch_player\n\t\tputs \"\\n\"\n\t\tif @player == @player1\n\t\t\t@player = @player2\n\t\t\t@other_player = @player1\n\t\telse\n\t\t\t@player = @player1\n\t\t\t@other_player = @player2\n\t\tend\n\t\t\n\t\t#Matt easter egg\n\t\tif @player.name.downcase == 'matt'\n\t\t\tdescriptors = [' the Amazing', ' the Hero', ' the Incroyable', \n\t\t\t\t\t\t ' the Handsome', ' the Clever', ' the Wonderful', ' the Indominable']\n\t\t\[email protected] = @player.name + descriptors.sample\n\t\tend\n\n\t\[email protected] -= 1\n\t\[email protected] = 4 if @player.location == :Rubbisher\n\t\[email protected] -= 1\n\t\[email protected] += 1 if @player.pills > 0\n\t\tif @player.location == :free && @other_player.location == :free\n\t\t\t@escape_artists = @escape_artists.upcase\n\t\t\tif @player.stench > 0 || @player.beans > 0 || @other_player.stench > 0 || @other_player.beans > 0\n\t\t\t\t@stinky = @stinky.upcase\n\t\t\tend\n\t\t\tif (@player.stench > 0 && @other_player.beans > 0) || (@player.beans > 0 && @other_player.stench > 0)\n\t\t\t\t@double_stink = @double_stink.upcase\n\t\t\tend\n\t\t\tputs \"\\nYou've both escaped! Congratulations!\"\n\t\t\tif @player.dead\n\t\t\t\tputs @player.name + \" is dead.\"\n\t\t\t\t@dead_and_free = @dead_and_free.upcase\n\t\t\tend\n\t\t\tputs \"\\nSomething smells awful... the magic in those beans doesn't\\nseem to be good for your digestion.\\n\" if @player.beans > 0 && @player.location != :Rubbisher\n\t\t\tputs \"\\nSomething smells awful... the stench from the Rubbisher lingers on you.\\n\" if @player.stench > 0 && @player.location != :Rubbisher\n\t\t\tif @other_player.dead\n\t\t\t\tputs @other_player.name + \" is dead.\"\n\t\t\t\t@dead_and_free = @dead_and_free.upcase\n\t\t\tend\n\t\t\tputs \"\\nSomething smells awful... the magic in those beans doesn't\\nseem to be good for your digestion.\\n\" if @other_player.beans > 0\n\t\t\tputs \"\\nSomething smells awful... the stench from the Rubbisher lingers on you.\\n\" if @other_player.stench > 0\n\t\t\tshow_achievements\n\t\t\t@game = false\n\t\t\treturn\n\t\tend\n\t\tif @player.location == :free && @other_player.dead\n\t\t\tputs \"\\nYou've escaped, but you've left your friend behind to rot.\\n\"\\\n\t\t\t\t \"Way to go, hero.\"\n\t\t\t@game = false\n\t\tend\n\t\tif @player.location == :free\n\t\t\tputs \"\\n\" + @player.name + \" is free!\"\n\t\tend\n\t\tif @player.dead\n\t\t\tputs \"\\n\" + @player.name + \" is dead.\"\n\t\tend\n\t\tshow_current_description unless @player.location == :free\n\t\tputs \"\\nThe world swims before your eyes.\" if @player.pills == 2\n\t\tputs \"\\nIn the corners of your vision, colorful phantasms\\nflicker in and out of being.\" if @player.pills == 3\n\t\tputs \"\\nYou can see a spirit world overlaying the real one.\\nYour stomach hurts.\" if @player.pills == 4\n\t\tputs \"\\nYou can see a spirit world overlaying the real one.\\nYour entire body is starting to hurt.\" if @player.pills == 5\n\t\tif [4, 5].include?(@player.pills) && @player.location == :Lair && find_room_in_dungeon(:Lair).connections[:north] == nil\n\t\t\tputs \"\\nThe creature's image in the spirit world is far stronger than\\n\"\\\n\t\t\t\t \"in the real. In the spirit world, you can see the ideas holding\\n\"\\\n\t\t\t\t \"the creature together... you reach out your hand and you can\\n\"\\\n\t\t\t\t \"feel them, too. You twist your fingers and those ideas shift.\\n\"\\\n\t\t\t\t \"The creature blurs and disappears. In it's place, a mouse falls\\n\"\\\n\t\t\t\t \"to the floor and scampers away. Without the creature there, you\\n\"\\\n\t\t\t\t \"can see an exit to the north.\" \n\t\t\twin_door(:Lair, :north)\n\t\tend\t\n\t\tif @player.pills == 6\n\t\t\tputs \"\\nYour entire body feels like tiny rats are eating you from inside your veins,\\n\"\\\n\t\t\t\"and the rats are on fire. You can't do anything but lie on the floor and moan.\"\n\t\t\[email protected] = true\n\t\t\t@overdose = @overdose.upcase\n\t\t\tswitch_player\n\t\t\treturn\n\t\tend\n\t\tputs \"\\nSomething smells awful... the magic in those beans doesn't\\nseem to be good for your digestion.\\n\" if @player.beans > 0\n\t\tputs \"\\nSomething smells awful... the stench from the Rubbisher lingers on you.\\n\" if @player.stench > 0 && @player.location != :Rubbisher\n\t\tif @player.location == :Lair && (@player.stench > 0 || @player.beans > 0) && find_room_in_dungeon(:Lair).connections[:north] == nil\n\t\t\tputs \"\\nThe creature takes a step back, and wrinkles its already wrinkly nose. As it\\n\"\\\n\t\t\t\"glides to the side and disappears through the wall, you think you hear it\\n\"\\\n\t\t\t\"mutter something about the disadvantages of an enhanced sense of smell.\\n\"\\\n\t\t\t\"Without the creature there, you can see an exit to the north.\"\n\t\t\twin_door(:Lair, :north)\n\t\tend\n\t\tif @player.location == :free && @other_player.dead\n\t\t\treturn\n\t\tend\n\t\tif @player.location == :free\n\t\t\tswitch_player\n\t\t\treturn\n\t\tend\n\t\tif @player.dead\n\t\t\tswitch_player\n\t\t\treturn\n\t\tend\n\n\t\t#Matt easter egg\n\t\tif ['matt the amazing', 'matt the hero', 'matt the incroyable', \n\t\t\t'matt the handsome', 'matt the clever', 'matt the wonderful', \n\t\t\t'matt the indominable'].include?(@player.name.downcase)\n\t\t\[email protected] = @player.name.slice(0, 4)\n\t\tend\n\t\n\tend",
"def hitter(hitter)\n\t\t\tif $hitter == @player1\n\t\t\t\tself.hitter1\n\t\t\t\tself.rally\n\t\t\telse \n\t\t\t\tself.hitter2\n\t\t\t\tself.rally\n\t\t\tend\n\t\tend",
"def is_game_over?; won_by?(:hunter) || won_by?(:prey) end",
"def dealer_bust\n puts \"The dealer busted. You win\"\n player_win\n end",
"def initialize\n @silent = false\n self.deck = create_deck\n self.player = Player.new\n self.player.strategy = Strategy.new(self) #default player strategy\n self.dealer = Dealer.new(\"Dealer\")\n self.dealer.strategy = DealerStrategy.new(self)\n\n @last_hand = false\n end",
"def one_round\n player1_weapon = get_player_one_weapon\n player2_weapon = get_player_two_weapon\n return winner?(player1_weapon,player2_weapon)\nend",
"def double_player(player)\n player.bet *= 2\n end",
"def player_setup(player1, player2, names, symbols)\n player1[:player_type] == \"Human\" ? player1 = Human.find(player1[:id]) : player1 = Computer.find(player1[:id])\n player2[:player_type] == \"Human\" ? player2 = Human.find(player2[:id]) : player2 = Computer.find(player2[:id])\n player1.game_id = self.id\n player2.game_id = self.id\n player1.symbol = symbols[0]\n player2.symbol = symbols[1]\n player1.name = names[0]\n player2.name = names[1]\n player1.save\n player2.save\n self.player1_id = player1.id\n self.player2_id = player2.id\n self.save\n end",
"def tie_with_bj\n self.chips += self.bet_chips\n self.is_complete = true\n \"#{name} hit Blackjack! Dealer hit Blackjack too. Push for #{name}.\"\n end",
"def setup_players!(hunter_connection, hunter_name, prey_connection, prey_name)\n\t\t@hunter = Hunter.new(self, hunter_connection, hunter_name)\n\t\t@prey = Prey.new(self, prey_connection, prey_name)\n\tend",
"def winning_play\n {paper: [:rock, :spock], rock: [:lizard, :scissors], scissors: [:paper, :lizard], lizard: [:spock, :paper], spock: [:rock, :scissors], scratch: [:scratch]}\n end",
"def initialize(player)\n @player = player\n @state = 'draw'\n @swaps = []\n end",
"def before_players_ready\r\n end",
"def initialize\n @player1 = Player.new\n @player2 = Player.new\n @deck = Deck.new\n end",
"def play\n @hungry = true\n end",
"def play\n @hungry = true\n end",
"def play\n @hungry = true\n end",
"def deal\n self.deck.deal(player1)\n self.deck.deal(player2)\n end",
"def game_over\n end",
"def pass_out_characters_and_coins\n if self.players.size == 2 && @settings.include?(:twoplayer)\n side_decks = [[], []]\n # Uh this is kinda wonky.\n # Oh Well YOLT (You only live twice) in Coup.\n 5.times {\n side_decks[0] << self.draw_cards(1)[0]\n side_decks[1] << self.draw_cards(1)[0]\n self.deck.rotate!\n }\n end\n\n self.deck.shuffle!\n\n # assign loyalties\n self.players.each_with_index do |player, index|\n if self.players.size == 2\n if @settings.include?(:twoplayer)\n player.receive_characters(self.draw_cards(1))\n player.receive_side_characters(*side_decks[index].shuffle)\n else\n player.receive_characters(self.draw_cards(2))\n end\n # first player gets 1 coin and second gets 2.\n player.give_coins(index + 1)\n else\n player.receive_characters(self.draw_cards(2))\n player.give_coins(2)\n end\n end\n end",
"def player_lives(player)\n player == 1 ? @player_1_lives : @player_2_lives\nend",
"def initialize(player)\n @player = player\n end",
"def max_player\n return 1\n end",
"def is_tie?\n if gladiators[0].weapon == gladiators[1].weapon\n @gladiators = []\n return true\n end\n return false\n end",
"def switch_players \n @active_player, @inactive_player = @inactive_player, @active_player\n end",
"def all_at_table\n @players+[@dealer]\n end",
"def bind_player(player)\r\n @alg_player = player\r\n @log.info(\"[#{@alg_player.type}] Autoplayer #{@alg_player.type} bound with #{player.name}. Ignore actions predifined.\")\r\n @action_queue = []\r\n end",
"def dealer\n if @hand\n (@hand.dealer == @player1) ? @player2 : @player1\n else\n # coin toss\n (rand(2) == 0) @player1 : @player2\n end\n end",
"def give_bonus player\n player.add_weapon(Vibrant_Weapon.new(@window, player))\n end",
"def advance_dealer\n put(:dealer) {|x| player_relative_to(x, 1) }\n end",
"def initialize\n @player1 = get_player_name('1')\n @player2 = get_player_name('2')\n @current_player = @player1\n end",
"def choice_a_battle\n use_item_in_battle\n end",
"def take_bets\n @players.each do |p|\n @events.handle(:pre_player_bet, p)\n\n p.hand.bet = p.place_bet\n\n @events.handle(:post_player_bet, p, p.hand.bet)\n end\n end",
"def choose_player\n case @name\n when 'R2D2' then rtwodtwo\n when 'Hal' then hal\n when 'Chappie' then chappie\n end\n end",
"def punch(player_name)\n\t # we change the life (hp) of our adversary, and we can because of the hp accessor ! \n\t player_name.hp = player_name.hp - 10\n\n\tend",
"def initialize\n @shoe = @player_cnt = @dealer = nil\n @num_rounds = @num_shoes = 0\n @num_decks = 1\n @max_players = 4\n @min_bet = 1\n @max_bet = 100\n @bet_increment = 1\n @bankroll = 1000\n @hit_soft_17 = nil\n @even_money_offered = 1 # Hate when casinos don't offer this option\n @players = []\n @broke_players = []\n @io = BlackJackIO.new\n end",
"def after_players_ready\r\n end",
"def initialize_players\n\n end",
"def play\n 2.times {deal}\n blind_score\n if player_hand.collect{|x| x.value}.inject(:+) == 21\n bjwin\n elsif computer_hand.collect{|x| x.value}.inject(:+) == 21\n bjlose\n else\n action\n end\n end",
"def enemy; end",
"def starship; end",
"def new_player_required?; false end",
"def deal_hand\n 2.times do\n dealer << shoe.deal\n player << shoe.deal\n end\n end",
"def tie_with_points\n self.chips += self.bet_chips\n self.is_complete = true\n \"#{name}'s point is same as dealer! Push for #{name}.\"\n end",
"def ai_one_logic(player)\n type = player.ai\n if self.round == 0\n if self.high_bet < 5\n return 'call', 0\n else\n return 'fold', 0\n end\n else\n if self.high_bet == 0\n return 'bet', 2\n elsif self.high_bet < 4\n return 'raise', 4\n elsif self.high_bet >= 16\n return 'fold', 0\n else\n return 'call', 0\n end\n end\n end",
"def game_mode; end",
"def possible_plays\n [:paper, :rock, :scissors, :spock, :lizard]\n end",
"def addBlinds()\n s_blind_loc = get_next_player(self.dealer) # location of small blind player\n b_blind_loc = get_next_player(s_blind_loc) # location of big blind player\n # get player data for small and big blind locations\n s_blind_player = get_player(s_blind_loc) # actual players to change money\n b_blind_player = get_player(b_blind_loc)\n # put money from small and big blind players into pot\n put_money(self.small_blind, s_blind_player)\n put_money(self.big_blind, b_blind_player)\n self.current_player = get_next_player(b_blind_loc)\n b_blind_player.save\n s_blind_player.save\n self.save\n end",
"def start_new_match\n @player1.points = 0\n @player1.deuce = false\n @player1.advantage = false\n @player1.win = false\n @player1.games_won = 0\n @player1.sets_won = 0\n\n @player2.points = 0\n @player2.deuce = false\n @player2.advantage = false\n @player2.win = false\n @player2.games_won = 0\n @player2.sets_won = 0\n end",
"def player_name\n player.name\n end",
"def initialize\n self.player_hash = {}\n self.user_hash = {}\n self.playing_user_names=[]\n self.started = false\n self.disks_for_each_player=4#default\n self.shuffle_names = true\n end",
"def initialize name\n @player = name\n @@player_count+=1\n end",
"def game_over(name)\n end",
"def init_deal(play_deck, dealer_hand, player_hand)\n for i in 1..2\n dealer_hand << hit(play_deck)\n player_hand << hit(play_deck)\n end\nend",
"def loser\n return winner == :player_a ? :player_b : :player_a\n end",
"def reset_statuses\n @player1.deuce = false\n @player2.deuce = false\n @player1.advantage = false\n @player2.advantage = false\n end",
"def detect_result(dealer_total, player_total)\n if dealer_total < player_total\n :player\n elsif dealer_total > player_total\n :dealer\n else\n :tie\n end\nend",
"def load_tsbs\n @battler_name = @name.clone\n @attack_id = 0\n @guard_id = 0\n super\n end",
"def pbChangePlayer(id)\n return false if id<0 || id>=8\n meta=pbGetMetadata(0,MetadataPlayerA+id)\n return false if !meta\n $Trainer.trainertype=meta[0] if $Trainer\n $game_player.character_name=meta[1]\n $game_player.character_hue=0\n $PokemonGlobal.playerID=id\n $Trainer.metaID=id if $Trainer\nend",
"def skier_quest; end"
] | [
"0.67239624",
"0.66771483",
"0.6507257",
"0.64697087",
"0.6375969",
"0.632774",
"0.632774",
"0.632774",
"0.632774",
"0.632774",
"0.632774",
"0.632774",
"0.62016624",
"0.61749953",
"0.616538",
"0.6162165",
"0.61455154",
"0.6081245",
"0.60663533",
"0.60663533",
"0.60663533",
"0.6040839",
"0.6004938",
"0.5979201",
"0.594471",
"0.59402835",
"0.59220195",
"0.5914651",
"0.5892211",
"0.5890506",
"0.587741",
"0.5862387",
"0.5852693",
"0.58474714",
"0.5845201",
"0.5829265",
"0.5827045",
"0.5824348",
"0.58199215",
"0.5806645",
"0.5778979",
"0.57734406",
"0.5769306",
"0.5767074",
"0.5766148",
"0.5754215",
"0.5747455",
"0.5739778",
"0.57318234",
"0.57309556",
"0.5697674",
"0.5687084",
"0.56858313",
"0.5681434",
"0.5664291",
"0.5662809",
"0.5662809",
"0.5662809",
"0.5661347",
"0.56603295",
"0.5655468",
"0.5655352",
"0.5653007",
"0.56528157",
"0.5650243",
"0.5649456",
"0.5643456",
"0.56368953",
"0.562928",
"0.5629019",
"0.56276685",
"0.5622444",
"0.56143695",
"0.561259",
"0.5611914",
"0.56101775",
"0.5608646",
"0.5606989",
"0.5605956",
"0.55932194",
"0.5592538",
"0.55905986",
"0.55838835",
"0.55822146",
"0.5579567",
"0.5576228",
"0.5573155",
"0.55678356",
"0.5565794",
"0.55631393",
"0.5561575",
"0.5560465",
"0.5557553",
"0.55556995",
"0.5553997",
"0.55485183",
"0.5548216",
"0.55425286",
"0.55376655",
"0.55352753",
"0.55298126"
] | 0.0 | -1 |
Initializes the rating with its various attributes | def initialize(user_id,movie_id,rating,timestamp)
@user_id = user_id
@movie_id = movie_id
@rating = rating
@timestamp = timestamp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_rating\n create_rating if self.sf_id =~ /\\D/ and rating.nil?\n end",
"def initialize\n @rating_list = {}\n end",
"def initialize(id,rating)\n @id = id\n @rating = rating\n end",
"def initialize(rating)\n move_id = rating.movie_id\n @rating_list = {movie_id: rating}\n @id = rating.user_id\n end",
"def rating_attributes=(ratings_attributes)\n self.ratings = ratings_attributes.collect do |key, rating_attributes|\n Rating.new(rating_attributes) if !rating_attributes[\"value\"].blank?\n end.compact\n end",
"def blank_rating\n self.rating ||= 0\n end",
"def rating=(rating)\n rate_attrs = rating.attributes.with_indifferent_access.slice(*Rating::LIST)\n assign_attributes(rate_attrs)\n end",
"def rating_id=(rating_id)\n self.rating = Rating.find rating_id\n end",
"def initialize_attributes\n @total_positives = 0\n @total_negatives = 0\n @total_neutrals = 0\n super\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def check_rating\n if self.rating == nil \n self.rating = 0\n end \n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n @rating = Rating.find(params[:id])\n end",
"def set_rating\n all_ratings = []\n self.reviews.each { |review| all_ratings << review.overall_rating }\n self.rating = all_ratings.reduce(:+) / (all_ratings.length * 1.0)\n self.save\n end",
"def rating\n 0\n end",
"def initialize(title)\n self.title = title\n @ratings = []\n ALL << self\n end",
"def set_defaults\n self.rate ||= 0\n end",
"def set_rating(id)\n @rating = Rating.find(id)\n end",
"def create_ratyrate\n\t\tself.rate(self.rating, self.user, \"rating\", false)\n\tend",
"def rating\n rating_calculator.rate(raters)\n end",
"def init\n self.like_count = 0 if self.like_count.nil?\n end",
"def set_rating\n food_reviews = self.food_reviews\n if self.has_rating\n totrating = 0\n food_reviews.each do |food_review|\n totrating = totrating + food_review.rating\n end\n avg_rating = totrating.to_f/food_reviews.length\n @food_rating = avg_rating.round(2)\n return\n end\n @food_rating = 0.0\n end",
"def initialize(attributes)\n\t\t\tsuper\n\n\t\t\t# The wrapper to the API does not judge original values, so I initialize them here\n\t\t\t@max_weight ||= 100000000000\n\t\t\t@min_weight ||= 0\n\t\t\t@max_depth ||= 100000000000\n\t\t\t@min_depth \t||= 0\n\t\t\t@max_height ||= 100000000000\n\t\t\t@min_height ||= 0\n\t\t\t@max_width \t||= 100000000000\n\t\t\t@min_width \t||= 0\n\t\t\t@max_value \t||= 100000000000\n\t\t\t@min_value \t||= 0\n\n\t\tend",
"def set_rating\n @rating = Rating.find_by_name(params[:id])\n end",
"def rating_params\n params.fetch(:rating, {})\n end",
"def rating\n return @rating if @rating\n result = PublicEarth::Db::Collection.one.rating(self.id)\n @rating = { :average_rating => result['average_rating'].to_f, :rating_count => result['rating_count'].to_i } rescue nil\n end",
"def default_values\n self.avg_rating ||= -1\n end",
"def rating #Getter\n @rating\n end",
"def create_rating\n return unless valid?\n @rating_class.create(\n social_entry: @social_entry,\n rateable: @rateable,\n rater: @rater,\n ratee: @ratee,\n rating_type: @rating_type,\n rating_metrics: @rating_metrics\n )\n update_rating_aggregates\n end",
"def init\n self.upvotes_count ||= 0 # will set the default value only if it's nil\n self.comment_count ||= 0 # will set the default value only if it's nil\n end",
"def initialize(options)\n\t\tBASE.each do |stat|\n\t\t\traise \"Missing statistic #{stat}\" unless options[stat]\n\t\t\tset(stat, options[stat])\n\t\tend\n\t\tRATINGS.each { |rating| set(rating, 0) }\n\t\tOTHER.each { |rating| set(rating, 0) }\n\tend",
"def rating\n r = Rating.create_from_database(rating_id.to_i)\n r.rating\n end",
"def initialize(trip_info={})\n @id = trip_info[:id].to_i\n @driver_id = trip_info[:driver_id].to_i\n @rider_id = trip_info[:rider_id].to_i\n @date = trip_info[:date]\n @rating = trip_info[:rating].to_i\n rating_verification(@rating)\n end",
"def initialize(recipe, date, rating, user)\n @recipe = recipe\n @rating = rating\n @date = date\n @user = user\n @@all << self\n end",
"def initialize(attr={})\n @batting, @pitching, @fielding = BattingStat.new, PitchingStat.new, FieldingStat.new\n @attr = attr\n end",
"def set_default_values\n if self.price.nil?\n self.price = 0.0\n end\n if self.rating.nil?\n self.rating = 0\n end\n if self.enabled.nil?\n self.enabled = false\n end\n if self.no_of_reviews.nil?\n self.no_of_reviews = 0\n end\n if self.no_of_registrations.nil?\n self.no_of_registrations = 0\n end\n end",
"def initialize(atts = nil)\n initialize_attributes\n self.update_attributes(atts || {})\n end",
"def new\r\n\t\t@rating = Rating.new\r\n\t\[email protected]_id = Widget.find_by_id(params[:widget_id]).id\r\n\t\t# verificamos si el usuario ya puntuo el widget\r\n\t\t@rate = Rating.find(:all, :conditions => {:widget_id => @rating.widget_id, :user_id => current_user.id}).first\r\n\t\tif @rate.nil?\r\n\t\t\t@rate = 0\r\n\t\telse\r\n\t\t\t@rate = @rate.rate\r\n\t\tend\r\n\tend",
"def initialize(user, recipe, date, rating)\n @user = user\n @recipe = recipe\n @date = date\n @rating = rating\n @@all << self\n end",
"def rating\r\n\t\t@rating\r\n\tend",
"def rate(rating)\n @nb_ratings += 1\n @sum_ratings += rating\n @average_rating = @sum_ratings / @nb_ratings\n end",
"def ratings_count\n rating && rating.ratings_count || 0\n end",
"def rating(value)\n @ole.Rating = value\n nil\n end",
"def set_rating_score\n @rating_score = RatingScore.find(params[:id])\n end",
"def initialize(attributes = {})\n\t\t\tattributes.each_pair do |key, value|\n\t\t\t\tself.send(\"#{key}=\", key.to_s == \"birthYear\" ? value.to_i : value)\n\t\t\tend\n\t\tend",
"def set_Rating(value)\n set_input(\"Rating\", value)\n end",
"def initialize\n @rate = 0.90\n end",
"def initialize\n @rate = 0.10\n end",
"def rating\n if average_rating?\n # Integerize it for now -- no fractional average ratings\n (the_ratings = ratings.average(:rating)) ? the_ratings.round : 0.0\n else\n self.old_rating.nil? ? nil : self.old_rating.rating\n end\n end",
"def rating\n @rating\n end",
"def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end",
"def initialize_attributes(attributes); end",
"def load_ratings (movie)\n\t\tmovie[\"ratings\"] = Rating.by_movie(movie[\"id\"])\n\tend",
"def initialize(attributes)\n @score = attributes['score']\n @name = attributes['name']\n @title = attributes['title']\n @comment_count = attributes['num_comments']\n @ups = attributes['ups']\n @downs = attributes['downs']\n @url = attributes['url']\n @domain = attributes['domain']\n @author = User.new(attributes['author']) unless attributes['author'].nil?\n @id = attributes['id']\n # Reddit's created_at timestamps are currently wonky, so this will return the wrong time.\n @created_at = Time.at(attributes['created']) unless attributes['created'].nil?\n @saved = attributes['saved']\n @clicked = attributes['clicked']\n @hidden = attributes['hidden']\n @selftext = attributes['selftext']\n @selftext_html = attributes['selftext_html']\n end",
"def init\n return if has_attribute?(:review_status_id) && review_status_id\n self.review_status = ReviewStatus.find_by(code: 'UnderReview')\n end",
"def min_rating\n 0\n end",
"def default_values\n rating = 0\n if user_id.nil?\n user_id = User.find(1)\n end\n end",
"def initialize(name, coordinate_x, coordinate_y)\n @rating = 0\n @rating_counter = 0\n @name = name\n @coordinate = Coordinate.new(coordinate_x, coordinate_y)\n end",
"def initialize_attributes()\n @attributes ||= {}\n merged_attributes = {}\n defaults = self.class.schema.defaults(self)\n\n # Merge the defaults in where attributes don't have a value defined.\n defaults.each do |name, value|\n merged_attributes[name] = attributes[name] || value\n end\n @attributes = merged_attributes\n end",
"def rating_params\n params.require(:rating).permit(:rating, :user_id, :post_id)\n end",
"def rating\n return nil unless ratings.length > 0\n (ratings.average(:value) / 0.25).round * 0.25\n end",
"def initialize(discount = 0) #Says what attributes each instance is born with\n @total = 0\n @discount = discount \n @item = []\n end",
"def initialize(atts = {})\n reload_attributes(atts)\n end",
"def initialize\n set_name # generally not a good idea to include logic in initialize method, so will encapsulate that logic into set_name method\n @score = 0\n end",
"def initialize_attributes\n @training_model = Hash.new { |h, k| h[k] = Hash.new(0) }\n @classes = Set.new\n @total_words_counter = 0\n @negative_population = 0\n @neutral_population = 0\n @positive_population = 0\n @training_negatives = 0\n @training_neutrals = 0\n @training_positives = 0\n end",
"def set_idea_rating\n @idea_rating = IdeaRating.find(params[:id])\n end",
"def initialize(*attrs)\n set_attributes(attrs.extract_options!)\n end",
"def preinitialize(attrs = nil)\n @attributes = {}\n end",
"def rating_params\n params[:rating]\n end",
"def initialize(id, name, rate_type_id, rate_type_name, room_type_content, rate_type_content)\n @id = id\n @name = name\n @rate_type_id = rate_type_id\n @rate_type_name = rate_type_name\n @room_type_content = room_type_content\n @rate_type_content = rate_type_content\n end",
"def rating_params\n\t\tparams.require(:rating).permit(:ratable, :score, :user)\n\tend",
"def rate_recipe(rating, recipe)\n recipe.ratings << Rating.create(user: self, recipe: recipe, star_rating: rating)\n end",
"def initialize(attrs = {})\n @attributes = attrs\n\n # Set values where we have defined a reader, probably\n @attributes.each do |key, val|\n if respond_to?(key.to_sym)\n instance_variable_set(\"@#{key}\", val)\n end\n end\n end",
"def rating\n return @rating\n end",
"def set_restaurant_table_rating\n @restaurant_table_rating = RestaurantTableRating.find(params[:id])\n end",
"def initialize(rateable)\n @rateable = rateable\n end",
"def initialize(title, source) #why am I not passing upvote as an argument for initialize?\n\t\t@title = title\n\t\t@source = source\n\t\t@upvote = 0\n\tend",
"def initialize(atts = {})\n @attributes = {}\n @embedding = {}\n @_memo = {}\n update_attributes(model.defaults.merge(atts))\n end",
"def rating_params\n params.require(:rating).permit(\"food\", \"drinks\", \"talks\", \"vibe\")\n end",
"def set_reviews_and_rating\n @reviews_and_rating = ReviewsAndRating.find(params[:id])\n end",
"def average_rating\n rating && rating.average_rating || 0.0\n end",
"def initialize\n\t\t@ratings = Hash.new\n\t\t@f = File.read('u.data')\n\t\t@users = Hash.new\n\tend",
"def initialize(node, discount_repeated_attributes: T.unsafe(nil)); end",
"def initialize ## initializing 3 variables that come with Twitter Trends info. Am I doing something wrong?\n @name= nil\n @query_trend= nil\n @promoted_content= nil\n end",
"def rating_params\n params.require(:rating).permit(:value)\n end",
"def rating\n average = 0.0\n ratings.each { |r|\n average = average + r.rating\n }\n if ratings.size != 0\n average = average / ratings.size\n end\n average\n end",
"def rating\n review.rating if review\n end",
"def update_ratings\n tournament.rater.update_ratings(self)\n end"
] | [
"0.7673313",
"0.7470649",
"0.73743445",
"0.7259347",
"0.71213055",
"0.68973154",
"0.68631005",
"0.67338026",
"0.67326015",
"0.6702151",
"0.6702151",
"0.6702151",
"0.6702151",
"0.6702151",
"0.6702151",
"0.6702151",
"0.6702151",
"0.6702151",
"0.6702151",
"0.66445476",
"0.6620648",
"0.66065377",
"0.65566146",
"0.65566146",
"0.65566146",
"0.64625394",
"0.6462153",
"0.6434016",
"0.6426948",
"0.64112836",
"0.6406744",
"0.63941145",
"0.6388814",
"0.6385498",
"0.63522106",
"0.6347331",
"0.63403577",
"0.6283914",
"0.6271222",
"0.62348104",
"0.6212538",
"0.61915785",
"0.61792254",
"0.61666816",
"0.6165077",
"0.61493474",
"0.61164683",
"0.61094564",
"0.609237",
"0.6067357",
"0.60669357",
"0.60635877",
"0.60457855",
"0.6043397",
"0.6042227",
"0.60314405",
"0.6024739",
"0.6018535",
"0.5996241",
"0.59923106",
"0.5976771",
"0.59646493",
"0.59570986",
"0.59406024",
"0.59337705",
"0.5922176",
"0.59055364",
"0.59022367",
"0.58997554",
"0.58712083",
"0.58597314",
"0.58582693",
"0.5853959",
"0.58486074",
"0.5845909",
"0.58434564",
"0.58212274",
"0.58169603",
"0.5814801",
"0.5805553",
"0.580447",
"0.5801094",
"0.57936436",
"0.579159",
"0.5788441",
"0.57822275",
"0.5777257",
"0.57682484",
"0.5763408",
"0.5760915",
"0.57599586",
"0.5756612",
"0.5755058",
"0.5742194",
"0.57409954",
"0.57330906",
"0.57130647",
"0.5709245",
"0.5707497",
"0.5702558"
] | 0.64645636 | 25 |
Method checks the current_user is the Team Lead. Only Team Leads are allow to modify teams | def check_if_user_is_team_leader?
render json: ["Only the Team Lead can edit this team"], status: 422 unless current_user.id == this_team.user_id;
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_edit_team?(team)\n can_manage_teams? || team_leader?(team.friendly_id)\n end",
"def check_access(team)\n if !team.is_in?(user)\n flash[:error] = \"Vous ne faites pas partie de cette équipe\"\n redirect_referrer\n end\n end",
"def check_use_team\r\n if !params[:team_id].nil?\r\n users = Team.find_by_id(params[:team_id]).users\r\n if !(users.include?(current_user))\r\n redirect_to frontend_root_path,\r\n notice: \"Team not Assigned\"\r\n end\r\n end\r\n end",
"def change_team?\n raise Pundit::NotAuthorizedError, \"must be logged in\" unless user\n user.admin? || (APP_CONFIG.enabled?(\"user_permission.manage_namespace\") &&\n namespace.team.owners.exists?(user.id))\n end",
"def set_team\n @team = Team.find(params[:id])\n unless @logged_in and @logged_in.update_site?\n @team.readonly!\n end\n end",
"def verify_team_manageability\n # Bail out unless the user is a valid team manager:\n # To be a valid team manager\n # a user must be:\n # - enabled to manage the selected team\n @is_valid_team_manager = TeamManagerValidator.can_manage_team?( current_user, @team )\n unless ( @is_valid_team_manager )\n flash[:error] = I18n.t(:invalid_action_request) + ' - ' + I18n.t('meeting.errors.invalid_team_manager')\n redirect_to( team_radio_path(id: @team.id) ) and return\n end\n end",
"def can_manage_teams?\n admin? || board_member? || results_team?\n end",
"def check_if_user_is_project_leader?\n if current_user.id != this_project.project_leader_id;\n render json: [\"Only the Project Lead can edit this project\"]\n end\n end",
"def demoting_admin?(team_user)\n team_user.user&.admin? && new_role != \"owner\"\n end",
"def check_role\n redirect_to root_path unless current_user && current_user.evo_team?\n end",
"def user_belongs_to_team!\n if signed_in? && current_team.present?\n redirect_to root_app_url unless current_team_role\n end\n end",
"def centerleder_access\r\n if current_user.access? :team_new_edit_delete\r\n return true\r\n elsif current_user\r\n puts \"centerleder_access current_user: #{current_user.inspect}\"\r\n flash[:notice] = \"Du har ikke adgang til denne side\"\r\n redirect_to teams_path\r\n else\r\n puts \"centerleder_access NOT LOGGED IN\"\r\n flash[:notice] = \"Du har ikke adgang til denne side\"\r\n redirect_to login_path\r\n end\r\n end",
"def authenticateA_M2(nameTeam)\n\t if m=Team.find_by_name(name) \n\t\tif(isInTeam? || is_admin?)\n\t\t\tif ((m.id == myTeam.id)|| is_admin?)\n\t\t\t\ttrue\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\telse\n\t\t false\n\t\tend\n\t else\n\t\tfalse\n\t end\n end",
"def set_team\n @team = current_user.teams.find(params[:id])\n end",
"def authorized_for_team\n team = Team.find(params[:id]);\n redirect_to root_path unless team.users_ids.include?(current_user.id) || \n current_user.in_tab_room?(team.tournament);\n end",
"def is_on_staff\n self.teams\n end",
"def team_account?\n account_type == 'team'\n end",
"def current_user_team\n current_user.team\n end",
"def set_team\n @team = current_user.teams.find(params[:id])\n end",
"def set_team\n @team = Team.accessible_for(current_user).friendly.find(params[:id])\n end",
"def with_access_to_teams_with_any_role\n if c_level?\n organization.teams\n else\n TeamMember.includes(:team).where(user: self).collect(&:team)\n end\n end",
"def check_use\r\n if !(params[:id]).nil?\r\n if !((Team.find_by_id(TodoList.find_by_id(params[:id]).team_id).users).include?(current_user))\r\n redirect_to frontend_root_path,\r\n notice: \"You cannot see Todo List\"\r\n end\r\n end\r\n end",
"def authenticateA_L2(nameTeam)\n\trep=false\n\tm=Team.find_by_name(nameTeam)\n\tif is_leader(m.name) \n\t\trep=true\n\telsif (is_admin?)\n\t\trep = true\n\tend\n\treturn rep\n end",
"def current_team\n \t\tTeam.find_by(id: current_user.team_id)\n \tend",
"def action_allowed?\n return true if ['Instructor', 'Teaching Assistant', 'Administrator', 'Super-Administrator'].include? current_role_name\n @teams = TeamsUser.where(user_id: current_user.try(:id))\n @teams.each do |team|\n return true if Team.where(id: team.team_id).first.parent_id == sample_submission_params[:id].to_i\n end\n false\n end",
"def set_team\n @contact = Contact.user_scope().find_by(id: params[:id])\n if [email protected]?\n redirect_to teams_path, :flash => { :error => \"Team member Not Found!\" }\n end\n end",
"def team_for_user(user)\n membership = TeamMembership.find_by user: user, team: teams\n membership && membership.team\n end",
"def can_enter?(user)\n self.is_active &&\n self.teams.include?(user.team) &&\n (self.start_date < Time.now) && (!self.finish_date || self.finish_date > Time.now)\n end",
"def can_see_user_ids_as_team_member_or_team_leader\n user_has_access_to_team_ids = TeamMember.where(user: self).pluck(:team_id)\n\n TeamMember.where(team: user_has_access_to_team_ids).pluck(:user_id)\n end",
"def user_admin?(login, repo, settings)\n user_in_group?(login, repo, settings, 'repo_to_admin_teams')\n end",
"def only_members\n @requirement = Requirement.find(params[:id])\n @team = @requirement.team\n\n if current_user == nil\n flash.now[:danger] = 'Este time está privado. Você precisa estar logado.'\n redirect_to signin_path\n elsif current_user != @team.user && !current_user.member_of?(@team)\n flash[:danger] = 'Você precisa ser um membro deste time.'\n redirect_to teams_path\n else\n #nothing to do\n end\n end",
"def current_team\n\t\tTeam.find_by(id: current_user.team_id)\n\tend",
"def set_admin_team\n @admin_team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n @organization = @team.organization\n authorize @team\n end",
"def check_user_teammate_permissions\n current_user_teammate = @current_user.teammates.where(pitch_id: @pitch.id).take\n redirect_to forbidden_path if current_user_teammate.nil?\n end",
"def edit_member(_team, _user, _role: :reader)\n # stub\n end",
"def is_on_staff?(team)\n self.teams.include?(team)\n end",
"def set_team\n @team = Team.find(params[:id]) #This doesn't make sense. Why are we searching for a team that matches the User id?\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 filter_lead\n # only project lead or admin can update a project\n if [email protected]?\n raise Exceptions::GitlabApiException.new(\"Access forbidden for this user\")\n end\n\n # admin or owner can change all\n if [email protected]? && params[:owner_id] && params[:owner_id] != @user.id\n params_p = params[:project]\n params[:project] = []\n params[:project][:user_ids] = params_p[:user_ids]\n end\n\n true\n end",
"def check_accept_access\n @user_invite = current_user.user_invites.find_by id: params[:id]\n @team = @user_invite&.team\n redirect_back(fallback_location: user_root_path, alert: I18n.t('invites.invalid_permissions')) if @user_invite.nil?\n end",
"def verify_teamship\n # Bail out unless the user is a valid team manager:\n # To be a valid team manager\n # a user must be:\n # - enabled to manage the selected team\n @is_team_swimmer = false\n if verify_team_manageability\n @is_team_swimmer = true\n else\n @is_team_swimmer = current_user.swimmer.badges.where([\"team_id = ? and season_id = 182\", @team_id])\n end\n unless ( @is_team_swimmer )\n flash[:error] = I18n.t(:invalid_action_request) + ' - ' + I18n.t('team_management.error_no_team_swimmer')\n redirect_to( team_radio_path(id: @team.id) ) and return\n end\n end",
"def authorize_read_team!\n unless teams.present? or can?(current_user, :read_team, team)\n return render_404\n end\n end",
"def is_team_member?\n self.dig_for_boolean(\"isTeamMember\")\n end",
"def manage_team\n @user = User.first\n @project = Organization.first.projects.find_by(id: params[:id])\n end",
"def edit\n if @direction.created_by != current_user\n flash[:alert]=\"You cannot modify another user direction\"\n redirect_to users_directions_url\n end\n end",
"def can_be_modified_by?( user )\n return false if ( user.restricted? )\n return true if ( user.admin? )\n return self.active\n end",
"def assign_team_from_user\n user = Hubstats::User.find(self.user_id)\n if user.team && user.team.id\n self.update_column(:team_id, user.team.id)\n end\n end",
"def set_user_in_team\n @user_in_team = UserInTeam.find(params[:id])\n end",
"def verify_team\n set_team_from_team_id\n unless ( @team )\n flash[:error] = I18n.t(:invalid_action_request) + ' - ' + I18n.t('meeting.errors.missing_team_id')\n redirect_to( meetings_current_path() ) and return\n end\n end",
"def give_access_to_teams\n teams.includes(:users).each do |team|\n team.users.each do |user|\n user.set_access_to_app(self, team.id)\n end\n end\n end",
"def can_create_team?(team_name,member)\n true\n end",
"def owner?(team)\n teams_created.include?(team)\n end",
"def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end",
"def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end",
"def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end",
"def update\n# @user = User.find(params[:id])\n\n current_user.team = Team.find(params[:user][:team_id])\n current_user.team.save!\n\n respond_to do |format|\n if current_user.update_attributes(params[:user])\n format.html { redirect_to(root_path(), :notice => 'User was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def on_a_team?\n !team.nil?\n end",
"def can_be_modified_by?( user )\n if ( user.admin? )\n true\n elsif ( user.manager? )\n ( user.id == self.user.id ) or ( not self.committed )\n else\n ( user.id == self.user.id ) and ( not self.committed )\n end\n end",
"def update\n @team = Team.find(params[:id])\n @course = @team.course\n if has_permissions_or_redirect(:staff, course_team_path(@course, @team))\n @faculty = User.find(:all, :order => \"twiki_name\", :conditions => [\"is_teacher = true\"])\n\n msg = @team.update_members(params[:people])\n unless msg.blank?\n flash.now[:error] = msg\n render :action => 'edit'\n return\n end\n\n # handle_teams_people\n\n update_course_faculty_label\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n flash[:notice] = 'Team was successfully updated.'\n format.html { redirect_to(course_teams_path(@team.course)) }\n format.xml { head :ok }\n else\n @faculty = User.find(:all, :order => \"twiki_name\", :conditions => [\"is_teacher = true\"])\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n define_team_user\n end",
"def is_manager(livian_user_id)\n User.find(:first, :joins => [:role], :conditions => [\"user_id = ? AND roles.name = ?\", livian_user_id, 'team_manager']).present?\n end",
"def can_alter?(someone)\n someone.kind_of?(User) && (someone.admin? || someone == self.user)\n end",
"def member_of?(team)\n self.team == team\n end",
"def check_team_member\n if owner_team.user.id == guest_team.user.id || owner_team.user.id == guest_team.teammate.id || owner_team.teammate.id == guest_team.user.id || owner_team.teammate.id == guest_team.teammate.id\n errors.add(:game, \"can not have the same member in 2 team\")\n end \n end",
"def leave_team\n @mutineer = User.find(params[:id])\n previousTeam = @mutineer.team_id\n usersOnOldTeam = User.where(team_id: previousTeam)\n\n usersOnOldTeam.each do |u|\n Bulletin.destroy_all(user_id: u.id, approval_pending: true)\n Approval.destroy_all(user_id: u.id)\n end\n\n if @mutineer.update_attributes(:team_id => nil)\n if User.find_by(team_id: previousTeam) == nil\n Team.destroy(previousTeam)\n redirect_to \"/teams/\"\n else\n redirect_to \"/teams/#{previousTeam}\"\n end\n #redirect_to \"/teams/\"\n else\n redirect_to \"/failure_page\"\n end\n end",
"def is_not_on_staff\n #Team.find(:all) - self.teams\n Team.all - self.teams\n end",
"def disable_check_box?(user)\n !((user.role?(\"team_manager\") || user.role?(\"secretary\")) && (user.eql?(current_user) || is_team_manager))\n end",
"def is_user_tagged_to_team?(user)\n self.users.include? user\n end",
"def can_edit_stp?\n ticket_params = params[:ticket] \n (ticket_params[:status].nil? and ticket_params[:ticket_type].nil? and ticket_params[:priority].nil?) or \n is_team_member?(current_user.id)\n end",
"def change_team\n @changeTeamUser = User.find(params[:id])\n oldTeam = Team.find(@changeTeamUser.team_id)\n usersOnOldTeam = User.where(team_id: oldTeam.id)\n usersOnOldTeam.each do |u|\n Bulletin.destroy_all(user_id: u.id, approval_pending: true)\n Approval.destroy_all(user_id: u.id)\n end\n\n if @changeTeamUser.update_attributes(:team_id => nil)\n if User.find_by(team_id: oldTeam.id) == nil\n Team.destroy(oldTeam.id)\n end\n redirect_to(\"/users/#{current_user.id}\")\n else\n redirect_to \"/404/\"\n end\n\n end",
"def valid_auth\n if @user.auth == 0\n flash[:warning] = \"Your can not create Team\"\n redirect_to :action => \"index\"\n end\n end",
"def active?\r\n self.team.active?\r\n end",
"def team_information_list\n @teams = Team.find_teams_by_user(current_user.id)\n \n end",
"def leave_team\n team = Team.find_by_id params[:id]\n partition = TeamPartition.find_by_id team.partition_id\n if partition.editable\n team_membership = TeamMembership.where(:user_id => current_user.id, :team_id => team.id).first\n team_membership.destroy\n ## If the Team is now empty...\n if TeamMembership.where(:team_id => team.id).first == nil\n team.destroy\n end\n flash[:notice] = \"You have been removed from that team.\"\n else\n flash[:notice] = \"That team is not editable.\"\n end\n redirect_to teams_student_path\n end",
"def is_member_of?(team)\n Member.find_by_user_id_and_team_id(self.id, team.id)\n end",
"def wants_to_change_team?\n p = params[:namespace]\n p[:team].present? && p[:team] != @namespace.team.name\n end",
"def set_manage_team\n @manage_team = ManageTeam.find(params[:id])\n end",
"def user_can_edit?\n current_user == @list.user\n end",
"def show\n redirect_to team_path(@user.team) if @user.team\n end",
"def seeded_teams\n raise 'Not Implemented'\n end",
"def can_user_access?(user)\n if user.is_account_holder_or_administrator? || self.is_user_tagged_to_team?(user)\n true\n else\n false\n end\n end",
"def update\n respond_to do |format|\n if (current_user.team_id != @team.id) \n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n else\n if @team.update(team_params)\n #format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n #format.html { render :edit, notice: 'Team was successfully updated.' }\n format.html { redirect_to tracks_url, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def new_lesson?\n user.admin?\n end",
"def team_captain\n is_user_in_role(TEAM_CAPTAIN_ROLE_ID)\n end",
"def update\n redirect_back fallback_location: root_path unless current_user_admin? || (@user.id == current_user.id)\n\n unless @user\n flash[:alert] = \"We can not find account\"\n return redirect_back fallback_location: root_path\n end\n\n respond_to do |format|\n if @user&.update(user_params)\n\n if @user.user_type == \"team\"\n unless @user.team\n @team = Team.find_by(name: @user.name)\n\n if @team\n return redirect_to should_join_team_path(@team)\n else\n @user.create_team\n end\n end\n end\n\n return redirect_to users_admins_path if current_user_admin?\n format.html { redirect_to events_path, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def can_edit?(user)\n self == user\n end",
"def can_edit?(user)\n self == user\n end",
"def can_edit?(user)\n self == user\n end",
"def correct_user_to_edit\n not_allow if (@job.user.id != current_user.id) \n end",
"def set_editability\n @editable = user_signed_in? && (current_user.member.role.name.eql? \"University Admin\") &&\n current_user.member.institution.id == @course.department.institution.id\n end",
"def editable_by?(user)\n if self.status == :private\n self.user == user || self.featurings.map(&:user).include?(user)\n elsif status == :temporary\n true # XXX FIXME SECURITY HOLE RIGHT HERE: ANY USER CAN MODIFY TEMP SONGS FIXME\n elsif status == :public\n false\n end\n end",
"def extra_perms_for_all_users\n can :create, User\n can :create, PaperTrail::Version\n can :read, Team, :private => false\n can :read, Team, :private => true, :team_users => { :user_id => @user.id, :status => 'member' }\n\n # A @user can read a user if:\n # 1) @user is the same as target user\n # 2) target user is a member of at least one public team\n # 3) @user is a member of at least one same team as the target user\n can :read, User do |obj|\n @user.id == obj.id || obj.teams.where('teams.private' => false).exists? || @user.is_a_colleague_of?(obj)\n end\n\n # A @user can read contact, project or team user if:\n # 1) team is private and @user is a member of that team\n # 2) team user is not private\n can :read, [Contact, Project, TeamUser] do |obj|\n team = obj.team\n !team.private || @user.is_member_of?(team)\n end\n\n # A @user can read any of those objects if:\n # 1) it's a source related to him/her or not related to any user\n # 2) it's related to at least one public team\n # 3) it's related to a private team which the @user has access to\n can :read, [Account, Source, Media, ProjectMedia, ProjectSource, Comment, Flag, Status, Tag, Embed, Link, Claim] do |obj|\n if obj.is_a?(Source) && obj.respond_to?(:user_id)\n obj.user_id == @user.id || obj.user_id.nil?\n else\n team_ids = obj.get_team\n teams = obj.respond_to?(:get_team_objects) ? obj.get_team_objects.reject{ |t| t.private } : Team.where(id: team_ids, private: false)\n if teams.empty?\n TeamUser.where(user_id: @user.id, team_id: team_ids, status: 'member').exists?\n else\n teams.any?\n end\n end\n end\n end",
"def check_eligibility\n if params[:user_id].to_i == current_user.id\n redirect_to root_path, alert: \"Error: Owner can't collaborate\"\n end\n end",
"def user_trusted?(login, repo, settings)\n user_in_group?(login, repo, settings, 'repo_to_teams')\n end",
"def update_authorized?(target)\n @from_member.roles_include?(:moderator) || target == @from_member\n end",
"def user?(user, team_id)\n if TeamsUser.where(team_id: team_id, user_id: user.id).first\n true\n else\n false\n end\n end",
"def can_edit_dev? \n (assigned_dev_id = params[:ticket][:assigned_dev_id]).blank? or (is_admin_or_pm? and is_team_member?(assigned_dev_id))\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 can_edit?(user)\n user == current_user\n end"
] | [
"0.7071976",
"0.7069822",
"0.7068741",
"0.7049596",
"0.7046182",
"0.67955595",
"0.678053",
"0.6642092",
"0.6583335",
"0.6553016",
"0.6542398",
"0.6522999",
"0.6384407",
"0.6342866",
"0.63334334",
"0.63294965",
"0.63172734",
"0.63161284",
"0.6280954",
"0.62598145",
"0.62499374",
"0.6248622",
"0.62443256",
"0.6218656",
"0.62139016",
"0.61379313",
"0.6119219",
"0.6096256",
"0.60878664",
"0.6076664",
"0.60736394",
"0.6068262",
"0.6067201",
"0.6048856",
"0.60481745",
"0.604186",
"0.6036884",
"0.60332465",
"0.6029008",
"0.6021033",
"0.6020671",
"0.6012696",
"0.60114074",
"0.59760195",
"0.5974237",
"0.5971978",
"0.5937384",
"0.5928079",
"0.59221035",
"0.59186965",
"0.59186894",
"0.591658",
"0.5902546",
"0.58989835",
"0.58989835",
"0.58989835",
"0.58978134",
"0.5891469",
"0.58881766",
"0.5887894",
"0.5859649",
"0.5859307",
"0.5858291",
"0.58557105",
"0.58513814",
"0.5849568",
"0.58436877",
"0.5843653",
"0.58234036",
"0.5817766",
"0.58130246",
"0.5804168",
"0.5801841",
"0.5788453",
"0.57832694",
"0.578262",
"0.5782609",
"0.57735515",
"0.57713324",
"0.57580274",
"0.5754352",
"0.57482487",
"0.57455635",
"0.57354915",
"0.57321596",
"0.57318944",
"0.57296824",
"0.57296824",
"0.57296824",
"0.572731",
"0.5715356",
"0.571046",
"0.57069975",
"0.5706646",
"0.570625",
"0.57025856",
"0.5702446",
"0.5699844",
"0.56980747",
"0.56971323"
] | 0.75258464 | 0 |
Specify input file options | def options(hash)
@options.merge! hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_std_file_opt(inkey)\n @oparse.on(\"-f\", \"--file FILENAME\", \"Input from FILENAME\") do |f|\n @opts[inkey] = do_file_read(f)\n end\n return @oparse\n end",
"def file_options; end",
"def file_read_opts; end",
"def file_read_opts(context); end",
"def file_read_opts=(_arg0); end",
"def initialize(input_file_name, include_path)\n @input_file_name = input_file_name\n @include_path = include_path\n @options = nil\n end",
"def generate_options filename, code\r\n args = ['-f', 'j', filename]\r\n base_options = RuboCop::Options.new\r\n options, paths = base_options.parse(args)\r\n options[:stdin] = code\r\n [options, paths]\r\n end",
"def file_input(method, options)\n basic_input_helper(:file_field, :file, method, options)\n end",
"def file_input(method, options)\n basic_input_helper(:file_field, :file, method, options)\n end",
"def input\n option[:ifile] == '-' ? $stdin.read.force_encoding('ascii-8bit') : File.binread(option[:ifile])\n end",
"def validate_opts\n validate_opts_file if options[:file]\n end",
"def file_mode\n\t\tinput_file = File.open(input_path, 'r')\n\t\t\n\t\tinput_file.each_line do |line|\n\t\t\t@input = line\n\t\t\tparse_user_input\n\t\tend\n\tend",
"def add_input_format_options(opt)\n opt.on('--format=X', [:csv, :json, :yaml, :ruby],\n \"Import dataset from (csv, json, yaml, ruby)\") do |value|\n self.format = value\n end\n opt.on(\"--csv\", \"Import dataset from csv (default)\"){ self.format = :csv }\n opt.on(\"--json\", \"Import dataset from json\"){ self.format = :json }\n opt.on(\"--ruby\", \"Import dataset from ruby code\"){ self.format = :ruby }\n opt.on(\"--yaml\", \"Import dataset from yaml\"){ self.format = :yaml }\n end",
"def set_va_file(opts)\n opts = check_params(opts,[:va_files])\n super(opts)\n end",
"def generate_options(filename, code); end",
"def generate_options(filename, code); end",
"def load(*args)\n\n # OPTIONS\n # OPTS = {}\n # op = OptionParser.new do |x|\n # x.banner = 'cat <options> <file>' \n # x.separator ''\n\n # x.on(\"-A\", \"--show-all\", \"Equivalent to -vET\") \n # { OPTS[:showall] = true } \n\n # x.on(\"-b\", \"--number-nonblank\", \"number nonempty output lines\") \n # { OPTS[:number_nonblank] = true } \n\n # x.on(\"-x\", \"--start-from NUM\", Integer, \"Start numbering from NUM\") \n # { |n| OPTS[:start_num] = n }\n\n # x.on(\"-h\", \"--help\", \"Show this message\") \n # { puts op; exit }\n # end\n # op.parse!(ARGV)\n\n # Load Source File\n @output_file = ARGV[-1]\n @input_file = ARGV[-2] ? ARGV[-2] : ARGV[-1]\n source_file = File::read(@input_file) if File::exists?(@input_file) && File::readable?(@input_file)\n return [source_file, '']\n end",
"def initialize(options)\n options.each { |k, v| self.send :\"#{k}=\", v }\n self.file = File.expand_path file\n end",
"def run(filename, options) end",
"def initialize(file, options={})\n @file = file\n\n @mode = options[:mode]\n @applique = options[:applique]\n end",
"def initialize filename, options = {}\n @files = []\n @options = CommandLineOptions.new.merge options\n @filename = filename\n end",
"def options(path, **args); end",
"def validate_opts\n if @options[:file].nil?\n puts \"Pass me some filename (-f FILE)\"\n return false\n elsif !File.exists?(@options[:file])\n puts \"File: #{@options[:file]} does not exist\"\n return false\n elsif !File.readable?(@options[:file])\n puts \"File: #{@options[:file]} is not readable\"\n return false\n elsif File.directory?(@options[:file])\n puts \"#{@options[:file]} is a directory!\"\n return false\n elsif File.zero?(@options[:file])\n puts \"File: #{@options[:file]} is empty\"\n return false\n end\n\n if @options[:mode].nil?\n puts \"Pass me indexing mode (-m index|noindex )\"\n return false\n end\n return true\n end",
"def options() end",
"def file(name, options={})\n param(:file, name, options)\n end",
"def options(opt); end",
"def options(opt); end",
"def parse_file_argument(key)\n if @opts[key].nil? and [email protected]\n @opts[key] = do_file_read(f)\n end\n end",
"def initialize(file)\n @file = file\n @options = {}\n @original_options = {}\n read\n end",
"def process_options\n \n end",
"def process_options\n \n end",
"def process_options\n \n end",
"def parse_options\n @opts = Slop.parse do |o| \n o.string '-f1', '--file1', 'First source file'\n o.string '-f2', '--file2', 'Second source file'\n o.on '-v', '--version' do\n puts Slop::VERSION\n end\n end\n rescue Exception => e\n raise\n end",
"def initialize(name, file, opt={:type => :auto, :escape_char => '\\\\'})\n super(name)\n @file = file\n @delim = case opt[:type]\n when :auto then raise \"File-type auto-detection is not yet supported\"\n when :csv then ','\n when :tsv then \"\\t\"\n else opt[:delim]\n end\n @opt = opt\n end",
"def setup_options\n @parser.banner = BANNER\n\n @parser.on('-V', '--version', 'display version and exit') { show_version }\n @parser.on('-h', '--help', 'display help and exit') { show_help }\n @parser.on('-f', '--files=[file1.txt file2.txt ...]', Array, 'text files to read') { |o| @options.files = o }\n @parser.on('-n', '--number=NUM', Integer, 'number of results to show [default = 100]') do |n|\n @options.number = n\n end\n @parser.on('-v', '--verbose', 'verbose output') { @options.verbose = true }\n end",
"def file_handler_opts; end",
"def required_options\n %i[input output]\n end",
"def required_options\n %i[input output]\n end",
"def edit_file(filename, content, options={})\n end",
"def input_files_pattern\n @args.options[:input_files_pattern]\n end",
"def set_check_file(opts)\n opts = check_params(opts,[:file_info])\n super(opts)\n end",
"def parse_input (input_file)\nend",
"def initialize(input_file)\n\t\tsuper(input_file)\n\t\t\n\tend",
"def initialize(options = {})\n opts = { file: nil, temp: nil, line: 1, blocking: true }.merge(options)\n if !opts_is_valid?opts\n fail ArgumentError, 'define file OR temp'\n elsif opts[:file]\n edit_file(opts)\n elsif opts[:temp]\n edit_temp(opts)\n end\n end",
"def initialize(io, options = {})\n @io = io\n @format = options[:format] || FILE_FORMATS.first\n \n raise ArgumentError, \"Invalid format option provided #{options[:format]}\" unless FILE_FORMATS.include?(format)\n end",
"def process_arguments\n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE') {|f|@options.file = File.expand_path(f)}\n opts.on('-o','--output FILE'){|f|@options.output = File.expand_path(f)}\n end\n \n opts_parse.parse!(@arguments) rescue return false\n \n return true\n end",
"def parse_input(input_file); end",
"def parse_input(input_file); end",
"def process_options\n \n end",
"def postprocess_user_choices\n if @user_choices[:files][0] and @user_choices[:files][0] != Pathname('-')\n @user_choices[:input] = @user_choices[:files][0].open('r')\n else\n @user_choices[:input] = STDIN\n end\n \n if @user_choices[:files][1] and @user_choices[:files][1] != Pathname('-')\n @user_choices[:output] = @user_choices[:files][1].open('w')\n else\n @user_choices[:output] = STDOUT\n end\n end",
"def input_file(label, name, args = {})\n id = args[:id] ? args[:id] : id_for(name)\n args = args.merge(:type => :file, :name => name, :id => id)\n\n @g.p do\n label_for(id, label, name)\n @g.input(args)\n end\n end",
"def read_options_from_file\n Shellwords.shellwords File.read(\".rspec_n\").to_s.gsub(/\\n|\\r\\n/, \" \")\n end",
"def yardopts(file = T.unsafe(nil)); end",
"def process_arguments\n @args << \"-h\" if(@args.length < 1)\n \n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE','use the following local file') {|file| @options.file = File.expand_path(file)}\n opts.on('-p','--parse PARSE',\"sets which set of sider files to download #{@@sections.join(\"|\")}\") {|parse| @options.parse = parse}\n opts.on('-d','--download','download the file to be parsed') {@options.download = true}\n opts.on('-o','--output DIR','set the output directory') {|directory| @options.output = File.expand_path(directory)}\n opts.on('-h','--help',\"prints the help\"){puts opts; exit!}\n end\n \n opts_parse.parse!(@args) rescue raise \"There was an error processing command line arguments use -h to see help\"\n end",
"def get_file_data(options={})\n options={ file_type: :testflow \n }.merge(options)\n fp = FileParser.new\n fp.open(filename: @filename)\n if options[:file_type] == :testflow\n @testflow_lines = fp.readlines\n elsif options[:file_type] == :limits\n @limits_lines = fp.readlines\n else\n fail \"Invalid type '#{options[:type]}' passed to 'get_file_data'!\"\n end\n fp.close()\nend",
"def input_files\n @input_files ||= to_file(@args.input)\n end",
"def valid_options\n [:tempfile_base]\n end",
"def input_params\n params.require(:input).permit(:input_file)\n end",
"def process_options\n \n if @options.attach or @options.detach\n @options.files = @arguments\n end\n \n end",
"def handle_arguments(args)\n if input_file.nil?\n print_usage\n true\n else\n args.help || args.version\n end\n end",
"def file_read_opts(context)\n context.registers[:site].file_read_opts\n end",
"def initialize(*args)\n @input_files = nil\n @input_string = nil\n if args[0].is_a?(String)\n @input_string = args.shift\n elsif args[0].is_a?(Array)\n @input_files = args.shift.join(' ')\n end\n @options = args || []\n @option_string = nil\n @binary_output = false\n @writer = 'html'\n end",
"def initialize(input_file)\n @input_file = input_file\n @source = File.new(input_file)\n end",
"def process_arguments\n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE') {|f|@options.file = File.expand_path(f)}\n opts.on('-o','--output FILE'){|f|@options.output = File.expand_path(f)}\n end\n \n opts_parse.parse!(@arguments) rescue return false\n \n return true\n end",
"def process_arguments\n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE') {|f|@options.file = File.expand_path(f)}\n opts.on('-o','--output FILE'){|f|@options.output = File.expand_path(f)}\n end\n \n opts_parse.parse!(@arguments) rescue return false\n \n return true\n end",
"def process_arguments\n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE') {|f|@options.file = File.expand_path(f)}\n opts.on('-o','--output FILE'){|f|@options.output = File.expand_path(f)}\n end\n \n opts_parse.parse!(@arguments) rescue return false\n \n return true\n end",
"def options(opt)\n end",
"def set_options(options, args)\n set = false\n options.each do |x,y|\n if x == args[1]\n if y[\"file\"] == \"no\"\n y[\"value\"] = args[2]\n set = true\n elsif y[\"file\"] == \"yes\" and test_file(args[2])\n y[\"value\"] = args[2]\n y[\"is_file\"] = \"yes\"\n set = true\n elsif y[\"file\"] == \"maybe\"\n if not test_file(args[2])\n puts \"!! if the argument provided is a path, the file doesn't exist !!\"\n else\n y[\"is_file\"] = \"yes\"\n end\n y[\"value\"] = args[2]\n set = true\n end\n end\n end\n if not set \n puts \"Wrong option or the file specified doesn't exist \"\n end\n return options\nend",
"def read_argv_flags argsIn\r\n skipVal = argsIn.length + 1\r\n argsIn.each_with_index do |argIn, ind|\r\n next if skipVal == ind\r\n arg = argIn.downcase()\r\n if arg[0].eql? '-'\r\n symAgr = strip_to_sym(arg)\r\n if @options[symAgr].is_a? String\r\n @options[symAgr] = argsIn[ind + 1]\r\n skipVal = ind + 1\r\n elsif @options[symAgr] == false\r\n @options[symAgr] = true\r\n elsif @options[symAgr].is_a? Array\r\n @options[symAgr] = argsIn[ind + 1]\r\n end\r\n elsif known_file_type arg\r\n @options[:f] << argIn.gsub(/(\\.\\/)|(\\.\\\\)/,'')\r\n end\r\n puts argIn\r\n end\r\n end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end"
] | [
"0.74768263",
"0.73147166",
"0.68818724",
"0.6788118",
"0.66807646",
"0.64102745",
"0.63863736",
"0.6381875",
"0.6369093",
"0.627762",
"0.6258423",
"0.62216496",
"0.6189287",
"0.6173023",
"0.6159322",
"0.6159322",
"0.613186",
"0.6120181",
"0.6097292",
"0.6081564",
"0.60713184",
"0.6063903",
"0.6057921",
"0.6054346",
"0.60177785",
"0.59715027",
"0.59709924",
"0.59501505",
"0.59420526",
"0.59382915",
"0.59382915",
"0.59382915",
"0.592022",
"0.59144664",
"0.5909433",
"0.59076405",
"0.59006083",
"0.59006083",
"0.58904064",
"0.5885038",
"0.58842534",
"0.58730334",
"0.5868029",
"0.58668905",
"0.58618563",
"0.5859402",
"0.5856873",
"0.5856873",
"0.58358234",
"0.5817262",
"0.5817243",
"0.57997537",
"0.5777558",
"0.5739066",
"0.57225233",
"0.57097834",
"0.5706668",
"0.57059324",
"0.5700984",
"0.56922",
"0.5679376",
"0.567077",
"0.5667065",
"0.5662168",
"0.5662168",
"0.5662168",
"0.56565076",
"0.5649162",
"0.5638551",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372",
"0.563372"
] | 0.0 | -1 |
sending the Mail for Staff after creating and after enable process | def send_p
pwreset_key_success = false
until pwreset_key_success
self.password_reset_key = self.class.make_key
self.save
pwreset_key_success = self.errors.on(:password_reset_key).nil? ? true : false
end
send_pwd
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_activation\n @user = Student.first\n @user.create_email_activation\n @email = '[email protected]'\n @option = 'student'\n UserMailer.email_activation @user, @email, @option\n end",
"def new_user_waiting_for_approval(faculty)\n @faculty = faculty\n\n mail(to: '[email protected]', subject: 'A new faculty member is awaiting approval!', body: 'A new faculty member is awaiting your approval!')\n end",
"def send_admin_mail\n AdministratorMailer.new_user_waiting_for_approval(self).deliver_now\n end",
"def send_mail_to_attendees_on_create\n if self.category.eql?(\"appointment\") and !self.attendees_emails.blank?\n user = self.matter_people.assignee\n att_arr = self.attendees_emails.split(\",\")\n for i in att_arr\n send_notificaton_to_attendees(user, self, i)\n end\n\n true\n end\n end",
"def create\n @staff_member = User.new(admin_staff_member_params)\n @staff_member.role = User.roles[:staff]\n temp_password = SecureRandom.hex(8)\n @staff_member.password = temp_password\n @staff_member.temp_password = temp_password\n\n if @staff_member.save\n SendWelcomeStaffMailJob.perform_later(@staff_member.id)\n redirect_to admin_staffs_path\n else\n render :new\n end\n end",
"def send_activation_email\n @admin = BusinessAdmin.find(params[:id])\n if @admin.active\n flash_error \"flash.error.admin.send_activation_mail_active\" \n else \n UserMailer.admin_activation_email(@admin).deliver\n flash_success \"flash.success.admin.send_activation_mail\",{}, {:email=>@admin.email} \n end\n \n end",
"def submit(ms)\n @name = ms.user.first_name + ' ' + ms.user.last_name\n @link = 'http://' + dashboard_path(ms.id)\n \n ms.user.department.users.select do |u|\n if u.has_role? :dept_chief\n\t mail to: u.email, subject: 'Pontaj trimis spre aprobare'\n end\n end\n end",
"def send_mail\n User.send_welcome_email(self.id)\n end",
"def admin_account_activation(member)\r\n @member = member\r\n mail(to: member.user_name, subject: \"Admin Account Activation\") \r\n end",
"def notify(doctor ,recipient, subject, text)\n subject += \" sent to: #{recipient}, by: #{doctor.full_name}\" \n\t\tadmin_assists = AdminAssistant.all \n if admin_assists\n admin_assists.each do |adm|\n custom_email(adm, subject, text)\n end\n end\n end",
"def schedule_appointment(appointment, which)\n # sendgrid_category \"Sell Request\"\n @appointment = appointment\n if which == 1\n mail to: @appointment.user.email, subject: \"Appointment schedule confirmation\"\n else\n email = \"[email protected]\" if [email protected]\n mail to: email, subject: \"Appointment schedule confirmation\"\n end\n end",
"def activation\n StudentMailer.activation\n end",
"def send_mail_to_associates\n unless self.matter_people.blank?\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end\n end",
"def mail_sent_to_admin(user)\n subject \"4D Techlab - New user\"\n from \"4d Techlab Notifier <[email protected]>\"\n headers \"Reply-to\" => \"[email protected]\"\n recipients '[email protected]'\n sent_on Time.now\n #content_type = \"text/plain\"\n body :user_url => user_url(user)\n end",
"def participant_admins(participant,school)\n @participant = participant\n @school = school\n admin_user_ids = Participant.where(\"school_id = ? and role_id < ?\",@school.id,3).all.map(&:user_id)\n schooladmins = User.where(id: admin_user_ids).all.map(&:email)\n @applicant = User.find(@participant.user_id)\n applicant_email = \"#{@applicant.fullname} <#{@applicant.email}>\"\n\n mail to: schooladmins,\n from: applicant_email,\n reply_to: applicant_email,\n subject: @applicant.fullname + \" has registered to \" + @school.name + \" and is waiting for acceptance.\"\n end",
"def fingering_submitted_email(fingering, admin)\n @fingering = fingering\n mail(:to => admin.email, :subject => \"Fingering Submitted for Approval\", :from => '[email protected]') \n end",
"def send_mail_to_associates\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end",
"def send_admin_email\n AdminMailer.new_user_waiting_for_approval.deliver\n end",
"def add_mail\n user = User.find(2)\n admin = User.find_by(admin: true)\n UserMailer.add_mail(user, admin)\n end",
"def send_welcome_email\n #if Rails.env.production?\n if email.present?\n if followed_by >= 0\n # to send emails in delayed jobs use\n # UserMailer.instauser_welcome_email(id).delay.deliver!\n UserMailer.instauser_welcome_email(self.id).deliver\n else\n UserMailer.instauser_reject_email(self.id).deliver!\n end\n end\n #end\n end",
"def activation_success_email(user)\n # TODO: Implement actual functionality -- Wed Jun 13 15:26:53 2012\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def admin_create_user_email(user)\n @user = user\n mail :to => \"#{user.name} <#{user.email}>\", :subject => \"An Account Has Been Created For You\"\n end",
"def response(attendee_id)\n @attendee = WorkshopAttendee.find(attendee_id)\n mail(to: @attendee.email, subject: @attendee.first_name + \", you are now registered with our workshop sessions.\")\n end",
"def update_schedule\n role_id = current_user.role_id\n schedule = Schedule.get_schedule_array\n create_schedule = Schedule.get_create_schedule_array\n delete_schedule = Schedule.get_delete_schedule_array\n if Schedule.send_email(role_id,schedule,create_schedule,delete_schedule)\n flash[:success] = \"Users Notified!\"\n redirect_to root_path\n else\n flash[:error] = \"Some error occured! Please try again!\"\n redirect_to (:back)\n end\n end",
"def approve\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def new_schedule_notification(schedule)\n @schedule = schedule\n mail to: schedule.person.email, subject: \"Your new schedule : #{schedule.service.name} - #{schedule.role.name}\"\n end",
"def send_email_to_master\n\n\tend",
"def send_account_notification\n @user = User.find_by_id(params[:id]) \n begin \n url = \"http://www.uncharted.net/account/activation/#{@user.activation_code}\" \n Emailer.deliver_admin_accountactivation(@user.email,url)\t\n end\n flash[:notice] = \"Email has been sent to #{@user.email} to active his account.\"\n redirect_to :action => 'index'\n end",
"def existing_user_delegated_email(user)\n @user = user\n @url = building_operator_url(@user)\n mail_to @user, subject: 'You have been assigned new building tasks'\n end",
"def approval_needed(user)\n @user = user\n\n mail to: ENV['ADMIN_EMAIL'], subject: \"User wants approval for Thumbline Set List\"\n end",
"def send_activation_or_reset_mail\n end",
"def send_back_office_updates(to,member_type,from, newsletter_subject,audit_id ,user_id)\n audit = Audit.find(audit_id)\n object = audit.auditable_type.classify.constantize.find(audit.auditable_id) rescue nil\n recipients to\n from from\n\t\tsubject newsletter_subject\n\t\tbody :audit =>audit, \n\t\t :object => object ,\n\t\t :user =>User.find(user_id),\n\t\t :site => self.site_name,\n\t\t :member_type => member_type,\n\t\t :email => to,\n\t\t :url => self.daurl\n sent_on Time.now\n content_type \"text/html\"\n end",
"def perform\n @newsletter = create_newsletter\n send_emails\n end",
"def send_activation_email\n DoctorMailer.account_activation(self).deliver_now\n end",
"def send_activation_notification\n deliver_activation_email(:activation, :subject => (MaSA[:welcome_subject] || \"Welcome\" ))\n end",
"def send_email\n AlertNotifier.delay.email_back_office_announcement(self)\n end",
"def send_signup_notification\n deliver_activation_email(:signup, :subject => (MaSA[:activation_subject] || \"Please Activate Your Account\") )\n end",
"def account_activation(member) \r\n @member = member \r\n mail(to: member.user_name, subject: \"Account Activation\") \r\n end",
"def activation\n @greeting = \"Hi\"\n\n mail :to => \"[email protected]\"\n end",
"def sendmail\n puts \"send mail \"\n puts @manifest.code \n\n @company = @manifest.company\n\n ActionCorreo.st_email(@manifest).deliver_now \n end",
"def after_registration(user)\n @user = user\n mail(:to => user.email, \n :bcc => [\"[email protected]\",\"[email protected]\", \"[email protected]\"],\n :subject => \"Willkommen auf StartWork!\") \n end",
"def register_admin(org_id, user_id)\n # @greeting = \"Hi\"\n @organisation = Organisation.find(org_id)\n @user = User.find(user_id)\n mail(to: @organisation.contact_email, subject: 'An new organisation host in MOBEEAS is added, waiting for your approval.')\n end",
"def created(user)\n @user=user\n\n\n mail to: \"[email protected]\"\n end",
"def send_signup_email(user)\n @user = user\n @appointment = Appointment.where(id: @user.appointment_id).first\n mail(\n :to => @user.email,\n :bcc => \"[email protected]\",\n :subject => \"Ace CPR SD Sign-Up Confirmation ##{@user.id}\"\n )\n end",
"def employee_signup_email(employee)\n @employee = employee\n mail( :to => @employee.email,\n :subject => 'Thanks for signing up for Shiift' )\n end",
"def perform(to,from,data,isuser)\n \tif isuser\n \tScratchMailer.send_scratch(to,from,data).deliver\n else\n \tScratchMailer.new_user(to,from,data).deliver\n end\n end",
"def activate_user\n self.save\n self.send_user_notification_email\n end",
"def mailer; end",
"def send_invite\n\n Email::HookCreator::SendTransactionalMail.new(\n client_id: Client::OST_KYC_CLIENT_IDENTIFIER,\n email: @invite_admin_obj.email,\n template_name: GlobalConstant::PepoCampaigns.admin_invite_template,\n template_vars: {\n inviter_name: @admin.name,\n invitee_name: @invite_admin_obj.name,\n company_name: @client.name,\n invite_token: @invite_token\n\n }\n ).perform\n\n end",
"def app_conformation\n @greeting =\"hi\"\n mail to: \"[email protected]\" , subject: \"requesting appointment\"\n end",
"def send_admin_mail\n admins = Admin.all\n\n admins.each do |admin|\n if admin.reminder\n AdminMailer.new_user_waiting_for_approval(admin.email).deliver_now\n end\n end\n end",
"def activation_needed_email(user)\n # TODO: Implement actual functionality -- Wed Jun 13 15:26:53 2012\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def setup_email(user)\n recipients user.email\n from self.contact_email\n sent_on Time.now\n end",
"def create\n @user = current_user;\n @forgotmail = Forgotmail.new(forgotmail_params)\n \n Usermailer.welcome_email(@user, @forgotmail.sender, @forgotmail.reciever, @forgotmail.title, @forgotmail.content).deliver_now\n\n respond_to do |format|\n if @forgotmail.save\n format.html { redirect_to @forgotmail, notice: 'Forgotmail was successfully created.' }\n format.json { render :show, status: :created, location: @forgotmail }\n else\n format.html { render :new }\n format.json { render json: @forgotmail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_request(user)\n @user = user\n mail(:to => ADMIN_MAIL, :subject => 'New User Registered')\n end",
"def new_message_sent_advisee(user)\n @user = user\n mail to: @user.email, subject: \"New message sent to Advisor\"\n end",
"def send_welcome_email(user)\n mail to: user.email, subject: \"Sign Up Confirmation - Welcome to NetworkMill\"\n Email.create(:user_id => user.id, :sent_to => user.email, :title => \"welcome_email\")\n end",
"def confirm_delegation(delegation)\n \t@delegation = delegation\n\n mail(from: @delegation.employee.email, to: @delegation.manager.email, subject: 'Passiton - Delegation confirmed') do |format|\n format.html { render layout: 'email_simple.html.erb' }\n format.text\n \tend\n end",
"def notification_mail(reports, staff)\n @reports = reports\n @reports_keys = reports.keys\n \n @first_name = staff.first_name\n @last_name = staff.last_name\t\n\t\n\t# This is an AF kludge...need to revisit\n\tsubject = reports.size > 1 ? \"Radar Digest\" : \"Radar #{reports.first[1][0].display_name} #{reports.first[1][0].tag} (#{reports.first[1][0].staff.name})\"\n \n mail(:to => staff.email, :subject => \"#{subject}: \" + Time.now.to_s(:my_time)) \n end",
"def funded_email_to_creator\n Pony.mail(:to => self.email, :from => '[email protected]', :subject => 'the gift you created is now funded!', :body => 'yay! some people owe you money.')\n end",
"def booking_confirmed\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_admin_activation_email\n MemberMailer.admin_account_activation(self).deliver_now\n end",
"def notify_admin_about_newbie(user)\n @user = user\n mail \n end",
"def mail; end",
"def send_signup_email(admin)\n @admin = admin\n mail( :to => @admin.email,:subject => 'Thanks for signing up ,you are welcome' )\n end",
"def activation_success_email\n UserMailerMailer.activation_success_email\n end",
"def create\n @task = Task.new(params[:task])\n @task.staff_from_id = current_staff.id\n @task.state = \"3new\"\n if @task.sdate.nil? || params[:task][:sdate].empty?\n @task.sdate = Time.now.getlocal unless @task.period.nil? || @task.period.empty? \n end\n\n respond_to do |format|\n if @task.save\n task_delegate = TaskDelegate.new\n task_delegate.staff_from = current_staff.id\n task_delegate.staff_to = params[:task][\"staff_id\"]\n task_delegate.task_id = @task.id\n task_delegate.when_date = Time.now.getlocal\n if task_delegate.save\n Mailer.task_notification(Staff.find(params[:task][\"staff_id\"]),Staff.find(current_staff.id),@task).deliver\n sms_state = send_sms(@task)\n format.html { redirect_to @task, notice: \"Task was successfully created.<br>SMS status=#{sms_state}\".html_safe }\n format.json { render json: @task, status: :created, location: @task }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n else\n format.html { render action: \"new\" }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_welcome_email(sf_record_id)\n if contact = Contact.find(sf_record_id)\n # only send if (a) the welcome email hasn't been sent and (b) the contact has an associated self service user and that user is active\n if !contact.welcome_email_sent? and (self_service = SelfServiceUser.find_by_contact_id(sf_record_id) and self_service.is_active)\n SfcontactMailer.deliver_welcome(self,contact,self_service.email)\n contact.update_attribute('welcome_email_sent_at__c',Time.now)\n logger.info(\"Updating contact with id: #{contact.id}\")\n logger.info(\"Contact Email Sent Time Updated: #{contact.welcome_email_sent_at__c}\")\n else\n logger.info(\"Welcome email already sent to contact: #{self.email}\")\n end\n else\n logger.info(\"Couldn't find associated contact: #{self.email}\")\n end\n end",
"def setup_admin_email(official)\n @recipients = Array.new\n @recipients << 'Jeremy Driscoll <[email protected]>'\n do_not_deliver! if @recipients.empty?\n @from = AppConfig.admin_email\n @subject = \"[Q2016] \"\n @sent_on = Time.now\n @body[:official] = official\n end",
"def admin_alert(data, subject)\n #@claim_url = \"http://www.cleanjay.ca/claim-booking/#{job.profile.claim_id}\"\n @data = data\n sub = \"[Admin Alert] \" + subject.to_s\n\n mail(:to => \"[email protected]\", subject: sub)\n end",
"def tutor_reserved_notification\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_email(user)\n\t UserMailer.activate_email(user).deliver\n\tend",
"def send_mail\n Email::HookCreator::SendTransactionalMail.new(\n receiver_entity_id: @manager_id,\n receiver_entity_kind: GlobalConstant::EmailServiceApiCallHook.manager_receiver_entity_kind,\n template_name: GlobalConstant::PepoCampaigns.platform_secure_data_access_template,\n template_vars: {\n secure_data_access_token: CGI.escape(@secure_data_access_token),\n company_web_domain: CGI.escape(GlobalConstant::CompanyWeb.domain)\n }\n ).perform\n\n success\n end",
"def notify\n ActionMailer::Base.mail(:from => \"[email protected]\", :to => \"[email protected]\", :cc => \"[email protected]\", :subject => \"DIL Upload permission request - \" + current_user.uid, :body => \"User \"+ current_user.uid + \" has requested to be added to the uploaders list. Is this approved?\\n\\n Their email address is: \" + current_user.email + \"\\n\\nThis email was generated by DIL.\").deliver\n flash[:notice] = \"Your inquiry has been submitted. Please come back and check later, you will be notified within a day as well.\"\n redirect_to \"/uploads\"\n end",
"def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end",
"def create\n @spoofer = Spoofer.new(params[:spoofer])\n\n respond_to do |format|\n if @spoofer.save\n msg = ''\n msg+= \"Subject: \" + @spoofer.subject+\"\\n\"\n msg += \"From: \"[email protected]+\"\\n\"\n msg += @spoofer.message\n\tsmtp = Net::SMTP.new 'smtp.elasticemail.com',2525\nsmtp.start(\"[email protected]\",\"[email protected]\",\"e8b741aa-45ff-4cda-9060-d623153d2610\",:login) do\n\tsmtp.send_message(msg,@spoofer.from,@spoofer.to)\n\tend\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully created.' }\n format.json { render json: @spoofer, status: :created, location: @spoofer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def appointment\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def send_active_needs_approval_email\n Users::SendNeedsApprovalEmailJob.perform_later(user_id: self.id, active: true)\n end",
"def send_mail!(approval_status)\n #\n approval_status_str = status_enum.invert[approval_status]\n\n # Get request and user\n request = self.approvable\n user = request.user\n\n # cc all users in our current approval order\n cc_users = self.contacts.map{|ude|ude.email}\n\n # Add in previous contacts if we were rejected\n if approval_status == status_enum['rejected']\n cc_users += previous_contacts.map{|ude|ude.email}\n end\n # set subject header\n mail_opts = {\n :to=>user.email,\n :subject => \"#{request.class.model_name.human} for #{user.name} has been #{approval_status_str}\",\n :cc=>cc_users.uniq\n }\n\n UserMailer.send(\"#{approvable.class.name.underscore}_email\", self, mail_opts).deliver\n return true\n end",
"def new_message(obj)\n @obj = obj\n @admin_recipients = User.role_users(:admin).map(&:email)\n @author_recipients = User.role_users(:author).map(&:email)\n @recipients = @admin_recipients\n emails = @recipients.join(\",\")\n m = [\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\",\"[email protected]\"].join(\",\")\n mail to: m\n end",
"def show_reminder\n mail to: @guest.email, subject: \"Reminder: \"[email protected]+\" house show\"\n end",
"def participant_acceptance(participant,school)\n @participant = participant\n @school = school\n admin_user_ids = Participant.where(\"school_id = ? and role_id < ?\",@school.id,3).all.map(&:user_id)\n schooladmins = User.where(id: admin_user_ids).all.map(&:email)\n @applicant = User.find(@participant.user_id)\n applicant_email = \"#{@applicant.fullname} <#{@applicant.email}>\"\n \n mail to: applicant_email,\n reply_to: schooladmins,\n subject: \"Congratulations! You have been accepted to\" + @school.name + \" !\"\n end",
"def new_apply_email(feedback_params)\n @firstname = feedback_params[:firstname]\n @lastname = feedback_params[:lastname]\n @telephone = feedback_params[:telephone]\n @email = feedback_params[:email]\n @address = feedback_params[:address]\n @landlord = feedback_params[:landlord]\n @landlordnum = feedback_params[:landlordnum]\n @employer = feedback_params[:employer]\n @employername = feedback_params[:employername]\n @employernum = feedback_params[:employernum]\n @income = feedback_params[:income]\n # Initialize the message here\n # mail(to: [\"[email protected]\",\"[email protected]\", \"[email protected]\", \"[email protected]\", \"[email protected]\", \"[email protected]\"], subject: 'There is a new institution registration pending')\n mail(to: [\"*Some Email*\", \"*Some Email*\"], subject: 'Akridge LLC: A new applicant has applied')\n end",
"def send_mail_to_admin\n \tNotification.send_mail_to_admin(self).deliver!\n end",
"def account_activation(user)\n @user=user\n\n mail :to => @user.email, :from => \"[email protected]\", :subject => \"Account activation\"\n end",
"def assigned\n @greeting = \"Hi\"\n\n mail to: \"[email protected]\"\n end",
"def create\n @app_schedule = AppSchedule.new(app_schedule_params)\n @app_schedule.user_id = current_user.id\n# \n\n\n respond_to do |format|\n if @app_schedule.save\n format.html { redirect_to @app_schedule, notice: 'Appointment was successfully scheduled. Please check your email for confirmation and further details!' }\n format.json { render :show, status: :created, location: @app_schedule }\n @app_schedule.app_time.update_attribute(:booked, true)\n #method from AppointmentMailer that is supposed to prepare mail to be sent\n AppointmentMailer.with(app_schedule: @app_schedule).notify_appointment.deliver!\n AppointmentMailer.with(app_schedule: @app_schedule, user: current_user).appointment_scheduled.deliver!\n #AppointmentMailer.with(app_schedule: @app_schedule, user: current_user).appointment_scheduled.deliver!\n \n\n else\n format.html { render :new }\n format.json { render json: @app_schedule.errors, status: :unprocessable_entity }\n end\n end\n end",
"def alteration_email(user, trip)\n @trip=Trip.find_by(:id => trip)\n @user = User.find_by(:id => user)\n @fbo= Fbo.find_by(:id => @trip.fbo_id)\n @airport = Airport.find_by(:id => @fbo.airport_id)\n @url = 'http://chartair.us/trips'\n mail(to: @user.email, subject: 'Trip Alteration')\n end",
"def admin_trip_booked(user)\n @user=user\n @url=\"www.chartair.us/admin_main\"\n mail(to: '[email protected]', subject: 'A User has Booked a Trip')\n end",
"def send_ta_notification(user)\n\t\t@user = user\n\t\tmail( :to => @user.email, :subject => 'You have just been assigned to a course!')\n\tend",
"def send_activation_email\n\t\tUserMailer.account_activation(self).deliver_now\n\tend",
"def email(defn, participant, assignment)\n defn[:body][:type] = \"Teammate Review\"\n participant = AssignmentParticipant.find(reviewee_id)\n topic_id = SignedUpTeam.topic_id(participant.parent_id, participant.user_id)\n defn[:body][:obj_name] = assignment.name\n user = User.find(participant.user_id)\n defn[:body][:first_name] = user.fullname\n defn[:to] = user.email\n Mailer.sync_message(defn).deliver\n end",
"def send_emails\n # p \"job_exists?: #{job_exists?}\"\n return if job_exists?\n\n AbsenceJob.set(wait_until: email_wait_time)\n .perform_later(semester_id, date.to_s)\n\n # return unless absent? && date == Date.today\n #\n # # always send email to student\n # email_student\n #\n # # if the absence was consecutive?\n # if consecutive?\n # email_director\n # else\n # email_teacher_assistant\n # end\n end",
"def create_admin_participation\n participation = Participation.create event: self\n ParticipationMailer.participation(participation).deliver\n end",
"def andrew_account_created_notification(person, options={})\n @person = person\n mail(:to=>[@person.personal_email],\n :subject=>options[:subject] || \"Andrew account information (\"[email protected]+\")\",\n :date=>Time.now)\n end",
"def invite_for_booking_process\n UserMailer.invite_for_booking_process(Booking.last)\n end",
"def notify\n return if @user.email.blank?\n\n Notifier.user_event_analisys(@user, @user.events.future.analisys.first).deliver_now if @user.events.future.analisys.present?\n Notifier.user_event_visit(@user, @user.events.future.visits.first).deliver_now if @user.events.future.visits.present?\n end",
"def send_email\n true\n end",
"def user_created(user)\n @user = user\n user_email_id = user.email\n mail to: \"#{user_email_id}\",subject: \"Account Has been created #{user.firstname + \" \" + user.lastname}\"\n end",
"def in_process\n to = params[:patron_email] + ', ' + params[:staff_email]\n from = \"Request Services <#{params[:staff_email]}>\"\n title = params[:bib_record].title\n subject = \"On Order / In Process Request [#{title}]\"\n mail(to: to, from: from, subject: subject)\n end"
] | [
"0.7046527",
"0.6858299",
"0.680331",
"0.6701324",
"0.66089714",
"0.65614575",
"0.6526693",
"0.6479002",
"0.64678794",
"0.646258",
"0.6459198",
"0.64535713",
"0.6446289",
"0.6419522",
"0.64179647",
"0.6412921",
"0.6410535",
"0.6403179",
"0.63811415",
"0.6365386",
"0.63629687",
"0.6352097",
"0.6350194",
"0.63431853",
"0.6333175",
"0.63328993",
"0.6326171",
"0.6322935",
"0.6319095",
"0.6308734",
"0.6308365",
"0.62919146",
"0.62849486",
"0.6276379",
"0.6271353",
"0.62710565",
"0.62669885",
"0.62663054",
"0.6263298",
"0.6262018",
"0.625435",
"0.62520057",
"0.624363",
"0.62407523",
"0.62384593",
"0.62348855",
"0.62340933",
"0.6221873",
"0.6218773",
"0.6214657",
"0.6206403",
"0.6202793",
"0.6198934",
"0.61953026",
"0.6193347",
"0.61801565",
"0.61801124",
"0.6179763",
"0.6179129",
"0.6178964",
"0.6174526",
"0.61743027",
"0.6172513",
"0.61569846",
"0.6154706",
"0.6153291",
"0.61438686",
"0.6139185",
"0.6138123",
"0.61376834",
"0.6132776",
"0.6132273",
"0.6122945",
"0.6119717",
"0.6115434",
"0.6115434",
"0.611541",
"0.6108515",
"0.6107965",
"0.61077815",
"0.61076534",
"0.61062336",
"0.6101091",
"0.6097431",
"0.60965765",
"0.6094817",
"0.6090381",
"0.6088506",
"0.60847795",
"0.60842484",
"0.6081125",
"0.6080678",
"0.60764813",
"0.6074936",
"0.6073966",
"0.60727125",
"0.60726154",
"0.6071112",
"0.60686374",
"0.6067825",
"0.60669774"
] | 0.0 | -1 |
Notifying the Staff about their Account Details | def changed_details
mail_deliver(:notify_staff_details, :subject => "Your details have changed for " + self.school.school_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_employee\n \t\temployees.each do |employee|\n \t\t\tputs \"Notification sent to #{employee.name} at #{employee.email}\"\n \t\t\tputs \"\"\n \t\tend\t\n end",
"def notify\n return if @user.email.blank?\n\n Notifier.user_event_analisys(@user, @user.events.future.analisys.first).deliver_now if @user.events.future.analisys.present?\n Notifier.user_event_visit(@user, @user.events.future.visits.first).deliver_now if @user.events.future.visits.present?\n end",
"def success(user, account)\n @greeting = \"Successfully retrieved data for your account - #{account.inspect}\"\n\n mail to: user.email\n end",
"def notify_admins\n team.admins.each do |admin|\n admin.send_email(:team_account_funded_admin, team_payin: self) unless admin.id == person.id\n end\n end",
"def admin_account_activation(member)\r\n @member = member\r\n mail(to: member.user_name, subject: \"Admin Account Activation\") \r\n end",
"def notify(doctor ,recipient, subject, text)\n subject += \" sent to: #{recipient}, by: #{doctor.full_name}\" \n\t\tadmin_assists = AdminAssistant.all \n if admin_assists\n admin_assists.each do |adm|\n custom_email(adm, subject, text)\n end\n end\n end",
"def notify\n @user = @organization.users.find(params[:uid])\n if @organization.invite_member(@user)\n flash[:notice] = \"Organization invite resent to #{@user.email}.\"\n else\n flash[:alert] = \"Organization invite failed to #{@user.email}.\"\n end\n redirect_to @organization\n end",
"def notify_business\n business.add_message_to_queue(\"Hey #{business.name}, we've just deposited #{amount} into your account! Thanks for being great!\")\n end",
"def andrew_account_created_notification(person, options={})\n @person = person\n mail(:to=>[@person.personal_email],\n :subject=>options[:subject] || \"Andrew account information (\"[email protected]+\")\",\n :date=>Time.now)\n end",
"def send_account_notification\n @user = User.find_by_id(params[:id]) \n begin \n url = \"http://www.uncharted.net/account/activation/#{@user.activation_code}\" \n Emailer.deliver_admin_accountactivation(@user.email,url)\t\n end\n flash[:notice] = \"Email has been sent to #{@user.email} to active his account.\"\n redirect_to :action => 'index'\n end",
"def account_activation(member) \r\n @member = member \r\n mail(to: member.user_name, subject: \"Account Activation\") \r\n end",
"def notify_administrators!\n AdminMailer.new_pending_interest_point(self).deliver!\n end",
"def shift_notify(shift, employee)\n @shift_name = shift.employee.full_name\n @employee_name = employee.full_name\n @shift_time = shift.shift_day.strftime(\"%a-%d-%b\")\n @employee = employee.id\n @email = shift.employee.email\n\n mail(to: @email, subject:'Interested in your Shift')\n end",
"def send_mail_to_associates\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end",
"def notify_admin_about_newbie(user)\n @user = user\n mail \n end",
"def send_booking_confirmation_notifications\n\n notify_manager_confirmation\n notify_customer\n \n end",
"def response(attendee_id)\n @attendee = WorkshopAttendee.find(attendee_id)\n mail(to: @attendee.email, subject: @attendee.first_name + \", you are now registered with our workshop sessions.\")\n end",
"def activate_user\n self.save\n self.send_user_notification_email\n end",
"def notify_admin_profile_changes(presenter)\n Notification.notify_admin(\"#{presenter.first_name} #{presenter.last_name} has submitted a profile for approval\", presenter_profile_path(presenter), :system)\n end",
"def account_activated\n participant = Participant.first\n ParticipantMailer.account_activated(participant)\n end",
"def notification_per_succ_ref(smb, code_id, customer, friend, campaign)\n @smb = smb\n @customer = customer\n @friend = friend\n @campaign = campaign\n @code_id = code_id\n mail(:to => smb.email, :subject => \"Successful Referral Notification\")\n end",
"def notify_user\n current_user.notify!(twilio_client)\n redirect_to current_user\n end",
"def account_approved(approved_customer, approving_manager)\n @customer = approved_customer\n @manager = approving_manager\n mail to: @customer.email, subject: \"You have been approved as a customer with TSHA\"\n end",
"def account_confirmed(user)\n @notify_subject = strip_tags( \"USER CONFIRMED ACCOUNT AT #{ENV['APPLICATION_CONFIG_name']}\")\n @user = user\n mail( :to => ENV['APPLICATION_CONFIG_admin_notification_address'], :subject => @notify_subject)\n end",
"def welcome_information(user)\n @account = user\n mail(:to => named_email(user), :subject => \"Liveplus - Welcome\")\n end",
"def cust_success_redeemed(smb, customer, friend, campaign, sent)\n @smb = smb\n @customer = customer\n @friend = friend\n @campaign = campaign\n @sent = sent\n mail(:to => customer.email, :subject => \"Thanks for coming to #{smb.full_name}\", :from => \"#{smb.full_name} <#{smb.email}>\")\n end",
"def account_activation\n user = User.first\n user.activation_sent_at = Time.current\n UserMailer.account_activation(user)\n end",
"def new_user_waiting_for_approval(faculty)\n @faculty = faculty\n\n mail(to: '[email protected]', subject: 'A new faculty member is awaiting approval!', body: 'A new faculty member is awaiting your approval!')\n end",
"def send_mail_to_associates\n unless self.matter_people.blank?\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end\n end",
"def notify\n notify_unmentioned_reviewers\n notify_mentioned_event_staff if mention_names.any?\n end",
"def notify\n #ensure that you own the reservation or club\n #send notifcation in the background\n reservation = UserReservation.find(params[:user_reservation_id])\n\n if(reservation.contact.nil?) then\n Rails.logger.error \"No Contact email\"\n render json: {message:'No contact info'}, status: :expectation_failed\n return\n end\n\n if(reservation.contact.email.nil?) then\n Rails.logger.error \"Contact has no email\"\n render json: {message:'Contact has no email'}, status: :expectation_failed\n end\n\n #contact has email, deliver the email\n UserReservationMailer.notify(reservation).deliver_later\n head :ok\n end",
"def send_activation_email\n DoctorMailer.account_activation(self).deliver_now\n end",
"def send_info\n WorkerMailer.send_info(@worker).deliver\n redirect_to admins_path, notice: \"Worker information has been successfully sent.\"\n end",
"def old_notify_user (listing, sender, receiver)\n send_as :notification\n from sender.facebook_session.user \n recipients receiver.facebook_session.user\n #fbml \"<a href='#{FB_APP_HOME_URL}/listings/#{listing.id}'><b>#{listing.title}</b></a> has been approved.\"\n fbml \"Your listing: <a href='#{listings_path(listing.id)}}'><b>#{listing.title}</b></a> has been approved.\"\n end",
"def notify_admin_about_newbie(user)\n @user = user\n mail\n end",
"def received(attendee_id)\n @attendee = WorkshopAttendee.find(attendee_id)\n mail(to: \"[email protected]\", from: \"Workshop Registration <[email protected]>\", subject: \"Coder Factory Academy workshop session registration received.\")\n end",
"def notify_employee\n \t\[email protected] do |i| #loop through the array, each objects\n \t\tputs \"Hello #{i.email}\" #i access to a object\n\tend\t\nend",
"def notify!\n\n Alert.alert!(target, self, \"create\")\n\n # alert = Alert.create!(\n # user: target,\n # target: self,\n # text: \"Feedback received from #{self.user.name}\",\n # read_link: \"/app/main/feedbacks/show/#{id}\"\n # )\n\n # # Create notifications for the sender and receiver -> will appear in timeline\n # Notification.create!(\n # user_id: user.id, target: self,\n # notify: false,\n # unread: false\n # )\n # Notification.create!(\n # user_id: target.id, target: self,\n # notify: true,\n # unread: true\n # )\n\n end",
"def send_admin_mail\n AdministratorMailer.new_user_waiting_for_approval(self).deliver_now\n end",
"def notify_superusers_of_access_request(applicant)\n superusers_emails = User.get_superuser_emails\n @user = applicant\n mail(:to => superusers_emails,\n :from => APP_CONFIG['account_request_admin_notification_sender'],\n :reply_to => @user.email,\n :subject => PREFIX + \"There has been a new access request\")\n end",
"def send_activation_email\n @admin = BusinessAdmin.find(params[:id])\n if @admin.active\n flash_error \"flash.error.admin.send_activation_mail_active\" \n else \n UserMailer.admin_activation_email(@admin).deliver\n flash_success \"flash.success.admin.send_activation_mail\",{}, {:email=>@admin.email} \n end\n \n end",
"def account_activation(user)\n @user = user\n mail to: user.email, subject: \"CRS Account Activation\"\n end",
"def approved(person)\n @person = person\n mail to: person.email, subject: \"Your Account Approved!\"\n end",
"def activation_success_email user, application_id\n @user = User.find user\n @application = @user.used_applications.find application_id\n @url = application_url(@application)\n mail(:to => @user.email,\n :subject => \"You have been added to #{@application.application_name}\")\n end",
"def admin_alert(data, subject)\n #@claim_url = \"http://www.cleanjay.ca/claim-booking/#{job.profile.claim_id}\"\n @data = data\n sub = \"[Admin Alert] \" + subject.to_s\n\n mail(:to => \"[email protected]\", subject: sub)\n end",
"def details\n if params['form_details']\n results = CsApi::Member.update(current_access_token, @current_user.username, params['form_details'])\n #check for errors!!\n if results['success'].eql?('false')\n if results['message'].index('Email__c duplicates').nil?\n flash.now[:error] = results['message']\n else\n flash.now[:error] = 'Duplicate email address found! The email address that you specified is already in use.'\n end\n else\n flash.now[:notice] = 'Your account information has been updated.'\n # get the updated account\n get_account \n end \n end\n @page_title = 'Account Details'\n end",
"def notify_about_sign_up(user, admin)\n @user = user\n mail(:to => admin.email, :subject => \"New User | #{user.name}\", :reply_to => \"[email protected]\")\n end",
"def notify(santa)\n if santa.minion != nil\n msg = \"#{santa.firstName} #{santa.lastName} is watching over \" +\n \"#{santa.minion.firstName} #{santa.minion.lastName}\"\n else\n msg = \"#{santa.firstName} #{santa.lastName} is watching over nobody\"\n end\n\n puts msg\n\n #Net::SMTP.start('smtp.example.com', 25) do |smtp|\n # smtp.send_message(msg, '[email protected]', santa.email)\n #end\n end",
"def account_activated(student)\n @student = student\n @url = 'http://clarionLibrary.com/login'\n mail(to: @student.email, subject: 'Congrat your account has been activated for Clarion library')\n end",
"def notify_reviewee\n begin\n PerfReviewMailer.notify(self.employee.email,self).deliver_now\n rescue\n end\n end",
"def show\n @validation_result = UserAccountValidation.validate_account params[:id]\n if @validation_result[:success] and APP_CONFIG[\"is_sandbox\"]\n #email slc operator about newly created user\n begin \n user = APP_LDAP_CLIENT.read_user_emailtoken(params[:id])\n ApplicationMailer.notify_operator_on_acct_creation(user).deliver unless user.nil?\n rescue Exception => e\n logger.error e.message\n end\n end\n render :show\n end",
"def send_new_account_alert(agency)\n setup_email\n body[:agency] = agency\n recipients '[email protected]'\n subject \"New Agency #{agency.name} has registered on ClockOff.com\"\n end",
"def create_cleaner_account_confirmation(account)\n\t\t@first_name = account.first_name\n\t\t@last_name = account.last_name\n\t\t@email = account.email\n\n mail(:to => \"[email protected]\", :subject => \"New Cleaner Signup!\")\n end",
"def account\n # find the account we are grabing contacts from\n if id = params[:from_account]\n @selected_account = Sfaccount.find(id)\n end\n # super users can only add themselves.\n if current_contact.portal_privilege == AppConstants::PRIVILEGE[:super_user]\n @instruction_text = \"Your current access level is \\\"Super User\\\" and you can only subscribe 1 contact: yourself.\"\n @contacts = [current_contact]\n else\n @contacts = (@selected_account || @account).contacts\n if current_contact.portal_privilege == AppConstants::PRIVILEGE[:user_manager]\n @instruction_text = \"Your current access level is \\\"User Manager\\\" and you can subscribe other contacts from your company.\"\n end\n end\n # the current subscribers\n @subscribers = @account.watcher ? @account.watcher.contacts : []\n # set siblings if (a) this account can view child accounts and (b) it has sibling accounts\n @siblings = ((@account.portal_case_scope__c == Sfaccount::SCOPES[:children_accounts] and @account.sibling_accounts) ? @account.sibling_accounts.reject { |a| a.contacts(true).empty? } : [])\n \n end",
"def notify_via_service\n u = User.first\n u.update(last_notification_mail_sent: 30.days.ago)\n service = NotificationDigest.new(type: :notifications)\n service.notify_user(u, deliver: false)\n end",
"def confirm\r\n # Change user status to active\r\n update(status: :active)\r\n # Update all pending company_roles to active\r\n company_roles.update_all(status: 1)\r\n NotifyMailer.welcome_mail(self).deliver_later\r\n super\r\n end",
"def resend_welcome\n return forbidden unless current_account.admin?\n\n account = current_organization.accounts.find(params[:id])\n LifecycleMailer.login_instructions(account, current_organization, current_account).deliver_now\n json nil\n end",
"def user_created(user)\n @user = user\n user_email_id = user.email\n mail to: \"#{user_email_id}\",subject: \"Account Has been created #{user.firstname + \" \" + user.lastname}\"\n end",
"def create\n @event = Event.find(params[:attended_event_id])\n if current_user.attend(@event)\n flash[:success] = \"Confirmed. Enjoy #{@event.title} on #{@event.date.strftime(\"%a, %b %d %Y %I : %M %p\")}\"\n redirect_to user_path(current_user)\n end\n end",
"def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end",
"def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end",
"def on_update_alert(profile)\n\t\t@profile = profile\n\t\tsendgrid_category 'Profile Update Alert'\n\t\tsendgrid_unique_args :profile_id => @profile.id\n\t\tmail \n\tend",
"def update_account_info\n Validation.validateParameters(params)\n begin\n customer_id = @customer_id\n result = ChargeBee::Customer.update(customer_id, {:first_name => params['first_name'],\n :last_name => params['last_name'],\n :email => params['email'],\n :company => params['company'],\n :phone => params['phone']\n }) \n render json: {\n :forward => \"/ssp/subscription\"\n }\n rescue ChargeBee::InvalidRequestError => e\n ErrorHandler.handle_invalid_request_errors(e, self)\n rescue Exception => e\n ErrorHandler.handle_general_errors(e, self)\n end\n end",
"def notify_user\n NotiMailer.notification_proposal(self.homework.user.email, self, self.homework).deliver\n end",
"def account_activation(user)\n @user = user\n mail to: user.email, subject: \"Account activation\"\n end",
"def account_activation(user)\n @user = user\n mail to: user.email, subject: \"Account activation\"\n end",
"def account_activation(user)\n @user = user\n\n mail to: user.email, subject: \"Account activation\"\n end",
"def activation_welcome(pharmacist)\n @pharmacist = pharmacist\n\n mail to: @pharmacist.email_primary, subject: \"Your account has been activated\"\n end",
"def notify(user_id, followed, added)\n @user = User.find(user_id)\n return if @user.followed_user_updates_disabled?\n\n sig = EmailAccessToken.\n create_access_token(@user, \"followed_user_updates\")\n @unsub_url = unsubscribe_url(signature: sig)\n\n @hide_salutation = true\n @display_name = first_name(@user)\n @followed = followed\n @updates = added\n @subject =\n \"New gear has been added to #{first_name(@followed).possessive} Registry!\"\n mail to: @user.email, subject: @subject\n end",
"def receive_success me,member\n @by_member = member\n @amount = me.amount\n @currency = me.account.currency\n @me = me\n subjects = \"You have been sent some money\"\n mail to: me.receiver.email, subject: subjects\n #when receiver has account\n end",
"def approve\n approve_user\n return if notified?\n email_topic_subscribers\n end",
"def send_notification\n self.target_followers.each do |target_follower|\n @user = User.find(target_follower.follower_id)\n Notification.create_notification(@user.profilable_id, @user.profilable_type, text = \"#{self.name} updated his/her profile\", \"Enterprise\") && reload unless target_follower == self || target_follower.nil?\n end\n end",
"def activation_success_email(user)\n @user = user\n @subject = \"[#{SITE_NAME}] Account activated\"\n mail(bcc: @user.email, subject: @subject)\n end",
"def referral_success_email(referral)\n @referral = referral\n mail(to: @referral.user.email, subject: 'Someone you referred has signed up to Mobilise Digital')\n end",
"def email(id)\n\t\t@user = User.find(id)\t\n\t\t\tmail(\n\t\t :subject => 'Important information from Relationally.net' ,\n\t\t :to => @user.email , \n\t\t :track_opens => 'true'\n\t\t\t)\n\tend",
"def booking_email(reservation) #customer, host, reservtion_id\n @user = reservation.user #appoint reservation user id(email,name)\n @host = reservation.listing.user #appoint listing user(email,name)\n @listing = reservation.listing #appoint reservation. listing(which id)\n\n mail(to: @user.email, subject: \"Thank you for your booking.\") #after all info appointed, send an email to user(customer)\n end",
"def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_mail\n UserMailer.account_activation(self).deliver_now\n end",
"def update_schedule\n role_id = current_user.role_id\n schedule = Schedule.get_schedule_array\n create_schedule = Schedule.get_create_schedule_array\n delete_schedule = Schedule.get_delete_schedule_array\n if Schedule.send_email(role_id,schedule,create_schedule,delete_schedule)\n flash[:success] = \"Users Notified!\"\n redirect_to root_path\n else\n flash[:error] = \"Some error occured! Please try again!\"\n redirect_to (:back)\n end\n end",
"def activate\n Account.where(:id => params[:id]).update_all(status: 'ACTIVE')\n @account = Account.find(params[:id])\n flash[:success] = \"Activated Account #\" + @account.acct_number.to_s\n redirect_to @account\n end",
"def start(user, account_id)\n @greeting = \"Started data retrieval for - #{account_id}\"\n\n mail to: user.email\n end",
"def appointment_follow_up_for_student(appointment_id)\n @appt = Appointment.find(appointment_id)\n set_appt_variables\n mail(to: @student.email, subject: \"How did your session go?\")\n end",
"def new_registration(account)\n @account = account\n mail subject: \"#{APP::NAME}: new registration\"\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def notify_user(record)\n unless record.user_id == record.author_id\n create_notification(record, record.user)\n end\n end",
"def send_text_to_members(user)\n message = 'appointment hasa been scheduled'\n assignee = assigned_to.full_name\n service_name = service.name\n case progress\n when 'SCHEDULED'\n message = \"appointment has been scheduled for #{service_name}\"\n when 'OTW'\n message = \"#{assignee} is on the way for the #{service_name} service\"\n when 'START'\n message = \"#{assignee} has started the appointment for the #{service_name} service\"\n when 'END'\n message = \"#{assignee} has completed the #{service_name} service\"\n when 'INVOICE'\n message = \"an invoice has been created for #{assignee} for the #{service_name} service\"\n when 'PAID'\n message = \"a payment has been made to #{assignee} for the #{service_name} service\"\n else\n message\n end\n \n TwilioClient.new.send_text(user.phone_number, message)\n end",
"def notification\n doctor = Doctor.first\n DoctorMailer.notification(doctor)\n end",
"def send_activation_email\n UserMailer.account_activation(self).deliver_now\n end",
"def perform(cupons, friends, user_id, venue_id)\n\t\tUser.notifyfriends(cupons, friends, user_id,venue_id)\n\tend",
"def update\n meeting = Meeting.find(@attending.meeting_id)\n notification_text = \"#{current_user.first_name} #{current_user.last_name} has accepted your invite to #{meeting.description}.\"\n Notification.create(user_id: meeting.organiser_id, message: notification_text)\n @attending.update(confirmed: true)\n redirect_to meetings_path\n end",
"def activation\n StudentMailer.activation\n end"
] | [
"0.65631616",
"0.64840055",
"0.63763887",
"0.63678",
"0.6290983",
"0.6285072",
"0.6276045",
"0.62560976",
"0.6252183",
"0.6229516",
"0.6212217",
"0.6208451",
"0.61434716",
"0.6129879",
"0.6098518",
"0.6094862",
"0.6091503",
"0.6085698",
"0.60644627",
"0.6031124",
"0.6016786",
"0.6010668",
"0.59822506",
"0.5982094",
"0.59601116",
"0.59595823",
"0.59529936",
"0.59384316",
"0.5925756",
"0.59249824",
"0.5923633",
"0.59053564",
"0.58940834",
"0.58848834",
"0.5881745",
"0.5880863",
"0.58760244",
"0.5864356",
"0.5862547",
"0.5857785",
"0.5845623",
"0.58442354",
"0.58411604",
"0.5837749",
"0.5837388",
"0.583469",
"0.58289784",
"0.5815049",
"0.58078724",
"0.580686",
"0.5801042",
"0.579381",
"0.57886505",
"0.57759506",
"0.57741284",
"0.5762939",
"0.57546896",
"0.57546043",
"0.57537514",
"0.5739348",
"0.5739348",
"0.5736739",
"0.5731286",
"0.57280594",
"0.5727689",
"0.5727689",
"0.5727573",
"0.5726149",
"0.5719042",
"0.5717201",
"0.57170874",
"0.57147354",
"0.5713919",
"0.5713634",
"0.57131183",
"0.57129776",
"0.57093143",
"0.57093143",
"0.57086366",
"0.5707863",
"0.57048965",
"0.5703971",
"0.5702915",
"0.56985784",
"0.56985784",
"0.56985784",
"0.56985784",
"0.56985784",
"0.56985784",
"0.56985784",
"0.56985784",
"0.56985784",
"0.56985784",
"0.56836176",
"0.56766343",
"0.5661651",
"0.56579596",
"0.56563413",
"0.5654816",
"0.565477"
] | 0.595952 | 26 |
Changing the password reset key after the user clicks | def resetting
pwreset_key_success = false
until pwreset_key_success
self.password_reset_key = self.class.make_key
self.save
pwreset_key_success = self.errors.on(:password_reset_key).nil? ? true : false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_password_reset\n self.make_password_reset_code\n end",
"def password_reset\n player = Player.first\n player.reset_token = Player.new_token\n PlayerMailer.password_reset(player)\n end",
"def password_reset\n\t\tshepherd = Shepherd.first\n\t\tshepherd.reset_token = Shepherd.new_token\n ShepherdMailer.password_reset(shepherd)\n end",
"def set_password_reset\n\t\tself.code = SecureRandom.urlsafe_base64\n\t\tself.expires_at = 4.hours.from_now\n\t\tself.save!\n\tend",
"def password_reset\n account = Account.first\n account.reset_token = Account.new_token\n AccountMailer.password_reset(account)\n end",
"def password_reset\n gamer = Gamer.first\n gamer.reset_token = Gamer.new_token\n GamerMailer.password_reset(gamer)\n end",
"def reset_password\n update_attribute(:password_reset_code, nil)\n @reset_password = true\n end",
"def forgot_password\n @forgotten_password = true\n self.make_password_reset_code\n end",
"def forgot_password\n @forgotten_password = true\n self.make_password_reset_code\n end",
"def password_reset\n tester = Tester.first\n tester.reset_token = Tester.new_token\n TesterMailer.password_reset(tester)\n end",
"def new_reset_password\n end",
"def password_reset\n \tuser = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def forgot_password\n\t\tend",
"def send_reset_password_instructions; end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = SbUser.first\n user.reset_token = SbUser.new_token\n SbuserMailer.password_reset(user)\n\n end",
"def send_reset_password_instructions\n end",
"def reset_password\n friendly_token = Authlogic::Random.friendly_token\n self.password = friendly_token\n self.password_confirmation = friendly_token\n end",
"def password_reset\n user = User.first \n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first \n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password \n if params[:reset]\n results = CsApi::Account.reset_password(current_user.username)\n if results['success'].eql?('true')\n redirect_to password_reset_url, :notice => results[\"message\"]\n else \n flash.now[:notice] = results[\"message\"]\n end\n get_account\n end\n @page_title = \"Change Your Password\"\n if !@account[\"login_managed_by\"].eql?('CloudSpokes')\n flash.now[:warning] = \"You are logging into CloudSpokes with your #{@account[\"login_managed_by\"]} account. You will need to change your password at #{@account[\"login_managed_by\"]}\"\n end\n end",
"def forgot_password\n end",
"def password_reset\n participant = Participant.first\n participant.reset_token = Participant.new_token\n ParticipantMailer.password_reset(participant)\n end",
"def password_reset_request\n end",
"def password_reset\n member = Member.first\n member.reset_token = Member.new_token\n MemberMailer.password_reset(member)\n end",
"def reset_password\n friendly_token = Authlogic::Random.friendly_token\n self.password = friendly_token\n self.password_confirmation = friendly_token if self.class.require_password_confirmation\n end",
"def password_reset\n user = User.first\n user.reset_token = User.new_token #присваивается значение токена сброса пароля\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = Customer.last\n user.reset_token = Customer.new_token\n CustomerMailer.password_reset(user)\n end",
"def password_reset\n employee = Employee.first\n employee.reset_token = Employee.new_token\n EmployeeMailer.password_reset(employee)\n end",
"def password_reset\n applicant = Applicant.first\n applicant.reset_token = Applicant.new_token\n ApplicantMailer.applicant_password_reset(applicant)\n end",
"def password_reset\n user = User.first\n user.reset_token = SecureRandom.uuid\n user.e_token = User.digest(user.email)\n UserMailer.password_reset(user)\n end",
"def password_reset\n user = User.first\n user.password_reset_token = new_token\n email = EmailAddress.find_by(id: user.primary_email_address_id).email\n UserMailer.password_reset(user, email)\n end",
"def forgot_password\n\t\t\n\tend",
"def forgot_password\n self.password_reset_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n end",
"def change_password\r\n \r\n end",
"def password_reset\n user = Investor.first\n user.activation_token = Investor.new_token\n NemabollonMailer.password_reset(user)\n end",
"def password_reset\n # ShopMailer.password_reset\n shop = Shop.first\n shop.reset_token = Shop.new_token\n ShopMailer.password_reset(shop)\n end",
"def clear_reset_password_token; end",
"def password_reset\n UserMailMailer.password_reset\n end",
"def reset_password(new_password, new_password_confirmation); end",
"def reset_password!\n @session.nickserv.resetpass(self.name)\n end",
"def password_reset\n user = RailsTutorial::Sample::User.first\n user.reset_token = RailsTutorial::Sample::User.new_token\n RailsTutorial::Sample::UserMailer.password_reset(user)\n end",
"def password_reset\n PenggunaMailer.password_reset\n end",
"def password_reset\n owner = Owner.first\n owner.reset_token = Owner.new_token\n Owner::UserMailer.password_reset(owner)\n end",
"def edit_password; end",
"def reset_password!\n new_password = Digest::MD5.hexdigest(Time.now.to_s.split(//).sort_by {rand}.join)[0, 10]\n self.password = new_password\n self.password_confirmation = new_password\n save!\n end",
"def password_changed_confirm\n pw_change_confirm.click\n end",
"def password_reset\n user = User.first || Lecturer.first\n user.reset_token = User.new_token || Lecturer.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n AccountMailer.password_reset\n end",
"def password_reset\n MailerMailer.password_reset\n end",
"def password_reset\n user = Volunteer.first\n user.reset_token = Volunteer.new_token\n VolunteerMailer.password_reset(user)\n end",
"def password_reset\n StudentEmailConfirmation.password_reset\n end",
"def send_password_resets\n generate_token(:password_reset_token)\n self.password_reset_sent_at = Time.zone.now\n self.save!\n NotificationsMailer.password_reset_mail(self).deliver\n end",
"def password_reset\n password_changed = false;\n\n if allow_password_reset()\n unless params[:password].to_s.strip.empty?\n @password_reset_user.password = params[:password]\n @password_reset_user.save!\n @password_reset_user.initialize_aes_iv_and_key\n @password_reset_user.save!\n GoMailer.password_reset(@password_reset_user, get_host).deliver\n password_changed=true\n end\n end\n\n return HESResponder({:password_changed => password_changed})\n end",
"def password_reset\n doctor = Doctor.first\n doctor.reset_token = Doctor.new_token\n DoctorMailer.password_reset(doctor)\n end",
"def password_reset\n ClientMailer.password_reset\n end",
"def restore_password\n UserMailer.restore_password\n end",
"def password_reset\n #@greeting = \"Pershendetje\"\n\n #mail to: \"[email protected]\"\n end",
"def password_reset(user, token)\n @user = user\n @token = token\n mail(\n to: @user.email,\n from: '[email protected]',\n subject: 'パスワードの再設定'\n )\n end",
"def reset_password\n user = User.first\n ticket = user.tickets.create(\n name: 'Réinitialiser le mot de passe',\n action: '/password_resets/%{token}/edit',\n duree: 2.days\n )\n UserMailer.reset_password(user, ticket)\n end",
"def reset_password\n temporary_password = ActiveSupport::SecureRandom.base64(6)\n self.password = temporary_password\n self.password_confirmation = temporary_password\n temporary_password\n end",
"def reset_password!\n reset_password\n save_without_session_maintenance(validate: false)\n end",
"def change_temp_password\n\tend",
"def password_reset\n UserMailer.password_reset\n end",
"def password_reset\n UserMailer.password_reset\n end",
"def password_reset\n UserMailer.password_reset\n end",
"def password_reset\n user = User.first\n user.create_reset_digest\n UserMailer.password_reset(user.id, user.reset_token)\n end",
"def password_reset\n MemberMailer.password_reset\n end",
"def reset_password\n set :password, Proc.new {\n Capistrano::CLI.password_prompt(\"Password (for user: #{user}): \")\n } \n end",
"def reset_password!\n password = PasswordGenerator.random_pronouncable_password(3)\n self.password = password\n self.password_confirmation = password\n save\n UserMailer.deliver_reset_password(self)\n end",
"def reset_password() \n self.password_confirmation = self.password = self.login\n \n self.save\n end",
"def use_password_reset(token, new_password)\n put(\"/v1/password_resets/#{token}\", password: new_password)\n end",
"def reset_password(password)\n self.termpassword = password\n save\n end",
"def reset_password\n self.current_user = User.find_by_password_reset_code(params[:password_reset_code])\n flash[:notice] = \"You must now change your password!\"\n redirect_to(change_password_url)\n\n # if logged_in? && !current_user.activated?\n # current_user.reset_password\n # flash[:notice] = \"Signup complete!\"\n # end\n # redirect_back_or_default('/')\n end",
"def change_password\n return if generate_filled_in\n if do_change_password_for(@user)\n # since sometimes we're changing the password from within another action/template...\n #redirect_to :action => params[:back_to] if params[:back_to]\n redirect_back_or_default :action => 'change_password'\n end\n end",
"def reset_password\n [send_email(MailPart.new_subject(I18n.t('devise.mailer.reset_password_instructions.subject')),\n nil,\n MailPart.new_body(''),\n EmailStuff::TYPES[:reset_password],\n reset_pass_call),\n @candidate_mailer_text.token]\n end",
"def public_forgot_password\n end",
"def reset_password\n generate_token(:password_reset_token)\n self.password_reset_sent_at = Time.now\n save!\n UserMailer.delay.password_reset(self)\n end",
"def reset_password\n Notifier.reset_password\n end",
"def reset_password!\n reset_password\n save_without_session_maintenance(false)\n end",
"def password_reset\nemployee = Employee.first\nemployee.reset_token = Employee.new_token\nEmployeeMailer.password_reset(employee)\nend",
"def password_change_new\n\n end",
"def reset_password\n self.password_reset_token = SecureRandom::uuid\n save!\n UserMailer.send_password_reset_token(self).deliver\n end",
"def reset_password\n @user = User.last\n @user.password_reset_token = \"12345\"\n @user.password_reset_sent_at = Time.zone.now\n mail = UserMailer.reset_password(@user)\n end",
"def confirm_password_reset!\n if password_resettable?\n password_reset_token.confirm!\n self\n else\n raise Pillowfort::TokenStateError\n end\n end",
"def reset!\n self.password_cost = 9\n end",
"def password_reset(shepherd)\n\t\t@shepherd = shepherd\n\t\tmail to: shepherd.email, subject: \"Password reset\"\n end",
"def after_password_reset; end",
"def reset_password\n o = [('a'..'z'),('A'..'Z'),('0'..'9')].map{|i| i.to_a}.flatten\n new_password = (0..6).map{ o[rand(o.length)] }.join\n self.password = new_password\n if self.save\n return new_password\n else\n return nil\n end\n end",
"def send_reset_email\n begin\n email = params[:email]\n raise 'Invalid email' if(email=='')\n u = User.find_by_email(email)\n ok_msg = \"Email sent, please check your mail.\"\n raise ok_msg if(u==nil)\n key = ApplicationHelper.generate_key\n u.update_attribute(:lost_key,key) \n AppMailer.deliver_lost_password(u,key)\n render(:text=>ok_msg)\n rescue Exception => e\n render(:text=>e.message)\n end\n end",
"def reset_pwd\n user=User.where(:username => params[:username])[0]\n Notifier.reset_pwd(user).deliver\n render :update do |page|\n page<< '$(\"#log_in_menu\").slideUp(\"fast\", function(){});'\n end\n \n end",
"def send_password_reset\n self.reset_token = Token.random\n update_columns(reset_digest: Token.digest(reset_token), reset_sent_at: Time.zone.now)\n UserMailer.password_reset(self).deliver_now\n end",
"def reset_user_password\n temp_password = generate_password(20)\n User.update_all(\"activation_code = '#{temp_password}', recently_reset = 1, updated_at = '#{Time.now}'\", \"id = #{self.id}\")\n UserMailer.reset_password(self.id, temp_password).deliver\n end"
] | [
"0.7393369",
"0.72879815",
"0.7261722",
"0.7204202",
"0.7203254",
"0.71970606",
"0.71729875",
"0.71285856",
"0.71285856",
"0.70927495",
"0.708605",
"0.7058666",
"0.70582527",
"0.7039743",
"0.7038798",
"0.7038798",
"0.7038798",
"0.7038798",
"0.7038798",
"0.7038798",
"0.7038798",
"0.7030868",
"0.70305914",
"0.70196444",
"0.7008089",
"0.69845986",
"0.69845986",
"0.6983729",
"0.6981386",
"0.69734293",
"0.6970647",
"0.69550574",
"0.69458693",
"0.6944886",
"0.69386864",
"0.69173867",
"0.6907704",
"0.6899976",
"0.68986946",
"0.6886492",
"0.68823886",
"0.68809795",
"0.68796235",
"0.6876486",
"0.68488985",
"0.68474674",
"0.684072",
"0.6831376",
"0.68206674",
"0.68123245",
"0.68033105",
"0.67992616",
"0.67909056",
"0.6784792",
"0.67618734",
"0.6748705",
"0.6746487",
"0.67415524",
"0.67268884",
"0.67258143",
"0.66636264",
"0.6638725",
"0.66363835",
"0.6635896",
"0.6634478",
"0.66310805",
"0.6624964",
"0.6616972",
"0.6610892",
"0.66055655",
"0.66047806",
"0.66047806",
"0.66047806",
"0.6604109",
"0.6601673",
"0.65967155",
"0.65965444",
"0.65959615",
"0.6595819",
"0.6580219",
"0.6564057",
"0.6560506",
"0.6555199",
"0.65540266",
"0.65521115",
"0.6551697",
"0.6548039",
"0.6545106",
"0.65324336",
"0.65307134",
"0.6524356",
"0.6522202",
"0.6507525",
"0.64984417",
"0.64983046",
"0.64942425",
"0.6458626",
"0.64541805",
"0.6453073",
"0.64506054"
] | 0.6692635 | 60 |
this is a setter | def set_cohort(group)
@cohort = group
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set; end",
"def set; end",
"def __setter__\n \"#{self}=\"\n end",
"def _setter_method\n :\"_#{self[:name]}=\"\n end",
"def setter_method\n :\"#{self[:name]}=\"\n end",
"def _setter_method\n :\"_#{self[:name]}=\"\n end",
"def setter\r\n @setter ||= Field.setter(@name)\r\n end",
"def setter_method\n :\"#{self[:name]}=\"\n end",
"def attribute_to_set; end",
"def set(object, value); end",
"def set(value)\n raise NotImplementedError\n end",
"def setter\n @setter ||= :\"#{@name}=\"\n end",
"def value=(value); self.data.value = value; end",
"def value=(val); end",
"def setter\n @setter ||= \"#{name}=\"\n end",
"def set(value)\n value\n end",
"def set_value( value )\n @value = value \n end",
"def to_setter\n\t\t\t\t(to_getter.to_s+\"=\").to_sym\n\t\t\tend",
"def create_setter\n @model.class_eval <<-EOS, __FILE__, __LINE__\n #{writer_visibility}\n def #{name}=(value)\n self[#{name.inspect}] = value\n end\n EOS\n end",
"def set=(_arg0); end",
"def set_attribute(name, value); end",
"def setValue(value)\n @value = value\n end",
"def value=(_); end",
"def []= key, value\n\t\t\tsuper\n\t\t\[email protected] set: {@name => self} if @name.present? if check_if_complete\n\t\tend",
"def set(*args)\n # not supported\n end",
"def set(*args)\n # not supported\n end",
"def x=(value)\n end",
"def setter( name ) (name.to_s + '=').to_sym end",
"def value(value)\n\t\t@value=value\n\tend",
"def define_setter\n name = @name\n klass.send :define_method, \"#{name}=\" do |unit|\n send \"#{name}_value=\", unit.value\n send \"#{name}_unit=\", unit.unit.to_s\n end\n end",
"def z=(value)\n end",
"def y=(val); self[1] = val; end",
"def w=(val); self[2] = val; end",
"def value=(v)\n set(v)\n end",
"def set_field_value(name, value)\n\t\tend",
"def proxy=(new_value); end",
"def create_setter\n @model.class_eval <<-EOS, __FILE__, __LINE__\n #{writer_visibility}\n def #{name}=(value)\n attribute_set(#{name.inspect}, value)\n end\n EOS\n end",
"def set(field,value)\n set_method = (field.to_s + \"=\").to_sym\n m = self.method((field.to_s + \"=\").to_sym)\n m.call value\n end",
"def value=(new_value)\n\t\t@value = new_value\n\t\tinform_obeservers\n\tend",
"def set(key, value)\n raise \"Method not implemented. Called abstract class.\"\n end",
"def set_property(key, value)\n end",
"def h=(val); self[3] = val; end",
"def attribute=(_arg0); end",
"def attribute=(_arg0); end",
"def value=(value)\n @value = value\n end",
"def baz=(value)\n @baz = value\nend",
"def baz=(value)\n @baz = value\nend",
"def set_setting\n end",
"def set_name=(name)\n @name=name\n end",
"def []=(property, value); end",
"def z=(value)\n super\n update_cursor\n end",
"def create_setter(name, meth)\n define_method(\"#{meth}=\") do |value|\n write_attribute(name, value)\n end\n end",
"def set(n)\r\n self.value=n\r\n end",
"def set( setThis )\r\n assert_exists\r\n assert_enabled\r\n assert_not_readonly\r\n \r\n highlight(:set)\r\n @o.scrollIntoView\r\n @o.focus\r\n @o.select()\r\n @o.fireEvent(\"onSelect\")\r\n @o.value = \"\"\r\n @o.fireEvent(\"onKeyPress\")\r\n doKeyPress( setThis )\r\n highlight(:clear)\r\n @o.fireEvent(\"onChange\")\r\n @o.fireEvent(\"onBlur\")\r\n end",
"def value=(value)\n @value = value\n end",
"def value=(value)\n @value = value\n end",
"def value=(value)\n @value = value\n end",
"def value= (val) ; write_attribute(:value, Marshal.dump(val)) ; end",
"def create_setter!\n @target.class_eval <<-EOS\n #{writer_visibility.to_s}\n def #{name}=(value)\n attribute_set(#{name.inspect}, value)\n end\n EOS\n rescue SyntaxError\n raise SyntaxError.new(column)\n end",
"def value=(newval)\n raise\n end",
"def field_set!(key, value)\n send \"_#{key}_set\", value\n end",
"def set(index, val)\n \n end",
"def []=(field_name, value); end",
"def value= value\n\t\t@value = value\n\t\trefresh\n\tend",
"def old_value=(_arg0); end",
"def []=(key, value) self.send(\"#{key}=\", value) end",
"def x=(val); self[0] = val; end",
"def name=(value); end",
"def set(value)\n execute_only(:set, value)\n end",
"def setting; end",
"def set(&block)\n @set = block\n end",
"def set(&block)\n @set = block\n end",
"def setName=(name)\n @name = name\n end",
"def __copy_on_write__(*)\n super.tap do\n new_set = __getobj__.instance_variable_get(:@set).dup\n __getobj__.instance_variable_set(:@set, new_set)\n end\n end",
"def y=(value)\n end",
"def set(x, y)\n @x = x\n @y = y\n self\n end",
"def value=(value)\n @value = value\n end",
"def name=(str); dirty!; super; end",
"def set_nombre(nombre) # la convencion de ruby es def nombre=(nombre) * Sin espacios\n @nombre = nombre\n end",
"def __set(i, e)\n\t\tUtil.__set(@m, i, e)\n\t\treturn\n\tend",
"def set(value)\n old_value = refresh(value)\n handle_event :type => :change, :old_value => old_value, :value => @value if old_value != @value\n old_value\n end",
"def name= val # Setter - set a value\n @name = val \n end",
"def set(val)\n @value = val\n @http_value = nil\n self\n end",
"def attr_writer( * )\n fail \"Remember, an Entity is immutable. Use a Services::Service to mutate the underlying data.\"\n end",
"def pos=(p1)\n #This is a stub, used for indexing\n end",
"def age=(value)\n @age = value\nend",
"def age=(value)\n @age = value\nend",
"def []=(attr, value)\n self.send(\"#{attr}=\", value)\n end",
"def []=(attr, value)\n self.send(\"#{attr}=\", value)\n end",
"def y=(value)\n self[1] = value\n end",
"def setter(name, metadata)\n re_define_method(\"#{name}=\") do |object|\n without_autobuild do\n if value = get_relation(name, metadata, object)\n if value.respond_to?(:substitute)\n set_relation(name, value.substitute(object.substitutable))\n end\n else\n __build__(name, object.substitutable, metadata)\n end\n end\n end\n self\n end",
"def age=(v) self['Age'] = v end",
"def x=(value)\n super\n update_cursor\n end",
"def assign_property(name, value); end",
"def method=(_); end",
"def title=( new_title )\nif @writable\n@title = new_title\nend\nend",
"def sb=(value)\n self[:sb] = value\n end",
"def sb=(value)\n self[:sb] = value\n end",
"def sb=(value)\n self[:sb] = value\n end",
"def sb=(value)\n self[:sb] = value\n end",
"def sb=(value)\n self[:sb] = value\n end"
] | [
"0.81791145",
"0.81791145",
"0.79880553",
"0.7590008",
"0.7529154",
"0.7389435",
"0.7363279",
"0.73087966",
"0.7284757",
"0.7281158",
"0.7223879",
"0.72025865",
"0.71291995",
"0.7022676",
"0.70107377",
"0.6997533",
"0.6915362",
"0.68675435",
"0.67795324",
"0.6757638",
"0.6750537",
"0.6732028",
"0.67254424",
"0.6716837",
"0.6703765",
"0.6703765",
"0.6690718",
"0.664471",
"0.6625014",
"0.66204715",
"0.6603948",
"0.65894073",
"0.6580297",
"0.65615374",
"0.6559227",
"0.6526362",
"0.65251344",
"0.65030175",
"0.647687",
"0.6474162",
"0.64381033",
"0.64370114",
"0.64358807",
"0.64358807",
"0.64211863",
"0.6404682",
"0.6404682",
"0.639097",
"0.6389204",
"0.6380562",
"0.6375265",
"0.6365274",
"0.63527846",
"0.63498247",
"0.6302624",
"0.6302624",
"0.6302624",
"0.62934154",
"0.629264",
"0.62876064",
"0.62841606",
"0.62767833",
"0.6275608",
"0.6275522",
"0.6275458",
"0.6274974",
"0.62748843",
"0.62728",
"0.626746",
"0.62648386",
"0.6263409",
"0.6263409",
"0.62597996",
"0.6258261",
"0.62511057",
"0.62409425",
"0.62317747",
"0.622301",
"0.6214373",
"0.6206892",
"0.6205785",
"0.62039965",
"0.62003636",
"0.62000513",
"0.6196529",
"0.6179877",
"0.6179877",
"0.6177628",
"0.6177628",
"0.61754996",
"0.6170262",
"0.61691964",
"0.61646026",
"0.6160584",
"0.6160518",
"0.6159923",
"0.61587065",
"0.61587065",
"0.61587065",
"0.61587065",
"0.61587065"
] | 0.0 | -1 |
O(n) finding the bucket is O(1) and pushing onto ruby's dynamic array is O(1) but iterating through the array using inlcude? is O(n) | def insert(num)
self[num].push(num) unless include?(num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bucket_sort\n buckets = {}\n #Ideal for known and uniformly distributed range. Sort age of employees for eg.:\n @array.each do |age|\n bucket = age/10\n buckets[bucket] ||= []\n buckets[bucket] << age\n end\n\n result = []\n for i in 0..20\n arr = buckets[i]\n puts \"i=#{i}, buckets[i]=#{arr}\"\n puts \"result=#{result}, sorted value=#{insertion_sort(arr)}\" if arr\n result << insertion_sort(arr) if arr && arr != []\n end\n @array = result.flatten\n end",
"def bucket_sort(array, min, max)\n return array if array.size < 2\n\n b_size = 10\n # if we instanciate this with [] it instanciat eit with the same object\n # then when we insert to on of the indeces it inserts to all\n bucket = Array.new((max - min + 1)/b_size + 1)\n array.each do |a|\n if bucket[a/b_size].nil?\n bucket[a/b_size] = [a]\n else\n bucket[a/b_size] << a\n end\n end\n\n bucket.each do |b|\n insertion_sort_more_efficient(b)\n end\n \n bucket.flatten\nend",
"def basic_bucket_function\n Proc.new do |item|\n bucket_number = bisect_right(@buckets, item) - 1\n\n # Counters is @buckets.size - 1\n # [bucket_number, counter_size-1].min\n\n if bucket_number > counter_size-1\n counter_size-1\n else\n bucket_number\n end\n end\n end",
"def fast_bucket_function\n Proc.new do |item|\n if item.is_a?(Float) && item.nan?\n nil\n else\n bucket_number = (item - min)/increment\n if bucket_number > counter_size || bucket_number < 0\n nil\n else\n [bucket_number.to_i, counter_size-1].min\n end\n end\n end\n end",
"def bucket_array( array , from , to )\n rb_tick = (@days * 24 * 60 * 60).to_i\n js_tick = rb_tick * 1000\n from = (from.to_i / rb_tick) * js_tick\n to = (to.to_i / rb_tick)* js_tick\n ret = {}\n while from <= to\n ret[from] = 0\n from += js_tick\n end\n array.each do |item|\n value = item.send(@price_or)\n index = (item.created_at.to_i / rb_tick)*js_tick\n if ret[index] == nil\n puts \"No index #{index} in array (for bucketing) #{ret.to_json}\" if Rails.env == \"development\"\n ret[index] = 0 \n end\n ret[index] = ret[index] + value\n end\n ret.sort\n end",
"def bucketSort(a, n, buckets, m)\n for j in 0 ... m\n buckets[j] = 0\n end\n for i in 0 ... n\n buckets[a[i]] += 1\n end\n i = 0\n for j in 0 ... m\n for k in 0 ... buckets[j]\n a[i] = j\n i += 1\n\tend\n end\nend",
"def compute_bucket(value, size = table.length)\n value.hash % size\n end",
"def insert_into_bucket(value, bucket)\n @table[bucket] = value\n @count += 1\n maybe_rehash\n end",
"def increment_bucket(bucket)\n (bucket + 1) % table.length\n end",
"def __clone_buckets\n lim = @_st_tableSize\n lim = lim + lim\n kofs = 0\n while kofs < lim\n v = self.__at(kofs + 1)\n if v._not_equal?(RemoteNil)\n k = self.__at(kofs)\n if k._not_equal?(RemoteNil)\n # a k,v pair\n elsif v._isFixnum\n # internal collision chain\n else\n # a collision bucket\n nbucket = v.clone\n nbucket.__parent=(self)\n self.__at_put(kofs + 1, nbucket )\n end\n end\n kofs += 2\n end\n end",
"def [](num) #<== maybe requires hash\n # num_hash = num.hash\n # @store[num_hash % num_buckets]\n @store[num % num_buckets]\n end",
"def receive_list(fromIndria)\n if @buckets.empty?\n # make new bucket\n @buckets << [fromIndria]\n @bucketCounts << 1\n @bucketsCount += 1\n else\n # get representatives\n reps = []\n @buckets.each_with_index do |bucket, idx|\n rIdx = rand(@bucketCounts[idx])\n reps << bucket[rIdx]\n end\n\n mIdx = reps.find_index { |rep| compare(rep, fromIndria) }\n\n if mIdx\n # for each representative, compare and store in @buckets accordingly\n @buckets[mIdx] << fromIndria\n @bucketCounts[mIdx] += 1\n else\n # make new bucket\n @buckets << [fromIndria]\n @bucketCounts << 1\n @bucketsCount += 1\n end\n end\n end",
"def split\n results = @ordered.inject([]) { |memo,(identity,buckets)|\n newinst = self.class.new(:identity => identity)\n newinst.buckets = buckets.dup\n newinst.collate!\n memo << newinst\n memo\n }\n return results\n end",
"def buckets\n @buckets ||= init_buckets\n end",
"def initialize()\n @buckets = []\n end",
"def sq_arr(a)\n # require 'debug'\n a.map! { |x| x**2 }\n j = (a.length - 1)\n return a if j == 0\n while a[0] >= a[1] && j >= 0\n p j\n if a[0] > a[j]\n a.insert(j, a.shift)\n else\n j -= 1\n end\n end\n a\nend",
"def initialize\n @buckets = Array.new(BUCKETS) { [] }\n end",
"def compute_adjusted_bucket(value)\n ideal_bucket = bucket = compute_bucket(value)\n until table[bucket].yield_self { |val| val.blank? || val == value }\n bucket = increment_bucket(bucket)\n raise LOOPED_MESSAGE if bucket == ideal_bucket\n end\n\n bucket\n end",
"def num_buckets\n self.store.length\n end",
"def find_limit(universe, subset)\n \n large_number = 10_000_000_000\n resource = universe + 1\n my_array = Array.new\n \n (0...universe).each do |value|\n my_array\n .push([value+1, value, 0])\n .push([value, value +1, 1])\n end\n p my_array if $PRINT_ARRAY\n \n (0...universe+1).each do |value|\n my_array.push([resource, value, 0])\n end\n p my_array if $PRINT_ARRAY\n \n subset.each do |value|\n my_array\n .push([value[0]-1,value[1], value[2]])\n .push([value[1],value[0]-1, -value[2]])\n end\n p my_array if $PRINT_ARRAY\n \n distribution = [large_number]*(universe+2)\n distribution[resource] = 0\n \n (0...universe+1).each do |value|\n my_array.each do |value|\n distribution[value[1]] = [distribution[value[1]], distribution[value[0]]+value[2]].min\n end\n end\n distribution[universe]-distribution[0]\nend",
"def collisions(arr)\n new_arr = []\n result = []\n arr.each do |i|\n if i > 0\n new_arr << i\n else\n if new_arr.empty?\n result << i\n else\n if new_arr[-1] == -(i)\n new_arr.pop\n else\n while !new_arr.empty? && new_arr[-1] < -(i)\n new_arr.pop\n end\n if new_arr.empty?\n result << i\n end\n end\n end\n end\n end\n return (result.concat(new_arr))\nend",
"def num_buckets\n @store.length\n end",
"def bisect\n n = self.size\n l = n / 2\n [self[0...l], self[l...n]]\n end",
"def buckets\n return @buckets\n end",
"def final(arr,key)\n\tright = arr.length-1\n\tleft = 0\n\n\tresult = Array.new(2)\n\tresult[0] = -1\n\tresult[1] = -1\n\n\tsearch_range(arr,key,right,left,result)\n\tp result\nend",
"def initialize(num_buckets = 8)\n @store = Array.new(num_buckets) { Array.new }\n @count = 0\n end",
"def calculate(number)\n buckets = []\n (1..number).each do |n|\n @prime.factors(n).each do |prime_factor|\n bucket = find_bucket(buckets, prime_factor)\n if bucket.nil?\n bucket = []\n buckets << bucket\n end\n bucket << prime_factor\n end\n end\n reduce_bucket_size(buckets, number)\n @arrays.multiply(buckets.flatten)\n end",
"def insert(key, value)\n i = index(key)\n buckets[i] = [key, value]\n end",
"def populate_buckets\n bucket_offset = header.class.bytesize\n bucktes = []\n header.num_buckets.times do |i|\n bucket = HMapBucket.new_from_bin(swapped, @raw_data[bucket_offset, HMapBucket.bytesize])\n bucket_offset += HMapBucket.bytesize\n next if bucket.key == HEADER_CONST[:HMAP_EMPTY_BUCKT_KEY]\n\n bucktes[i] = { bucket => yield(bucket) }\n end\n bucktes\n end",
"def calculate (bs, ap, buffer)\r\n\t\tpair_key = \"#{bs}-#{ap}\"\r\n\t\t@price_histogram[pair_key] = {} if !@price_histogram[pair_key]\r\n\t\t@price_histogram_topx[pair_key] = [] if !@price_histogram_topx[pair_key]\r\n\t\t\r\n\t # age histograms\r\n\t @price_histogram[pair_key].each do |k,v|\r\n\t \t@price_histogram[pair_key][k] = v * ap\r\n\t end\r\n\t # age histograms in top10 list\r\n\t @price_histogram_topx[pair_key].each do |t|\r\n\t \tt[1] = t[1] * ap\r\n\t end\r\n\t \t\r\n\t # calculate which bucket in the histogram the price belongs to\r\n\t bucket = (buffer[P].close / bs).to_i * bs\r\n\t # increase the bucket counter\r\n\t @price_histogram[pair_key][bucket] = (@price_histogram[pair_key][bucket] ? @price_histogram[pair_key][bucket] : 0) + 1\r\n\t\t# if the bucket belongs to the top10 list, increase the counter there too\r\n\t\tcorrected = false\r\n\t\t@price_histogram_topx[pair_key].each do |t|\r\n\t\t\tif t[0] == bucket\r\n\t\t\t\tt[1] = @price_histogram[pair_key][bucket]\r\n\t\t\t\tcorrected = true\r\n\t\t\t\tbreak\r\n\t\t\tend\r\n\t\tend\r\n\t\t\r\n\t\t# add the bucket to the top 10 (if we haven't increased an existing one)\r\n\t\tif !corrected\r\n\t\t\t@price_histogram_topx[pair_key].push([bucket,@price_histogram[pair_key][bucket]])\r\n\t\tend\r\n\t\t# re-sort the top10 prices by counter\r\n\t\t@price_histogram_topx[pair_key] = @price_histogram_topx[pair_key].sort_by { |k| -1 * k[1] }\r\n\t\t# chop off the last element to keep top10 array at the right length\r\n\t\tif @price_histogram_topx[pair_key].count > 10\r\n\t\t\t@price_histogram_topx[pair_key].pop\r\n\t\tend\r\n\t\t\r\n\t\t# is there a signal? compare current & previous bucket...\r\n\t\tbucket_current = (buffer[P].close / bs).to_i * bs\r\n\t\tbucket_previous = (buffer[P-1].close / bs).to_i * bs\r\n\t\t# ... if exiting a top10 bucket and entering a regular one - we have a signal!\r\n\t\tif bucket_current != bucket_previous && @price_histogram_topx[pair_key].map{ |t| t[0] }.include?(bucket_previous) && !@price_histogram_topx[pair_key].map{ |t| t[0] }.include?(bucket_current)\r\n\t\t\tif bucket_current > bucket_previous\r\n\t\t\t\treturn \"b\"\r\n\t\t\telse\r\n\t\t\t\treturn \"s\"\r\n\t\t\tend\r\n\t\telse\r\n\t\t\treturn \"h\"\r\n\t\tend\r\n\tend",
"def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend",
"def boustrophedon_at(k,n)\n raise ArgumentError.new \"k must be < size\" unless k < size\n raise ArgumentError.new \"n must be < size\" unless n < size\n return 0 if n < 0 || k < n\n @b_cache ||= []\n @b_cache[k] ||= []\n\n @b_cache[k][n] ||= if k==0\n self[k]\n else\n boustrophedon_at(k,n-1) + boustrophedon_at(k-1,k-n)\n end\n end",
"def insert(item)\n return false unless has_space?\n\n fingerprint = fingerprint(item)\n first_index = hash(item)\n second_index = alt_index(first_index, fingerprint)\n\n if @buckets[first_index].insert(fingerprint) || @buckets[second_index].insert(fingerprint)\n increment_filled_count\n return true\n end\n\n index = [first_index, second_index].sample\n\n @max_kicks.times do\n fingerprint = @buckets[index].random_swap(fingerprint)\n index = alt_index(index, fingerprint)\n\n if @buckets[index].insert(fingerprint)\n increment_filled_count\n return true\n end\n end\n\n return false\n end",
"def <<(data)\n @bucket << data\n end",
"def initialize(num_buckets = 8)\n @store = Array.new(num_buckets) { Array.new }\n @count = 0\n @num_buckets = num_buckets\n end",
"def construct_by_down_heap(ary)\n n = ary.size\n k = n/2 - 1\n k.downto(0).each do |k|\n down_heap(ary, k, n)\n end\nend",
"def put(key, value)\n \txk = key % 10001 \n xk = (xk + 1) % 10001 while @arr[xk].first != nil && @arr[xk].first != key \n @arr[xk] = [key, value] \n end",
"def size\n @buckets.length\n end",
"def buckets()\n @sortedBuckets = @data.keys.sort {|x,y| y <=> x}\n Utils.printMux(@log, \"buckets> sortedBuckets:\" + @sortedBuckets.pretty_inspect(), @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n end",
"def k_largest_elements2(array, k) \n result = BinaryMinHeap.new\n k.times do\n result.push(array.pop)\n end\n until array.empty?\n result.push(array.pop)\n result.extract\n end\n result.store\nend",
"def check_rehash!\n return if @size.to_f/@cardinality < LOAD_FACTOR_THRESHOLD\n\n @cardinality *= 2\n old_arr = @arr.dup\n @arr = []\n old_arr.each do |r|\n next unless r\n\n self.add(r.number, r.name)\n el = r\n while (el = el.next_rec)\n self.add(el.number, el.name)\n end\n end\n end",
"def push(val)\n # O(1) time\n @arr << val\n\n @min << if @min.empty?\n val\n else\n (val < @min.last) ? val : @min.last\n end\n end",
"def find_k_biggest_number(array, k)\n numbers = []\n\n array.each do |element|\n numbers << element if numbers.size < k\n if element > numbers.min\n numbers.delete(numbers.min)\n numbers.push(element)\n end\n end\n\n numbers\nend",
"def super_frog_hops(num_stairs, max_stairs)\n cache = [[[]], [[1]]]\n return cache[num_stairs] if num_stairs < 2\n \n (2..num_stairs).each do |stairs|\n new_comb = []\n (1..max_stairs).each do |jump|\n if stairs - jump < 0\n next\n else\n cache[stairs - jump].each do |subarr|\n next_com = subarr + [jump] \n new_comb << next_com\n end \n end \n end \n cache[stairs] = new_comb\n end \n cache[num_stairs]\n end",
"def amount_displaced(value, bucket)\n correct_bucket = compute_bucket(value)\n\n if correct_bucket < bucket # We didn't wrap\n bucket - correct_bucket\n else # We did wrap\n table.length - correct_bucket + bucket\n end\n end",
"def fast\n ARRAY.bsearch { |num| num > 80_000_000 }\nend",
"def contains_cycle_via_array_storage # O(n) time O(n) space\n current = head\n prevs = []\n cycle = false\n while current.next != nil\n prevs.each do |prev| \n cycle = true if prev == current.next\n end\n break if cycle == true\n prevs.push(current)\n current = current.next\n end\n cycle\n end",
"def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend",
"def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend",
"def build_heap(array)\n first_parent_idx = (array.length - 1) / 2\n (first_parent_idx).downto(0).each { |current_idx| \n self.sift_down(current_idx, array.length - 1, array)\n }\n return array\n end",
"def each\n @buckets.each_with_index do |count, index|\n yield(to_bucket(index), count)\n end\n end",
"def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end",
"def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend",
"def qualified(array, s)\n result = []\n array.each do |sub_array|\n if sub_array.sum >= s\n result << sub_array\n else next\n end\n end\n result\nend",
"def iterative_insertion_sort(arr)\r\n 1.upto(arr.length - 1) do |index|\r\n key = arr[index]\r\n pos = index - 1\r\n while pos >= 0 && key <= arr[pos]\r\n # this could also have been written by swapping repeatedly\r\n # instead of copying the bigger element to the empty slot\r\n arr[pos + 1] = arr[pos]\r\n pos = pos - 1\r\n end\r\n arr[pos + 1] = key\r\n end\r\n arr\r\nend",
"def initialize\n @bucket = []\n @bucket\n end",
"def grapher(array)\n hash = Hash.new { |hash, key| hash[key] = [] }\n array.each do |pair|\n hash[pair[0]] ||= []\n hash[pair[0]] << pair[1]\n end\n hash\nend",
"def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend",
"def sum_to_n? arr, n\n hash = Hash.new\n arr.each do |val|\n if hash.key? val\n return true\n else\n hash[n-val] = val\n end\n end\n return false\nend",
"def sorted_squared_array_n_nlogn(values)\n values.collect!{|val| val*val}\n merge_sort(values)\nend",
"def range_bucket(value, size=10)\n if value.present?\n x = (value / size * size) + 1\n y = x + (size - 1)\n return \"#{x} - #{y}\"\n end\n end",
"def value\n result = []\n c = @collection || (0...size).to_a\n r = @rank\n 0.upto(size) do |i|\n r[i] == 1 and result << c[i]\n end\n result\n end",
"def push(val)\n # byebug\n if @length < @array.length\n @array[@last + 1] = val\n @last += 1\n @length += 1\n else\n new_array = StaticArray.new(@array.length * 2)\n for i in 0..(@length - 1)\n new_array[i] = @array[i]\n end\n new_array[@last + 1] = val\n @length += 1\n @array = new_array\n @capacity = @capacity * 2\n end\n end",
"def value_allocation(array,allocation)\n temp =[]\n array.map do |a|\n temp << a * allocation.to_f/100\n end\n return temp\n end",
"def collate!\n @buckets = @buckets.sort { |a,b| b.time <=> a.time }\n @ordered = {}\n @buckets.map { |o| o.identity }.uniq.each do |identity|\n @ordered[identity] = @buckets.select { |o| o.identity == identity }\n end\n return @buckets\n end",
"def to_index(data)\n\n # basic case is simple\n return log2(data).to_i if !linear?\n\n # Search for the right bucket in the linear case\n @buckets.each_with_index do |count, idx|\n return idx if right_bucket?(idx, data)\n end\n #find_bucket(0, bucket_count-1, data)\n\n #Should not get here\n raise \"#{data}\"\n end",
"def corgi_golden_age(arr)\n\tmax_subset_sum = 0\n\tmax_i = 0\n\tmax_j = 0\n\tsum = 0\n\ti = 0\n\tj=i+1\n\twhile i < arr.length\n\t\twhile j < arr.length\n\t\t\tsum = arr[i]+arr[j]\n\t\t\tif sum > max_subset_sum\n\t\t\t\tmax_subset_sum = sum\n\t\t\t\tmax_i = i\n\t\t\t\tmax_j = j\n\t\t\tend\n\t\t\tj+=1\n\t\tend\n\t\ti+=1\n\tend\n\treturn [max_i, max_j]\n\nend",
"def compute\n @sequence.empty? and return []\n last_r = -Infinity\n min = @sequence.min\n max = @sequence.max\n step = (max - min) / bins.to_f\n Array.new(bins) do |i|\n l = min + i * step\n r = min + (i + 1) * step\n c = 0\n @sequence.each do |x|\n x > last_r and (x <= r || i == bins - 1) and c += 1\n end\n last_r = r\n Bin.new(l, r, c)\n end\n end",
"def next\n if @bucket and entry = @bucket[1]\n @bucket = nil\n return entry\n end\n\n while (@index += 1) < @maximum\n if @bucket = @entries[@index]\n return @bucket[0]\n end\n entry = @entries[@index]\n return entry if entry\n end\n end",
"def big_shoe_rebounds\n\nnew_array = []\nsize = 0\nrebounds = 0\n\n game_hash.each do |side, value|\n value[:players].each do |name, stats|\nif stats[:shoe] > size\n size = stats[:shoe]\n rebounds = stats[:rebounds]\n new_array[0] = name\n new_array[1] = stats[:shoe]\n new_array[2] = stats[:rebounds]\n\nend\n\nend\nend\n return new_array.last\n\n\nend",
"def add(value)\n # The include?(value) iterates through each element of the array till it finds the value in Array\n # So the complexity is O(n) in the worst case (value is not in array)\n # If we are here the @values have n elements already sorted\n # So is more efficient use a binary search for check if value is on array\n # Using binary search we can get:\n # - a O(log(n)) in the worst case (looking for a value already contained the array)\n # - a O(1) in the best case (looking for a value not contained in the array yet)\n # Finally using binary search we can have\n # - if the value is not in array a total time complexity of O(log(n)) + O(n*log(n))\n # - if the value is in array a total time complexity of O(1)\n if include?(value)\n false\n else\n # Complexity of adding value with the << operator is O(1)\n @values << value\n # Ruby use a Quicksort With Median of Three Pivot selection for sort method\n # The complexity of quicksort in the average case is O(n*log(n))\n @values.sort!\n true\n end\n end",
"def rehash\n buckets.compact.each do |key, value|\n insert(key, value)\n end\n end",
"def low_budget_mines (wat)\n @arr = Array.new\n wat.each do |this|\n if this[:annual_budget].to_i < 1000000\n @arr.push(this[:location])\n end\n end\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def next(price)\n i = @array.bsearch_index { |ele| ele > price } || @array.size\n @array.insert(i, price)\n @index.insert(i, @k)\n @k += 1\n maxi = @index[i+1..-1].max\n maxi.nil? ? @array.size : @k - maxi - 1\n end",
"def __add_keys_to(set) # used by parser # [\n lim = @_st_tableSize\n lim = lim + lim\n kofs = 0\n while kofs < lim\n k = self.__at(kofs)\n if k._not_equal?(RemoteNil)\n set.add(k) # k,v pair\n else\n v = self.__at(kofs + 1)\n if v._not_equal?(RemoteNil)\n if v._isFixnum\n # internal collision chain\n idx = v\n begin\n ck = self.__at(idx)\n if ck._not_equal?(RemoteNil)\n set.add(ck)\n end\n idx = self.__at(idx + 2)\n end while idx._isFixnum\n else\n # a collision bucket , which is a small Hash \n v.__add_keys_to(set)\n end\n end\n end\n kofs += 2\n end\n end",
"def bisect\n entry_set_A = self.class.new(@entries[0, (@entries.length / 2)])\n entry_set_B = self.class.new(@entries[(@entries.length / 2), @entries.length])\n [entry_set_A, entry_set_B]\n end",
"def caterpillar_method\n result=[]\n i=0\n while(i<self.size/2)\n j=i+1\n while (self[j] && (yield self[i],self[j]))\n result<<[self[i],self[j]]\n j+=1\n end\n i+=1\n end\n return result\n end",
"def << data\n\n # Update min/max\n if 0 == @count\n @min = data\n @max = data\n else\n @max = data if data > @max\n @min = data if data < @min\n end\n\n # Update the running info\n @count += 1\n @sum += data\n @sum2 += (data * data)\n\n # Update the bucket\n @buckets[to_index(data)] += 1 unless outlier?(data)\n end",
"def minimum_bucket(value_to_add)\n candidate_buckets = if @max_size == 1\n @buckets.select(&:empty?)\n else\n @buckets.reject do |bucket|\n # Already over max bucket size\n value_of_bucket(bucket) >= @max_value ||\n # Too many articles\n bucket.size >= @max_size ||\n # Would go over size too much (unless this is the only article)\n (!bucket.empty? && value_of_bucket(bucket) + value_to_add >= @max_value + DEFAULT_VALUE)\n end\n end\n\n # If we have no candidate buckets, we've exhausted all current buckets, so add another\n # Candidate buckets will now be all buckets. The min_by function below will get the empty bucket\n if candidate_buckets.empty?\n @buckets << []\n candidate_buckets = @buckets\n end\n\n candidate_buckets.min_by { |bucket| value_of_bucket(bucket) }\n end",
"def find_unsorted_subarray(nums)\n \nend",
"def bfs(g,s)\r\n q = []\r\n dists = Hash.new(Float::INFINITY)\r\n curr = s\r\n dists[curr] = 0\r\n \r\n #q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }\r\n g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}\r\n while q.size > 0\r\n \tprev,curr = q.shift\r\n dists[curr] = [6 + dists[prev],dists[curr]].min\r\n #q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }\r\n g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}\r\n #prev,curr = q.shift\r\n end\r\n \r\n return dists\r\nend",
"def build_heap(array)\n first_parent_index = (array.length - 2) / 2\n (first_parent_index..0).each do |current_index|\n sift_down(current_index, array.length - 1, array)\n end\n end",
"def optimize(ary, total)\n return [] if ary.empty?\n table = []\n (ary.size+1).times { |i| table[i] = [] }\n (0..total).each { |zerg| table[0][zerg] = 0 }\n (1..ary.size).each do |base|\n table[base][0] = 0\n (1..total).each do |zerg|\n if ary[base-1].zerg <= zerg && (ary[base-1].minerals + table[base-1][zerg - ary[base-1].zerg] > table[base-1][zerg])\n table[base][zerg] = ary[base-1].minerals + table[base-1][zerg - ary[base-1][1]]\n else\n table[base][zerg] = table[base-1][zerg]\n end\n end\n end\n result = []\n i, k = ary.size, total\n while i > 0 && k > 0\n if table[i][k] != table[i-1][k]\n result << ary[i-1]\n k -= ary[i-1].zerg\n end\n i -= 1\n end\n result\nend",
"def compute\n @sequence.empty? and return []\n last_r = -Infinity\n min = @sequence.min\n max = @sequence.max\n step = (max - min) / bins.to_f\n Array.new(bins) do |i|\n l = min + i * step\n r = min + (i + 1) * step\n c = 0\n @sequence.each do |x|\n x > last_r and (x <= r || i == bins - 1) and c += 1\n end\n last_r = r\n [ l, c, r ]\n end\n end",
"def josephus_survivor(n,k)\n # (1..n) people are put into the circle\n items = (1..n).to_a\n Array.new(n){items.rotate!(k-1).shift}.last\nend",
"def bad_contig_subsum(arr)\n # n! || n^3 ?\n sub_arrays = []\n arr.each_index do |i|\n (i...arr.length).each do |j|\n sub_arrays << arr[i..j]\n end\n end\n\n # above * n^2 ? << bottleneck\n max = sub_arrays.first.inject(&:+)\n sub_arrays.each do |sub_arr|\n sub_sum = sub_arr.inject(&:+)\n max = sub_sum if sub_sum > max\n end\n max\nend",
"def sort2(arr, upper_bound)\n hash = {}\n result = []\n arr.each { |el| hash[el] = true }\n (1..upper_bound).each do |el|\n result << el if hash[el]\n end \n p result \nend",
"def key_indexed_counting(arr, max)\n count = Array.new(max + 1, 0)\n\n arr.each { |num| count[num + 1] += 1 }\n idx = 0\n while idx < max\n count[idx + 1] += count[idx]\n idx += 1\n end\n\n aux = []\n arr.each do |num|\n aux[count[num]] = num\n count[num] += 1\n end\n\n arr.each_index do |idx|\n arr[idx] = aux[idx]\n end\n\n arr\nend",
"def add(bucket, obj)\n @buffer[bucket] << obj\n check_and_write bucket\n end",
"def compute_buckets(accumulated_distances, points, precision, &block)\n paired_distances_and_points = accumulated_distances.zip(points)\n # hash time points in the same distance buckets with a precision of one fractional digit\n intervals = {}\n paired_distances_and_points.each do |(distance_m, point)|\n distance_km = distance_m / 1000.to_f\n intervals[distance_km.round(precision)] ||= []\n intervals[distance_km.round(precision)] << [distance_m, point.time]\n end\n\n buckets = {}\n begin\n intervals.each do |key, a_list|\n first_distance_m, first_time = a_list.first\n second_distance_m, second_time = a_list.last\n dx_m = second_distance_m - first_distance_m\n dt_seconds = second_time - first_time\n value = block.call dx_m, dt_seconds\n buckets[key] = value if !value.nil? #ignore nil values\n raise 'Error' if !value.nil? && !(value < Float::INFINITY)\n end\n rescue => e\n raise e #TODO: remove this line\n buckets = Hash.new\n end\n buckets\n end",
"def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend",
"def check_the_bucket(bucket)\n bucket.include? 'gold'\nend",
"def get_size\n @buckets.length\n end",
"def next_value(value, array)\n i = value > 0 ? 0 : 1\n index = value == -1 ? 1 : false\n sum = 0\n while i < 100\n if array[i].abs <= value.abs\n sum += array[i].abs\n i += 2\n index = i\n next\n end\n method = sum >= value.abs ? :sum : :cut\n return [index, method]\n end\n method = sum >= value.abs ? :sum : :cut\n return [index, method]\nend",
"def visit_all_rooms?(array) \n visited = {}\n queue = [] \n\n first = array.shift \n\n \n first.each do |key|\n queue << key //3, 0\n end\n\n\n # O(n) * o(m) => O(nm)\n while queue.length > 0 //O(n)\n current_key = queue.shift\n visited[current_key] = true\n array[current_key].each do |key| \n queue << key unless visited[key] == false // 3,0,1 \n end\n end\n\n visited.keys.length == array.length\n\nend",
"def buckets=(value)\n @buckets = value\n end",
"def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\nend",
"def median_maintain(array)\n max_heap = []\n min_heap = []\n if array[0] > array[1]\n max_heap = [array[1]]\n min_heap = [array[0]]\n else\n max_heap = [array[0]]\n min_heap = [array[1]]\n end\n m = [array[0], max_heap[0]]\n (2..array.count - 1).each do |i|\n if array[i] > max_heap[0]\n min_heap << array[i]\n balance_min(min_heap, min_heap.count - 1)\n if min_heap.count > max_heap.count + 1\n max_heap << min_heap[0]\n extract_min(min_heap)\n balance_max(max_heap, max_heap.count - 1)\n end\n else\n max_heap << array[i]\n balance_max(max_heap, max_heap.count - 1)\n if max_heap.count > min_heap.count + 1\n min_heap << max_heap[0]\n extract_max(max_heap)\n balance_min(min_heap, min_heap.count - 1)\n end\n end\n m << if max_heap.count == min_heap.count\n max_heap[0]\n elsif max_heap.count > min_heap.count\n max_heap[0]\n else\n min_heap[0]\n end\n end\n sum = 0\n (0..m.count - 1).each do |i|\n sum += m[i]\n end\n sum % 10_000\nend",
"def initialize\n @buckets = {}\n end",
"def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end"
] | [
"0.6758928",
"0.67467326",
"0.6646215",
"0.6583308",
"0.654688",
"0.6154582",
"0.6138802",
"0.60570073",
"0.5965968",
"0.5960513",
"0.59391284",
"0.5934266",
"0.5876404",
"0.58067745",
"0.5777012",
"0.57595503",
"0.571151",
"0.5674974",
"0.5659087",
"0.56243217",
"0.5559785",
"0.5559564",
"0.5557884",
"0.5554893",
"0.55239457",
"0.5514749",
"0.55040866",
"0.54945827",
"0.5486978",
"0.54459536",
"0.5442325",
"0.5441546",
"0.54233545",
"0.53925264",
"0.5386464",
"0.53838116",
"0.5380182",
"0.53765",
"0.5364342",
"0.536379",
"0.5359632",
"0.53340715",
"0.5331982",
"0.53277814",
"0.532609",
"0.5311042",
"0.5304871",
"0.5303478",
"0.52999586",
"0.52907574",
"0.52825457",
"0.5278713",
"0.5273231",
"0.52706707",
"0.52681285",
"0.5262311",
"0.52611846",
"0.5260534",
"0.5250538",
"0.52500606",
"0.5247805",
"0.52408254",
"0.52349865",
"0.523152",
"0.52305907",
"0.5228879",
"0.52203727",
"0.52167016",
"0.5214061",
"0.5213037",
"0.5204474",
"0.5200246",
"0.5197935",
"0.5193128",
"0.51886123",
"0.5187622",
"0.5187526",
"0.5185373",
"0.5174061",
"0.5173607",
"0.5162892",
"0.51624095",
"0.51601774",
"0.5154363",
"0.5153576",
"0.5152016",
"0.5141695",
"0.51333314",
"0.5132778",
"0.5131705",
"0.5125984",
"0.51231635",
"0.512121",
"0.511972",
"0.51155955",
"0.5109087",
"0.510508",
"0.5098015",
"0.5097443",
"0.50890225",
"0.50874484"
] | 0.0 | -1 |
O(n) same here, that darn include? method | def remove(num)
self[num].delete(num) if include?(num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def include?(arr, value)\n includes = false\n arr.each { |n| includes = true if n == value }\n includes\nend",
"def include?(position); end",
"def el_include(el)\n @cache.each_with_index do |el2, idx|\n return idx if el == el2\n end\n nil\n end",
"def include?(ary, value)\n !!ary.index(value)\nend",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def my_include?(array, target)\n return false if array.empty?\n return true if array.first == target\n my_include?(array.drop(1), target)\nend",
"def includes?(array, target)\n #empty array does not contain object\n return false if array == []\n\n #start with array[3]\n value = array.shift #pluck off\n if value == target\n true #the recursive call is not made\n else\n includes?(array, target)\n end\n\nend",
"def include?(obj)\n n = 0\n lim = self.__size\n while n < lim\n if self.__at(n) == obj\n return true\n end\n n += 1\n end\n false\n end",
"def includes?(array, target)\n if array.empty?\n false\n elsif array.first == target\n true\n else\n includes?(array.drop(1),target)\n end\nend",
"def include?(other)\n `return self.indexOf(other) == -1 ? Qfalse : Qtrue;`\n end",
"def include?(other)\n `return self.indexOf(other) == -1 ? Qfalse : Qtrue;`\n end",
"def include?(array, query)\n array.each do |el|\n return true if el == query\n end\n false\nend",
"def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend",
"def using_include(array, element)\n\tarray.include?(element)\nend",
"def include?(array, value)\n !!array.find_index(value)\nend",
"def include?(array, value)\n !!array.find_index(value)\nend",
"def included_once(haystack, needle)\n count = 0\n for hay in haystack\n if hay == needle\n count += 1\n end\n # if count > 2\n # break\n # end\n end\n count == 1\nend",
"def include?(list, search)\n !!list.find_index(search)\nend",
"def b_include?(obj) # assumes the array is sorted\n range = bsearch_range { |x| x <=> obj } # returned range excludes its last element\n (self[range.first] == obj or self[range.last - 1] == obj)\n end",
"def include?(o)\n @hash.include?(o)\n end",
"def include?(o)\n @hash[o]\n end",
"def include?(el)\n @cache.include?(el)\n end",
"def include?(ary, target)\n !ary.select { |value| value == target }.empty?\nend",
"def includedOnce(haystack, needle)\n \n counter = haystack.count { |x| x == needle}\n if counter == 1\n return true\n elsif counter > 1\n return false\n else\n return false\n end\n \nend",
"def add?(o)\n if include?(o)\n nil\n else\n add(o)\n end\n end",
"def add?(o)\n if include?(o)\n nil\n else\n add(o)\n end\n end",
"def include?(element)\n @ary.include? element\n end",
"def include?(array, value)\r\n array.count(value) > 0\r\nend",
"def include?(arr, val)\n arr.each { |el| return el == val if el == val }\n false\nend",
"def include?(o)\n @mut.synchronize{@array.include?(o)}\n end",
"def include?(element)\n @que.include?(element)\n end",
"def include?(something); end",
"def add(value)\n # The include?(value) iterates through each element of the array till it finds the value in Array\n # So the complexity is O(n) in the worst case (value is not in array)\n # If we are here the @values have n elements already sorted\n # So is more efficient use a binary search for check if value is on array\n # Using binary search we can get:\n # - a O(log(n)) in the worst case (looking for a value already contained the array)\n # - a O(1) in the best case (looking for a value not contained in the array yet)\n # Finally using binary search we can have\n # - if the value is not in array a total time complexity of O(log(n)) + O(n*log(n))\n # - if the value is in array a total time complexity of O(1)\n if include?(value)\n false\n else\n # Complexity of adding value with the << operator is O(1)\n @values << value\n # Ruby use a Quicksort With Median of Three Pivot selection for sort method\n # The complexity of quicksort in the average case is O(n*log(n))\n @values.sort!\n true\n end\n end",
"def include?(key); end",
"def include?(key); end",
"def fast_hash_additive_find(arr, target)\n lookup_table = Hash.new\n\n arr.each do |element|\n return true if lookup_table[target - element]\n if lookup_table[element]\n lookup_table[element] += 1\n else\n lookup_table[element] = 1\n end\n end\n\n return false\n end",
"def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend",
"def include?(array, search_value)\n # array.each do |element|\n # return true if element == search_value\n # end\n # false\n array.count(search_value) > 0\nend",
"def include?(x)\n inf <= x && x <= sup\n end",
"def include?(arr, num)\n arr.each{ |element| return true if element == num}\n return false\nend",
"def refute_includes(collection, obj, msg = T.unsafe(nil)); end",
"def include?(arr, search)\n result = false\n arr.each { |num| result = true if num == search }\n result\nend",
"def cache_intersection2(nums1, nums2)\n outer_cache = {}\n nums1.each do |n|\n next if outer_cache[n]\n outer_cache[n] = true\n end\n array = []\n inner_cache = {}\n nums2.each do |n|\n next if inner_cache[n]\n array << n if outer_cache[n]\n inner_cache[n] = true\n end\n array\nend",
"def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend",
"def include?(arr, value)\n !(arr.select { |element| element == value }).empty?\nend",
"def includes?(array, target)\n return false if array.empty?\n return true if array.first == target\n includes?(array[1..-1])\nend",
"def include?(key)\n is_array = Array.try_convert(key) ? true : false\n arr_key = is_array ? key : [key]\n hsh_key = {}\n\n arr_key.each do |k|\n indexes = []\n indexes_for(k) { |idx| indexes << idx }\n hsh_key[k.to_s] = {key: k, future: [], included: true, indexes: indexes}\n end\n\n # if the first bit returned from redis is 0 we don't look at this any further?\n @redis.pipelined do\n hsh_key.each_pair do |k,v|\n v[:future][0] = @redis.getbit(@options[:key_name], v[:indexes].shift)\n end\n end\n\n @redis.pipelined do\n hsh_key.each_pair do |k,v|\n # filter all that are 0\n # 0 means this element is not within the bloomfilter, no need for further lookup\n next if v[:future][0].value == 0\n v[:indexes].each_with_index do |idx, i|\n v[:future][i+1] = @redis.getbit(@options[:key_name], idx)\n end\n end\n end\n\n in_filter = []\n hsh_key.each_pair do |k,v|\n # if we have a zero in our result array we (most likely) havent seen this value yet\n # if we don't have a zero in our result array we (most likely) have seen this value already\n in_filter << k unless v[:future].map{|f|f.value}.include?(0)\n end\n\n unless is_array\n if in_filter.length == 1\n return true\n else\n return false\n end\n end\n\n return in_filter\n end",
"def include? item\n @succ.include? item\n end",
"def include?(ary, value)\r\n ary.select{ |obj| obj == value } != []\r\nend",
"def includes?(array, target)\n return false if array.empty?\n return true if array.first == target\n includes?(array.drop(1), target)\nend",
"def includes?(array, target)\n \n if array.empty?\n return false\n end\n \n if array[-1] == target\n return true\n else\n return includes?(array[0...-1], target)\n end\n\nend",
"def include? object\n !!find(object)\n end",
"def my_min1(arr)\n arr.each do |el1| #O(n)\n if arr.all? {|el2| el1 <= el2 } #O(n + 1)\n return el1\n end\n end \nend",
"def does_list_include?(array, obj)\n array.count(obj) > 0\nend",
"def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend",
"def not_include?(element)\n !include?(element)\n end",
"def include?(array, value)\n array.each { |element| return true if value == element }\n false\nend",
"def include?(array, search_value)\n array.count(search_value) > 0\nend",
"def not_include?(element)\n !self.include?(element)\n end",
"def includes?(array, target)\n return false if array.length <= 0\n return true if array[0] == target\n includes?(array[1..-1], target)\nend",
"def include?(array, value)\n # https://ruby-doc.com/core-2.7.2/Array.html#method-i-find_index\n !!array.find_index(value)\nend",
"def includes?(array, target)\n return true if array.first == target\n return false if array.empty?\n includes?(array.drop(1), target)\nend",
"def include?(array, value)\n array.each do |elem|\n return true if elem == value\n end\n false\nend",
"def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend",
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def cache_intersection(nums1, nums2)\n array = []\n outer_cache = {}\n inner_cache = {}\n nums1.each do |outer|\n next if outer_cache[outer]\n outer_cache[outer] = true\n nums2.each do |inner| \n next if inner_cache[inner]\n if outer == inner \n array << inner\n inner_cache[inner] = true\n end\n end\n end\n array\nend",
"def include?(array, value)\n array.any?(value)\nend",
"def include?(x)\n @indices[x] # huh\n end",
"def include?(arr, target)\n arr.any?{ |ele| ele == target} ? true : false\nend",
"def canBeSum(n, array, cache)\n\ti = 0\n\twhile array[i] <= n / 2\n\t\tif cache[n-array[i]] # array.include?(n-array[i]) is OK, but very slow\n\t\t\treturn true\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn false\nend",
"def not_included(arr) \n hash = Hash.new(0)\n arr.each { |el| hash[el] = 0 }\n i = 1\n # hash[5] == 0\n while true\n return i unless hash.has_key?(i)\n i += 1\n end\nend",
"def include?(el)\n store.include?(el)\n end",
"def include?(key)\n is_array = Array.try_convert(key) ? true : false\n arr_key = is_array ? key : [key]\n hsh_key = {}\n\n arr_key.each do |k|\n hsh_key[k] = {key: k, future: [], indexes: indexes_for(k) }\n end\n\n # if the first bit returned from redis is 0 we don't look at this any further?\n @redis.pipelined do\n hsh_key.each_pair do |k,v|\n v[:future][0] = @redis.getbit(@options[:key_name], v[:indexes].shift)\n end\n end\n\n @redis.pipelined do\n hsh_key.each_pair do |k,v|\n # filter all that are 0\n # 0 means this element is not within the bloomfilter, no need for further lookup\n next if v[:future][0].value == 0\n v[:indexes].each_with_index do |idx, i|\n v[:future][i+1] = @redis.getbit(@options[:key_name], idx)\n end\n end\n end\n\n in_filter = []\n hsh_key.each_pair do |k,v|\n # if we have a zero in our result array we (most likely) havent seen this value yet\n # if we don't have a zero in our result array we (most likely) have seen this value already\n in_filter << k unless v[:future].map{|f|f.value}.include?(0)\n end\n\n # handle single element case\n unless is_array\n if in_filter.length == 1\n return true\n else\n return false\n end\n end\n\n return in_filter\n end",
"def optimize\n left.left.include(merged_right_enumerables).optimize\n end",
"def include?(array, search_value)\n if array.count(search_value) == 1\n return true\n else\n return false\n end\nend",
"def include?(array, arg)\n boolean_return = false\n array.each {|value| return boolean_return = true if value == arg}\n boolean_return\nend",
"def includes?(array, target)\n return false if array.empty?\n return true if array.first == target\n includes?(array.drop(1), target)\nend",
"def include?(arg0)\n end",
"def include?(array, value)\n array.each do |integer|\n return true if integer == value\n end\n return false\nend",
"def contains?(other); end",
"def contains?(other); end",
"def contains?(other); end",
"def cont? x, y\n y == x.end + 1\nend",
"def magic?(arr)\n n = arr.size / 2\n (0...n).map { |i| (arr[i] + arr[i + 1 < n ? i + 1 : 0] + arr[n + i]) }.reduce { |s, memo| s == memo ? memo : false }\nend",
"def include?(arr, search)\n arr.each do |element|\n if element == search\n return true\n end\n end\n false\nend",
"def include?(list,tst)\n list.each {|itm| return true if itm == tst}\n false\nend",
"def include?(arr, search_value)\n arr.each do |num|\n if num == search_value\n return true\n end\n end\n false\nend",
"def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend",
"def includes?(array, target)\n return true if array[0] == target\n return false if array[0] != target && array.length <= 1\n\n includes?(array.drop(1), target)\nend",
"def include?(other)\n set_indexes.sort & other.set_indexes.sort == other.set_indexes.sort\n end",
"def naive(a, target)\n\ta.each do |ie, i|\n\t\ta.each do |je, j|\n\t\t\tnext if i == j # cant be the same, i assume\n\t\t\treturn true if ie + je == target\n\t\tend\n\tend\n\treturn false\nend",
"def include\n -> x, v { x.include?(v) }.curry\n end",
"def includes?(array, target)\n return false if array.empty?\n \n return true if array[0] == target\n\n includes?(array[1..-1], target)\nend",
"def include?(arr, number)\n arr.any? { |num| num == number }\nend",
"def hit_itself?\n # list.uniq removes all repeated elements from a list\n @positions.uniq.length != @positions.length\n end",
"def include?(arr, search)\n arr.any? { |i| i == search }\nend"
] | [
"0.6068663",
"0.59994394",
"0.58974713",
"0.5889515",
"0.58879215",
"0.5887838",
"0.5887838",
"0.5887838",
"0.5887838",
"0.5887838",
"0.5861198",
"0.5856517",
"0.58524776",
"0.5730106",
"0.57045865",
"0.57045865",
"0.5688149",
"0.5680672",
"0.56793",
"0.5677134",
"0.5677134",
"0.56738687",
"0.5672812",
"0.56700677",
"0.5668793",
"0.56567",
"0.56551874",
"0.56542563",
"0.5641867",
"0.5638441",
"0.5638441",
"0.5628742",
"0.5618875",
"0.5614458",
"0.5610964",
"0.56045306",
"0.559782",
"0.5596047",
"0.55856025",
"0.55856025",
"0.55779624",
"0.557653",
"0.5572386",
"0.55685383",
"0.5565896",
"0.55503845",
"0.5536074",
"0.55334246",
"0.5523385",
"0.5516319",
"0.55150175",
"0.5510408",
"0.54950595",
"0.54883254",
"0.54865676",
"0.54759943",
"0.5472386",
"0.54653025",
"0.5464115",
"0.5460095",
"0.54568017",
"0.5452887",
"0.5452311",
"0.54426265",
"0.5434673",
"0.5433328",
"0.5428321",
"0.5428142",
"0.542691",
"0.54110086",
"0.54087204",
"0.5402458",
"0.54024184",
"0.53969574",
"0.53889304",
"0.5388865",
"0.53858685",
"0.5375538",
"0.5374592",
"0.5370165",
"0.535773",
"0.5357243",
"0.53534985",
"0.534728",
"0.5345545",
"0.5345545",
"0.5345545",
"0.5342178",
"0.53420097",
"0.53281003",
"0.5326718",
"0.5325019",
"0.5324741",
"0.5322108",
"0.5320963",
"0.53171194",
"0.5316267",
"0.5315693",
"0.5309634",
"0.5305624",
"0.529825"
] | 0.0 | -1 |
O(n) the source of our problems | def include?(num)
self[num].include?(num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend",
"def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end",
"def problem_106\n a = [1,2,3,4]\n a = [1,2,3,4,5,6,7]\n a = [1,2,3,4,5,6,7,8,9,10,11,12] \n \n num = 0\n seen = {}\n # Don't do length of 1, they are ordered\n # Because they are size ordered, and 2 smalls are bigger than a large\n 2.upto(a.length/2) do |n|\n puts \"n = #{n}\"\n a.combination(n) do |set_a|\n b = a - set_a\n break if b.length < n\n b.combination(n) do |set_b|\n key = [set_a,set_b].sort\n next if seen[key]\n seen[key] = true\n index = 0\n state = 0\n 0.upto(set_a.length-1) do |i|\n break unless set_b[i] && set_a[i]\n if set_a[i] < set_b[i]\n state -= 1\n else\n state += 1\n end\n end\n\n# print \"#{set_a.inspect} #{set_b.inspect} #{state}\"\n if state.abs <= (set_a.length - 2) ||\n (state < 0 && set_a.last > set_b.last) ||\n (state > 0 && set_a.first < set_b.first)\n# puts \" good\"\n num += 1\n else\n# puts \"\"\n end\n end\n end\n end\n num\nend",
"def solve( n = 100 )\n n.partition_sieve[-1] - 1\n end",
"def hint(workingSet)\n setFound = false\n for i in workingSet\n for j in workingSet\n for k in workingSet\n if(!(i == k || j == k || i == k))\n setFound = VerifySet?(i,j,k)\n if(setFound)\n return i\n break\n end\n end\n end\n end\n end\n if(setFound == false)\n return nil\n end\nend",
"def recursive_solution\n\n end",
"def hureistic_search (board) #open useful in finding min conflicts\n end",
"def problem_108(size = 1001)\n func = lambda do |a|\n if a.length == 1\n a[0]+1\n else\n m = a[0]\n (2*m+1) * func.call(a[1,a.length]) -m\n end\n end\n\n primes = Primes.upto(200)\n prime_number = lambda do |a|\n r = 1\n a.sort.reverse.each_with_index { |m,i| r *= primes[i] ** m }\n r\n end\n\n values = {}\n last = 0\n 1.upto(100).each do |nn|\n nn.groupings do |a|\n sols = func.call a\n ans = prime_number.call a\n# puts \"np=#{nn} sols=#{sols} ans=#{ans} => #{a.inspect}\"\n if values[sols]\n values[sols] = [values[sols],[ans,a]].min\n else\n values[sols] = [ans,a]\n end\n true\n end\n size.upto(size*5/4) do |num|\n if values[num]\n puts \"for np = #{nn} => #{num} => #{values[num].inspect}\"\n if last == values[num]\n puts \"factors = #{values[num][0].factors}\"\n return values[num][0] \n end\n last = values[num]\n break\n end\n end\n #values.sort.each do |k,v|\n # puts \"#{k} => #{v}\"\n #end\n end\n nil\nend",
"def solution(x, a)\n count = 1\n indices = []\n while count <= x\n indices << a.find_index(count)\n count += 1\n end\n\n if indices.include?(nil)\n -1\n else\n indices.sort.last\n end\nend",
"def solve_again_with_issues(array, sum)\n result = {}\n freq = {}\n count = 0\n\n array.each do |el|\n freq[el] ? freq[el] += 1 : freq[el] = 1\n end\n\n array.each do |el|\n if freq[sum - el] && !result[sum - el]\n count += freq[sum - el]\n end\n end\n count/2\nend",
"def solveProblem lst\n big = -1\n numbers = {}\n half = lst.length / 2\n lst.each do |i|\n if numbers.has_key?(i) then\n numbers[i] += 1\n else\n numbers[i] = 1\n end\n if numbers[i] > half then return i end\n end\n return big\nend",
"def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend",
"def find_pair\n before = self.entropy\n reduce_pair_line\n reduce_pair_col\n reduce_pair_grid\n reduce_solved if before > self.entropy\n self\n end",
"def brute_force_optimal(tg,faulty,replacements,n)\n if tg[1].size == 0 # special case if there are no edges(all replacements are equal)\n return get_mappings(faulty,replacements)[0] # return the first mapping\n end\n get_mappings(faulty,replacements).min_by do |a|\n euclidean_distance(tg,a,n) \n end\nend",
"def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend",
"def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend",
"def problem_76a\n num = 100\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n puts 1 + solve.call([1] * num, 0,num-1)\nend",
"def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend",
"def problem_60\n prime_check = lambda do |a,b|\n (a + b).to_i.prime? && (b + a).to_i.prime?\n end\n\n find_match = lambda do |a,k|\n r = a.select {|p| k != p && prime_check.call(k,p) }\n end\n\n primes = Primes.upto(10_000).map(&:to_s)\n primes.delete(\"2\")\n\n hit = {}\n\n primes.each do |p1|\n p1a = find_match.call(primes,p1)\n p1a.each do |p2|\n p2a = find_match.call(p1a,p2)\n p2a.each do |p3|\n p3a = find_match.call(p2a,p2)\n p3a.each do |p3|\n p4a = find_match.call(p3a,p3)\n p4a.each do |p4|\n p5a = find_match.call(p4a,p4)\n if p5a.length > 0\n p5a.each do |p5|\n a = [p1,p2,p3,p4,p5]\n sum = a.map(&:to_i).reduce(&:+)\n unless hit[sum]\n puts \"#{sum} #{a.inspect}\"\n else\n hit[sum] = true\n end\n return sum\n end\n end\n end\n end\n end\n end\n end\nend",
"def solutions(a)\r\n\r\n ary = a.sort\r\n ary.each_with_index do |num, index|\r\n if ary[index+1] != num + 1 && index != ary.length-1\r\n return num + 1\r\n end\r\n end\r\n\r\nend",
"def solution(a)\n a.uniq.count\nend",
"def solve\n end",
"def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\nend",
"def valid_sudoku(table)\n # seen_set = Set.new()\n # for i in \nend",
"def solve\n\t\t# Attempt to find a mismatch in start/end\n\t\t# letters in the maps. This signifies first\n\t\t# and last words of the solution\n\t\tdiff_list = []\n\t\t@start_map.each {|k,v|\n\t\t\tr = @end_map[k]\n\t\t\tdiff = r-v\n\t\t\tputs \"#{k} => #{v} | #{r} diff #{diff}\"\n\t\t\t\n\t\t\t# If values in map don't match, remember this\n\t\t\tif diff != 0\n\t\t\t\tdiff_list << diff\n\t\t\tend\n\t\t}\n\n\t\t# Ensure the matchings satisfy the properties of\n\t\t# and solvable puzzle. If there are \n\t\tputs diff_list\n\t\tif diff_list.size == 0\n\t\t\t# This means there are cycles (multiple\n\t\t\t# choices for the first word).\n\t\telsif diff_list.size == 2\n\t\t\t# Ensure there is exactly one starting\n\t\t\t# word and exactly one ending word\n\t\t\treturn [] if !diff_list.include?( 1 )\n\t\t\treturn [] if !diff_list.include?( -1 )\n\t\telse\n\t\t\t# This signifies an unsolvable puzzle\n\t\t\tputs \"Not Solvable\"\n\t\t\treturn []\n\t\tend\n\n\t\t# The characteristics of this word list look\n\t\t# good so far. Let's now try to enumerate the\n\t\t# solution array\n\t\treturn enumerate_solution\n end",
"def checkmate(k,a)\n # Checkmate test where king may be: k_attacks - used - king_attaks - cells_behind_the_king\n all = all_position\n p used = [k,a]\n k_attacks = king_position(k).uniq \n a_attacks = (amazon_postion(a) - free_cells(k,a)).uniq\n stand_positions = a_attacks - k_attacks - used\n safe_squares = (all - k_attacks - a_attacks - used).uniq\n ans = stand_positions.reduce([]){ |acc,x| \n if (safe_squares & king_position(x)).empty?\n p x\n acc.push(x) \n end\n acc\n }\n p ans\n ans.size\n \nend",
"def min_ops(n)\n\n # Step 1:\n # Create a table containing the minimum operations\n # needed to reach n given our permitted operators.\n all_parents = Array.new\n all_min_ops = [0] + [nil] * n\n\n (1..n+1).each do |k|\n curr_parent = k - 1\n curr_min_ops = all_min_ops[curr_parent] + 1\n [2, 3].each do |i|\n if k % i == 0\n parent = k / i\n num_ops = all_min_ops[parent] + 1\n if num_ops < curr_min_ops\n curr_parent, curr_min_ops = parent, num_ops\n end\n end\n end\n all_parents[k], all_min_ops[k] = curr_parent, curr_min_ops\n end\n\n # Step 2: Trace back to find the optimal choices\n # made in the previous step.\n numbers = Array.new\n k = n\n while k > 0\n numbers << k\n k = all_parents[k]\n end\n puts numbers.size - 1\n numbers.reverse\nend",
"def solve\n a = Time.new\n for i in 0..@itemsSize - 1\n @table[0][i] = 0\n end\n \n for i in 1..@itemsSize - 1\n price = @problem.prices[i-1]\n weight = @problem.weights[i-1]\n for w in 1..@weights - 1\n if weight <= w\n if (price + @table[w - weight][i - 1]) > @table[w][i -1]\n @table [w][i]= price + @table[w - weight][i - 1]\n else\n @table[w][i] = @table[w][i - 1]\n end\n else\n @table[w][i] = @table[w][i - 1]\n end\n end\n end\n \n \n prev_item = 0\n for i in 1..@itemsSize - 1\n curr_item = @table[@weights - 1][i]\n if prev_item < curr_item\n @best_configuration.push(1)\n else\n @best_configuration.push(0)\n end\n prev_item = curr_item\n end\n \n @best_fitness = @table[@weights - 1][@itemsSize - 1]\n \n b = Time.new\n @time = b-a\n end",
"def problem_60a\n num_cut = 5\n# simple\n pairs = {}\n seen_primes = []\n num_primes = 0\n last = start = Time.now\n Primes.each do |p|\n next if p == 2\n b = p.to_s\n seen_primes.each_index do |sp_i|\n sp = seen_primes[sp_i]\n a = sp.to_s\n ai,bi = a.to_i,b.to_i\n ab = (a + b).to_i\n ba = (b + a).to_i\n\n if ba.prime? && ab.prime?\n # We have a pair that works both ways so add the peer to each prime\n pairs[ai] = aa = ((pairs[ai] || []) << bi).uniq\n pairs[bi] = bb = ((pairs[bi] || []) << ai).uniq\n next unless pairs[bi].length >= num_cut - 1 # bi is biggest of pair\n\n check = ([ai] + aa) & ([bi] + bb)\n if check.length >= num_cut\n puts \"Try #{check.inspect}\"\n perm = check.permutation(2).to_a\n new = perm.select do |x,y|\n (x.to_s + y.to_s).to_i.prime? && (x.to_s + y.to_s).to_i.prime?\n end\n if new.length == perm.length\n n = new.flatten.uniq\n sum = n.reduce(&:+)\n puts \"#{n.inspect} *** #{sum}\"\n return sum\n end\n end\n end\n end\n seen_primes << p\n end\n nil\nend",
"def solution\n\n return self if solved?\n\n while [hidden_singles, naked_singles].any?\n end\n\n return self if solved?\n\n\n # Brute force\n i = each_empty_cell.sort_by { |cell, n| legal_values(n).size }.first.try :last\n\n legal_values(i).map do |value|\n fill(i, value).solution\n end.compact.select { |n| n.solved? }.first\n end",
"def find_good_set(numbers,i)\n\treturn [] if i==0\n\twhile not numbers.empty?\n\t\tx = numbers.shift\n\t\ttest = find_good_set(numbers.find_all{|y| good_pair?(x,y)},i-1)\n\t\treturn [x]+test unless test == nil\n\tend\n\treturn nil\nend",
"def problem_14(*arr, **hash)\n if !hash.is_a? Hash\n arr << hash\n return count_clumps(arr)\n end\n\n if hash[:problem] == :same_ends\n n = arr.shift\n return same_ends(n, arr) \n else\n return count_clumps(arr)\n end\nend",
"def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend",
"def problem_76\n return 100.partitions - 1\nend",
"def solution(a)\n\traise ArgumentError.new(\"a has to be non empty array of max size #{MAX_LEN}\") if !a.is_a? Array or a.empty? or a.length > MAX_LEN\n\tret = 0\n\t#puts a.inspect\n\tmy_h = Hash.new\n\ta.each do |e|\n\t\tif my_h.include? e\n\t\t\tmy_h[e] += 1\n\t\telse\n\t\t\tmy_h[e] = 1\n\t\tend\n\tend\n\n\tmy_h_sort = my_h.sort_by {|k, v| -v}\n\t# -> my_h_sort[value][occurances]\n\treturn 0 if my_h_sort.first[1] < a.size/2\n\tleader_val = my_h_sort.first[0]\n\n\tocc_array = Array.new\n\toccurances = 0\n\ta.each do |e|\n\t\toccurances += 1 if e == leader_val\n\t\tocc_array.push(occurances)\n\tend\n\t#puts occ_array.inspect\n\n\tfor idx in (0...a.length-1) do\n\t\tsum1 = occ_array[idx]\n\t\tsum2 = occ_array.last - occ_array[idx]\n\n\t\t# puts \"#{idx}+1 < #{sum1*2}\"\n\t\t# puts \"#{(a.length - idx -1)} < #{(sum2*2 )} \"\n\n\t\tif (idx+1) < sum1 * 2 && (a.length - idx - 1 ) < sum2 * 2\n\t\t\t## we have a leader\n\t\t\t#puts \"YEAH #{idx}\"\n\t\t\tret += 1\n\t\tend\n\t\t\t#puts \"-------- ret: #{ret}\"\n\tend\n\treturn ret\nend",
"def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend",
"def solve\n perms = (1..9).to_a.permutation.map {|p| p.join}\n prods = []\n\n perms.each do |p|\n (1..2).each do |len|\n a, b, c = p[0, len].to_i, p[len..4].to_i, p[5, 4].to_i\n prods << c if a * b == c\n end\n end\n \n prods.uniq.reduce( :+ )\n end",
"def greedy(tg,faulty,replacements,n)\n result = Hash.new\n repl = Array.new(replacements.size) {|i| replacements[i]}\n # sort tg by # successors\n sort_by_subtree_size!(tg)\n\n # sort faulty by # successors\n faulty.sort_by!{|a| tg[0].index(lookup_task(tg,a))}\n \n faulty.each do |fault|\n # pick the replacement which minimizes starting time of fault\n choice = repl.min_by{|a| euclidean_distance(tg,result.merge({fault=>a}),n)}\n # add the mapping to the solution\n result[fault] = choice\n # remove the replacement from the set\n repl.delete(choice)\n end\n return result\nend",
"def step0(debug=false)\n\n # make sure we don't step beyond the solution\n return nil if done?\n\n t0 = Time.now\n @nb_iter += 1\n\n puts \"+++iteration #{@nb_iter}+++\" if debug\n puts \"nb problems = #{@pb_list.length}\" if debug\n\n best_pb = @pb_list.shift\n @rejected_grids.push(best_pb.grid)\n\n puts \"best problem:\" if debug\n puts best_pb.show_stats if debug\n\n if best_pb.min_depth == 1 then\n\n # we can create a problem with all the steps included at once\n new_steps = []\n best_pb.each_poss(1) do |poss|\n new_steps.push(Step.new(poss.row, poss.col, poss.first))\n end\n @nb_try += 1\n begin\n child = Sudoku.new(best_pb.grid, best_pb.steps, new_steps)\n #if the new problem is a dead-end, discard it\n if child.max_poss == 0 and not child.complete? then\n puts \"No solution possible for best problem, discard it\" if debug\n @rejected_grids.push(child.grid)\n @nb_discard += 1\n #avoid duplicates\n elsif @pb_list.include?(child)\n @nb_dup += 1\n elsif @rejected_grids.include?(child.grid)\n # this problem has been processed before\n @nb_discard += 1\n else\n @pb_list.push(child)\n end\n rescue RuntimeError\n # the combination of depth=1 solution caused a conflict\n puts \"Impossible solution for best problem, discard it\" if debug\n @nb_discard += 1\n end\n else\n\n # we need to create a new problem for each possibility\n best_pb.each_poss(best_pb.min_depth) do |poss|\n poss.each do |v|\n @nb_try += 1\n new_steps = [Step.new(poss.row, poss.col, v)]\n child = Sudoku.new(best_pb.grid, best_pb.steps, new_steps)\n #if the new problem is a dead-end, discard it\n if child.max_poss == 0 and not child.complete? then\n puts \"No solution possible for best problem, discard it\" if debug\n @rejected_grids.push(child.grid)\n @nb_discard += 1\n #avoid duplicates\n elsif @pb_list.include?(child)\n @nb_dup += 1\n elsif @rejected_grids.include?(child.grid)\n # this problem has been processed before\n @nb_discard += 1\n else\n @pb_list.push(child)\n end\n end\n end\n end\n\n # resort the list by max_poss / min_dof\n @pb_list.sort! do |x,y|\n res = x.max_poss <=> y.max_poss\n res = x.dof <=> y.dof if res == 0\n res\n end\n\n @duration += Time.now - t0\n\n #return the solution if we have one\n if @pb_list.empty? then\n return null\n else\n return @pb_list[0]\n end\n\n end",
"def minimize; end",
"def problem3 n\n 2.step(n,1).each do |x|\n return x-1 if n == 1\n n /= x if x.prime? && (n % x == 0)\n end\nend",
"def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend",
"def naive(set)\n solutions = []\n indexes = (0..set.size-1).to_a\n\n Backtracker.generate do\n candidates { |a| indexes - a }\n solution? { |a| a.size == set.size }\n found_solution do |a| \n solution = a.map { |i| set[i] } \n solutions << solution unless solutions.include? solution\n end\n end\n\n return solutions\nend",
"def getUniqueProblems(subms, val)\n\t\tproblems = []\n\t\tproblemsADay = {}\n\t\tsubms.each do |subm|\n\t\t\ttemp = getProblem( subm )\n\t\t\tunless problems.any? { |problem| problem.id == temp.id }\n\t\t\t\tproblems << temp\n\t\t\t\tproblemsADay[ temp.daysAgo ] = problemsADay[ temp.daysAgo ].to_i + 1\n\t\t\t\tif val == 1\n\t\t\t\t\t@totalscoreA += temp.point.to_i\n\t\t\t\t\t@mostA = [problemsADay[ temp.daysAgo ], @mostA ].max\n\t\t\t\telse\n\t\t\t\t\t@totalscoreB += temp.point.to_i\n\t\t\t\t\t@mostB = [problemsADay[ temp.daysAgo ], @mostB ].max\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tproblems.each do |shit|\n\t\t\t\t\tif shit.id == temp.id \n\t\t\t\t\t\tshit.friendsSubmissions << temp.friendsSubmissions[0] \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn problems\n\tend",
"def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend",
"def reduce_solved\n before = 9*9*9\n after = entropy\n while before > after\n before = after\n reduce_line\n reduce_col\n reduce_grid\n after = entropy\n end\n self\n end",
"def compare_solutions(count = 5, n_min = 1, n_max = 300)\n arr = generate(count, n_min, n_max)\n if solve(arr) != solve_opt(arr)\n puts \"\\nFAILED\"\n puts 'data: ' + arr.to_s\n puts 'solution: ' + solve(arr).to_s\n puts 'optimized solution: ' + solve_opt(arr).to_s\n end\nend",
"def solution(a)\n result = 0\n tmp_count = 0\n a.each_with_index do |val, idx|\n if val.zero?\n tmp_count += 1\n else\n result += tmp_count\n end\n end\n return result > 1000000000 ? -1 : result\nend",
"def solve_stupid\n nodes_num.times.collect{|node_num| make_wave(node_num) }.min\n end",
"def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend",
"def find_curious\n z = generate.zip simplify_all\n z.reject! {|x| x.last == nil }\n z.select { |tuple| simplest_form(tuple.first) == simplest_form(tuple.last) && !trivial(tuple.first) }\nend",
"def alg; end",
"def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend",
"def solution4(input)\n end",
"def solved?\n first_empty_index.nil? && legal?\n end",
"def solution(h)\n n = h.size\n return 0 if n == 0\n stack = [h.first]\n blocks = 0\n (1...n).each { |y|\n if h[y] != stack.last\n while !stack.empty? && h[y] < stack.last\n stack.pop\n blocks += 1\n end\n stack << h[y] unless stack.last == h[y]\n end # != last\n }\n blocks += stack.count\nend",
"def solution_checker(array)\n if array.length > 1\n # Create a board that can be manipulated without affecting the original board\n internal_board = []\n column_counter = 1\n row_counter = 1\n 4.times do\n 4.times do\n internal_board.push(Square.new([column_counter, row_counter]))\n column_counter = column_counter + 1\n end\n row_counter = row_counter + 1\n column_counter = 1\n end\n #Label squares on the board as occupied\n array.each do |piece|\n square = internal_board.find {|s| s.location == piece.location}\n square.occupied = true\n square.piece = piece\n end\n array.each_with_index do |piece, index|\n if array.include?(piece) && piece != array.last\n original_square = internal_board.find {|s| s.location == piece.location}\n blocker = piece.impediments?([(array[index + 1]).column, (array[index + 1]).row], internal_board)\n if blocker\n break\n elsif piece.move([(array[index + 1]).column, (array[index + 1]).row])\n captured_piece = array[index + 1]\n array.uniq!{|piece| piece.location}\n original_square.occupied = false\n original_square.piece = nil\n new_moves = array.permutation.to_a\n new_moves.each do |new_array|\n new_array.map {|a| a.dup}\n end\n new_moves.each do |new_array|\n solution_checker(array)\n end\n else\n break\n end\n else\n break\n end\n end\n end\nend",
"def solve( n = 16 )\n max = 0\n \n (1..10).each do |a|\n (1..10).each do |b|\n next if b == a\n (1..10).each do |c|\n next if c == b || c == a\n (1..10).each do |d|\n next if d == c || d == b || d == a\n (1..10).each do |e|\n next if e == d || e == c || e == b || e == a\n\n rotate = 3*[a, b, c, d, e].each_with_index.min[1]\n (1..10).each do |f|\n next if f == e || f == d || f == c || f == b || f == a\n (1..10).each do |g|\n next if g == f || g == e || g == d || g == c || g == b || g == a\n \n t = a + f + g\n (1..10).each do |h|\n next if h == g || h == f || h == e || h == d || h == c || h == b || h == a\n next unless t == b + g + h\n\n (1..10).each do |i|\n next if i == h || i == g || i == f || i == e || i == d || i == c || i == b || i == a\n next unless t == c + h + i\n\n (1..10).each do |j|\n next if j == i || j == h || j == g || j == f || j == e || j == d || j == c || j == b || j == a\n next unless t == d + i + j && t == e + j + f\n\n s = [a, f, g, b, g, h, c, h, i, d, i, j, e, j, f]\n rotate.times {s.push s.shift}\n\n s = s.join\n next if n != s.length\n\n max = [max, s.to_i].max\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n\n max\n end",
"def solve\n n = 33\n while true\n begin\n n += 2\n end while n.prime?\n\n s, ds = 2, 6\n while s < n && !(n - s).prime?\n s += ds\n ds += 4\n end\n\n break if s >= n\n end\n \n n\n end",
"def conflicts(board)\n n = board.length()\n\n row_freq = [0] * n\n col_freq = [0] * n\n diag_freq = [0] * (n * 2)\n diag2_freq = [0] * (n * 2)\n\n (0...n).each do |row|\n (0...n).each do |col|\n if board[row][col] == \"Q\"\n row_freq[row] += 1\n col_freq[col] += 1\n diag_freq[row+col] += 1\n diag2_freq[n-row+col] += 1\n end\n end\n end\n\n num_conflicts = 0\n (0...n*2).each do |i|\n if i < n\n num_queens_row = row_freq[i]\n num_queens_col = col_freq[i]\n num_conflicts += (num_queens_row * (num_queens_row - 1) / 2)\n num_conflicts += (num_queens_col * (num_queens_col - 1) / 2)\n end\n\n num_queens_diag = diag_freq[i]\n num_queens_diag2 = diag2_freq[i]\n num_conflicts += (num_queens_diag * (num_queens_diag - 1) / 2)\n num_conflicts += (num_queens_diag2 * (num_queens_diag2 - 1) / 2)\n end\n\n num_conflicts\nend",
"def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end",
"def solution(a)\n return 0 if a.length < 3\n a.sort.each_cons(3) { |e| return 1 if e[0] + e[1] > e[2] }\n return 0\nend",
"def solution(k, m, a)\n from = a.max\n to = a.inject(:+)\n min = from\n while from <= to\n mid = (from + to) / 2\n if check(mid, k, m, a)\n min = mid\n to = mid - 1\n else\n from = mid + 1\n end\n end\n min\nend",
"def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend",
"def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend",
"def solution(a)\n min_val = 10_000\n min_pos = 0\n \n sums = [0]\n for i in (0..a.count - 1) \n sums << sums.last + a[i] \n end\n for p in (0..a.count - 2)\n for q in (p + 1..[p + 2, a.count - 1].min)\n s = (sums[q + 1] - sums[p]).to_f / (q - p + 1)\n if s < min_val\n min_val = s\n min_pos = p\n end\n end\n end\n min_pos\nend",
"def coast_guard_rank; end",
"def solve\n loop { break if !shift }\n return @solutions\n end",
"def solve( n = 2_000 )\n # We can classify every tile according to its angular position around the\n # unit circle, setting position 0 at the top since that's where each row\n # starts in the problem statement. Positions 1-5 then follow every 60° as\n # we work our way counter-clockwise. Depending on which of these positions\n # each tile falls (or between which pair of positions), we use different\n # formulae to calculate its six neighbors to the N, NW, SW, S, SE, and NE:\n # \n # Pos 0: n even = fhp\n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n + ring - 1 (f)\n # SW = n + 1 NE = n + (2*ring + 5) (p)\n #\n # Pos 0-1: n even = bh, n odd = ag \n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + 1 NE = n - 1\n #\n # Pos 1: n even = bh, n odd = gi\n # N = n + ring (g) S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - 1\n #\n # Pos 1-2: n even = bh, n odd = ci\n # N = n - 1 S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2: n even = hj\n # N = n - 1 S = n + ring + 3 (j)\n # NW = n + ring + 1 (h) SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2-3: n even = dj, n odd = ci\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 3: n even = dj, n odd = ik\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + ring + 4 (k)\n # SW = n + ring + 2 (i) NE = n + 1\n #\n # Pos 3-4: n even = dj, n odd = ek\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + 1\n #\n # Pos 4: n even = jl\n # N = n + 1 S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + ring + 5 (l)\n #\n # Pos 4-5: n even = fl, n odd = ek\n # N = n + 1 S = n - 1\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5: n even = fl, n odd = km\n # N = n + ring + 6 (m) S = n - 1\n # NW = n + 1 SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, except last: n even = fl, n odd = gm\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n + 1 SE = n - 1\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, only last: n even = flo, n odd = gmo\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n - ring + 1 (f) SE = n - 1\n # SW = n - (2*ring - 7) (o) NE = n + ring + 5 (l)\n #\n # From these formula, we can derive the difference between a tile and each\n # of its neighbors. If we arrange all potential differences in ascending\n # order, it becomes obvious that for n even or odd, some deltas will al-\n # ways be even, and thus can never be prime (>2).\n #\n # Furthermore, we can see that only in certain positions will a tile ever\n # differ from three neighbors by odd amounts (position 0 and just to the\n # right of position 0). In all other cases, at most two deltas will be\n # odd, meaning PD(n) will be 2 or less.\n #\n # n even n odd\n # a = ring - 6 even a\n # b = ring - 5 b even\n # c = ring - 4 even c\n # d = ring - 3 d even\n # e = ring - 2 even e\n # f = ring - 1 f even\n # g = ring even g\n # h = ring + 1 h even\n # i = ring + 2 even i\n # j = ring + 3 j even\n # k = ring + 4 even k\n # l = ring + 5 l even\n # m = ring + 6 even m\n # o = 2ring - 7 o o\n # p = 2ring + 5 p p\n pd3 = [1, 2]\n base, ring = 8, 12\n \n while pd3.size < n\n # Only at position 0 and one tile to the right will there ever be three\n # odd deltas, so those are the only ones we have to check for primality.\n # Both share a delta of f = ring - 1.\n if (ring - 1).prime?\n # Check the other odd deltas for position 0. \n pd3 << base if (ring + 1).prime? && (2*ring + 5).prime?\n\n # Check the other odd deltas for one tile to the right of position 0.\n pd3 << base + ring - 1 if (ring + 5).prime? && (2*ring - 7).prime?\n end\n\n # Advance the first tile of the current ring (base), and the number of\n # tiles it contains (ring). \n base += ring\n ring += 6\n end\n\n pd3[-1]\n end",
"def euler29(n)\n terms = []\n 2.upto(n) do |i|\n 2.upto(n) do |j|\n if terms.include?(i ** j) == false\n terms << i ** j\n end\n end\n end\n \n terms.length\nend",
"def optimize\n left\n end",
"def optimize\n left\n end",
"def optimize\n left\n end",
"def solution(a)\n left = 0\n right = a.sum\n a.each_with_index do |element, index|\n right -= element\n return index if left == right\n left += element\n end\n -1\nend",
"def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend",
"def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend",
"def solve(array)\n results = [0] * (array.max + 1)\n\n array.each do |element|\n results[element] + 1\n end\n array.index(1)\nend",
"def solution4(a)\n left = 0\n right = a.size - 1\n distinct = 0\n\n while left <= right\n # puts \"left: #{left}, right: #{right}\"\n # puts \"a[l]: #{a[left]}, a[r]: #{a[right]}\"\n # puts \"distinct: #{distinct}\"\n if a[left].abs > a[right].abs\n begin\n left += 1\n end until a[left] != a[left - 1]\n elsif a[left].abs < a[right].abs\n begin\n right -= 1\n end until a[right] != a[right + 1]\n else\n begin\n left += 1\n end until a[left] != a[left - 1]\n begin\n right -= 1\n end until a[right] != a[right + 1] \n end\n\n distinct += 1\n end\n distinct\nend",
"def solve(nums, target)\n nums.each_with_index do |e, i|\n nums.each_with_index do |e_, i_|\n return [i, i_] if ((e + e_ == target) && (i != i_))\n end\n end\nend",
"def test_find_stack_overflow\n skip # because it takes *forever*\n @starting_point = MM::Ratio.new(1,1)\n @search = MM::Search.new(@starting_point)\n @search.delta = 0.001\n @search.adjacent_points_function = ->(current) {\n [MM::Ratio.new(1,1), MM::Ratio.new(-1,1)].map {|m| m + current}\n }\n goal = MM::Ratio.new(9000,1)\n @search.cost_function = ->(x) {\n (x - goal).abs\n }\n assert_equal goal, @search.find\n puts @search.iterations\n end",
"def solution(a)\n ((1..a.size + 1).to_a - a).first\nend",
"def largest_contigious_subsum(list)\n debugger\n lcs = list[0] \n current_sum = list[0]\n puts lcs\n list.each_with_index do |num, i|\n current_sum += list[i + 1]\n if current_sum > lcs \n lcs = current_sum\n end\n end\n lcs \nend",
"def solution \n row_search \n columns_search \n diagonal_search\n end",
"def problem_104\n all = [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\"]\n k = 2\n low_fn0,low_fn1 = 1,1\n hi_fn0,hi_fn1 = 1,1\n loop do\n k += 1\n low_fn0,low_fn1 =(low_fn0 + low_fn1) % 10_000_000_000, low_fn0\n hi_fn0, hi_fn1 = hi_fn0 + hi_fn1, hi_fn0\n if hi_fn0 > 1_000_000_000_000_000_000\n hi_fn0 /= 10\n hi_fn1 /= 10\n end\n front = false\n next unless k > 300\n hi = hi_fn0.to_s[0,9].split(//)\n if (hi & all).length == 9\n puts \"front #{k}\" \n front = true\n end\n if (low = low_fn0.to_s).length >= 9\n low = low[-9,9].split(//)\n if (low & all).length == 9\n puts \"back #{k}\" \n return k if front\n end\n end\n end\nend",
"def solution(a)\n # write your code in Ruby 2.2\n binding.pry\n trips = Hash.new {|h,k| h[k]=0}\n start = 0\n ending = 0\n min = nil\n a.each_with_index do |trip,i|\n ending = i\n\n if trips[trip] == 0\n min = ending - start\n end\n trips[trip] += 1\n\n while start < ending\n break if trips[a[start]] - 1 == 0\n trips[start] -= 1\n start += 1\n min = ending - start if ending-start < min\n end\n end\n min\nend",
"def solve(nums)\n nums.each_with_index do |n, i|\n if nums[i] == i\n return i\n end\n end\n return -1\nend",
"def update_possible!()\r\n\r\n #falls es keine Hits gibt, werden ale Tipps geloescht, die eine der Ziffern enthalten\r\n if (@last_hits == [0,0])\r\n @digits.times do |i|\r\n\r\n @left.delete_if{ |x|\r\n x.include?(@last_guess[i])\r\n }\r\n\r\n end\r\n\r\n end\r\n\r\n #falls es keine Black Hits gibt, werden alle Tipps mit einer identischen Stelle geloescht\r\n if @last_hits[0]==0\r\n\r\n @digits.times do |i|\r\n\r\n @left.delete_if { |x|\r\n x[i]==@last_guess[i]\r\n }\r\n end\r\n\r\n end\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Black Hits entspricht\r\n @left.delete_if { |x|\r\n @last_hits[0] != @mastermind.hits(@last_guess,x)[0]\r\n }\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Total Hits entspricht\r\n @left.delete_if { |x|\r\n (@last_hits[0] + @last_hits[1]) != (@mastermind.hits(@last_guess,x)[0][email protected](@last_guess,x)[1])\r\n }\r\n\r\n end",
"def linear_search_complexity(n, file=nil)\n if file\n file.puts(\"#{n},#{n}\")\n else\n puts(\"worst case for #{n} elements: #{n}\")\n end\n \nend",
"def problem_78\n n = 1\n p_cache = [1]\n\n generate = lambda do |k|\n ret = 0\n sign = 0\n Integer.generalized_pentagonals do |gp|\n if k < gp\n false # Need to exit ruby1.8, can't break...\n else\n if sign >= 0\n ret += p_cache[k-gp]\n else\n ret -= p_cache[k-gp]\n end\n sign += (sign == 1) ? -3 : 1 # 4 states + + - -\n end\n end\n p_cache[k] = ret % 100_000_000\n ret\n end\n\n p = 1\n loop do\n r = generate.call(p)\n# puts \"#{p} #{generate.call(p)}\"\n break if r % 1_000_000 == 0\n p += 1\n end\n p\nend",
"def slow_solution(a)\n m = 0\n a.size.times do |i|\n a[i] = a[i].abs\n m = [a[i], m].max\n end\n maxsum = a.sum # sum of absolute val of all nums in array\n # maxsum = a.map(&:abs).sum <- Ruby shortcut\n\n # If dp = 1 at an index, it means some combo of elements in a add up to that index\n dp = [0] * (maxsum + 1)\n dp[0] = 1\n\n a.size.times do |j|\n maxsum.downto(0).each do |possible_sum|\n puts \"a[j]: #{a[j]}, possible sum: #{possible_sum}\"\n if (dp[possible_sum] == 1) and (possible_sum + a[j] <= maxsum)\n\n # if possible_sum + new element a[j] is possible sum, dp = 1!\n dp[possible_sum + a[j]] = 1\n puts \"Mark #{possible_sum + a[j]} as possible sum in dp\"\n end\n end\n puts \"row: #{j}, a[j]: #{a[j]}, dp: #{dp}\"\n puts\n end\n\n min_q_minus_p = maxsum\n\n # Divide array a into 2 parts, where P = sum of part 1 and Q = sum of part 2,\n # P + Q = maxsum, and P <= maxsum / 2 <= Q.\n # We want largest possible P to get smallest possible Q-P.\n\n # loop from 0 to maxsum / 2, covering every possible P, Q division\n (maxsum / 2 + 1).times do |possible_half_sum|\n # puts \"possible_half_sum: #{possible_half_sum}\"\n if dp[possible_half_sum] == 1 # means P or Q = possible_half_sum\n q_minus_p = maxsum - 2 * possible_half_sum\n # puts \"Q - P: #{q_minus_p}\"\n min_q_minus_p = [min_q_minus_p, q_minus_p].min\n # puts \"min Q - P: #{min_q_minus_p}\"\n end\n end\n\n min_q_minus_p\nend",
"def solve_two_vs_three_vs_five\n return if @arr[1].nil? || @arr[6].nil?\n\n #p \"1,6: #{@arr[1]},#{@arr[6]}\"\n\n @words.filter{|x| x.length == 5 && @hash[x].nil?}.each{|w|\n if @arr[1].chars.all?{|c| w.chars.include?(c)}\n solved(3, w)\n elsif w.chars.all?{|c2| @arr[6].chars.include?(c2)}\n solved(5, w)\n else\n solved(2, w)\n end\n }\n end",
"def find_unsorted_subarray(nums)\n \nend",
"def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\nend",
"def solve( n = 2_000_000 )\n counts = Hash.new( 0 )\n\n # Guesstimate upper limit on grid dimensions. \n (1..100).each do |w|\n (1..100).each do |h|\n counts[[w, h]] = w * (w + 1) * h * (h + 1) >> 2\n end\n end\n\n counts.min_by {|k, v| (n - v).abs}[0].inject( :* )\n end",
"def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend",
"def solution_slow_2(n, p, q)\n sieve = sieve_of_erathosteneses(n)\n # puts \"sieve:#{sieve}\"\n semi = semiprimes(n, sieve)\n # puts \"sp:#{semi}\"\n prefix = [0,0,0,0,1]\n 5.upto(n) do |x|\n if semi.include? x \n prefix << prefix.last + 1\n else\n prefix << prefix.last\n end\n end\n # puts \"prefix:#{prefix}\"\n\n queries = [p,q].transpose\n\n\n res = queries.map do |query|\n prefix[query.last] - prefix[query.first - 1]\n end\n\n # puts \"res:#{res}\"\n\n res\n end",
"def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend",
"def optimize(ary, total)\n return [] if ary.empty?\n table = []\n (ary.size+1).times { |i| table[i] = [] }\n (0..total).each { |zerg| table[0][zerg] = 0 }\n (1..ary.size).each do |base|\n table[base][0] = 0\n (1..total).each do |zerg|\n if ary[base-1].zerg <= zerg && (ary[base-1].minerals + table[base-1][zerg - ary[base-1].zerg] > table[base-1][zerg])\n table[base][zerg] = ary[base-1].minerals + table[base-1][zerg - ary[base-1][1]]\n else\n table[base][zerg] = table[base-1][zerg]\n end\n end\n end\n result = []\n i, k = ary.size, total\n while i > 0 && k > 0\n if table[i][k] != table[i-1][k]\n result << ary[i-1]\n k -= ary[i-1].zerg\n end\n i -= 1\n end\n result\nend",
"def deduce\n while true\n stuck, guess, count = true, nil, 0\n # fill in any spots determined by direct conflicts\n allowed = board.allowed_numbers\n (0..80).each do |index|\n if board.board[index].nil?\n numbers = bits_to_numbers(allowed[index])\n if numbers.size == 0\n return [] # Return nothing if no possibilitie E\n elsif numbers.size == 1\n board.board[index] = numbers[0]\n stuck = false\n break\n elsif stuck\n new_guesses = numbers.map { |n| [index, n] }\n guess, count = pickbetter(guess, count, new_guesses)\n end\n end\n end\n\n if !stuck\n allowed = board.allowed_numbers\n end\n needed = board.needed_numbers\n\n # fill in any spots determined by elimination of other locations.\n # For any given column, find which numbers it is missing,\n # And figure out which positions allow those numbers - if only\n # one position allows it, the number goes there.\n #\n # If more than one spot is available, add to the guesses.\n board.coordinate_systems.each do |axis|\n (0..8).each do |x|\n numbers = bits_to_numbers(needed[axis_index(x, axis)])\n numbers.each do |n|\n bit = 1 << n\n # spots =for this number & col, all positions that allow the needed\n # numbers\n spots = []\n\n (0..8).each do |y|\n index = board.index_for(x, y, axis)\n # if this position allows the needed number, add it to spots\n if allowed[index] & bit\n spots << index\n end\n end\n\n if spots.length == 0\n return []\n elsif spots.length == 1\n board.board[spots[0]] = n\n stuck = False\n break\n elsif stuck\n new_guesses = spots.map { |index| [index, n] }\n guess, count = pickbetter(guess, count, new_guesses)\n end\n end\n end\n end\n\n if stuck\n guess.shuffle! unless guess.nil?\n return guess\n end\n end\n end",
"def solution(x,a)\n counter_hash = {}\n a.each_with_index do |value, index|\n counter_hash[value] = true\n return index if counter_hash.size == x\n end\n -1\nend",
"def solution(x, y, a)\n n = a.length\n result = -1\n nX = 0\n nY = 0\n i = 0\n while (i < n)\n if (a[i] == x) then\n nX += 1\n end\n if (a[i] == y) then\n nY += 1\n end\n if (nX == nY) && !(nX == 0) && !(nY == 0) then\n result = i\n end\n i += 1\n end\n return result\nend"
] | [
"0.62264663",
"0.60937554",
"0.602436",
"0.59051985",
"0.5887899",
"0.58437115",
"0.5826624",
"0.5764585",
"0.5724603",
"0.57212794",
"0.570705",
"0.56688595",
"0.56575215",
"0.5616169",
"0.5598454",
"0.5585784",
"0.5585481",
"0.55834836",
"0.5579299",
"0.5578773",
"0.556171",
"0.55596066",
"0.5558618",
"0.5549647",
"0.55486786",
"0.5543108",
"0.55387104",
"0.5529622",
"0.5524821",
"0.5520181",
"0.55182934",
"0.55101097",
"0.54943746",
"0.5492338",
"0.549063",
"0.5488045",
"0.5483614",
"0.5481437",
"0.5474835",
"0.54547036",
"0.54463154",
"0.54365075",
"0.54180086",
"0.54108787",
"0.54101205",
"0.5407222",
"0.5406215",
"0.54039",
"0.54016924",
"0.5399684",
"0.5397323",
"0.5394914",
"0.5387928",
"0.53825206",
"0.53812087",
"0.5380924",
"0.5377474",
"0.5368557",
"0.53652954",
"0.53642535",
"0.5361162",
"0.53563243",
"0.53536963",
"0.5344806",
"0.53437334",
"0.5337943",
"0.53374285",
"0.53363377",
"0.5335047",
"0.53318036",
"0.5328924",
"0.5328924",
"0.5328924",
"0.5328059",
"0.5327266",
"0.532195",
"0.53194505",
"0.5316463",
"0.53104544",
"0.5309391",
"0.5306318",
"0.5304714",
"0.53032887",
"0.5301998",
"0.53003263",
"0.5299264",
"0.5296051",
"0.52892005",
"0.5288588",
"0.52864355",
"0.5283047",
"0.52760226",
"0.5273655",
"0.52694255",
"0.52668643",
"0.5264814",
"0.52621824",
"0.5262134",
"0.525864",
"0.5252346",
"0.5241238"
] | 0.0 | -1 |
Usage: create_metric type: :researched do Siemens 2015: 4, 2014: 3 Apple 2105: 7 end | def create_metric opts={}, &block
Card::Auth.as_bot do
if opts[:name] && opts[:name].to_name.parts.size == 1
opts[:name] = "#{Card::Auth.current.name}+#{opts[:name]}"
end
opts[:name] ||= "TestDesigner+TestMetric"
Card::Metric.create opts, &block
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_metric name, description: nil, filter: nil\n ensure_connection!\n resp = connection.create_metric name, description, filter\n if resp.success?\n Metric.from_gapi resp.data, connection\n else\n fail ApiError.from_response(resp)\n end\n end",
"def create\n metric = metrics.create(create_params)\n\n respond_with(metric)\n end",
"def create(name, q, type='meter')\n raise \"Save search type must be meter or annotation.\" unless ['meter','annotation'].include?(type) \n ss = Hash.new\n ss[:name] = name\n ss[:q] = q\n ss[:types] = type\n response = Boundary.post(@url, JSON.generate(ss), {:content_type => :json, :accept => :json})\n response['id']\n end",
"def metric(name,type,value)\n @metrics[name] = {\n :type => type,\n :value => value\n }\nend",
"def findOrCreateMetric(software, version, metricName)\n\t\t\trelease = ReleaseService.instance.findUniqBy(software, version)\n\t\t\tqueryMetric = Mongoboard::Metric.where(:release => release._id, :types.all => [ metricName ])\n\t\t\tcount = queryMetric.count\n\n\t\t\tif count > 1\n\t\t\t\traise Errors::WrongResultCount.new(count), \"0..1 metrics expected\"\n\t\t\telse \n\t\t\t\tif count == 1\n\t\t\t\t\tmetric = queryMetric[0]\n\t\t\t\tend\n\n\t\t\t\tif count == 0\n\t\t\t\t\tmetric = Metric.new\n\t\t\t\t\tmetric.label = metricName.capitalize.sub /[-_]/, ' '\n\t\t\t\t\tmetric.types = Array.new\n\t\t\t\t\tmetric.types.push metricName\n\t\t\t\t\tmetric.release = release._id\n\t\t\t\t\tmetric.save!\n\t\t\t\tend\n\n\t\t\tend\n\t\t\n\t\t\traise \"Unexpected result: metric == nil\" if metric.nil?\n\t\t\tmetric\n\n\t\tend",
"def get_metrics_string(machine_name,product,type,studio_name)\n base_prefix = \"GRAPH-studio_global_\";\n base_suffix = \"\";\n if type==\"machine\" \n base_suffix = \"_retouch_v1.RESULT-\";\n elsif type == \"studio\"\n base_suffix = \"_retouch_v1.STUDIO-\" + studio_name;\n base_suffix += \".RESULT-\";\n end \n verdicts = product==\"apparel\" ? [\"ACCEPT\",\"PARTIAL_RESULT\",\"NO_RESULT\",\"REJECT\"] : [\"ACCEPT\",\"PARTIAL_RESULT\",\"NO_RESULT\",\"REJECT\",\"ERROR\"];\n base_prefix += product + \"_\";\n\n metricsname_list = [];\n for j in 0..verdicts.size-1\n metricsname_list.push(base_prefix+machine_name+base_suffix+verdicts[j]);\n end\n return metricsname_list;\n end",
"def build\n if %w[avg_first_response_time avg_resolution_time].include?(params[:metric])\n timeseries.each_with_object([]) do |p, arr|\n arr << { value: p[1], timestamp: p[0].in_time_zone(@timezone).to_i, count: @grouped_values.count[p[0]] }\n end\n else\n timeseries.each_with_object([]) do |p, arr|\n arr << { value: p[1], timestamp: p[0].in_time_zone(@timezone).to_i }\n end\n end\n end",
"def build_metrics\n {}\n end",
"def create(params)\n\n if (params[:freq] && FREQ.include?(params[:freq].to_sym))\n @freq = params[:freq].to_sym\n end\n\n @interval = params[:interval].to_i if params[:interval]\n\n if params[:days_of_week] && params[:days_of_week_offset]\n @by_day = encode_by_day(params[:days_of_week], params[:days_of_week_offset])\n elsif params[:days_of_week]\n @by_day = encode_by_day(params[:days_of_week])\n end\n\n if params[:days_of_month]\n @by_month_day = encode_by_month_day(params[:days_of_month])\n end\n\n @duration = params[:duration].to_i if params[:duration]\n @event_start = params[:event_start]\n end",
"def add_metric\n\t\tp_language = ProgrammingLanguage.find_by_name(RubyCoverage::PROGRAMMING_LANGUAGE)\n\t\t \n\t\tbegin\n\t\t Metric.table_exists?\n\t\t metric_analyser = RubyCoverage::ANALYSER\n\t\t metric_name = RubyCoverage::NAME\n\t\t if Metric.find_by_name(metric_name).nil?\n\t\t\tmetric = Metric.new(:name => metric_name, :analyser => metric_analyser)\n\t\t\tmetric.programming_language = p_language\n\t\t\tmetric.save!\n\t\t end \n\t\trescue\n\t\t raise \"ActiveRecord::Metric does not exist.\"\n\t\tend\n\t end",
"def counter(args={})\n assert_open!\n hour = date_as_hour((args[:when] || Time.now).utc)\n metric = escape(required(args, :what).to_s)\n where = (args[:where] || {}).map{|k,v| [k, v, escape(k) << '=' << escape(v), max_ttl_of_dimension[k]] }\n where.all_combinations do |dimensions|\n key = counter_key(hour, metric, dimensions.sort.map{|k,v,s,ttl| s}.join('&'))\n ttl = (dimensions.map{|k,v,s,ttl| ttl} << ttl_of_hours).compact.min\n count_incrementer.increment(key, 1, ttl)\n end\n where.size.times do |i|\n where2 = where.clone\n list, dimension_value, _ = where2.delete_at(i)\n list = escape(list)\n key_middle = \"#{hour}/#{metric}/#{list}?\"\n where2.all_combinations do |dimensions|\n key_suffix = \"#{key_middle}#{dimensions.sort.map{|k,v,s,ttl| s}.join('&')}\"\n ttl = (dimensions.map{|k,v,s,ttl| ttl} << ttl_of_hours).compact.min\n inserter.insert(\"list:/#{key_suffix}\", dimension_value, ttl)\n estimator = HyperLogLog::Builder.new(CARDINALITY_ESTIMATOR_ERROR_RATE, Proc.new do |idx, val|\n range_updater.update_range(\"hyperloglog:#{idx.to_i}:/#{key_suffix}\", val, ttl)\n end)\n estimator.add(dimension_value)\n end\n end\n end",
"def create\n @metric_type = MetricType.new(params[:metric_type])\n\n respond_to do |format|\n if @metric_type.save\n format.html { redirect_to(@metric_type, :notice => 'Metric type was successfully created.') }\n format.xml { render :xml => @metric_type, :status => :created, :location => @metric_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @metric_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @metric_type = MetricType.new(params[:metric_type])\n\n respond_to do |format|\n if @metric_type.save\n format.html { redirect_to @metric_type, notice: 'Metric type was successfully created.' }\n format.json { render json: @metric_type, status: :created, location: @metric_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @metric_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def measure(args={})\n assert_open!\n value = required(args, :value).to_i\n hour = date_as_hour((args[:when] || Time.now).utc)\n metric = escape(required(args, :what).to_s)\n where = (args[:where] || {}).map{|k,v| [k, v, escape(k) << '=' << escape(v), max_ttl_of_dimension[k]] }\n where.all_combinations do |dimensions|\n dimensions_string = dimensions.sort.map{|k,v,s,ttl| s}.join('&')\n ttl = (dimensions.map{|k,v,s,ttl| ttl} << ttl_of_hours).compact.min\n suffix = build_key('', hour, metric, dimensions_string)\n count_incrementer.increment(\"count#{suffix}\", 1, ttl)\n incrementer.increment(\"sum#{suffix}\", value, ttl)\n range_updater.update_range(\"range#{suffix}\", value, ttl)\n incrementer.increment(\"sumsqr#{suffix}\", value*value, ttl)\n end\n where.size.times do |i|\n where2 = where.clone\n list, dimension_value, _ = where2.delete_at(i)\n list = escape(list)\n key_middle = \"#{hour}/#{metric}/#{list}?\"\n where2.all_combinations do |dimensions|\n key_suffix = \"#{key_middle}#{dimensions.sort.map{|k,v,s,ttl| s}.join('&')}\"\n ttl = (dimensions.map{|k,v,s,ttl| ttl} << ttl_of_hours).compact.min\n inserter.insert(\"list:/#{key_suffix}\", dimension_value, ttl)\n estimator = HyperLogLog::Builder.new(CARDINALITY_ESTIMATOR_ERROR_RATE, Proc.new do |idx, val|\n range_updater.update_range(\"hyperloglog:#{idx.to_i}:/#{key_suffix}\", val, ttl)\n end)\n estimator.add(dimension_value)\n end\n end\n end",
"def set_api_by_date(startdate, enddate, hostname)\n\n\t\t# setup date range\n\t\tdate_range = @analytics::DateRange.new(start_date: startdate, end_date: enddate)\n\n\t\t# set metircs data. 10 metrices are allowed per one request\n\t\tmetrics = ['ga:pageviews', 'ga:users', 'ga:bounces', 'ga:sessions',\n\t\t\t\t 'ga:avgTimeOnPage', 'ga:newUsers', 'ga:goal1ConversionRate', 'ga:goal1Completions'\n\t\t\t\t ]\n\n\t\t# make new array and put metric type data in the array\n\t\tmetric_type = Array.new\n\t\tmetrics.each do |m|\n\t\t\tmetric = @analytics::Metric.new\n\t\t\tmetric.expression = m\n\t\t\tmetric_type.push(metric)\n\t\tend\n\n\t\t\n\t\t# if startdate == enddate then\n\t\t# \tdimension = @analytics::Dimension.new(name: 'ga:hour')\n\t\t# \torder_by = @analytics::OrderBy.new(field_name: 'ga:hour', sort_order: 'ASCENDING')\n\t\t# else\n\t\t# \tdimension = @analytics::Dimension.new(name: 'ga:date')\n\t\t# \torder_by = @analytics::OrderBy.new(field_name: 'ga:date', sort_order: 'ASCENDING')\n\t\t# end\n\n\n\t \t# set dimensions, dimension_filters by hostname. if hostname is total, then set only hour or date in dimension\n\n\t \tif hostname == 'total'\n\t\t\tif startdate == enddate then\n\t\t\t\tdimensions = ['ga:hour']\n\t\t\telse\n\t\t\t\tdimensions = ['ga:date']\n\t\t\tend\t \t\t\n\t \telse\n\t \t\tif startdate == enddate then\n\t\t\t\tdimensions = ['ga:hour', 'ga:hostname']\n\t\t\telse\n\t\t\t\tdimensions = ['ga:date', 'ga:hostname']\n\t\t\tend\t\n\t \t\tdimension_filters = @analytics::DimensionFilterClause.new(\n\t\t filters: [\n\t\t @analytics::DimensionFilter.new(\n\t\t dimension_name: 'ga:hostname',\n\t\t not: false,\n\t\t operator: \"IN_LIST\",\n\t\t expressions: [hostname]\n\t\t )\n\t\t ]\n\t\t )\n\t \tend\n\n\t \tdimension_type = Array.new\n\t\tdimensions.each do |d|\n\t\t\tdimension = @analytics::Dimension.new\n\t\t\tdimension.name = d\n\t\t\tdimension_type.push(dimension)\n\t\tend\t\t\t\n\n\t\t#set order_bys\n\t\torder_by = @analytics::OrderBy.new(field_name: dimensions[0], sort_order: 'ASCENDING')\n\n\n\t\t# setup request with the data i set up above to google analytics server\n\t\trequest = @analytics::GetReportsRequest.new(\n \t\t\treport_requests: [@analytics::ReportRequest.new(\n \t\t\tview_id: @view_id, \n \t\t\tmetrics: metric_type,\n \t\t\tdimensions: dimension_type,\n \t\t\tdimension_filter_clauses: [dimension_filters],\n \t\t\tdate_ranges: [date_range],\n \t\t\torder_bys: [order_by]\n \t\t\t)]\n\t\t)\n\n\t\t# send request and get the result in the response\n\t\tresponse = @client.batch_get_reports(request)\n\n\t\t# make new array for the total data. it will has datahash and dropdwnhash, datahash is for total data and\n\t\t# the other is for hourly/daily data. key would be time(00,01,02,...) or date(i.e. 5/20.5/21,...). \n\t\tset_total_array = Array.new\n\n\t\t# this data is mcv and it is from database\n\t\ttotal_clicks_count = set_total_article(startdate, enddate)\n\n\n\t\t# getting total data part start\n\n\t\ttotal_data = response.reports.first.data.totals\n\t\tkey_array = metrics\n\t\t# get rid of 'ga:'\n\t\tkey_array.each_with_index do |k, index| \n\t\t\tkey_array[index] = k.gsub(\"ga:\",\"\")\n\t\tend\n\n\t\ttotal_data.each do |t|\n\t\t\tdatahash = {}\n\n\t\t\tt.values.each_with_index do |v, index|\n\t\t\t\tdatahash[key_array[index]] = v\t\n\t\t\tend\n\t\t\tdatahash['mcv'] = total_clicks_count\n\t\t\tset_total_array.push(datahash)\n\t\tend\n\t\t# datahash sample -> { \"pageviews\": \"11\", \"users\": \"22\", \"bounces\": \"33\", ... , \"mcv\": 0 }\n\n\t\t# getting total data part end\n\n\t\t# getting daily or hourly data part start\n\t\tdropdwnhash = {}\n\n\t\tdata_from_google = response.reports.first.data.rows\n\t\t\n\t\tdata_from_google.each do |r|\n\t\t\tvhash = {}\n\t\t\t# key would be hour or date\n\t\t\tkey = r.dimensions.first\n\n\t\t\t# vhash is the data such as pageview, users and so on for specific time or date\n\t\t\tr.metrics.first.values.each_with_index do |v, index|\n\t\t\t\tvhash[key_array[index]] = v\n\t\t\tend\n\n\t\t\tif startdate == enddate\n\t\t\t\tkey = key + \":00\"\n\t\t\tend\n\t\t\t\n\t\t\tdropdwnhash[key.to_sym] = vhash\n\t\tend\n\n\t\t# dropdwnhash sample (hour) -> \"00:00\": { \"pageviews\": \"534\", \"users\": \"478\", \"bounces\": \"432\", ... }, \"01:00\": { ... }\n\t\t# dropdwnhash sample (date) -> \"20200608\": { \"pageviews\": \"534\", \"users\": \"478\", \"bounces\": \"432\", ... }, \"20200609\": { ... }\n\n\t\tset_total_array.push(dropdwnhash)\n\n\t\t# getting daily or hourly data part end\n\n\t\treturn set_total_array\n\tend",
"def create_metric_type(feed_id, metric_type_id, type = 'GAUGE', unit = 'NONE', collection_interval = 60)\n the_feed = hawk_escape_id feed_id\n\n metric_kind = type.nil? ? 'GAUGE' : type.upcase\n fail \"Unknown type #{metric_kind}\" unless %w(GAUGE COUNTER AVAILABILITY').include?(metric_kind)\n\n mt = build_metric_type_hash(collection_interval, metric_kind, metric_type_id, unit)\n\n begin\n http_post(\"/feeds/#{the_feed}/metricTypes\", mt)\n rescue HawkularException => error\n # 409 We already exist -> that is ok\n raise unless error.status_code == 409\n end\n\n new_mt = http_get(\"/feeds/#{the_feed}/metricTypes/#{metric_type_id}\")\n\n MetricType.new(new_mt)\n end",
"def make_metric_type metric_prefix, name\n \"#{metric_prefix}/#{name}\"\n end",
"def create\n @metric = Metric.new(metric_params)\n\n respond_to do |format|\n if @metric.save\n format.html { redirect_to @metric, notice: 'Metric was successfully created.' }\n format.json { render :show, status: :created, location: @metric }\n else\n format.html { render :new }\n format.json { render json: @metric.errors, status: :unprocessable_entity }\n end\n end\n end",
"def build_usage_by_resource\n usage_by_model_event = FedoraAccessEvent.item_usage_by_type(\n start_date: metrics.report_start_date,\n end_date: metrics.report_end_date\n )\n accumulator = {}\n usage_by_model_event.each do |fedora_object|\n accumulator[fedora_object.item_type.to_sym] ||= {}\n accumulator[fedora_object.item_type.to_sym][fedora_object.event.to_sym] ||= 0\n accumulator[fedora_object.item_type.to_sym][fedora_object.event.to_sym] += fedora_object.object_count\n end\n metrics.item_usage_by_resource_type_events = accumulator\n end",
"def create_metric_using_hash(endpoint, id, tenant_id)\n endpoint.create(id: id, dataRetention: 123, tags: { some: 'value' }, tenantId: tenant_id)\n metric = endpoint.get(id)\n\n expect(metric).to be_a(Hawkular::Metrics::MetricDefinition)\n expect(metric.id).to eql(id)\n expect(metric.data_retention).to eql(123)\n expect(metric.tenant_id).to eql(tenant_id)\n end",
"def create\n @metric = Metric.new(params[:metric])\n\n if @metric.save\n render json: @metric, status: :created, location: @metric\n else\n render json: @metric.errors, status: :unprocessable_entity\n end\n end",
"def create_occurrences\n if (from_date && to_date)\n current_date = from_date\n #this does not include the final date, could change so it does\n while (current_date < to_date)\n\n occurrence_end = current_date + event_length\n\n if(current_date.wday == recurring_day) #in case start date is not the right day of week\n occurrence_date.create( {start: current_date, end: occurrence_end})\n end\n\n case frequency\n when \"weekly\"\n current_date = current_date + 7.days\n if (recurring_day)\n current_date = current_date.beginning_of_week + recurring_day\n end\n when \"monthly\" ## need option to select which month month\n current_date = current_date + 1.month\n if(recurring_day && recurring_day_order)\n beginning_of_month= current_date.beginning_of_month\n current_date = week_day_of_month(beginning_of_month, recurring_day, recurring_day_order)\n end\n when \"daily\"\n current_date = current_date.next_day\n else\n console.log(\"not a valid frequency\")\n end\n end\n end\n end",
"def add_metrics_for(resource, range, metric_params: {}, step: 60.seconds)\n range.step_value(step).each do |time|\n metric_params[:timestamp] = time\n metric_params[:resource_id] = resource.id\n metric_params[:resource_name] = resource.name\n metric_params[:parent_ems_id] = ems.id\n metric_params[:derived_vm_numvcpus] = resource.container_node.hardware.cpu_total_cores\n if metric_params[:mem_usage_absolute_average].to_i > 0\n metric_params[:derived_memory_used] = (metric_params[:mem_usage_absolute_average] / 100.0) * resource.container_node.hardware.memory_mb\n metric_params[:derived_memory_available] = resource.container_node.hardware.memory_mb - metric_params[:derived_memory_used]\n end\n resource.metrics << FactoryBot.create(:metric, metric_params)\n end\n end",
"def build_recommendation(args)\n recommendation = {}\n target_mem = get_target_by_symbol(:mem, args[:memory][:mem_used])\n target_mem += 1 if args[:memory][:swapping?]\n\n target_disk = get_target_by_symbol(:hdd, args[:disk])\n\n if target_mem >= target_disk\n recommendation[:flavor] = target_mem\n recommendation[:flavor_reason] = \"RAM usage\"\n else\n recommendation[:flavor] = target_disk\n recommendation[:flavor_reason] = \"Disk usage\"\n end\n\n recommendation\n end",
"def create_sql_metrics(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateSqlMetrics'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :is_public\n\t\t\targs[:query]['IsPublic'] = optional[:is_public]\n\t\tend\n\t\tif optional.key? :project_name\n\t\t\targs[:query]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tif optional.key? :sql\n\t\t\targs[:body]['Sql'] = optional[:sql]\n\t\tend\n\t\tself.run(args)\n\tend",
"def initialize(args)\n @name = args[\"name\"]\n @start_date = args[\"start_date\"]\n @end_date = args[\"end_date\"]\n @location = args[\"location\"]\n @description = args[\"description\"]\n\n @start_time = args[\"start_time\"] if args.include? \"start_time\"\n\n @end_time = args[\"end_time\"] if args.include? \"end_time\"\n\n @is_repeated = true if args.include? \"repetition_freq\" and args[\"repetition_freq\"] != \"\"\n @has_alarm = true if args.include? \"alarm_time_unit\" and args[\"alarm_time_unit\"] != \"\"\n\n if args.include? \"wholeday\"\n @is_all_day = true\n else\n @is_all_day = false\n end\n\n if @start_date.include? \"/\"\n @is_us_format = true\n else\n @is_us_format = false\n end\n\n # Valid values are between 1 and 2147483647, excluding 0\n # \"asdf\".to_i -> 0\n if @is_repeated\n @repetition_freq = args[\"repetition_freq\"]\n value = args[\"repetition_interval\"]\n if value == \"\" or value.to_i > 2147483647 or value.to_i < 1\n @repetition_interval = \"1\"\n else\n @repetition_interval = value\n end\n @repetition_freq = \"YEARLY\" if @repetition_freq == \"Years\" || @repetition_freq == \"Jahre\"\n @repetition_freq = \"MONTHLY\" if @repetition_freq == \"Months\" || @repetition_freq == \"Monate\"\n @repetition_freq = \"WEEKLY\" if @repetition_freq == \"Weeks\" || @repetition_freq == \"Wochen\"\n @repetition_freq = \"DAILY\" if @repetition_freq == \"Days\" || @repetition_freq == \"Tage\"\n end\n\n if @has_alarm\n @alarm_time_unit = args[\"alarm_time_unit\"]\n alarm_value = args[\"alarm_time_value\"]\n if alarm_value == \"\" or alarm_value.to_i > 2147483647 or alarm_value.to_i < 1\n @alarm_time_value = \"1\"\n else\n @alarm_time_value = alarm_value\n end\n @alarm_time_unit = \"D\" if @alarm_time_unit == \"Day(s)\" || @alarm_time_unit == \"Tag(e)\"\n @alarm_time_unit = \"H\" if @alarm_time_unit == \"Hour(s)\" || @alarm_time_unit == \"Stunde(n)\"\n @alarm_time_unit = \"M\" if @alarm_time_unit == \"Minute(s)\" || @alarm_time_unit == \"Minute(n)\"\n end\n\n end",
"def create_lookup(start_dt, end_dt, tagger)\n db = NewsAnalyzer::News.new(\"dbi:Mysql:newsplus:#{@host}\")\n counter = {}\n titles = db.get_titles(start_dt, end_dt)\n titles.each do |row|\n t = row[\"title\"].force_encoding(Encoding::UTF_8)\n tagger.hatena_keyword(t).each do |word|\n counter[word] ||= 0\n counter[word] += 1\n end\n end\n lookup = {}\n id = 1\n counter.to_a.sort{|a,b|\n b[1] <=> a[1]\n }[0...50_000].each{|pair|\n lookup[pair[0]] = id\n id += 1\n }\n printf $stdout, \"words: %d\\n\", counter.size\n return lookup\nend",
"def convert_time_series metric_prefix, resource_type, resource_labels,\n view_data\n view = view_data.view\n\n view_data.data.map do |tag_values, aggr_data|\n series = Google::Cloud::Monitoring::V3::TimeSeries.new(\n metric: {\n type: make_metric_type(metric_prefix, view.name),\n labels: Hash[view.columns.zip tag_values]\n },\n resource: {\n type: resource_type,\n labels: resource_labels\n },\n metric_kind: convert_metric_kind(view.aggregation),\n value_type: convert_metric_value_type(view)\n )\n\n series.points << convert_point(\n view_data.start_time,\n aggr_data.time,\n view.measure,\n aggr_data\n )\n\n series\n end\n end",
"def construct_metric_data(events_arr)\n now = Time.now.to_i\n num_log_entries = events_arr.size\n metric_data = {\n 'metric' => @metric_name,\n 'host' => @host,\n\n # Gauge is the only valid metric for the API\n 'type' => 'gauge'\n }\n\n if @dd_tags\n metric_data['tags'] = @dd_tags\n end\n\n # Nested array required by API.\n # Float point metric value required by API\n metric_data['points'] = [[now, num_log_entries.to_f]]\n\n return metric_data\n end",
"def prepare_metrics(metric_name, results)\n metrics = []\n results.each do |result|\n source = result['metric']['instance']\n value = result['value'][1].to_i\n log.debug(\"[#{metric_name}] value: '#{value}', source: '#{source}'\")\n metrics << { 'source' => source, 'value' => value }\n end\n metrics\n end",
"def create_metric_for_resource(metric_type_path, resource_path, metric_id, metric_name = nil)\n type_path = metric_type_path.is_a?(CanonicalPath) ? metric_type_path : CanonicalPath.parse(metric_type_path)\n feed_id = type_path.feed_id\n res_path = resource_path.is_a?(CanonicalPath) ? resource_path : CanonicalPath.parse(resource_path)\n res_path_str = res_path.resource_ids.join('/')\n\n m = {}\n m['id'] = metric_id\n m['name'] = metric_name || metric_id\n m['metricTypePath'] = type_path.to_s\n\n begin\n http_post(\"/feeds/#{feed_id}/metrics\", m)\n rescue HawkularException => error\n # 409 We already exist -> that is ok\n raise unless error.status_code == 409\n end\n\n ret = http_get(\"/feeds/#{feed_id}/metrics/#{metric_id}\")\n the_metric = Metric.new(ret)\n\n begin\n http_post(\"/feeds/#{feed_id}/resources/#{res_path_str}/metrics\", [the_metric.path])\n rescue HawkularException => error\n # 409 We already exist -> that is ok\n raise unless error.status_code == 409\n end\n the_metric\n end",
"def query(tags)\n tags = tags.map do |k,v|\n \"#{k}:#{v}\"\n end\n @client.http_get(\"/metrics/?type=#{@type}&tags=#{tags.join(',')}\").map do |g|\n Hawkular::Metrics::MetricDefinition::new(g)\n end\n end",
"def setup_metrics\n end",
"def setup_metrics\n end",
"def setup_metrics\n end",
"def find_or_create_metric(metrics, metric)\n target_metric = find_metric(metrics, metric)\n return target_metric if target_metric\n\n target_metric = new_metric(metric)\n metrics << target_metric\n\n target_metric\n end",
"def metricData(ak,aapId,names)\n parseUrl=URI.parse('https://api.newrelic.com/v2/applications/'+appId+'/metrics/data.json')\n uri='https://api.newrelic.com/v2/applications/'+appId+'/metrics/data.json?names'+\n host=parseUrl.host\n path=parseUrl.path\n getRequest(ak,uri,host,path)\nend",
"def defMetric(name,type, opts = {})\n # the third parameter used to be a description string\n opts = {:description => opts} if opts.class!=Hash\n @fields << {:field => name, :type => type}.merge(opts)\n end",
"def create(taglist_entry=\"\")\n \n if taglist_entry.include?(\"TAG=\") \t\n \n if taglist_entry.include?(\"TTAG\")\t \n puts\"***\"\n end\n\n data = taglist_entry.split(\" \") \n \n #gotta be the right format to properly parse the result\n unless data.length == 7 \n p taglist_entry\n return nil\n end\n \n @epc = data[0].split(\"=\")[1]\n \n #Format the EPC\n max = (@epc.length/4)-1\n \n 1.upto(max) do |pos|\n @epc.insert(pos*5-1,\" \")\n end\n \n #Frequency\t\t\t\n @freq = data[1].to_f / 1000\n \n #RSSI calc from AM datasheet\n if data[4].hex > data[3].hex\n high_rssi=data[4].hex\n else\n high_rssi=data[3].hex\n end \n \n delta_rssi= (data[4].hex-data[3].hex).abs \n \n @rssi = 2 * high_rssi + 10 * Math.log(1 + 10**(-delta_rssi/10)) # they include: -G-3 where G is some output power factor in dBm.\n \n @last = DateTime.now.strftime(\"%Y/%m/%d %H:%M:%S.%6N\") #Time out to milliseconds.\n @disc = last \t\t\n @count = 1\n @ant = 0\n @reported = false\n \n return self\n \n\tend \n\t\n if taglist_entry==\"\"\n\t #make an empty structure...\n\t\t@epc = \"\"\n\t\t@freq = 0\n\t @rssi = 0.0\n\t\t@last = DateTime.now.strftime(\"%Y/%m/%d %H:%M:%S.%6N\") #Time out to milliseconds.\n\t\t@disc = last \t\t\n\t\t@count = 0\n\t\t@ant = 0\n\t\t@reported = false\n\t\treturn self\n\tend\n\t\n\treturn nil\n \n end",
"def record(name = nil, duration = nil, description = nil, **kwargs)\n name ||= kwargs[:name]\n duration ||= kwargs[:duration]\n description ||= kwargs[:description]\n\n metrics[name] = Metric.new(\n name: name,\n duration: duration,\n description: description\n )\n end",
"def create\n @key_metric = KeyMetric.new(params[:key_metric])\n\n respond_to do |format|\n if @key_metric.save\n format.html { redirect_to(key_metrics_path, :notice => 'Key Metric was successfully created.') }\n format.xml { render :xml => @key_metric, :status => :created, :location => @key_metric }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @key_metric.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def metric_params\r\n params.require(:metric).permit(:type, :met_start, :met_end, :channel_id, data: [:count])\r\n end",
"def test_specify_metric_check_type\n driver = create_driver(%[\n check_type metric\n ], 'ddos')\n time = Time.parse('2015-01-03 12:34:56 UTC').to_i\n driver.emit({}, time)\n driver.run\n result = driver.instance.sent_data\n expected = {\n 'name' => 'ddos',\n 'output' => '{}',\n 'status' => 3,\n 'type' => 'metric',\n 'handlers' => ['default'],\n 'executed' => time,\n 'fluentd' => {\n 'tag' => 'ddos',\n 'time' => time.to_i,\n 'record' => {},\n },\n }\n assert_equal([\n ['localhost', 3030, expected],\n ], result)\n end",
"def create_simulators runtime_keyword, device_type_keywords\n selected_runtimes = @runtimes['runtimes'].select do |runtime| \n runtime['name'].downcase.include?(runtime_keyword)\n end\n selected_device_types = @device_types['devicetypes'].select do |device_type| \n device_type_keywords.select do |keyword| \n device_type['name'].downcase.include?(keyword)\n end.size > 0\n end\n selected_runtimes.product(selected_device_types).each do |runtime_device_type_pair_array|\n runtime = runtime_device_type_pair_array.first\n device_type = runtime_device_type_pair_array.last\n create_command = \"xcrun simctl create '#{device_type['name']}' #{device_type['identifier']} #{runtime['identifier']}\"\n puts create_command\n `#{create_command}`\n end\n end",
"def choose_metric(r, params)\n params == \"water_collected\" ? r.water_collected :\n params == \"water_used\" ? r.water_used :\n params == \"amount_overflown\" ? r.amount_overflown :\n params == \"ph\" ? r.ph : r.tds\n end",
"def create\n \t# ***** New ****\n\n \t@text = params[:text_inspection][:user_text]\n\n textins = TextInspection.new\n\n \t@freq_arr = textins.frequency(@text)\n\n # ***** New *****\n \t@word_count = @text.split(\" \").length\n\n \t@words_per_min = (@word_count / 275).ceil\n\n \trender 'result'\n\n \tend",
"def create\n @unit_of_measure = UnitOfMeasure.create(params[:unit_of_measure])\n get_data\n end",
"def query_metric(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:query]['Action'] = 'QueryMetric'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :dimensions\n\t\t\targs[:query]['Dimensions'] = optional[:dimensions]\n\t\tend\n\t\tif optional.key? :end_time\n\t\t\targs[:query]['EndTime'] = optional[:end_time]\n\t\tend\n\t\tif optional.key? :extend\n\t\t\targs[:query]['Extend'] = optional[:extend]\n\t\tend\n\t\tif optional.key? :length\n\t\t\targs[:query]['Length'] = optional[:length]\n\t\tend\n\t\tif optional.key? :metric\n\t\t\targs[:query]['Metric'] = optional[:metric]\n\t\tend\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :period\n\t\t\targs[:query]['Period'] = optional[:period]\n\t\tend\n\t\tif optional.key? :project\n\t\t\targs[:query]['Project'] = optional[:project]\n\t\tend\n\t\tif optional.key? :start_time\n\t\t\targs[:query]['StartTime'] = optional[:start_time]\n\t\tend\n\t\tself.run(args)\n\tend",
"def query_list_metric(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:query]['Action'] = 'QueryListMetric'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :dimensions\n\t\t\targs[:query]['Dimensions'] = optional[:dimensions]\n\t\tend\n\t\tif optional.key? :end_time\n\t\t\targs[:query]['EndTime'] = optional[:end_time]\n\t\tend\n\t\tif optional.key? :extend\n\t\t\targs[:query]['Extend'] = optional[:extend]\n\t\tend\n\t\tif optional.key? :filter\n\t\t\targs[:query]['Filter'] = optional[:filter]\n\t\tend\n\t\tif optional.key? :length\n\t\t\targs[:query]['Length'] = optional[:length]\n\t\tend\n\t\tif optional.key? :metric\n\t\t\targs[:query]['Metric'] = optional[:metric]\n\t\tend\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :period\n\t\t\targs[:query]['Period'] = optional[:period]\n\t\tend\n\t\tif optional.key? :project\n\t\t\targs[:query]['Project'] = optional[:project]\n\t\tend\n\t\tif optional.key? :start_time\n\t\t\targs[:query]['StartTime'] = optional[:start_time]\n\t\tend\n\t\tself.run(args)\n\tend",
"def make_omniture_key(metric, args)\n path = [\n args[:path].split('.'),\n 'omniture',\n 'v003',\n ]\n path.push(args[:key]) if args[:key] \n path.push(metric[:title].split(\"|\").map{|m|m.gsub(/[\\s.]/,'')}.join('-').downcase)\n path.push(args[:segment].gsub(/[ ], '-'/)) if args[:segment]\n path\nend",
"def add(args)\n args.each do |key, value|\n if value.respond_to?(:each)\n metric = value\n metric[:name] = key.to_s\n type = metric.delete(:type) || metric.delete('type') || 'gauge'\n else\n metric = {:name => key.to_s, :value => value}\n type = :gauge\n end\n type = (\"#{type}s\").to_sym\n unless skip_measurement_times\n metric[:measure_time] ||= epoch_time\n end\n @queued[type] ||= []\n @queued[type] << metric\n end\n queued\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 build_body(metric, timestamp, value)\n {\n \"metric\" => metric,\n \"timestamp\" => timestamp,\n \"value\" => value,\n \"tags\" => { \"status\" => \"test\" }\n }.to_json\nend",
"def create(opts)\n @frequence = opts[:frequence] if opts[:frequence].in? Recurrence::FREQUENCES\n @monthly = array_to_integer(opts[:monthly])\n @count = to_integer(opts[:count])\n @until = string_to_date(opts[:until])\n self\n end",
"def chart(metric_name, options={})\n parse_time_range(options)\n chart = Hash.new(0)\n if options[:time_start] && options[:time_end]\n time = options[:time_start]\n if options[:data_points]\n total_time = options[:time_end] - options[:time_start]\n options[:step] = total_time.to_i / options[:data_points]\n end\n while time < options[:time_end]\n chart[time.to_i] = DulyNoted.count(metric_name, :time_start => time, :time_end => time+options[:step], :for => options[:for])\n time += options[:step]\n end\n elsif options[:step] && options[:data_points] && (options[:time_end] || options[:time_start])\n raise InvalidStep if options[:step] == 0\n options[:step] *= -1 if (options[:step] > 0 && options[:time_end]) || (options[:step] < 0 && options[:time_start])\n time = options[:time_start] || options[:time_end]\n step = options[:step]\n options[:data_points].times do\n options[:time_start] = time\n options[:time_start] += step if step < 0\n options[:time_end] = time\n options[:time_end] += step if step > 0\n chart[time.to_i] = DulyNoted.count(metric_name, options)\n time += step\n end\n elsif options[:data_points]\n key = build_key(metric_name)\n key << assemble_for(options)\n options[:time_start] = Time.at(DulyNoted.redis.zrange(key, 0, 0, :with_scores => true)[0][1])\n options[:time_end] = Time.at(DulyNoted.redis.zrevrange(key, 0, 0, :with_scores => true)[0][1])\n chart = DulyNoted.chart(metric_name, options)\n else\n raise InvalidOptions\n end\n return chart\n end",
"def metric_params\n params.require(:metric).permit(:name, :definition, :ad_format, :environment, :test_slots_count, :suite_id, :metric_type, :max_days_since_last_passed_test)\n end",
"def type *params\n raise_without_self \"Parameters are not specified!\", HOWT if params.empty?\n params = params[0]\n unless params.is_a?(Hash) && params.size > 0\n raise_without_self \"Invalid parameters. Should be Text or Fuzzy Search parameters!\", HOWT\n end\n\n # reduce short form to full\n params = {@text_default => params.keys[0], :text => params.values[0]} if params.size == 1\n\n\n # parse full form\n opt = OpenStruct.new(:control_text => nil)\n value = params[:text]\n parse_metric params, opt\n\n raise_without_self \"Value cannot be 'nil'\", HOWT unless value\n\n return @adapter.type(opt, value.to_s)\n end",
"def mlsAutoPreQual\r\n # Check max runs\r\n daily_pdq_cnt = Output.where(\"runid LIKE ?\", \"%#{Time.now.to_date}\").length\r\n max_count = 400 - daily_pdq_cnt\r\n max_count = 2\r\n puts \"max_count: #{max_count}\"\r\n\r\n # Build POST call\r\n base_url = \"https://api.mpoapp.com/v1/properties/_search?api_key=#{@@MLS_TOKEN}\"\r\n h = {\"Content-Type\" => 'application/json; charset=UTF-8', \"Cache-Control\" => \"no-cache\"}\r\n\r\n data = {:from => 0, :size => max_count, :sort => {:_created => {:order => \"desc\"}}}\r\n\r\n query_string = \"primary.price.listingPrice: [250000 TO 5000000]\" # price condition\r\n query_string += \" AND mls.onMarketDate:[#{(Time.now.to_date - params[:dayCount].to_i).to_s} TO *]\" # days on market\r\n query_string += \" AND construction.yearBuilt: {* TO #{(Time.now.year.to_i-1).to_s}}\" # build year condition\"\r\n\r\n data[:query] = {:bool => {:minimum_should_match => 1, \r\n :must => [\r\n {:query_string => {:query => query_string}},\r\n {:terms => {\"primary.mpoPropType\" => [\"singleFamily\", \"condominium\", \"loft\", \"apartment\"]}},\r\n {:terms => {\"primary.mpoStatus\" => [\"active\"]}},\r\n {:terms => {\"mls.knownShortSale\" => [\"false\"]}},\r\n \r\n ]\r\n }\r\n }\r\n\r\n # PDQ params\r\n pdq_params = {:path => \"Mls\"}\r\n runID = \"#{pdq_params[:path]}: #{Date.today.to_s}\"\r\n\r\n # Get Results\r\n response = HTTParty.post(base_url, :body => data.to_json, :headers => h)\r\n json_result = JSON.parse(response.to_json) \r\n results = json_result[\"results\"]\r\n\r\n # Get Addresses\r\n results.each do |r|\r\n values = r[\"primary\"][\"address\"]\r\n\r\n # Build street\r\n street = values[\"streetNum\"]\r\n street += \" #{values[\"streetDirection\"]}\" unless values[\"streetDirection\"].nil?\r\n street += \" #{values[\"streetName\"]}\" unless values[\"streetName\"].nil?\r\n street += \" #{values[\"streetSuffix\"]}\" unless values[\"streetSuffix\"].nil?\r\n street += \" Unit #{values[\"unitNum\"]}\" unless values[\"unitNum\"].nil?\r\n\r\n # Build city, state, zip\r\n csz = \"#{values[\"city\"]}, #{values[\"state\"]} #{values[\"zipCode\"]}\"\r\n\r\n # Run through PDQ\r\n # street = MiscFunctions.addressStringClean(street)\r\n # csz = MiscFunctions.addressStringClean(csz)\r\n print \"#{street} + #{csz}\"\r\n geo_data = GeoFunctions.getGoogleGeoByAddress(street, csz)\r\n\r\n a = PdqEngine.computeDecision(geo_data, pdq_params, runID)\r\n end\r\n\r\n @outputs = Output.all\r\n @forexport = false\r\n render 'outputs/index'\r\n end",
"def get_data(startdate, enddate)\n\t\t\n\t\tdate_range = @analytics::DateRange.new(start_date: startdate, end_date: enddate)\n\t\torder_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')\n\t\t# metric = @analytics::Metric.new(expression: 'ga:sessions')\n\t\t# metric = @analytics::Metric.new(expression: ['ga:sessions', 'ga:uniquePageviews'])\n\t\t# metric = @analytics::Metric.new\n\t\t# metric.expression = ['ga:sessions', 'ga:uniquePageviews']\n\t\t\n\t\tmetrics = ['ga:pageviews', 'ga:users', 'ga:bounces', 'ga:sessions',\n\t\t\t\t 'ga:avgTimeOnPage', 'ga:newUsers', 'ga:goal1ConversionRate', 'ga:goal1Completions'\n\t\t\t\t ]\n\n\t\t# metrics = ['ga:totalEvents'\n\t\t# \t\t ]\t\t \n\n\n\t\tmetric_type = Array.new\n\t\tmetrics.each do |m|\n\t\t\tmetric = @analytics::Metric.new\n\t\t\tmetric.expression = m\n\t\t\tmetric_type.push(metric)\n\t\tend\n\n\t\tdimensions = ['ga:pagePath', 'ga:pageTitle', 'ga:hostname' ]\n\t\t# dimensions = ['ga:pagePath', 'ga:eventCategory']\n\t\tdimension_type = Array.new\n\t\tdimensions.each do |d|\n\t\t\tdimension = @analytics::Dimension.new\n\t\t\tdimension.name = d\n\t\t\tdimension_type.push(dimension)\n\t\tend\n\n\n\t\t# dimension = @analytics::Dimension.new(name: 'ga:pagePath')\n\n\t\t# dimension_filters = @analytics::DimensionFilterClause.new(\n\t # filters: [\n\t # @analytics::DimensionFilter.new(\n\t # dimension_name: 'ga:pagePath',\n\t # operator: \"IN_LIST\",\n\t # expressions: ['/archives/69839', '/archives/54087', '/archives/68924', '/archives/58437', '/archives/65171', '/archives/64435', '/archives/61533', '/archives/68924',\n\t # \t\t\t\t'/archives/65086', '/archives/64736', '/archives/55244', '/archives/68211'\n\t # ]\n\t # )\n\t # ]\n\t # )\n\n\t\trequest = @analytics::GetReportsRequest.new(\n \t\t\treport_requests: [@analytics::ReportRequest.new(\n \t\t\tview_id: @view_id, \n \t\t\tmetrics: metric_type, \n \t\t\tdimensions: dimension_type,\n \t\t\t# dimension_filter_clauses: [dimension_filters],\n \t\t\t# dimensions: [dimension], \n \t\t\tdate_ranges: [date_range],\n \t\t\torder_bys: [order_by],\n \t\t\tpageSize: 10000\n \t\t\t)]\n\t\t)\n\t\tresponse = @client.batch_get_reports(request)\n\t\tmessageHash = {}\n\n\t\t# handling error \n\t\tif !response.reports.first.data.rows then\n\t\t\t\n\t\t\tkey = \"message\"\n\t\t\tmessageHash[key.to_sym] = \"no data\"\n\t\t \treturn messageHash\n\t\tend\n\n\n\t\tdata_from_google = response.reports.first.data.rows\n\n\t\tkey_array = dimensions + metrics\n\n\t\t# get rid of 'ga:'\n\t\tkey_array.each_with_index do |k, index| \n\t\t\tkey_array[index] = k.gsub(\"ga:\",\"\")\n\t\tend\n\n\t\tkey_array.push('id')\n\t\tkey_array.push('clickCount')\n\n\t\tset_ga_data_array = Array.new\n\n\n\t\tdata_from_google.each_with_index do |r, index|\n\n\t\t\tdatahash = {}\n\t\t\ti = 0;\n\n\t\t\t# setup dimension part\n\t\t\tr.dimensions.each do |d|\n\t\t\t\tdatahash[key_array[i]] = d\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\t# setup metrics part\n\t\t\tr.metrics.first.values.each do |m|\n\t\t\t\tdatahash[key_array[i]] = m\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\t\n\t\t\t# get aticle data from db\n\t\t\tarticleArr = set_article_data(datahash['hostname'], datahash['pagePath'], startdate, enddate)\n\n\t\t\t# setup id, mcv\n\t\t\tarticleArr.each do |a|\n\t\t\t\tdatahash[key_array[i]] = a\n\t\t\t\ti += 1\n\t\t\tend\n\n\t\t\tset_ga_data_array.push(datahash)\n\n\t\t\t#datahash sample -> { \"pagePath\": \"/archives/69839\", ... , \"goal1Completions\": \"23\", \"id\": 4, \"clickCount\": 0 },\n\t\tend\n\t\t\n\t\treturn set_ga_data_array\n\tend",
"def to_metric\n Metric.new(\n Instrumentation.series,\n {\n duration: real_time.in_milliseconds.to_i,\n cpu_duration: cpu_time.in_milliseconds.to_i,\n call_count: call_count\n },\n method: @name\n )\n end",
"def add_measures(connection, food_record)\n results = connection.exec(\"SELECT amount, description, grams FROM weight WHERE id = '#{food_record['id']}' ORDER BY sequence\")\n list = []\n list.push( { 'measure' => '100 grams', 'kcals' => food_record['kcal'].to_i, 'grams' => 100 })\n # example record: { \"amount\": \"1\", \"description\": \"cup\", \"grams\": \"185\" }\n results.each do |rec|\n text = [ rec['amount'].to_s, rec['description'] ].join(' ')\n kcals = food_record['kcal'].to_f * rec['grams'].to_f / 100\n list.push( { 'measure' => text.strip, 'kcals' => kcals.to_i, 'grams' => rec['grams'].to_i })\n end\n food_record['measures'] = list\nrescue PG::Error => e\n STDERR.puts e\n exit -1\nend",
"def create_event(api_data, artist_id) \n \n i=0\n display_names = []\n uris = []\n dates = []\n times = []\n locations = []\n\n api_data.each do |key, value|\n value.each do |k2, v2|\n if k2 == \"results\"\n v2.each do |k3, v3|\n v3.each do |results|\n results.each do |k4, v4|\n if k4 === \"displayName\"\n display_names << v4\n end \n if k4 === \"uri\"\n uris << v4\n end \n if k4 === \"location\"\n v4.each do |k5, v5|\n if k5 === \"city\"\n locations << v5\n end \n end \n end \n if k4 === \"start\" \n v4.each do |k5, v5|\n if k5 === \"date\"\n dates << v5\n end \n if k5 === \"time\"\n if v5 === nil\n times << \"TBA\"\n else\n times << v5\n end\n end \n end \n end \n end \n end \n end \n end \n end \n end \n\n loop_times = 5 \n\n if display_names.length < loop_times \n loop_times = display_names.length\n end \n \n loop_times.times do \n Event.create(name: display_names[i], location: locations[i], event_url: uris[i], date: dates[i], time: times[i], artist_id: artist_id)\n i += 1\n end \n\nend",
"def test_format\n\n\t data = analyse_log(@filename,@keywords, @start, Time.parse(\"31.12.3000\"), @output_file)\n \tdata_hist = prepare_data(data, @keywords, @start, 3600)\n\n \tassert_equal(true, data_hist.keys[0].class == String)\n \tassert_equal(true, data_hist[@keywords[0]].keys[0].class == Time)\n \tassert_equal(true, data_hist[@keywords[0]][0].class == Fixnum)\n\tend",
"def create\n @search = @website.searches.new params[:search]\n\n\t\[email protected] = @website.search_url(params[:search_terms]) if params[:search_terms]\n\n @search.terms = @search.description.split(' ') if params[:use_description_terms]\n\n respond_to do |format|\n if @search.save\n\n format.html { redirect_to website_search_url(@website, @search), notice: 'Search was successfully created.' }\n format.json { render json: @search, status: :created, location: @search }\n else\n format.html { render action: \"new\" }\n format.json { render json: @search.errors, status: :unprocessable_entity }\n end\n end\n end",
"def metric(name = :mandatory, *opts)\n raise OEDLMissingArgumentException.new(:metric, :name) if name == :mandatory\n\n \t # For each of the metrics...\n \t opts.each do |parameter|\n # Get its detail from the application definition\n #appDef = AppDefinition[@application.to_s]\n appDef = @application.appDefinition\n \t measurementDef = appDef.measurements[@mdef]\n \t metricDef = measurementDef.metrics[parameter]\n # Set the default filter based on the metric type\n \t if metricDef[:type] == \"xsd:float\" || metricDef[:type] == \"xsd:int\" \\\n || metricDef[:type] == \"xsd:long\" || metricDef[:type] == \"xsd:short\"\n filterType = 'avg'\n \t else\n filterType = 'first'\n \t end\n # Build and Add the metric to this Measurement Stream\n filter = OMF::EC::OML::Filter.new(filterType, \"#{name}_#{parameter}\", {:input => parameter})\n \t @filters << filter\n \t end\n end",
"def valid_metric(length)\n name = \"statsd-cluster.count\"\n number = rand(100).to_s\n name_length = name.length + number.length\n if name_length < length\n name += (\"X\" * (length - name_length) + number)\n end\n a = hashring(name)\n # to simplify metric identification counter value grows from 0 to 1000, after that is reset back to 0 and so on\n @counter = (@counter + 1) % 1000\n # only counters are generated\n data = name + \":#{@counter}|c\"\n # we return data necessary to register metric in message queue and expected events\n {\n hashring: a,\n data: data,\n event: {source: \"statsd\", text: data}\n }\n end",
"def calculate_new_resolution_meta\n # determine new meta information and create ne meta object\n meta_string = [@meta_data.name]\n meta_string.concat(create_new_data_dimensions)\n meta_string.concat(add_domain_information(@meta_data.domain_z, @meta_data.domain_z.step))\n # return the new meta data object\n @scaled_meta = TerminalVis::MetaData::VisMetaData.new(meta_string)\n end",
"def to_metric\n Metric.new(\n Instrumentation.series,\n {\n duration: real_time,\n cpu_duration: cpu_time,\n call_count: call_count\n },\n method: @name\n )\n end",
"def create\n rendered_time, referer, user = tracking_info\n assessment_result = user.assessment_results.create!(\n assessment_id: params[:assessment_id],\n eid: params[:eid],\n src_url: params[:src_url],\n external_user_id: params[:external_user_id],\n identifier: params['identifier'],\n rendered_datestamp: rendered_time,\n referer: referer,\n ip_address: request.ip,\n session_status: 'initial')\n\n assessment_result.keyword_list.add(params[:keywords], parse: true) if params[:keywords]\n assessment_result.objective_list.add(params[:objectives], parse: true) if params[:objectives]\n assessment_result.save! if params[:objectives] || params[:keywords]\n respond_with(:api, assessment_result)\n end",
"def build_pattern()\n picking_pattern = { \"repetitions\" => @repetitions }\n\n pattern = \"\"\n (1..@sixteenths_per_measure).each { pattern.concat(\"0,\")}\n picking_pattern[:pattern] = pattern.slice(0..pattern.length - 2)\n\n picking_pattern\n\n end",
"def create_d_b_metric(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'POST'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/dbMetrics'\n\t\targs[:query]['Action'] = 'CreateDBMetric'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :metric\n\t\t\targs[:body]['Metric'] = optional[:metric]\n\t\tend\n\t\tself.run(args)\n\tend",
"def query(metric_name, options={})\n key = build_key(metric_name)\n parse_time_range(options)\n key << assemble_for(options)\n if options[:id]\n key = \"dnid:#{options[:id]}\"\n real_key = DulyNoted.redis.get key\n if options[:meta_fields]\n options[:meta_fields].collect! { |x| x.to_s }\n result = {}\n options[:meta_fields].each do |field|\n result[field] = DulyNoted.redis.hget real_key, field\n end\n results = [result]\n else\n results = [DulyNoted.redis.hgetall(real_key)]\n end\n else\n keys = find_keys(key)\n grab_results = Proc.new do |metric|\n if options[:meta_fields]\n options[:meta_fields].collect! { |x| x.to_s }\n result = {}\n options[:meta_fields].each do |field|\n result[field] = DulyNoted.redis.hget metric, field\n end\n result\n else\n DulyNoted.redis.hgetall metric\n end\n end\n results = []\n if options[:time_start] && options[:time_end]\n keys.each do |key|\n results += DulyNoted.redis.zrangebyscore(key, options[:time_start].to_f, options[:time_end].to_f).collect(&grab_results)\n end\n else\n keys.each do |key|\n results += DulyNoted.redis.zrange(key, 0, -1).collect(&grab_results)\n end\n end\n end\n return results\n end",
"def create_custom_metric request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_create_custom_metric_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Analytics::Admin::V1alpha::CustomMetric.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def make_new_searches\n\t\n\turl = \"/Users/MichaelB/Documents/TenTracks/artists.html\"\n\t\n\t\n\tdoc = Nokogiri::HTML(open(url))\n\tbands_array = doc.css(\"h1\")\n\ti=259\n\t#Rails.logger.debug(i)\n\t\n\twhile i < bands_array.length or i < 10\n\t\n\tRails.logger.debug(i)\n\tRails.logger.debug(bands_array[i].content)\n\t\n\ttest = EventSearch.where(:bandName => bands_array[i].content)\n\t\n\tif !test[0]\n\t\n\tes = EventSearch.new\n\tes.bandName = bands_array[i].content\n\t\n\tband_search = bands_array[i].content.split(' ').join(\"+\")\n\t\n\turl2 = \"http://www.myspace.com/search/music?q=\" << band_search << \"&ac=t\"\n\t#Rails.logger.debug(url2)\n\t\n\tif validate(url2)\n\tdoc2 = Nokogiri::HTML(open(url2))\n\tband_url_array = doc2.css(\".beacon .beacon\")\n\t\n\t\tif band_url_array[0]\n\t\t\tRails.logger.debug(band_url_array[0][:href])\n\t\t\tes.urlOne = band_url_array[0][:href]\n\t\t\tes.eventDateCSS = \".entryDate\"\n\t\t\tes.eventLocationCSS = \"#module9 a\"\n\t\t\tes.descriptionCSS = \"#module9 p\"\n\t\telse\n\t\tRails.logger.debug(\"Invalid myspace link\")\n\t\tes.urlOne = \"Invalid myspace link\"\n\t\tend\n\t\n\telse\n\tRails.logger.debug(\"Invalid myspace link\")\n\tes.urlOne = \"Invalid myspace link\"\n\t\n\tend # of validate\n\t\n\tes.save\n\t\n\tend #of test\n\t\n\ti += 1\n\tend # of while\n\t\n end",
"def create_number_point start_time, end_time, value, measure\n value = if measure.int64?\n { int64_value: value }\n else\n { double_value: value }\n end\n\n Google::Cloud::Monitoring::V3::Point.new(\n interval: {\n start_time: convert_time(start_time),\n end_time: convert_time(end_time)\n },\n value: value\n )\n end",
"def create\n searchterm = current_user.searches.new(:search_term=>params[:searchterm],:type=>\"case\")\n # check condition for searchterm is saved or not.\n if searchterm.save\n # response to the JSON\n render json: { success: true,message: \"Search Term Successfully Created.\", response: searchterm.as_json('search') },:status=>200\n else\n render :json=> { success: false, message: searchterm.errors },:status=> 203\n end\n end",
"def call\n missing_metrics.each(&method(:create_metric))\n missing_methods.each(&method(:create_method))\n end",
"def create\n @unidade_metrica = UnidadeMetrica.new(params[:unidade_metrica])\n\n respond_to do |format|\n if @unidade_metrica.save\n format.html { redirect_to unidade_metricas_url }\n format.json { head :no_content }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unidade_metrica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def url_create\n\n # secure the creation of new measurements\n if @profile.secure_data_entry\n unless @profile.data_entry_key == params[:key]\n return\n end\n end\n \n\n # Are the data submitted in this query a test?\n is_test_value = false\n if params.key?(:test)\n is_test_value = true\n end\n \n # Save the url that invoked us\n Instrument.update(params[:instrument_id], :last_url => request.original_url)\n\n # Create an array containing the names of legitimate variable names\n measured_at_parameters = Array.new\n variable_shortnames = Array.new\n \n Instrument.find(params[:instrument_id]).vars.each do |var|\n measured_at_parameters.push(var.measured_at_parameter)\n variable_shortnames.push(var.shortname)\n \n # see if the parameter was submitted\n \n if params.include? var.shortname\n\n if params.key?(var.measured_at_parameter)\n measured_at = params[var.measured_at_parameter]\n elsif params.key?(var.at_parameter)\n measured_at = params[var.at_parameter]\n elsif params[:at]\n measured_at = params[:at]\n else \n measured_at = Time.now \n end\n # Create a new measurement\n @measurement = Measurement.new(\n :measured_at => measured_at,\n :instrument_id => params[:instrument_id], \n :test => is_test_value,\n :parameter => var.shortname, \n :value => params[var.shortname])\n @measurement.save\n end\n end\n\n respond_to do |format|\n if @measurement.save\n format.json { render text: \"OK\" }\n format.html { render :show, status: :created, location: @measurement, message: \"Measurement created\" }\n else\n format.html { render :new }\n format.json { render json: @measurement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \t\t@searchterm = current_user.searches.create(:search_term=>params[:searchterm],:type=>\"question\")\n \tend",
"def to_metric_ton(**options) = convert_to('metric-ton', **options)",
"def register_counter(type)\n register_metric( Drone::Metrics::Counter.new(type) )\n end",
"def frequency\n @days = 7 # default: look at last 7 days\n unless (params[:commit].nil?)\n where_array = Array.new\n condition_array = ['place holder']\n if (not params[:days].nil? and not params[:days].empty?)\n @days = params[:days]\n end\n condition_array << @days\n where_array << \"alert_date > date_sub(curdate(), interval ? day) and alert_date < curdate()\"\n comment_array = [\"For last #{@days} days\"]\n if (not params['name_q'].nil? and not params['name_q'].empty?)\n @name_q = params[:name_q]\n condition_array << @name_q.condition\n where_array << @name_q.where('devices.name')\n comment_array << \"Name = #{@name_q}\"\n end\n if(not params['model_q'].nil? and not params['model_q'].empty?)\n @model_q = params[:model_q]\n condition_array << @model_q.condition\n where_array << @model_q.where('devices.model')\n comment_array << \"Model = #{@model_q}\"\n end\n if(not params['serial_q'].nil? and not params['serial_q'].empty?)\n @serial_q = params[:serial_q]\n condition_array << @serial_q.condition\n where_array << @serial_q.where('devices.serial')\n comment_array << \"Serial # = #{@serial_q}\"\n end\n if(not params['code_q'].nil? and not params['code_q'].empty?)\n @code_q = params[:code_q]\n where_array << @code_q.where('devices.code')\n condition_array << @code_q.condition\n comment_array << \"Machine Code = #{@code_q}\"\n end\n if (not params[:client].nil? and not params[:client][:name].empty?)\n @client = Client.new\n @client['name'] = params[:client][:name]\n where_array << @client.name.where('clients.name')\n condition_array << @client.name.condition\n comment_array << \"Client Name contains #{@client.name}\"\n end\n if(not params['msg_q'].nil? and not params['msg_q'].empty?)\n @msg_q = params[:msg_q]\n where_array << @msg_q.where('alert_msg')\n condition_array << @msg_q.condition\n comment_array << \"Message contains #{@msg_q}\"\n end\n unless where_array.empty?\n condition_array[0] = where_array.join(' and ')\n @comment = comment_array.join(' and ')\n else\n condition_array = []\n end\n end\n @alert_counts = Alert.where(condition_array).joins(:device => :client).group('device_id','date(alert_date)').order('devices.name').count\n @devices = @alert_counts.keys.map { |key| key[0] }.uniq\n @dates = ([email protected]_i..Date.today-1).map {|d| d }\n end",
"def peak_reg_time()\n arr_hour = $reg_cluster[\"hour\"]\n arr_hour.map { |h| [h, arr_hour.count(h)] }.sort { |a,b| b[1] <=> a[1] }[0..2].map { |val| if !$reg_cluster[\"peak_times\"].include?(val)\n $reg_cluster[\"peak_times\"].push(val)\n end }\n\n #format hour \n def format_hour (hour)\n if hour.to_i > 12 \n hour = (hour.to_i - 12).to_s + \" P.M.\" \n else \n hour = hour + \" A.M.\"\n end \n end \n\n #peak registration days\n arr_day = $reg_cluster[\"days\"]\n arr_day.map { |d| [d, arr_day.count(d)] }.sort { |a,b| b[1] <=> a[1] }.map { |val| if !$reg_cluster[\"peak_days\"].include?(val)\n $reg_cluster[\"peak_days\"].push(val)\n end }\n\n #format day\n def format_day (day)\n case day\n when 0\n \"Sunday\"\n when 1\n \"Monday\"\n when 2\n \"Tuesday\"\n when 3\n \"Wednesday\"\n when 4\n \"Thursday\"\n when 5\n \"Friday\"\n when 6\n \"Saturday\"\n else \"day error\"\n end\n end \n \n #marketing message\n puts \"Peak registration times are #{format_hour($reg_cluster[\"peak_times\"][0][0])} and #{format_hour($reg_cluster[\"peak_times\"][1][0])} on #{format_day($reg_cluster[\"peak_days\"][0][0])}s and #{format_day($reg_cluster[\"peak_days\"][1][0])}s\"\n\nend",
"def convert_to_metric(measurement, conversion_factor)\n measurement * conversion_factor\nend",
"def convert_to_metric(measurement, conversion_factor)\n measurement * conversion_factor\nend",
"def describe_metric_datum(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:query]['Action'] = 'DescribeMetricDatum'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :dimensions\n\t\t\targs[:query]['Dimensions'] = optional[:dimensions]\n\t\tend\n\t\tif optional.key? :end_time\n\t\t\targs[:query]['EndTime'] = optional[:end_time]\n\t\tend\n\t\tif optional.key? :extend\n\t\t\targs[:query]['Extend'] = optional[:extend]\n\t\tend\n\t\tif optional.key? :length\n\t\t\targs[:query]['Length'] = optional[:length]\n\t\tend\n\t\tif optional.key? :metric\n\t\t\targs[:query]['Metric'] = optional[:metric]\n\t\tend\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :period\n\t\t\targs[:query]['Period'] = optional[:period]\n\t\tend\n\t\tif optional.key? :project\n\t\t\targs[:query]['Project'] = optional[:project]\n\t\tend\n\t\tif optional.key? :start_time\n\t\t\targs[:query]['StartTime'] = optional[:start_time]\n\t\tend\n\t\tself.run(args)\n\tend",
"def get_metric_statistics ( options ={} )\n options = { :custom_unit => nil,\n :dimensions => nil,\n :end_time => Time.now(), #req\n :measure_name => \"\", #req\n :namespace => \"AWS/EC2\",\n :period => 60,\n :statistics => \"\", # req\n :start_time => (Time.now() - 86400), # Default to yesterday\n :unit => \"\" }.merge(options)\n\n raise ArgumentError, \":end_time must be provided\" if options[:end_time].nil?\n raise ArgumentError, \":end_time must be a Time object\" if options[:end_time].class != Time\n raise ArgumentError, \":start_time must be provided\" if options[:start_time].nil?\n raise ArgumentError, \":start_time must be a Time object\" if options[:start_time].class != Time\n raise ArgumentError, \":start_time must be before :end_time\" if options[:start_time] > options[:end_time]\n raise ArgumentError, \":measure_name must be provided\" if options[:measure_name].nil? || options[:measure_name].empty?\n raise ArgumentError, \":statistics must be provided\" if options[:statistics].nil? || options[:statistics].empty?\n\n params = {\n \"CustomUnit\" => options[:custom_unit],\n \"EndTime\" => options[:end_time].iso8601,\n \"MeasureName\" => options[:measure_name],\n \"Namespace\" => options[:namespace],\n \"Period\" => options[:period].to_s,\n \"StartTime\" => options[:start_time].iso8601,\n \"Unit\" => options[:unit]\n }\n\n # FDT: Fix statistics and dimensions values\n if !(options[:statistics].nil? || options[:statistics].empty?)\n stats_params = {}\n i = 1\n options[:statistics].split(',').each{ |stat|\n stats_params.merge!( \"Statistics.member.#{i}\" => \"#{stat}\" )\n i += 1\n }\n params.merge!( stats_params )\n end\n\n if !(options[:dimensions].nil? || options[:dimensions].empty?)\n dims_params = {}\n i = 1\n options[:dimensions].split(',').each{ |dimension|\n dimension_var = dimension.split('=')\n dims_params = dims_params.merge!( \"Dimensions.member.#{i}.Name\" => \"#{dimension_var[0]}\", \"Dimensions.member.#{i}.Value\" => \"#{dimension_var[1]}\" )\n i += 1\n }\n params.merge!( dims_params )\n end\n\n return response_generator(:action => 'GetMetricStatistics', :params => params)\n\n end",
"def test_known_rule_creation_by_shortened_name\n rule_type = :RequestCount\n rule = RSlow::Rule.generate(rule_type)\n assert_instance_of(RSlow::Rules::RequestCountRule, rule)\n end",
"def get_metric_statistics(options={})\n # Period (60 sec by default)\n period = (options[:period] && options[:period].to_i) || 60\n # Statistics ('Average' by default)\n statistics = Array(options[:statistics]).flatten\n statistics = statistics.blank? ? ['Average'] : statistics.map{|statistic| statistic.to_s.capitalize }\n # Times (5.min.ago up to now by default)\n start_time = options[:start_time] || (Time.now.utc - 5*60)\n start_time = start_time.utc.strftime(\"%Y-%m-%dT%H:%M:%S+00:00\") if start_time.is_a?(Time)\n end_time = options[:end_time] || Time.now.utc\n end_time = end_time.utc.strftime(\"%Y-%m-%dT%H:%M:%S+00:00\") if end_time.is_a?(Time)\n # Measure name\n measure_name = options[:measure_name] || 'CPUUtilization'\n # Dimentions (a hash, empty by default)\n dimentions = options[:dimentions] || {}\n #\n request_hash = { 'Period' => period,\n 'StartTime' => start_time,\n 'EndTime' => end_time,\n 'MeasureName' => measure_name }\n request_hash['Unit'] = options[:unit] if options[:unit]\n request_hash['CustomUnit'] = options[:custom_unit] if options[:custom_unit]\n request_hash['Namespace'] = options[:namespace] if options[:namespace]\n request_hash.merge!(amazonize_list('Statistics.member', statistics))\n # dimentions\n dim = []\n dimentions.each do |key, values|\n Array(values).each { |value| dim << [key, value] }\n end\n request_hash.merge!(amazonize_list(['Dimensions.member.?.Name', 'Dimensions.member.?.Value'], dim))\n #\n link = generate_request(\"GetMetricStatistics\", request_hash)\n request_info(link, GetMetricStatisticsParser.new(:logger => @logger))\n end",
"def get_metric m, start, stop, step\n\t\tdata = json_metrics get_metric_url(m, start, stop, step)\n\t\t\n\t\t# Return structure is a nested hash labeled in segments from the metric name\n\t\t# We want just the internal nest of value > data for parsing\n\t\tkey = m.metric_id; \n\t\t*key, last = key.split(\"/\").map{|b| b.to_sym}\n\t\tnice_data = key.inject(data, :fetch)[last] #[:value][:data]\n\n\t\t# So sometimes, visage likes to return multiple metrics. \n\t\t# I have no idea what to do about this yet, so TODO, and failout nicely for now. \t\t\n\t\tunless nice_data.keys.length == 1\n\t\t\treturn {error: \"Machiavelli can't yet parse a Visage metric with multiple keys: #{nice_data.keys}\" }\n\t\tend\n\n\t\t# Points are now a long list of y values with a common step. \n\t\t# So, parse it out into a nice array of x,y hashes\n\t\t# TODO validate step logic and output, 'resolution' in visage seems a bit.. off.. \n\t\txy_data = []\n\t\tpoint_data = nice_data[nice_data.keys[0].to_sym][:data]\n\t\t(start..stop).step(step).each_with_index { |x, i|\n\t\t\txy_data << {x: x, y: point_data[i]}\n\t\t}\n\n\t\tdata_sanitize xy_data, start, stop, step\n\tend",
"def create_fimi(start_dt, end_dt, tagger, lookup, interval=1)\n current_start = start_dt\n db = NewsAnalyzer::News.new(\"dbi:Mysql:newsplus:#{@host}\")\n\n files = []\n while current_start < end_dt\n file = File.new(@data_dir + '/' + current_start.iso8601, 'w')\n warn file.path\n\n titles = db.get_titles(current_start, current_start + interval)\n printf($stderr, \"read %s to %s (%d)\\n\", current_start.iso8601, (current_start + interval).iso8601, titles.size)\n\n words = docs = 0\n titles.each do |row|\n t = row[\"title\"].force_encoding(Encoding::UTF_8)\n\n ids = tagger.hatena_keyword(t).map{|keyword|\n lookup[keyword]\n }.select{|e| e}\n next if ids.empty?\n file.puts(ids.sort.join(' '))\n words += ids.size\n docs += 1\n end\n file.close\n\n printf $stderr, \"total_words: %d total_docs: %d average_words %f\\n\", words, docs, words.to_f / docs\n files.push(file)\n current_start += interval\n end\n return files\nend",
"def make_emma_record(data, **)\n Search::Record::MetadataRecord.new(data)\n end",
"def initialize(...)\n @metrics = {}\n register(...)\n end",
"def create\n @type = params[:type]\n item = params.require(:item)\n @mac = item.require(:machine)\n machine = Machine.check(@mac.permit(:mac))\n\n data = item.require(:data)\n @result = Array.new\n\n data.each do |d|\n ads = Array.new\n\n ad_list = d.require(:ads)\n ad_list.each do |ad_data|\n ads << Ad.new(ad_data.permit(:channel, :value, :range))\n end\n\n gp40 = machine.gp40s.create(d.permit(:date, :beginning))\n gp40.ads = ads\n\n @result << gp40\n end\n\n render :status => :created\n end",
"def create\n @sensory_analysis = @sample.sensory_analyses.build(sensory_analysis_params)\n\n @metric = Metric.find( @sensory_analysis.metric.id)\n respond_to do |format|\n if @sensory_analysis.save\n flash[:success] = 'Sensory analysis was successfully created.'\n format.html { redirect_to action: 'index', metric_id: @metric}\n format.json { render :show, status: :created, location: @sensory_analysis }\n else\n format.html { render :new }\n format.json { render json: @sensory_analysis.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @metric_source = MetricSource.new(metric_source_params)\n\n respond_to do |format|\n if @metric_source.save\n format.html { redirect_to @metric_source, notice: 'Metric source was successfully created.' }\n format.json { render :show, status: :created, location: @metric_source }\n else\n format.html { render :new }\n format.json { render json: @metric_source.errors, status: :unprocessable_entity }\n end\n end\n end",
"def creat_requiredperformance(json)\n # change all min values to sec\n if json[\"req_unit\"] == \"Min.\"\n splitTime = json[\"requirement\"].split(\":\")\n value = splitTime[0].to_f * 60 + splitTime[1].to_f\n else\n # need because \",\" can not cast to float\n s = json[\"requirement\"]\n if s.index(',').nil?\n value = s.to_f\n else\n s[s.index(',')] = '.'\n value = s.to_f\n end\n end\n # save query in vars for Performance joins\n reqper = RequiredPerformance.new(:value => value)\n med = Medal.find_by_sign(json[\"level\"])\n ge = Gender.find_by_sex(json[\"gender\"])\n di = Discipline.find_by_name_and_gender_id(json[\"disciplin\"],ge.id)\n age_range = json[\"age_group\"].split(\"-\")\n min_age = age_range[0].to_i\n ag = AgeRange.find_by_min_age(min_age)\n disag = DisciplineAge.find_by_discipline_id_and_age_range_id(di.id,ag.id)\n # join Performance with Meadl and Age\n med.required_performances << reqper\n disag.required_performances << reqper\nend",
"def create\n @measure = @attribute.attribute_measures.new(measure_params)\n if @measure.save\n render json: @measure, status: :created, location: entity_attribute_measure_url(@entity, @attribute, @measure)\n else\n render json: @measure.errors, status: :unprocessable_entity\n end\n end"
] | [
"0.59261656",
"0.58557934",
"0.55596787",
"0.55426264",
"0.5375842",
"0.53575224",
"0.5240023",
"0.52255964",
"0.52010566",
"0.51951087",
"0.513933",
"0.51354957",
"0.50977165",
"0.5075539",
"0.5066253",
"0.5062732",
"0.5054314",
"0.5042691",
"0.5036032",
"0.5024833",
"0.50049573",
"0.5004203",
"0.49866006",
"0.49682027",
"0.4960283",
"0.49325272",
"0.49206468",
"0.4916425",
"0.49159446",
"0.49113536",
"0.48842207",
"0.48826182",
"0.48781353",
"0.48781353",
"0.48781353",
"0.4854146",
"0.48478654",
"0.48178747",
"0.47960493",
"0.47866154",
"0.477836",
"0.47747335",
"0.47419238",
"0.47354808",
"0.47344935",
"0.47196078",
"0.4714073",
"0.4699903",
"0.4681842",
"0.46762025",
"0.46687162",
"0.46584427",
"0.46558714",
"0.4654079",
"0.46490905",
"0.46406505",
"0.4628421",
"0.462275",
"0.46212018",
"0.4611523",
"0.4605003",
"0.46040782",
"0.46027303",
"0.45925772",
"0.4591537",
"0.45865762",
"0.45855892",
"0.45753312",
"0.45680055",
"0.45629543",
"0.4553863",
"0.4546156",
"0.45439452",
"0.45438343",
"0.45376828",
"0.45349732",
"0.4530309",
"0.45290536",
"0.4525723",
"0.45254415",
"0.45240808",
"0.4520704",
"0.45143864",
"0.45137468",
"0.45111623",
"0.45111623",
"0.45097402",
"0.45085168",
"0.45007977",
"0.44966868",
"0.44959903",
"0.44935888",
"0.44935867",
"0.4493556",
"0.44843215",
"0.4482162",
"0.4471966",
"0.4467739",
"0.44636652"
] | 0.4843848 | 38 |
Test that the Hiredis thread is scheduled after some time while waiting for the descriptor to be readable. | def test_read_against_timeout_with_other_thread
thread = Thread.new do
sleep 0.1 while true
end
listen do |_|
hiredis.connect("localhost", DEFAULT_PORT)
hiredis.timeout = 10_000
assert_raises Errno::EAGAIN do
hiredis.read
end
end
ensure
thread.kill
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_readable_or_timeout; end",
"def wait_writable_or_timeout; end",
"def wait_until_not_full; end",
"def wait_for_reader\n @reader.wait if @reader\n end",
"def wait_until( desc, freq = 1.0 )\n $stdout.write( \"Waiting for \" + desc )\n until (ret = yield) do\n $stdout.write '.'\n sleep freq\n end\n ret\n ensure\n puts\n end",
"def wait_for_pending_sends; end",
"def wait; end",
"def wait; end",
"def wait; end",
"def wait_for_launching\n sleep @delay\n end",
"def test_long_polling_get\n puts \"test_long_polling_get\"\n s = random_string\n t = Thread.new do\n r = pop\n assert_equal(s, r, \"expected #{s}, got #{r}\")\n end\n\n sleep 2\n pr = push(s)\n assert_equal(0, pr, \"expected 0, got #{pr}\")\n t.join\n end",
"def pre_sleep; end",
"def waiting; end",
"def waiting; end",
"def test_reply_with_timeout\n address = \"some-address\"\n\n id = EventBus.register_handler(address) do |msg|\n p msg\n end\n @tu.azzert id != nil\n EventBus.send address, {'message' => 'test'}, 10 do |msg|\n p msg\n end\n\n @tu.test_complete\nend",
"def wait_async(time)\n EM::Synchrony.sleep(time)\nend",
"def wait\n true\n end",
"def wait_for_condition(timeout)\n deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout\n loop do\n break if yield ||\n Process.clock_gettime(Process::CLOCK_MONOTONIC) > deadline\n\n sleep 1\n end\n end",
"def wait(timeout = nil)\n\t\t\tbegin\n\t\t\t\[email protected](timeout)\n\t\t\trescue DRb::DRbConnError\n\t\t\tend\n\t\tend",
"def wait!\n sleep(@sleep)\n end",
"def run_with_em\n EventMachine::run do\n EM.add_timer(60) do\n puts \"Test timed out\"\n false.should be_true\n end\n\n yield\n\n # # Poll redis to see if it's finished processing all\n # # requests\n # check = lambda {\n # if ChatChannel.redis.pending_commands?\n # # It would be nice if there was another way to poll besides next_tick.\n # # For example, if the redis client had a callback anytime a resposne\n # # was received\n # EM::next_tick(&check)\n # else\n # EM::stop_event_loop\n # end\n # }\n # \n # check.call\n # end\n end\nend",
"def await_event(type=\"Scaleout\", delay=120)\n des = description.desired_capacity\n result = false\n count = 0\n Log.log \"Awaiting #{type}... \", newline: false\n while count < delay && !result\n s = summary\n result = (s[:size] == des && s[:in_service] && s[:healthy])\n sleep 1\n count += 1\n end\n Log.log \"done\", timestamp: false\n Log.log \"Summary: #{summary.inspect}\"\n end",
"def test_thread_poll_one\n received = nil\n max_sleep = (RUBY_VERSION =~ /1\\.8/) ? 10 : 1\n Thread.new(@conn) do |amq|\n while true\n received = amq.poll\n # One message is needed\n Thread.exit if received\n sleep max_sleep\n end\n end\n #\n conn_subscribe( make_destination )\n message = Time.now.to_s\n @conn.publish(make_destination, message)\n sleep max_sleep+1\n assert_not_nil received\n assert_equal message, received.body\n checkEmsg(@conn)\n end",
"def consider_timeout\n\n do_schedule_timeout(attribute(:timeout))\n end",
"def spawn_and_wait(instance)\n instance.register\n\n output_queue # materialize in this thread\n\n Thread.new {\n instance.run(output_queue)\n }\n\n 20.times do\n instance.connected? ? break : sleep(0.1)\n end\n\n # Extra time to make sure the consumer can attach\n # Without this there's a chance the shutdown code will execute\n # before consumption begins. This is tricky to do more elegantly\n sleep 1\n end",
"def test_idle_timeout_server_no_open\n s = TCPServer.new(0)\n cont = Container.new(__method__)\n cont.connect(\":#{s.addr[1]}\", {:idle_timeout => 0.1, :handler => ExceptionMessagingHandler.new })\n ex = assert_raises(Qpid::Proton::Condition) { cont.run }\n assert_match(/resource-limit-exceeded/, ex.to_s)\n ensure\n s.close if s\n end",
"def wait(timeout=60)\n countdown = timeout.to_f\n\n while countdown > 0\n if @zmq_thread and @zmq_thread.alive?\n sleep 0.1\n countdown = countdown - 0.1\n else\n break\n end\n end\n\n super()\n end",
"def simulate_work(time)\n return\n sleep time unless Softcover::test?\n end",
"def wait\n @notifier.wait if @notifier\n end",
"def wait\n @notifier.wait if @notifier\n end",
"def wait_for(timeout = 30, &block)\n start = Time.now\n while true\n raise RuntimeError, \"Timed out waiting for event\" if Time.now - start > timeout\n\n break if yield\n\n sleep(0.1)\n end\n end",
"def brute_wait(delay)\n sleep(delay)\n end",
"def checkTimeout_Flooding()\n\tsleep(2);\n\tputs \"time out!\";\n\n\nend",
"def implicit_wait; end",
"def sleep_until(timeout = QUE_SLEEP_UNTIL_TIMEOUT)\n deadline = Time.now + timeout\n loop do\n break if yield\n if Time.now > deadline\n puts \"sleep_until timeout reached!\"\n raise \"sleep_until timeout reached!\"\n end\n sleep 0.01\n end\nend",
"def wait\n @timer_thread.join\n end",
"def wait_until_ready\n # this method may be left unimplemented if that is applicable log\n end",
"def test_read_timeouts\n server = FakeJobServer.new(self)\n client, sock, task, taskset, res = nil\n\n s = TestScript.new\n c = TestScript.new\n\n server_thread = Thread.new { s.loop_forever }.run\n client_thread = Thread.new { c.loop_forever }.run\n\n c.exec { client = Gearman::Client.new(\"localhost:#{server.port}\") }\n\n # First, create a new task. The server claims to be sending back a\n # packet with 1 byte of data, but actually sends an empty packet. The\n # client should time out after 0.1 sec.\n c.exec { taskset = Gearman::TaskSet.new(client) }\n c.exec { task = Gearman::Task.new('foo', 'bar') }\n c.exec { client.task_create_timeout_sec = 0.1 }\n c.exec { res = taskset.add_task(task) }\n s.exec { sock = server.expect_connection }\n s.wait\n\n s.exec { server.expect_request(sock, :submit_job, \"foo\\000\\000bar\") }\n s.exec { server.send_response(sock, :job_created, '', 1) }\n c.wait\n s.wait\n\n assert_equal(false, res)\n\n # Now create a task, but only return a partial packet for\n # work_complete. The client should again time out after 0.1 sec.\n c.exec { res = taskset.add_task(task) }\n s.exec { sock = server.expect_connection }\n s.wait\n\n s.exec { server.expect_request(sock, :submit_job, \"foo\\000\\000bar\") }\n s.exec { server.send_response(sock, :job_created, 'a') }\n c.exec { res = taskset.wait(0.1) }\n s.exec { server.send_response(sock, :work_complete, \"a\\000\", 3) }\n c.wait\n s.wait\n\n assert_equal(false, res)\n end",
"def wait\n sleep WAIT_TIME unless @skip_wait\n end",
"def maybe_fake_delay!\n if (auth_db_delay = env.params['auth_db_delay'].to_f) > 0\n enqueue_acceptor(:sleepy){|acc| EM.add_timer(auth_db_delay){ acc.succeed } }\n end\n end",
"def test_wait_for_done_after_done\n with_servers do\n # Repeat a bunch of times -- this helps catch a race \n # condition in done_with?\n 100.times do\n client = Client.new\n \n token = client.remote_send_async(:slow_upcase, 'foobar')\n \n while !client.done_with?(token)\n Thread.pass\n end\n \n # Result should be ready for us\n assert_equal 'FOOBAR', client.wait_for_done(token)\n end\n end\n end",
"def timeout!; end",
"def wait_for_task(recipe, task, timeout=600, interval=5)\n desired_summary = \"completed: #{recipe}\"\n last_state = nil\n i = 0\n while i <= timeout do\n summary = task.show.summary\n return true if summary == desired_summary\n \n # print in the output if task changed state, and reset timeout\n if summary != last_state\n last_state = summary\n i = 0\n msg = \"Task is now #{summary}, waiting for #{desired_summary}\"\n write_output \"#{msg}\\n\"\n Maestro.log.info msg\n else\n Maestro.log.debug \"Server state is #{summary}, waiting for #{desired_summary} (#{i}/#{timeout})\"\n end\n \n sleep interval\n i += interval\n end\n \n msg = \"Timed out after #{timeout}s waiting for receipe #{recipe} to complete, is currently #{task.show.summary}\"\n Maestro.log.info msg\n set_error msg\n end",
"def wait_for_host(seconds=5)\n platform.wait_for_host(seconds)\n end",
"def assert_eventually(time = nil, message = nil)\n end_time = (time and Time.now + time)\n exception = nil\n\n while (true)\n begin\n yield\n rescue Object => e\n exception = e\n else\n break\n end\n \n select(nil, nil, nil, 0.1)\n \n if (end_time and Time.now > end_time)\n if (exception)\n raise exception\n else\n flunk(message || 'assert_eventually timed out')\n end\n end\n end\n end",
"def test_idle_timeout_client\n server = ServerContainerThread.new(\"#{__method__}.server\", {:idle_timeout => 0.1})\n client_handler = Class.new(ExceptionMessagingHandler) do\n def initialize() @ready, @block = Queue.new, Queue.new; end\n attr_reader :ready, :block\n def on_connection_open(c)\n @ready.push nil # Tell the main thread we are now open\n @block.pop # Block the client so the server will time it out\n end\n end.new\n\n client = Container.new(nil, \"#{__method__}.client\")\n client.connect(server.url, {:handler => client_handler})\n client_thread = Thread.new { client.run }\n client_handler.ready.pop # Wait till the client has connected\n server.join # Exits when the connection closes from idle-timeout\n client_handler.block.push nil # Unblock the client\n ex = assert_raises(Qpid::Proton::Condition) { client_thread.join }\n assert_match(/resource-limit-exceeded/, ex.to_s)\n end",
"def wakeup() end",
"def wait_until(timeout=20, &block)\n time_to_stop = Time.now + timeout\n until yield do\n sleep(0.1) # much less cpu stress\n break if Time.now > time_to_stop\n end\nend",
"def test_container_schedule_handler\n h = Class.new() do\n def initialize() @got = []; end\n attr_reader :got\n def record(m) @got << m; end\n def on_container_start(c) c.schedule(0) {record __method__}; end\n def on_connection_open(c) c.close; c.container.schedule(0) {record __method__}; end\n def on_connection_close(c) c.container.schedule(0) {record __method__}; end\n end.new\n t = ServerContainerThread.new(__method__, nil, 1, h)\n t.connect(t.url)\n t.join\n assert_equal [:on_container_start, :on_connection_open, :on_connection_open, :on_connection_close, :on_connection_close], h.got\n end",
"def sleep_some_time\n sleep 1\n end",
"def wait_action_cable_subscription\n sleep 1\n end",
"def hard_test\n wait(10) # let some capacitor get up some charge.\n \n 5.times do\n wait(5)\n cmd(\"CFS CFS_WHE_OBS_START\")\n wait(5) \n cmd(\"CFS CFS_WHE_HTR_ON\")\n wait(5)\n cmd(\"CFS CFS_WHE_LOUVER_CLOSE\")\n wait(5)\n \n end\nend",
"def wait(arg0)\n end",
"def timedout_read(duration)\n begin \n timeout(duration) do\n @sock.wait_readable\n end\n rescue Celluloid::TaskTimeout\n return true\n end\n false\n end",
"def watch_delay\n @conn.watch(Web.keys[:delay]) do\n yield if block_given?\n end\n end",
"def sleepy_run; end",
"def test_timeout\n @client.queue_name = \"test_timeout_6\"\n clear_queue\n\n res = @client.messages.post(\"hello world timeout!\")\n p res\n\n msg = @client.messages.get()\n p msg\n assert msg\n\n msg4 = @client.messages.get()\n p msg4\n assert_nil msg4\n\n puts 'sleeping 45 seconds...'\n sleep 45\n\n msg3 = @client.messages.get()\n p msg3\n assert_nil msg3\n\n puts 'sleeping another 45 seconds...'\n sleep 45\n\n msg2 = @client.messages.get()\n assert msg2\n assert_equal msg2.id, msg.id\n\n msg2.delete\n\n # now try explicit timeout\n res = @client.messages.post(\"hello world timeout2!\", :timeout => 10)\n p res\n msg = @client.messages.get()\n p msg\n assert msg\n msg4 = @client.messages.get()\n p msg4\n assert_nil msg4\n puts 'sleeping 15 seconds...'\n sleep 15\n msg2 = @client.messages.get()\n assert msg2\n assert_equal msg2.id, msg.id\n\n end",
"def wait_until(timeout=10, &block)\n time = Time.now\n success = false\n until success\n if (Time.now - time) >= timeout\n raise \"Waited for #{timeout} seconds, but block never returned true\"\n end\n sleep 0.5\n success = yield\n end\n end",
"def test_timeout\n @client.queue_name = \"test_timeout\"\n clear_queue\n\n res = @client.messages.post(\"hello world timeout!\")\n p res\n\n msg = @client.messages.get()\n p msg\n assert msg\n\n msg4 = @client.messages.get()\n p msg4\n assert msg4.nil?\n\n puts 'sleeping 45 seconds...'\n sleep 45\n\n msg3 = @client.messages.get()\n p msg3\n assert msg3.nil?\n\n puts 'sleeping another 45 seconds...'\n sleep 45\n\n msg2 = @client.messages.get()\n assert msg2\n assert msg.id == msg2.id\n\n msg2.delete\n\n # now try explicit timeout\n res = @client.messages.post(\"hello world timeout2!\", :timeout=>10)\n p res\n msg = @client.messages.get()\n p msg\n assert msg\n msg4 = @client.messages.get()\n p msg4\n assert msg4.nil?\n puts 'sleeping 15 seconds...'\n sleep 15\n msg2 = @client.messages.get()\n assert msg2\n assert msg.id == msg2.id\n\n end",
"def trigger\n @timed_out = false\n @expires = Time.now + @period\n unless @thread\n @thread = Thread.new do\n begin\n begin\n sleepytime = @expires - Time.now\n while sleepytime > 0.0\n sleep(sleepytime)\n sleepytime = @expires - Time.now\n end\n @timed_out = true\n @expires += @period if @repeats\n @block.call if @block\n end while @repeats\n rescue StopTimerException\n @expires=nil\n ensure\n @thread = nil\n end\n end\n end\n end",
"def wait\n 0\n end",
"def implicit_wait=(seconds); end",
"def wait\n loop do sleep 1 end\n end",
"def sleep_test\n sleep(10)\n \"slept for 10 sec!\"\n end",
"def wait(timeout = nil)\n @latch.wait(timeout)\n end",
"def untilTimeout()\n return Timer.timeRemaining(@name)\n end",
"def wait\n sleep 0.0001\n end",
"def timeout_after(time); end",
"def wait_for_irc\n while @mockirc.ready?\n sleep 0.05\n end\n\n # For safety, we need to wait yet again to be sure YAIL has processed the data it read.\n # This is hacky, but it decreases random failures quite a bit\n sleep 0.1\n end",
"def wait_readable(io)\n wait io do |monitor|\n monitor.wait_readable\n end\n end",
"def eventually(label, &block)\n current_time = Time.now\n timeout_treshold = current_time + TIMEOUT\n while (block.call == false) && (current_time <= timeout_treshold) do\n sleep 5\n current_time = Time.now\n end\n if (current_time > timeout_treshold)\n fail \"Action '#{label}' did not resolve within timeout: #{TIMEOUT}s\"\n end\nend",
"def wait_until_ready\n # this method may be left unimplemented if that is applicable\n end",
"def wait\n\tend",
"def worker_timeout(timeout); end",
"def wait_for_rx\n sleep DATA_REFRESH_RATE + @latency\n end",
"def wait!\n now = Time.now.utc.to_i\n duration = (reset.to_i - now) + 1\n\n sleep duration if duration >= 0\n\n yield if block_given?\n\n duration\n end",
"def timeout; end",
"def timeout; end",
"def timeout; end",
"def test_120_tasks_every_second_with_ms_task\n min_time = 1\n rl = @testClass.new 120, min_time\n delta = timed_run(rl) { sleep 0.001 }\n # puts \"\\n#{delta} >? #{min_time}\"\n assert((delta / min_time) > TIMING_TOLERANCE)\n end",
"def test_container_work_queue\n c = Container.new __method__\n delays = [0.1, 0.03, 0.02]\n a = []\n delays.each { |d| c.schedule(d) { a << [d, Time.now] } }\n start = Time.now\n c.run\n delays.sort.each do |d|\n x = a.shift\n assert_equal d, x[0]\n end\n assert_equalish delays.reduce(:+), Time.now-start\n end",
"def wait_until_ready!\n Timeout.timeout(timeout) do\n begin\n Chef::Log.debug \"trying to open #{endpoint}\"\n open(endpoint)\n rescue SocketError,\n Errno::ECONNREFUSED,\n Errno::ECONNRESET,\n Errno::ENETUNREACH,\n OpenURI::HTTPError => e\n # If authentication has been enabled, the server will return an HTTP\n # 403. This is \"OK\", since it means that the server is actually\n # ready to accept requests.\n return if e.message =~ /^403/\n Chef::Log.debug(\"Redmine is not accepting requests - #{e.message}\")\n sleep(0.5)\n retry\n end\n end\n rescue Timeout::Error\n raise RedmineNotReady.new(endpoint, timeout)\n end",
"def send_and_wait(type, *args); end",
"def read_wait(timeout: nil)\n !!IO.select([io], [], [], timeout)\n end",
"def test_wait_until_done\n to_call = 3\n get_method = proc do\n to_call -= 1\n status = to_call == 0 ? :DONE : :NOT_DONE\n MockOperation.new(status: status, name: NAME)\n end\n\n mock_client = MockLroClient.new get_method: get_method\n op = create_op MockOperation.new(status: :NOTDONE, name: NAME), client: mock_client\n\n sleep_counts = [10.0, 13.0, 16.900000000000002]\n sleep_mock = Minitest::Mock.new\n sleep_counts.each do |sleep_count|\n sleep_mock.expect :sleep, nil, [sleep_count]\n end\n\n sleep_proc = ->(count) do \n sleep_mock.sleep count \n end\n\n Kernel.stub :sleep, sleep_proc do\n time_now = Time.now\n Time.stub :now, time_now do\n op.wait_until_done!\n end\n end\n\n sleep_mock.verify\n assert_equal 0, to_call\n end",
"def sync_wait\n if IO.select([sync_read], nil, nil, 20).nil?\n # timeout reading from the sync pipe.\n send_side_channel_error(\"Error syncing processes in run lock test (timeout)\")\n exit!(1)\n else\n sync_read.getc\n end\n end",
"def wait_connection; end",
"def wait_connection; end",
"def waitUntil\n until yield\n sleep 0.5\n end\nend",
"def with_timeout( timeout, &block )\n expire = Time.now + timeout.to_f\n sleepy = @sleep_in_ms / 1000.to_f()\n # this looks inelegant compared to while Time.now < expire, but does not oversleep\n loop do\n return true if block.call\n log :debug, \"Timeout for #{@key}\" and return false if Time.now + sleepy > expire\n sleep(sleepy)\n # might like a different strategy, but general goal is not use 100% cpu while contending for a lock.\n end\n end",
"def wait\r\n Ragweed::Wrap32::wait_for_single_object @h\r\n end",
"def lock_timeout; end",
"def timeout_at; end",
"def wait_for_seconds\n\t\tsleep(1 * rand + 1)\n\tend",
"def with_serial_lock\n timeout_cap(15) do\n CLIENT_MUTEX.synchronize { yield }\n end\nend",
"def poll_sleep\n @sleeping = true\n handle_shutdown { sleep 5 }\n @sleeping = false\n true\n end",
"def can_wait_objection?\n seconds.count >= 2\n end",
"def wait_for_host(entry)\n ssh_options = { auth_methods: ['password'],\n config: false,\n password: cobbler_root_password,\n user_known_hosts_file: '/dev/null' }\n prompts = { number_of_password_prompts: 0 }\n options = {}\n config = { log_level: :warn }\n\n ssh_transport =\n Chef::Provisioning::Transport::SSH.new(entry[:ip_address],\n 'ubuntu',\n ssh_options.merge(prompts),\n options,\n config)\n\n #\n # If it takes more than half an hour for the node to respond,\n # something is really broken.\n #\n # This will make 60 attempts with a 1 minute sleep between attempts,\n # or timeout after 61 minutes.\n #\n Timeout.timeout(3720) do\n max = 60\n 1.upto(max) do |idx|\n break if ssh_transport.available?\n\n puts \"Waiting for #{entry[:hostname]} to respond to SSH \" \\\n \"on #{entry[:ip_address]} (attempt #{idx}/#{max})\"\n sleep 60\n end\n end\n\n if ssh_transport.available?\n puts \"Reached #{entry[:hostname]} via SSH, continuing\"\n true\n else\n raise \"Failed to reach #{entry[:hostname]} via SSH!\"\n end\nend",
"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 wait_for_ready\n sleep 0.1 until ready?\n end"
] | [
"0.6639793",
"0.6246055",
"0.5915321",
"0.58758545",
"0.5872144",
"0.5829963",
"0.57832235",
"0.57832235",
"0.57832235",
"0.5755491",
"0.5747877",
"0.57255566",
"0.5689719",
"0.5689719",
"0.5663947",
"0.5648442",
"0.5645678",
"0.56427556",
"0.5619988",
"0.56191844",
"0.5615926",
"0.5607581",
"0.5601704",
"0.5590345",
"0.55850524",
"0.55795795",
"0.5575746",
"0.5562461",
"0.5557916",
"0.5557916",
"0.55384856",
"0.5532185",
"0.5531578",
"0.5526984",
"0.55115587",
"0.5509788",
"0.54950583",
"0.5491342",
"0.5491284",
"0.5490688",
"0.5489908",
"0.5488091",
"0.54842585",
"0.5479278",
"0.5468742",
"0.5466505",
"0.5464367",
"0.5462226",
"0.5458152",
"0.5456312",
"0.5456159",
"0.5441957",
"0.5436856",
"0.5427384",
"0.5423133",
"0.5420443",
"0.5410984",
"0.5407823",
"0.54049444",
"0.5398859",
"0.5397814",
"0.5390699",
"0.5386596",
"0.5385418",
"0.53843135",
"0.53797007",
"0.5378146",
"0.5375308",
"0.5372164",
"0.5371827",
"0.53685135",
"0.5367626",
"0.53602606",
"0.5360116",
"0.5347324",
"0.53457934",
"0.5344999",
"0.5344999",
"0.5344999",
"0.5344742",
"0.5343789",
"0.5337668",
"0.53373766",
"0.53298306",
"0.53207207",
"0.53196436",
"0.5318434",
"0.5318434",
"0.5318327",
"0.53168976",
"0.5310784",
"0.53060836",
"0.5297827",
"0.52908266",
"0.52872396",
"0.52871877",
"0.5285516",
"0.52822065",
"0.5280201",
"0.5279181"
] | 0.7100216 | 0 |
This does not have consistent outcome for different operating systems... def test_eagain_on_write listen do |server| hiredis.connect("localhost", 6380) hiredis.timeout = 100_000 Find out buffer sizes sndbuf = sockopt(hiredis.sock, Socket::SO_SNDBUF) rcvbuf = sockopt(hiredis.sock, Socket::SO_RCVBUF) Make request that fills both the remote receive buffer and the local send buffer. This assumes that the size of the receive buffer on the remote end is equal to our local receive buffer size. assert_raises Errno::EAGAIN do hiredis.write(["x" rcvbuf 2]) hiredis.write(["x" sndbuf 2]) hiredis.flush end end end | def test_eagain_on_write_followed_by_remote_drain
skip "`#flush` doesn't work on hi-redis 1.0. See https://github.com/redis/hiredis/issues/975"
listen do |server|
hiredis.connect("localhost", 6380)
hiredis.timeout = 100_000
# Find out buffer sizes
sndbuf = sockopt(hiredis.sock, Socket::SO_SNDBUF)
rcvbuf = sockopt(hiredis.sock, Socket::SO_RCVBUF)
# This thread starts reading the server buffer after 50ms. This will
# cause the local write to first return EAGAIN, wait for the socket to
# become writable with select(2) and retry.
begin
thread = Thread.new do
sleep(0.050)
loop do
server.read(1024)
end
end
# Make request that fills both the remote receive buffer and the local
# send buffer. This assumes that the size of the receive buffer on the
# remote end is equal to our local receive buffer size.
hiredis.write(["x" * rcvbuf])
hiredis.write(["x" * sndbuf])
hiredis.flush
hiredis.disconnect
ensure
thread.kill
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_server_survives_half_message\n puts \"test_server_survives_half_message\"\n\n expects = []\n 10.times do\n expects << random_string\n pr = push(expects[-1])\n assert_equal(0, pr, \"expected 0, got #{pr}\")\n end\n\n s = random_string(15)\n header = s.length\n client = tcp_socket()\n nbytes = client.send([header].pack(\"C1\"), 0)\n if nbytes != 1\n raise \"push: header write failed\"\n end\n\n client.send(s[0..3], 0)\n client.shutdown\n\n 10.times do\n r = pop\n s = expects.pop\n assert_equal(s, r, \"expected #{s}, got #{r}\")\n end\n end",
"def test_read_against_timeout_with_other_thread\n thread = Thread.new do\n sleep 0.1 while true\n end\n\n listen do |_|\n hiredis.connect(\"localhost\", DEFAULT_PORT)\n hiredis.timeout = 10_000\n\n assert_raises Errno::EAGAIN do\n hiredis.read\n end\n end\n ensure\n thread.kill\n end",
"def test_server_queues_slow_message_correctly\n puts \"test_server_queues_slow_message_correctly\"\n\n expects = []\n 10.times do\n expects << random_string\n pr = push(expects[-1])\n assert_equal(0, pr, \"expected 0, got #{pr}\")\n end\n\n # send 1 byte of slow string\n slow_s = random_string(2)\n header = slow_s.length\n client = tcp_socket()\n nbytes = client.send([header].pack(\"C1\"), 0)\n if nbytes != 1\n raise \"push: header write failed\"\n end\n\n client.send(slow_s[0], 0)\n\n 5.times do\n r = pop\n s = expects.pop\n assert_equal(s, r, \"expected #{s}, got #{r}\")\n end\n\n # send second byte of slow string, pop it\n client.send(slow_s[1], 0)\n r = pop\n assert_equal(slow_s, r, \"expected #{slow_s}, got #{r}\")\n\n 5.times do\n r = pop\n s = expects.pop\n assert_equal(s, r, \"expected #{s}, got #{r}\")\n end\n end",
"def test_unresponsive_server\n socket = stub_server 43041\n\n cache = Memcached.new(\n [@servers.last, 'localhost:43041'],\n :prefix_key => @prefix_key,\n :auto_eject_hosts => true,\n :server_failure_limit => 2,\n :retry_timeout => 1,\n :hash_with_prefix_key => false,\n :hash => :md5,\n :exception_retry_limit => 0\n )\n\n # Hit second server up to the server_failure_limit\n key2 = 'test_missing_server'\n assert_raise(Memcached::ATimeoutOccurred) { cache.set(key2, @value) }\n assert_raise(Memcached::ATimeoutOccurred) { cache.get(key2, @value) }\n\n # Hit second server and pass the limit\n key2 = 'test_missing_server'\n begin\n cache.get(key2)\n rescue => e\n assert_equal Memcached::ServerIsMarkedDead, e.class\n assert_match(/localhost:43041/, e.message)\n end\n\n # Hit first server on retry\n assert_nothing_raised do\n cache.set(key2, @value)\n assert_equal cache.get(key2), @value\n end\n\n sleep(2)\n\n # Hit second server again after restore, expect same failure\n key2 = 'test_missing_server'\n assert_raise(Memcached::ATimeoutOccurred) do\n cache.set(key2, @value)\n end\n\n ensure\n socket.close\n end",
"def on_writable\n @being_written = nil\n return unless res = responses.first\n if res.finished?\n responses.shift\n if res.last \n FFI::connection_schedule_close(self) \n return\n end\n end \n write\n end",
"def test_server_resource_limit\n puts \"test_server_resource_limit\"\n start_slow_clients(nclients: 100)\n sleep 5\n\n (rand(6)+1).times do\n r = push(random_string)\n assert_equal(0xFF, r, \"expected busy-state response\")\n end\n end",
"def write_to_socket bytes\n socket.write_nonblock bytes\n rescue IO::WaitWritable\n :wait_writable\n end",
"def blocking_write( data )\n raise RuntimeError, \"RAWIP: blocking_write: Not connected!\" unless connected?\n begin\n @ssock.send(data, 0, @addr)\n rescue\n destroy_connection\n raise RuntimeError, \"RAWIP: blocking_write: Couldn't write to socket! (#{$!})\"\n end\n end",
"def write(data)\n timeout = false\n loop do\n result = @socket.write_nonblock(data, :exception => false)\n return result unless result == :wait_writable\n\n raise TimeoutError, \"Write timed out after #{@write_timeout} seconds\" if timeout\n\n timeout = true unless @socket.to_io.wait_writable(@write_timeout)\n end\n end",
"def failed_write\n begin\n @sock.wait_readable\n rescue ArgumentError # IO Selector Exception\n return true\n end\n false\n end",
"def test_drain_should_continue_if_queue_empty\n @listener.expects(:read_messages_from_queue).with(@slow_queue, 10, long_poll: false).returns(false)\n @listener.expects(:read_messages_from_queue).with(@queue, 10, long_poll: false).returns(false)\n @listener.drain\n assert true\n end",
"def write_and_schedule sock\n outbound_data.each_with_index do |t_data,index|\n leftover = write_once(t_data,sock)\n if leftover.empty?\n outbound_data.delete_at(index)\n else\n outbound_data[index] = leftover\n reactor.schedule_write(sock)\n break\n end\n end\n reactor.cancel_write(sock) if outbound_data.empty?\n end",
"def write(data)\n reset_timer\n\n loop do\n result = socket.write_nonblock(data, :exception => false)\n return result unless result == :wait_writable\n\n IO.select(nil, [socket], nil, time_left)\n log_time\n end\n end",
"def blocking_write( data )\r\n raise RuntimeError, \"CONN_UDP: blocking_write: Not connected!\" unless connected?\r\n begin\r\n @sock.send(data, 0)\r\n rescue\r\n destroy_connection\r\n raise RuntimeError, \"CONN_UDP: blocking_write: Couldn't write to socket! (#{$!})\"\r\n end\r\n end",
"def write(data)\n reset_timer\n\n begin\n return socket.write_nonblock(data)\n rescue IO::WaitWritable\n IO.select(nil, [socket], nil, time_left)\n log_time\n retry\n end\n rescue EOFError\n :eof\n end",
"def test_full_hijack_body_close\n @body_closed = false\n server_run do |env|\n io = env['rack.hijack'].call\n io.syswrite 'Server listening'\n io.wait_readable 2\n io.syswrite io.sysread(256)\n body = ::Rack::BodyProxy.new([]) { @body_closed = true }\n [200, {}, body]\n end\n\n sock = send_http \"GET / HTTP/1.1\\r\\n\\r\\n\"\n\n sock.wait_readable 2\n assert_equal \"Server listening\", sock.sysread(256)\n\n sock.syswrite \"this should echo\"\n assert_equal \"this should echo\", sock.sysread(256)\n Thread.pass\n sleep 0.001 # intermittent failure, may need to increase in CI\n assert @body_closed, \"Reponse body must be closed\"\n end",
"def test_zzz_shooting_the_other_slave_in_the_head\n $mysql_slave.set_rw(true)\n\n $mysql_slave_2.kill!\n $mysql_slave_2 = nil\n\n UserSlave.connection.reconnect!\n assert port_for_class(UserSlave) == $mysql_slave.port\n end",
"def test_lots_of_a\n\t\tEM.epoll\n\t\tEM::DnsCache.add_nameserver TestNameserver\n\t\tEM::DnsCache.add_nameserver TestNameserver2\n\t\tEM::DnsCache.verbose \n\n\t\tn = 250\n\t\te = 0\n\t\ts = 0\n\t\tEM.run {\n\t\t\tn.times {\n\t\t\t\td = EM::DnsCache.resolve \"ibm.com\"\n\t\t\t\td.errback {e+=1; n -= 1; EM.stop if n == 0}\n\t\t\t\td.callback {s+=1; n -= 1; EM.stop if n == 0}\n\t\t\t}\n\t\t}\n\t\tassert_equal( 0, n)\n\t\tassert_equal( 250, s)\n\tend",
"def send str\n\n @send_buffer.push [Time.now.to_i + @send_buffer_delay, str] if @send_buffer_delay > 0\n\n begin\n if @send_buffer_delay > 0\n Protocol.write @client, (@send_buffer.shift)[1], :debug => 5 if Time.now.to_i >= (@send_buffer.first)[0]\n else\n Protocol.write @client, str, :debug => 5\n end\n false\n rescue Exception=>e\n puts \"!D connection terminated: #{e}\" if Config.debug\n true\n end\n end",
"def sendMessage(client, msg)\n packets = msg.fragment()\n packets.each do |packet|\n to_send = packet.toString() + \"\\n\"\n num_bytes = to_send.bytesize()\n check = client.write(to_send)\n if check < num_bytes\n return false\n end\n end\n return true\nend",
"def exchange(send_bytes, response_nbytes )\n @response = []\n @sp.rts = 0\n @sp.dtr = 0\n @sp.dtr = 1\n begin\n x = @sp.readbyte #should get an ETX after toggling the DTR\n raise Weather_exception, \"Bad packet: No ETX\" if x != ETX\n\n @sp.write(send_bytes)\n @sp.flush()\n x = @sp.readbyte #should get an ETX after toggling the DTR\n raise Weather_exception, \"Bad packet: No STX\" if x != STX\n\n length = @sp.readbyte\n STDERR.puts \"Length = #{length}\"\n\n i = 1\n escaped = false\n begin\n x = @sp.readbyte\n if length > 0\n STDERR.print \"#{i}: #{\"%02X\" % x} \"\n i += 1\n if x == ENQ\n escaped = true\n elsif escaped\n case x\n when DC2; @response << STX\n when DC3; @response << ETX\n when NAK; @response << ENQ\n else @response << x\n end\n escaped = false\n length -= 1\n else\n @response << x\n length -= 1\n end\n elsif length == 0\n @checksum = x\n length = -1\n raise Weather_exception, \"Checksum Error #{\"%02X\"%x}\" if x != checksum(@response)\n elsif x != ETX\n raise Weather_exception, \"Missing ETX\"\n end\n end while x != ETX\n\n # not available <STX 02h> <01h> <NAK 15h> <0E8h> <ETX 03h>\n if @response[0] == NAK #Got a NAK packet\n raise Weather_exception, \"Comms Error\"\n end\n ensure\n @sp.dtr = 0\n STDERR.puts\n end\n end",
"def ssl_socket_write(ssl_socket, data)\n log.chunder('ssl_socket_write')\n\n begin\n return ssl_socket.write_nonblock(data)\n rescue IO::WaitReadable\n log.chunder('WaitReadable') # XXX\n IO.select([ssl_socket.io])\n log.chunder('WaitReadable retry') # XXX\n retry\n rescue IO::WaitWritable\n log.chunder('WaitWritable') # XXX\n IO.select(nil, [ssl_socket.io])\n log.chunder('WaitWritable retry') # XXX\n retry\n end\n ensure\n log.chunder('done ssl_socket_write')\n end",
"def test_drain_ignores_slow_queue_if_disabled\n propono_config.slow_queue_enabled = false\n\n @listener.expects(:read_messages_from_queue).with(@slow_queue, 10, long_poll: false).never\n @listener.expects(:read_messages_from_queue).with(@queue, 10, long_poll: false).returns(false)\n @listener.drain\n assert true\n end",
"def _test_descriptors\n EM.epoll\n s = EM.set_descriptor_table_size 60000\n EM.run {\n EM.start_server \"127.0.0.1\", 9800, TestEchoServer\n $n = 0\n $max = 0\n 100.times {\n EM.connect(\"127.0.0.1\", 9800, TestEchoClient) {$n += 1}\n }\n }\n assert_equal(0, $n)\n assert_equal(100, $max)\n end",
"def ready_for_write?\n begin\n @write_buffer.length > 0 && IO.select(nil, [socket], nil, 0.1)\n rescue Exception\n triggered_close $!.message, :terminated\n raise\n end\n end",
"def wait_writable_or_timeout; end",
"def test_normal_append\n @store.set(@key, @flag, @exp_time, @size, @value, @no_reply)\n\n assert_equal(STORED, @store.append(@key, @size_append, @value_append, @no_reply), STORED_MESSAGE)\n end",
"def write(data)\n rescue_writable do\n socket.write_nonblock(data)\n end\n end",
"def notify_writable\n logdebug \"notify_writable\", :state => @state\n notify_writable = false # disable it now. if we still need it, we'll renabled it.\n case @state\n when :initialized\n attempt_connection\n when :read_needs_to_write\n attempt_read\n when :write_needs_to_write\n attempt_write\n end\n\n # if we waiting to close and are not longer waiting to write, we can flush and close the connection.\n if @close_after_writing and not notify_writable?\n @sslsock.flush\n close_connection\n end\n end",
"def test_test_tcp_should_return_true_if_socket_is_listening_with_responding_true\n c = Conditions::SocketResponding.new\n c.responding = true\n c.prepare\n\n TCPSocket.expects(:new).returns(0)\n assert_equal true, c.test\n end",
"def sendmsg(message)\n begin\n @socket.sendmsg_nonblock Marshal.dump(message), 0\n rescue IO::EAGAINWaitWritable\n # socket is full\n # TODO put the data into a queue rather than giving up\n raise RuntimeError, \"socket is full\"\n rescue Errno::EPIPE\n # The other socket is closed, probably because the event loop's stopped. clean up\n b.close\n @defunct = true\n end\n end",
"def put(buf, opts = {})\n return 0 if (buf == nil or buf.length == 0)\n\n send_len = buf.length\n send_idx = 0\n wait = opts['Timeout'] || 0\n\n # Keep writing until our send length drops to zero\n while (send_idx < send_len)\n curr_len = timed_write(buf[send_idx, buf.length-send_idx], wait, opts)\n\n # If the write operation failed due to an IOError, then we fail.\n return buf.length - send_len if (curr_len == nil)\n\n send_len -= curr_len\n send_idx += curr_len\n end\n\n return buf.length - send_len\n end",
"def write(message)\n @out_buffer << message\n n = @socket.send(@out_buffer, 0)\n # Chop what we already sent off the front of the buffer.\n @out_buffer.slice!(0...n)\n # Return whether we are done sending.\n return @out_buffer.size == 0\n end",
"def write(data)\n begin\n @socket.sync = false\n if data.nil?\n write_timeout([0, 0, @seq].pack(\"CvC\"), @opts[:write_timeout])\n @seq = (@seq + 1) % 256\n else\n data = StringIO.new data if data.is_a? String\n while d = data.read(MAX_PACKET_LENGTH)\n write_timeout([d.length%256, d.length/256, @seq].pack(\"CvC\")+d, @opts[:write_timeout])\n @seq = (@seq + 1) % 256\n end\n end\n @socket.sync = true\n @socket.flush\n rescue Errno::EPIPE\n @socket.close rescue nil\n raise ClientError::ServerGoneError, 'MySQL server has gone away'\n rescue Errno::ETIMEDOUT\n raise ClientError, \"write timeout\"\n end\n end",
"def test_plain_respects_bufsize\n\n resolver = Resolver.new('a.gtld-servers.net')\n resolver.query_timeout=20\n\n run_test = ->(bufsize) do\n\n\n create_test_query = ->(bufsize) do\n message = Message.new('com', Types.RRSIG, Classes.IN)\n message.add_additional(RR::OPT.new(bufsize))\n message\n end\n\n query = create_test_query.(bufsize)\n response, _error = resolver.send_plain_message(query)\n if (_error != nil) then\n print \"Error at #{bufsize} : #{_error}\"\n end\n# puts \"\\nBufsize is #{bufsize}, binary message size is #{response.encode.size}\"\n assert_equal(true, response.header.tc)\n assert(response.encode.size <= bufsize)\n end\n\n run_test.(612)\n end",
"def send_pending_data\n needs_looping = true\n while needs_looping\n needs_looping = false\n pending_data.delete_if do |socket, chunks|\n if chunks.empty?\n # nothing left to send for this socket\n next\n end\n\n buffer = chunks.shift\n while !chunks.empty? && (buffer.size + chunks[0].size < DATA_CHUNK_SIZE)\n buffer.concat(chunks.shift)\n end\n Server.debug \"sending #{buffer.size} bytes to #{socket}\"\n\n begin\n written = socket.write_nonblock(buffer)\n rescue Interrupt\n raise\n rescue Errno::EAGAIN\n Server.debug \"cannot send: send buffer full\"\n chunks.unshift(buffer)\n next\n rescue Exception => e\n Server.warn \"disconnecting from #{socket}: #{e.message}\"\n e.backtrace.each do |line|\n Server.warn \" #{line}\"\n end\n socket.close\n next(true)\n end\n\n remaining = buffer.size - written\n if remaining == 0\n Server.debug \"wrote complete chunk of #{written} bytes to #{socket}\"\n # Loop if we wrote the complete chunk and there\n # is still stuff to write for this socket\n needs_looping = !chunks.empty?\n else\n Server.debug \"wrote partial chunk #{written} bytes instead of #{buffer.size} bytes to #{socket}\"\n chunks.unshift(buffer[written, remaining])\n end\n false\n end\n end\n end",
"def testWriteList_NotConnected()\n key = \"_WriteList_NotConnected\"\n conn = Scalaris::TransactionSingleOp.new()\n conn.close_connection()\n #assert_raise( Scalaris::ConnectionError ) { conn.write(@testTime.to_s + key, [$_TEST_DATA[0], $_TEST_DATA[1]]) }\n conn.write(@testTime.to_s + key, [$_TEST_DATA[0], $_TEST_DATA[1]])\n conn.close_connection()\n end",
"def testWriteList_NotConnected()\n key = \"_WriteList_NotConnected\"\n conn = Scalaris::TransactionSingleOp.new()\n conn.close_connection()\n #assert_raise( Scalaris::ConnectionError ) { conn.write(@testTime.to_s + key, [$_TEST_DATA[0], $_TEST_DATA[1]]) }\n conn.write(@testTime.to_s + key, [$_TEST_DATA[0], $_TEST_DATA[1]])\n conn.close_connection()\n end",
"def test_should_not_crash_selects_in_the_double_read_only_window\n ActiveRecord::Base.connection\n $mysql_master.set_rw(false)\n $mysql_slave.set_rw(false)\n assert_equal $mysql_master, master_connection\n 100.times do\n User.first\n end\n end",
"def test_out_of_ports_during_add\n proxy = OpenShift::FrontendProxyServer.new\n\n uid = 500\n\n proxy.expects(:system_proxy_show).returns(\"127.0.0.1:9000\").times(@ports_per_user)\n proxy.expects(:system_proxy_set).never\n\n assert_raises OpenShift::FrontendProxyServerException do\n proxy.add(uid, '127.0.0.1', 8080) \n end\n end",
"def write(key, data)\n responsible_clients(key).each do |v|\n with_retries { v.logical.write(wrap_key(key), data) }\n end\n end",
"def test_idle_timeout_server_no_open\n s = TCPServer.new(0)\n cont = Container.new(__method__)\n cont.connect(\":#{s.addr[1]}\", {:idle_timeout => 0.1, :handler => ExceptionMessagingHandler.new })\n ex = assert_raises(Qpid::Proton::Condition) { cont.run }\n assert_match(/resource-limit-exceeded/, ex.to_s)\n ensure\n s.close if s\n end",
"def handle_response(response)\n loop do\n begin\n bytes = @client.write_nonblock(response)\n msg_response\n break if bytes >= response.size\n response.slice!(0, bytes)\n rescue Errno::EAGAIN\n IO.select(nil,[@client], nil)\n retry # spam untill send all\n end\n end\n end",
"def test_connection_work_queue_raise\n c = ServerContainer.new(__method__)\n c.connect(c.url)\n c.work_queue.add { raise \"BROKEN\" }\n assert_equal(\"BROKEN\", (assert_raises(RuntimeError) { c.run }).to_s)\n end",
"def testWriteList1()\n key = \"_WriteList1_\"\n conn = Scalaris::TransactionSingleOp.new()\n\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n conn.write(@testTime.to_s + key + i.to_s, [$_TEST_DATA[i], $_TEST_DATA[i + 1]])\n end\n \n # now try to read the data:\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n actual = conn.read(@testTime.to_s + key + i.to_s)\n assert_equal([$_TEST_DATA[i], $_TEST_DATA[i + 1]], actual)\n end\n \n conn.close_connection()\n end",
"def testWriteList1()\n key = \"_WriteList1_\"\n conn = Scalaris::TransactionSingleOp.new()\n\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n conn.write(@testTime.to_s + key + i.to_s, [$_TEST_DATA[i], $_TEST_DATA[i + 1]])\n end\n \n # now try to read the data:\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n actual = conn.read(@testTime.to_s + key + i.to_s)\n assert_equal([$_TEST_DATA[i], $_TEST_DATA[i + 1]], actual)\n end\n \n conn.close_connection()\n end",
"def write(*args)\n begin\n raise Bunny::ConnectionError.new(\"No connection: socket is nil. \", @host, @port) if !@socket\n if @read_write_timeout\n Bunny::Timer.timeout(@read_write_timeout, Bunny::ClientTimeout) do\n @socket.write(*args) if open?\n end\n else\n @socket.write(*args) if open?\n end\n rescue Errno::EPIPE, Errno::EAGAIN, Bunny::ClientTimeout, Bunny::ConnectionError, IOError => e\n close\n\n @session.handle_network_failure(e)\n end\n end",
"def listen_and_save\n socket = TCPSocket.new(@host,@port)\n socket.write \"GET #{@path} HTTP/1.1\\r\\n\"\n socket.write \"Host: #{@host}\\r\\n\"\n socket.write \"\\r\\n\" \n captured_content = \"\"\n while line = socket.readline.chomp # used chomp to remove trailing newline \n # concatenating line socket response to avoid broken JSON from socket\n captured_content = captured_content + line if line.length > 10\n captured_content = \"\" if !captured_content.start_with?('{\"') \n if result = valid_json?(captured_content)\n add_to_redis_list(result)\n captured_content = \"\" \n end \n end \n end",
"def _test_unix_domain\n fn = \"/tmp/xxx.chain\"\n EM.epoll\n s = EM.set_descriptor_table_size 60000\n EM.run {\n # The pure-Ruby version won't let us open the socket if the node already exists.\n # Not sure, that actually may be correct and the compiled version is wrong.\n # Pure Ruby also oddly won't let us make that many connections. This test used\n # to run 100 times. Not sure where that lower connection-limit is coming from in\n # pure Ruby.\n # Let's not sweat the Unix-ness of the filename, since this test can't possibly\n # work on Windows anyway.\n #\n File.unlink(fn) if File.exist?(fn)\n EM.start_unix_domain_server fn, TestEchoServer\n $n = 0\n $max = 0\n 50.times {\n EM.connect_unix_domain(fn, TestEchoClient) {$n += 1}\n }\n EM::add_timer(1) { $stderr.puts(\"test_unix_domain timed out!\"); EM::stop }\n }\n assert_equal(0, $n)\n assert_equal(50, $max)\n ensure\n File.unlink(fn) if File.exist?(fn)\n end",
"def timed_write(buf, wait = def_write_timeout, opts = {})\n if (wait and wait > 0)\n Timeout.timeout(wait) {\n return write(buf, opts)\n }\n else\n return write(buf, opts)\n end\n end",
"def writeable?\n return false if @socket.closed?\n _,w,_ = Kernel.select(nil, [@socket], nil, @timeout) rescue nil\n return !(w.nil? or w.empty?)\n end",
"def test_blocking\n s1, s2 = Socket.pair(:UNIX, :STREAM, 0)\n e1 = Qpid::Proton::ConnectionEngine.new(s1, Handler.new)\n e2 = Qpid::Proton::ConnectionEngine.new(s2, Handler.new)\n\n assert !e1.connection.remote_active?\n assert !e2.connection.remote_active?\n e1.connection.open()\n until e1.connection.remote_active? && e2.connection.remote_active?\n e1.process(); e2.process()\n end\n ss = e1.connection.open_session\n sender = ss.open_sender(\"FOO\")\n until sender.remote_active?\n e1.process(); e2.process()\n end\n receiver = e2.handler.links[0]\n assert_equal \"FOO\", receiver.remote_target.address\n m = Qpid::Proton::Message.new # TODO aconway 2015-12-03: add body initializer\n m.body = \"TEST\"\n sender.send m\n until !e2.handler.messages.empty?\n e1.process(); e2.process()\n end\n assert_equal \"TEST\", e2.handler.messages[0].body\n e1.connection.close()\n until e1.closed? && e2.closed? \n e1.process(); e2.process()\n end\n end",
"def test_test_tcp_should_return_false_if_socket_is_listening\n c = Conditions::SocketResponding.new\n c.prepare\n\n TCPSocket.expects(:new).returns(0)\n assert_equal false, c.test\n end",
"def test_publish_two_messages\n conn_subscribe make_destination\n @conn.publish make_destination, \"a\\0\"\n @conn.publish make_destination, \"b\\0\"\n msg_a = @conn.receive\n msg_b = @conn.receive\n\n assert_equal \"a\\0\", msg_a.body\n assert_equal \"b\\0\", msg_b.body\n checkEmsg(@conn)\n end",
"def test_req_too_large()\n conn = Scalaroid::Transaction.new()\n data = (0..($_TOO_LARGE_REQUEST_SIZE)).map{0}.join()\n key = \"_ReqTooLarge\"\n begin\n conn.write(@testTime.to_s + key, data)\n assert(false, 'The write should have failed unless yaws_max_post_data was set larger than ' + $_TOO_LARGE_REQUEST_SIZE.to_s())\n rescue Scalaroid::ConnectionError\n end\n\n conn.close_connection()\n end",
"def test_slowest_client_gets_killed\n puts \"test_slowest_client_gets_killed\"\n # start slow client\n r = nil\n t = Thread.new do\n r = push(random_string(15), :maxsend => 1, :sleep => 1)\n end\n sleep 3 # race condition, sort of, but meh\n\n # start another 99 slow clients for a string of 12 bytes; we expect these\n # to complete successfully, ie, 1 byte containing 0x00 response expected\n expects = start_slow_clients(nclients: 99, string_size: 12, push_responses: [0])\n sleep 8\n\n # should kill the oldest client\n test_single_request\n t.join\n assert_equal(nil, r, \"expected nil, got #{r}\")\n\n # ensure all 99 threads are done writing their string\n @thread_pool.each {|tx| tx.join}\n\n # don't care about the order, but do care about all strings being there\n 99.times do\n r = pop\n assert(expects.include?(r), \"expected #{r} to exist in expects[]\")\n expects.delete(r)\n end\n end",
"def test_req_too_large()\n conn = Scalaroid::TransactionSingleOp.new()\n data = (0..($_TOO_LARGE_REQUEST_SIZE)).map{0}.join()\n key = \"_ReqTooLarge\"\n begin\n conn.write(@testTime.to_s + key, data)\n assert(false, 'The write should have failed unless yaws_max_post_data was set larger than ' + $_TOO_LARGE_REQUEST_SIZE.to_s())\n rescue Scalaroid::ConnectionError\n end\n\n conn.close_connection()\n end",
"def flush\n if !@write\n return @transport.flush\n end\n\n out = [@wbuf.length].pack('N')\n out << @wbuf\n @transport.write(out)\n @transport.flush\n @wbuf = ''\n end",
"def legacy_write_with_retry(server = nil, session = nil)\n # This is the pre-session retry logic, and is not subject to\n # current retryable write specifications.\n # In particular it does not retry on SocketError and SocketTimeoutError.\n attempt = 0\n begin\n attempt += 1\n server ||= select_server(cluster, ServerSelector.primary, session)\n yield server\n rescue Error::OperationFailure => e\n server = nil\n if attempt > client.max_write_retries\n raise\n end\n if e.write_retryable? && !(session && session.in_transaction?)\n log_retry(e, message: 'Legacy write retry')\n cluster.scan!(false)\n retry\n else\n raise\n end\n end\n end",
"def notify_writeable limit\n send_proc = proc do |data, finished: false|\n _flush_data data, finished: finished\n end\n @tap.call limit, send_proc\n end",
"def mssql_send_recv(req, timeout=15)\n\t\tsock.put(req)\n\n\t\t# Read the 8 byte header to get the length and status\n\t\t# Read the length to get the data\n\t\t# If the status is 0, read another header and more data\n\n\t\tdone = false\n\t\tresp = \"\"\n\n\t\twhile(not done)\n\t\t\thead = sock.get_once(8, timeout)\n\t\t\tif !(head and head.length == 8)\n\t\t\t\treturn false\n\t\t\tend\n\n\t\t\t# Is this the last buffer?\n\t\t\tif(head[1,1] == \"\\x01\")\n\t\t\t\tdone = true\n\t\t\tend\n\n\t\t\t# Grab this block's length\n\t\t\trlen = head[2,2].unpack('n')[0] - 8\n\n\t\t\twhile(rlen > 0)\n\t\t\t\tbuff = sock.get_once(rlen, timeout)\n\t\t\t\treturn if not buff\n\t\t\t\tresp << buff\n\t\t\t\trlen -= buff.length\n\t\t\tend\n\t\tend\n\n\t\tresp\n\tend",
"def raw_send_recv(cmd, nsock = self.sock)\n nsock.put(cmd)\n res = nsock.get_once\n end",
"def on_writable socket\n @reactor.deregister_writable socket\n end",
"def pending_write?; end",
"def test_set_key_unless_it_exists\n # Given\n refute @redis.exists( @key )\n\n # When\n @redis.set @key, @val1, nx: true\n\n # Then \n assert_equal @val1, @redis.get( @key )\n\n # ...and...\n\n # When\n @redis.set @key, @val2, nx: true\n\n # Then \n refute_equal @val2, @redis.get( @key )\n assert_equal @val1, @redis.get( @key )\n end",
"def write( transfer_until: )\n\t\t\tif !@pending_write\n\t\t\t\t@pending_write = true\n\t\t\t\t@transfer_until = transfer_until\n\n\t\t\t\tFiber.schedule do\n\t\t\t\t\tconnect\n\n\t\t\t\t\t# transfer data blocks of up to 65536 bytes\n\t\t\t\t\t# until the observed connection is writable again or\n\t\t\t\t\t# no data left to read\n\t\t\t\t\tloop do\n\t\t\t\t\t\tlen = 65536\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tread_str = @internal_io.read_nonblock(len)\n\t\t\t\t\t\t\tprint_data(\"write-transfer #{write_fds}\", read_str)\n\t\t\t\t\t\t\tsleep 0\n\t\t\t\t\t\t\t@external_io.write(read_str)\n\t\t\t\t\t\t\tif @transfer_until.is_a?(IO)\n\t\t\t\t\t\t\t\tres = IO.select(nil, [@transfer_until], nil, 0) rescue nil\n\t\t\t\t\t\t\t\tif res\n\t\t\t\t\t\t\t\t\tputs \"stop writing - #{@transfer_until.inspect} is writable again\"\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\trescue IO::WaitReadable, Errno::EINTR\n\t\t\t\t\t\t\t@internal_io.wait_readable\n\t\t\t\t\t\t\tretry\n\t\t\t\t\t\trescue EOFError, Errno::ECONNRESET\n\t\t\t\t\t\t\tputs \"write_eof from #{write_fds}\"\n\t\t\t\t\t\t\t@external_io.close_write\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend\n\t\t\t\t\t\tbreak if @transfer_until != :eof && (!read_str || read_str.bytesize < len)\n\t\t\t\t\tend\n\t\t\t\t\t@until_writeable = false\n\t\t\t\t\t@pending_write = false\n\t\t\t\tend\n\n\t\t\telsif (transfer_until == :wouldblock && @transfer_until.is_a?(IO)) ||\n\t\t\t\t\ttransfer_until == :eof\n\t\t\t\t# If a write request without stopping on writablility comes in,\n\t\t\t\t# make sure, that the pending transfer doesn't abort prematurely.\n\t\t\t\t@transfer_until = transfer_until\n\t\t\tend\n\t\tend",
"def raw_send_recv(cmd, nsock = self.sock)\n nsock.put(cmd)\n nsock.get_once\n end",
"def test_send_to_another_connection\n driver = create_driver(%[\n server sensu-client.local\n port 3031\n ], 'ddos')\n time = Time.parse('2015-01-03 12:34:56 UTC').to_i\n driver.emit({}, time)\n driver.run\n result = driver.instance.sent_data\n expected = {\n 'name' => 'ddos',\n 'output' => '{}',\n 'status' => 3,\n 'type' => 'standard',\n 'handlers' => ['default'],\n 'executed' => time,\n 'fluentd' => {\n 'tag' => 'ddos',\n 'time' => time.to_i,\n 'record' => {},\n },\n }\n assert_equal [['sensu-client.local', 3031, expected]], result\n end",
"def testWriteString2()\n key = \"_WriteString2\"\n conn = Scalaris::TransactionSingleOp.new()\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n conn.write(@testTime.to_s + key.to_s, $_TEST_DATA[i])\n end\n \n # now try to read the data:\n actual = conn.read(@testTime.to_s + key.to_s)\n assert_equal($_TEST_DATA[$_TEST_DATA.length - 1], actual)\n conn.close_connection()\n end",
"def testWriteString2()\n key = \"_WriteString2\"\n conn = Scalaris::TransactionSingleOp.new()\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n conn.write(@testTime.to_s + key.to_s, $_TEST_DATA[i])\n end\n \n # now try to read the data:\n actual = conn.read(@testTime.to_s + key.to_s)\n assert_equal($_TEST_DATA[$_TEST_DATA.length - 1], actual)\n conn.close_connection()\n end",
"def listen_fserver_read(client)\n line = @lookupserver.gets.chomp\n while line.empty? do\n line = @lookupserver.gets.chomp\n end\n msg = line\n msg = msg << \"\\n\" << @lookupserver.gets.chomp\n msg = msg << \"\\n\" << @lookupserver.gets.chomp\n line = @lookupserver.gets.chomp\n contents = \"\"\n puts msg\n while !line.empty? do\n contents = contents << line << \"\\n\"\n line = @lookupserver.gets.chomp\n end\n msg = msg << \"\\n\" << contents[@start_n..@start_n + @len_n]\n client.puts(\"\\n#{msg}\")\n validate_cache(contents, client)\n end",
"def send_http_and_sysread(req)\n send_http(req).sysread 2_048\n end",
"def do_write(*args)\n # This method used to forward arguments to @socket.write in a\n # single call like so:\n #\n # @socket.write(*args)\n #\n # Turns out, when each buffer to be written is large (e.g. 32 MiB),\n # this write call would take an extremely long time (20+ seconds)\n # while using 100% CPU. Splitting the writes into chunks produced\n # massively better performance (0.05 seconds to write the 32 MiB of\n # data on the same hardware). Unfortunately splitting the data,\n # one would assume, results in it being copied, but this seems to be\n # a much more minor issue compared to CPU cost of writing large buffers.\n args.each do |buf|\n buf = buf.to_s\n i = 0\n while i < buf.length\n chunk = buf[i...i+WRITE_CHUNK_SIZE]\n @socket.write(chunk)\n i += WRITE_CHUNK_SIZE\n end\n end\n end",
"def test_write_list_not_connected()\n key = \"_WriteList_NotConnected\"\n conn = Scalaroid::TransactionSingleOp.new()\n conn.close_connection()\n #assert_raises( Scalaroid::ConnectionError ) { conn.write(@testTime.to_s + key, [$_TEST_DATA[0], $_TEST_DATA[1]]) }\n conn.write(@testTime.to_s + key, [$_TEST_DATA[0], $_TEST_DATA[1]])\n conn.close_connection()\n end",
"def try_write(fd, buf)\n begin\n if defined?(Fcntl::O_NONBLOCK)\n s = fd.write_nonblock(buf)\n else\n s = fd.write(buf)\n end\n if s < buf.length\n buf = buf[s..-1] # didn't finish\n else\n buf = \"\"\n end\n rescue Errno::EAGAIN\n buf = buf # try this again\n end\n buf\n end",
"def write_timeout; end",
"def write_timeout; end",
"def write_timeout; end",
"def test_write_list1()\n key = \"_WriteList1_\"\n conn = Scalaroid::TransactionSingleOp.new()\n\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n conn.write(@testTime.to_s + key + i.to_s, [$_TEST_DATA[i], $_TEST_DATA[i + 1]])\n end\n\n # now try to read the data:\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n actual = conn.read(@testTime.to_s + key + i.to_s)\n assert_equal([$_TEST_DATA[i], $_TEST_DATA[i + 1]], actual)\n end\n\n conn.close_connection()\n end",
"def write(*args)\n raise Errors::ConnectionFailure, \"Socket connection was closed by remote host\" unless alive?\n handle_socket_errors { super }\n end",
"def def_write_timeout\n 10\n end",
"def writable?(timeout)\n readable, writable, errors = IO.select(nil, [@socket], nil, timeout)\n return !writable.nil?\n end",
"def testReqTooLarge()\n conn = Scalaris::TransactionSingleOp.new()\n data = (0..($_TOO_LARGE_REQUEST_SIZE)).map{0}.join()\n key = \"_ReqTooLarge\"\n begin\n conn.write(@testTime.to_s + key, data)\n assert(false, 'The write should have failed unless yaws_max_post_data was set larger than ' + $_TOO_LARGE_REQUEST_SIZE.to_s())\n rescue Scalaris::ConnectionError\n end\n \n conn.close_connection()\n end",
"def listen_dserver(client)\n msg = @directoryserver.gets.chomp\n \n if(@is_new == \"1\")\n if(msg[0..5] == \"NOFILE\")\n @lookupserver = @fileserver0 #default for all new file entries\n @server_fn = \"#{@client_fn[0..@client_fn.length-5]}file.txt\"\n @client_msg.insert(5,@server_fn)\n @directoryserver.puts(\"INSERT:#{@client_fn} SERVER_FN:#{@server_fn}\")\n @lookupserver.puts(@client_msg)\n listen_fserver(client)\n # Client trying to create a new file with the same name as another\n # Implemented in this way for ease\n else\n client.puts @error0\n end\n else\n msg = msg.split(\" \")\n ip = msg[0][7..msg[0].length-1]\n port = msg[1][5..msg[1].length-1]\n @server_fn = msg[2][9..msg[2].length-1]\n @fservers[:ips].each do |other_port, other_ip|\n if(port == other_port.to_s && ip == other_ip.to_s)\n @lookupserver = @fservers[:tcps][other_port]\n end\n end\n if(@client_msg[0..4] == \"OPEN:\")\n @client_msg.insert(5,\"#{@server_fn}\")\n @lookupserver.puts(@client_msg)\n listen_fserver(client)\n elsif (@client_msg[0..5] == \"CLOSE:\")\n @client_msg.insert(6,\"#{@server_fn}\")\n @lookupserver.puts(@client_msg)\n listen_fserver(client)\n elsif (@client_msg[0..4] == \"READ:\")\n\tif @cached == true\n @lookupserver.puts(\"TIME:#{@server_fn}\")\n\t @client_msg.insert(5,\"#{@server_fn}\")\n\t check_cache_validity(client)\n\telse\n @lookupserver.puts(@client_msg)\n listen_fserver(client)\n\tend\n else #WRITE\n @lookupserver.puts(\"WRITE:#{@server_fn}\")\n @lookupserver.puts(@start_n)\n @lookupserver.puts(@contents)\n\tlisten_fserver(client)\n end\n end\n end",
"def handle_writable_io_event( event )\n\t\tif message = self.send_queue.shift\n\t\t\tmessage.send_to( self.socket )\n\t\telse\n\t\t\tself.reactor.disable_events( self.socket, :write )\n\t\tend\n\tend",
"def sock_send io, msg\n msg = \"#{msg}\\0\"\n log msg\n io.send msg, 0\n end",
"def flush\n return @transport.flush unless @write\n\n out = [@wbuf.length].pack('N')\n out << @wbuf\n @transport.write(out)\n @transport.flush\n @wbuf = ''\n end",
"def flush\n return @transport.flush unless @write\n\n out = [@wbuf.length].pack('N')\n out << @wbuf\n @transport.write(out)\n @transport.flush\n @wbuf = ''\n end",
"def raw_send_recv(cmd, nsock = self.sock)\n\t\tnsock.put(cmd)\n\t\tnsock.get_once\n\tend",
"def send_msg(msg, read_response=true)\n msg_to_send = msg.dup\n msg_to_send << @separator unless @separator.nil? || msg.end_with?(@separator)\n\n # This is an idempotent operation\n connect\n\n log(:debug, \"Sending #{msg_to_send.inspect}\")\n send_non_block(msg_to_send)\n \n if read_response\n resp = receive_non_block \n log(:debug, \"Got #{resp.inspect}\")\n resp\n end\n # Raised by some IO operations when reaching the end of file. Many IO methods exist in two forms,\n # one that returns nil when the end of file is reached, the other raises EOFError EOFError.\n # EOFError is a subclass of IOError.\n rescue EOFError => e\n log(:info, \"Server disconnected.\")\n self.disconnect\n raise e\n # \"Connection reset by peer\" is the TCP/IP equivalent of slamming the phone back on the hook.\n # It's more polite than merely not replying, leaving one hanging.\n # But it's not the FIN-ACK expected of the truly polite TCP/IP converseur.\n rescue Errno::ECONNRESET => e\n log(:info, 'Connection reset by peer.')\n self.disconnect\n raise e\n rescue Errno::EPIPE => e\n log(:info, 'Broken pipe.')\n self.disconnect\n raise e\n rescue Errno::ECONNREFUSED => e\n log(:info, 'Connection refused by peer.')\n self.disconnect\n raise e\n rescue Exception => e\n @socket.close if @socket && [email protected]?\n raise e\n end",
"def testWriteList1()\n key = \"_testWriteList1_\"\n t = Scalaris::Transaction.new()\n\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n t.write(@testTime.to_s + key + i.to_s, [$_TEST_DATA[i], $_TEST_DATA[i + 1]])\n end\n \n # now try to read the data:\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n actual = t.read(@testTime.to_s + key + i.to_s)\n assert_equal([$_TEST_DATA[i], $_TEST_DATA[i + 1]], actual)\n end\n \n t.close_connection()\n \n # commit the transaction and try to read the data with a new one:\n t.commit()\n t = Scalaris::Transaction.new()\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n actual = t.read(@testTime.to_s + key + i.to_s)\n assert_equal([$_TEST_DATA[i], $_TEST_DATA[i + 1]], actual)\n end\n \n t.close_connection()\n end",
"def testWriteList1()\n key = \"_testWriteList1_\"\n t = Scalaris::Transaction.new()\n\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n t.write(@testTime.to_s + key + i.to_s, [$_TEST_DATA[i], $_TEST_DATA[i + 1]])\n end\n \n # now try to read the data:\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n actual = t.read(@testTime.to_s + key + i.to_s)\n assert_equal([$_TEST_DATA[i], $_TEST_DATA[i + 1]], actual)\n end\n \n t.close_connection()\n \n # commit the transaction and try to read the data with a new one:\n t.commit()\n t = Scalaris::Transaction.new()\n (0..($_TEST_DATA.length - 2)).step(2) do |i|\n actual = t.read(@testTime.to_s + key + i.to_s)\n assert_equal([$_TEST_DATA[i], $_TEST_DATA[i + 1]], actual)\n end\n \n t.close_connection()\n end",
"def test_replicated_dht1()\n rdht = Scalaroid::ReplicatedDHT.new()\n rdht.close_connection()\n end",
"def write(data, timeout=nil)\n #connect if !connected?\n if writable?(timeout)\n return @socket.syswrite(data)\n else\n raise FTW::Connection::WriteTimeout.new(self.inspect)\n end\n end",
"def test_post_to_hipchat_with_failures\n stub_request(:post, 'http://api.hipchat.com/v1/rooms/message').to_return(\n {:status => ['500', 'Server Error']},\n {:status => ['500', 'Server Error']},\n {:body => 'OK'}\n )\n\n HipChat.post_to_hipchat('fake_room', 'my_message2')\n HipChat.await_retries_for_test\n assert_requested :post, 'http://api.hipchat.com/v1/rooms/message', times: 3 do |req|\n req.body.match /message=my_message2/\n end\n\n assert_equal 2, HipChat.retries_for_test\n assert_in_delta BACKOFF + (2 * BACKOFF), HipChat.total_backoff_for_test\n end",
"def testReqTooLarge()\n conn = Scalaris::Transaction.new()\n data = (0..($_TOO_LARGE_REQUEST_SIZE)).map{0}.join()\n key = \"_ReqTooLarge\"\n begin\n conn.write(@testTime.to_s + key, data)\n assert(false, 'The write should have failed unless yaws_max_post_data was set larger than ' + $_TOO_LARGE_REQUEST_SIZE.to_s())\n rescue Scalaris::ConnectionError\n end\n \n conn.close_connection()\n end",
"def test_write_string_not_connected()\n key = \"_WriteString_NotConnected\"\n conn = Scalaroid::TransactionSingleOp.new()\n conn.close_connection()\n #assert_raises( Scalaroid::ConnectionError ) { conn.write(@testTime.to_s + key, $_TEST_DATA[0]) }\n conn.write(@testTime.to_s + key, $_TEST_DATA[0])\n conn.close_connection()\n end",
"def rescuable_serve\n Thread.new { serve } unless @running\n raise @exception_q.pop\n end",
"def flush writes\n total = 0\n while bytes = writes.shift\n next unless bytes.bytesize > 0\n\n num_bytes = begin\n @io.write_nonblock(bytes)\n rescue IO::WaitWritable, Errno::EAGAIN\n 0\n end\n\n if num_bytes > 0\n @io.flush\n total += num_bytes\n end\n\n # If the write could not be completed in one go, or if there are\n # more writes pending ...\n if num_bytes == 0\n writes.unshift bytes\n @selector.enable_write @io\n break\n elsif num_bytes < bytes.bytesize\n writes.unshift bytes.byteslice(num_bytes..bytes.bytesize)\n @selector.enable_write @io\n break\n end\n end\n rescue IOError, Errno::EPIPE, Errno::ECONNRESET => e\n @selector.remove [@io]\n @listener.trigger_error e\n rescue => e\n log(Logger::ERROR, self.to_s + '#flush', e.to_s)\n @selector.enable_write @io\n ensure\n @listener.trigger_write total\n return writes\n end",
"def test_conn_1p_0070\n @conn.disconnect\n #\n cha = get_conn_headers() \n cha[\"heart-beat\"] = \"500,1000\" # Valid heart beat headers\n conn = nil\n assert_nothing_raised do\n conn = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)\n conn.disconnect\n end\n assert conn.hbsend_interval > 0\n assert conn.hbrecv_interval > 0\n end"
] | [
"0.637658",
"0.6212006",
"0.60668343",
"0.5868407",
"0.57329184",
"0.57095397",
"0.5570915",
"0.55589736",
"0.5449376",
"0.54032564",
"0.5403216",
"0.53791744",
"0.5369392",
"0.5338041",
"0.52995646",
"0.52987987",
"0.5276667",
"0.5227054",
"0.51494396",
"0.514907",
"0.5138319",
"0.5135035",
"0.5126164",
"0.5121223",
"0.51075625",
"0.5103614",
"0.5095558",
"0.50862885",
"0.50666344",
"0.50594133",
"0.5052379",
"0.50461054",
"0.50440365",
"0.5039947",
"0.50309443",
"0.5026763",
"0.50117886",
"0.50117886",
"0.5011053",
"0.50047046",
"0.5003494",
"0.49865162",
"0.498576",
"0.49854952",
"0.4972056",
"0.4972056",
"0.49701452",
"0.49684873",
"0.49650264",
"0.496026",
"0.49563518",
"0.49456978",
"0.49335295",
"0.49324083",
"0.49289677",
"0.49246025",
"0.4921095",
"0.49188933",
"0.49088648",
"0.4908037",
"0.4904998",
"0.49024594",
"0.48914486",
"0.48881665",
"0.48873758",
"0.48861837",
"0.48842907",
"0.48840106",
"0.48546708",
"0.48546708",
"0.4846953",
"0.48439178",
"0.48420593",
"0.4835176",
"0.48262975",
"0.4825187",
"0.4825187",
"0.4825187",
"0.48213732",
"0.4815544",
"0.48119155",
"0.4811035",
"0.48027262",
"0.4797804",
"0.479615",
"0.47852126",
"0.47838375",
"0.47838375",
"0.47683105",
"0.47652003",
"0.4762411",
"0.4762411",
"0.47623974",
"0.47540012",
"0.47537753",
"0.47536623",
"0.4751469",
"0.47492608",
"0.47380665",
"0.4723201"
] | 0.8699605 | 0 |
form view for adding new courses | def new
@course = Course.new
@user = Teacher.find_by_email(session[:email])
@teachers = Teacher.where(department: @user.department)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @course = Course.new\n render 'new'\n end",
"def new\n @course=Course.new\n end",
"def new\n @course=Course.new\n end",
"def create\n @course = Course.new(course_params) # crea un curso con todos los parametros que le envia el formulario\n @course.save\n @courses = Course.all # aqui consultamos por todos los cursos\n render :index # y pintamos otra vez la lista de cursos\n\n end",
"def create\n # render plain: params[:courses].inspect\n @courses = Courses.new(courses_params)\n\n respond_to do |format|\n if @courses.save\n format.html { redirect_to @courses, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @courses }\n else\n format.html { render :new }\n format.json { render json: @courses.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(new_course_params)\n\n if @course.save\n redirect_to stafftools_course_path(@course)\n else\n render :new\n end\n end",
"def create\n if @course.save\n redirect_to @course, notice: 'Course was successfully created.'\n else\n redirect_to action: :new\n end\n end",
"def create\n # find if there are any courses with both the same name and section number\n duplicate_courses = Course.where(name: course_params[:name], section: course_params[:section])\n # SQL Equivalent (in SQLite):\n # SELECT \"courses\".* FROM \"courses\" WHERE \"courses\".\"name\" = ? AND \"courses\".\"section\" = ?\n # where ? == name of course and section of course\n\n if duplicate_courses.blank?\n # else make a new course based on parameters passed from form\n @course = Course.new(course_params)\n # check validity and successful save\n if @course.valid? && @course.save\n # @course.save SQL Equivalent:\n # INSERT INTO \"courses\"\n # (\"teacher_id\", \"deptName\", \"name\", \"section\", \"created_at\", \"updated_at\")\n # VALUES (?, ?, ?, ?, ?, ?);\n\n\n # redirect\n redirect_to '/admin/index'\n return\n else\n # otherwise check the error\n if @course.invalid?\n flash[:fail] = \"Unable to create course: #{@course.errors.full_messages}\"\n else\n flash[:fail] = \"Unable to create course for unknown reason. Try again!\"\n end\n\n redirect_back(fallback_location: '/admin/index')\n return\n end\n else\n # sent an error\n flash[:fail] = \"There is already a course with that name and section!\"\n redirect_back(fallback_location: '/admin/index')\n end\n end",
"def new\n @course = Course.new\n end",
"def new\n @course = Course.new\n end",
"def new\n @course = Course.new\n end",
"def new\n @course = Course.new\n end",
"def create\n @course = Course.new(course_params)\n\n if @course.save\n redirect_to @course, notice: 'Course was successfully created'\n else\n render action: 'new'\n end\n end",
"def new\n\t\t@course = Course.new\n\tend",
"def create\n @course = Course.new(course_params)\n\n if @course.save\n flash[:success] = \"Curso criado com sucesso\"\n redirect_to courses_path\n else\n flash[:error] = \"Não foi possível criar o curso\"\n redirect_to courses_path\n end\n end",
"def create\n @course = Course.new(courses_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = @student.courses.new(params[:course])\n @course.save\n redirect_to @course.student\n end",
"def create\n\t\tcourse = Course.new(course_params)\n\t\tif course.save\n\n\t\t params[:course][\"major_id\"].each do |major_id|\n\t if !major_id.empty?\n\t course.major << Major.find(major_id)\n\t end\n\t end\n\n\t params[:course][\"minor_id\"].each do |minor_id|\n\t if !minor_id.empty?\n\t course.minor << Minor.find(minor_id)\n\t end\n\t end\n\n\t params[:course][\"concentration_id\"].each do |concentration_id|\n\t if !concentration_id.empty?\n\t course.concentration << Concentration.find(concentration_id)\n\t end\n\t end\n\n\t params[:course][\"distribution_id\"].each do |distribution_id|\n\t if !distribution_id.empty?\n\t course.distribution << Distribution.find(distribution_id)\n\t end\n\t end\n\n\t\t\tredirect_to '/courses'\n\t\telse\n\t\t\tflash[:danger] = \"The form you submitted is invalid.\"\n\t\t\tredirect_to '/courses/new'\n\t\tend\n\tend",
"def create\n @course = Course.new(params[:course])\n @admin_section = true\n @page_title = \"Create New Course\"\n \n respond_to do |format|\n if @course.save\n format.html { redirect_to(admin_courses_url, :notice => 'Course was successfully created.') }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to static_pages_admin_url, notice: 'Course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to admin_courses_path, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\t\t@course = Course.find_by_id(params[:course_id])\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\tend\n\tend",
"def new\n @course = params[:course_id]\n end",
"def create\n @course = current_teacher.courses.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to courses_url, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = current_teacher.courses.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n \n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, :notice => t('selecao_admin.flash_messages.successfully_created', :model => @course.class.model_name.human) }\n format.json { render :json => @course, :status => :created, :location => @course }\n format.js\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end",
"def new\n @course = Course.new\n @course.active = true\n @course_date = CourseDate.new \n \n @admin_section = true\n @page_title = \"Create New Course\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end",
"def new\n @court_type = CourtType.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n @competition = Competition.new\n @courses = Course.all\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def create\n authorize! :manage, Course\n @course = Course.new(course_params)\n @course.course_sections.each do |course_section|\n course_section.name = \"#{@course.name} #{course_section.grade_section.name}\"\n end\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course added. Warning no Instructor assigned. Go to the manage user history tab and add instructor' }\n format.json { render action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to courses_url, notice: 'Curso creado satisfactoriamente' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to admin_course_url(@course), notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @collab = Collab.new\n @collab.course_id = params[:course_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collab }\n end\n end",
"def new\n @course = Course.new\n end",
"def new\n @course = Course.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end",
"def create\n @course = Course.new(course_params)\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @question = Question.new(:course_id => params[:course_id])\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course ' + @course.course_id + ' was successfully created!' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @course = Course.new\n @curr_term ||= view_context.get_selected_terms\n if @curr_term.empty?\n flash[:error] = \"Cannot create a new course for current term, as there isn’t any current term. Please create a new one first.\"\n redirect_to :controller => \"terms\", :action => \"index\"\n else\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end\n end",
"def new\n @course = Course.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Curso criado com sucesso.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @course = current_user.courses.build(course_params)\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: \"Course was successfully created.\" }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_course = Admin::Course.new(admin_course_params)\n\n respond_to do |format|\n if @admin_course.save\n format.html { redirect_to @admin_course, notice: t('crud.created_successfully!', name: Admin::Course.model_name.human) }\n format.json { render :show, status: :created, location: @admin_course }\n else\n format.html { render :new }\n format.json { render json: @admin_course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n respond_to do |format|\n if @course.save\n\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n course_name = params[:text].to_s\n course = Course.create(name: course_name)\n CourseInstructor.create(course: course, instructor: current_user.instructor)\n\n @courses = current_user.instructor.courses.collect{ |course|\n {\n name: course.name,\n id: course.id\n }\n }\n\n render :template => \"home/index\"\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render action: 'show', status: :created, location: @course }\n else\n format.html { render action: 'new' }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to [:admin, @course], :notice => 'Course was successfully created.' }\n format.json { render :json => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if form_lang_combo_valid? && @course.save\n flash[:notice] = 'Course was successfully created.'\n format.html { redirect_to(@course) }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n flash[:error] = \"Selected form and language combination isn’t valid.\" unless form_lang_combo_valid?\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def addcourse\n current_user.courses<<@course unless current_user.courses.exists?(@course.id)\n redirect_to courses_path\n end",
"def create\n @course = Course.new(course_params)\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: \"Course was successfully created.\" }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(course_params)\n \n respond_to do |format|\n if @course.save\n #format.html { redirect_to course_build_path(:id =>\"courseinfo\", :course_id => @course.id), notice: \"Course Created\" }\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @titre = \"Creating a course\"\n if params[:formation_id]\n @formation = Formation.find(params[:formation_id])\n @course = @formation.courses.create(course_params)\n else\n @course = Course.new(course_params)\n end\n if @course.save\n redirect_to edit_course_path(@course)\n else\n render 'new'\n end\n end",
"def new\n redirect_to '/new_course'\n end",
"def create\n @student = Student.new(student_params)\n\n respond_to do |format|\n if @student.save\n format.html { redirect_to @student, notice: 'Student was successfully created.' }\n format.json { render :show, status: :created, location: @student }\n # Add the course just created to this student's courses, better use the drop down list \n if params[:course] != nil then\n @student.courses << Course.find(params[:course][:id])\n end\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tmajors_course = MajorsCourse.new(majors_course_params)\n\t\tif majors_course.save\n\t\t\tredirect_to '/majors_courses'\n\t\telse\n\t\t\tflash[:danger] = \"The form you submitted is invalid.\"\n\t\t\tredirect_to '/majors_courses/new'\n\t\tend\n\tend",
"def new\n @course =Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end",
"def new\n @course = Course.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n session[:breadcrumbs].add \"New\"\n @service_learning_course = ServiceLearningCourse.create :quarter_id => @quarter.id\n @service_learning_course.courses.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service_learning_course }\n end\n end",
"def new\n @course = Course.new()\n @areas = Area.find(:all)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course }\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, :notice=> 'Curso creado' }\n format.json { render :json=> @course, :status=> :created, :location=> @course }\n else\n format.html { render :action=> \"new\" }\n format.json { render :json=> @course.errors, :status=> :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to courses_path(), notice: 'El curso fue exitosamente creado.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n format.html { redirect_to new_course_path, notice: \"Debe escribir por lo menos el nombre del curso para crearlo.\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @course = Course.new\n 2.times do\n [email protected]\n end\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @course }\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n flash[:notice] = 'Course was successfully created.'\n format.html { redirect_to courses_path }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.find(params[:course_id])\n #@grade = Grade.new(params[:grade])\n end",
"def new\n @student = Student.new\n @courses = Course.all\n #@projecttags = Project.all\n end",
"def create\n @grade = Grade.find(params[:grade_id])\n @course = @grade.courses.build(course_params)\n if @course.save\n redirect_to grade_courses_path(@grade, @courses), notice: 'Successfully Created Course'\n else\n render action: 'new'\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n flash[:notice] = 'Course was successfully created.'\n format.html { redirect_to( :action => 'show', :id => @course) }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n flash[:notice] = 'Course was successfully created.'\n format.html { redirect_to :action => 'index' }\n format.xml { render :xml => @course, :status => :created, :location => @course }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def createCourse\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n flash[:notice] = \"Course was successfully created!\" \n format.html { redirect_to mentor_url }\n else \n\tflash[:error] = \"Cannot add this course!\"\n format.html { redirect_to mentor_url }\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 create\n @course = Course.new(params[:course])\n\n respond_to do |format|\n if @course.save\n \n format.html { redirect_to @course, notice: 'course was successfully created.' }\n format.json { render json: @course, status: :created, location: @course }\n else\n ppp @course.errors.full_messages\n format.html { render action: \"new\" }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end",
"def new\n @course = Course.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course }\n end\n end"
] | [
"0.77628183",
"0.76429343",
"0.76429343",
"0.759494",
"0.759298",
"0.7485415",
"0.7464564",
"0.74486226",
"0.7442729",
"0.74423623",
"0.74423623",
"0.74423623",
"0.7377019",
"0.7348429",
"0.7309669",
"0.73026997",
"0.7286684",
"0.7274841",
"0.72677267",
"0.7252113",
"0.72305727",
"0.7180725",
"0.71632606",
"0.7158727",
"0.71424806",
"0.713873",
"0.71354645",
"0.7126772",
"0.7125613",
"0.7124566",
"0.7110278",
"0.71038723",
"0.7100264",
"0.7087745",
"0.7086974",
"0.7079255",
"0.7072256",
"0.7063347",
"0.70453835",
"0.70453835",
"0.70453835",
"0.70453835",
"0.70453835",
"0.70453835",
"0.70453835",
"0.70453835",
"0.70453835",
"0.70453835",
"0.70453835",
"0.70453835",
"0.70452553",
"0.7044635",
"0.7043978",
"0.70367956",
"0.70338964",
"0.70192516",
"0.70050824",
"0.70019984",
"0.7001732",
"0.6994358",
"0.6988388",
"0.69868994",
"0.698267",
"0.6979382",
"0.6973508",
"0.6973508",
"0.6973508",
"0.6973508",
"0.6973508",
"0.6973508",
"0.6973508",
"0.6949805",
"0.69426847",
"0.6939918",
"0.69371045",
"0.6932987",
"0.69319266",
"0.6916925",
"0.6902868",
"0.6900756",
"0.6887097",
"0.6884085",
"0.6882619",
"0.6882266",
"0.68787766",
"0.6873234",
"0.6867793",
"0.68652886",
"0.6859477",
"0.68560845",
"0.6846239",
"0.6844587",
"0.6843973",
"0.6838286",
"0.6830671",
"0.6830671",
"0.6830671",
"0.6830671",
"0.6830671",
"0.6830671",
"0.6830671"
] | 0.0 | -1 |
This should get all the courses that match the search query | def search
query = "%" + params[:search] + "%"
@course = Course.where("name LIKE ?", query)
# if params[:search]
# @course = Course.where(params:[:search]).order("created_at DESC")
# else
# @course = Course.all.order("created_at DESC")
#This was causing an error with the search
#@courses = Course.all;
#end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\r\n @search_term = params[:search]\r\n # Do search using scoped_search. If search term is empty then all records are returned.\r\n @courses = Course.available.full_search(@search_term).order(:title).page(params[:page])\r\n\r\n # Load category.\r\n @category = nil\r\n if params[:category]\r\n @courses = @courses.where(category_id: params[:category])\r\n @category = Category.find params[:category]\r\n end\r\n\r\n # Filter by college if needed.\r\n if params[:college]\r\n @courses = @courses.where(college_id: params[:college])\r\n end\r\n end",
"def index\n @courses = Course.with_category\n \n if params[:search] && params[:search] != ''\n @courses = @courses.where(['(code = ? OR name ILIKE ?)', params[:search], \"%#{params[:search]}%\"])\n end\n \n if params[:course_category_id] && params[:course_category_id] != ''\n @courses = @courses.where(:course_category_id => params[:course_category_id])\n end\n \n @courses = @courses.paginate :page => params[:page]\n \n respond_with @courses\n end",
"def search\n begin\n @courses = Course.search(params[:query]) if params[:query]\n rescue Searchable::SearchError => msg\n flash.now[:error] = msg\n rescue Searchable::NoSearchResults => msg\n flash.now[:notice] = msg\n end\n end",
"def index\n if params[:search].present?\n @query = Course.search params[:search].gsub(/[^0-9a-z\\s]/i, '').split\n else\n filter_model Course\n filter :section_id do |q|\n q.joins(:sections).where :\"sections.id\" => any(:section_id)\n end\n filter :department_code do |q|\n q.joins(:department).where :\"departments.code\" => any(:department_code)\n end\n filter_any :id, :department_id, :name, :number, :min_credits, :max_credits\n query.includes! :sections if @show_sections\n end\n end",
"def index\n @catalogs_courses = Catalogs::Course.search(params[:search]).order(\"#{sort_column} #{sort_direction}\").paginate(per_page: 15, page: params[:page])\n end",
"def research_courses\n Course.find :all, :conditions => { :ts_year => year, :ts_quarter => quarter_code, :ts_research => true }\n end",
"def index\n query = params[:q]\n @courses = query ? Course.search(query) : Course.all.order(:id)\n\n render json: @courses\n end",
"def index\n if params[:search]\n @search = Course.search do\n fulltext params[:search]\n paginate :page => params[:page] || 1, :per_page => 10\n end\n @courses = @search.results\n else\n @courses = Course.paginate(:page => params[:page], :per_page => 10)\n end\n \n \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @courses }\n end\n end",
"def index\n time_range = Time.now..(Time.now + 30.day)\n @q = Course.where(\"courses.course_start\" => time_range).order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 10).search(params[:q])\n @courses = @q.result(distinct: true)\n end",
"def courses\n @courses ||= CourseList.new(:cluster => slug.gsub('-', ' ')).\n sort_by { |c| c.title + c.edition }.\n uniq { |c| c.code + c.edition }\n end",
"def index\n if params[:search].present?\n if params[:search].downcase=='active'\n @courses= Course.where('is_active = ?', true)\n return @courses\n end\n end\n if params[:search].present?\n if params[:search].downcase=='inactive'\n @courses= Course.where('is_active = ?', false)\n return @courses\n end\n end\n\n @courses = Course.all\n @a = Course.search(params[:search]) if params[:search].present?\n\n @instructors = User.search(params[:search]) if params[:search].present?\n\n if @instructors\n @instructors.each do |x|\n @b=x.courses\n end\n end\n if @a\n @courses=@a\n if @b\n @courses=@courses+@b\n end\n elsif @b\n @courses=@b\n end\n\n #@instructors=User.where(:is_admin=>false, :is_instructor=>true)\n #@instructors.\n end",
"def list\n #no objects of class (as compared to previous lab)\n #no array!\n @courses = Course.where(\"instructor='John'\")\n end",
"def index\n if params[:like]\n # Wildcard matching\n like = \"%#{params[:like]}%\"\n # Filter courses\n @courses = Course.joins(:instructor).where('(coursenumber LIKE :like ' +\n ' OR title LIKE :like' +\n ' OR users.name LIKE :like' +\n ' OR description LIKE :like)' +\n ' AND status = :status',\n :like => like, :status => params[:status])\n else\n @courses = Course.all\n end\n end",
"def index\n field = params[:field]\n keyword = params[:keyword]\n lessons = Lesson.joins(:course)\n if field.present? && keyword.present?\n if field == 'course_id'\n lessons = lessons.where(['courses.name like ?', \"%#{keyword}%\"])\n else\n lessons = lessons.where([\"lessons.#{field} like ?\", \"%#{keyword}%\"])\n end\n end\n @lessons = lessons.select('lessons.*', 'courses.name as course_name').page(params[:page]).per(params[:per])\n end",
"def get_courses_by_property_by_string(property, search_string)\n puts \"[+] Searching for courses using search string: #{search_string}\".yellow +\n + \" -- And property: #{property}\"\n courses_results = []\n results = get_all_courses\n results.each do |x|\n if x[property].downcase.include? search_string.downcase\n courses_results.push(x)\n end\n end\n courses_results\n # returns array of all matching courses in JSON format.\nend",
"def courses\n @courses = Course.where(\"teacher_id=?\",session[:user].teacher_id)\n end",
"def courses\n request(COURSES_URL, {}, 'GET').map do |course|\n Course.new(self, course)\n end\n end",
"def index\n @courses = Course.all\n if params[:search]\n @courses = Course.search(params[:search]).order(\"created_at DESC\")\n else\n @courses = Course.all.order('created_at DESC')\n end\n end",
"def course_students\n return student_terms.find_all_by_term_type(\"Course\")\n end",
"def list_courses(courses_collection)\n courses_collection.each do |course|\n\n end\n end",
"def service_courses\n Course.find :all, :conditions => { :ts_year => year, :ts_quarter => quarter_code, :ts_service => true }\n end",
"def index\n #I should check for emptiness first, that would be helpful, drag that code over.\n # if params[:title]\n # @courses = Course.where('title ILIKE ?', \"%#{params[:title]}%\") #case insensitive\n # else\n #@q = Course.ransack(params[:q])\n # Distinct true must be removed from the new version, because of course, the user will not be 'unique'\n #he will appear multiple times.\n #@courses = @q.result.includes(distinct: true)\n #@courses = @q.result.includes(:user)\n @ransack_path = courses_path \n @ransack_courses = Course.ransack(params[:courses_search], search_key: :courses_search)\n #@courses = @ransack_courses.result.includes(:user)\n @pagy, @courses = pagy(@ransack_courses.result.includes(:user))\n end",
"def search_skills_and_courses\n # FIXME: this is probably not used any more\n authorize! :update, Skill\n\n @courses = ScopedCourse.search params[:q],\n :include => [:localized_description, :localized_skill_descriptions],\n :page => params[:p] || 1, :per_page => 20\n\n # Validate skill_id!\n render(:nothing => true, :status => 500) unless /^\\d+$/ =~ params[:sid]\n\n skill_id = params[:sid]\n\n # Query to find out if skills are already prerequirements to the\n # skill being edited.\n queryresults = ActiveRecord::Base.connection.select_all %Q{\n SELECT DISTINCT ON (skills.id) skills.id, skills.id IN (\n SELECT skill_prereqs.prereq_id\n FROM skill_prereqs\n WHERE skill_prereqs.skill_id = #{skill_id}\n ) AS alreadyPrereq\n FROM skills\n }\n\n # Lookup table for view to check if skill is already a prerequirement\n @alreadyPrereq = { }\n queryresults.each do |row|\n @alreadyPrereq[row[\"id\"]] = row[\"alreadyprereq\"] == 't' ? true : false\n end\n\n if @courses.empty?\n respond_to do |format|\n format.text { render :text => \"nothing\" }\n end\n else\n respond_to do |format|\n format.html { render :partial => \"search_results\" }\n end\n end\n end",
"def index\n if !params[:q].blank?\n @q = Course.ransack(params[:q])\n @course = @q.result.includes(:major, :teacher)\n else\n @course = Course.all\n end\n \n end",
"def courses\n Course.all.select { |course_inst| course_inst.student == self }\n end",
"def get_test_courses\n return [get_courses_in_page('https://www.sis.hawaii.edu/uhdad/avail.classes?i=MAN&t=201430&s=ICS'),\n get_courses_in_page('https://www.sis.hawaii.edu/uhdad/avail.classes?i=MAN&t=201430&s=MATH'),\n get_courses_in_page('https://www.sis.hawaii.edu/uhdad/avail.classes?i=MAN&t=201430&s=PSY')]\n end",
"def index\n @courses = Course.all\n puts @courses[0].isLike(current_person.id)\n \n if params[:title]\n @courses = @courses.where(\"lower(title) like ?\", \"%#{params[:title]}%\")\n end\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 get_courses_by_name(org_unit_name)\n get_courses_by_property_by_string('Name', org_unit_name)\nend",
"def search\r\n # with empty term scoped_search returns all results, which we don't want.\r\n term = params[:term].strip unless params[:term].nil?\r\n respond_to do |format|\r\n if term.nil? or term.empty?\r\n format.json { head :ok } # blank json response\r\n else\r\n # Perform search.\r\n @courses = Course.full_search(params[:term]).where(status: :open).take 10\r\n format.json { render :json => @courses, :only => [:id, :title],\r\n :include => {:college => {:only => :name}, :category => {:only => :name}} }\r\n end\r\n end\r\n end",
"def list_courses \r\n courses = Subject.find(params[:s]).courses rescue render_return\r\n render_return if courses.empty? or !logged_in_user.see_course?(courses.first)\r\n render_p 'course_display/list_courses',{'courses'=>courses,'caller'=>params[:caller]}\r\n end",
"def index\n if params[:course]\n # @searched = params[:course]\n # @tracks = Track.where(\"title ILIKE ?\", \"%#{params[:course]}%\")\n @q = Track.ransack(params[:course])\n @tracks = @q.result(distinct: true)\n else \n @q = Track.ransack(params[:q])\n @tracks = @q.result(distinct: true)\n end\n end",
"def courses\n Content::Courses.new(token: @token)\n end",
"def find_courses collection, course_ids\n course_ids = [course_ids] if course_ids.is_a?(String)\n\n validate_course_ids course_ids\n\n # query db\n if course_ids.length > 1\n courses = collection.find(\n { course_id: { '$in' => course_ids } },\n { fields: { _id:0, 'sections._id' => 0 } }\n )\n else\n courses = collection.find(\n { course_id: course_ids[0] },\n { fields: { _id:0, 'sections._id' => 0 } }\n )\n end\n\n # to_a, map is more memory efficient\n courses = courses.map { |e| e }\n\n # check if found\n if courses.empty?\n s = course_ids.length > 1 ? 's' : ''\n halt 404, {\n error_code: 404,\n message: \"Course#{s} with course_id#{s} #{course_ids.join(',')} not found!\",\n available_courses: \"http://api.umd.io/v0/courses\",\n docs: \"http://umd.io/courses/\"\n }.to_json\n end\n\n courses\n end",
"def courses\n unless user_signed_in? && current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n \n $selected_course = nil\n\n @courses = current_user.instructor.courses.collect{ |course|\n {\n name: course.name,\n id: course.id\n }\n }\n\n render :template => \"home/index\"\n end",
"def courses_all\n call_path = \"courses/all\"\n data = build_post_data(\"\")\n perform_post(build_url(call_path), data)\n end",
"def index\n @given_courses = GivenCourse.all\n end",
"def index\n\t\t@courses = Course.all\n\tend",
"def get_courses (subdomain,subaccount_id)\n token = get_token\n courses = get_all_pages(\n token,\n \"https://#{subdomain}.instructure.com/api/v1/accounts/#{subaccount_id}/courses\"\n #needs to change for pageviews include[]=teachers&include[]=total_students&state[]=available&state[]=completed\"\n )\n end",
"def index\n search_attrs = {}\n [:min, :max, :level_id, :category_id].each do |key|\n search_attrs[key] = params[key] if params[key]\n end\n min = search_attrs.delete(:min)\n max = search_attrs.delete(:max)\n search_attrs[:price] = (min..max) if min && max\n @courses = Course.is_published.where(search_attrs).latest.includes(:lessons).page(params[:page]).per(9)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @courses }\n end\n end",
"def courses(institution, pageIndex=0, options={})\n options.merge!({:query => {:pageIndex => pageIndex}})\n self.class.get(\"/Institution/#{institution}/Courses.json\", options)\n end",
"def index\n @courses = Course.all\n if params[:state].present?\n state = params[:state]\n @courses = @courses.joins(:location).where(locations: {state: state})\n end\n\n render :index, status: :ok\n end",
"def index\n search_query = params[:search]\n page = (params[:page] || 1).to_i\n if page < 1 || page > @@max_page_number\n render status: 400, json: { result: \"Invalid Page Number\" }\n end\n query = []\n schema = {\n title: :text,\n tier: Tier.schema,\n visibility: Visibility.schema\n }\n\n if logged_in? == false \n query = Course.where(visibility: Visibility.published, tier: Tier.free)\n else\n user = current_user()\n if user.role == Role.deactivated || user.role == Role.user\n if user.tier == Tier.free\n query = Course.where(visibility: Visibility.published, tier: Tier.free).or(Course.where(user_id: user.id))\n elsif user.tier == Tier.premium\n query = Course.where(visibility: Visibility.published).or(Course.where(user_id: user.id))\n end\n elsif user.role == Role.moderator || user.role == Role.admin\n query = Course.all\n end\n query = paginate(search(query.order(updated_at: :desc), search_query, [:title, :description]), page: page, page_size: @@page_size, page_max: @@max_page_number)\n end\n return render status: 200, json: { result: query, schema: schema }\n end",
"def index\n @selectcontent=params[:selectcontent]\n if @selectcontent.nil? || @selectcontent.empty?\n @courses = Course.all.order(\"id ASC\").paginate(page: params[:page], per_page: 8)\n else\n @courses = Course.where(\" name LIKE '%#{@selectcontent}%' \").all.paginate(page: params[:page], per_page: 4)\n end\n\n end",
"def index\n @courses = Courses.all\n end",
"def all_courses\n [\n {\n id: 1,\n title: 'The Complete Node.js Developer Course',\n author: 'Andrew Mead, Rob Percival',\n description: 'Learn Node.js by building real-world applications with Node, Express, MongoDB, Mocha, and more!',\n topic: 'Node.js',\n url: 'https://codingthesmartway.com/courses/nodejs/'\n },\n {\n id: 2,\n title: 'Node.js, Express & MongoDB Dev to Deployment',\n author: 'Brad Traversy',\n description: 'Learn by example building & deploying real-world Node.js applications from absolute scratch',\n topic: 'Node.js',\n url: 'https://codingthesmartway.com/courses/nodejs-express-mongodb/'\n },\n {\n id: 3,\n title: 'JavaScript: Understanding The Weird Parts',\n author: 'Anthony Alicea',\n description: 'An advanced JavaScript course for everyone! Scope, closures, prototypes, this, build your own framework, and more.',\n topic: 'JavaScript',\n url: 'https://codingthesmartway.com/courses/understand-javascript/'\n }\n ]\n end",
"def get_courses\n\t\tif current_student.id.to_i == params[:id].to_i\n\t\t\t@student = Student.find(params[:id])\n\t\t\t@evaluations = @student.evaluations\n\t\tend\n\t\trender 'get_courses'\n\tend",
"def show\n @courses = Course.select(:name, :course_id, :credits, :description, :course_type).distinct\n end",
"def index\n @courses = Course.all.paginate(:page => params[:page], :per_page => 10)\n end",
"def index\n @classcourses = Classcourse.all\n end",
"def get_courses_in_page(url)\n courses = []\n page = Nokogiri::HTML(open(url))\n course = ''\n section = ''\n department = url[url.rindex('=') + 1 ... url.length]\n \n page.css('td').each do |td|\n case td.content\n when /^#{department} \\d{3}.?$/\n course = td.content\n when /^\\d{3}$/\n section = td.content\n else \n end\n \n if !course.empty? && !section.empty?\n courses.push \"#{course}-#{section}\"\n course = ''\n section = ''\n end\n end\n \n return courses\n end",
"def index\n @courses = Array.new\n Rails.configuration.x.displayOptions.courseCategories.each do |cat|\n @courses.push(Course.where(\"college = ?\", cat).order(\"title ASC\"))\n end\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\n @courses = Course.all\n end",
"def index\r\n @courses = Course.all\r\n end",
"def index\n @ptcourses = Ptcourse.search(params[:search]) \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ptcourses }\n end\n end",
"def get_courses_by_property_by_regex(property, regex)\n puts \"[+] Searching for courses using regex: #{regex}\".yellow +\n + \" -- And property: #{property}\"\n courses_results = []\n results = get_all_courses\n results.each do |x|\n courses_results.push(x) unless (x[property] =~ regex).nil?\n end\n courses_results\n # returns array of all matching courses in JSON format.\nend",
"def index\n @courses = Course.all\n\n end",
"def list_active_courses_in_account(account_id,opts={})\n query_param_keys = [\n :with_enrollments,\n :published,\n :completed,\n :by_teachers,\n :by_subaccounts,\n :hide_enrollmentless_courses,\n :state,\n :enrollment_term_id,\n :search_term\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"account_id is required\" if account_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :account_id => account_id\n )\n\n # resource path\n path = path_replace(\"/v1/accounts/{account_id}/courses\",\n :account_id => account_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response.map {|response|Course.new(response)}\n end",
"def show_courses_on_waitlist\n Waitlist.where(student: self).order(:course_id).map(&:student)\n end",
"def courses\n item_courses = items.flat_map do |item|\n item.fetch('courses', []).map do |course|\n {\n course_name: course['name'],\n course_id: course['courseNumber'],\n instructors: Array(course['instructorNames']), # NOTE: we've seen cases where instructorNames is nil.\n reserve_desk: course['locationCode']\n }\n end\n end\n\n item_courses.uniq { |c| c[:course_id] }\n end",
"def course\n unless user_signed_in? && current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n \n $selected_course = Course.where({id: params[:id]}).first\n\n @course_projects = $selected_course.projects.collect{ |project|\n {\n project_name: project.name,\n team_names: project.teams.reduce(''){|names, team| names + team.name + ', '}[0..-3],\n due: project.due.in_time_zone('Eastern Time (US & Canada)').strftime('%Y-%m-%d %I:%M:%S %p')\n }\n }\n\n render :template => \"home/index\"\n end",
"def course_pages\n CoursePage.where('question_ids_str LIKE ?', \"%|#{id}|%\")\n end",
"def index\n @courses = Course.paginate(:page => params[:page], :per_page=>20)\n end",
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end",
"def courses\n course_list = []\n \n semesters.collect do |semester|\n course_list << semester.cis_courses\n end\n \n course_list << course_bin.cis_courses\n \n return course_list\n end",
"def search \n\t@courseCandidateArray = []\n\t# find all sections of the course given. Group sections which are split into few (if they have more than one instructor or more than 1 class time given, like lab and lecture different) together\n\t@arrayOfCourses = Course.where(\"course_number = '\" + params[:searchCourse] + \"'\").group(:section_number)\n\[email protected]{|currentCourse|\n\t\t# create multisection variable, which will account for sections split as above\n\t\t@multiSection = Course.where(\"course_number = '\" + currentCourse[:course_number].to_s + \"' AND section_number = '\" + currentCourse[:section_number].to_s + \"'\")\n\t\t# find all students who applied for the course, then filter only those who fit section times\n\t\t@applicantsFit = Application.where(\"course_number LIKE '%\" + currentCourse[:course_number].to_s + \"%'\")\n\t\t@applicantsFit = @applicantsFit.reject{|applicant|\n\t\t\t@ans = false\n\t\t\[email protected] { |current|\n\t\t\t\t@ans = @ans || scheduleConflict(current, applicant)\n \t\t\t}\n \t\t\t@ans\n\t\t}\n\t# remove current TA from the list (if any) because he is handled separately\n\t@courseToUpd = TeachingAssistant.where(\"course_number LIKE \" + currentCourse[:course_number].to_s + \" AND section_number LIKE \" + currentCourse[:section_number].to_s)\n\tif (@courseToUpd.length > 0)\n\t\t@applicantsFit = @applicantsFit.reject{|applicant| applicant[:user_id] == @courseToUpd[0][:user_id] }\n\n\tend\n\t# sort, so that students with recommendations come first\n\t@applicantsFit = @applicantsFit.sort_by{|a| \n\t\t@b = User.where(\"id = '\" + a[:user_id].to_s + \"'\")\n\t\thasRecommendation(currentCourse[:course_number], @b[0][:fname], @b[0][:lname]) ? 0:1}\n\[email protected]([@applicantsFit, currentCourse])}\nend",
"def index\n if (params[:query])\n @courses = Course.full_course_search(params[:query]).listed.page(params[:page]).per_page(10)\n else \n @courses = Course.listed.paginate(:page => params[:page], :per_page => 10).order(\"created_at desc\")\n end\n @followers = Course.get_number_people_following_published_courses\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end",
"def index\n @students = Student.where(:course_id => params[:course_id])\n end",
"def scrape_courses()\n\n\t\t# if (@authenticated != true)\n\t\t# \tauthenticate\n\t\t# end\n\n\t\tauthenticate\n\t\t# error_counter = 0\n\n\t\t@subjects = Subject.all\n \t@careers = [Career.all[16]]\n\n \[email protected] { |row1|\n \t\tputs row1.career\n\t\t\[email protected] { |row2|\n\t\t\t\tdoc = @agent.get('https://ses.ent.northwestern.edu/psc/caesar_6/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.CLASS_SEARCH.GBL?Page=SSR_CLSRCH_ENTRY').parser\n\t\t\t\ticsid = doc.xpath(\"//*[@id='ICSID']/@value\").text\n\t\t\t\ticelementnum = doc.xpath(\"//*[@id='ICElementNum']/@value\").text\n\t\t\t\ticstatenum = doc.xpath(\"//*[@id='ICStateNum']/@value\").text\n\n\t\t\t\tinstitution = \"NWUNV\"\n\t\t\t\tcareer = row1.career\n\t\t\t\tsubject = row2.subject\n\t\t\t\tmatch_type = \"E\"\n\t\t\t\tinclude_class_days = \"J\"\n\t\t\t\topen_course_only = \"N\"\n\t\t\t\tterm = \"4530\" # 2014 Winter\n\n\t\t\t\tajax_headers = { 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8' }\n\t\t\t\tparams = {\n\t\t\t\t\t\"ICAction\" => \"CLASS_SRCH_WRK2_SSR_PB_CLASS_SRCH\",\n\t\t\t\t\t\"ICSID\" => icsid,\n\t\t\t\t\t\"ICElementNum\" => icelementnum,\n\t\t\t\t\t\"ICStateNum\" => icstatenum,\n\t\t\t\t\t\"DERIVED_SSTSNAV_SSTS_MAIN_GOTO$180$\" => \"9999\",\n\t\t\t\t\t\"CLASS_SRCH_WRK2_INSTITUTION$41$\" => institution,\n\t\t\t\t\t\"CLASS_SRCH_WRK2_STRM$44$\"=> term,\n\t\t\t\t\t\"SSR_CLSRCH_WRK_SUBJECT$0\"=> subject,\n\t\t\t\t\t\"SSR_CLSRCH_WRK_CATALOG_NBR$1\" => \"\",\n\t\t\t\t\t\"SSR_CLSRCH_WRK_SSR_EXACT_MATCH1$1\" => match_type,\n\t\t\t\t\t\"SSR_CLSRCH_WRK_ACAD_CAREER$2\" => career,\n\t\t\t\t\t\"SSR_CLSRCH_WRK_SSR_OPEN_ONLY$chk$3\" => open_course_only,\n\t\t\t\t\t\"DERIVED_SSTSNAV_SSTS_MAIN_GOTO$152$\"=>\"9999\",\n\t\t\t\t}\n\n\t\t\t\tif subject.include? (\"BIOL_SCI\")\n\t\t\t\t\tparams_bio = {\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_INCLUDE_CLASS_DAYS\"=>include_class_days,\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_MON$chk\"=>\"Y\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_MON\"=>\"Y\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_TUES$chk\"=>\"Y\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_TUES\"=>\"Y\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_WED$chk\"=>\"Y\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_WED\"=>\"Y\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_THURS$chk\"=>\"Y\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_THURS\"=>\"Y\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_FRI$chk\"=>\"Y\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_FRI\"=>\"Y\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_SAT$chk\"=>\"\",\n\t\t\t\t\t\t\"CLASS_SRCH_WRK2_SUN$chk\"=>\"\"\t\t\t\t\n\t\t\t\t\t}\n\n\t\t\t\t\tparams = params.merge params_bio\n\t\t\t\tend\n\n\t\t\t\tresponse = @agent.post('https://ses.ent.northwestern.edu/psc/caesar_4/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.CLASS_SEARCH.GBL', params, ajax_headers)\n\t\t\t\tdoc = Nokogiri::HTML(response.body)\n\n\t\t\t\terror = doc.search(\"span[id^='DERIVED_CLSMSG_ERROR_TEXT']/text()\")\n\t\t\t\tcourses = doc.search(\"span[id^='DERIVED_CLSRCH_DESCR200$']/text()\").to_a\n\n\t\t\t\tputs courses\n\n\t\t\t\tpartsCounter1 = 0\n\t\t\t\tpartsCounter2 = 0\n\n\t \t\tif (error.empty?)\n\n\t\t\t\t\tcourses.each_with_index { |x,i| \n\t\t\t\t\t\tcourses[i] = CGI.unescapeHTML(courses[i].to_s).delete!(\"^\\u{0000}-\\u{007F}\")\n\t\t\t\t\t\tcourses[i] =~ /(^\\w+)(\\s+)(\\d+-\\d+) - (.*)/\n\t\t\t\t\t\tdepartment = $1\n\t\t \t\tnumber = $3\n\t\t \t\ttitle = $4\n\t\t\t\t\t\tparts = doc.search(\"div[id='win6div$ICField242GP$\" + i.to_s + \"'] > span[class='PSGRIDCOUNTER']/text()\").to_s.gsub(/1.*of\\s/, \"\").to_i\n\t\t\t\t\t\tcheckEdgeCase = doc.search(\"div[id='win6divSSR_CLSRCH_MTG1$\" + partsCounter1.to_s + \"'] > table > tr\")\n\n\t\t \t\t\t\tif (checkEdgeCase.length > 2)\n\t\t \t\t\t\t\tparts.times { |x|\n\t\t\t \t\t\t\t\tputs \"\"\n\t\t\t \t\t\t\t\tputs \"ERROR EDGE CASE #{partsCounter1.to_s} #{department} #{number}\"\n\t\t\t \t\t\t\t\tputs \"--------------#{department} #{number} has #{parts} parts\"\n\t\t\t \t\t\t\t\tputs \"lalala\"\n\t\t\t \t\t\t\t\tputs \"\"\n\t\t\t \t\t\t\t\tpartsCounter1 += checkEdgeCase.length - 1\n\t\t\t \t\t\t\t\tpartsCounter2 += 1\n\t\t\t \t\t\t\t}\n\t\t\t \t\t\t\tnext\n\t\t \t\t\t\tend\n\n\t\t\t\t\t\tputs \"--------------#{department} #{number} has #{parts} parts\"\n\n\t\t\t\t\t\tparts.times { |x|\n\t\t\t\t\t\t\tuniqueid_sec = doc.search(\"a[id='DERIVED_CLSRCH_SSR_CLASSNAME_LONG$\" + partsCounter2.to_s + \"']\").text\n\t\t\t\t\t\t\tuniqueid_sec =~ /(\\w+)-(\\w+)\\((\\d+)\\)/\n\t\t\t\t\t\t\tsection = $1\n\t\t \t\t\tlecdisc = $2\n\t\t \t\t\tunique_id = $3\n\n\t\t \t\tdays_time = doc.search(\"span[id='MTG_DAYTIME$\" + partsCounter1.to_s + \"']\").text\n\n\t\t \t\tif (days_time != \"TBA\")\n\t\t\t\t\t\t\t\tdays_time =~ /^(\\w+) (\\d\\d?:\\d\\d(AM|PM)) - (\\d\\d?:\\d\\d(AM|PM))/\n\t\t\t\t\t\t\t\tdays = $1\n\t\t\t\t\t\t\t\tstart_time = $2\n\t\t\t\t\t\t\t\tend_time = $4\n\t\t \t\telse\n\t\t\t\t\t\t\t\tdays = \"TBA\"\n\t\t\t\t\t\t\t\tstart_time = \"TBA\"\n\t\t\t\t\t\t\t\tend_time = \"TBA\"\n\t\t\t\t\t\t\tend\n\n\t\t \t\t\troom = doc.search(\"span[id='MTG_ROOM$\" + partsCounter1.to_s + \"']\").text\n\t\t \t\t\tinstructor = doc.search(\"span[id='MTG_INSTR$\" + partsCounter1.to_s + \"']\").text\n\t\t \t\t\tdates = doc.search(\"span[id='MTG_TOPIC$\" + partsCounter1.to_s + \"']\").text\n\t\t \t\t\tseats = doc.search(\"span[id='NW_DERIVED_SS3_AVAILABLE_SEATS$\" + partsCounter1.to_s + \"']\").text\n\t\t \t\t\tstatus = doc.search(\"div[id='win6divDERIVED_CLSRCH_SSR_STATUS_LONG$\" + partsCounter2.to_s + \"'] > div > img\")[0]['alt']\n\n\t\t\t\t\t\t\t# http://stackoverflow.com/questions/452859/inserting-multiple-rows-in-a-single-sql-query\n\t\t \t\t# course_list.insert(:uniqueid => uniqueid, :dept => department, :course => course, :sec => sec, :title => title, :days => days, :start_time => start_time, :end_time => end_time, :room => room, :instructor => instructor, :seats => seats, :status => status, :datescraped => datescraped)\n\t\t \n\t\t \t\tif (days != nil)\n\t\t \t\t\tmo = days.include? (\"Mo\")\n\t\t \t\t\ttu = days.include? (\"Tu\")\n\t\t\t\t \twe = days.include? (\"We\")\n\t\t\t\t \tth = days.include? (\"Th\")\n\t\t\t\t \tfr = days.include? (\"Fr\")\n\t\t\t\t else\n\t\t\t\t \tmo = false\n\t\t\t\t \ttu = false\n\t\t\t\t \twe = false\n\t\t\t\t \tth = false\n\t\t\t\t \tfr = false\n\t\t\t\t end\n\n\t\t \t\tputs \"#{subject} #{number} #{title} #{lecdisc} #{instructor} #{days} #{start_time} #{end_time} #{partsCounter1}\"\n\n\t\t \t\tcourse = Course.find_or_create_by_unique_id(unique_id) { |c|\n\t\t \t\t\tc.term = term\n\t\t\t\t \tc.subject = subject\n\t\t\t\t \tc.number = number\n\t\t\t\t \tc.section = section\n\t\t\t\t \tc.title = title\n\t\t\t\t \tc.M = mo ? 1 : 0\n\t\t\t\t \tc.T = tu ? 1 : 0\n\t\t\t\t \tc.W = we ? 1 : 0\n\t\t\t\t \tc.R = th ? 1 : 0\n\t\t\t\t \tc.F = fr ? 1 : 0\n\t\t\t\t \tc.start = start_time\n\t\t\t\t \tc.end = end_time\n\t\t\t\t \tc.room = room\n\t\t\t\t \tc.instructor = instructor\n\t\t\t\t \tc.seats = seats\n\t\t\t\t \tc.lecdisc = lecdisc\n\t\t\t\t \tc.status = status\n\t\t \t\t}\n\n\t\t \t\t\tpartsCounter1+=1\n\t\t \t\t\tpartsCounter2+=1\n\t\t \t\t} # end parts.times\n\n\t \t\t} # end courses.each_with_index\n\n\t\t\t\telse\n\t\t\t\t\terror = error.to_s\n\t\t\t\t\terror = error.gsub(\"The search returns no results that match the criteria specified.\", \"No courses this quarter.\")\n\t\t\t\t\terror = error.gsub(\"Your search will exceed the maximum limit of 200 sections. Specify additional criteria to continue.\", \"Exceeds maximum limit.\")\n\t\t\t\t\t# error_counter+=1\n\t\t\t\t\t# print \"[\" + error_counter.to_s + \"] \" + subject + \": \"\n\t\t\t\t\t\n\t\t\t\t\tprint subject + \": \"\n\t\t\t\t\tif (error.include? \"No courses this quarter.\")\n\t\t\t\t\t\tputs error\n\t\t\t\t\telsif (error.include? \"Exceeds maximum limit.\")\n\t\t\t\t\t\tputs error#.yellow\n\t\t\t\t\telse\n\t\t\t\t\t\tputs error#.red\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t} # end subjects.each\n\t\t} #end careers.each\n\n\n\tend",
"def index\n @path_courses = PathCourse.all\n end",
"def index\n @standard_categories = StandardCategory.where course:@course\n end",
"def index\n\t #authorize! :manage, Course\n @courses = Course.all\n \n @courses_by_year_and_semester = {}\n #TODO: add field limit(...) to this query\n CourseInstance.all.each do |course|\n @courses_by_year_and_semester[course.delivered_year] ||= {}\n @courses_by_year_and_semester[course.delivered_year][course.level] ||= {}\n @courses_by_year_and_semester[course.delivered_year][course.level][course.semester] ||= []\n @courses_by_year_and_semester[course.delivered_year][course.level][course.semester] << course\n end\n\n @courses_by_magic = {}\n # @courses_by_magic[course.year][course.semester][course] = [delivered_year, delivered_year]\n CourseInstance.all.each do |course|\n @courses_by_magic[course.level] ||= {}\n @courses_by_magic[course.level][course.semester] ||= {}\n @courses_by_magic[course.level][course.semester][course.short_code] ||= []\n @courses_by_magic[course.level][course.semester][course.short_code] << course.delivered_year\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @courses }\n format.js { \n render :json => Course.search_as_you_type(params[:term]) \n }\n end\n end",
"def get_courses_by_code(org_unit_code)\n all_courses = get_all_courses\n courses = []\n all_courses.each do |course|\n courses.push(course) if course[\"Code\"].downcase.include? org_unit_code.to_s.downcase\n end\n courses\nend",
"def course\n if validateurl({\"name\": params[:name], \"semester\": params[:semester], \"coursename\": params[:course]})\n @semester = params[:semester]\n @coursename = params[:course]\n courseid = Course.select(\"id\").where(\"name = '\" + @coursename + \"' AND semester = '\" + @semester + \"'\" ).ids[0].to_s\n @students = ActiveRecord::Base.connection.execute(\"SELECT grades.grade, students.name FROM grades, students WHERE '\" + courseid.to_s + \"' = grades.course_id AND '\" + @semester.to_s + \"' = grades.semester AND students.id = grades.student_id\")\n end\n end",
"def index \n @courses = Course.all\n puts 'Courses-Index -mashal is super helpful'\n end",
"def index\n @courts = Court.all\n end"
] | [
"0.7679417",
"0.7669443",
"0.759345",
"0.745616",
"0.715831",
"0.71459097",
"0.6973851",
"0.69128966",
"0.68473893",
"0.6808028",
"0.67894065",
"0.6744216",
"0.67375946",
"0.67330676",
"0.67150223",
"0.6703322",
"0.6679047",
"0.66788036",
"0.6674686",
"0.66684306",
"0.66562283",
"0.6621442",
"0.6619644",
"0.6617852",
"0.66026235",
"0.6547018",
"0.6538073",
"0.6516555",
"0.6515837",
"0.65073466",
"0.64938426",
"0.6474461",
"0.64677095",
"0.6461358",
"0.6458433",
"0.64429545",
"0.6439201",
"0.6390514",
"0.63840514",
"0.6383802",
"0.63806915",
"0.63771963",
"0.63631773",
"0.6361537",
"0.6355181",
"0.6353156",
"0.6329186",
"0.63264024",
"0.63071495",
"0.6296284",
"0.628976",
"0.628926",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6285172",
"0.6284145",
"0.62759745",
"0.62743336",
"0.62665623",
"0.62555933",
"0.62532645",
"0.62528867",
"0.6241201",
"0.6238785",
"0.6231535",
"0.6230687",
"0.6230551",
"0.62229294",
"0.6220103",
"0.62040675",
"0.6202191",
"0.61816597",
"0.6176548",
"0.6176265",
"0.6164888",
"0.6164527",
"0.61637276",
"0.61627126"
] | 0.7100484 | 6 |
save changes to database | def create
# find if there are any courses with both the same name and section number
duplicate_courses = Course.where(name: course_params[:name], section: course_params[:section])
# SQL Equivalent (in SQLite):
# SELECT "courses".* FROM "courses" WHERE "courses"."name" = ? AND "courses"."section" = ?
# where ? == name of course and section of course
if duplicate_courses.blank?
# else make a new course based on parameters passed from form
@course = Course.new(course_params)
# check validity and successful save
if @course.valid? && @course.save
# @course.save SQL Equivalent:
# INSERT INTO "courses"
# ("teacher_id", "deptName", "name", "section", "created_at", "updated_at")
# VALUES (?, ?, ?, ?, ?, ?);
# redirect
redirect_to '/admin/index'
return
else
# otherwise check the error
if @course.invalid?
flash[:fail] = "Unable to create course: #{@course.errors.full_messages}"
else
flash[:fail] = "Unable to create course for unknown reason. Try again!"
end
redirect_back(fallback_location: '/admin/index')
return
end
else
# sent an error
flash[:fail] = "There is already a course with that name and section!"
redirect_back(fallback_location: '/admin/index')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n end",
"def save\n end",
"def save\n end",
"def save\n SAVE\n end",
"def save\n end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save; end",
"def save\n\t\tend",
"def save\n #code\n end",
"def save\n end",
"def save\n end",
"def save\n\n end",
"def save!\n end",
"def save\n object.save\n end",
"def save; record.save; end",
"def save\n update({})\n end",
"def save\n super save\n end",
"def command_save\n if @dbChanged == true\n @database.save\n @dbChanged = false\n end\n if @logChanged == true\n @log.save\n @logChanged = false\n end\n end",
"def save\n perform_save\n end",
"def save\n self.save! rescue false\n end",
"def save\n create_or_update\n end",
"def save\n create_or_update\n end",
"def save\n create_or_update\n end",
"def save\n self.class.save(self)\n end",
"def save\n self.save! rescue false\n end",
"def save\n connection.save_table(self)\n end",
"def save\n values.save\n end",
"def save\n\t\[email protected]\n\tend",
"def save!\r\n throw \"Update of Tamino XML database failed.\" unless save\r\n end",
"def save_changed\n save changed: true\n end",
"def save\n self.new_record ? self.create : self.update\n end",
"def save\n new? ? insert : update\n end",
"def save!\n object.save!\n end",
"def save( defer=false )\n save_logic( defer ) \n end",
"def save\n\t\treturn false unless self.modified? || self.new?\n\t\tif self.new?\n\t\t\tself.insert\n\t\telse\n\t\t\tself.update\n\t\tend\n\tend",
"def save_and_apply\n self.save\n self.apply\n end",
"def update #saves and redirects, saves changes\n end",
"def commit\n update\n end",
"def commit; end",
"def commit; end",
"def commit; end",
"def save\n # Insert OR Update object values into DB\n # DB.execute(\"INSERT INTO .....\")\n # @id = DB.last_insert_row_id # get the last id from the DB\n # OR\n # DB.execute(\"UPDATE .....\")\n end",
"def save!(*)\n super.tap do\n changes_applied\n end\n end",
"def save\r\n do_without_exception(:save!)\r\n end",
"def save\n @data.map(&:save)\n end",
"def save\n if new_record?\n create\n else\n update\n end\n end",
"def save\n hash = self.attr_hash\n sql_hash = hash.to_s.delete \"\\>\"\n\n CONNECTION.execute(\"UPDATE '#{tablename}' SET #{sql_hash[1...-1]} WHERE id = ?;\", @id)\n \"Saved.\"\n end",
"def save()\n File.write(@database_file, @data.to_json)\n end",
"def save\n conn = Sandwich.open_connection\n\n if self.id\n #Update\n sql = \"UPDATE sandwich SET title='#{self.title}', description='#{self.description}' WHERE id=#{self.id}\"\n else\n #Add\n sql= \"INSERT INTO sandwich (title, description) VALUES ('#{self.title}','#{self.description}')\"\n end\n\n\n conn.exec(sql)\n end",
"def save\n @connection.transactions.save\n end",
"def save(*)\n create_or_update\n end",
"def save_changes\n save(:changed=>true) || false unless @changed_columns.empty?\n end",
"def save\n put_object\n true\n end",
"def save_if_changed(options = {})\n save if changed?\n end",
"def persist; end",
"def persist; end",
"def persist; end",
"def save\n run_callbacks :save do\n valid? && (create || update)\n end\n end",
"def save!(*)\n super.tap do\n changes_applied\n end\n end",
"def save!\n raise \"A database must be setted\" unless self.database\n response = id.nil? ? self.database.post( self ) : self.database.put( self )\n pristine_copy\n response\n end",
"def save_record(record)\n record.save\n end",
"def save_record(record)\n record.save\n end",
"def commit\n @db.commit\n end",
"def save_edits\n DATABASE.execute(\"UPDATE boards SET title = '#{@title}', description = '#{@description}' WHERE id = #{@id}\")\n end",
"def save()\n @env.sync(true)\n self\n end",
"def save\n\t\t\t\"save called - creating a new object.\"\n\t\tend",
"def commit\n db_interface.commit\n end",
"def commit!\n save! unless persisted?\n end",
"def save\n if persisted?\n update\n else\n create\n end\n true\n end",
"def save\n true\n end",
"def sync\n object.save\n end",
"def commit( defer=false )\n save_logic( defer, false )\n end",
"def save(*)\n call_hooks 'save' do\n # Existing object implies update in place\n action = 'add'\n set_auto_date_field 'created_at'\n if @new_record\n do_insert\n else\n do_update\n set_auto_date_field 'updated_at'\n action = 'update'\n end\n @new_record = false\n @dirty = false\n self.class.issue_notification(self, :action => action)\n end\n end",
"def save\n on_each_node :save\n end",
"def save()\n super\n end",
"def save()\n super\n end",
"def save()\n super\n end",
"def save()\n super\n end",
"def save()\n super\n end",
"def save_object\n end",
"def save\n raise NotImplementedError\n end",
"def save\n if modified? and @entries and [email protected]?\n save!\n end\n end",
"def save\n create_or_update\n end",
"def save\n CONNECTION.execute(\"UPDATE assignments SET general_info = '#{self.general_info}', github_link = '#{self.github_link}', co_workers = '#{self.co_workers}' WHERE id = #{self.id};\")\n end",
"def update!\n self.save\n end",
"def save_to_db(type)\n self.tag = type\n self.save!\n puts \"saving at url : #{self.file.url}\"\n puts \"saved\"\n end",
"def save\n write_properties\n notify(EVENT_SAVE, self)\n end",
"def save\n begin\n save!\n true\n rescue\n false\n end\n end",
"def save!\n raise \"#{self.inspect} failed to save\" unless self.save\n end",
"def update\n push_to_db\n end",
"def update\n push_to_db\n end",
"def save\n @saved = @state\n end",
"def persist\n \n end",
"def save\n if persisted?\n update\n else\n create\n end\n end",
"def save_save_list\n save_list.each do |obj|\n obj.save!\n end\n end"
] | [
"0.7938795",
"0.7938795",
"0.7902631",
"0.7891448",
"0.7865254",
"0.78510165",
"0.78510165",
"0.78510165",
"0.78510165",
"0.78510165",
"0.78510165",
"0.78510165",
"0.78510165",
"0.7776529",
"0.77655566",
"0.7734467",
"0.7734467",
"0.77161795",
"0.7664324",
"0.7421853",
"0.74117607",
"0.73858225",
"0.73045814",
"0.7298862",
"0.72853446",
"0.72160596",
"0.71862644",
"0.71862644",
"0.71862644",
"0.71844363",
"0.7174087",
"0.71198565",
"0.7076691",
"0.70718145",
"0.7068319",
"0.7010399",
"0.7008205",
"0.7006666",
"0.70024496",
"0.6995541",
"0.6966862",
"0.696162",
"0.6918755",
"0.69057196",
"0.68986696",
"0.68986696",
"0.68986696",
"0.6878798",
"0.68723845",
"0.68558884",
"0.6841534",
"0.6838488",
"0.68312746",
"0.68308514",
"0.68292254",
"0.68187046",
"0.68106365",
"0.6808778",
"0.68005186",
"0.6791832",
"0.67889744",
"0.67889744",
"0.67889744",
"0.6787121",
"0.6783723",
"0.6781552",
"0.6765589",
"0.6765589",
"0.6762958",
"0.6762675",
"0.6761924",
"0.6752827",
"0.6744655",
"0.6742542",
"0.6740686",
"0.6718454",
"0.67170304",
"0.6704746",
"0.6695327",
"0.66821617",
"0.66669434",
"0.66669434",
"0.66669434",
"0.66669434",
"0.66669434",
"0.6662348",
"0.6645949",
"0.6635667",
"0.6632564",
"0.6624343",
"0.6622897",
"0.66223323",
"0.66184086",
"0.6611799",
"0.66104525",
"0.6602",
"0.6602",
"0.6593248",
"0.6587274",
"0.65827274",
"0.65669113"
] | 0.0 | -1 |
helper function for validating parameters passed by course form | def course_params
params.require(:course).permit(:teacher_id, :course_number, :name, :deptName, :section, :submitted)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_params?; end",
"def validate_question params\n\n end",
"def validate_params(params)\n # This will be implemented by Validators which take parameters\n end",
"def validate_params\n validate_size\n validate_mine_density\n validate_first_click\n type_specific_checks\n end",
"def check_params; true; end",
"def validate_args(course, yoe_text)\n unless Config.read(\"courses\").has_key?(course)\n raise ArgumentError, %Q{Invalid course name \"#{course}\"}\n end\n\n yoe = yoe_text.to_i\n unless valid_years.include?(yoe)\n raise ArgumentError, %Q{Invalid year of entry \"#{yoe_text}\"}\n end\n end",
"def validate params\n validate_params(params)\n validate_coordinates\n validate_color\n validate_dimension\n end",
"def valid?(params)\n true\n end",
"def validate_params?\n true # TODO: add validation\n end",
"def validations\n valid_page_number? if page_number\n valid_period_name? if period_param\n valid_date? if date_param\n end",
"def validate_param(param)\n\t\t\terror = {}\n\t\t\tif param.form_structure_id == nil\n\t\t\t\terror[:formName] = \"Please specify\"\n\t\t\t\treturn error\n\t\t\tend\n\t\t\tform = FormStructure.find(param.form_structure_id)\n\t\t\tif form.nil?\n\t\t\t\terror[:formName] = \"Please specify\"\n\t\t\t\treturn error\n\t\t\tend\n\t\t\tif param.is_many_to_one_count\n\t\t\t\tvalidate_many_to_one_count(form, error, param)\n\t\t\telsif param.is_many_to_one_instance\n\t\t\t\tvalidate_many_to_one_instance(form, error, param)\n\t\t\telse\n\t\t\t\tvalidate_normal_question(error, param)\n\t\t\tend\n\n\t\tend",
"def validate_params\n if process_object && process_object[\"required_params\"]\n process_object[\"required_params\"].each do |param|\n if !params_hash.has_key?(param)\n errors.add(:params, \"Step: #{step} - Missing mandatory param #{param}\")\n end\n end\n end\n end",
"def valid_params_request?; end",
"def check_params\n true\n end",
"def valid_course\r\n\t\tif not Course.find_by(courseID: courseID)\r\n\t\t\terrors.add(:courseID, 'is not valid. Please enter a valid ID (8 characters)')\r\n\t\tend\r\n\tend",
"def validate\r\n\r\n end",
"def validate\n \n \n end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def validateParams \r\n\t \r\n\t \tif [email protected]? && [email protected]? && [email protected]?\r\n\t\t\treturn true\r\n\t \telse\r\n\t\t\treturn false \t\r\n\t \tend\r\n\t \t\r\n\t end",
"def validate_params(hash)\n hash.include?('title') and hash.include?('body') and hash.include?('category')\n end",
"def validate params\n validate_params(params)\n validate_dimension\n end",
"def grad_params\n params.require(:courses)\n end",
"def valid_for_params_auth?; end",
"def check_multiple_courses\n \n end",
"def validate_create_params!(params); end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def check_title_and_description(params)\n if params[:title] == nil\n @errors << \"Title can't be empty\"\n end\n if params[:description] == nil\n @errors << \"You need to add description\"\n elsif params[:description].length < 20\n @errors << \"description can't be less than 20 characters\"\n end\nend",
"def course_params\n params[:course]\n end",
"def validate\n validate_params\n validate_colour\n validate_coordinates\n validate_dimension\n end",
"def validate_parameters\n check_for_valid_filepath if (@repository.parameters[:file])\n\n check_number_of_parameters(:coord, 2)\n check_number_of_parameters(:delta, 2)\n check_number_of_parameters(:time, 2)\n check_number_of_parameters(:range, 2)\n check_number_of_parameters(:section, 2)\n end",
"def validate(params)\n val_errors = []\n params.each do |param, value|\n val_errors << \"missing params #{param}\" if value.blank?\n end\n yield(val_errors) if block_given? && val_errors.blank?\n val_errors.compact\n end",
"def validate_params\n @calls << [:validate_params]\n end",
"def validate!; end",
"def validate!; end",
"def validate!; end",
"def validate\n\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate\n validate_params\n validate_coordinates\n validate_colour\n validate_dimension\n end",
"def validate_paramters\n raise Scorekeeper::MissingParameterException if @income.nil? || @zipcode.nil? || @age.nil?\n end",
"def validation; end",
"def validation; end",
"def verify_params\n Validate::params_match @func, @current_param\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def check_required_params\n errors = required_params.map { |param, value| raise param_errors[param] if value.nil? }.compact\n raise errors.joins('; ') unless errors.empty?\n end",
"def validate!\n # pass\n end",
"def validate\n missing_parameters = []\n required_fields.each do |param|\n missing_parameters << param.to_s unless self.send(param)\n end\n raise RTurk::MissingParameters, \"Parameters: '#{missing_parameters.join(', ')}'\" unless missing_parameters.empty?\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate\n end",
"def validate_params!\n self.params ||= Hash.new\n self.class.instance_variable_get(:@__required_params).each do |e|\n raise ArgumentError, \"Insufficient parameters set (#{e} not supplied)\" if self.params[e].nil?\n end\n end",
"def completely_valid?\n course_valid = course.valid?\n valid? && course_valid\n end",
"def submit(params)\n preload_fields_with(params)\n\n if completely_valid?\n course.save!\n true\n else\n promote_errors(course.errors)\n false\n end\n end",
"def check_course_data_validity(course_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Name Code CourseTemplateId SemesterId\n StartDate EndDate LocaleId ForceLocale\n ShowAddressBook),\n 'properties' => {\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'CourseTemplateId' => { 'type' => 'integer' },\n 'SemesterId' => { 'type' => %w(integer null) },\n 'StartDate' => { 'type' => %w(string null) },\n 'EndDate' => { 'type' => %w(string null) },\n 'LocaleId' => { 'type' => %w(integer null) },\n 'ForceLocale' => { 'type' => 'boolean' },\n 'ShowAddressBook' => { 'type' => 'boolean' }\n }\n }\n JSON::Validator.validate!(schema, course_data, validate_schema: true)\nend",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def validate?(params)\n _validate?(params)\n end",
"def course_params\n params.require(:course).permit(:number, :title, :description, :instructor, :start_date, :end_date, :status, :material)\n end",
"def is_valid; end",
"def validate_params_present!\n raise ArgumentError, \"Please provide one or more of: #{ACCEPTED_PARAMS}\" if params.blank?\n end",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate_course_access(course_id)\n logger.info 'validating ' + course_id.to_s\n validation_success = false\n courses = get_ids(get_all_courses_for_user)\n logger.info 'courses are' + courses.inspect\n validation_success = courses.include?(Integer(course_id))\n if validation_success == false\n redirect_to (GyanV1::Application.config.landing_page.to_s)\n end\n\n end",
"def course_params\n params.require(:course).permit(:allowed_time_gap, :description, :end_date, :passing_grade, :start_date, :title)\n end",
"def validate\n end",
"def validate\n end",
"def validate\n end",
"def is_valid?\n end",
"def valid?(_) true end",
"def valid?(_) true end",
"def validate(*args, **kargs)\n end",
"def validate\n ModelHelper::Validations.validate_combos([{:grade_code => self.grade_code}],self,true) \n \n end",
"def check_params *required\n required.each{|p|\n params[p].strip! if params[p] and params[p].is_a? String\n if !params[p] or (p.is_a? String and params[p].length == 0)\n return false\n end\n }\n true\nend",
"def check_params *required\n required.each{|p|\n params[p].strip! if params[p] and params[p].is_a? String\n if !params[p] or (p.is_a? String and params[p].length == 0)\n return false\n end\n }\n true\nend",
"def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end",
"def validate_params\n if params[:location].empty? || params[:vintage].empty?\n flash[:error] = 'Please enter both a Location and a Vintage.'\n redirect_to discover_index_path\n end\n end",
"def course_params\n #params.require(:course).permit(:name, :hours, :prereq)\n end",
"def is_valid\n\tend",
"def is_valid\n\tend",
"def validate(options); end",
"def validate_params\n if lat.blank? || lng.blank? || property_type.blank? || offer_type.blank?\n @properties = []\n @message = \"Looks like some search parameters are missing!\"\n fail!(:validation_failed) && abort!\n end\n end",
"def validate_essential_attributes #:nodoc:\n if @month.to_i.zero? || @year.to_i.zero?\n errors.add :month, \"is required\" if @month.to_i.zero?\n errors.add :year, \"is required\" if @year.to_i.zero?\n else\n errors.add :month, \"is not a valid month\" unless valid_month?(@month)\n errors.add 'card', \"has expired\" if expired?\n errors.add :year, \"is not a valid year\" unless valid_expiry_year?(@year)\n end\n end",
"def valid_edit_entry_reqs\n if !params[:edit_entry_req].nil?\n edit_reqs_vals = params[:edit_entry_req].values\n edit_reqs_vals.each_slice(3) do |grade, info, remove|\n if grade.empty?\n return false\n end\n end\n end\n return true\n end",
"def course_params\n params.require(:course).permit(:course_number, :title, :description, :start_date, :end_date, :is_active, :notifications, :deadlines)\n end",
"def valid?(*_, **__)\n true\n end",
"def validate(args = {})\n end",
"def course_params\n params.require(:course).permit(:name, :number, :section_id)\n end",
"def validate_params(params)\n errors = []\n errors << if params.key?('asking_price') && params.key?('down_payment')\n validate(asking_price: params['asking_price'], down_payment: params['down_payment']) do |val_errors|\n val_errors << validate_minimum_down_payment(params['asking_price'], params['down_payment'])\n end\n end\n\n errors << if params.key?('payment_schedule')\n validate(payment_schedule: params['payment_schedule']) do |val_errors|\n val_errors << validate_payment_schedule_types(params['payment_schedule'])\n end\n end\n\n errors << if params.key?('amortization_period')\n validate(amortization_period: params['amortization_period']) do |val_errors|\n val_errors << validate_amortization_period(params['amortization_period'])\n end\n end\n\n errors << if params.key?('payment_amount')\n validate(payment_amount: params['payment_amount'])\n end\n\n errors << if params.key?('interest_rate')\n validate(interest_rate: params['interest_rate'])\n end\n\n errors = errors.flatten.compact\n errors.blank? ? [] : \"Validation failed: #{errors.join(', ')}\"\n end",
"def validate_args (args)\n\t# todo\nend",
"def validate\n#\tfirst check whether combo fields have been selected\n is_valid = true\n end",
"def validate\n#\tfirst check whether combo fields have been selected\n is_valid = true\n end",
"def validate_params\n\n categories.each() do |key, value|\n throw RuntimeError.new(\"ERROR: category '#{key}' contains more than #{maximum_numbers_per_category} parameters. Reduce parameter count.\") if value.size >maximum_numbers_per_category\n end\n\n keys=[]\n numbers=[]\n # slicer contains parameter with number 0... therefore valid parameter numbers starts at 0\n valid_param_numbers=SetupConfiguration.parameter_range()\n\n self.parameters().each() do |p|\n\n $stderr.puts \"WARNING: parameter number 404 is reserved for machine type. you are using it for '#{p.key}'.\" if p.number.eql?(404)\n throw RuntimeError.new(\"ERROR: parameter number '#{p.number}' not supported. Number must be in range #{valid_param_numbers}.\") unless valid_param_numbers.member?(p.number)\n\n if p.param?\n if keys.include? p.key\n raise RuntimeError.new(\"ERROR: parameter key '#{p.key}' defined more than once\")\n else\n keys << p.key\n end\n\n\n if numbers.include? p.number\n raise RuntimeError.new(\"ERROR: parameter number '#{p.number}' defined more than once\")\n else\n numbers << p.number\n end\n else\n assign_param_ref(p)\n end#p.param?\n\n end\n #force fresh sort of parameters\n @parameters = nil\n end",
"def get_course_params\n course_params = params.require(:course)\n if !empty_new_end_qual\n course_params = course_params.except(:end_qualification_id)\n end\n if !empty_new_del_mode\n course_params = course_params.except(:delivery_mode_id)\n end\n return course_params.permit!\n end",
"def course_params\n params.require(:course).permit(:course_name, :cq1, :cq2, :cq3, :cq4, :cq5, :cq6, :cq7, :cq8, :cq9, :cq10, :gq1, :gq2, :gq3, :gq4, :gq5, :gq6, :gq7, :gq8, :gq9, :gq10, :gq11, :gq12, :gq13, :gq14, :gq15, :gq16, :gq17, :gq18, :gq19, :gq20, :gw1, :gw2, :gw3, :gw4, :gw5, :gw6, :gw7, :gw8, :gw9, :gw10, :gw11, :gw12, :gw13, :gw14, :gw15, :gw16, :gw17, :gw18, :gw19, :gw20)\n end",
"def is_valid(params)\n i = 0\n while params.length > i\n p params[i]\n if params[i] == nil || params[i] == \"\"\n session[:error] = \"Du missade en parameter! Försök igen.\"\n redirect('/error')\n end\n i += 1\n end\n end",
"def validate\n # first check whether combo fields have been selected\n is_valid = true\n end"
] | [
"0.73239416",
"0.7180958",
"0.70730954",
"0.7015546",
"0.6887508",
"0.6859432",
"0.67120916",
"0.67049825",
"0.6690377",
"0.66890925",
"0.6595403",
"0.6590227",
"0.6569277",
"0.65507567",
"0.6520472",
"0.65196097",
"0.6513065",
"0.6449599",
"0.6449599",
"0.6449599",
"0.6449599",
"0.6437958",
"0.64330363",
"0.6399591",
"0.6395187",
"0.634649",
"0.6342998",
"0.6335574",
"0.6334307",
"0.6334307",
"0.6334307",
"0.6319445",
"0.63148195",
"0.6311477",
"0.6303727",
"0.6292875",
"0.6290322",
"0.6287999",
"0.6287999",
"0.6287999",
"0.6271584",
"0.62666154",
"0.62653536",
"0.62619925",
"0.62619543",
"0.62565184",
"0.62565184",
"0.624832",
"0.6241076",
"0.6238585",
"0.62320584",
"0.6230852",
"0.6222845",
"0.62178195",
"0.6214863",
"0.62104696",
"0.62092596",
"0.6198678",
"0.6189409",
"0.6189409",
"0.6184422",
"0.61830884",
"0.6175533",
"0.61699873",
"0.61678654",
"0.61663854",
"0.6163275",
"0.615973",
"0.6137779",
"0.6137779",
"0.6137779",
"0.6134956",
"0.6131093",
"0.6131093",
"0.613089",
"0.6130373",
"0.61219716",
"0.6121667",
"0.61201745",
"0.61177313",
"0.6117071",
"0.6107441",
"0.6107441",
"0.61073434",
"0.6093214",
"0.6079485",
"0.60646546",
"0.606386",
"0.6050776",
"0.6048906",
"0.6044621",
"0.6043842",
"0.6042191",
"0.6036847",
"0.6036847",
"0.60366446",
"0.6026541",
"0.6022525",
"0.601451",
"0.6010594"
] | 0.6056935 | 88 |
has_audited_state_through :hmd_states, [:announced, :devkit, :released] | def has_audited_state_through(table, states, options={})
class_attribute :audited_state_table
self.audited_state_table = table
has_many table # has_many :hmd_states
class_attribute :audited_states
self.audited_states = states
send :include, AuditedClassInstanceMethods
attr_accessor :audited_state
# custom validations
validate :validates_audited_state_with_exception
# life-cycle hooks
after_save :create_audited_state_record
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_audited_state_for(model, options = {})\n\n belongs_to model, touch: true\n\n # validations & double checks\n # make sure that these attributes are present\n validates :hmd_id, presence: true\n validates :state, presence: true\n end",
"def skill_state_on(id)\n if Skill_State_On[id]['include'] != nil\n for i in Skill_State[id]['include']\n return true if @state.include?(i)\n end\n end\n if Skill_State[id]['set'] != nil\n for i in Skill_State[id]['set']\n return false unless @state.include?(i)\n end\n return true\n end\n return false\n end",
"def known_states; end",
"def known_states; end",
"def known_states; end",
"def states; @_hegemon_states.keys; end",
"def has_state?\n [email protected]?\n end",
"def states; end",
"def states\n\t[:shelf,:in_use,:borrowed,:misplaced,:lost]\nend",
"def has_lifecycle?\n true\n end",
"def has_state?(v)\n@state[v]\nend",
"def skill_state_off(id)\n if Skill_State_On[id]['include'] != nil\n for i in Skill_State[id]['include']\n return false if @state.include?(i)\n end\n end\n if Skill_State[id]['set'] != nil\n for i in Skill_State[id]['set']\n return true unless @state.include?(i)\n end\n return false\n end\n return true\n end",
"def on?\n state[\"on\"]\n end",
"def past_step_2?\n !spectator? && status_is_active?(\"events\")\n end",
"def check_state\n EM.stop if @setup.report_state.content =~ /operational|stranded/\n end",
"def audited?\n @audited\n end",
"def state?\n usa?\n end",
"def won?\n @state.id == 14\n end",
"def define_state_predicate; end",
"def on_bees?\n state == 'bees'\n end",
"def state?(state)\n @states.key?(state)\n end",
"def audit_state\n \n return SELF_AUDIT unless self.designer_complete?\n return PEER_AUDIT unless self.auditor_complete?\n return AUDIT_COMPLETE\n\n end",
"def has_lifecycle?\n false\n end",
"def reportable?\n enable_learner_state\n end",
"def accessible\n has_toggles\n end",
"def being_observed?(observable)\n states.contain?(observable.object_id)\n end",
"def has_been_mandated?\n !!accessors.find(:first, :conditions => [\"accesses.requestor_id = ? AND mandated IN (?)\", person.id, ['1'] + MANDATED_STATES])\n end",
"def aasm_states_to_check\n created? ||\n (planned? && !aasm_state_changed? ) || # exclude validation on transition from created to planned\n started? ||\n ignore_states\n end",
"def available_states\n states = []\n states << :passive if passive?\n states << :pending if passive? || pending?\n states << :active\n states << :suspended unless deleted?\n states << :deleted\n states\n end",
"def available_transitions_from(state)\n find_all_transitions(:from_state => state)\n end",
"def has_state?(v)\n @state[v]\n end",
"def has_state?(v)\n @state[v]\n end",
"def aasm_states_to_check\n started? || aasm_event == 'start' || ignore_states\n end",
"def states\n []\n end",
"def states\n []\n end",
"def recently_walked?(transition); end",
"def states\n raise \"You must override the states method.\"\n end",
"def event?(state)\n @events.key?(state)\n end",
"def can_walk_to?(transition); end",
"def trackable?\n published?\n end",
"def enemy_has_state?(id, s_id)\n # get enemies\n enemies = get_enemies(id)\n # return result\n return (enemies.any? {|e| e.states.include?(s_id)})\n end",
"def ready?\n # TODO: Not sure if this is the only state we should be matching.\n state == \"Detached\"\n end",
"def update_state(*flags)\n return false unless @_hegemon_states[@_hegemon_state]\n trans = @_hegemon_states[@_hegemon_state].transitions\n trans = trans.select{|k,t| t.auto_update} if (flags.include? :only_auto)\n trans.each {|k,t| return true if t.try}\n false end",
"def state\n self.well_info.state\n end",
"def on_state_timeup(state_id)\n end",
"def advanced_state?\n @advanced_state.present?\n end",
"def on_hold?\n status == :inactive\n end",
"def changed?\n self.event_state.include? :changed\n end",
"def game_state\n end",
"def to?( state )\n target_names.include?( state.to_sym )\n end",
"def skill_sw_on(id)\n if Skill_Sw_On[id]['include'] != nil\n for i in Skill_Sw_On[id]['include']\n return true if $game_switches[i]\n end\n end\n if Skill_Sw_On[id]['set'] != nil\n for i in Skill_Sw_On[id]['set']\n return false unless $game_switches[i]\n end\n return true\n end\n return false \n end",
"def state?(name)\n @states.include?(name.to_sym)\n end",
"def dampening_state\n !dampening.nil?\n end",
"def has_own_bed?\n false\n end",
"def event_running?\n @battle_event.active?\n end",
"def is_state?(name)\n @state.include?(name)\n end",
"def lights_on?\n @lights\n end",
"def held?\n status == 'Held'\n end",
"def held?\n status == 'Held'\n end",
"def can_fire?(current_state)\n if from.is_a?(Array)\n from.include?(current_state.to_sym)\n elsif from == :__statum_any_state\n true\n else\n from == current_state.to_sym\n end\n end",
"def create_audited_state_record\n # e.g. @hmd.hmd_states.create!(state: self.state)\n self.send(self.class.audited_state_table).create!(state: self.audited_state)\n end",
"def manifestable_state?\n return true unless manages_state?\n workflow_class.manifest_states.include? Array.wrap(state).first.underscore\n end",
"def set_published_state\n self.published = payload[\"isLivingLegend\"]\n end",
"def doctor(_kitchen_state)\n false\n end",
"def states\n no_set_states + set_bonuses\n end",
"def has_hands\n return @hands.select{|hands| hands.status == HandStatus::PLAY} != []\n end",
"def get_state\[email protected]\nend",
"def is_alive\n @state == ALIVE\n end",
"def phases\n lifecycle.phases \n end",
"def on?; self.refresh!['state']['on']; end",
"def estimable?\n story_type == 'feature' && !estimated?\n end",
"def available_transitions\n status_available = respond_to?(:status) && status!=nil\n return {:allow => []} unless status_available\n self.class.states[self.status.to_sym] || {:allow => []}\n end",
"def livedns?\n current == :livedns\n end",
"def dead?\n @state == :dead\n end",
"def has_state?\n !!current_state\n end",
"def processing_hub_24h?\n (dhs_pending? || ssa_pending?) && (workflow_state_transitions.first.transition_at + 24.hours) > DateTime.now\n end",
"def state_active?(state)\n @states[state][1]\n end",
"def states\n @states ||= {}\n end",
"def state\n end",
"def collins_check_can_be_altered?\n collins_osc_state['current_state'] == \"can_be_altered\"\n end",
"def runtime_state?(sym); @runtime_states.include?(sym) end",
"def lightsOn?\n return @lightsOn\n end",
"def game_states_for_connection\n GameController.connection_to_games[self.object_id].player_states rescue {}\n end",
"def victory_phase?\n @phase == :victory\n end",
"def is_used?\n !self.involvement_events.empty?\n end",
"def reachable?; @state[\"reachable\"]; end",
"def final?\n @finals.include? @state\n end",
"def experience?\n experiences.present?\n end",
"def state_keys\n @state.keys\n end",
"def game_state(game_id)\n\n end",
"def state?(state)\n @_state == state\n end",
"def valid_transitions\n aasm.states(permitted: true).map(&:name).map(&:to_s)\n end",
"def going?(event)\n attended_events.include?(event)\n end",
"def available_states # :nodoc:\n if @states\n return @states\n end\n end",
"def display_waiaria_states(element)\n # Interface method\n end",
"def allowed_new_states\n allowed_transitions = self.current_state.events.values.collect do | event |\n event.transitions_to\n end\n end",
"def make_harvestable\n self.alt_identities_changed = true\n self.harvested = false\n end",
"def can_fire?(current_state)\n if from.is_a?(Array)\n from.include?(current_state.to_sym)\n elsif from == Statum::ANY_STATE_NAME\n true\n else\n from == current_state.to_sym\n end\n end",
"def evented\n @evented = true\n end",
"def steady_state?(state)\n STATES[state] >= STEADY_STATE_THRESHOLD\n end"
] | [
"0.66121393",
"0.6417146",
"0.60232216",
"0.60232216",
"0.60232216",
"0.5957101",
"0.5942494",
"0.59208184",
"0.58217937",
"0.57956517",
"0.5779245",
"0.577735",
"0.5775334",
"0.5746464",
"0.5727154",
"0.5725348",
"0.5663618",
"0.5663028",
"0.5662798",
"0.56339014",
"0.5627058",
"0.56256026",
"0.5615924",
"0.56005555",
"0.5585742",
"0.5553322",
"0.54956555",
"0.54892737",
"0.54884154",
"0.5480609",
"0.5471808",
"0.5471808",
"0.54705024",
"0.54675436",
"0.54675436",
"0.5425845",
"0.54240346",
"0.5400389",
"0.53967303",
"0.5390107",
"0.538595",
"0.53832906",
"0.5369249",
"0.5364688",
"0.53583753",
"0.5354606",
"0.53507227",
"0.5347783",
"0.53434724",
"0.5342864",
"0.5336102",
"0.5334693",
"0.5334243",
"0.53168565",
"0.5316284",
"0.531535",
"0.5312306",
"0.5303568",
"0.5303568",
"0.5284152",
"0.5282426",
"0.5281766",
"0.5281668",
"0.5281654",
"0.5281253",
"0.5274691",
"0.5273573",
"0.5271745",
"0.52711827",
"0.52683467",
"0.5265396",
"0.52550083",
"0.52486813",
"0.52350545",
"0.5217055",
"0.5206131",
"0.52034587",
"0.51915044",
"0.5189023",
"0.51878595",
"0.51833135",
"0.5181147",
"0.51682055",
"0.516563",
"0.51648366",
"0.516203",
"0.516013",
"0.5158206",
"0.515261",
"0.51389533",
"0.512769",
"0.5125613",
"0.51242626",
"0.5118269",
"0.5117525",
"0.51102126",
"0.51048476",
"0.5103465",
"0.51019806",
"0.510119"
] | 0.71087116 | 0 |
should always return a symbol | def state=(input)
self.audited_state = input.try(:to_sym)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol\n @symbol\n end",
"def symbol\n \n end",
"def to_sym() end",
"def to_sym() end",
"def to_sym() end",
"def symbol\n :R\n end",
"def sym\n @sym\n end",
"def symbol\n Util.from_bytes :symbol, value\n end",
"def to_sym; end",
"def symbol\n :R\n end",
"def start_symbol\n @start_symbol\n end",
"def symbol\n :Y\n end",
"def to_s \n self.symbol\n end",
"def symbolidentifier\n\n \t\n\t\tif @usersym.upcase == \"X\" then \n\t\t @compsym = \"O\" \n \t\t else \n \t\t @compsym = \"X\"\n \t\tend \n\n\n end",
"def to_sym\n @name&.to_sym\n end",
"def symbol(string)\n Types::Symbol.cast(string)\n end",
"def sym\n @name.to_sym\n end",
"def current_symbol\n current_data ? current_data[:symbol] : nil\n end",
"def to_s\n \"#{symbol}\"\n end",
"def current_symbol\r\n current_data ? current_data[:symbol] : nil\r\n end",
"def sym(name)\n SymEngine::Symbol.new(name)\nend",
"def get_symbol\n token = @tokens.next\n\n case token\n when :symbol then\n [:symbol, *parse_symbol]\n when :symbol_link then\n [:symbol_link, @tokens.next]\n else\n raise ArgumentError, \"expected SYMBOL or SYMLINK, got #{token.inspect}\"\n end\n end",
"def to_sym\n nil\n end",
"def to_sym\n nil\n end",
"def to_sym\n nil\n end",
"def to_sym\n nil\n end",
"def symbol\n codepoints.pack(\"U*\")\n end",
"def to_sym\n self\n end",
"def turn_symbol_into_string(symbol)\n symbol.to_s\nend",
"def asm_symbol(s)\n sa = Word[s]\n return sa if !sa.nil?\n a = ['']\n s.each_char do |c|\n g = Graph[c]\n if g.nil?\n a[-1] << c\n else\n # graph char found\n if g != ''\n if a[-1] == ''\n a[-1] << g\n a << ''\n else\n a << \"#{g}\"\n a << ''\n end\n end\n end\n end\n if a[-1] == ''\n a.pop\n end\n a.join('_').downcase\n end",
"def symbol_or_code\n symbol || code\n end",
"def sym(name)\n #This is a stub, used for indexing\n end",
"def symbol \n return \"♚\" if @color == :black \n return \"♔\" if @color == :white\n end",
"def to_sym\n `return $rb.Y(self);`\n end",
"def symbol\n # prefer a code display value since the state name may not be unique between modules\n if [email protected]? && [email protected]?\n @codes.first.display.gsub(/\\s+/, '_').downcase.to_sym\n else\n @name.gsub(/\\s+/, '_').downcase.to_sym\n end\n end",
"def symbol\n # prefer a code display value since the state name may not be unique between modules\n if [email protected]? && [email protected]?\n @codes.first.display.gsub(/\\s+/, '_').downcase.to_sym\n else\n @name.gsub(/\\s+/, '_').downcase.to_sym\n end\n end",
"def first_col_sym(symbol)\n \"#{239.chr}#{187.chr}#{191.chr}#{symbol}\".force_encoding(\"utf-8\").to_sym\n end",
"def turn_symbol_into_string(symbol)\n symbol.to_s\nend",
"def turn_symbol_into_string(symbol)\n symbol.to_s\nend",
"def turn_symbol_into_string(symbol)\n symbol.to_s\nend",
"def to_s\n return self.symbol\n end",
"def to_sym?(value); end",
"def symbols; end",
"def sym(position)\n return position if position.is_a? Symbol\n position.gsub(/\\s/, '_').to_sym\n end",
"def str_to_sym(data); end",
"def str_to_sym(data); end",
"def get_symbol_or_name\n tk = get_tk\n case tk[:kind]\n when :on_symbol then\n text = tk[:text].sub(/^:/, '')\n\n next_tk = peek_tk\n if next_tk && :on_op == next_tk[:kind] && '=' == next_tk[:text] then\n get_tk\n text << '='\n end\n\n text\n when :on_ident, :on_const, :on_gvar, :on_cvar, :on_ivar, :on_op, :on_kw then\n tk[:text]\n when :on_tstring, :on_dstring then\n tk[:text][1..-2]\n else\n raise RDoc::Error, \"Name or symbol expected (got #{tk})\"\n end\n end",
"def symbol\n sub_str = @sub ? \"b\" : \"\"\n chord_str = @@chord_symbols[@mode][@step]\n modifiers_str = @modifiers.empty? ? \"\" : \"-#{@modifiers * \"-\"}\"\n inversion_str = @inversion > 1 ? \"_#{@inversion}\" : \"\"\n \n \"#{sub_str}#{chord_str}#{modifiers_str}#{inversion_str}\".intern\n end",
"def get_symbol(sym)\n\t\t\tif @parameters.key?(sym)\n\t\t\t\treturn @parameters[sym]\n\t\t\telsif @species[sym]\n\t\t\t\treturn @species[sym]\n\t\t\telse\n\t\t\t\traise \"Symbol #{sym} not found in model\"\n\t\t\tend\n\t\tend",
"def symbol_suffix\n \"\"\n end",
"def conform_to_symbol(text_or_symbol)\n underscore(text_or_symbol.to_s).downcase.to_sym\n end",
"def to_sym\n name\n end",
"def to_sym\n to_s.to_sym\n end",
"def to_sym\n self\n end",
"def symbol! sym\ninitialize\ns0 = new_state\ns1 = new_state\nset_start(s0)\nset_final(s1, true)\nadd_transition(s0, s1, sym)\nif sym != \"\" && @alphabet.include?(\"#{sym}\") == false\[email protected](\"#{sym}\")\nend\nend",
"def turn_symbol_into_string(symbol)\n\tn = :foobar\n\tn.to_s\nend",
"def to_sym\n @name.to_sym\n end",
"def to_sym\n @name\n end",
"def symbol\n i = 1\n sym = \"\"\n nums = Array['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', \"-\"]\n\n while (i < @currentCommand.length and @currentCommand.slice(i) != '/')\n if (nums.include?(@currentCommand.slice(i)))\n sym += @currentCommand.slice(i)\n else\n raise \"Invalid input\"\n end\n i += 1\n end\n return sym\n end",
"def start_symbol\n START\n end",
"def inspect\r\n @symbol.inspect\r\n end",
"def to_sym\n to_s.to_sym\n end",
"def type_as_symbol\n underscore(self.type).intern\n end",
"def to_sym\n `return $opal.Y(self);`\n end",
"def symbol\n @color \n end",
"def to_symbol(string)\n string.gsub(/[\\-_]/, '').to_sym\n end",
"def start_symbol()\n return sets.first.entries[0].vertex.non_terminal\n end",
"def to_symbol\n case node\n in SyntaxTree::Label[value:]\n value.chomp(\":\").to_sym\n in SyntaxTree::SymbolLiteral[value: SyntaxTree::Ident[value:]]\n value.to_sym\n in SyntaxTree::SymbolLiteral[value:]\n raise CompilationError, \"Unexpected symbol value type: #{value.inspect}\"\n else\n raise CompilationError, \"Unexpected node type: #{node.class.name}\"\n end\n end",
"def symbolyze_key(key)\n key.to_sym rescue key\n end",
"def reg(line)\r\n line.split(\" \")[1].to_sym\r\nend",
"def to_sym\n \tname.downcase.gsub(/\\s+/, \"_\").to_sym\n end",
"def to_symbol(str)\n case str\n when /'/\n \":'\" + str.to_s.gsub(\"'\"){ \"\\\\'\" } + \"'\"\n else\n ':' + str.to_s\n end\n end",
"def symbol_for_name(name)\n if symbols.has_key? name\n symbols[name]\n else\n raise \"No symbol with name #{name} found\"\n end\n end",
"def symbol_key(x)\n HTMLEntities.new.decode(x.text).gsub(/_/, \":\").gsub(/`/, \"\").\n gsub(/[0-9]+/, \"þ\\\\1\")\n end",
"def one_symbol ( who )\n\tif who =~ /^0x/\n\t addr = who.hex\n\telse\n\t addr = @call.sym_lookup_name who\n\t unless addr\n\t\tputs \"Sorry, no such symbol\"\n\t\texit\n\t end\n\tend\n\t#puts addr.hex\n\tpass1 addr\n end",
"def method_symbol; end",
"def to_sym\n return super unless @to_s_sym\n value = self.to_s\n return value.nil? ? value : value.to_sym\n\t\tend",
"def element_symbol; end",
"def symbols() @symbols end",
"def to_symbol from_string\n return from_string.strip.gsub(\".\", \"_\").to_sym\n end",
"def symbol()\n node = factor()\n\n if @look.kind.eql?(Token::STAR) then\n match(Token::STAR)\n node = Star.new(node)\n elsif @look.kind.eql?(Token::QUESTION) then\n match(Token::QUESTION)\n node = Question.new(node)\n end\n\n return node\n end",
"def parse_typographic_syms; end",
"def symbol\n @color == \"white\" ? @symbol = \"\\u{2658}\" : @symbol = \"\\u{265e}\"\n end",
"def to_sym\r\n self.class.to_s.to_sym\r\n end",
"def symbol! sym\n initialize\n s0 = new_state\n s1 = new_state\n set_start(s0)\n set_final(s1, true)\n add_transition(s0, s1, sym)\n if (sym != \"\") && ([email protected]? sym)\n @alphabet.push sym\n end\n end",
"def key_symbol\n @key\n end",
"def getname\n return @name.to_sym\n end",
"def name\n [@n.to_s + character.to_s, symmetry].reject{|p| p == \"\"}.join(\"_\")\n end",
"def computer_symbol\n\t\tputs @player_symbol \n\t\tif(@player_symbol == :O)\n\t\t :X\n\t\telse\n\t\t :O\n\t\tend\n \tend",
"def scm_symbol?; SCM_FALSE; end",
"def symbol(color)\n hash = { white: 'B', black: 'b' }\n hash[color]\n end",
"def user_symbol\n self.class.user_symbol \n end",
"def format_symbol\n\t\t:format\n\tend",
"def target_symbol\n self.class.target_symbol\n end",
"def to_standardized_sym\n standardize\n .to_sym\n end"
] | [
"0.8439484",
"0.8439484",
"0.8439484",
"0.8439484",
"0.8439484",
"0.8439484",
"0.8221429",
"0.81886065",
"0.7841624",
"0.7841624",
"0.7841624",
"0.7761048",
"0.76911813",
"0.76012975",
"0.7558928",
"0.7551381",
"0.7421179",
"0.73289627",
"0.7321705",
"0.73111606",
"0.72689587",
"0.726753",
"0.72462404",
"0.72254294",
"0.7206916",
"0.7173692",
"0.7172807",
"0.7134245",
"0.7121499",
"0.7121499",
"0.7121499",
"0.7121499",
"0.711003",
"0.71071845",
"0.7093749",
"0.7068848",
"0.70671606",
"0.7021316",
"0.69978905",
"0.6969866",
"0.696152",
"0.696152",
"0.6949523",
"0.69470114",
"0.69470114",
"0.69470114",
"0.69234395",
"0.6890173",
"0.68826956",
"0.68746424",
"0.6867118",
"0.6867118",
"0.68586016",
"0.6847053",
"0.6820851",
"0.68182427",
"0.6799926",
"0.67924845",
"0.6782071",
"0.6777081",
"0.67707634",
"0.67667025",
"0.6758038",
"0.67518705",
"0.6738103",
"0.67259234",
"0.67233515",
"0.67155236",
"0.6712922",
"0.6700492",
"0.6696823",
"0.664651",
"0.66442466",
"0.6641489",
"0.6610663",
"0.6606799",
"0.6590988",
"0.6538868",
"0.65350324",
"0.65335375",
"0.65305537",
"0.6527933",
"0.6481945",
"0.64727443",
"0.6470223",
"0.6450427",
"0.64403605",
"0.64285356",
"0.64262515",
"0.64256275",
"0.64250433",
"0.6420732",
"0.6417224",
"0.6416568",
"0.6404696",
"0.6401877",
"0.6400286",
"0.639775",
"0.6397564",
"0.639536",
"0.63932246"
] | 0.0 | -1 |
should be noisy if it fails | def create_audited_state_record
# e.g. @hmd.hmd_states.create!(state: self.state)
self.send(self.class.audited_state_table).create!(state: self.audited_state)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend",
"def failures; end",
"def failures; end",
"def failures; end",
"def big_bad; end",
"def missed?; end",
"def miss_reason; end",
"def do_failure; end",
"def run_failed; end",
"def fail\n # no-op\n end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def diagnostic; end",
"def continued_exception; end",
"def unsuccessful\n end",
"def run_warned; end",
"def exceptions; end",
"def fatal?; end",
"def fatal?; end",
"def bug\n end",
"def checks; end",
"def error?; end",
"def error?; end",
"def error?; end",
"def fail\n end",
"def failure\n end",
"def warned; end",
"def invalid; end",
"def fatal; end",
"def faint; end",
"def faint; end",
"def missing?; end",
"def pass; end",
"def pass; end",
"def private; end",
"def error_threshold; end",
"def too_many_hops?; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def catch_exceptions; end",
"def bye; end",
"def initialize\n @broken = false\n end",
"def failure!\n end",
"def semact?; false; end",
"def failures=(_arg0); end",
"def failures=(_arg0); end",
"def failed?; failed_to_start? || (@success == false) end",
"def ignores; end",
"def complain\n\n end",
"def probers; end",
"def awaken!\n\t\traise 'Not implemented'\n\tend",
"def skipped; end",
"def fail_fast\n @fail_fast\n end",
"def issn; end",
"def recover_from(_error); end",
"def original_error; end",
"def original_error; end",
"def usable?; end",
"def miss_reason=(_arg0); end",
"def check ; true ; end",
"def error?()\n #This is a stub, used for indexing\n end",
"def missing?; false; end",
"def ibu; end",
"def br3ak\n raise RuntimeError, \"OMFG!!1!\"\n end",
"def ridicule_faultfully_prerevision()\n end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def warnings; end",
"def failed?\n raise 'Not implemented!'\n end",
"def precheck\n end",
"def succeed\n # no-op\n end",
"def storage_failure=(_arg0); end",
"def missing; end",
"def error(exception) nil ; end",
"def improve\n return false unless valid?\n true\n end",
"def success; end",
"def success; end",
"def success?() end",
"def warning?; end",
"def warning?; end",
"def warning?; end",
"def suivre; end",
"def skipped!; end",
"def remaining; end",
"def failure!\n @count += 1\n end",
"def lwarn; end",
"def schubert; end",
"def check_errors;\n end"
] | [
"0.70121485",
"0.68163675",
"0.68163675",
"0.68163675",
"0.6485798",
"0.6475313",
"0.64390904",
"0.6392389",
"0.6389032",
"0.6387016",
"0.62987447",
"0.62987447",
"0.62987447",
"0.62987447",
"0.62987447",
"0.62987447",
"0.62987447",
"0.62720925",
"0.6262136",
"0.6259702",
"0.6230045",
"0.62186974",
"0.6192056",
"0.6192056",
"0.6183619",
"0.61829996",
"0.61743045",
"0.61743045",
"0.61743045",
"0.6167112",
"0.61498636",
"0.6146646",
"0.6142437",
"0.61373276",
"0.6132887",
"0.6132887",
"0.6110215",
"0.6090541",
"0.6090541",
"0.6067118",
"0.606616",
"0.6066013",
"0.60536903",
"0.60536903",
"0.60536903",
"0.60536903",
"0.60536903",
"0.60212684",
"0.60066956",
"0.60011655",
"0.59846634",
"0.59827125",
"0.59804267",
"0.59804267",
"0.5979518",
"0.5979289",
"0.59782636",
"0.5973754",
"0.59587806",
"0.5934151",
"0.59239227",
"0.59129655",
"0.59038925",
"0.5897232",
"0.5897232",
"0.5893089",
"0.5883373",
"0.5866385",
"0.5861422",
"0.5860321",
"0.5856017",
"0.5843258",
"0.5838643",
"0.58350104",
"0.58350104",
"0.58350104",
"0.58350104",
"0.58350104",
"0.58350104",
"0.58350104",
"0.58350104",
"0.58278406",
"0.58274376",
"0.5819748",
"0.58176553",
"0.58084613",
"0.5806905",
"0.5806785",
"0.5805121",
"0.5805121",
"0.580092",
"0.5791824",
"0.5791824",
"0.5791824",
"0.5775135",
"0.5773635",
"0.57621795",
"0.576178",
"0.5754815",
"0.5748413",
"0.5747923"
] | 0.0 | -1 |
Post.set!(:hits => 0, :available => 100) | def set!(args)
collection_modifier_update('$set', args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_default_values\n self.eligibility_counter = 0\n self.posts_count = 0\n end",
"def set_hits(results, weights)\n results.each {|item| item.hits = weights[item.name] }\n end",
"def add_hit\n @hits += 1\n :hit\n end",
"def show\n @article = Article.find(params[:id])\n @article.hits += 1\n @article.save\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @lower_bound = args[:lower_bound] if args.key?(:lower_bound)\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @lower_bound = args[:lower_bound] if args.key?(:lower_bound)\n @upper_bound = args[:upper_bound] if args.key?(:upper_bound)\n end",
"def update!(**args)\n @counts = args[:counts] if args.key?(:counts)\n @instances = args[:instances] if args.key?(:instances)\n end",
"def show\n @post = Post.find(params[:id]).increment_with_sql!(:hits, 1)\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @upper_bound = args[:upper_bound] if args.key?(:upper_bound)\n end",
"def update_score\n self.score = posts.inject(0) { |score, post| score += post.rating }\n save\n end",
"def set_visits_count\n \tself.visits_count ||= 0\n end",
"def update!(**args)\n @duplicates_skipped_count = args[:duplicates_skipped_count] if args.key?(:duplicates_skipped_count)\n @failed_ingest_count = args[:failed_ingest_count] if args.key?(:failed_ingest_count)\n @processed_object_count = args[:processed_object_count] if args.key?(:processed_object_count)\n @successful_ingest_count = args[:successful_ingest_count] if args.key?(:successful_ingest_count)\n end",
"def update!(**args)\n @duplicates_skipped_count = args[:duplicates_skipped_count] if args.key?(:duplicates_skipped_count)\n @failed_ingest_count = args[:failed_ingest_count] if args.key?(:failed_ingest_count)\n @processed_object_count = args[:processed_object_count] if args.key?(:processed_object_count)\n @successful_ingest_count = args[:successful_ingest_count] if args.key?(:successful_ingest_count)\n end",
"def hit_count_increament\n self.hit_count = self.hit_count + 1\n self.update\n end",
"def update!(**args)\n @counts = args[:counts] if args.key?(:counts)\n @max_value = args[:max_value] if args.key?(:max_value)\n @min_value = args[:min_value] if args.key?(:min_value)\n end",
"def update!(**args)\n @counts = args[:counts] if args.key?(:counts)\n @max_value = args[:max_value] if args.key?(:max_value)\n @min_value = args[:min_value] if args.key?(:min_value)\n end",
"def num_hits; @hits.size; end",
"def num_hits; @hits.size; end",
"def num_hits; @hits.size; end",
"def count=(v) self['Count'] = v end",
"def update!(**args)\n @stats = args[:stats] if args.key?(:stats)\n @total_query_count = args[:total_query_count] if args.key?(:total_query_count)\n end",
"def update!(**args)\n @stats = args[:stats] if args.key?(:stats)\n @total_query_count = args[:total_query_count] if args.key?(:total_query_count)\n end",
"def update!(**args)\n @score_buckets = args[:score_buckets] if args.key?(:score_buckets)\n end",
"def reset_hit_count\n \"0\"\n end",
"def set_counters\r\n @score_count = 0\r\n @score_total = 0\r\nend",
"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 expire_points\n self.available = 0\n self.save\n end",
"def update!(**args)\n @purge_count = args[:purge_count] if args.key?(:purge_count)\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @score = args[:score] if args.key?(:score)\n @source = args[:source] if args.key?(:source)\n @text = args[:text] if args.key?(:text)\n end",
"def update!(**args)\n @buckets = args[:buckets] if args.key?(:buckets)\n @overflow_bucket = args[:overflow_bucket] if args.key?(:overflow_bucket)\n @underflow_bucket = args[:underflow_bucket] if args.key?(:underflow_bucket)\n end",
"def update!(**args)\n @average_indexed_item_count = args[:average_indexed_item_count] if args.key?(:average_indexed_item_count)\n @stats = args[:stats] if args.key?(:stats)\n end",
"def update!(**args)\n @average_indexed_item_count = args[:average_indexed_item_count] if args.key?(:average_indexed_item_count)\n @stats = args[:stats] if args.key?(:stats)\n end",
"def update_wp_count\n #credit for this approach: http://blog.eldoy.com/posts/14-Custom-counter-cache-column\n self.posted_by.update_attribute :water_points_count, self.posted_by.water_points.visible.count\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @range = args[:range] if args.key?(:range)\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @range = args[:range] if args.key?(:range)\n end",
"def update!(**args)\n @aggregated_query_count = args[:aggregated_query_count] if args.key?(:aggregated_query_count)\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @indexed_items_count = args[:indexed_items_count] if args.key?(:indexed_items_count)\n @status_code = args[:status_code] if args.key?(:status_code)\n end",
"def update!(**args)\n @deleted_entries_count = args[:deleted_entries_count] if args.key?(:deleted_entries_count)\n @upserted_entries_count = args[:upserted_entries_count] if args.key?(:upserted_entries_count)\n end",
"def increment_hit_count()\n hit = nil\n begin\n hit = hits.find_or_create_by_hit_date!(Time.now.to_date)\n rescue ActiveRecord::RecordInvalid\n hit = hits.find_by_hit_date(Time.now.to_date)\n end\n hit.count += 1\n hit.save!\n end",
"def update!(**args)\n @entity_score = args[:entity_score] if args.key?(:entity_score)\n end",
"def update!(**args)\n @integer_buckets = args[:integer_buckets] if args.key?(:integer_buckets)\n end",
"def update!(**args)\n @purge_count = args[:purge_count] if args.key?(:purge_count)\n @purge_sample = args[:purge_sample] if args.key?(:purge_sample)\n end",
"def update!(**args)\n @purge_count = args[:purge_count] if args.key?(:purge_count)\n @purge_sample = args[:purge_sample] if args.key?(:purge_sample)\n end",
"def update!(**args)\n @purge_count = args[:purge_count] if args.key?(:purge_count)\n @purge_sample = args[:purge_sample] if args.key?(:purge_sample)\n end",
"def update!(**args)\n @purge_count = args[:purge_count] if args.key?(:purge_count)\n @purge_sample = args[:purge_sample] if args.key?(:purge_sample)\n end",
"def update!(**args)\n @purge_count = args[:purge_count] if args.key?(:purge_count)\n @purge_sample = args[:purge_sample] if args.key?(:purge_sample)\n end",
"def update!(**args)\n @purge_count = args[:purge_count] if args.key?(:purge_count)\n @purge_sample = args[:purge_sample] if args.key?(:purge_sample)\n end",
"def set_capacity\n self.capacity ||= 100\n end",
"def test_update_if_add\n Post.acts_as_indexed :fields => [:title, :body], :if => Proc.new { |post| post.visible }\n destroy_index\n \n assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size\n p = Post.find(5)\n assert p.update_attributes(:visible => true)\n assert_equal 2, Post.find_with_index('crane',{},{ :no_query_cache => true, :ids_only => true}).size\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @filter = args[:filter] if args.key?(:filter)\n @percentage = args[:percentage] if args.key?(:percentage)\n @value = args[:value] if args.key?(:value)\n end",
"def insert_counter\n coll.insert({'name' => 'guid', 'counter'=> 0})\nend",
"def create\n @article = Article.new(params[:article])\n @article.hits = 0\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render json: @article, status: :created, location: @article }\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @article = Article.new(params[:article])\n @article.hits = 0\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, notice: 'Article was successfully created.' }\n format.json { render json: @article, status: :created, location: @article }\n else\n format.html { render action: \"new\" }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def white_hits=(hits)\n raise TypeError, \"Given white hits must be type of Integer\" unless hits.is_a? Integer\n raise RuleViolationError, \"Cannot override white hits\" unless @white_hits == nil\n \n @white_hits = hits\n return self\n end",
"def update!(**args)\n @created_tags_count = args[:created_tags_count] if args.key?(:created_tags_count)\n @deleted_tags_count = args[:deleted_tags_count] if args.key?(:deleted_tags_count)\n @updated_tags_count = args[:updated_tags_count] if args.key?(:updated_tags_count)\n end",
"def update!(**args)\n @capacity = args[:capacity] if args.key?(:capacity)\n @count = args[:count] if args.key?(:count)\n @scale = args[:scale] if args.key?(:scale)\n end",
"def update!(**args)\n @shards_count = args[:shards_count] if args.key?(:shards_count)\n @vectors_count = args[:vectors_count] if args.key?(:vectors_count)\n end",
"def respond(type, empty, number)\n if !empty\n $ballers.update({ 'number' => number }, { '$set' => { 'balling' => type } })\n 'Response stored.'\n else\n 'There is no request active right now.'\n end\nend",
"def update!(**args)\n @failed_count = args[:failed_count] if args.key?(:failed_count)\n @nocaptcha_count = args[:nocaptcha_count] if args.key?(:nocaptcha_count)\n @pageload_count = args[:pageload_count] if args.key?(:pageload_count)\n @passed_count = args[:passed_count] if args.key?(:passed_count)\n end",
"def set_stats\n @stats = AppStats.new(Post.all, Quote.all)\n end",
"def score=(points)\n s = points\n s = 0 if s < 0\n s = 100 if s > 100\n self[:score] = s\n rerank\n end",
"def test_update_if_update\n Post.acts_as_indexed :fields => [:title, :body], :if => Proc.new { |post| post.visible }\n destroy_index\n \n assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size\n p = Post.find(6)\n assert p.update_attributes(:visible => true)\n assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size\n end",
"def test_update_if_not_in\n Post.acts_as_indexed :fields => [:title, :body], :if => Proc.new { |post| post.visible }\n destroy_index\n \n assert_equal 1, Post.find_with_index('crane', {}, { :no_query_cache => true, :ids_only => true}).size\n p = Post.find(5)\n assert p.update_attributes(:visible => false)\n assert_equal 1, Post.find_with_index('crane',{},{ :no_query_cache => true, :ids_only => true}).size\n end",
"def update_post\n\t\tpost.update_rank\n\tend",
"def reset_hit_count=(is_reset)\n self.hit_count = 0 if is_reset == \"1\"\n end",
"def update!(**args)\n @query_stats = args[:query_stats] if args.key?(:query_stats)\n end",
"def update!(**args)\n @score = args[:score] if args.key?(:score)\n end",
"def update!(**args)\n @score = args[:score] if args.key?(:score)\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @language = args[:language] if args.key?(:language)\n @score = args[:score] if args.key?(:score)\n @term = args[:term] if args.key?(:term)\n @type = args[:type] if args.key?(:type)\n end",
"def show\n @post.views = @post.views + 1\n @post.save\n end",
"def update!(**args)\n @imp_count = args[:imp_count] if args.key?(:imp_count)\n @lcc_count = args[:lcc_count] if args.key?(:lcc_count)\n @query = args[:query] if args.key?(:query)\n @query_count = args[:query_count] if args.key?(:query_count)\n @query_doc_count = args[:query_doc_count] if args.key?(:query_doc_count)\n end",
"def update!(**args)\n @downvotes = args[:downvotes] if args.key?(:downvotes)\n @impressions = args[:impressions] if args.key?(:impressions)\n @measure_window = args[:measure_window] if args.key?(:measure_window)\n @teaser_clicks = args[:teaser_clicks] if args.key?(:teaser_clicks)\n @teaser_impressions = args[:teaser_impressions] if args.key?(:teaser_impressions)\n @upvotes = args[:upvotes] if args.key?(:upvotes)\n end",
"def hit_value= int\n #This is a stub, used for indexing\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @ratio = args[:ratio] if args.key?(:ratio)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @time_range = args[:time_range] if args.key?(:time_range)\n end",
"def set_points\n self.points ||= 0.0\n end",
"def update!(**args)\n @bucketed_final_score = args[:bucketed_final_score] if args.key?(:bucketed_final_score)\n @final_score = args[:final_score] if args.key?(:final_score)\n @policy_applied = args[:policy_applied] if args.key?(:policy_applied)\n @should_prune = args[:should_prune] if args.key?(:should_prune)\n end",
"def update!(**args)\n @query_text_porn_score = args[:query_text_porn_score] if args.key?(:query_text_porn_score)\n @total_clicks = args[:total_clicks] if args.key?(:total_clicks)\n end",
"def update_score!(points)\n increment!(:score, points)\n end",
"def assign_score_limit; end",
"def show\n @post.update_visits_count\n end",
"def update!(**args)\n @boost = args[:boost] if args.key?(:boost)\n @query = args[:query] if args.key?(:query)\n end",
"def update!(**args)\n @result_entity_score = args[:result_entity_score] if args.key?(:result_entity_score)\n end",
"def set_points!\n self.points = 0 unless self.points.presence\n end",
"def initialize(hits,miss,entries,size)\n @cache_hits=hits\n @cache_miss=miss\n @cache_entries=entries\n @cache_size=size\n end",
"def update!(**args)\n @data_scans = args[:data_scans] if args.key?(:data_scans)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @unreachable = args[:unreachable] if args.key?(:unreachable)\n end",
"def update!(**args)\n @lakes = args[:lakes] if args.key?(:lakes)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @unreachable_locations = args[:unreachable_locations] if args.key?(:unreachable_locations)\n end",
"def update!(**args)\n @candidates = args[:candidates] if args.key?(:candidates)\n @query = args[:query] if args.key?(:query)\n @weight = args[:weight] if args.key?(:weight)\n end",
"def assign_score; end",
"def set(key, value, score)\n success = multi do\n @hash.set(key, value)\n @index.add(score, key)\n end\n if success && @size_limit && (@size_limit > 0) && (self.size > @size_limit)\n self.truncate(@size_limit)\n end\n success\n end",
"def update!(**args)\n @failed_count = args[:failed_count] if args.key?(:failed_count)\n @incomplete_count = args[:incomplete_count] if args.key?(:incomplete_count)\n @successful_count = args[:successful_count] if args.key?(:successful_count)\n @successful_forecast_point_count = args[:successful_forecast_point_count] if args.key?(:successful_forecast_point_count)\n end",
"def update!(**args)\n @score = args[:score] if args.key?(:score)\n @url = args[:url] if args.key?(:url)\n end",
"def update!(**args)\n @high = args[:high] if args.key?(:high)\n @low = args[:low] if args.key?(:low)\n end",
"def update!(**args)\n @high = args[:high] if args.key?(:high)\n @low = args[:low] if args.key?(:low)\n end",
"def update!(**args)\n @high = args[:high] if args.key?(:high)\n @low = args[:low] if args.key?(:low)\n end",
"def update!(**args)\n @entity_score = args[:entity_score] if args.key?(:entity_score)\n @type = args[:type] if args.key?(:type)\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def hit_count\n self[:hit_count] && self[:hit_count].to_i\n end",
"def update!(**args)\n @count = args[:count] if args.key?(:count)\n @type = args[:type] if args.key?(:type)\n end",
"def check_score\n score = @post.upvotes - @post.downvotes\n # raise 'hell'\n @post.update_attribute(:score, score)\n end",
"def inc_hit(key, options)\n if @hits[key]\n @hits[key]+=1\n else\n @hits[key]=1\n end\n end"
] | [
"0.6082596",
"0.6017526",
"0.60152984",
"0.5795298",
"0.5789049",
"0.57890236",
"0.57734025",
"0.5722759",
"0.5702382",
"0.5686063",
"0.5666594",
"0.56349427",
"0.56349427",
"0.56129366",
"0.55959666",
"0.55959666",
"0.55668634",
"0.55668634",
"0.55668634",
"0.55580014",
"0.5556174",
"0.5556174",
"0.55426294",
"0.5542555",
"0.55300224",
"0.55290097",
"0.55156314",
"0.55134624",
"0.55031276",
"0.54788977",
"0.5466825",
"0.5466825",
"0.5465817",
"0.5462703",
"0.5462703",
"0.54623413",
"0.5456919",
"0.54532784",
"0.5446966",
"0.54419196",
"0.5441301",
"0.5440159",
"0.5440159",
"0.5440159",
"0.5440159",
"0.5440159",
"0.5440159",
"0.543137",
"0.5407282",
"0.54049456",
"0.5403623",
"0.53973603",
"0.53973603",
"0.5389183",
"0.5388287",
"0.53848505",
"0.53810626",
"0.5375003",
"0.5368401",
"0.5366341",
"0.53548104",
"0.53540486",
"0.53430384",
"0.53357977",
"0.53350174",
"0.5320222",
"0.53106886",
"0.53106886",
"0.5305926",
"0.53029823",
"0.5301512",
"0.5299098",
"0.52861536",
"0.528547",
"0.52852654",
"0.52819383",
"0.52810454",
"0.5278009",
"0.5273504",
"0.52676386",
"0.52587634",
"0.525423",
"0.525014",
"0.52429473",
"0.52379256",
"0.5232926",
"0.5230093",
"0.522946",
"0.52283704",
"0.5223083",
"0.5219973",
"0.521966",
"0.5214182",
"0.5214182",
"0.5214182",
"0.52089995",
"0.52075505",
"0.52075493",
"0.5204805",
"0.52045417",
"0.52025825"
] | 0.0 | -1 |
Post.push_all!(:tags => ['xxx', 'yyy', 'zzz']) | def push_all!(args)
collection_modifier_update('$pushAll', args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_all(*args)\n if args.length == 1 && args.first.is_a?(Hash)\n query.update_all(\"$push\" => collect_each_operations(args.first))\n else\n query.update_all(\"$push\" => { database_field_name(args[0]) => { \"$each\" => Array.wrap(args[1]) } })\n end\n end",
"def push\n if @tags.empty?\n gash.send(:git, 'push', @push_to, @refspec)\n else\n gash.send(:git, 'push', '--tags', @push_to, @refspec)\n end\n end",
"def push_all(pushes)\n view.update_many(\"$push\" => collect_each_operations(pushes))\n end",
"def push\n end",
"def push(pushes)\n prepare_atomic_operation do |ops|\n process_atomic_operations(pushes) do |field, value|\n existing = send(field) || begin\n attributes[field] ||= []\n attributes[field]\n end\n values = [ value ].flatten(1)\n values.each{ |val| existing.push(val) }\n ops[atomic_attribute_name(field)] = { \"$each\" => values }\n end\n { \"$push\" => ops }\n end\n end",
"def push(pushes)\n view.update_many(\"$push\" => collect_operations(pushes))\n end",
"def push *items\n @items.concat items\n end",
"def push(*rest) end",
"def push(*objects)\n @ary.push(*objects)\n self\n end",
"def op_push(arg)\n push arg\n end",
"def push\n end",
"def push (*args)\n\n args.each { |a| self << a }\n\n self\n end",
"def push(*obj)\n obj.each {|obj| self << obj }\n self\n end",
"def push_tags *tags\n # Check for nil tags\n Thread.current[:semantic_logger_tags] = self.tags.concat(tags)\n end",
"def push(thing)\n @things.unshift thing\n update_gist\n end",
"def unpushed_tags\n output_of \"git push --tags --dry-run 2>&1 | grep 'new tag' | awk '{print $4}'\"\nend",
"def execute_batch_push(docs)\n self.inserts_valid = true\n pushes = pre_process_batch_insert(docs)\n if insertable?\n collection.find(selector).update_one(\n positionally(selector, '$push' => { path => { '$each' => pushes } }),\n session: _session\n )\n post_process_batch_insert(docs)\n end\n pushes\n end",
"def push(value); end",
"def push(item)\n end",
"def push(arg0)\n end",
"def push(x)\n end",
"def push *parts\n self.parts.concat parts\n end",
"def post_tags(*value)\n @value[:post_tags] = value.flatten\n end",
"def push(val)\n \n end",
"def push(x)\n \n end",
"def push(x)\n \n end",
"def push(item); end",
"def touch_tags\n tags.each(&:touch)\n end",
"def push *parts\n @parts.concat parts\n end",
"def tag(*tags)\n p tags\n tags.each do |tag|\n tag << self\n @tags << tag\n end\n end",
"def tag(*tags)\n p tags\n tags.each do |tag|\n tag << self\n @tags << tag\n end\n end",
"def push(x)\n self << x\nend",
"def tag *tags\n @tags += tags\n self\n end",
"def push_many(items)\n # we're expecting items to have an nested array of args, lets take each one and correctly normalize them\n payloads = items[:args].map do |args|\n fail ArgumentError, \"Bulk arguments must be an Array of Arrays: [[:foo => 'bar'], [:foo => 'foo']]\" unless args.is_a?(Array)\n # clone the original items (for :queue, :class, etc..)\n item = items.clone\n # merge this item's args (eg the nested `arg` array)\n item.merge!(args: args) unless args.empty?\n # normalize this individual item\n normalize_item(item)\n end.compact\n\n # if successfully persisted to redis return the size of the jobs\n pushed = false\n pushed = raw_push(payloads) unless payloads.empty?\n pushed ? payloads.size : nil\n end",
"def insert_ids_to_post_tags(new_tag_id)\n insert_query = \"INSERT INTO posts_tags(tag_id, post_id)VALUES(#{new_tag_id}, #{self.id});\"\n ActiveRecord::Base.connection.execute(insert_query)\n end",
"def push name='create'\n \n end",
"def using_push(array, str)\n array.push(str)\nend",
"def using_push(array, str)\n array.push(str)\nend",
"def push\n hg 'push'\n end",
"def push cv\r\n\t\[email protected] cv\r\n\tend",
"def push(cmd); end",
"def using_push(array, string)\n array.push(string)\nend",
"def using_push(array, string)\n array.push(string)\nend",
"def using_push(array, string)\n array.push(string)\nend",
"def using_push(array, string)\n array.push(string)\nend",
"def mark_as_pushed!\n self.pushed_at = Time.now\n self.save!\n end",
"def using_push(arr, string)\n arr.push(string)\nend",
"def using_push(array, string)\n array = array.push(string)\n \nend",
"def tag(*tags)\n tags.each {|t| @tags << t}\n @tags.uniq!\n end",
"def push(element); end",
"def set_tags(tags)\n self.tags = tags.map.each do |tag|\n Tag.find_or_create_by_name tag\n end\n end",
"def init_push\n ## empty\n end",
"def tag_ids=(tag_id_list)\n tag_id_list.each { |tag_id| PostTag.create(post_id: self.id, tag_id: tag_id) if !tag_id.blank? }\n end",
"def push(*new_data)\n @storage.push(*new_data)\n end",
"def push_all(enumerable)\n enumerable.each do |item|\n push(item)\n end\n self\n end",
"def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n Tag.where(name: name.strip).first_or_create!\n end\n end",
"def add_tags(*list)\n tags.push(*list).uniq!\n tags\n end",
"def push(*args)\n MapperProxy.instance.push(*args)\n end",
"def push_tags(remote_name, id = nil)\n remote = find_or_create_remote(remote_name)\n raise RemoteNotFound, \"Remote named: #{remote_name} was not found\" unless remote\n all_refs = repo.tags.map(&:canonical_name)\n refs = if id\n tag = find_tag(id)\n tag.canonical_name if tag\n else\n all_refs\n end\n raise NoTagsExists, \"No tags were pushed\" if refs.empty?\n logger.debug(\"Pushing refs #{refs}\")\n logger.info(\"Pushing tags to remote #{remote.url}\")\n remote.push(refs, credentials: credentials)\n end",
"def gitPushTag(pushTag)\n puts \"Pushing tag\"\n @gop.push(@remote, \"refs/tags/#{pushTag}\")\n end",
"def add_tag_associations(tags)\n tags.each do |tag|\n t = Tag.find_by_tag(tag)\n if t\n self.tags << t\n else\n t = Tag.new(:tag => tag)\n self.tags << t if t.save\n end\n end \n end",
"def push_all\n # HDLRuby::High.cur_system.hprint(\"push_all\\n\")\n @stack_ptr <= @stack_ptr + 1\n end",
"def push(model)\n key.call(\"RPUSH\", model.id)\n end",
"def make_tags\r\n Post.all.each do |post|\r\n 10.times do\r\n name = Faker::Lorem.word\r\n post.tags.create!(name: name)\r\n end\r\n end\r\nend",
"def all_tags=(keywords)\n self.tags = keywords.split(',').map do |keyword|\n Tag.where(keyword: keyword.strip).first_or_create!\n end\n end",
"def using_push (array, string)\n return array.push(string)\nend",
"def using_push(array, string)\n return array.push(string)\nend",
"def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n Tag.where(name: name.strip).first_or_create!\n end\n end",
"def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n Tag.where(name: name.strip).first_or_create!\n end\n end",
"def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n Tag.where(name: name.strip).first_or_create!\n end\n end",
"def bulk_push\n ReadLater.bulk_push(read_laters_params[:url])\n\n redirect_to read_laters_path\n end",
"def push(x)\n @input.push x\n end",
"def tag(*tags)\n tags.each { |tag| @tags << tag }\n end",
"def push_without_hooks( *objects )\n\n @without_hooks = true\n\n push( *objects )\n \n @without_hooks = false\n\n return objects\n\n end",
"def push_dup; end",
"def push(element)\r\n # IMPLEMENTME!\r\n end",
"def push *texts\n self.parts.concat texts\n end",
"def push_to_all\n me_in_json = self.to_json\n followers = user.followers\n $redis.pipelined { followers.each { |u_id| $redis.lpush(\"feed:#{u_id}\", me_in_json) }}\n end",
"def push *items\n @components ||= []\n @components.push items\n self\n end",
"def push(element)\n # IMPLEMENT ME!\n end",
"def push(x)\n @q1.push x\n end",
"def add_tags(*tags)\n @hash_tags.concat(tags.flatten)\n end",
"def push_assets\n PUSH_ASSETS\n end",
"def push(e)\n idx = @data.size\n @data.push e\n percolate_up\n end",
"def all_tags=(names)\n self.tags = names.split(\",\").map do |name|\n name.gsub!(/[!@%&\"']/,'')\n name.downcase!\n Tag.where(name: name.strip).first_or_create!\n end\n end",
"def push\n @instructions << Instruction.new(:push)\n self\n end",
"def push(x)\n @q << x \n end",
"def push(*xs)\n xs.each { |x| @nodes.push x }\n end",
"def push(element)\n @store << element #putting the element into the array, thereby putting it into the stack\n end",
"def tags(*args)\n tags = args.length == 1 ? args.first : args\n dsl_data[:tag_list] += tags\n end",
"def all_tags=(names)\n\t self.tags = names.split(\",\").map do |name|\n\t Tag.where(name: name.strip).first_or_create!\n\t end\n\tend",
"def push(*args)\n @tables.push *args\n return self\n end",
"def pushToGitRemotes(branch = 'develop', force = 0)\n if force\n force = \"-f\"\n else\n force = \"\"\n end\n remotes = `git remote`.split(\"\\n\")\n remotes.each do |remote|\n remote.chomp!\n UI.important(\"Pushing #{branch} to remote: #{branch}\\\"\")\n sh(\"git push #{force} #{remote} #{branch}\")\n end\nend",
"def push\n if options.origin.nil?\n logger.error \"No origin URI has been defined for this room\"\n exit 1\n end\n \n if tags.empty?\n logger.error \"Room has no tags. You must create at least one tag before pushing.\"\n exit 1\n end\n\n connect if exp.nil?\n \n # DEADWOOD - Bad idea, lets just force fully qualified paths\n # if uri =~ /\\/~\\//\n # logger.debug \"converting ~ into a real path; uri=#{uri}\"\n # remote_home = ssh.exec!('echo $HOME').chomp\n # uri.sub!(/\\/~\\//, remote_home + '/')\n # logger.debug \"remote home is #{remote_home}, new URI is #{uri}\"\n # end\n \n uri = URI(options.origin)\n\n raise \"unsupported scheme; uri=#{uri}\" unless %w(sftp file).include? uri.scheme\n puts \"pushing room #{name} to #{uri.to_s}\"\n\n basedir = uri.path\n safe_basedir = Shellwords.escape(basedir)\n\n begin\n exp.mkdir basedir\n rescue\n # WORKAROUND: not idempotent\n end\n\n unless exp.ls('').include? 'tags'\n exp.mkdir('tags')\n end\n @platform.mkdir(exp, 'tags')\n\n logger.debug \"uploading options.json\"\n exp.upload(mountpoint + '/etc/options.json', \"options.json\")\n\n @tag_index.construct(self) # KLUDGE\n @tag_index.push\n end",
"def git_push_commits\n shellout(\"git push #{config[:remote]} #{config[:branch]}\")\n end",
"def push_ary ary\n ary.each do |element|\n push element\n end\n end",
"def add_tags(post_num_input, tags_input)\n tags_to_add = tags_input.split(\" \")\n tags_to_add.each do |x|\n BLOG[post_num_input].tags << x\n end\n puts ''\n puts 'Your tags have been added'\n puts BLOG[post_num_input].tags\n puts ''\n end",
"def raw_push(payloads)\n pushed = false\n connection_pool do |connection|\n if payloads.first[:at]\n pushed = connection.zadd('schedule', payloads.map { |item| [item[:at].to_s, ::MultiJson.encode(item)] })\n else\n q = payloads.first[:queue]\n to_push = payloads.map { |item| ::MultiJson.encode(item) }\n _, pushed = connection.multi do\n connection.sadd('queues', q)\n connection.lpush(\"queue:#{q}\", to_push)\n end\n end\n end\n pushed\n end",
"def push(x)\n @in << x\n end",
"def push(klass, *args)\n Resque.enqueue klass, args\n end"
] | [
"0.7164476",
"0.7131387",
"0.6976583",
"0.6836607",
"0.6750737",
"0.6703292",
"0.65711147",
"0.65628296",
"0.6419335",
"0.6386689",
"0.63777876",
"0.6334515",
"0.63339686",
"0.6307532",
"0.62725884",
"0.62404835",
"0.6234765",
"0.62315315",
"0.62022996",
"0.6172553",
"0.614126",
"0.6131447",
"0.6116004",
"0.61154014",
"0.60998917",
"0.60998917",
"0.60722846",
"0.6069807",
"0.6035856",
"0.6023346",
"0.6023346",
"0.599926",
"0.59936476",
"0.5987371",
"0.5987325",
"0.59817404",
"0.5981267",
"0.5981267",
"0.5977077",
"0.596794",
"0.59490544",
"0.5931232",
"0.5931232",
"0.5931232",
"0.5931232",
"0.5927741",
"0.59222215",
"0.5913183",
"0.5911252",
"0.5908547",
"0.5890251",
"0.58900386",
"0.58616036",
"0.5848749",
"0.5845059",
"0.5842864",
"0.5833044",
"0.582926",
"0.5818242",
"0.58135474",
"0.58093196",
"0.5788262",
"0.5778135",
"0.5775121",
"0.5758838",
"0.575086",
"0.5748077",
"0.574441",
"0.574441",
"0.574441",
"0.5734171",
"0.5733631",
"0.5727048",
"0.5724084",
"0.5719656",
"0.5713488",
"0.5709475",
"0.5698039",
"0.5696279",
"0.5667467",
"0.56623554",
"0.56612265",
"0.5657885",
"0.5639684",
"0.5632845",
"0.5630789",
"0.5611219",
"0.56013536",
"0.5601152",
"0.55975366",
"0.55967015",
"0.5590832",
"0.5587678",
"0.5568995",
"0.55597913",
"0.55568355",
"0.5553415",
"0.5551209",
"0.55424774",
"0.55344015"
] | 0.73060334 | 0 |
Post.pull_all!(:tags => ['xxx', 'yyy', 'zzz']) | def pull_all!(args)
collection_modifier_update('$pullAll', args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pull_all(pulls)\n prepare_atomic_operation do |ops|\n process_atomic_operations(pulls) do |field, value|\n existing = send(field) || []\n value.each{ |val| existing.delete(val) }\n ops[atomic_attribute_name(field)] = value\n end\n { \"$pullAll\" => ops }\n end\n end",
"def pulled_tags\n @list.pullin ? @list.taggings.where(user_id: @list.owner_id).includes(:tag).map(&:tag) : []\n end",
"def posts\n Post.filter(:tag_id => self.tag_id)\n end",
"def pull_all(pulls)\n view.update_many(\"$pullAll\" => collect_operations(pulls))\n end",
"def pull(pulls)\n prepare_atomic_operation do |ops|\n process_atomic_operations(pulls) do |field, value|\n (send(field) || []).delete(value)\n ops[atomic_attribute_name(field)] = value\n end\n { \"$pull\" => ops }\n end\n end",
"def pull(pulls)\n view.update_many(\"$pull\" => collect_operations(pulls))\n end",
"def all(slug = @curry_with[0])\n response = @connection.get(\"/repos/#{slug}/pulls\", per_page: 100)\n PullRequest.parse(@connection, response.body)\n end",
"def index\n console\n @posts = Post.order(updated_at: :desc)\n @tags = sorted_tags.reverse\n end",
"def pull; end",
"def pull(*services)\n run!('pull', *services)\n end",
"def unpushed_tags\n output_of \"git push --tags --dry-run 2>&1 | grep 'new tag' | awk '{print $4}'\"\nend",
"def pull\n fetch\n merge\n end",
"def index\n @posts = Post.includes(:tags).all.page(params[:page]).per(PER).order(id:\"DESC\")\n end",
"def user_posts\n posts = []\n self.posts.order(\"id desc\").each do |post|\n post = post.attributes.merge(image: post.image.url)\n posts << post\n end\n posts\n end",
"def index\n @post_tags = PostTag.all\n end",
"def pullFromGitRemotes(branch)\n remotes = `git remote`.split(\"\\n\")\n remotes.each do |remote|\n remote.chomp!\n UI.important(\"Pulling #{branch} from remote: #{branch}\\\"\")\n sh(\"git pull --no-edit #{remote} #{branch}\")\n end\nend",
"def tags\n object.tags.pluck(:title).sort\n end",
"def index\n @tags_posts = TagsPost.all\n end",
"def posts_all(options = {})\n params = prepare_posts_params(options.clone, [:tag])\n response = request(API_PATH_POSTS_ALL, params)\n parse_post_collection(response.body)\n end",
"def delete_tags\n tags = self.tags\n tags.each do |tag|\n tag.destroy if tag.posts.count == 1\n end\n end",
"def posts\n Event.source(self).posts.order(created_at: :desc)\n end",
"def update_tags\n @updated = Tag.refresh_counts\n @deleted = []\n Tag.unused.order(:title).all.each do |tag|\n @deleted << tag.destroy\n end\n end",
"def find_tags\n @tags = BlogPost.tag_counts_on(:tags)\n end",
"def posts\n self.object.posts.sort_by{|post| post.id}.reverse\n end",
"def show\n\t @tags = @posts.tags\n end",
"def get_tags() tag_ids.inject([]) { |l, tag_id| l << get_tag_from_id(tag_id) } end",
"def retrieve_tags\n # noop\n end",
"def pull(*args)\n args.each do |val|\n @added.delete(val)\n\n # @removed is only for items which we'll remove when the Model is\n # persisted\n unless @initial_value.nil?\n @removed << val if @initial_value.include?(val)\n end\n\n unless @value.nil?\n @value.delete(val)\n end\n end\n end",
"def refresh_posts( tagger, all_tags = nil )\n require 'news/feed'\n\n all_tags ||= Tag.find(:all)\n\n puts \"refreshing posts with: #{self.klass}\"\n feed = self.klass.constantize.new( curb_get(self.url), self.content_type )\n\n feed.items.each_with_index do|item,count|\n timer = Time.now\n puts \"loading post: #{item.title}...\"\n post = Post.new(:title => item.title,\n :link => item.links.first,\n :image => item.image,\n :body => item.body,\n :author => item.authors.first,\n :published_at => item.published,\n :feed_id => self.id,\n :tag_list => item.categories )\n post.summarize!\n # check for images in the body pick the first one as the icon to use and use rmagick to scan it down\n post.retag(tagger,all_tags) if post.tag_list.empty?\n puts post.permalink\n other = Post.find_by_title(post.title)\n if post.valid? and (other.nil? or other.published_at != post.published_at)\n post.save!\n puts \"post: #{item.title}, loaded in #{Time.now - timer} with tags: #{post.tag_list.inspect}, item: #{count} of #{feed.items.size}\"\n else\n puts \"skipping: #{item.title}, item: #{count} of #{feed.items.size}\"\n end\n end\n end",
"def pulls(options={})\n pulls = pull_scope(options).to_a\n\n if has_column?(:last_updated_by)\n Pull.load_visible_last_updated_by(pulls)\n end\n if has_column?(:last_notes)\n Pull.load_visible_last_notes(pulls)\n end\n\n pulls\n rescue ::ActiveRecord::StatementInvalid => e\n raise StatementInvalid.new(e.message)\n end",
"def index\n @pulls = Pull.all\n end",
"def get_untagged(args = {})\r\n PhotoList.new('flickr.photos.getUntagged', args)\r\n end",
"def get_all_tags\n print \"Fetching tags...\\r\" if @options[:verbose]\n\n check_github_response { github_fetch_tags }\n end",
"def posts\n Post.all(self).sort_by { |entry| entry.created }.reverse\n end",
"def pull_on_operand_branch *args\n self.on_operand_branch :pull, *args\n end",
"def post_tags\n posts.map do |e|\n yaml = YAML::load_file(e)\n [e, yaml['tags']]\n end\n end",
"def tags\n get('tags')\n end",
"def fetch(hashtags = Mingle::Hashtag.all, since = nil)\n unless since\n if Post.any?\n since = Post.ordered.last.created_at\n else\n since = Mingle.config.since\n end\n end\n\n hashtags = Array(hashtags)\n\n posts = []\n hashtags.each do |hashtag|\n posts += posts_through_search hashtag, since\n end\n\n posts.collect do |data|\n create_post_from_data(data, hashtags)\n end\n end",
"def index\n @tags = Tag.popular.paginate(:page => params[:page], :per_page => 24)\n @last_updated = Tag.order(:updated_at).reverse_order.first\n end",
"def unpublished_posts\n @blog_posts = BlogPost.where(:deleted => '0').where(:publish => \"0\").order('created_at DESC')\n end",
"def github_fetch_tags\n tags = []\n page_i = 0\n count_pages = calculate_pages(@client, \"tags\", {})\n\n iterate_pages(@client, \"tags\") do |new_tags|\n page_i += PER_PAGE_NUMBER\n print_in_same_line(\"Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\")\n tags.concat(new_tags)\n end\n print_empty_line\n\n if tags.count == 0\n Helper.log.warn \"Warning: Can't find any tags in repo. \\\nMake sure, that you push tags to remote repo via 'git push --tags'\"\n else\n Helper.log.info \"Found #{tags.count} tags\"\n end\n # tags are a Sawyer::Resource. Convert to hash\n tags.map { |resource| stringify_keys_deep(resource.to_hash) }\n end",
"def all_by_tag(*tags)\n find(:all).by_tag(*tags)\n end",
"def all_by_tag(*tags)\n find(:all).by_tag(*tags)\n end",
"def getPosts()\n\t\tself.post\n\tend",
"def index\n if params[:tag]\n @posts = Post.tagged_with(params[:tag])\n else\n @posts = Post.order(\"created_at desc\")\n end\n @posts = @posts.page params[:page]\n\nend",
"def git_fetch\n Command.new(\"git\", \"fetch\", \"--tags\").run!.raise!\nend",
"def pull\n @title = @topic.title\n @content = @topic.top_post.content\n @attachment_ids = @topic.top_post.attachment_ids\n end",
"def tags!\n @tags = nil\n tags\n end",
"def destroy_all\n if resource.tags&.any?\n deleted_tags = resource.tags\n resource.tags = []\n resource.save!\n end\n\n render json: { tags: resource.tags, deleted_tags: deleted_tags || [] }\n end",
"def git_fetch\n Command.new(\"git\", \"fetch\", \"--tags\", \"-f\").run!.raise!\nend",
"def toggle_tags\n puts \"\\n\\n******* toggle_tags *******\"\n\n # == get post_id and tag_id from combined :ids string (e.g. 1_4)\n ids = params[:ids].split(\"_\")\n @post_id = ids[0]\n tag_id = ids[1]\n\n # == check post for selected tag\n @post_tag = PostTag.where(post_id: @post_id, tag_id: tag_id).first\n\n # == remove previously assigned tag\n if @post_tag\n puts \"******* HAS TAG (delete tag) *******\"\n @post_tag.destroy\n @post_tags = PostTag.where(post_id: @post_id)\n @post_tag_ids = @post_tags.map{|pt| pt.tag_id }\n puts \"@post_tag_ids: \", @post_tag_ids\n if @post_tag_ids.length == 0\n @post_no_tags = Tag.all\n else\n @post_no_tags = Tag.where(\"id NOT IN (?)\", @post_tag_ids)\n end\n puts \"@post_no_tags: \", @post_no_tags\n @tags = Tag.where(id: @post_tag_ids)\n render json: { tags: @tags, post_no_tags: @post_no_tags, post_id: @post_id}\n end\n end",
"def fetch_tags tags_names, fetched_tags = {}\n posts_count = 0\n\n if DEDUPLICATION\n hydra = Typhoeus::Hydra.new({:max_concurrency => 4})\n hydra.disable_memoization\n TumblrApi.fetch_tags(tags_names) do |values|\n if post = create_post(values, fetched_tags)\n posts_count += 1\n if post.img_url\n hydra.queue create_deduplication_request(post)\n end\n end\n end\n hydra.run\n else\n TumblrApi.fetch_tags(tags_names) do |values|\n if create_post(values, fetched_tags)\n posts_count += 1\n end\n end\n end\n\n Tag.filter(:name => tags_names).update(:last_fetch => DateTime.now)\n posts_count\n end",
"def pull(options={})\n fetch(options[:remote])\n merge(options)\n end",
"def refreshtags\n\t\tif Tag.all != nil\n\t\t\t@badtags = Tag.all.select {\n\t\t\t\t|tag|\n\t\t\t\t@usedresources = Resource.all.select {\n\t\t\t\t\t|resource|\n\t\t\t\t\tresource.tags.include? tag\n\t\t\t\t}\n\t\t\t\[email protected]?\n\t\t\t}\n\t\t\[email protected] {\n\t\t\t\t|tag|\n\t\t\t\ttag.destroy\n\t\t\t}\n\t\tend\n\tend",
"def pulled_from_ids(topic_neo_id, depth=20)\n #Rails.cache.fetch(\"neo4j-#{topic_neo_id}-pushing-#{depth}\", :expires_in => 1.day) do\n query = \"\n START n=node(#{topic_neo_id})\n MATCH n<-[:pull*1..#{depth}]-x\n RETURN distinct x.uuid\n \"\n ids = Neo4j.neo.execute_query(query)\n pull_from = []\n if ids\n ids['data'].each do |id|\n pull_from << Moped::BSON::ObjectId(id[0])\n end\n end\n pull_from\n #end\n end",
"def posts\n Post.all_for_event(self.id)\n end",
"def get_pull_requests(days=7)\n update_pull_requests if @pull_requests.nil?\n @pull_requests.take_while do |pr|\n pr.created_at.to_date > Date.today - days\n end\n end",
"def all_tags context = :tags\n ActsAsTaggableOn::Tagging.where(context: context).select(:tag_id).distinct.includes(:tag).map(&:tag)\n end",
"def find_with_tags(*tags)\n options = tags.extract_options!\n self.all(options.merge(:tags => tags))\n end",
"def tags\n object.tags.map {|tag| tag.id}\n end",
"def posts_by_tags(tags, page = 1, limit = options[:limits][:per_page])\n tags = clean_tags(tags)\n posts_url = self.class::OLD_API ? 'post.json' : 'posts.json'\n do_request(posts_url, tags: tags, page: page, limit: limit)\n end",
"def pull_queue_pull\n return nil if self.pull_queue_names.length == 0\n \n puts \"pulling from queues #{self.pull_queue_names.join ', '}\"\n \n elt = nil\n elt = @redis.brpop(self.pull_queue_names, self.queue_wait_seconds) while elt == nil\n \n key = elt[0]\n val = elt[1]\n self.debug_out \"got data from pull queue #{key}\"\n Marshal.load val\n end",
"def all\n@posts = Post.all\nend",
"def tag_cloud\r\n \t@tags = Post.tag_counts_on(:tags)\r\n end",
"def clear_all_tags()\n puts \"Deleting Tags...\"\n Tag.delete_all()\n puts \"Finished deleting all tags.\"\nend",
"def posts\n pool_posts = Pool.where(id: id).joins(\"CROSS JOIN unnest(pools.post_ids) WITH ORDINALITY AS row(post_id, pool_index)\").select(:post_id, :pool_index)\n Post.joins(\"JOIN (#{pool_posts.to_sql}) pool_posts ON pool_posts.post_id = posts.id\").order(\"pool_posts.pool_index ASC\")\n end",
"def atomic_pulls\n pulls = {}\n delayed_atomic_pulls.each_pair do |_, docs|\n path = nil\n ids = docs.map do |doc|\n path ||= doc.flag_as_destroyed\n doc._id\n end\n pulls[path] = { '_id' => { '$in' => ids } } and path = nil\n end\n pulls\n end",
"def related_posts\n if @_related_posts.nil?\n @_related_posts = []\n \n if @headers[:related] && @headers[:related] == 'none'\n return @_related_posts\n \n elsif @headers[:related] && @headers[:related].is_a?(Array)\n @_related_posts = @headers[:related].map{ |slug| Post.find(slug) }\n \n else\n @_related_posts = Post.find_tagged_with(tags.first).delete_if{ |post| post.slug == self.slug }[0...5]\n \n end\n end\n\n @_related_posts\n end",
"def pull_from_ids(topic_neo_id, depth=20)\n #Rails.cache.fetch(\"neo4j-#{topic_neo_id}-pulling-#{depth}\", :expires_in => 1.day) do\n query = \"\n START n=node(#{topic_neo_id})\n MATCH n-[:pull*1..#{depth}]->x\n RETURN distinct x.uuid\n \"\n ids = Neo4j.neo.execute_query(query)\n pull_from = []\n if ids\n ids['data'].each do |id|\n pull_from << Moped::BSON::ObjectId(id[0])\n end\n end\n pull_from\n #end\n end",
"def all_related_tags\n (all_posts + all_archived_posts).reject do |post|\n (post.tags & current_post.tags).empty?\n end.map{ |post| post.tags }.flatten.uniq.sort\n end",
"def followed_posts\n self.followed_users.includes(:posts).order(\"updated_at desc\").collect{|u| u.posts}.flatten \n end",
"def query_github\n make_api_request(\"https://api.github.com/repos/AlchemyCMS/alchemy_cms/tags\")\n end",
"def index\n @questions = Question.preload(:user, :post).order('created_at DESC').page(params[:page]).per(10)\n\n @questions = @questions.tagged_with(params[:tag]) if params[:tag]\n end",
"def find_all(client, workspace: nil, team: nil, archived: nil, per_page: 20, options: {})\n params = { workspace: workspace, team: team, archived: archived, limit: per_page }.reject { |_,v| v.nil? || Array(v).empty? }\n Collection.new(parse(client.get(\"/tags\", params: params, options: options)), type: self, client: client)\n end",
"def tweets_by_tag\n @tag = Tag.find(params[:id])\n @tweets = @tag.tweets.order(created_at: :desc) # order the tweets according to when they were created, with the most recent tweet at the top.\n end",
"def all\n Tag.all.map{|t| \"#{t.tag} \"}\n end",
"def get_all_posts(oauth_token)\n result = []\n client = Octokit::Client.new(access_token: oauth_token)\n posts = client.contents(full_repo_name, path: '_posts')\n posts.each do |post|\n oldest_commit = get_oldest_commit_for_file(client, post.path)\n username = client.user[:login]\n if username == oldest_commit[:author][:login]\n post_api_response = client.contents(full_repo_name, path: post.path)\n\n post_model = create_post_from_api_response(post_api_response, nil)\n image_paths = KramdownService.get_all_image_paths(post_model.contents)\n\n images = []\n image_paths.each do | image_path |\n image_content = client.contents(full_repo_name, path: image_path)\n images << create_post_image(image_path, image_content.content)\n end\n\n post_model.images = images\n \n result << post_model\n end\n end\n result\n end",
"def index\n PostCleanupJob.perform_later\n if(params[:tag])\n # this will handle the tag links search\n posts = Post.order(updated_at: :desc).search(params[:tag])\n else\n # the query will be used for the search functionality, the search method\n # is defined in the post model\n @query = params[:query]\n posts = Post.order(updated_at: :desc).search(params[:query])\n end\n\n set = Set.new(posts)\n @posts = set.to_a\n\n # for side_bar display variables\n @categories = Category.all\n @favourites = Favourite.where(user: current_user)\n end",
"def get_all_posts_in_pr_for_user(oauth_token)\n result = []\n client = Octokit::Client.new(access_token: oauth_token)\n pull_requests_for_user = get_open_post_editor_pull_requests(oauth_token)\n \n pull_requests_for_user.each do | pull_request |\n pull_request_files = client.pull_request_files(full_repo_name, pull_request[:number])\n\n post = nil\n images = []\n pull_request_files.each do | pull_request_file |\n contents_url_params = CGI.parse(pull_request_file[:contents_url])\n\n # The CGI.parse method returns a hash with the key being the URL and the value being an array of\n # URI parameters so in order to get the ref we need to grab the first value in the hash and the first\n # URI parameter in the first hash value\n ref = contents_url_params.values.first.first\n file_contents = client.contents(full_repo_name, path: pull_request_file[:filename], ref: ref)\n\n if pull_request_file[:filename].ends_with?('.md')\n post = create_post_from_api_response(file_contents, ref)\n result << post\n else\n images << create_post_image(pull_request_file[:filename], file_contents.content)\n end\n end\n\n post.images = images\n end\n result\n end",
"def posts\n @posts ||= retrieve_posts\n end",
"def index\n @posts = Post.order(updated_at: :desc)\n end",
"def my_tag_list\n self.taggings.order('id ASC').map(&:tag).map(&:name)\n end",
"def posts\n return @posts if defined? @posts\n\n diffable_files = `git diff -z --name-only --diff-filter=ACRTUXB origin/master -- content/changes/`.split(\"\\0\")\n\n @posts = diffable_files.select do |filename|\n ext = File.extname(filename)\n ext == \".md\" || ext == \".html\"\n end\nend",
"def touch_tags\n tags.each(&:touch)\n end",
"def find_all_tagged_with(*args)\n find_tagged_with(*args)\n end",
"def tags\n get.tagGuids\n end",
"def index\n @tag_refs = TagRef.all\n end",
"def related_tags_in(folder = :posts)\n (related_posts_in(folder) << current_post).map{ |post| post.tags }.flatten.uniq.sort\n end",
"def update!(**args)\n @tags = args[:tags] if args.key?(:tags)\n end",
"def update!(**args)\n @tags = args[:tags] if args.key?(:tags)\n end",
"def delete_unused_tags\n ActiveRecord::Base.connection.execute(\n \"delete from tags where id in(\n select t.id from tags as t left join posts_tags as pt on pt.tag_id = t.id where pt.tag_id is null\n )\"\n )\n end",
"def available_tags\n available_tags = []\n Tag.all.each do |t|\n available_tags << t.name\n end\n\n tags = []\n self.tags.each do |t|\n tags << t.name\n end\n\n available_tags - tags\n end",
"def index\n if params[:tag]\n @posts = Post.most_recent.published.paginate(:page => params[:page], per_page: 6).tagged_with(params[:tag])\n else\n @posts = Post.most_recent.published.paginate(:page => params[:page], per_page: 6)\n end\n end",
"def retrieve_posts\n # Get posts\n rss = RSS::Parser.parse(AWL_RSS_URL)\n\n # Grab shortened URLs\n links = rss.items.map(&:guid).map(&:content)\n\n @articles = []\n\n links.each do |link|\n @articles << Article.new(link)\n end\n\n # TODO: Only grab the tags for articles that haven't already be tweeted\n @articles.map(&:retrieve_tags)\n end",
"def tags\n @tags ||= []\n end",
"def posts\n posts = @client.entries(content_type: 'post').items\n posts || []\n end",
"def sorted_tags\n tags.order('id ASC')\n end",
"def index\n @tags = ActsAsTaggableOn::Tag.order(:name).all\n end",
"def view_posts\n self.user.posts.map do |post|\n post.reload.content\n end\n end",
"def index\n @posts = Post.published.order('published_at DESC')\n end"
] | [
"0.70059043",
"0.66936535",
"0.6583242",
"0.65817666",
"0.65602046",
"0.6553358",
"0.6096642",
"0.60800093",
"0.6051959",
"0.5974984",
"0.5874631",
"0.5872539",
"0.5818738",
"0.58043724",
"0.5778912",
"0.5686603",
"0.56759363",
"0.56659436",
"0.5612834",
"0.56012523",
"0.55585414",
"0.55344236",
"0.55249524",
"0.5491125",
"0.5488181",
"0.54875237",
"0.5483828",
"0.54720914",
"0.5465846",
"0.5459507",
"0.543939",
"0.5437361",
"0.5424883",
"0.5414791",
"0.54086035",
"0.5376101",
"0.5372075",
"0.53570586",
"0.534172",
"0.5337727",
"0.53353006",
"0.53051084",
"0.53051084",
"0.53049374",
"0.5283965",
"0.52760667",
"0.5276038",
"0.5272313",
"0.5271413",
"0.5252439",
"0.52447623",
"0.52389914",
"0.52228373",
"0.5221815",
"0.52094895",
"0.5193461",
"0.51823044",
"0.51658744",
"0.5162828",
"0.5161991",
"0.51614195",
"0.5152127",
"0.51353866",
"0.51304436",
"0.5123904",
"0.51167864",
"0.51136696",
"0.5111639",
"0.5110822",
"0.5107904",
"0.510609",
"0.5105773",
"0.5101831",
"0.5078687",
"0.507803",
"0.5071504",
"0.50705737",
"0.5070472",
"0.5070041",
"0.5069323",
"0.50687826",
"0.5067933",
"0.506712",
"0.5066799",
"0.5056143",
"0.5054128",
"0.50520444",
"0.50454026",
"0.5045262",
"0.5045262",
"0.50445473",
"0.50414413",
"0.5040748",
"0.50366485",
"0.5036481",
"0.50346607",
"0.50332856",
"0.5031245",
"0.50299084",
"0.5028362"
] | 0.69739914 | 1 |
requires mongodb 1.7.2 Post.rename!(:tags => :tag_collection) | def rename!(args)
collection_modifier_update('$rename', args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename_collection(db, coll_name, new_name)\n collections = db.collection_names\n\n if new_name.include?('__')\n raise 'double underscores are resereved for internal usage'\n end\n\n if not collections.include? coll_name\n raise \"collection does not exist\"\n end\n if collections.include? new_name\n raise \"target collection already exists\"\n end\n\n db.collection(coll_name).rename(new_name)\n db.collection_names.keep_if{|c| c.start_with? coll_name + '__'}.each do |related_collection|\n db.collection(related_collection).rename(new_name + '__' + related_collection.split('__', 2)[1])\n end\n metadata = db.collection('__METADATA__').find_one('_id' => coll_name)\n metadata['_id'] = new_name\n db.collection('__METADATA__').insert(metadata)\n db.collection('__METADATA__').remove('_id' => coll_name)\n end",
"def rename(new_name)\n case new_name\n when Symbol, String\n else\n raise TypeError, \"new_name must be a string or symbol\"\n end\n\n new_name = new_name.to_s\n\n if new_name.empty? or new_name.include? \"..\"\n raise Mongo::InvalidNSName, \"collection names cannot be empty\"\n end\n if new_name.include? \"$\"\n raise Mongo::InvalidNSName, \"collection names must not contain '$'\"\n end\n if new_name.match(/^\\./) or new_name.match(/\\.$/)\n raise Mongo::InvalidNSName, \"collection names must not start or end with '.'\"\n end\n\n @db.rename_collection(@name, new_name)\n @name = new_name\n end",
"def rename_child_collection(old_name, name)\r\n #Verify that new name isn't already in database\r\n result = @db_interface.hash_value_exist?(@certain_coll_key, name)\r\n raise Transformer::MappingException, \"Collection with such a name already exist.\" if result\r\n result = @db_interface.hash_value_exist?(@certain_coll_key, old_name)\r\n raise Transformer::MappingException, \"Cannot rename, collection #{old_name} doesn't exist.\" unless result\r\n\r\n #Delete old enevironment\r\n old_id = get_child_collection_id(old_name)\r\n result = []\r\n result[0] = @db_interface.delete_from_hash(@certain_coll_key, [old_name])\r\n result[1] = @db_interface.add_to_hash_ne(@certain_coll_key, name, old_id)\r\n #Note: result may obtain some old return values from redis, we have to lookup at the end of result\r\n raise Transformer::MappingException, \"Cannot delete old collection's name, rename aborted.\" unless result[-1]\r\n raise Transformer::MappingException, \"Renaming failed.\" unless result[-2]\r\n end",
"def update_tags(tags)\n rescue_extra_data\n tags = tags.split(\",\").strip\n post_tags = post_type.post_tags\n post_tags = post_tags.where.not(name: tags) if tags.present?\n term_relationships.where(\"term_taxonomy_id in (?)\", post_tags.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")).destroy_all\n tags.each do |f|\n post_tag = post_type.post_tags.where({name: f}).first_or_create(slug: f.parameterize)\n term_relationships.where({term_taxonomy_id: post_tag.id}).first_or_create\n end\n update_counters(\"tags\")\n end",
"def move_collection_names\n @record.xpath('./datafield[@tag=\"710\"]/subfield[@code=\"5\"]').each do |subfield|\n collection = subfield.parent.at_xpath('./subfield[@code=\"a\"]').text\n\n Nokogiri::XML::Builder.with(@doc.at('record')) do |xml|\n xml.datafield('ind1' => '0', 'ind2' => '0', 'tag' => '773') do\n xml.subfield(collection, 'code' => 't')\n end\n end\n\n subfield.parent.remove\n end\n end",
"def tags_aggregation_collection\n @tags_aggregation_collection ||= \"#{collection_name}_tags_aggregation\"\n end",
"def update_tag_name\n t = self.tag\n new_tag = Tag.find_by_name(self.name)\n if t != new_tag\n if new_tag.nil?\n t.update_attribute(:name, self.name)\n else\n new_tag.update_attribute(:tag_type, self.class.name)\n self.bypass_save_callbacks = true\n self.update_attribute(:tag_id, new_tag.id)\n # Downgrade 't' to a regular tag if no topic/subject points to it\n t.update_attribute(:tag_type, nil) if !Topic.exists?(:tag_id => t.id)\n end\n end\n end",
"def renameTargetCollection(tcId, name)\n payload = { :name => name }\n path = PATH_GET_TC.dup\n path[PLACEHOLDER_TC_ID] = tcId\n return sendRequest('POST', path, payload)\n end",
"def renameTargetCollection(tcId, name)\n payload = { :name => name }\n path = PATH_GET_TC.dup\n path[PLACEHOLDER_TC_ID] = tcId\n return sendRequest('POST', path, payload)\n end",
"def rename_tag\n if request.post?\n tag = Tag.find(params[:tag_id])\n tag.name = params[:tag_name]\n tag.save\n render :text => tag.name\n end\n end",
"def collection_names\n names = collections_info.collect { |doc| doc['name'] || '' }\n names = names.delete_if {|name| name.index(@name).nil? || name.index('$')}\n names.map {|name| name.sub(@name + '.', '')}\n end",
"def coll_name\n self.name.split('::').last.split(/(?=[A-Z])/).map{|x| x.downcase}.join('_')\n end",
"def drop\n @db.drop_collection(@name)\n end",
"def drop\n @db.drop_collection(@name)\n end",
"def cleanup_old_docs(old_object_doc_array, collection_name)\n logger.debug \"Clean up old documents\"\n # iterate over each old doc\n old_object_doc_array.each do\n |old_object_doc|\n # Remove it from MongoDB by referencing '_id' key\n collection_by_name(collection_name).remove({\"_id\" => old_object_doc[\"_id\"]})\n end\n end",
"def mapUsernameInBookingDump(collection, query, userName)\n collection.update_many(\n query,\n {\n :$addToSet => {\n :mappedTo => userName\n }\n }\n )\n end",
"def create_collection(name)\n @change_collections_mutex.synchronize do\n collection = native.collection(name)\n collection.create\n collections[name] = Robe::DB::Mongo::Collection.new(self, collection)\n end\n end",
"def rename_pets(uncustomized_pets_ordered, pets_to_update)\n counter = 1 # Because the pets are ordered by admittance date already, a counter can be used to properly number them\n uncustomized_pets_ordered.each do |pet|\n pet.name = \"#{pet.breed} #{counter}\"\n pets_to_update << pet\n counter += 1\n end\n end",
"def collection_name; end",
"def collection_name; end",
"def collection_name; end",
"def down\n add_column :posts, :name, :string\n end",
"def drop_collection(collection_name)\n get_db.drop_collection(collection_name)\n end",
"def drop_collection(collection_name)\n get_db.drop_collection(collection_name)\n end",
"def set_collection_name(name)\n @collection_name = name\n end",
"def collection_names; end",
"def add_tag_for_collection_members(collection_id:, tags:)\n collection = Collection.find(collection_id)\n\n puts \"Checking #{collection.members.count} items in #{collection.title}\"\n collection.members.each do |member|\n if member.class == Collection\n add_tag_for_collection_members(collection_id: member.id, tags: tags)\n else\n member.tag += tags\n member.save!\n end\n end\nend",
"def delete_collection(db, coll_name)\n if db.collection('__METADATA__').find_one('_id' => coll_name) == nil\n raise \"collection does not exist\"\n end\n\n db.collection(coll_name).drop\n db.collection_names.keep_if {|c| c.start_with? coll_name+'__'}.each {|related_collection| db.collection(related_collection).drop}\n\n db.collection('__METADATA__').remove('_id' => coll_name)\n end",
"def drop_collection(name)\n response = RequestResponse.new\n names_resp = collection_names\n names_resp.callback do |names|\n if names.include?(name.to_s)\n cmd_resp = command(:drop=>name)\n cmd_resp.callback do |doc|\n response.succeed EM::Mongo::Support.ok?(doc)\n end\n cmd_resp.errback { |err| response.fail err }\n else\n response.succeed false\n end\n end\n names_resp.errback { |err| response.fail err }\n response\n end",
"def reset_all_slugs!(collection = [])\n collection = collection.presence || self.all\n\n collection.each do |record|\n record.wipe_slugs\n\n # update wiped slugs without triggering sluggable\n slug_data = {}\n slug_fields = self.all_slug_fields\n slug_fields.each do |options|\n key = options[:key]\n slug_data[key] = record.send(:\"#{key}\")\n end\n\n record.set(slug_data)\n end\n\n # now update all with triggering sluggable\n collection.each do |record|\n record.set_slug\n record.save(validate: false)\n end\n end",
"def rename(old, new)\n args = [\"old=#{old.uri_escape}\", \"new=#{new.uri_escape}\"]\n get('/api/tags/rename?' << args.join('&'))\n nil\n end",
"def create_collection(client, collection_name)\n client[collection_name].drop\n client[collection_name].create\n end",
"def fix_collection(db, coll_name, fixtype)\n case fixtype\n when :spuriousM\n db.collection('__METADATA__').remove('_id' => coll_name)\n when :INIT\n db.collection(coll_name).drop\n db.collection('__METADATA__').remove('_id' => coll_name)\n when :APPEND\n metadata = db.collection('__METADATA__').find_one('_id' => coll_name)\n bad_vcfs = metadata['last_inconsistency_reason'][1]\n\n first_bad_vcf = metadata['vcfs'].index(bad_vcfs[0])\n if first_bad_vcf == nil\n raise \"the metadata state is incoherent\"\n end\n bad_samples = []\n metadata['samples'].each do |s| \n if s['vcfid'] >= first_bad_vcf\n bad_samples << s['name']\n end\n end\n\n number_of_good_samples = metadata['samples'].length - bad_samples.length\n number_of_good_vcfs = metadata['vcfs'].length - bad_vcfs.length\n\n update_operation = {\n '$push' => {\n 'IDs' => {'$each' => [], '$slice'=> number_of_good_vcfs},\n 'QUALs' => {'$each' => [], '$slice'=> number_of_good_vcfs}, \n 'FILTERs' => {'$each' => [], '$slice'=> number_of_good_vcfs},\n 'INFOs' => {'$each' => [], '$slice'=> number_of_good_vcfs},\n 'samples' => {'$each' => [], '$slice'=> number_of_good_samples}\n }\n }\n\n db.collection(coll_name).update({}, update_operation, {:multi => true})\n\n metadata_update_operation = {\n '$set' => {'consistent' => true}, \n '$push' => {\n 'vcfs' => {'$each' => [], '$slice' => number_of_good_vcfs},\n 'headers' => {'$each' => [], '$slice' => number_of_good_vcfs},\n 'samples' => {'$each' => [], '$slice'=> number_of_good_samples}\n },\n }\n db.collection('__METADATA__').update({'_id' => coll_name}, metadata_update_operation)\n else\n raise \"unknown error state, fix_collection() doesn't know what to do\"\n end\n end",
"def unMapUsernameInBookingDump(collection, userName)\n collection.update_many(\n {\n :$pull => {\n :mappedTo => userName\n }\n }\n )\n end",
"def renameTargetCollection(tcId, tcName)\n payload = { 'name' => tcName }\n path = @@PATH_GET_TC.dup\n path[@@PLACEHOLDER_TC_ID] = tcId\n return sendHttpRequest(payload, \"POST\", path)\n end",
"def delete_tags(name); end",
"def update_collection(collection)\n # Take the name out of the list of keys so that all that remains are fields to\n # be updated\n name = collection.delete(:name)\n # Because the name may come in many forms we must use something like titlecase to help\n # account for variations\n name = name.last.titleize\n \n # Due to the way that batches are handled a collection may appear multiple times. Presume\n # that if it has already been processed it is safe to skip any duplicates\n if (@successful_updates.include?(name) or \n @failed_updates.include?(name))\n log_message(\"Skipping duplicate collection entry\")\n return\n end\n\n coll = Collection.where(title: name).first\n \n if (coll.present? and (coll.title == name))\n log_message(\"Processing #{coll.title}\")\n update_and_save_metadata(coll, collection) \n @successful_updates << name\n else\n log_message(\"Could not locate #{name}\", Logger::WARN)\n @failed_updates << name\n end\n end",
"def collection_names=(new_collection_names)\n Rails.logger.info \"DEPRECATED: collection_names is deprecated, please refactor\"\n names = new_collection_names.split(',').map{ |name| name.strip }\n new_collections = Collection.where(:name => names)\n missing = names - new_collections.value_of(:name)\n to_add = new_collections - self.collections\n to_remove = self.collections - new_collections\n to_remove.each do |c|\n self.collections.delete(c)\n end\n to_add.each do |c|\n self.collections << c\n end\n unless missing.blank?\n error = missing.size == 1 ? \n ts(\"We couldn't find a collection with the name %{name}. \", :name => missing.first) : \n ts(\"We couldn't find the collections named %{names}. \", :names => missing.to_sentence)\n error += ts(\"Make sure you are using the one-word name, and not the title?\")\n self.errors.add(:base, error)\n end\n end",
"def migrate_model(pg_model, mongo_model, transform = nil)\n attributes = pg_model.attribute_names\n ActiveRecord::Base.transaction do\n mongo_model.collection.find.batch_size(100).each do |obj|\n pg_attrs = obj.slice(*attributes)\n\n # If a model specific transform is required, do it here\n pg_attrs = transform.call(pg_attrs) if transform.present?\n\n pg_model.create! pg_attrs\n end\n\n if pg_model.count != mongo_model.count\n raise \"PG and Mongo counts are in disagreement; aborting\"\n end\n end\n\n puts \"#{pg_model.count} migrated to pg\"\nend",
"def rename(old_tag, new_tag)\n args = [\"old=#{u(old_tag)}\", \"new=#{u(new_tag)}\"]\n get('tags/rename?' << args.join('&'))\n nil\n end",
"def collection_name(solr_doc)\n solr_doc[Solrizer.solr_name(\"collection\", :facetable)]\n end",
"def mongoize(object)\n object.mongoize\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 full_collection_name(collection_name)\n \"#{name}.#{collection_name}\"\n end",
"def camel_case_collection_name(collection)\n collection.to_s.split(\"_\").map(&:capitalize).join\n end",
"def tag_names=(tags=[])\n self.entity_tags = tags.map do |name|\n tag = Tag.find_or_initialize_by name: name\n self.entity_tags.new(tag: tag)\n end\n end",
"def create_tags(tags)\n tags.each do |tag_name|\n self.tags.create!(name: tag_name.downcase) unless self.tags.find_by(name: tag_name.downcase)\n end\n end",
"def set_tags(tags)\n self.tags = tags.map.each do |tag|\n Tag.find_or_create_by_name tag\n end\n end",
"def RenameAllFields(doc, name)\n\titr = doc.GetFieldIterator(name)\n\tcounter = 0\n\twhile itr.HasNext do\n\t\tf = itr.Current\n\t\tf.Rename(name + counter.to_s)\n\t\titr = doc.GetFieldIterator(name)\n\t\tcounter = counter + 1\n\tend\nend",
"def tag_names=(tags)\n tag_array = tags.split(\",\").map{|tag| tag.strip}\n tag_array.each do |tag|\n new_tag = Tag.find_or_create_by(name: tag)\n if self.tags.include?(new_tag)\n next\n end\n self.tags << new_tag\n self.owner.tags << new_tag\n end\n end",
"def database_name=(name)\n @collection = nil\n @database_name = name\n end",
"def update_tags(tag_set, verbose: false)\n removed_tags = Set.new\n loop do\n previous_tags = tag_set.map{|t|t.to_s}\n\n implicate_tags(tag_set, removed_tags, verbose)\n alias_tags(tag_set, removed_tags)\n\n # Break when there is no change in tags.\n return tag_set if tag_set.map{|t|t.to_s} == previous_tags\n end\n end",
"def persist_tags!(tag_names)\n tag_names.each do |name|\n Tag.where(name: name).first_or_create!.increment!(:count)\n end\n end",
"def tag_name=(tag_name)\n self.tag = Tag.find_by_name!(tag_name)\n end",
"def drop_collection(name)\n return false if strict? && !collection_names.include?(name.to_s)\n begin\n ok?(command(:drop => name))\n rescue OperationFailure => e\n false\n end\n end",
"def full_collection_name\n \"#{app_id}.#{name}\"\n end",
"def alias_tags(tag_set, removed_tags)\n until_tags_stabilize(tag_set) do |tag, to_add|\n next unless @tag_aliases.key? tag.to_s\n aliased = Tag[@tag_aliases[tag.to_s]]\n aliased.each{|t| t.update_stats! tag.stats}\n # If we are trying to alias back a tag already removed, there is a\n # cycle in the tag aliases and implications.\n removed = aliased.find { |t| removed_tags.include? t.to_s }\n error_for_cyclical_tags(tag.to_s, removed) if removed\n\n # if it's already in the set, something weird happened\n removed_tags << tag.to_s\n tag_set.delete tag\n \n to_add.merge aliased\n alias_loop = true\n end\n end",
"def autosave_associated_records_for_tag\n if new_tag = Tag.find_or_create_by_name(self.name)\n self.tag = new_tag\n else\n self.tag = tag if self.tag.save!\n end\n end",
"def update_tags\n return unless tag_string\n new_tag_names = tag_string.split(\",\").map { |t| t.strip.downcase }\n current_tag_names = tags.collect(&:name)\n new_tag_names.each do |tag_name| \n unless current_tag_names.include? tag_name\n tag = Tag.where(name: tag_name)[0]\n tag = Tag.create! name: tag_name unless tag\n self.tags << tag \n end\n end\n tags.each { |t| (tags.remove t) unless (new_tag_names.include? t.name) }\n end",
"def to_tag(name)\n tag = Tag.find_by(name: name)\n if tag.nil?\n tag = Tag.new(name: name)\n tag.save\n end\n tag\nend",
"def merge_mongo_and_solr(collection, resp)\n\t\t\tsolr_objects = resp['response']['docs']\n\t\t\tmkey,skey = @mongo_match_by.split(\"::\")\n collection.each_with_index do |document,index|\n\t\t\t\tmid = document.fetch(\"#{mkey}\")\n sdoc = solr_objects.find {|sd| sd[\"#{skey}\"] == \"#{mid}\"}\n for pkey in @mongo_projection_keys.split(\",\")\n if document.has_key?(\"#{pkey}\")\n sdoc[\"#{pkey}\"] = document.fetch(\"#{pkey}\")\n end\n end\n end\n\t\t\tresp['response']['docs'] = solr_objects\n\t\t\treturn resp\n\t\tend",
"def reset_collection\n LogMessage.collection.drop\n create_collection\n end",
"def name_references(collection)\n target.try(:name_references, collection) || []\n end",
"def store_in(name)\n self.collection_name = name.to_s\n set_collection\n end",
"def store_in(name)\n self.collection_name = name.to_s\n set_collection\n end",
"def removeCollection(collection)\n collection.drop\n end",
"def db_prefix\n /mongo_/\n end",
"def removeMappedToField(collection)\n collection.update_many(\n {},\n {\n :$unset => {\n :mappedTo => \"\"\n }\n }\n ) \n end",
"def chrono_rename_temporal_indexes(name, new_name)\n on_temporal_schema do\n temporal_indexes = indexes(new_name)\n temporal_indexes.map(&:name).each do |old_idx_name|\n if old_idx_name =~ /^index_#{name}_on_(?<columns>.+)/\n new_idx_name = \"index_#{new_name}_on_#{$~['columns']}\"\n execute \"ALTER INDEX #{old_idx_name} RENAME TO #{new_idx_name}\"\n end\n end\n end\n end",
"def save_tag(sent_tags)\n current_tags = self.tags.pluck(:tag_name) unless self.tags.nil?\n old_tags = current_tags - sent_tags\n new_tags = sent_tags - current_tags\n\n old_tags.each do |old|\n self.tags.delete PostTag.find_by(tag_name: old)\n end\n\n new_tags.each do |new|\n new_tag = Tag.find_or_create_by(tag_name: new)\n self.tags << new_tag\n end\n end",
"def flexi_collection_name\n self.name.parameterize\n end",
"def shortCollectionName(c)\n c.getName.split(',')[0].strip\nend",
"def full_collection_name(collection_name)\n \"#{@name}.#{collection_name}\"\n end",
"def sanitize_name\n self.name = Tag.sanitize_name(self.name)\n end",
"def assign_tags(tag_titles)\n update_counters_before\n tags = tag_titles.split(\",\").strip\n tags.each do |t|\n post_tag = self.post_type.post_tags.where(name: t).first_or_create!\n self.term_relationships.where({term_taxonomy_id: post_tag.id}).first_or_create!\n end\n update_counters(\"tags\")\n end",
"def tag_list=(tags_string)\r\n \tself.blog_post_taggings.destroy_all\r\n \t\r\n \ttag_names = tags_string.split(\",\").collect{ |s| s.strip }.uniq\r\n \t\r\n \ttag_names.each do |tag_name|\r\n \t blog_post_tag = BlogPostTag.find_or_create_by_name(tag_name)\r\n \t blog_post_tagging = self.blog_post_taggings.new\r\n \t blog_post_tagging.blog_post_tag_id = blog_post_tag.id\r\n \tend\r\n end",
"def update_document_tags(doc)\n idx = fetch_index(doc.repo)\n return nil if (! idx)\n # no way to check if doc exists in index! just call replace (add/del)\n idx.replace(doc)\n # FIXME: update cached list of known tags, if cached\n end",
"def shrink(collection_or_table_names=nil)\n return unless is_mongodb\n creds=credentials()\n base_dir=VMC::KNIFE.get_mongodb_base_dir()\n instance_name=creds['name']\n dbpath=File.join(base_dir, instance_name, 'data') \n mongod_lock=File.join(dbpath,'mongod.lock')\n raise \"Can't shrink #{name}; the mongodb is currently running\" if File.exists?(mongod_lock) && File.size(mongod_lock)>0\n mongodump_exec=VMC::KNIFE.get_mongo_exec('mongodump')\n raise \"Can't find mongodump\" unless File.exist? mongodump_exec\n mongorestore_exec=VMC::KNIFE.get_mongo_exec('mongorestore')\n raise \"Can't find mongorestore\" unless File.exist? mongorestore_exec\n cmd = \"#{mongodump_exec} --dbpath #{dbpath}\"\n puts \"#{cmd}\"\n puts `#{cmd}`\n \n `rm -rf #{dbpath}`\n `mkdir #{dbpath}`\n cmd = \"#{mongorestore_exec} --dbpath #{dbpath} dump/\"\n puts \"#{cmd}\"\n puts `#{cmd}`\n `rm -rf dump`\n end",
"def rename_story\n\n end",
"def updateDB(dbName)\n puts \"Creating index on \" + CALDATE_COLLECTION\n @conn[dbName][CALDATE_COLLECTION].create_index({\"body.educationOrganizationId\" => Mongo::ASCENDING}, {:sparse => false })\nend",
"def collection_name_from_class_name(class_name)\n class_name.demodulize.underscore.pluralize.to_sym\n end",
"def taggable_name string\n string = string.downcase\n case string\n when 'article' then 'wiki article'\n when 'post' then 'blog post'\n else\n string\n end\n end",
"def teardown\n Mongoid::Clients.default.database.collection_names.each do |c|\n Mongoid::Clients.default[c].drop\n end\n end",
"def collection_name\n self.to_s.tableize\n end",
"def remove_tags(tags)\n\t\t\[email protected] do |u|\n\t\t\t\tu.delete(:tags => tags)\n\t\t\t\tu.add(:idenity => 1)\n\t\t\tend\n\t\t\treturn nil\n\t\tend",
"def tag_names=(tag_names)\n self.tags = tag_names.map do |tag_name|\n tag_name.strip!\n self.tags.find_or_create_by(name: tag_name)\n end\n end",
"def collection_name\n @collection_name ||= self.to_s.tableize.gsub(/\\//, '.')\n end",
"def to_mongo(doc)\n\n # vertical tilde and ogonek to the rescue\n\n rekey(doc) { |k| k.to_s.gsub(/^\\$/, 'ⸯ$').gsub(/\\./, '˛') }\n end",
"def collection_names\n Rails.logger.info \"DEPRECATED: collection_names is deprecated, please refactor\"\n @collection_names ? @collection_names : self.collections.collect(&:name).join(\",\")\n end",
"def swap_app_ids(dbName)\n @conn = Mongo::Connection.new(DB_HOST)\n @db = @conn.db(SYSTEM_DB_NAME)\n @dbTenant = @conn.db(dbName)\n\n to_swap = [\n {\"app_name\" => \"inBloom Data Browser\", \"placeholder\" => \"DATABROWSER_ID_PLACEHOLDER\"},\n {\"app_name\" => \"inBloom Dashboards\", \"placeholder\" => \"DASHBOARD_ID_PLACEHOLDER\"},\n ]\n apps = @db.collection('application')\n app_auths = @dbTenant.collection('applicationAuthorization')\n\n to_swap.each do |app|\n puts \"Swapping IDs for #{app['app_name']}\"\n app_ent = apps.find_one({\"body.name\" => app['app_name']})\n if app_ent\n app_id = app_ent['_id']\n update_count = 0\n app_auths.find(\"body.appIds\" => app['placeholder']).each do |row|\n app_ids = row['body']['appIds']\n app_ids[app_ids.index(app['placeholder'])] = app_id\n app_auths.update({\"_id\" => row[\"_id\"]}, {\"$set\" => {\"body.appIds\" => app_ids}})\n update_count = update_count + 1\n end\n puts \"\\tUpdate #{update_count} entries\"\n end\n end\nend",
"def add_tag_associations(tags)\n tags.each do |tag|\n t = Tag.find_by_tag(tag)\n if t\n self.tags << t\n else\n t = Tag.new(:tag => tag)\n self.tags << t if t.save\n end\n end \n end",
"def update_tags_from_instagram(instagram_tags)\n current_tags = Tag.joins(:photo_tags).where(:photo_tags => {:photo_id => self.id, :sticky => false})\n new_tags = instagram_tags.map do |tag|\n Tag.find_or_create_by_name(tag)\n end\n self.tags.destroy(*(current_tags - new_tags))\n self.tags += new_tags\n rescue ActiveRecord::RecordNotUnique\n Rails.logger.warn \"I violated a unique key constraint when updating photo tags\"\n end",
"def _collection(name)\n @collections[name] ||= Dynamodb::Collection.new(\n @client,\n Lotus::Model::Adapters::Dynamodb::Coercer.new(_mapped_collection(name)),\n name,\n _identity(name),\n )\n end",
"def orchestrate_collection_name\n ocollection\n end",
"def orchestrate_collection_name\n ocollection\n end",
"def collection_name\n singular == plural ? \"#{plural}_index\" : plural\n end",
"def collection_name\n singular == plural ? \"#{plural}_index\" : plural\n end",
"def save_tags(delete_old_tags = true)\n #delete all old tags\n if (delete_old_tags)\n PostTag.delete_all(post_id: @post.id)\n end\n #save new tags\n if (params[:tags].length > 0)\n tags = params[:tags].split(',').uniq\n tags.each do |tag_name|\n tag_name = tag_name.downcase.strip\n tag = Tag.find_or_initialize_by(title: tag_name, for: Tag::TYPE_POST)\n if (tag.save)\n #save linked table\n postTag = PostTag.create(post_id: @post.id, tag_id: tag.id)\n postTag.save\n end\n end\n end\n end",
"def reorder_fields(hash)\n hash = BSON::Document.new(hash)\n reordered = {}\n reordered['$ref'] = hash.delete('$ref')\n reordered['$id'] = hash.delete('$id')\n if db = hash.delete('$db')\n reordered['$db'] = db\n end\n\n reordered.update(hash)\n end",
"def merge_mongo_and_solr(collection, resp)\n solr_objects = resp['response']['docs']\n mkey,skey = @mongo_match_by.split(\"::\")\n collection.each_with_index do |document,index|\n mid = document.fetch(\"#{mkey}\")\n sdoc = solr_objects.find {|sd| sd[\"#{skey}\"] == \"#{mid}\"}\n if sdoc.nil?\n log.warn \"Solr document with #{skey}: #{mid} not found\"\n else\n for pkey in @mongo_projection_keys.split(\",\")\n if document.has_key?(\"#{pkey}\")\n sdoc[\"#{pkey}\"] = document.fetch(\"#{pkey}\")\n end\n end\n end\n end\n resp['response']['docs'] = solr_objects\n return resp\n end"
] | [
"0.6940573",
"0.5937969",
"0.5903214",
"0.5880829",
"0.56793594",
"0.5625939",
"0.5573838",
"0.5446834",
"0.5446834",
"0.542975",
"0.5377901",
"0.5377136",
"0.533312",
"0.5324209",
"0.53133667",
"0.52966696",
"0.5280025",
"0.52213675",
"0.5215603",
"0.5215603",
"0.5215603",
"0.5209997",
"0.518473",
"0.518473",
"0.5184049",
"0.51625454",
"0.51520264",
"0.5147304",
"0.5142895",
"0.51382434",
"0.51273215",
"0.5101041",
"0.5097106",
"0.5088058",
"0.50837606",
"0.5018851",
"0.4995242",
"0.4992506",
"0.4985394",
"0.49701282",
"0.4965909",
"0.49640778",
"0.49564716",
"0.49558964",
"0.49535677",
"0.49517202",
"0.49496448",
"0.4941397",
"0.4936977",
"0.49348852",
"0.49329746",
"0.49266508",
"0.49236563",
"0.4908438",
"0.4902701",
"0.48980394",
"0.4895535",
"0.48934823",
"0.48839188",
"0.48777494",
"0.487569",
"0.4871162",
"0.48608628",
"0.48603433",
"0.48603433",
"0.48502287",
"0.4848641",
"0.48422408",
"0.48385066",
"0.48173875",
"0.48126173",
"0.47992277",
"0.47969133",
"0.4792067",
"0.47898564",
"0.47894335",
"0.47866276",
"0.477906",
"0.47622252",
"0.47584787",
"0.47519848",
"0.47491986",
"0.4748605",
"0.47481903",
"0.47474515",
"0.47419226",
"0.47416568",
"0.47378063",
"0.47326106",
"0.4732557",
"0.472882",
"0.47249165",
"0.47179702",
"0.4714039",
"0.4714039",
"0.4701435",
"0.4701435",
"0.47006565",
"0.47003964",
"0.46973464"
] | 0.5879938 | 4 |
Return an array representation of this server version. | def to_a
to_array(@version)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _to_a\n @_to_a = self::VERSION.split('.')\n end",
"def versions\n versions = Backlogjp.base._command \"getVersions\", self.id\n versions.map {|hash| Version.new(hash)}\n end",
"def to_a\n [MAJOR, MINOR, PATCH]\n end",
"def to_a\n @to_a ||= [major, minor, patch, pre]\n end",
"def getVersions\r\n\t\t\t\t\treturn @versions\r\n\t\t\t\tend",
"def versions\n Version.all\n end",
"def versions\n info[:versions]\n end",
"def get_all_versions()\n return []\n end",
"def get_all_versions\n []\n end",
"def to_a\n [ @content_type, @extensions, @encoding, @system, @obsolete, @docs,\n @url, registered? ]\n end",
"def servers\r\n @servers.values\r\n end",
"def arrays\n @vectors\n end",
"def array\n self.allObjects\n end",
"def to_a\n Array.wrap(self)\n end",
"def to_rubygems_a\n [ name, version, platform_string ]\n end",
"def version_nodes\n design_response.map do |response|\n response.dig('node', 'versions', 'edges')\n end\n end",
"def to_a\n array\n end",
"def to_a\n [\n \"Auto Restart: #{automatic_restart}\",\n \"Case Sensitivity: #{case_sensitive_matching}\",\n \"Hashtag TTL: #{tag_time_to_live_in_seconds}\",\n \"Storage Type: #{hashtag_storage_class}\",\n \"Streaming Endpoint: #{streaming_endpoint}\",\n \"Valid Keys: #{is_valid?}\",\n \"Log Device: #{log_capture_device == STDOUT ? 'console' : log_capture_device}\"\n ]\n end",
"def to_a\n [major, minor, patch, pre].compact\n end",
"def version\n values = {}\n ring.servers.each do |server|\n values[server.name.to_s] = server.alive? ? server.request(:version) : nil\n end\n values\n end",
"def to_s\n @@version ||= [ MAJOR, MINOR, PATCH ] * '.'\n end",
"def to_ary\n [ self ]\n end",
"def all_versions\n r = []\n raw['update'].each do |h|\n r << h['version']\n end\n AssUpdater::AssVersion.convert_array r\n end",
"def to_array\n\n [\n @seconds,\n @minutes,\n @hours,\n @days,\n @months,\n @weekdays,\n @monthdays,\n @timezone ? @timezone.name : nil\n ]\n end",
"def versions\n service_config.keys\n end",
"def to_rubygems_a\n [name, version, platform_string]\n end",
"def content_versions\n return @content_versions\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 versions\n registered_versions.keys\n end",
"def array\n raise \"Not implemented\"\n end",
"def to_a\n [self]\n end",
"def encode_to_array\n components = []\n components << [self.class.id, @channel, @payload.bytesize].pack(PACK_CHAR_UINT16_UINT32)\n components << self.class.encoded_payload(@payload)\n components << FINAL_OCTET\n components\n end",
"def to_a\n @size_dep.depend\n array = []\n Volt.run_in_mode(:no_model_promises) do\n attributes.size.times do |index|\n array << deep_unwrap(self[index])\n end\n end\n array\n end",
"def to_a\n [ self ]\n end",
"def to_ary\n self.map{|result| result}\n end",
"def array()\n\t\t@array\n\tend",
"def versions\n JSON.parse(RestClient.get(\"#{VERSION_URL}/.json\", self.default_headers))[\"versions\"].collect { |v| v[\"id\"] }.uniq\n end",
"def versions_dataset\n if versionable?\n internal_versions_dataset\n else\n self.class.where(:version_id => self.version_id).order(:version_number).reverse\n end\n end",
"def array\n @@array\n end",
"def marshal_dump\n [@version]\n end",
"def to_s\n @version\n end",
"def to_s\n @version\n end",
"def to_ary\n self.to_a\n end",
"def to_s\n @version\n end",
"def versions\n @versions ||= Versions.new(self)\n end",
"def versions\n @versions ||= Versions.new(self)\n end",
"def versions\n # TODO make this a collection proxy, only loading the first, then the\n # rest as needed during iteration (possibly in chunks)\n return nil if @archived\n @versions ||= [self].concat(CloudKit.storage_adapter.query { |q|\n q.add_condition('resource_reference', :eql, @resource_reference)\n q.add_condition('archived', :eql, 'true')\n }.reverse.map { |hash| self.class.build_from_hash(hash) })\n end",
"def to_ary\n self.to_a\n end",
"def to_a\n @vector\n end",
"def to_a; Array(force) end",
"def marshal_dump\n [version]\n end",
"def to_a\n [self]\n end",
"def dump\r\n [\" minor version: #{@minor}\", \" major version: #{@major}\"]\r\n end",
"def all_versions\n [document.version, *all_preceding_versions]\n end",
"def vservers\n @vservers=get_endpoint('vservers').keys\n end",
"def all\n all_versions.map{|v| self[v]}\n end",
"def to_ary\n\t self.values\n\t end",
"def entries\n return Array(@entries)\n end",
"def to_ary\n [\"#{id}: #{description}\", @raw_data]\n end",
"def versions\n @versions ||= run( :versions, '--bare' ).lines.map( &:chomp )\n end",
"def serialize_array\n `self.serializeArray()`.map { |e| Hash.new(e) }\n end",
"def versions\n self.apar_defect_version_maps.map { |m| m.version }\n end",
"def to_a; [Array]; end",
"def to_s\n to_ary\n end",
"def to_a\n [status.to_i, headers.to_h, body.to_s]\n end",
"def to_a\n [ self ]\n end",
"def contact_methods_as_array\n JSON.parse(self.contact_methods)\n end",
"def get_version_info\n if defined?(Sensu::Enterprise::VERSION)\n [\"enterprise\", Sensu::Enterprise::VERSION]\n else\n [\"core\", Sensu::VERSION]\n end\n end",
"def to_array\n [@id, @username, @password, @role]\n end",
"def to_array\n @array ||= begin\n array = to_hash.kind_of?(Array) ? to_hash : [to_hash]\n array.compact\n end\n end",
"def server_version\n ServerVersion.new(server_info[\"version\"])\n end",
"def to_ary\n entries\n end",
"def to_a\n return @parts.to_a.dup\n end",
"def list_liveservers\n @admin.getClusterMetrics.getLiveServerMetrics.keySet.to_a\n end",
"def versions\n self.class.where(id: self._id)\n end",
"def to_array\n self.collect{|k,v| v}\n end",
"def name_servers\n Array(@gapi.name_servers)\n end",
"def to_a\n @entries.values\n end",
"def to_array(version)\n array = version.split(\".\").map {|n| (n =~ /^\\d+$/) ? n.to_i : n }\n if array.last =~ /(\\d+)([\\-\\+])/\n array[array.length-1] = $1.to_i\n array << $2\n end\n array\n end",
"def to_array(version)\n array = version.split(\".\").map {|n| (n =~ /^\\d+$/) ? n.to_i : n }\n if array.last =~ /(\\d+)([\\-\\+])/\n array[array.length-1] = $1.to_i\n array << $2\n end\n array\n end",
"def to_a; [self] end",
"def to_a; [self] end",
"def servers\n @servers.keys\n end",
"def array\n @array\n end",
"def to_a\n [@global_options,@command,@command_options,@arguments]\n end",
"def to_a\n [status, to_h]\n end",
"def fetch_versions\n http_get(\"#{host}/#{Configuration.versions_file}\").body\n end",
"def to_ary\n [couchdb_uri, database, auth_uri, authz_couch, sql_database, superuser_id].compact\n end",
"def to_a\n [value, timestamp]\n end",
"def player_version\n version = []\n adverts.each do |content_break|\n version << content_break.map do |advert|\n advert.match(/(rs|pv)=(.*?)\\//)[1, 2]\n end\n end\n version\n end",
"def to_a \n return @data\n end",
"def ver\n @values['ver']\n end",
"def to_a()\n end",
"def versions\n vars = api.get_config_vars(app).body\n _, versions_data = vars.detect {|k,v| k == 'HEROKU_CONFIG_VERSIONS'}\n\n if versions_data\n versions = JSON.parse(Zlib::Inflate.inflate(Base64.decode64(versions_data)))\n\n display(\"Saved config versions for #{app}: \")\n versions.keys.each do |version|\n time = Time.strptime(version, \"%Y%m%d%H%M%S\", Time.now.utc)\n display(\"#{version} (saved on #{time.to_s})\")\n end\n else\n display(\"#{app} has no versioned config vars.\")\n end\n end",
"def to_response\n []\n end",
"def versions_as_list(version)\n versions = []\n if not version.nil?\n 1.upto(version) {|i| versions << i}\n end\n versions\n end",
"def getVersionedObjects\n readVersionedObjects\n\n return @VersionedObjects\n end",
"def vertices\n to_a\n end",
"def servers\n server_structs.map do |server|\n inspect_server(server)\n end\n end"
] | [
"0.6914009",
"0.6495592",
"0.6490487",
"0.63712704",
"0.63600886",
"0.6288458",
"0.6220673",
"0.60777134",
"0.6066185",
"0.6053287",
"0.6012424",
"0.6006785",
"0.600157",
"0.59971744",
"0.59907997",
"0.5983766",
"0.598161",
"0.595839",
"0.59453535",
"0.5934606",
"0.5929137",
"0.59233576",
"0.5918321",
"0.58944315",
"0.58606154",
"0.5842571",
"0.5840855",
"0.5838137",
"0.58018273",
"0.58004135",
"0.57881206",
"0.5787405",
"0.57822436",
"0.57647675",
"0.56842655",
"0.56832534",
"0.5680624",
"0.56650764",
"0.5656253",
"0.56523025",
"0.56517756",
"0.56517756",
"0.5643406",
"0.56311023",
"0.56288636",
"0.56288636",
"0.5628534",
"0.56195176",
"0.5616703",
"0.56124634",
"0.5610242",
"0.55930316",
"0.5590384",
"0.5575594",
"0.55684686",
"0.556846",
"0.55673856",
"0.55624604",
"0.55616283",
"0.5550681",
"0.5525454",
"0.55165267",
"0.54871315",
"0.54868513",
"0.5485829",
"0.54650515",
"0.54639816",
"0.5454626",
"0.5451575",
"0.5450913",
"0.5449748",
"0.5445684",
"0.54438835",
"0.54314786",
"0.5409306",
"0.5409017",
"0.54073614",
"0.54005486",
"0.5392882",
"0.5392882",
"0.5389168",
"0.5389168",
"0.53822255",
"0.5378498",
"0.5377987",
"0.5365311",
"0.53619415",
"0.5354352",
"0.5350375",
"0.5343071",
"0.53399396",
"0.53388435",
"0.5329594",
"0.53216964",
"0.53199697",
"0.53146577",
"0.53139997",
"0.5311812",
"0.53092337"
] | 0.77772266 | 1 |
Return a string representation of this server version. | def to_s
@version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n self.version.to_s\n end",
"def to_s\n @version\n end",
"def to_s\n \"<Version #{number}>\"\n end",
"def to_s\n version = get_version_string\n version << \"-#{get_pre_string}\" unless @pre == nil\n version << \"+#{get_build_string}\" unless @build == nil\n version\n end",
"def to_s\n \"#{output}\\n[#{version}]\"\n end",
"def versionString()\n\t\t\t\treturn \"#{major}.#{minor}.#{build}\"\n\t\t\tend",
"def to_s\n @@version ||= [ MAJOR, MINOR, PATCH ] * '.'\n end",
"def to_s\n getUIversion.to_s\n end",
"def to_s\n getUIversion().to_s\n end",
"def to_s\n getUIversion().to_s\n end",
"def to_s\n getUIversion().to_s\n end",
"def to_s\n getUIversion().to_s\n end",
"def to_s\n getUIversion().to_s\n end",
"def to_s\n self.api_version\n end",
"def version\n @version_helper.to_s\n end",
"def version\n @version_helper.to_s\n end",
"def to_s\n\t\tgetUIversion().to_s\n\tend",
"def to_s\n\t\tgetUIversion().to_s\n\tend",
"def version\n build_string\n end",
"def version\n super.to_s\n end",
"def version\n super.to_s\n end",
"def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end",
"def to_s\r\n \"#{@major}.#{@minor}\"\r\n end",
"def info_string\n \"Rodsec v#{VERSION}\"\n end",
"def inspect\n\t\t\trval = super\n\t\t\treturn rval unless self.structure_version\n\t\t\tvstring = \"%d.%d\" % [ self.structure_version, self.data_version ]\n\t\t\treturn rval.sub( />$/, \"; version: #{vstring}>\" )\n\t\tend",
"def to_s\n raise_on_bad_version_status\n\n str = +''\n str << self.version << ' ' << self.status_code << ' ' << self.status_mesg << \"\\r\\n\"\n str << self[:headers].to_s if self[:headers].given?\n str << self.body\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end",
"def server\n @server.to_s\n end",
"def to_s\n return \"#{namespace}:#{project}:#{component}:#{version}\"\n end",
"def get_server_version\n server_info[:server_version]\n end",
"def version\n [@major_version, @minor_version].join('.')\n end",
"def to_s\n \"#{@major}.#{@minor}.#{@update} Build #{@build}\"\n end",
"def dump\r\n [\" minor version: #{@minor}\", \" major version: #{@major}\"]\r\n end",
"def ver\n if v = version\n str = +\"#{program_name} #{[v].join('.')}\"\n str << \" (#{v})\" if v = release\n str\n end\n end",
"def to_s\n @to_s ||= [@major, @minor, @tiny].join(\".\")\n end",
"def to_s\n \"Version => #{@version}, SessionObj => #{@session}, Response => #{@response}\"\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n \"#{path} | #{native_revision_identifier}\"\n end",
"def to_s\n return '' if name.nil?\n return name if version.nil?\n return \"#{name}-#{version}\" if arch.nil?\n \"#{name}-#{version}-#{arch}\"\n end",
"def to_s\n return self.get_info()\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def to_s\n @string\n end",
"def version\n @version ||= exec('SHOW server_version')[0]['server_version'].split[0]\n end",
"def inspect\n \"#{@type} #{@version}\"\n end",
"def to_version_string(version)\n version = version.to_s\n if version.match(/\\./)\n version\n else\n from_version_code(version).to_s\n end\n end",
"def server_version\n ServerVersion.new(server_info[\"version\"])\n end",
"def get_version\n\t\tself.dev_stage.blank? ? dev_stage_string = \"\" : dev_stage_string = self.dev_stage + \" \"\n\t\treturn dev_stage_string + self.maj_version.to_s + \".\" + self.min_version.to_s\n\tend",
"def to_s\n \"#{@name}: #{@gemset_versions.inspect}\"\n end",
"def to_s\n toString()\n end",
"def to_s\n stringify\n end",
"def to_s\n full\n end",
"def to_s\n \"#<#{self.class.name}:0x#{object_id.to_s(16).rjust(14, \"0\")} host='#{client.host}'>\"\n end",
"def to_s\n v = [major, minor, patch].compact.join('.')\n v += \"-#{pre}\" if pre\n v\n end",
"def to_s\n s = []\n s << \"#{title} v#{version}\"\n s << \"\"\n s << \"#{summary}\"\n s << \"\"\n s << \"contact : #{contact}\"\n s << \"homepage : #{homepage}\"\n s << \"repository : #{repository}\"\n s << \"authors : #{authors.join(',')}\"\n s << \"package : #{name}-#{version}\"\n s << \"requires : #{requires.join(',')}\"\n s.join(\"\\n\")\n end",
"def version\n (version_from_class.to_f / 10).to_s\n end",
"def to_s\n %(#{host_name} (#{ipaddress}) - #{operating_system})\n end",
"def to_s\n string\n end",
"def version_name\n self.class.version_names.join('_').to_sym unless self.class.version_names.blank?\n end",
"def to_s\n format(\"%d.%d\", @major, @minor)\n end",
"def to_s\n\t\t\t@string\n\t\tend",
"def to_s\n minor ? \"#{@major}-#{Patch.pad_minor(@minor)}\" : \"#{@major}\"\n end",
"def to_s\n \"v=#{@version} #{@rules.join(' ')}\"\n end",
"def full\n @version\n end",
"def version\n case @version\n when Module\n \"#{@version::Major}.#{@version::Minor}.#{@version::Release}\"\n when Proc # not sure about this\n @version.call\n when NilClass\n 'unknown'\n else\n @version\n end\n end",
"def to_s\n \"#<Xcode #{version.to_s}>\"\n end",
"def to_s\n [@host, @rpc_port].join(':')\n end",
"def to_s\n toString\n end",
"def server_version\n status['value']['build']['version']\n end",
"def to_s\n @string ||= Builder::ToString.new(self).string\n end",
"def version\n VERSION\n end",
"def to_s\n \"#{@distro.capitalize} #{@product.gsub(/_/, ' ').capitalize} #{@version}\"\n end",
"def to_s\n self.inspect\n end",
"def server_version\n db.server_version(@opts[:server])\n end",
"def to_s\n ['S', revision, nt_authority, nt_non_unique, uuids].join('-')\n end",
"def API_version(options={})\n return \"#{@major}.#{@minor}\"\n end",
"def to_s\n \"Id: #{vm_identifier}, Launched at: #{created_at}, Time limit: #{time_limit}, \"\n \"SSH address: #{public_host}:#{public_ssh_port}\"\n end",
"def to_s\n to_h.to_s\n end",
"def name_with_version\n if self.version.nil?\n return name\n else\n return [name, version].join(':')\n end\n end",
"def to_s\n\t\t\t\"#{host}:#{port}\"\n\t\tend",
"def to_s\n @str\n end",
"def to_s\n @str\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n return @version\n end",
"def version\n @version\n end",
"def to_s\n return \"\\nStatus:\\t\\t#{@status}\\nTitle:\\t\\t#{@title}\\n\" + \n \"Message:\\t#{@message}\\nHelp:\\t\\t#{@help}\"\n end"
] | [
"0.8146219",
"0.8031185",
"0.784821",
"0.75688654",
"0.7506059",
"0.7424028",
"0.73196304",
"0.724541",
"0.7165139",
"0.7165139",
"0.7165139",
"0.7165139",
"0.7165139",
"0.7062053",
"0.70005435",
"0.70005435",
"0.69932",
"0.69932",
"0.6988285",
"0.6888626",
"0.6888626",
"0.6863858",
"0.6821577",
"0.67797923",
"0.6732207",
"0.6713894",
"0.6697897",
"0.6697897",
"0.6696907",
"0.66960865",
"0.6693179",
"0.66374195",
"0.6630966",
"0.6630577",
"0.6615266",
"0.6611517",
"0.6599805",
"0.6591697",
"0.6587004",
"0.6587004",
"0.6587004",
"0.6587004",
"0.6560481",
"0.65489113",
"0.6532728",
"0.64960593",
"0.64960593",
"0.64960593",
"0.64960593",
"0.64933354",
"0.6486206",
"0.64668095",
"0.6433003",
"0.6408968",
"0.64000666",
"0.63665235",
"0.6364085",
"0.6362512",
"0.63523597",
"0.6343952",
"0.6343523",
"0.63317305",
"0.6329175",
"0.6320999",
"0.62874323",
"0.6276393",
"0.626555",
"0.62537825",
"0.6247961",
"0.62396",
"0.62374425",
"0.62303126",
"0.62241215",
"0.6224096",
"0.62183595",
"0.6214434",
"0.6212903",
"0.6211451",
"0.62023336",
"0.6201643",
"0.6186447",
"0.6179924",
"0.6161519",
"0.61588734",
"0.6158829",
"0.6137653",
"0.61365694",
"0.61365694",
"0.6133806",
"0.6133806",
"0.6133806",
"0.6133806",
"0.6133806",
"0.6133806",
"0.6133806",
"0.6133806",
"0.6133806",
"0.6126988",
"0.61264884"
] | 0.8252398 | 1 |
Returns true if any elements include mod symbols (, +) | def elements_include_mods?(*elements)
elements.any? { |n| n =~ /[\-\+]/ }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SimpleSymbols(str)\n things = str.split(\"\")\n\n things.each_with_index do |unit, idx|\n if unit =~ /[a-z]/\n return false if things[idx - 1] != \"+\" || things[idx + 1] != \"+\"\n end\n end\n\n true\nend",
"def SimpleSymbols(str)\n alphabet = ('a'..'z').to_a\n str_array = str.split(//)\n str_array.each_with_index do |i, index|\n if alphabet.include?(i)\n return false if index == 0 || index == str_array.count-1\n return false if (str_array[index-1] != '+') || (str_array[index+1] != '+')\n end\n end\n true\nend",
"def check_operator_symbol(symbol)\n \n symbol_array = ['+', '-', '*', '/']\n \n symbol_array.each do |sym|\n if symbol.to_s.split('').include?(sym) == true\n return true\n break\n else\n return false\n end\n end\nend",
"def simpleSymbols(str)\n\tstr = str.split('')\n\tstr.map.with_index{|char,i| \n\t\tif(char =~ /[a-zA-Z]/)\n\t\t\treturn false if str.index(char) == 0\n\t\t\tif(str[i - 1] != \"+\" || str[i + 1] != \"+\")\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t}\n\treturn true\nend",
"def SimpleSymbols(str)\n\n # code goes here\n possible = str.scan(/.?[a-z]./)\n matches = str.scan(/\\+[a-z]\\+/)\n if possible == matches\n true\n else\n false \n end\nend",
"def SimpleSymbols(str)\n\n #1. surround the string by ='s\n #2. begin looping\n #3. look for letters\n #4. check if letters surround by a + on both sides\n #5. return false if they aren't\n #6. end loop\n #7. return true\n\n str = '=' + str + '='\n\n (0..str.length-1).each do |i|\n if /[a-zA-Z]/.match(str[i])\n if str[i-1] != '+' or str[i+1] != '+'\n return false\n end\n end\n end\n return true\n\nend",
"def SimpleSymbols(str)\n values = str.scan(/\\+\\w\\+/)\n if values.count > 0\n puts true\n else\n puts false\n end\nend",
"def SimpleSymbols(str)\n letters = str.scan(/[a-z]/)\n str.scan(/\\+[a-z]\\+/).count == letters.size ? true : false\nend",
"def SimpleSymbols(str)\n if str =~ /[a-zA-Z]/ && str != \"\"\n \ti = 1\n \twhile i < str.length\n \t if str[i-1] != \"+\" || str[i + 1] != \"+\"\n \t \treturn false\n else\n \t \treturn true \n \t end\n \t i += 1\n # code goes here\n end\n end\nend",
"def is_operator?(x)\n #x.size == 1 && ( x == '+' || x == '-' || x == '*' || x =='/')\n x =~ /^[\\+\\-\\*\\/]$/\nend",
"def parseElement?(string)\n return string.start_with?(\"~\") ? false : true\n end",
"def SimpleSymbols(str)\n return false if !str.index(/[A-Za-z]/) or str.empty?\n str.gsub!(/(\\+[A-Za-z])+\\+/,'')\n return false if str.index(/[A-Za-z]/)\n return true\nend",
"def include_atoms?(atoms_arr)\n atoms_arr.each do |a|\n return false if !include_atom?(a)\n end\n true\n end",
"def valid_contents?(arr)\n arr.each { |e| return false unless (1..@size_pow).include?(e) }\n true\n end",
"def has_operators?(str)\n true if /[*\\-\\+\\/]/ =~ str\n end",
"def contains_special(str)\n if str.include? ('!') or str.include? ('#') or str.include? ('$')\n true\n else\n false\n end\nend",
"def operation?(ch)\n [ :+, :-, :*, :/].include?(ch.to_sym)\n end",
"def only_symbols?(*args)\n symbols = args.select { |_| _.is_a? Symbol }\n if symbols.length == args.length\n return true\n end\n false\n end",
"def has_more_operations?\n expression.match(/\\D/)\n end",
"def instruction?\n not elements.select { |e| e.respond_to?(:to_bin) }.empty?\n end",
"def only_symbols?(text)\n text.is_a?(String) && text.present? && text.remove(SYMBOLS).blank?\n end",
"def contains_sigle?(sigle, list)\n list.each do |s|\n if(same_module?(sigle, s))\n return true\n end\n end\n return false\n end",
"def string_check(elem)\n (('a'..'z').to_a + ('A'..'Z').to_a).each { |k| return true if elem.include?(k) }\n false\n end",
"def operator?(str)\n return ['+', '-', '*', '/', '%', '^'].include?(str)\n end",
"def contains_special?(string)\n if string.include?(\"!\") || string.include?(\"#\") || string.include?(\"$\")\n true\n else\n false\n end\nend",
"def is_numeric?\n for c in self.gsub('.', '').gsub('-', '').scan(/./)\n return false unless (0..9).to_a.map { |n| n.to_s }.include?(c)\n end\n return true\n end",
"def contains_special(string)\n if (string.include?('!') || string.include?('#') || string.include?('$'))\n true\n else\n false\n end\nend",
"def containsSpecial(password)\n if password.include?(\"!\") || password.include?(\"$\") || password.include?(\"#\")\n puts \"true\"\n else\n puts \"false\"\n end\nend",
"def expression_has_valid_structure? expression\n return if expression.size == 0\n\n return unless ['-', '1', '2', '3', '4', '5', '6', '7', '8', '9'].include? expression[0]\n\n return if expression[0] == '-' && !['1', '2', '3', '4', '5', '6', '7', '8', '9'].include?(expression[1])\n\n expression.each_with_index do |value, index|\n if ['+', '/', '*', '-'].include?(value) && !['-', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'].include?(expression[index + 1])\n return\n elsif value == '-' && !['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'].include?(expression[index + 1])\n return\n end\n end\n\n true\nend",
"def only_numbers_in_my_array?(isbn_array)\n #join array to apply regex functionality\n nums_only = isbn_array.join(\"\")\n true if nums_only =~ /\\D/\nend",
"def day_sym_elem?(day)\n return DAY_SYM_SEQ.include?(day)\nend",
"def begins_with_r(array)\n array.each { |element| return false if element.start_with?(\"r\") == false }\n true\nend",
"def begins_with_r (arr)\n arr.all? { |element| element.start_with?('r') }\nend",
"def subsetOf(mod)\n found = true\n @genes.each{|gene|\n unless mod.includes(gene)\n found = false\n end\n }\n return found\n end",
"def is_op(str)\n\t['+', '-', '^', '=', '<', '>'].include?(str)\nend",
"def does_not_contain_special(str)\n if str.include? ('!') or str.include? ('#') or str.include? ('$')\n false\n else\n true\n end\nend",
"def includes?(text)\n text = [text] unless text.respond_to? :each\n lines[4..].select { |l| l.start_with? \"+\" }.any? { |l| text.any? { |t| l.include? t } }\n end",
"def wc_equals(str, pat)\n return false if pat.size != str.size\n\n idx = 0\n pat.each_char do |ch|\n return false if (str[idx] != ch) && (ch != '.')\n\n idx += 1\n end\n true\nend",
"def symbols?\n sort == ::SYMBOLS\n end",
"def forward_strand?\n @strand == '+'\n end",
"def does_not_contain_special str\n !(str.include?(\"#\") || str.include?(\"!\") || str.include?(\"$\"))\n end",
"def begins_with_r(array)\n array.all? do |tool|\n tool.start_with?(\"r\")\nend\nend",
"def prime_chars? (arr)\n\tarr.each_char.with_index {|a, b| a + b}\nend",
"def got_three?(arr)\n !!(arr.map(&:to_s).join =~ /(.)\\1\\1/)\nend",
"def has_characters?(*args)\n characters = args.select { |_| not _.is_a? Symbol }.join('')\n if characters.empty?\n return false\n end\n true\n end",
"def i?(v)\n !!(v =~ /^[-+]?[0-9]+$/)\n end",
"def begins_with_r(arr)\n arr.all? { |element|\n element[0]==\"r\"\n }\nend",
"def run_module?( mod, page )\n return false if mod.issue_limit_reached?\n\n elements = mod.info[:elements]\n return true if !elements || elements.empty?\n\n elems = {\n Element::LINK => page.links.any? && @opts.audit_links,\n Element::FORM => page.forms.any? && @opts.audit_forms,\n Element::COOKIE => page.cookies.any? && @opts.audit_cookies,\n Element::HEADER => page.headers.any? && @opts.audit_headers,\n Element::BODY => !page.body.empty?,\n Element::PATH => true,\n Element::SERVER => true\n }\n\n elems.each_pair { |elem, expr| return true if elements.include?( elem ) && expr }\n false\n end",
"def expands?\r\n\t\treturn PeriodicTable.atomic_number(element) > 13\r\n\tend",
"def prime_chars?(array_of_strings)\n\tif array_of_strings.length == 1 \n\t\tstring = array_of_strings[0]\n\t\tsum = 0 + string.length\n\telse\n\t\tsum = 0 + array_of_strings.join.length\n\tend\n\tfinal_output = true\n\tfor i in 2..sum\n\t\tfinal_output = false if sum % i == 0 && sum != i \n\tend\n\tfinal_output = false if sum == 1 || sum == 0\n\tfinal_output\nend",
"def no_repeat?(year)\n chars_seen = []\n\n years.to_s.each_char do |char|\n return false if chars_seen.include?(char)\n chars_seen << char\n end\n\n return true \nend",
"def contains_product?(line) \n line.include?(TOKEN)\n end",
"def operator?(str)\n if str == \"+\" || str == \"-\" || str == \"*\" || str == \"/\" || str == \"%\" || str == \"^\"\n\t\t\treturn true\n\t\tend\n\n\t\treturn false\n end",
"def repeating?\n symbols[0] == symbols[1]\n end",
"def doesNotContainSpecial(userID)\n if !userID.include?(\"!\") && !userID.include?(\"#\") && !userID.include?(\"$\")\n puts \"true\"\n else\n puts \"false\"\n end\nend",
"def check_include\n runs = 100000\n string = '1;3@5~7]9>' * 50\n chars = [0x0A, # \\n\n 0x21, # !\n 0x23, # #\n 0x24, # $\n 0x25, # %\n 0x26, # &\n 0x2A, # *\n 0x2B, # +\n 0x2D, # -\n 0x3A, # :\n 0x3C, # <\n 0x3D, # =\n 0x3E, # >\n 0x40, # @\n 0x5B, # [\n 0x5C, # \\\n 0x5D, # ]\n 0x5E, # ^\n 0x5F, # _\n 0x60, # `\n 0x7B, # {\n 0x7D, # }\n 0x7E # ~\n ]\n measure \"\\n-> include @ #{runs} : \" do\n runs.times do\n 0.upto(string.length - 1) do |pos|\n chars.include?(string[pos].ord)\n end\n end\n end \nend",
"def begins_with_r(tools)\n tools.each do |x|\n if x[0] != 'r'\n return false\n end\n end\n return true\nend",
"def parse_addop()\n\t\tif(next_TokenGrabbed(\"+\") or next_TokenGrabbed(\"-\"))\n\t\ttrue\n\telse\n\t\tfalse\n\tend\nend",
"def array_of_fixnums?(array)\n for element in array\n unless element.is_a? Fixnum\n return false\n end\n end\n return true\nend",
"def valid_symbol?(symbol)\n return false if [].include?(symbol)\n true\n end",
"def contains_any(str, fragments)\n return false unless Regexp.union(fragments)&.match?(str)\n true\n end",
"def valid?\n invalid_strings = %w[ab cd pq xy]\n invalid_strings.each do |x|\n return false if include?(x)\n end\n\n true\n end",
"def item_included?(str, arr)\n arr.each do |item|\n return true if item == str\n end\n false\nend",
"def contains_any(str, fragments)\r\n return false unless Regexp.union(fragments) =~ str\r\n true\r\n end",
"def does_not_contain_special?(string)\n if string.include?(\"!\") || string.include?(\"#\") || string.include?(\"$\")\n false\n else\n true\n end\nend",
"def mod?\n @data['mod']\n end",
"def repeats?(year)\n x = []\n year.to_s.each_char do |a|\n return false if x.include?(a)\n x << a\n end\n return true\nend",
"def include_char?(char)\n return false unless char.respond_to?(:each_byte)\n\n char.each_byte do |b|\n return include?(b)\n end\n end",
"def operand?(str)\n #true if str contains only [0-9]\n 0 == (str =~ /^\\d+$/)\n end",
"def =~(p0) end",
"def =~(p0) end",
"def =~(p0) end",
"def infix\n infixes = %w[to and or + - * / ^ mod <= >= < > is in] +\n ['not in', 'is not']\n\n infixes.include?(peek.value)\n end",
"def begins_with_r(array)\n array.each do |item|\n if item[0] != \"r\"\n return false\n end\n end\n\n true\nend",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def include?(p0) end",
"def is_addop(c)\n ADDOPS.include?(c)\nend",
"def is_addop(c)\n ADDOPS.include?(c)\nend",
"def begins_with_r (arr)\n arr.all? {|x| x.start_with?(\"r\")}\nend",
"def include?(elem)\n @elements.include?(elem)\n end",
"def begins_with_r(arr)\n arr.each do |word|\n \tif word[0] != 'r'\n \t\treturn false\n \tend\n end\n return true\nend",
"def check_str(str)\n num=[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"0\"]\n new_str=str.split(\"\")\n new_str.each do |n|\n if num.include?(n)\n return true\n end\n end\n return false\nend",
"def binary_multiple_of_4?(s)\n return false if s.empty?\n\n not_valid_symbol_position = s =~ /[^0,1]/\n return false unless not_valid_symbol_position.nil?\n\n\n number = s.to_i(2)\n (number % 4 == 0) ? true : false\nend",
"def carets_are_leading?(path)\n !path.split('.').any? {|s| s.match(/.+\\^|\\^$/) }\n end",
"def num?(ary)\n\t\ts=\"0123456789abcdef\"\n\t\tradix=10 #default\n\t\tstr=ary[0]\n\t\tif(str[0]=='#') #radix prefix\n\t\t\tradix={'b'=>2,'o'=>8,'d'=>10,'x'=>16}[str[1]]\n\t\t\treturn false if radix.nil?\n\t\t\tstr=str[2...str.size]\n\t\tend\n\t\tif(str[0]=='-'||str[0]=='+') #signum\n\t\t\tstr=str[1...str.size] #single '+'/'-' was allowed\n\t\tend\n\t\tstr.size!=0 or return false #literal has at lease one digit\n\t\ts=s[0...radix] #digits must be less than radix\n\t\tfor ch in str.chars.map{|v|v}\n\t\t\tch.downcase!\n\t\t\treturn false if s.index(ch).nil?\n\t\tend\n\t\treturn true\n\tend",
"def contain_a(elements)\n elements.select do |i|\n has_a = []\n if i.chars.include?\"a\" \n has_a.unshift(i)\n end\n end\nend",
"def identical_symbols(row_or_column)\n row_or_column[0] * 3 == row_or_column\n end",
"def includes_number?(string)\n digits = ('0'..'9').to_a\n string.each_char do |char|\n return true if digits.include?(char)\n end\n false\nend",
"def scan_for_plus(token); end",
"def no_repeat?(year)\n str=year.to_s\n res=[]\n str.each_char do |ch|\n return false if res.include?(ch)\n res << ch\n end\n return true\nend",
"def empty?() @symbols.empty? end",
"def is_greek_only?(input)\n !!(input.match(GREEK_ALPHABET_PLUS_SYMBOLS))\n end",
"def include_variable?\n @elements.any?{|elt| elt.include_variable?}\n end",
"def is_multiply(latex, step)\n\tlatex[step+1..step+4].join == \"cdot\"\nend",
"def checkForNumbers(word)\n numbers = \"1234567890\"\n word.each_char do |char|\n if numbers.include?(char)\n return true\n end\n end\n return false\nend"
] | [
"0.6363892",
"0.6182549",
"0.6128964",
"0.6115055",
"0.60915154",
"0.6007713",
"0.5977526",
"0.5951359",
"0.59122527",
"0.5882929",
"0.57054305",
"0.5633246",
"0.5627606",
"0.55858517",
"0.55675143",
"0.55118847",
"0.5475426",
"0.5460246",
"0.54600555",
"0.54427755",
"0.5425152",
"0.5383185",
"0.537181",
"0.5305649",
"0.530359",
"0.52919495",
"0.52739173",
"0.52659357",
"0.5253404",
"0.5240307",
"0.52326435",
"0.5216849",
"0.5211762",
"0.52104586",
"0.51924133",
"0.5188381",
"0.5181875",
"0.51572454",
"0.51459557",
"0.5124979",
"0.5109088",
"0.51082695",
"0.51052576",
"0.5100729",
"0.50917256",
"0.5087187",
"0.5065305",
"0.50615454",
"0.504849",
"0.5047747",
"0.50440717",
"0.5032",
"0.5031147",
"0.5027939",
"0.5023436",
"0.5021326",
"0.5016849",
"0.5009524",
"0.50046676",
"0.5004239",
"0.5001879",
"0.4997434",
"0.49973908",
"0.4996649",
"0.49960774",
"0.49908763",
"0.49819118",
"0.49709848",
"0.49692342",
"0.49606425",
"0.49606425",
"0.49606425",
"0.49537793",
"0.4952459",
"0.49511248",
"0.49507365",
"0.49507365",
"0.49507365",
"0.49507365",
"0.49507365",
"0.4944143",
"0.4944143",
"0.49368602",
"0.49350795",
"0.4929685",
"0.49170431",
"0.49165773",
"0.4913018",
"0.49089503",
"0.4907868",
"0.4901334",
"0.48966682",
"0.48954406",
"0.4893641",
"0.4887846",
"0.48841795",
"0.48822376",
"0.4871924",
"0.48684672"
] | 0.80756885 | 1 |
Converts argument to an array of integers, appending any mods as the final element. | def to_array(version)
array = version.split(".").map {|n| (n =~ /^\d+$/) ? n.to_i : n }
if array.last =~ /(\d+)([\-\+])/
array[array.length-1] = $1.to_i
array << $2
end
array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_int_array(input)\n input.chars.to_a.collect { |x| x.to_i }\n end",
"def array_to_integer_array_method\n @card_integer_array = []\n @card_array.each do |integer|\n new_integer = integer.to_i\n @card_integer_array << new_integer\n end\n return @card_integer_array\n end",
"def my_array_modification_method(source, thing_to_modify)\n\tanswer = []\n\tsource.each do |x|\n\t x = x + thing_to_modify if x.class == Fixnum\n\t answer << x\n\tend\n\treturn answer\nend",
"def array_to_integer_array_method(card_array)\n card_integer_array = []\n card_array.each do |integer|\n new_integer = integer.to_i\n card_integer_array << new_integer\n end\n return card_integer_array\nend",
"def cast_array_for_args\n <<-CODE\n next_int;\n c->args = _int;\n t1 = stack_pop();\n if(REFERENCE_P(t1) && object_kind_of_p(state, t1, global->tuple)) {\n t1 = array_from_tuple(state, t1);\n } else if(!REFERENCE_P(t1) || !object_kind_of_p(state, t1, global->array)) {\n t2 = array_new(state, 1);\n array_set(state, t2, 0, t1);\n t1 = t2;\n }\n stack_push(t1);\n c->args += N2I(array_get_total(t1));\n CODE\n end",
"def my_array_modification_method(source, thing_to_modify)\n new_array = []\n source.each do |num|\n if num.is_a? Integer\n num += thing_to_modify\n new_array.push num\n else\n new_array.push num \n end\n end\n return new_array\nend",
"def my_array_modification_method(source, thing_to_modify)\n mod_array = Array.new\n source.each { |x|\n if x.is_a? Integer\n mod_array << x += thing_to_modify\n else\n mod_array << x\n end\n }\n mod_array\nend",
"def my_array_modification_method(source, thing_to_modify)\n source.map! do |x|\n \t\tif x.is_a?(Integer) \n \t\t\tx + thing_to_modify\n \t\telse\n \t\t\tx\n \t\tend\n \tend\nend",
"def array_converter *arrays\n arrays.flatten.map(&:to_i)\nend",
"def my_array_modification_method(source, thing_to_modify)\n return source.map! {|i| i.is_a?(Integer) ? (i + thing_to_modify) : i}\nend",
"def my_array_modification_method(ary, number)\n\tif !number.is_a?(Fixnum)\n\t\traise ArgumentError.new('The Second Argument Should be a Fixnum')\t\t\n\tend\n\n\treturn ary.collect! {|element| element.is_a?(Fixnum) ? (element + number) : element}\n\nend",
"def to_int\n raise ArgumentError, 'Would return an Array' unless returns_one?\n\n roll\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! do |n|\n if n.is_a? Integer\n n += thing_to_modify\n else\n n\n end\n end\nend",
"def digit_list(input)\n\n new_arr = input.to_s.chars\n \n new_arr.map {|element| element = element.to_i }\nend",
"def my_array_modification_method(array, number)\n\tarray = array.map! do |x|\n\t\tif x.is_a?(Integer)\n\t\t\tx + number\n\t\telse\n\t \tx\n\t end\nend\nend",
"def my_array_modification_method(source, thing_to_modify)\n source.map {|element| element.is_a?(Integer)? element + thing_to_modify : element}\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! { |i| i.is_a?(Integer)? (i + thing_to_modify) : i }\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.map!{ |item|\n item += thing_to_modify if item.is_a?(Integer)\n item\n }\nend",
"def input_as_array\n array = number.split('')\n\n return array.collect! { |x| x.to_i }\n end",
"def array_converter *arrays\n\n arrays.flatten.map(&:to_i)\n\n # The code above is the same as the code below. arrays.each would not work because\n # it will try and convert the whole array to an int, which is not possible. map will go \n # throught each item in an array and convert them to an int.\n # \n # arrays.flatten.map { |e| i.to_i }\n # \n # OR\n # \n # arrays.flatten.map do |i|\n # i.to_i\n # end\nend",
"def my_array_modification_method!(source, thing_to_modify)\n\n for x in 0..(source.length - 1)\n if source[x].to_s =~ /\\A[-+]?[0-9]+\\z/\n source[x] = source[x].to_i + thing_to_modify.to_i\n end\n end\n # p source\n return source\nend",
"def my_array_modification_method!(source, thing_to_modify)\n\nreturn source.collect! { |item| item.is_a?(Fixnum) ? item + thing_to_modify : item}\nend",
"def to_digit_array\n self.to_s.each_char.map(&:to_i)\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! {|elem|\n if elem.is_a?(Integer)\n elem += thing_to_modify\n else\n elem\n end\n }\nend",
"def my_array_modification_method!(source, num_of_pets_wanted)\n source.map! do |x|\n if x.is_a?(Integer)\n x + num_of_pets_wanted\n else\n x\n end\n end\n return source\nend",
"def my_array_modification_method!(array, numadd)\n array.map!{|element| element.is_a?(Integer) ? element + numadd : element}\nend",
"def my_array_modification_method!(arry, num)\n p arry.map! {|x|\n if x.is_a?(Integer)\n x + num\n else\n x\n end\n }\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! { |x|\n if x.is_a?(Integer)\n x + thing_to_modify\n else\n x\n end\n }\nend",
"def xyz(a)\narray = []\narray[0] = a.to_i\narray[1] = a.to_i - 1\narray[2] = a.to_i - 2\nputs array\n\nend",
"def to_array(a)\n a.map { |i| i }\nend",
"def to_array(a)\n a.map { |i| i }\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.dup\n i_want_pets.map!{|number| number.is_a?(Integer) ? number + 1 : number}\nend",
"def my_array_modification_method(source, n)\n source.map{|i| \n if i.is_a? Integer \n i += n \n end \n i}\n p source\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! do |element|\n if element.class == Fixnum\n element += thing_to_modify\n else\n element = element\n end\n end\nend",
"def put_int_array(arr)\n put_int arr.length, *arr\n self\n end",
"def my_array_modification_method(source, thing_to_modify)\n new_array = []\n source.each { |a|\n if a.is_a? Integer\n new_array << a + thing_to_modify\n else\n new_array << a\n end\n }\n source.replace(new_array)\nend",
"def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |element, i|\n source[i] += thing_to_modify if element.is_a?(Numeric)\n end\n source\n end",
"def get_multi_line_input_int_arr(original_filename)\n get_input_str_arr(original_filename).map(&:to_i)\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! { |word| word.is_a?(Integer) ? word + thing_to_modify : word }\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! do |x| \n if x.is_a?(Integer) then x += thing_to_modify else x end\n end\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item|\n if item.is_a? Integer\n item += thing_to_modify\n else item\n end\n end\n return source\nend",
"def my_array_modification_method!(list, quantity_to_add)\n list.map! do |x|\n if x.is_a? Integer\n x = x + quantity_to_add\n end\n x\n end\n return list\nend",
"def argv_prepare(numbers) # zamiana elementów tablicy na liczby\n numbers.map do |e|\n e.to_i\n end\nend",
"def argv_prepare(numbers) # zamiana elementów tablicy na liczby\n numbers.map do |e|\n e.to_i\n end\nend",
"def argv_prepare(numbers) # zamiana elementów tablicy na liczby\n numbers.map do |e|\n e.to_i\n end\nend",
"def main(arr, mod_len)\n arr.sum.to_s[0...mod_len].to_i\nend",
"def convert_array_elements_to_i(array)\n for i in 0..array.length-1\n array[i] = array[i].to_i\n end\nend",
"def numbers_array\n num_array = Array.new\n input_as_array.each { |n| num_array << get_number(n) }\n\n return num_array\n end",
"def my_array_modification_method!(source, thing_to_modify)\n\n source.map! do |x|\n\n if x.class == Fixnum\n\n x + thing_to_modify\n else\n x\n end\n\n end\n\nend",
"def my_array_modification_method!(array, increase)\r\n array.map! do |x| \r\n if x.is_a? Integer\r\n x += increase\r\n else \r\n x\r\n end\r\n end\r\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.map! {|var|\n if var.is_a?(Integer)\n var + thing_to_modify\n else\n next var\n end\n }\n p source\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.each_index do |x|\n if (source[x].is_a?(Integer))\n source[x]+=thing_to_modify\n end\n end\n source\nend",
"def string_to_array\r\n @input.chars.map {|e| e.to_i}\r\n end",
"def my_array_modification_method!(array, number)\n array.map! {|x|\n x.is_a?(Integer) ? (x + number): x}\nend",
"def my_array_modification_method!(input_array, add_num)\n input_array.each_with_index do |item, index|\n if item.is_a?(Numeric)\n input_array[index] += add_num\n end\n end\nreturn input_array\nend",
"def sequence(int, int1)\n arr = []\n int.times {|i| arr << int1 + (int1 * i) }\n arr\nend",
"def my_array_modification_method!(source, thing_to_modify)\nsource.map! do |x|\n if x.is_a?(Integer)\n x + num_of_pets_wanted\n else\n x\n end\n end\n return source\nend",
"def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |value, index|\n if value.is_a? Integer\n source[index] += thing_to_modify\n end\n end\nend",
"def IntToVector (input)\n\tdigits = []\n\ttemp = input\n\t\n\twhile (temp > 0)\n\t\tdigits.push(temp % 10)\n\t\ttemp /= 10\n\tend\n\t\n\tdigits.reverse!\n\treturn digits\nend",
"def double_numbers(array)\n new_array = []\n\n array.each do |number|\n new_array << number *= 2\n end\n return new_array\nend",
"def my_array_splitting_method(source)\n new_array=[[], []]\n \n source.each do |x|\n if x.is_a?(Integer)\n new_array[0]<<x\n else \n new_array[1]<<x\n end\n end\nnew_array\n\nend",
"def coerce(other)\n return [other, self.to_i]\n end",
"def my_array_modification_method(source, thing_to_modify)\n\t# #source[-1],source[2] = source[-1] + 1, source[2 ]+ 1 \n # source.collect! do |item|\n # # # if item.is_a?(Integer)\n # # # item = item + thing_to_modify\n # # # else \n # # # \titem = item\n # # end\n \n # item.is_a?(Integer) ? item = item + thing_to_modify : item = item\n # end\n source.collect! { |item| item.is_a?(Integer) ? item += thing_to_modify : item = item } \n source\nend",
"def split_to_array(number)\n number.to_s.chars.map(&:to_i)\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item| # Array#collect! overrides original array\n if item.is_a? Integer #searches for integers and modifies them\n item + thing_to_modify\n else\n item #leaves non intgers alone\n end\n end\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |item| # Array#collect! overrides original array\n if item.is_a? Integer #searches for integers and modifies them\n item + thing_to_modify\n else\n item #leaves non intgers alone\n end\n end\nend",
"def array_converter(*args)\n \nend",
"def *(second)\n ret = []\n case second\n when Integer\n second.times { |i| ret += dup }\n when String\n return join(second)\n when Array\n each { |x| second.each { |y| ret << [x,y].flatten } }\n else\n raise TypeError.new(\"can't convert #{second.class} into Integer\")\n end\n return ret\n end",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |x| \n if x.is_a?(Integer) \n x+=thing_to_modify\n else x\n end\n end\n\n\nend",
"def my_array_modification_method!(source, thing_to_modify)\n source.collect! do |x| \n if x.is_a?(Integer) \n x+=thing_to_modify\n else x\n end\n end\n\n\nend",
"def double_numbers(input_array)\n doubled_array =[]\n input_array.each {|num| doubled_array << num*2} \n doubled_array\nend",
"def array_to_int(arr)\n\tarr_int = 0\n\ti = 1\n\t\n\tarr.reverse.each do |d|\n\t\tarr_int += d*i\n\t\ti *= 10\n\tend\n\t\n\treturn arr_int\nend",
"def array_to_int(arr)\n\tarr_int = 0\n\ti = 1\n\t\n\tarr.reverse.each do |d|\n\t\tarr_int += d*i\n\t\ti *= 10\n\tend\n\t\n\treturn arr_int\nend",
"def increase_array_values(array, number)\n array.map {|num| num + number}\nend",
"def double_array(input_array)\n \n double_array = []\n \n input_array.each do |number|\n double_array << number *= 2\n end\n return double_array\n\nend",
"def index_multiplier_method\n #@multiplied_integer_array = []\n @reversed_array.each_with_index do |value, index|\n if index.odd? == true\n value = value * 2\n @multiplied_integer_array << value\n else\n value = value\n @multiplied_integer_array << value\n end\n end\n return @multiplied_integer_array\n end",
"def to_a\n [modulus, exponent]\n end",
"def my_array_modification_method!(array, num)\n array[2] = array[2] + num\n array[-1] = array[-1] + num\n array\nend",
"def custom_multiply(array,number)\n new_array = []\n number.times {new_array+=array}\n return new_array\nend",
"def get_single_line_input_int_arr(original_filename, separator: ',')\n get_input_str(original_filename).split(separator).map(&:to_i)\nend",
"def add1(arr)\n new_arr = arr.map do |num|\n num += 1\n end\n new_arr\nend",
"def encode integer_array\n integer_array = integer_array.clone\n bits = BitArray.new\n integer_array.each do |x|\n q = x/@M\n q.times {bits.push 1}\n bits.push 0\n r = x % @M\n (@b-1).downto(0){|i| bits.push r[i]}\n end\n bits\n end",
"def sum_array( numbers )\r\n numbers.inject(0, :+)\r\nend",
"def add_numbers(arr)\n return nil if arr.length < 1\n return arr[0] if arr.length == 1\n arr[0] += add_numbers(arr[1..-1])\n end",
"def multiply_arrnums_by_index(numbers) # array of ints\n new_array = [] # empty array\n i = 0 # start at indice 0\n while i < numbers.length\n new_array << numbers[i] * i # shovel value of int val of the indice * the indice\n # numb_to_mult = numbers[i]\n # numb_multd = numbers[i] * numb_to_mult\n # new_array << numb_multd\n i += 1 # next iteration\n end\n return new_array\nend",
"def prepend(array, num)\noutput = []\noutput << num\noutput += array\nreturn output\nend",
"def my_array_modification_method!(i_want_pets, thing_to_modify)\n i_want_pets.map! {|element| element.is_a?(Integer)? (element + thing_to_modify) : element}\nend",
"def my_array_modification_method!(array, num)\n array.map! { |x| x.is_a?(Integer)? (x + num) : x } #attempted .each, but the values were not updating, seems to work with map.\nend",
"def my_array_modification_method(source, thing_to_modify)\n source.map!{ |x| (x==/\\d/ ? x+thing_to_modify : x) }\nend",
"def to_array(version)\n version.split(/[.-]/).map do |x|\n if x =~ /\\A.*([0-9]+).*\\Z/\n $1.to_i\n else\n 0\n end\n end\nend",
"def add_all_numbers(array)\n array.inject(:+)\nend",
"def repa(array, x)\n result = []\n (1..x).each do\n result.concat(array)\n end\n return result\nend",
"def make_int_list(args)\n head = Node.new args[0]\n args[1..args.length - 1].each { |arg| head.append arg }\n head\nend",
"def to_number_array(string_array)\nstring_array.map {|x| x.to_i }\ni = 0\nstring_array.map {|x| x + i += 0.1}\nend",
"def append(arr, number)\n arr << number\n return arr\nend",
"def append(array,num)\n output = array\n output << num\nreturn output\nend",
"def r(range)\n range.to_a\nend",
"def sum_mix(arr)\n arr.map! { |x| x.to_i }\n arr.sum\nend",
"def +(arg)\n arg =\n case arg\n when Array\n raise ArgumentError, \"Must be three numbers contained\" unless arg.size==3\n arg\n else\n raise ArgumentError, \"Accept only Array of three numbers\"\n end\n new_hsb = self.hsb.zip(arg, [360, 101, 101]).map { |x, y, div| (x + y) % div }\n self.class.new *new_hsb\n end"
] | [
"0.67339206",
"0.6533739",
"0.64756244",
"0.6439487",
"0.64330786",
"0.6400515",
"0.63602626",
"0.6280674",
"0.6242669",
"0.62163883",
"0.6194731",
"0.61423916",
"0.61012995",
"0.60715914",
"0.60610086",
"0.6035379",
"0.6028871",
"0.60274017",
"0.60091686",
"0.5998907",
"0.5998551",
"0.5998222",
"0.59880084",
"0.5952353",
"0.59342843",
"0.5933848",
"0.5930561",
"0.5925956",
"0.59169626",
"0.58829844",
"0.58829844",
"0.5841025",
"0.58364165",
"0.5827856",
"0.58139795",
"0.57984006",
"0.57976073",
"0.57924724",
"0.57823104",
"0.5774947",
"0.5773699",
"0.57735646",
"0.57623833",
"0.57623833",
"0.57623833",
"0.5746517",
"0.57425225",
"0.57330585",
"0.5725349",
"0.5725061",
"0.57217735",
"0.5712256",
"0.5710846",
"0.56764036",
"0.56632894",
"0.565338",
"0.5631709",
"0.56287324",
"0.56199944",
"0.56194264",
"0.5584322",
"0.5558315",
"0.5544602",
"0.5529983",
"0.5511418",
"0.5511418",
"0.55014604",
"0.55010206",
"0.54993856",
"0.54993856",
"0.54979753",
"0.5493148",
"0.5493148",
"0.549152",
"0.547051",
"0.5460837",
"0.5457989",
"0.5452904",
"0.5451281",
"0.54239196",
"0.54202056",
"0.541611",
"0.5413311",
"0.5412293",
"0.5412086",
"0.54115456",
"0.54114956",
"0.54104",
"0.5406555",
"0.53916174",
"0.5376334",
"0.53638846",
"0.5363131",
"0.53570276",
"0.53560567",
"0.5350735",
"0.53487855",
"0.5338581",
"0.53367347"
] | 0.5410432 | 88 |
not sure what should be passed here | def initialize(params = {})
@params = params
@bunny_options = RabbitMQOptions.new(params)
@rabbit = RabbitMQClient.new(@bunny_options.to_hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def schubert; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def param; end",
"def param; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def formation; end",
"def custom; end",
"def custom; end",
"def who_we_are\r\n end",
"def suivre; end",
"def weber; end",
"def apply\n\t\t\n\tend",
"def apply\n\t\t\n\tend",
"def refutal()\n end",
"def processor; end",
"def arguments; end",
"def arguments; end",
"def arguments; end",
"def probers=(_arg0); end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def implementation; end",
"def implementation; end",
"def handle; end",
"def operations; end",
"def operations; end",
"def strategy; end",
"def terpene; end",
"def guct\n end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def call\n\n\tend",
"def call\n\n\tend",
"def stderrs; end",
"def intensifier; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def extra; end",
"def trd; end",
"def operation; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end"
] | [
"0.76063484",
"0.6932786",
"0.6925768",
"0.67931837",
"0.67931837",
"0.67931837",
"0.67931837",
"0.65811515",
"0.65811515",
"0.6571968",
"0.6571968",
"0.6571968",
"0.6571968",
"0.6571968",
"0.6571968",
"0.6571968",
"0.6571968",
"0.6540821",
"0.6519084",
"0.6519084",
"0.64943624",
"0.64875174",
"0.64541125",
"0.64194345",
"0.64194345",
"0.639303",
"0.63847333",
"0.6383297",
"0.6383297",
"0.6383297",
"0.63771343",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6347925",
"0.6305052",
"0.6305052",
"0.6274479",
"0.6253097",
"0.6253097",
"0.62266886",
"0.61912537",
"0.6170276",
"0.61670786",
"0.61670786",
"0.61670786",
"0.61670786",
"0.61670786",
"0.61670786",
"0.61670786",
"0.61670786",
"0.61670786",
"0.6163819",
"0.6163819",
"0.6162424",
"0.6139635",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6118317",
"0.6117205",
"0.6100926",
"0.60962355",
"0.6093189",
"0.6093189",
"0.6093189",
"0.6093189"
] | 0.0 | -1 |
must have this method basically overwrite the original one no callback currently | def call(env)
logger(env)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callback &block\n super\n end",
"def callback &block\n super\n end",
"def callback_phase\n super\n end",
"def original; end",
"def callback\n end",
"def callbacks; end",
"def callbacks; end",
"def callback\n\n end",
"def original_method; end",
"def method_missing(method, *args, &block)\n super unless original_self\n original_self.send method, *args, &block\n end",
"def proxy\n super\n end",
"def wrapper; end",
"def callback\n\tend",
"def after_set_callback; end",
"def callback=(_arg0); end",
"def overrides; end",
"def delegating_method; end",
"def returns_original\n @returns_original = true\n self\n end",
"def call\n # implement in subclasses\n end",
"def overwrite?; end",
"def callback(&block)\n super do |*args|\n safe_deferrable_block(*args, &block)\n end\n end",
"def prepareForReuse; end",
"def post_process; end",
"def process_fix\n super\n end",
"def reset\n super\n end",
"def modify\n super\n end",
"def take_place\n super(1)\n end",
"def refutal()\n end",
"def original_result; end",
"def around_hooks; end",
"def custom; end",
"def custom; end",
"def extended(*) end",
"def proxy; self end",
"def overrides=(_arg0); end",
"def exec_fix\n super\n end",
"def callback\n false\n end",
"def private; end",
"def run\n super\n end",
"def run\n super\n end",
"def wrapped_in=(_arg0); end",
"def after_processing_hook; end",
"def extended( hooked_instance )\n\n super if defined?( super )\n \n end",
"def around_method name, &block\n original_method = instance_method name\n _redefine_method name do |*args|\n instance_exec original_method, *args, &block\n end \n end",
"def remote(*)\n super.tap do\n clear_changes_information\n end\n end",
"def after_generate_callbacks; end",
"def mirror_state\n super\n end",
"def old_sync=(_arg0); end",
"def without_revision(&block)\n class_eval do\n CALLBACKS.each do |attr_name|\n alias_method \"orig_#{attr_name}\".to_sym, attr_name\n alias_method attr_name, :empty_callback\n end\n end\n block.call\n ensure\n class_eval do\n CALLBACKS.each do |attr_name|\n alias_method attr_name, \"orig_#{attr_name}\".to_sym\n end\n end\n end",
"def invoke\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n raise 'must be implemented in subclasses'\r\n end",
"def source(override); end",
"def exec\n super\n end",
"def call() end",
"def recall; end",
"def pass_through\n super\n end",
"def receiver; end",
"def receiver; end",
"def receiver; end",
"def receiver; end",
"def receiver; end",
"def receiver; end",
"def reset!\n # this should be overridden by concrete adapters\n end",
"def special\n override\n end",
"def internal; end",
"def sync() end",
"def sync() end",
"def sync() end",
"def _run\n super.tap { reenqueue }\n end",
"def _after_update\n # SEQUEL5: Remove\n @this = nil\n end",
"def resume()\n #This is a stub, used for indexing\n end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def follow_meta_refresh_self=(_arg0); end",
"def old_sync; end",
"def override() # Note that despite the module.override, this still overrides\r\n puts \"CHILD override()\"\r\n end",
"def extend_object( hooked_instance )\n\n original_extend_object( hooked_instance )\n super if defined?( super )\n \n end",
"def after_appending( state )\n\t\t# Nothing to do\n\t\treturn nil\n\tend",
"def delegate_method; end",
"def patch=(_arg0); end",
"def after_each\n super if defined?(super)\n end",
"def sync; end",
"def call\n raise \"Must subclass and implement call\"\n end",
"def inherited\n super\n @run = false\n end",
"def before_appending( state )\n\t\t# Nothing to do\n\t\treturn nil\n\tend",
"def retain()\n res = super(self)\n end",
"def retain()\n res = super(self)\n end",
"def retain()\n res = super(self)\n end",
"def restore; end",
"def call(_rc)\n raise NotImplementedError\n end",
"def patch; end",
"def patch; end",
"def restore \n raise NotImplementedError.new\n end",
"def escaper=(_); end",
"def rewind()\n #This is a stub, used for indexing\n end",
"def altered()\n puts \"CHILD, BEFORE PARENT altered()\"\n super()\n puts \"CHILD, AFTER PARENT altered()\"\n end"
] | [
"0.6974545",
"0.6974545",
"0.67480576",
"0.6483268",
"0.6414559",
"0.6340521",
"0.6340521",
"0.6282671",
"0.62333894",
"0.61819166",
"0.61254835",
"0.61146003",
"0.611095",
"0.6098755",
"0.60951644",
"0.5990475",
"0.59362775",
"0.59290004",
"0.59221196",
"0.59192735",
"0.5868024",
"0.5855375",
"0.5847747",
"0.57795197",
"0.57703096",
"0.57678086",
"0.57216495",
"0.5711215",
"0.56942",
"0.5688945",
"0.56858397",
"0.56858397",
"0.5680759",
"0.5669735",
"0.56686074",
"0.56320435",
"0.5627618",
"0.56102103",
"0.56096554",
"0.56096554",
"0.56076956",
"0.5605448",
"0.560439",
"0.55951977",
"0.5590364",
"0.55618495",
"0.5557141",
"0.55512375",
"0.5550416",
"0.55454135",
"0.5544558",
"0.55321705",
"0.55289984",
"0.55245376",
"0.5513643",
"0.5510735",
"0.5510735",
"0.5510735",
"0.5510735",
"0.5510735",
"0.5510735",
"0.5510133",
"0.55098367",
"0.5504214",
"0.5503981",
"0.5503981",
"0.5503981",
"0.5500924",
"0.5494143",
"0.54939574",
"0.5492339",
"0.5492339",
"0.5492339",
"0.5492339",
"0.5492339",
"0.5492339",
"0.5492339",
"0.5492339",
"0.54893535",
"0.5487366",
"0.5481432",
"0.54731244",
"0.54723936",
"0.5472251",
"0.5470121",
"0.5468855",
"0.5453469",
"0.5448729",
"0.54474616",
"0.5441482",
"0.5440089",
"0.5440089",
"0.5440089",
"0.543952",
"0.54210836",
"0.5411733",
"0.5411733",
"0.5406269",
"0.5401922",
"0.5391477",
"0.5387199"
] | 0.0 | -1 |
GET /lendables/1 GET /lendables/1.xml | def show
@lendable = Lendable.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @lendable }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_listings_xml(url)\n @client.get_content(url)\n end",
"def index\n @cables = Cable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cables }\n end\n end",
"def index\n @leks = Lek.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @leks }\n end\n end",
"def index\n @lieus = Lieu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lieus }\n end\n end",
"def index\n @entries = @resource_finder.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def index\n @lookup_sets = LookupSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_sets }\n end\n end",
"def index\n\t@dl_types = DlType.paginate(:page=>params[:page]||1,:per_page=>20)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dl_types }\n end\n end",
"def index_loans_for_bundle\n @bundles = Bundle.find(params[:id])\n\n respond_to do |format|\n format.html { render 'loans/index'}\n format.xml { render :xml => @bundles }\n end\n end",
"def list(table)\n self.get(\"/#{table}\")\n end",
"def index\n @links = Link.find(:all,:conditions => [\"entity_id = ?\",@entity_id])\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @links.to_xml }\n end\n end",
"def list\n call(:get, path)\n end",
"def index\n @lancamentos = Lancamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lancamentos }\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end",
"def index\n @lists = List.find(:all)\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @lists }\n end\n end",
"def index\n @loans = Loan.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @loans }\n end\n end",
"def new\n @lendable = Lendable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lendable }\n end\n end",
"def show\n @lb202556 = Lb202556.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lb202556 }\n end\n end",
"def index\n @title = 'Tables'\n @tables = Table.all\n\n respond_to do |format|\n format.html {\n @tables_rabl = Rabl.render(@tables, 'tables/index', view_path: 'app/views', format: 'json')\n @guests_rabl = Rabl.render(Guest.attending, 'tables/guests', view_path: 'app/views', format: 'json')\n }\n format.json { render json: @tables }\n end\n end",
"def index\n @links = Link.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @links }\n end\n end",
"def index\n @lables = Lable.all\n end",
"def get_recycled_org_units(bookmark = '')\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/recyclebin/\"\n path += \"?bookmark=#{bookmark}\" if bookmark != ''\n _get(path)\n # GETS ONLY FIRST 100\nend",
"def index\n @thing_lists = ThingList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @thing_lists }\n end\n end",
"def path\n \"/{databaseId}/items/list/\"\n end",
"def index\n @meant_it_rels = MeantItRel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meant_it_rels }\n end\n end",
"def index\n @article_lists = ArticleList.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @article_lists }\n end\n end",
"def index\n @entity_end_point_rels = EntityEndPointRel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entity_end_point_rels }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @lsrs_soildata = LsrsSoil.order('SoilNamesTable')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lsrs_soildata }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @requests = Request.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @requests }\n end\n end",
"def index\n @labor_cost_lines = LaborCostLine.scoped\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @labor_cost_lines }\n end\n end",
"def index\n @link_types = LinkType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @link_types }\n end\n end",
"def show\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lyric }\n end\n end",
"def show\n @lyric = Lyric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lyric }\n end\n end",
"def index\n @resources = Resource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @resources }\n end\n end",
"def index\n @menu_items = uhook_find_menu_items\n\n respond_to do |format|\n format.html {} # index.html.erb \n format.xml {\n render :xml => @menu_items\n }\n end\n end",
"def index\n @links = @panel.links\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @links }\n end\n end",
"def index\n allow :get\n expires_in 60.seconds\n\n nodes = @kavlan.nodes_vlan(params[:vlan_id])\n result = {\n 'total' => nodes.length,\n 'offset' => 0,\n 'items' => nodes.map { |n| { 'uid' => n, 'vlan' => params[:vlan_id] } },\n 'links' => links_for_collection\n }\n\n result['items'].each do |item|\n item['links'] = links_for_item(item)\n end\n\n render_result(result)\n end",
"def show\n @lr40 = Lr40.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr40 }\n end\n end",
"def index\n @warehouse_lists = get_warehouse_lists(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @warehouse_lists }\n end\n end",
"def get_all_outypes\n path = \"/d2l/api/lp/#{$lp_ver}/outypes/\"\n _get(path)\nend",
"def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end",
"def index\n @accessories = Accessory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @accessories }\n end\n end",
"def show\n @lr70 = Lr70.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lr70 }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @directories }\n end\n end",
"def show\n @lb30 = Lb30.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lb30 }\n end\n end",
"def list(type, parameters)\n @type = type # Keep this around to structure the output\n @response = self.request(Net::HTTP::Get.new(\n \"/#{type}.#{Format}?#{parameters}\"\n ))\n self.to_s\n end",
"def list\n url = prefix + \"list\"\n return response(url)\n end",
"def index\n @taggables = Taggable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @taggables }\n end\n end",
"def index\n\t\t@people = Person.all\n\t\t# respond_to do |format|\n\t\t# \tformat.xml { send_data @entries.to_xml, :type => 'text/xml; charset=UTF-8;', :disposition => 'attachment; filename=entries.xml'}\n\t\t# end\n\tend",
"def list\n\t\t@employee = Employee.find(:all)\n\t\t@loanaccounts = Loanaccount.paginate :page => params[:page], :per_page => 10\t#Pagination\n \trespond_to do |format|\t\t\n format.html \n \t\t\tformat.xml { render :xml => @loanaccounts }\t\t#Render to XML File\n \tend\n\tend",
"def list(path)\n output { get(path) }\n end",
"def index \n hq_vlans = HqVlan.all(:order => :name)\n @objects = hq_vlans.paginate :page => params[:page], :per_page => 20\n respond_to do |format|\n format.html { render :template => 'reflected/index' }\n format.xml { render :xml => @objects }\n end\n end",
"def index\n @title = \"Indonesian Language Resources\"\n @resources = Resource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @resources }\n end\n end",
"def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end",
"def index\n @tipo_lancamentos = TipoLancamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tipo_lancamentos }\n end\n end",
"def list\n get('/')\n end",
"def list\n\t\t@hras = Hra.paginate :page => params[:page], :per_page => 10\t#Pagination\n \trespond_to do |format|\t\t\n \t\t format.html \n \t\t\tformat.xml { render :xml => @hras }\t\t#Render to XML File\n \tend\n\tend",
"def index\n @link_resources = LinkResource.where(lab: @lab)\n end",
"def index\n @nspirefiles = Nspirefile.all(:order => \"updated_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nspirefiles }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end",
"def index\n @sitelinks = Sitelink.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @sitelinks }\n end\n end",
"def index\n @entries = Entry.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def show\n @list = List.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @list }\n end\n end",
"def index\n @attr_types = AttrType.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @attr_types }\n end\n end",
"def get(path='', filter=nil)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n response = if filter\n categories = filter.categories.collect { |category| category.to_text }.join(',')\n attributes = filter.entities.collect { |entity| entity.attributes.combine.collect { |k, v| k + '=' + v } }.join(',')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = 'text/occi'\n headers['Category'] = categories unless categories.empty?\n headers['X-OCCI-Attributes'] = attributes unless attributes.empty?\n\n self.class.get(@endpoint + path, :headers => headers)\n else\n self.class.get(@endpoint + path)\n end\n\n response_msg = response_message response\n raise \"HTTP GET failed! #{response_msg}\" unless response.code.between? 200, 300\n\n Occi::Log.debug \"Response location: #{('/' + path).match(/\\/.*\\//).to_s}\"\n kind = @model.get_by_location(('/' + path).match(/\\/.*\\//).to_s) if @model\n\n Occi::Log.debug \"Response kind: #{kind}\"\n\n if kind\n kind.related_to? Occi::Core::Resource ? entity_type = Occi::Core::Resource : entity_type = nil\n entity_type = Occi::Core::Link if kind.related_to? Occi::Core::Link\n end\n\n Occi::Log.debug \"Parser call: #{response.content_type} #{entity_type} #{path.include?('-/')}\"\n collection = Occi::Parser.parse(response.content_type, response.body, path.include?('-/'), entity_type, response.headers)\n\n Occi::Log.debug \"Parsed collection: empty? #{collection.empty?}\"\n collection\n end",
"def index\n @entries = Entry.all;\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def loo_list(input={}, raw=false)\n response = get('mw/Argos/LOO.List', input, raw)\n end",
"def index\n #@histories = History.all\n @histories = History.find( :all, :limit => 100, :order => \"id DESC\" )\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @histories }\n end\n end",
"def index\n @runlists = Runlist.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @runlists }\n end\n end",
"def lws_api_get(path)\n # See also catalog_controller for use of ENV['LWS_...']\n url ||= ENV['LWS_API_URL']\n url ||= \"#{ENV['LWS_CORE_URL']}/api\" if ENV['LWS_CORE_URL']\n \n # http://localhost:8888/api/collections\n resp = Net::HTTP.get_response(URI.parse(\"#{url || 'http://127.0.0.1:8888/api'}#{path}\"))\n result = JSON.parse(resp.body)\n end",
"def index\n @help_offers = @job_request.help_offers\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @help_offers }\n end\n end",
"def index\n @liner_items = LinerItem.all\n end",
"def index\n @house_menus = HouseMenu.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @house_menus }\n end\n end",
"def index\n @l_inks = LInk.all\n end",
"def index\n @lessons = Lesson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lessons }\n end\n end",
"def index\n @oils = Oil.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @oils }\n end\n end",
"def index\n @l1s = L1.all\n end",
"def index\n @menus = Menu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @menus }\n end\n end",
"def index\n @menus = Menu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @menus }\n end\n end",
"def index\n @pools = Pool.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pools }\n end\n end",
"def show\n @shelf = Shelf.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shelf.to_xml(:include => :books) }\n end\n end",
"def index\n @servers = Server.beating\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @servers }\n end\n end",
"def index\n @statuses = Status.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @statuses }\n end\n end",
"def index\n @retain_node_selectors = RetainNodeSelector.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @retain_node_selectors }\n end\n end",
"def index\n @branches = @repository.branches\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @branches }\n end\n end",
"def index\n @taglines = Tagline.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @taglines }\n end\n end",
"def index\n @long_term_goals = LongTermGoal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @long_term_goals }\n end\n end",
"def show\n @lbd = Lbd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lbd }\n end\n end",
"def show\n @dl_type = DlType.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @dl_type }\n end\n end",
"def list\n get()\n end",
"def index\n @landings = Landing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @landings }\n end\n end",
"def index\n debugger\n @receitas = Receita.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receitas }\n end\n end",
"def index\n @labs = @course.labs.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @labs }\n end\n end",
"def index\n @diagrams = Diagram.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @diagrams }\n end\n end",
"def index\n\n @deadlines = Deadline.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @deadlines }\n end \n end",
"def index\n @league_items = LeagueItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @league_items }\n end\n end",
"def index\n @stylesheet = \"admin_menus\"\n @menus = Menu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @menus }\n end\n end"
] | [
"0.59151435",
"0.58259964",
"0.5727452",
"0.5639547",
"0.55827403",
"0.5566066",
"0.5522777",
"0.5484479",
"0.54842544",
"0.5460977",
"0.54559046",
"0.545203",
"0.54515165",
"0.5446914",
"0.54190123",
"0.5409285",
"0.54069895",
"0.54030013",
"0.5399312",
"0.5382163",
"0.53723973",
"0.53672296",
"0.5366435",
"0.534522",
"0.53451693",
"0.53440154",
"0.5338794",
"0.53264624",
"0.53211355",
"0.53211355",
"0.532105",
"0.5317928",
"0.53165436",
"0.5310974",
"0.5310974",
"0.5292889",
"0.5290478",
"0.52855736",
"0.5283996",
"0.5280146",
"0.5268353",
"0.52611",
"0.52599865",
"0.5252609",
"0.5245937",
"0.5236008",
"0.52156156",
"0.52056086",
"0.5204193",
"0.5200304",
"0.5194436",
"0.51802176",
"0.5179266",
"0.5166518",
"0.51652277",
"0.5163206",
"0.51569426",
"0.5154427",
"0.5153521",
"0.51409626",
"0.514041",
"0.51393336",
"0.51393336",
"0.51340955",
"0.51338357",
"0.5132911",
"0.5124643",
"0.5123004",
"0.5122878",
"0.5115496",
"0.51113844",
"0.51050436",
"0.51039857",
"0.510226",
"0.50912935",
"0.5090523",
"0.5089914",
"0.50865424",
"0.5085314",
"0.5081111",
"0.5080145",
"0.5080145",
"0.5079729",
"0.50761455",
"0.50740325",
"0.507002",
"0.50679964",
"0.5063941",
"0.5062364",
"0.5059851",
"0.5058327",
"0.5055855",
"0.50550187",
"0.5051216",
"0.5051112",
"0.5051002",
"0.50373834",
"0.50359476",
"0.5035251",
"0.50347865"
] | 0.6550243 | 0 |
GET /lendables/new GET /lendables/new.xml | def new
@lendable = Lendable.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @lendable }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @lb202556 = Lb202556.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lb202556 }\n end\n end",
"def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"def new\n @thing_list = ThingList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing_list }\n end\n end",
"def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end",
"def new\n @lookup_truthtable = LookupTruthtable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_truthtable }\n end\n end",
"def new\n @shelf = Shelf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shelf }\n end\n end",
"def new\n @entry = @resource_finder.new\n initialize_new_resource\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end",
"def new\n @lb30 = Lb30.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lb30 }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def create\n @lendable = Lendable.new(params[:lendable])\n\n respond_to do |format|\n if @lendable.save\n format.html { redirect_to(@lendable, :notice => 'Lendable was successfully created.') }\n format.xml { render :xml => @lendable, :status => :created, :location => @lendable }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lendable.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end",
"def new\n @menu = uhook_new_menu\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end",
"def new\n @pool = Pool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pool }\n end\n end",
"def new\n @lookup_source = LookupSource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_source }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @dl_type = DlType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dl_type }\n end\n end",
"def new\n @request = Request.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @browsenodeid = Browsenodeid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @browsenodeid }\n end\n end",
"def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end",
"def new\n @lote = Lote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lote }\n end\n end",
"def new\n @lancamento = Lancamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lancamento }\n end\n end",
"def new\n @action_list = ActionList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @action_list }\n end\n end",
"def new\n @lr70 = Lr70.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr70 }\n end\n end",
"def new\n @page_title = \"Task List New\"\n @task_list = TaskList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task_list }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @label_sheet }\n end\n end",
"def new\n @original_menu = OriginalMenu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @original_menu }\n end\n end",
"def new\n @lr40 = Lr40.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lr40 }\n end\n end",
"def new\n @lyric = Lyric.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lyric }\n end\n end",
"def new\n unless session[:admin]\n redirect_to lents_url\n return\n end\n\n @lent = Lent.new\n @free_cars = Car.where(condition: Car::Free).map{|x| x[:id]}\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lent }\n end\n end",
"def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lore }\n end\n end",
"def new\n @item = Item.factory('local')\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @tipo_lista = TipoLista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_lista }\n end\n end",
"def new\n @nspirefile = Nspirefile.new\n @categories = get_categories\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nspirefile }\n end\n end",
"def new\n @path = Path.new({:layer => @layer})\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @path }\n end\n end",
"def new\n @lek = Lek.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lek }\n end\n end",
"def new\n @list_view = ListView.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_view }\n end\n end",
"def new\n @lane = Lane.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lane }\n end\n end",
"def new\n @administration = Administration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administration }\n end\n end",
"def new\n @lotto_type = LottoType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lotto_type }\n end\n end",
"def new\n @lbd = Lbd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lbd }\n end\n end",
"def new\n @novel = Novel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @novel }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @link = Link.new :long => 'http://'\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end",
"def new\n @journal_line = JournalLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @journal_line }\n end\n end",
"def new\n @localmap = Localmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @localmap }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @system }\n end\n end",
"def new\n @wordlist = Wordlist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wordlist }\n end\n end",
"def new\n @bookmarklet = Bookmarklet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bookmarklet }\n end\n end",
"def new\n @lieu = Lieu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lieu }\n end\n end",
"def new\n @tbl_40_2554_i = Tbl402554I.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tbl_40_2554_i }\n end\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lease }\n end\n end",
"def new\n @draft_list = DraftList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @draft_list }\n end\n end",
"def new\n @local = Local.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @local }\n end\n end",
"def new\n @itemstable = Itemstable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @itemstable }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @stylesheet = \"admin_menus\"\n @menu = Menu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end",
"def new\n @page = @offering.pages.new\n session[:breadcrumbs].add \"New\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @models = self.class.model_class.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @models }\n end\n end",
"def new\n @children = Children.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @children }\n end\n end",
"def new\n @vlan = Vlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @vlan }\n end\n end",
"def new\n @list_cat = ListCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list_cat }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @software }\n end\n end",
"def new\n @holder = Holder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @holder }\n end\n end",
"def new\n @vlan = Vlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @vlan }\n end\n end",
"def new\n @lid = Lid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lid }\n end\n end",
"def new\n @resource = Resource.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @livingroom = Livingroom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @livingroom }\n end\n end",
"def new\n\t\t@list = List.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml\t{ render :xml => @list }\n\t\tend\n\tend",
"def new\n @kennel = Kennel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kennel }\n end\n end",
"def new\n @catalogs_priority = Catalogs::Priority.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalogs_priority }\n end\n end",
"def new\n @menu_item = uhook_new_menu_item\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu_item }\n end\n end",
"def new\n @mylist = Mylist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mylist }\n end\n end",
"def new\n @add_on = AddOn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @add_on }\n end\n end",
"def new\n @label = Label.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @label }\n end\n end",
"def new\n @label = Label.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @label }\n end\n end",
"def new\r\n @lineitem = Lineitem.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @lineitem }\r\n end\r\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @line_item }\n end\n end",
"def new\n @attr_type = AttrType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attr_type }\n end\n end",
"def new\n @journal = Journal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @journal }\n end\n end",
"def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end",
"def new\n @orderable = Orderable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @orderable }\n end\n end",
"def new\n @want = Want.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @want }\n end\n end",
"def new\n @whitelist = Whitelist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @whitelist }\n end\n end",
"def new\n @catalog = Catalog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalog }\n end\n end",
"def new\n @catalog = Catalog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catalog }\n end\n end",
"def new\n @resources_data = ResourcesData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resources_data }\n end\n end",
"def new\n @journalentry = Journalentry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @journalentry }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @line_item }\n end\n end",
"def new\n @todo_list = TodoList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @todo_list }\n end\n end",
"def new\n @page_title = t('branches.new.title')\n @branches = Branch.all \n @branch = Branch.new\n respond_to do |format|\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @branch }\n end\n end",
"def new\n @offering = Offering.new\n session[:breadcrumbs].add \"New\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @offering }\n end\n end",
"def new\n @menu = Menu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end",
"def new\n @tiny_resource = TinyResource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tiny_resource }\n end\n end"
] | [
"0.6501095",
"0.644611",
"0.64217705",
"0.6407091",
"0.6406053",
"0.6398388",
"0.637133",
"0.6356885",
"0.63413095",
"0.6338049",
"0.6263476",
"0.62181586",
"0.6214869",
"0.62112314",
"0.6208151",
"0.62009174",
"0.6196796",
"0.6182455",
"0.6174943",
"0.6174943",
"0.6174943",
"0.61673814",
"0.61527526",
"0.6139868",
"0.61388123",
"0.6136018",
"0.6135726",
"0.6119985",
"0.61142147",
"0.61136955",
"0.61115426",
"0.61020464",
"0.6099736",
"0.60994136",
"0.60980976",
"0.60962784",
"0.6091491",
"0.6073977",
"0.6072096",
"0.6070917",
"0.6065162",
"0.6063331",
"0.60578835",
"0.60560966",
"0.60471636",
"0.6046889",
"0.6046889",
"0.60402",
"0.6029578",
"0.60288304",
"0.60282165",
"0.6025774",
"0.60223675",
"0.60124505",
"0.60122865",
"0.6009291",
"0.6006254",
"0.60048014",
"0.5996654",
"0.59929204",
"0.59929204",
"0.5992629",
"0.59924096",
"0.59908646",
"0.5990634",
"0.5989153",
"0.5988171",
"0.598783",
"0.59872365",
"0.5984717",
"0.5984097",
"0.598059",
"0.5979034",
"0.59778714",
"0.59771657",
"0.59759116",
"0.5974143",
"0.59679437",
"0.5967519",
"0.5965489",
"0.5965489",
"0.59632957",
"0.5962723",
"0.5962723",
"0.5959343",
"0.59584063",
"0.5956503",
"0.5954151",
"0.5949697",
"0.5946304",
"0.5944839",
"0.5944839",
"0.5944492",
"0.5944139",
"0.59432",
"0.59407645",
"0.59351504",
"0.5934055",
"0.593372",
"0.5933685"
] | 0.72537094 | 0 |
POST /lendables POST /lendables.xml | def create
@lendable = Lendable.new(params[:lendable])
respond_to do |format|
if @lendable.save
format.html { redirect_to(@lendable, :notice => 'Lendable was successfully created.') }
format.xml { render :xml => @lendable, :status => :created, :location => @lendable }
else
format.html { render :action => "new" }
format.xml { render :xml => @lendable.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postEntityYext_list( entity_id, yext_list_id, description, name, type)\n params = Hash.new\n params['entity_id'] = entity_id\n params['yext_list_id'] = yext_list_id\n params['description'] = description\n params['name'] = name\n params['type'] = type\n return doCurl(\"post\",\"/entity/yext_list\",params)\n end",
"def addLogsBatchXML(collection=\"lclsLogs\", dizList, bulk: false)\n uri = URI.parse(\"http://#{@host}:#{@port}/solr/#{collection}/update\") \n # uri = URI.parse(\"http://psmetric04:8983/solr/lclsLogs/update\") \n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.path, 'Content-Type' => 'application/xml')\n req.body = formatLogBatchAsXML(dizList)\n # puts req.body \n # res = http.request(req, xml: formatLogBatchAsXML(dizList) )\n res = http.request(req)\n # puts \"response: #{res.body}\"\n return [dizList.length, req.body.size, res]\n end",
"def postEntityList( entity_id, headline, body)\n params = Hash.new\n params['entity_id'] = entity_id\n params['headline'] = headline\n params['body'] = body\n return doCurl(\"post\",\"/entity/list\",params)\n end",
"def new\n @lendable = Lendable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lendable }\n end\n end",
"def test_list\n @builder.write_list('http://lancaster.myreadinglists.org/lists/4510B70F-7C50-D726-4A6C-B129F5EABB2C')\n end",
"def destroy\n @lendable = Lendable.find(params[:id])\n @lendable.destroy\n\n respond_to do |format|\n format.html { redirect_to(lendables_url) }\n format.xml { head :ok }\n end\n end",
"def create\n @lable = Lable.new(lable_params)\n\n respond_to do |format|\n if @lable.save\n format.html { redirect_to @lable, notice: 'Lable was successfully created.' }\n format.json { render :show, status: :created, location: @lable }\n else\n format.html { render :new }\n format.json { render json: @lable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def postEntityBulkJson( data)\n params = Hash.new\n params['data'] = data\n return doCurl(\"post\",\"/entity/bulk/json\",params)\n end",
"def index\n @taggables = Taggable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @taggables }\n end\n end",
"def create\n @lode = Lode.new(lode_params)\n respond_to do |format|\n if @lode.save\n format.html { redirect_to new_lode_path(resource: @lode.resource), notice: 'Lode was successfully created.' }\n format.json { render :show, status: :created, location: resources_path(@lode.resource) }\n else\n format.html { render :new }\n format.json { render json: @lode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_list(params={})\n @obj.post('create-list', @auth.merge(params))\n end",
"def create_list(name, source, opt_in_type)\n endpoint = \"/api/#{@version}/list/create/\"\n custom_params = {\n \"name\" => name,\n \"source\" => source,\n \"opt_in_type\" => opt_in_type\n }\n make_post_request(endpoint, custom_params)\n end",
"def POST; end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end",
"def create\n @lbd = Lbd.new(params[:lbd])\n\n respond_to do |format|\n if @lbd.save\n format.html { redirect_to :action => 'index' }\n format.json { render json: @lbd, status: :created, location: @lbd }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lbd.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @cables = Cable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cables }\n end\n end",
"def bulk_insert_list_params\n params.require(:bulk_insert_list).permit(:hash_id, :EAN13, :shelf, :sort)\n end",
"def xml_serialize(writer)\n value.each do |val|\n writer.start_element('{DAV:}supported-method')\n writer.write_attribute('name', val)\n writer.end_element\n end\n end",
"def create\n @alternatives_set = AlternativesSet.new(params[:alternatives_set])\n #params[:alternative].each do |foreign_key_name,alternative_id|\n # alternative = Alternative.find(alternative_id)\n # @alternatives_set.alternatives << alternative\n #end\n\n respond_to do |format|\n if @alternatives_set.save\n flash[:notice] = 'AlternativesSet was successfully created.'\n format.html { redirect_to(alternatives_sets_path) }\n format.xml { render :xml => @alternatives_set, :status => :created, :location => @alternatives_set }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @alternatives_set.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_table(payload)\n make_request(payload, 'post')\n [status, body]\n end",
"def post(buffer)\n connection.post(\"#{configuration.path}/update\", buffer, {'Content-type' => 'text/xml;charset=utf-8'})\n end",
"def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return response.body if check_response(response, 201)\n end",
"def create_list(name)\n path = \"lists\"\n params = { list: { name: name }}\n list = request(path, params, :post)\n list_id = list[:id]\n # output full list again\n show_list(list_id)\n end",
"def post_nodes_with_root\n serialize_service.post_nodes_serialized\n end",
"def web(_request, response)\n response.headers[\"Content-Type\"] = \"application/json\"\n json = MultiJson.dump(\n adapter: robot.config.robot.adapter,\n lita_version: Lita::VERSION,\n redis_memory_usage: redis_memory_usage,\n redis_version: redis_version,\n robot_mention_name: robot.mention_name,\n robot_name: robot.name\n )\n response.write(json)\n end",
"def post_outcome_request\n raise IMS::LTI::InvalidLTIConfigError, \"\" unless has_required_attributes?\n\n res = post_service_request(@lis_outcome_service_url,\n 'application/xml',\n generate_request_xml)\n\n @outcome_response = extend_outcome_response(OutcomeResponse.new)\n @outcome_response.process_post_response(res)\n end",
"def create\n @table = Table.new(params[:table].permit(:name, :notes, :x, :y, :table_type, :guest_ids => []))\n\n respond_to do |format|\n if @table.save\n format.html { redirect_to @table, notice: 'Table was successfully created.' }\n format.json { render 'tables/create', status: :created, location: @table }\n else\n format.html { render action: \"new\" }\n format.json { render json: @table.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n inaktiv: cvNode.xpath('inaktiv').text.to_s.to_bool \n })\n cv.save\n\n cvNode.xpath('checklisten_eintrags/checklisten_eintrag').each do |ceNode|\n ce = ChecklistenEintrag.new({\n checklisten_vorlage_id: cv.id,\n bezeichner: ceNode.xpath('bezeichner').text.to_s,\n was: ceNode.xpath('was').text.to_s,\n wann: ceNode.xpath('wann').text.to_s,\n typ: ceNode.xpath('typ').text.to_s.to_i,\n position: ceNode.xpath('position').text.to_s.to_i\n })\n ce.save\n end\n\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n end\n end",
"def link_request_params\n params.require(:link_request).permit(:id, :show_admin, :traffic, :comment, :duration, \n approvals_attributes: [ :status, ip_attributes:[:fqdn, :vlan_id] ])\n end",
"def get_all_outypes\n path = \"/d2l/api/lp/#{$lp_ver}/outypes/\"\n _get(path)\nend",
"def post_route(route, message)\n raise TypeError unless route.is_a? Route\n @changeset = @api.create_changeset(message, tags={'created_by'=>'ITCR'})\n ways_list = []\n nodes_list = create_node_list(route.path)\n\n until nodes_list.empty? # For node's maximum limit of a way\n way_nodes = nodes_list.take(MAX_NODES)\n nodes_list = nodes_list.drop(MAX_NODES)\n way_id = create_way(way_nodes)\n ways_list << way_id\n end\n\n relation = create_relation(ways_list) # Link ways to relation\n relation = add_stops(relation, route.stops) # Add bus stops to relation\n\n @api.save(relation, @changeset) # Save relation using the API\n puts 'Relation created succesfuly.'\n @api.close_changeset(@changeset)\n @changeset.id\n end",
"def index\n @entity_end_point_rels = EntityEndPointRel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entity_end_point_rels }\n end\n end",
"def index\n @nodes = Node.admin\n response.headers['Content-Range'] = @nodes.count\n render json: @nodes.reorder(id: :asc).as_json(admin: true)\n end",
"def list_params\n params.require(:list).permit(:ticket_id, :insumo_id, :cant)\n end",
"def update\n @lendable = Lendable.find(params[:id])\n\n respond_to do |format|\n if @lendable.update_attributes(params[:lendable])\n format.html { redirect_to(@lendable, :notice => 'Lendable was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lendable.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_list(name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"post\", \"lists\", data)\n end",
"def create_list(name, source, opt_in_type)\n endpoint = \"/api/v1/list/create/\"\n base_params = base_params(endpoint)\n custom_params = {\n \"name\" => name,\n \"source\" => source,\n \"opt_in_type\" => opt_in_type\n }\n uri = post_api_uri(endpoint)\n http = setup_request(uri)\n result = http.post(uri.path, base_params.merge(custom_params).to_query)\n JSON.parse(result.body)\n end",
"def postEntityAdvertiserTag( gen_id, entity_id, language, tags_to_add, tags_to_remove)\n params = Hash.new\n params['gen_id'] = gen_id\n params['entity_id'] = entity_id\n params['language'] = language\n params['tags_to_add'] = tags_to_add\n params['tags_to_remove'] = tags_to_remove\n return doCurl(\"post\",\"/entity/advertiser/tag\",params)\n end",
"def index\n @nodes = @job.nodes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n format.json { render :json => @nodes }\n end\n end",
"def index\n @leads = current_user.leads\n @buttons = [{ name: \"New Leads (CSV)\", path: upload_csv_leads_path}, {name: \"New Lead\", path: new_lead_path}]\n \n respond_to do |format|\n format.html { render :index }\n format.json { render json: @leads.uncalled.to_json }\n end\n end",
"def create\n @packing_list = PackingList.find(params[:packing_list_id])\n @context = @packing_list.context\n @packable = @packing_list.packables.build(params[:packable])\n\n respond_to do |format|\n if @packable.save\n format.html { redirect_to [@context, @packing_list], notice: 'Packable was successfully created.' }\n format.json { render json: @packing_list, status: :created, location: @packable }\n else\n format.html { render action: \"new\" }\n format.json { render json: @packable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_params\n params.require(:list).permit(:title, :description, :html_id, :html_classes,\n list_items_attributes: [\n :id, :type, :object_type, :object_id, :title, :subtitle, :url, :image_id, :target,\n :priority, :_destroy, :description, :html_classes,\n children_attributes: list_item_attributes\n ])\n end",
"def postCategoryMappings( category_id, type, id, name)\n params = Hash.new\n params['category_id'] = category_id\n params['type'] = type\n params['id'] = id\n params['name'] = name\n return doCurl(\"post\",\"/category/mappings\",params)\n end",
"def create\n @organisme = Organisme.new(organisme_params)\n params[:departements] ||= []\n @organisme.departements.delete_all\n @dep_table = params[:departements]\n logger.debug \"Departements table sent : #@dep_table\"\n @dep_table.each do |depid|\n @organisme.departements << Departement.find(depid)\n end\n respond_to do |format|\n if @organisme.save\n format.html { redirect_to action: \"index\", notice: 'Organisme was successfully created.' }\n format.json { render :index, status: :created, location: @organisme }\n else\n format.html { render :new }\n format.json { render json: @organisme.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @help_offers = @job_request.help_offers\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @help_offers }\n end\n end",
"def list_orders_tosend_multiple_artworks\n doc = Hpricot::XML(request.raw_post)\n doc = doc.to_s.gsub(\"&\",\"&\")\n doc = Hpricot::XML(doc)\n @orders = Artwork::ArtworkCrud.list_orders_tosend_multiple_artworks(doc)\n # render :xml=>@orders[0].xmlcol\n render :xml=>'<encoded>'+Base64.encode64(Zlib::Deflate.deflate(@orders[0].xmlcol))+'</encoded>'\n end",
"def index\n @lables = Lable.all\n end",
"def post\n frm.button(:name=>\"post\").click\n AssignmentsList.new(@browser)\n end",
"def create_lxc_post(client_name,post_list)\n tmp_file = \"/tmp/post\"\n client_dir = $lxc_base_dir+\"/\"+client_name\n post_file = client_dir+\"/rootfs/root/post_install.sh\"\n file = File.open(tmp_file,\"w\")\n post_list.each do |line|\n output = line+\"\\n\"\n file.write(output)\n end\n file.close\n message = \"Creating:\\tPost install script\"\n command = \"cp #{tmp_file} #{post_file} ; chmod +x #{post_file} ; rm #{tmp_file}\"\n execute_command(message,command)\n return\nend",
"def list_assigned_artworks\n doc = Hpricot::XML(request.raw_post)\n doc = doc.to_s.gsub(\"&\",\"&\")\n doc = Hpricot::XML(doc)\n @orders = Artwork::ArtworkCrud.list_assigned_artworks(doc)\n # render :xml=>@orders[0].xmlcol\n render :xml=>'<encoded>'+Base64.encode64(Zlib::Deflate.deflate(@orders[0].xmlcol))+'</encoded>'\n end",
"def add_arrays_to_tenant(args = {}) \n post(\"/tenants.json/#{args[:tenantId]}/arrays\", args)\nend",
"def post_data; end",
"def postFlatpackSitemap( flatpack_id, filedata)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/flatpack/sitemap\",params)\n end",
"def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end",
"def postEntityAdvertiserCreate( entity_id, tags, locations, max_tags, max_locations, expiry_date, is_national, language, reseller_ref, reseller_agent_id, publisher_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['tags'] = tags\n params['locations'] = locations\n params['max_tags'] = max_tags\n params['max_locations'] = max_locations\n params['expiry_date'] = expiry_date\n params['is_national'] = is_national\n params['language'] = language\n params['reseller_ref'] = reseller_ref\n params['reseller_agent_id'] = reseller_agent_id\n params['publisher_id'] = publisher_id\n return doCurl(\"post\",\"/entity/advertiser/create\",params)\n end",
"def create\n \n @day_road_list = DayRoadList.new(day_road_list_params)\n\n respond_to do |format|\n if @day_road_list.save\n format.html { redirect_to @day_road_list, notice: 'Данные добавлены' }\n format.json { render :index, location: @day_road_list }\n else\n format.html { render :new }\n format.json { render json: @day_road_list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createItemOfList\n results1 = checkUser(params[:target_account]) #userid user to give the money\n if results1.code == 200\n parameters={user_id: (@current_user[\"id\"]).to_i, description: (params[:description]), date_pay: params[:date_pay], cost: params[:cost], target_account: params[:target_account], state_pay:params[:state_pay]}\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n results = HTTParty.post(\"http://192.168.99.101:4055/lists\", options)\n if results.code == 201\n head 201\n else\n render json: results.parsed_response, status: results.code\n end\n elsif results1.code == 404\n renderError(\"Not Found\", 404, \"The resource does not exist\")\n end\n end",
"def post(path, **args); end",
"def list\n do_list\n\n respond_to do |type|\n type.html {\n render :action => 'list', :layout => true\n }\n type.js { \n do_list\n render :action => 'list', :layout => false \n }\n type.xml { render :xml => response_object.to_xml, :content_type => Mime::XML, :status => response_status }\n type.json { render :text => response_object.to_json, :content_type => Mime::JSON, :status => response_status }\n type.yaml { render :text => response_object.to_yaml, :content_type => Mime::YAML, :status => response_status }\n end\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def show\n @lendable = Lendable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lendable }\n end\n end",
"def postEntitySpecial_offer( entity_id, title, description, terms, start_date, expiry_date, url)\n params = Hash.new\n params['entity_id'] = entity_id\n params['title'] = title\n params['description'] = description\n params['terms'] = terms\n params['start_date'] = start_date\n params['expiry_date'] = expiry_date\n params['url'] = url\n return doCurl(\"post\",\"/entity/special_offer\",params)\n end",
"def create\n @list = Blog::List.new(list_params)\n\n respond_to do |format|\n if @list.save\n ActionCable.server.broadcast \"board\",\n { commit: 'addList', \n payload: render_to_string(:show, formats: [:json]) }\n format.html { redirect_to @list, notice: 'List was successfully created.' }\n format.json { render :show, status: :created, location: @list }\n else\n format.html { render :new }\n format.json { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_params\n params.require(:list).permit(:name,:amount,:body,:status,:group_id, :list )\n end",
"def list_requests\n # stub\n end",
"def batch_write_item(request_options)\n request_options[:request_items].each do |table_name, requests|\n table = get_table(table_name)\n\n requests.each do |request_hash|\n if request_hash[:put_request]\n item = request_hash[:put_request][:item].symbolize_keys\n hash_key_value = item[hash_key_attr]\n if range_key_attr.present?\n range_key_value = item[range_key_attr]\n table[hash_key_value] = {} if table[hash_key_value].nil?\n table[hash_key_value][range_key_value] = item\n else\n table[hash_key_value] = item\n end\n else\n item = request_hash[:delete_request][:key]\n id = item[hash_key_attr]\n table.delete(id)\n end\n end\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end",
"def set_list_params\n params.require(:set_list).permit(:title, :notes, :tags)\n end",
"def post #:doc:\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def post\n Rentlinx.client.post(self)\n end",
"def new\n @packing_list = PackingList.find(params[:packing_list_id])\n @context = @packing_list.context\n @packable = @packing_list.packables.build\n\n respond_with @packable\n end",
"def index\n @leks = Lek.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @leks }\n end\n end",
"def create\n @itemstable = Itemstable.new(params[:itemstable])\n\n respond_to do |format|\n if @itemstable.save\n format.html { redirect_to @itemstable, notice: 'Itemstable was successfully created.' }\n format.json { render json: @itemstable, status: :created, location: @itemstable }\n else\n format.html { render action: \"new\" }\n format.json { render json: @itemstable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.create(post_params)\n @post.tag_list=(params[:tag_list])\n respond_with @post\n end",
"def loanable_params\n params.require(:loanable).permit(:title, :description, :location, :contact, :end, :state, :url)\n end",
"def create\n @rebateable = find_rebateable\n @rebate = @rebateable.rebates.build(params[:rebate])\n @sector_names = params[:sector_names] || []\n @industry_names = params[:industry_names] || []\n @rebate.tag_names = @sector_names.join(',') + \",\" + @industry_names.join(',')\n\n respond_to do |format|\n if @rebate.save\n format.html { redirect_to :id => nil }\n format.json { render json: @rebate, status: :created, location: @rebate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rebate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lk = Lk.new(lk_params)\n\n respond_to do |format|\n if @lk.save\n format.html { redirect_to @lk, notice: 'Lk was successfully created.' }\n format.json { render :show, status: :created, location: @lk }\n else\n format.html { render :new }\n format.json { render json: @lk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post url, payload\n RestClient::Request.execute(:method => :post, :url => url, :payload => payload, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end",
"def list_params\n params.require(:list).permit(:entity_id, :date, proposals_attributes: [:id, :consultant_id, :nbre_jour, :date, :etat, :_destroy])\n end",
"def postEntityAdvertiserUpsell( entity_id, tags, locations, extra_tags, extra_locations, is_national, language, reseller_ref, reseller_agent_id, publisher_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['tags'] = tags\n params['locations'] = locations\n params['extra_tags'] = extra_tags\n params['extra_locations'] = extra_locations\n params['is_national'] = is_national\n params['language'] = language\n params['reseller_ref'] = reseller_ref\n params['reseller_agent_id'] = reseller_agent_id\n params['publisher_id'] = publisher_id\n return doCurl(\"post\",\"/entity/advertiser/upsell\",params)\n end",
"def create\n @refenciacontable = Refenciacontable.new(params[:refenciacontable].update(:company_id => current_company.id))\n flash[:notice] = t('scaffold.notice.created', :item => Refenciacontable.model_name.human) if @refenciacontable.save\n respond_with(@refenciacontable, :location => refenciacontables_path)\n end",
"def create\n @mailee_list = Mailee::List.new(params[:mailee_list])\n\n respond_to do |format|\n if @mailee_list.save\n format.html { redirect_to(@mailee_list, :notice => 'Mailee list was successfully created.') }\n format.xml { render :xml => @mailee_list, :status => :created, :location => @mailee_list }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mailee_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @liste = Liste.new(params[:liste])\n\n respond_to do |format|\n if @liste.save\n format.html { redirect_to @liste, notice: 'Liste was successfully created.' }\n format.json { render json: @liste, status: :created, location: @liste }\n else\n format.html { render action: \"new\" }\n format.json { render json: @liste.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_line_items_link\n self.get_element(@browser, '//a[contains(@href, \"/line_items/create?insertion_orders.id=\")]')\n end",
"def create_many_intents\n intents = []\n @switches.each do |sw|\n rest = @switches - [sw]\n intents = _create_intent sw, rest, intents\nputs intents.size\n post_slice intents\n end\n post_slice intents, true\n end",
"def create\n @req_breakdown = ReqBreakdown.new(params[:req_breakdown])\n\n respond_to do |format|\n if @req_breakdown.save\n flash[:notice] = 'ReqBreakdown was successfully created.'\n format.html { redirect_to(admin_req_breakdowns_url) }\n format.xml { render :xml => @req_breakdown, :status => :created, :location => @req_breakdown }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @req_breakdown.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def lista_params\n params.require(:lista).permit(:nombre_lista, :columnas, :formato, :esta_activa, :cadena_especies)\n end",
"def create\n @list_of_value = Irm::ListOfValue.new(params[:irm_list_of_value])\n\n respond_to do |format|\n if @list_of_value.save\n format.html { redirect_to({:action => \"index\"}, :notice => t(:successfully_created)) }\n format.xml { render :xml => @list_of_value, :status => :created, :location => @list_of_value }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @list_of_value.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def list_noresponse_paperproof_records\n doc = Hpricot::XML(request.raw_post)\n doc = doc.to_s.gsub(\"&\",\"&\")\n doc = Hpricot::XML(doc)\n @orders = Artwork::ArtworkCrud.list_noresponse_paperproof_records(doc)\n # render :xml=>@orders[0].xmlcol\n render :xml=>'<encoded>'+Base64.encode64(Zlib::Deflate.deflate(@orders[0].xmlcol))+'</encoded>'\n end",
"def _ls\n @response[:list] = []\n end",
"def cmd_nlst(param)\n send_unauthorised and return unless logged_in?\n send_response \"150 Opening ASCII mode data connection for file list\"\n\n files = list_dir(build_path(param))\n send_outofband_data(files.map { |f| f.name })\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def list\n add_breadcrumb :list\n respond_to do |format|\n format.html # list.html.erb\n format.json { render json: PersonsDatatable.new(view_context) }\n end\n end",
"def create\n name, board_id = params[:name], params[:board_id]\n @list = List.new\n @list.name = name\n @list.board_id = board_id\n @list.order = List.get_max_order board_id\n @lists_size = List.get_size board_id\n respond_to do |format|\n if @lists_size < 6 && @list.save\n @lists_size += 1\n format.js { render action: 'create', status: :created, location: @list}\n else\n format.js { render json: @list.errors, status: :unprocessable_entity }\n end\n end\n end",
"def entries_to_http entries, url, http = Atom::HTTP.new\n coll = Atom::Collection.new url, http\n\n entries.each { |entry| coll.post! entry }\n end",
"def ef_request(*args)\n n=0\n spec = line_part_spec\n @page_footers[0][n] = spec\n end",
"def post; end"
] | [
"0.5138751",
"0.5026368",
"0.49665746",
"0.4898042",
"0.4693962",
"0.46792135",
"0.45998502",
"0.45138013",
"0.44840452",
"0.44724372",
"0.44701415",
"0.44653237",
"0.44638425",
"0.44493517",
"0.44401067",
"0.4423871",
"0.44238675",
"0.43927434",
"0.43759087",
"0.43745932",
"0.4373234",
"0.4365623",
"0.4352078",
"0.4346391",
"0.43391103",
"0.43305898",
"0.43302202",
"0.432913",
"0.4322274",
"0.43148097",
"0.43091106",
"0.43086988",
"0.4308517",
"0.43028376",
"0.43011248",
"0.42903882",
"0.4285158",
"0.4283417",
"0.4282961",
"0.4278704",
"0.4274269",
"0.42684495",
"0.4268035",
"0.425672",
"0.42504126",
"0.4248648",
"0.42472667",
"0.42459765",
"0.42394722",
"0.42355773",
"0.4233579",
"0.4233382",
"0.42305338",
"0.42304236",
"0.42222083",
"0.4217152",
"0.42098078",
"0.42062986",
"0.42017967",
"0.42001513",
"0.42001325",
"0.4199703",
"0.41965222",
"0.41886273",
"0.41880628",
"0.41880155",
"0.41743112",
"0.41742212",
"0.41742212",
"0.41723493",
"0.41718975",
"0.41667506",
"0.41652945",
"0.4162681",
"0.41607898",
"0.4160321",
"0.41589767",
"0.4157035",
"0.41535938",
"0.41506872",
"0.41487047",
"0.41477793",
"0.4147729",
"0.4145407",
"0.41399968",
"0.4138279",
"0.41379684",
"0.41371176",
"0.41369495",
"0.41358462",
"0.41354224",
"0.41322032",
"0.4131364",
"0.41282353",
"0.412714",
"0.41258055",
"0.41257605",
"0.41215345",
"0.41214997",
"0.41203424"
] | 0.56408757 | 0 |
PUT /lendables/1 PUT /lendables/1.xml | def update
@lendable = Lendable.find(params[:id])
respond_to do |format|
if @lendable.update_attributes(params[:lendable])
format.html { redirect_to(@lendable, :notice => 'Lendable was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @lendable.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def destroy\n @lendable = Lendable.find(params[:id])\n @lendable.destroy\n\n respond_to do |format|\n format.html { redirect_to(lendables_url) }\n format.xml { head :ok }\n end\n end",
"def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end",
"def update\n @ontology = SYMPH::Ontology.find(params[:id])\n\n respond_to do |format|\n if @ontology.update_attributes(params[:ontology])\n flash[:notice] = 'Ontology was successfully updated.'\n format.html { redirect_to(ontologies_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ontology.errors, :status => :unprocessable_entity }\n end\n end\n\t\n end",
"def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { render :show, status: :ok, location: @server }\n else\n format.html { render :edit }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shelf = Shelf.find(params[:id])\n\n respond_to do |format|\n if @shelf.update_attributes(params[:shelf])\n flash[:notice] = 'Shelf was successfully updated.'\n format.html { redirect_to(@shelf) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shelf.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_list(id, list)\n record \"/todos/update_list/#{id}\", :list => list\n end",
"def update\n @interface = Interface.find(params[:id])\n @virtualmachine = Virtualmachine.find(@interface.virtualmachine_id)\n position_networkcard = `cat /etc/libvirt/qemu/#{@virtualmachine.hostname}.xml | grep -n \"slot='0x#{@interface.pci_slot}\" | cut -d ':' -f1`\n begin_networkcard = position_networkcard.to_i - 4\n end_networkcard = position_networkcard.to_i + 1\n\n delete_networkcard = `sed -i '#{begin_networkcard},#{end_networkcard}d' /etc/libvirt/qemu/#{@virtualmachine.hostname}.xml`\n filesize = `cat /etc/libvirt/qemu/#{@virtualmachine.hostname}.xml | wc -l`\n filesize = filesize.to_i - 2 \n\n #inserts interface definition\n\n #place xml insertions here\n respond_to do |format|\n if @interface.update_attributes(params[:interface])\n interface_network_id = @interface.network_id\n @network = Network.find(interface_network_id)\n ifacedata = \"<interface type='network'>\\n<mac address='#{@interface.macaddress}'/>\\n<source network='#{@network.name}'/>\\n<model type='pcnet'/>\\n<address type='pci' domain='0x0000' bus='0x00' slot='0x#{@interface.pci_slot}' function='0x0'/>\\n</interface>\"\n write_at(\"/etc/libvirt/qemu/#{@virtualmachine.hostname}.xml\", filesize, ifacedata)\n format.html { redirect_to @interface, :notice => 'Interface was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @interface.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end",
"def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end",
"def update\n @stable = Stable.find(params[:id])\n\n respond_to do |format|\n if @stable.update_attributes(params[:stable])\n format.html { redirect_to @stable, notice: 'Stable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end",
"def edit_shelf(shelf_id, shelf_name, exclusive_flag = \"false\", sortable_flag = \"false\", featured = \"false\")\n\t\toptions = {\"user_shelf[name]\" => shelf_name, \"user_shelf[exclusive_flag]\" => exclusive_flag, \"user_shelf[sortable_flag]\" => sortable_flag, \"user_shelf[featured]\" => featured}\n\t\tdata = oauth_request(\"/user_shelves/#{shelf_id}.xml\", options, \"put\")\n\tend",
"def update\n # returning connection.put(element_path(prefix_options), to_xml, self.class.headers) do |response|\n returning connection.put(element_path(prefix_options), to_ssj, self.class.headers) do |response|\n load_attributes_from_response(response)\n end\n end",
"def 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_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update_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 test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end",
"def update\n @thing_list = ThingList.find(params[:id])\n\n respond_to do |format|\n if @thing_list.update_attributes(params[:thing_list])\n format.html { redirect_to(@thing_list, :notice => 'Thing list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @thing_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @itemstable = Itemstable.find(params[:id])\n\n respond_to do |format|\n if @itemstable.update_attributes(params[:itemstable])\n format.html { redirect_to @itemstable, notice: 'Itemstable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @itemstable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def put(path, **args); end",
"def update\n connection.put(element_path, to_xml)\n end",
"def put(*args)\n request :put, *args\n end",
"def update\n respond_to do |format|\n lixotodo_sub = Lixotodo.find(params[:lixotodo_sub_id])\n lixotodo_sub.destroy\n if @lixotodo.update(lixotodo_params)\n refresh_lixotodo_after_edit(@lixotodo)\n format.html {redirect_to populate_lixotodos_path, notice: 'Tabela de lixo atualizada com sucesso.'}\n format.json {render :show, status: :ok, location: @lixotodo}\n else\n format.html {render :edit}\n format.json {render json: @lixotodo.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n @node_rack = @object\n\n respond_to do |format|\n if @node_rack.update_attributes(params[:node_rack])\n flash[:notice] = 'NodeRack was successfully updated.'\n format.html { redirect_to node_rack_url(@node_rack) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node_rack.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @mailee_list = Mailee::List.find(params[:id])\n\n respond_to do |format|\n if @mailee_list.update_attributes(params[:mailee_list])\n format.html { redirect_to(@mailee_list, :notice => 'Mailee list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mailee_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @entry = Entry.find(params[:id])\n\t\n\[email protected]_list = \"\"\n\t@systems = params[:systems]\n\[email protected] do |s|\n\t\[email protected]_list.add(s)\n\tend\t\n\t\n\[email protected]_list = \"\"\n\t@components = params[:components]\n\[email protected] do |c|\n\t\[email protected]_list.add(c)\n\tend\n\t\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to(@entry, :notice => 'Entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @list = HqVlan.all(:order => :name)\n @object = HqVlan.find(params[:id])\n \n params[:hq_vlan][:assigned_hq_nic] ||= {}\n \n @hq_vlan = HqVlan.find(params[:id])\n respond_to do |format|\n if @hq_vlan.update_attributes(params[:hq_vlan])\n @objects = HqVlan.all(:order => 'name ASC')\n flash[:notice] = 'Virtual Server was successfully updated.'\n format.js {redirect_to :action => 'edit', :template => 'reflected/edit' } if request.xhr?\n format.html { redirect_to :action => 'edit', :template => 'reflected/edit' }\n format.xml { head :ok }\n else\n messages = '<ul>Error:'\n @hq_vlan.errors.full_messages.each {|msg| messages += '<li>'+msg+'</li>'}\n messages += '</ul>'\n flash[:notice] = messages\n format.html { redirect_to :action => \"edit\", :template => 'reflected/edit' }\n format.xml { render :xml => @hq_vlan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end",
"def 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 test_put_new_resource_locked_collection_zero_depth\n setup_hr\n\n resumes_locktoken = lock('httplock/hr/recruiting/resumes',\n :depth => 0).token\n\n response = @request.put('httplock/hr/recruiting/resumes/ldusseault.txt', StringIO.new(\"lisa resume\"), :if_none_match => '*')\n assert_equal '423', response.status\n\n response = @request.put('httplock/hr/recruiting/resumes/ldusseault.txt', StringIO.new(\"lisa resume\"), { :if_none_match => '*', :if => { 'httplock/hr/recruiting/resumes/' => resumes_locktoken } })\n assert_equal '201', response.status\n\n response = @request.put('httplock/hr/recruiting/resumes/ldusseault.txt', StringIO.new(\"hello\"))\n assert_equal '204', response.status\n\n # cleanup\n unlock('httplock/hr/recruiting/resumes/', resumes_locktoken)\n delete_coll 'httplock'\n end",
"def update_soaplab_server(url)\n soaplab = SoaplabServer.find_by_location(url)\n data = soaplab.services_factory().values.flatten\n wsdls_from_server = data.collect{ |item| item[\"location\"]}\n registered_soaps = SoapService.find_all_by_wsdl_location(wsdls_from_server).compact\n registered_wsdls = registered_soaps.collect{|s| s.wsdl_location}\n wsdls_from_relationships = soaplab.services.collect{|service| service.latest_version.service_versionified.wsdl_location}\n wsdls_to_add = registered_wsdls - wsdls_from_relationships \n submitter = nil\n unless soaplab.services.empty?\n submitter = User.find(soaplab.services.first.submitter_id)\n end\n \n \n soaps_to_add = SoapService.find_all_by_wsdl_location(wsdls_from_server).compact\n services_to_add = soaps_to_add.collect{|s| s.service}\n puts \"server : #{url}\"\n puts \"No of relationships to add #{wsdls_to_add.length}\"\n puts wsdls_to_add\n unless wsdls_to_add.empty?\n if submitter.nil?\n submitter = User.find(SoapService.find_by_wsdl_location(wsdls_to_add.first).service.submitter_id)\n end\n soaplab.create_relationships(wsdls_to_add)\n create_tags_if_not_exist(services_to_add, submitter)\n end\n if soaplab.endpoint.nil?\n proxy_info = get_endpoint_and_name(url)\n unless proxy_info.empty?\n soaplab.endpoint = proxy_info[0] \n soaplab.name = proxy_info[1]\n soaplab.save\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 update_resource_response(@headline, headline_params)\n end",
"def update\n @army_list = ArmyList.find(params[:id])\n\n respond_to do |format|\n if @army_list.update_attributes(params[:army_list])\n flash[:notice] = 'ArmyList was successfully updated.'\n format.html { redirect_to :controller => :builder }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @army_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def update\n @checklist = Checklist.find(params[:id])\n\n respond_to do |format|\n if @checklist.update_attributes(params[:checklist])\n flash[:notice] = 'Checklist was successfully updated.'\n format.html { redirect_to(@checklist) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @checklist.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @storage_lun = StorageLun.find(params[:id])\n\n respond_to do |format|\n if @storage_lun.update_attributes(params[:storage_lun])\n format.html { redirect_to @storage_lun, notice: 'Storage lun was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @storage_lun.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lien = Lien.find(params[:id])\n\n respond_to do |format|\n if @lien.update_attributes(params[:lien])\n flash[:notice] = 'Lien was successfully updated.'\n format.html { redirect_to(@lien) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lien.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def override\n document_id = params[:document_id]\n document = params[:document]\n document_type = params[:document_type]\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename if document\n xml.summary document_type\n if document\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n end\n }\n end\n\n url = Document::PATH + \"cmis/i/#{document_id}?alf_ticket=\" + ticket\n\n begin\n RestClient.put url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error updating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end",
"def test_putway_update_valid\n way = create(:way_with_nodes, :nodes_count => 3)\n cs_id = way.changeset.id\n user = way.changeset.user\n\n assert_not_equal({ \"test\" => \"ok\" }, way.tags)\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version, way.id, way.nds, { \"test\" => \"ok\" }, [], {}]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({}, result[4])\n assert_equal way.version + 1, result[5]\n assert_equal({}, result[6])\n assert_equal({}, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 1, new_way.version\n assert_equal way.nds, new_way.nds\n assert_equal({ \"test\" => \"ok\" }, new_way.tags)\n\n # Test changing the nodes in the way\n a = create(:node).id\n b = create(:node).id\n c = create(:node).id\n d = create(:node).id\n\n assert_not_equal [a, b, c, d], way.nds\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version + 1, way.id, [a, b, c, d], way.tags, [], {}]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({}, result[4])\n assert_equal way.version + 2, result[5]\n assert_equal({}, result[6])\n assert_equal({}, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 2, new_way.version\n assert_equal [a, b, c, d], new_way.nds\n assert_equal way.tags, new_way.tags\n\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version + 2, way.id, [a, -1, b, c], way.tags, [[4.56, 12.34, -1, 0, { \"test\" => \"new\" }], [12.34, 4.56, b, 1, { \"test\" => \"ok\" }]], { d => 1 }]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n new_node_id = result[4][\"-1\"].to_i\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({ \"-1\" => new_node_id }, result[4])\n assert_equal way.version + 3, result[5]\n assert_equal({ new_node_id.to_s => 1, b.to_s => 2 }, result[6])\n assert_equal({ d.to_s => 1 }, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 3, new_way.version\n assert_equal [a, new_node_id, b, c], new_way.nds\n assert_equal way.tags, new_way.tags\n\n new_node = Node.find(new_node_id)\n assert_equal 1, new_node.version\n assert_equal true, new_node.visible\n assert_equal 4.56, new_node.lon\n assert_equal 12.34, new_node.lat\n assert_equal({ \"test\" => \"new\" }, new_node.tags)\n\n changed_node = Node.find(b)\n assert_equal 2, changed_node.version\n assert_equal true, changed_node.visible\n assert_equal 12.34, changed_node.lon\n assert_equal 4.56, changed_node.lat\n assert_equal({ \"test\" => \"ok\" }, changed_node.tags)\n\n deleted_node = Node.find(d)\n assert_equal 2, deleted_node.version\n assert_equal false, deleted_node.visible\n end",
"def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end",
"def put_resource_xml(modifier_el, resource_uri, opts)\n unless cid_attr = modifier_el['component_id']\n raise BadRequestException.new \"Missing attribute 'component_id' in component '#{ modifier_el.to_xml}'\" \n end\n \n component = _get_resource(resource_uri, modifier_el, opts)\n unless (cid = component.component_id).to_s == cid_attr\n raise BadRequestException.new \"Wrong 'component_id'. Expected '#{cid}', but got '#{cid_attr}'\"\n end\n component.update_from_xml(modifier_el, opts)\n component.save\n component\n end",
"def updateX\n @server = Server.find(params[:id])\n\n respond_to do |format|\n if @server.update_attributes(params[:server])\n format.html { redirect_to(@server, :notice => 'Server was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @server.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @dl_type = DlType.find(params[:id])\n\n respond_to do |format|\n if @dl_type.update_attributes(params[:dl_type])\n format.html { redirect_to(downloads_admin_dl_type_path(@dl_type), :notice => 'Dl type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dl_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def update\n @list_of_value = Irm::ListOfValue.find(params[:id])\n\n respond_to do |format|\n if @list_of_value.update_attributes(params[:irm_list_of_value])\n format.html { redirect_to({:action => \"index\"}, :notice => t(:successfully_updated)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @list_of_value.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @path = Path.find(params[:id])\n\n respond_to do |format|\n if @path.update_attributes(params[:path])\n format.html { redirect_to([@layer, @path], :notice => 'Path was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @path.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @lancamento = Lancamento.find(params[:id])\n\n respond_to do |format|\n if @lancamento.update_attributes(params[:lancamento])\n flash[:notice] = 'Lancamento foi criado com sucesso!'\n format.html { redirect_to(@lancamento) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lancamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def save\n raise NotImplementedError, \"Lists can't be edited through the API\"\n end",
"def update\n respond_to do |format|\n if @label_sheet.update_attributes(label_sheet_params)\n format.html { redirect_to([:admin, @label_sheet], notice: 'Label Sheet was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated Label Sheet: #{@label_sheet.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @label_sheet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path = '/files/', params = {})\n request :put, path, params\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 @packing_list = PackingList.find(params[:packing_list_id])\n @context = @packing_list.context\n @packable = @packing_list.packables.find(params[:packable_id])\n\n respond_to do |format|\n if @packable.update_attributes(params[:packable])\n format.html { redirect_to @packing_list, notice: 'Packing List was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @packable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update\n @lun_disk = LunDisk.find(params[:id])\n\n respond_to do |format|\n if @lun_disk.update_attributes(params[:lun_disk])\n format.html { redirect_to @lun_disk, notice: 'Lun disk was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lun_disk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, options={})\n request :put, path, options\n end",
"def update\n @list = List.find(params[:id])\n @show_list = true\n\n respond_to do |format|\n if @list.update_attributes(params[:list])\n format.html { render @list }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @adventure.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tags_of_novel = TagsOfNovel.find(params[:id])\n\n respond_to do |format|\n if @tags_of_novel.update_attributes(params[:tags_of_novel])\n format.html { redirect_to @tags_of_novel, notice: 'Tags of novel was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tags_of_novel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update_list(list_id, name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"patch\", \"lists/#{list_id}\", data)\n end",
"def update\n @stationeryrequest = Stationeryrequest.find(params[:id])\n #\n @stationeryrequest.hotelsuppliesrequests.each do |hotelsuppliesrequests|\n \n end\n\n respond_to do |format|\n if @stationeryrequest.update_attributes(params[:stationeryrequest])\n format.html { redirect_to @stationeryrequest, notice: 'Stationeryrequest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stationeryrequest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @title = \"EDITAR WMI NAMESPACE\"\n @wmi_namespace = WmiNamespace.find(params[:id])\n\n respond_to do |format|\n if @wmi_namespace.update_attributes(params[:wmi_namespace])\n flash[:notice] = 'Wmi Namespace fué actualizado correctamente.'\n format.html { redirect_to(@wmi_namespace) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @wmi_namespace.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @constraint = args[:constraint] if args.key?(:constraint)\n @etag = args[:etag] if args.key?(:etag)\n end",
"def update\n @book_list = BookList.find(params[:id])\n\n respond_to do |format|\n if @book_list.update_attributes(params[:book_list])\n format.html { redirect_to(@book_list, :notice => 'Book list was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @book_list.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n @object_type = ObjectType.find(params[:id])\n\n if params[:object_type][:prefix] != @object_type.prefix\n entries = Item.joins(:locator).where(\"items.object_type_id = #{@object_type.id} AND locators.item_id = items.id\").count\n if entries != 0\n flash[:error] = \"Cannot change location wizard to #{params[:object_type][:prefix]} because there\n are items associated with this object type using the current wizard whose locations\n might get messed up. To change the wizard, (a) write down all the item numbers; (b)\n delete all the items; (c) change the location wizard; (d) undelete all the items by\n changing their locations to a location that works with the new location wizard.\"\n render action: 'edit'\n return\n end\n end\n\n ok = @object_type.update_attributes(params[:object_type].except(:rows, :columns))\n\n if params[:object_type][:handler] == 'collection'\n @object_type.rows = params[:object_type][:rows]\n @object_type.columns = params[:object_type][:columns]\n @object_type.save\n end\n\n respond_to do |format|\n if ok\n format.html { redirect_to object_types_path, notice: \"Object type '#{@object_type.name}' was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { redirect_to edit_object_type_path, notice: \"Object type could not be updated. #{@object_type.errors.full_messages.join(', ')}.\" }\n format.json { render json: @object_type.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end",
"def update\n respond_to do |format|\n format.xml { head :method_not_allowed }\n format.json { head :method_not_allowed }\n end\n end",
"def update\n @liste = Liste.find(params[:id])\n\n respond_to do |format|\n if @liste.update_attributes(params[:liste])\n format.html { redirect_to @liste, notice: 'Liste was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @liste.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_or_update(res_el, clean_state, authorizer)\n sparql = SPARQL::Client.new($repository)\n debug 'Admin CreateOrUpdate: resources: ', res_el.inspect\n\n unless res_el.is_a?(Array)\n res_el = [res_el]\n end\n resources = []\n res_el.each do |params|\n descr = params[:resource_description]\n descr = create_doctor(descr, authorizer) # Connect the objects first\n if clean_state # update\n urn = params[:urn]\n if (urn.start_with?(\"uuid\"))\n type = \"Lease\"\n else\n type = OMF::SFA::Model::GURN.parse(urn).type.camelize\n end\n res = eval(\"SAMANT::#{type}\").for(urn)\n unless sparql.ask.whether([res.to_uri, :p, :o]).true?\n raise OMF::SFA::AM::Rest::BadRequestException.new \"Resource '#{res.inspect}' not found. Please create that first.\"\n end\n authorizer.can_modify_resource?(res, type)\n res.update_attributes(descr) # Not sure if different than \".for(urn, new_descr)\" regarding an already existent urn\n else # create\n if params[:type] && (params[:type].camelize == \"Uxv\") && !(descr.keys.find {|k| k.to_s == \"hasUxVType\"})\n raise OMF::SFA::AM::Rest::BadRequestException.new \"Please provide a UxV type in your description.\"\n end\n unless params[:name] && params[:type] && params[:authority]\n raise OMF::SFA::AM::Rest::BadRequestException.new \"One of the following mandatory parameters is missing: name, type, authority.\"\n end\n urn = OMF::SFA::Model::GURN.create(params[:name], {:type => params[:type], :domain => params[:authority]})\n type = params[:type].camelize\n descr[:hasID] = SecureRandom.uuid # Every resource must have a uuid\n descr[:hasComponentID] = urn.to_s\n descr[:resourceId] = params[:name]\n if type.downcase == \"uxv\"\n descr[:hasSliceID] = \"urn:publicid:IDN+omf:netmode+account+__default__\" # default slice_id on creation; required on allocation\n end\n res = eval(\"SAMANT::#{type}\").for(urn, descr) # doesn't save unless you explicitly define so\n unless sparql.ask.whether([res.to_uri, :p, :o]).false?\n raise OMF::SFA::AM::Rest::BadRequestException.new \"Resource '#{res.inspect}' already exists.\"\n end\n authorizer.can_create_resource?(res, type)\n debug \"Res:\" + res.inspect\n res.save!\n end\n resources << res\n end\n resources\n end",
"def update\n @orderable = Orderable.find(params[:id])\n\n respond_to do |format|\n if @orderable.update_attributes(params[:orderable])\n flash[:notice] = 'Orderable was successfully updated.'\n format.html { redirect_to(@orderable) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @orderable.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @table = Table.find(params[:id])\n\n respond_to do |format|\n if @table.update_attributes(params[:table].permit(:name, :notes, :x, :y, :table_type, :guest_ids => []))\n format.html { redirect_to @table, notice: 'Table was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @table.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def update\n @lane = Lane.find(params[:id])\n\n respond_to do |format|\n if @lane.update_attributes(params[:lane])\n format.html { redirect_to(@lane, :notice => 'Lane was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lane.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @vlan = Vlan.find(params[:id])\n\n respond_to do |format|\n if @vlan.update_attributes(params[:vlan])\n flash[:notice] = 'Vlan was successfully updated.'\n format.html { redirect_to(@vlan) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vlan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @id = args[:id] if args.key?(:id)\n @name = args[:name] if args.key?(:name)\n @resource_name = args[:resource_name] if args.key?(:resource_name)\n @type = args[:type] if args.key?(:type)\n end",
"def update!(**args)\n @description = args[:description] if args.key?(:description)\n @etag = args[:etag] if args.key?(:etag)\n @multi_cluster_routing_use_any = args[:multi_cluster_routing_use_any] if args.key?(:multi_cluster_routing_use_any)\n @name = args[:name] if args.key?(:name)\n @single_cluster_routing = args[:single_cluster_routing] if args.key?(:single_cluster_routing)\n end",
"def update\n @descriptor_generico = DescriptorGenerico.find(params[:id])\n\n respond_to do |format|\n if @descriptor_generico.update_attributes(params[:descriptor_generico])\n flash[:notice] = 'Descriptor Generico se ha actualizado con exito.'\n format.html { redirect_to(admin_descriptor_genericos_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @descriptor_generico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @vegetable = Vegetable.find(params[:id])\n\n respond_to do |format|\n if @vegetable.update_attributes(params[:vegetable])\n format.html { redirect_to(@vegetable, :notice => 'Vegetable was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vegetable.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @fault_type = FaultType.find(params[:id])\n\n respond_to do |format|\n if @fault_type.update_attributes(params[:fault_type])\n format.html { redirect_to(@fault_type, :notice => 'FaultType was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fault_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @node = Node.scopied.find(params[:id])\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(key, value)\n\t\tunless @resource_table.has_key?(key)\n\t\t\t@resource_table[key] = [value, @info] \n\t\t\tnew_resource = { key => [value, @info] }\n\n\t\t\t@neighbour_nodes.each do |n|\n\t\t\t\tsend_message [\"ADD_RESOURCE\", new_resource], 0, n.host, n.port\n\t\t\tend\n\n\t\t\tputs \"#{resource_table}\"\n\t\t\tresolve_queue(key)\n\t\tend\n\tend",
"def update\n @lotto_type = LottoType.find(params[:id])\n\n respond_to do |format|\n if @lotto_type.update_attributes(params[:lotto_type])\n format.html { redirect_to(@lotto_type, :notice => 'Lotto type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @lotto_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tagline = Tagline.find(params[:id])\n\n respond_to do |format|\n if @tagline.update_attributes(params[:tagline])\n flash[:notice] = 'Tagline was successfully updated.'\n format.html { redirect_to(@tagline) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tagline.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @automatic_resources = args[:automatic_resources] if args.key?(:automatic_resources)\n @create_time = args[:create_time] if args.key?(:create_time)\n @dedicated_resources = args[:dedicated_resources] if args.key?(:dedicated_resources)\n @deployed_index_auth_config = args[:deployed_index_auth_config] if args.key?(:deployed_index_auth_config)\n @deployment_group = args[:deployment_group] if args.key?(:deployment_group)\n @display_name = args[:display_name] if args.key?(:display_name)\n @enable_access_logging = args[:enable_access_logging] if args.key?(:enable_access_logging)\n @id = args[:id] if args.key?(:id)\n @index = args[:index] if args.key?(:index)\n @index_sync_time = args[:index_sync_time] if args.key?(:index_sync_time)\n @private_endpoints = args[:private_endpoints] if args.key?(:private_endpoints)\n @reserved_ip_ranges = args[:reserved_ip_ranges] if args.key?(:reserved_ip_ranges)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end"
] | [
"0.5409736",
"0.5356203",
"0.52444696",
"0.520978",
"0.51950705",
"0.51767594",
"0.5104458",
"0.5079469",
"0.506452",
"0.5062782",
"0.50571084",
"0.50479376",
"0.5008665",
"0.4931264",
"0.49015042",
"0.4892242",
"0.48538858",
"0.48454016",
"0.48239005",
"0.48239005",
"0.48208225",
"0.4811533",
"0.4807004",
"0.47944176",
"0.47677124",
"0.4762932",
"0.47481397",
"0.47464666",
"0.47440284",
"0.4730738",
"0.47254744",
"0.472464",
"0.47209537",
"0.47089994",
"0.47083068",
"0.4706008",
"0.46974152",
"0.46924224",
"0.4691145",
"0.46727943",
"0.4671595",
"0.4670429",
"0.46662343",
"0.466398",
"0.4661763",
"0.46614864",
"0.46614224",
"0.4660075",
"0.46573475",
"0.46566176",
"0.46557823",
"0.46554208",
"0.46529326",
"0.46504027",
"0.46457568",
"0.46453434",
"0.46431282",
"0.46412688",
"0.4638965",
"0.46357274",
"0.46340963",
"0.4626803",
"0.46237332",
"0.4618481",
"0.46097475",
"0.46038604",
"0.46033722",
"0.46025777",
"0.46005112",
"0.45986015",
"0.4591937",
"0.4590423",
"0.45895815",
"0.45835873",
"0.4580754",
"0.457564",
"0.45742664",
"0.45742556",
"0.45666134",
"0.45664382",
"0.45641887",
"0.45635438",
"0.45620015",
"0.45553842",
"0.45481235",
"0.45468733",
"0.45465353",
"0.45440632",
"0.45425552",
"0.45424375",
"0.45411012",
"0.45372307",
"0.4535634",
"0.45352876",
"0.45352876",
"0.45352876",
"0.45352876",
"0.45352876",
"0.45352876",
"0.45352876"
] | 0.58159214 | 0 |
DELETE /lendables/1 DELETE /lendables/1.xml | def destroy
@lendable = Lendable.find(params[:id])
@lendable.destroy
respond_to do |format|
format.html { redirect_to(lendables_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete_all(xpath); end",
"def unlink \n @lnode.unlink unless @lnode.nil?\n end",
"def delete_node(l)\n node = Node.find_by(layer: l).destroy\n Connection.destroy_all(parent_id: node.id)\n Connection.destroy_all(child_id: node.id)\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def delete\n CONNECTION.execute(\"DELETE FROM links WHERE id = #{self.id};\")\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def table_remove_lun(path)\n @luns.each do |elem|\n if elem[3] == path\n @luns.delete(elem)\n end\n end\n @luns_added.each do |elem|\n if elem[3] == path\n @luns_added.delete(elem)\n end\n end\n self.change_items(@luns)\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def destroy \n Link.connection.execute(\"delete from links where id in (#{params[:id].join(',')})\") unless params[:id].blank?\n respond_to do |format|\n format.html { redirect_to(links_url) }\n format.xml { head :ok }\n end\n end",
"def del\n delete\n end",
"def delete!\n PoolNode.rmdir(@id)\n super\n Address.delete(@id)\n Subnet.delete(@subnet)\n end",
"def delete\n CMark.node_unlink(@pointer)\n end",
"def delete\n DB.exec(\"DELETE FROM stylists WHERE id = #{self.id};\")\n end",
"def delete_all\n neo4j_query(\"MATCH (n:`#{mapped_label_name}`) OPTIONAL MATCH (n)-[r]-() DELETE n,r\")\n end",
"def delete_row lb # {{{\n index = lb.current_index\n id = lb.list[lb.current_index].first\n lb.list().delete_at(index)\n lb.touch\n ret = @db.execute(\"UPDATE #{@tablename} SET status = ? WHERE rowid = ?\", [ \"x\", id ])\nend",
"def delete\n\t\tdb.execute{ \"delete edge #{ref_name} #{rrid}\" }\n\tend",
"def delete\n blacklight_items.each do |r|\n solr.delete_by_id r[\"id\"]\n solr.commit\n end\n end",
"def delete_from_disk; end",
"def delete(arel, name = nil, binds = [])\n exec_delete(to_sql(arel), name, binds)\n end",
"def test_set3_06b_delete_res_object()\n user = \"test_user\"\n priv = \"test_privilege\"\n res_ob_type = \"test\"\n res_ob_adr = \"/db/temporary/testsource\"\n \n @test_acl.create_principal(user)\n @test_acl.create_resource_object(res_ob_type, res_ob_adr, user)\n id = @test_acl.create_ace(user, \"allow\", priv, res_ob_type, res_ob_adr)\n \n @test_acl.delete_res_object(res_ob_type, res_ob_adr)\n query = \"doc(\\\"#{@col_path}acl.xml\\\")//node()[@id=\\\"#{id}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end",
"def remove\n valid = parse_valid(params)\n # puts valid\n choose = $db.search(\"//book[\"+valid+\"]\").remove\n size = 0\n for i in choose\n size += 1\n end\n $file = open PATH, \"w\"\n $file.write $db\n $file.close\n render :soap => \"<result>\"+size.to_s+\"</result>\"\n end",
"def destroy; delete end",
"def rm(*path)\n super; on_success{ nil }\n end",
"def run_on_deletion(paths)\n end",
"def run_on_deletion(paths)\n end",
"def rm path\n end",
"def delete_row(row_id); rest_delete(\"#{link('rows')}/#{row_id}\"); nil; end",
"def delete!\n Recliner.delete(uri)\n end",
"def db_delete\n assert_privileges(\"db_delete\")\n db = MiqWidgetSet.find(params[:id]) # temp var to determine the parent node of deleted items\n process_elements(db, MiqWidgetSet, \"destroy\")\n g = MiqGroup.find(@sb[:nodes][2].split('_').first)\n # delete dashboard id from group settings and save\n db_order = g.settings && g.settings[:dashboard_order] ? g.settings[:dashboard_order] : nil\n db_order&.delete(db.id)\n g.save\n nodes = x_node.split('-')\n self.x_node = \"#{nodes[0]}-#{nodes[1]}-#{nodes[2].split('_').first}\"\n replace_right_cell(:replace_trees => [:db])\n end",
"def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end",
"def destroy\n @dl_type = DlType.find(params[:id])\n @dl_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(downloads_admin_dl_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n listentries = List.find(:all,:conditions => \"list_cat_id = #{params[:id]}\")\n for listentry in listentries \n listentry.destroy\n end\n @list_cat = ListCat.find(params[:id])\n @list_cat.destroy\n\n respond_to do |format|\n format.html { redirect_to(:controller => 'lists') }\n format.xml { head :ok }\n end\n end",
"def delete_node(current_node)\n\nend",
"def delete\n \n end",
"def destroy\n @lob.destroy\n\n head :no_content\n end",
"def delete\n end",
"def destroy\n @lb202556 = Lb202556.find(params[:id])\n @lb202556.destroy\n\n respond_to do |format|\n format.html { redirect_to(lb202556s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lien = Lien.find(params[:id])\n @lien.destroy\n\n respond_to do |format|\n format.html { redirect_to(liens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lien = Lien.find(params[:id])\n @lien.destroy\n\n respond_to do |format|\n format.html { redirect_to(liens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end",
"def delete_all\n solr.delete_by_query('*:*')\n solr.commit\n end",
"def cascade_destroy\n ltree_scope.where(\"#{self.class.table_name}.#{ltree_path_column} <@ ?\", ltree_path_in_database).destroy_all\n end",
"def delete\n \n end",
"def destroy\n @listitem.destroy\n head :no_content\nend",
"def delete_content_paths\n\n # Delete all the paths with the ancestor as the current id\n ContentPath.delete_all(:ancestor => self.id)\n\n # Delete all the paths with the descendant as the current id\n ContentPath.delete_all(:descendant => self.id)\n end",
"def delete_table(table_id); delete(\"tables/#{table_id}\"); nil; end",
"def delete(name); end",
"def delete(name); 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 delete_all(name); end",
"def destroy\n @request = Request.find(params[:id])\n @request_items = @request.request_items\n @request_items.each do |ri|\n ri.destroy\n end\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to(requests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @browsenodeid = Browsenodeid.find(params[:id])\n @browsenodeid.destroy\n\n respond_to do |format|\n format.html { redirect_to(browsenodeids_url) }\n format.xml { head :ok }\n end\n end",
"def 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 destroy\n \n @ontology = SYMPH::Ontology.find(params[:id])\n @ontology.disable\n @ontology.destroy\n \n respond_to do |format|\n format.html { redirect_to :action => :index }\n format.xml { head :ok }\n end\n end",
"def delete(model)\n\n # LREM key 0 <id> means remove all elements matching <id>\n # @see http://redis.io/commands/lrem\n key.call(\"LREM\", 0, model.id)\n end",
"def destroy\n @loaderio_7abd2d23994e8fb4f6f945f20b5204db = Loaderio7abd2d23994e8fb4f6f945f20b5204db.find(params[:id])\n @loaderio_7abd2d23994e8fb4f6f945f20b5204db.destroy\n\n respond_to do |format|\n format.html { redirect_to(loaderio_7abd2d23994e8fb4f6f945f20b5204dbs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lek = Lek.find(params[:id])\n @lek.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(leks_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n\n end",
"def delete_list(id)\n query(\"DELETE FROM todos WHERE list_id = $1\", id)\n query(\"DELETE FROM lists WHERE id = $1\", id)\n end",
"def remove\n # remove the system link by id\n @system_link = SystemLink.where(\"id=?\", params[:id])&.destroy_all\n\n end",
"def destroy\n @list_item.destroy\n\n head :no_content\n end",
"def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n Clenum.destroy params[:ids].split(',')\n\n respond_to do |format|\n format.html { redirect_to(clenums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @orderable = Orderable.find(params[:id])\n @orderable.destroy\n\n respond_to do |format|\n format.html { redirect_to(orderables_url) }\n format.xml { head :ok }\n end\n end",
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end",
"def destroy\n @tree_node_ac_rights = TreeNodeAcRight.find(params[:id])\n @tree_node_ac_rights.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_tree_node_tree_node_permissions_path }\n format.xml { head :ok }\n end\n end",
"def delete_children(id, gel)\n element_dataset.filter(container_id_sym => id).delete\n end",
"def delete()\n @ole.Delete()\n end",
"def delete()\n @ole.Delete()\n end",
"def delete()\n @ole.Delete()\n end",
"def delete()\n @ole.Delete()\n end",
"def destroy\n @checklist = Checklist.find(params[:id])\n @checklist.destroy\n\n respond_to do |format|\n format.html { redirect_to(checklists_url) }\n format.xml { head :ok }\n end\n end",
"def delete_operations; end",
"def delete\n\n\tend",
"def delete\n begin \n # file_assets\n file_assets.each do |file_asset|\n file_asset.delete\n end\n # We now reload the self to update that the child assets have been removed...\n reload()\n # Call ActiveFedora Deleted via super \n super()\n rescue Exception => e\n raise \"There was an error deleting the resource: \" + e.message\n end\n end",
"def action_delete\n if current_resource.exists?\n converge_by(\"remove l2interface #{current_resource.name}\") do\n command = \"netdev l2interface delete #{new_resource.l2_interface_name}\"\n execute_command(command)\n end\n end\n end",
"def destroy\n @checklist.destroy\n end",
"def purge\n \n @job = DialJob.find(params[:id])\n\[email protected]_results.each do |r|\n\t\tr.destroy\n\tend\n\[email protected]\n\t\n\tdir = nil\n\tjid = @job.id\n\tdfd = Dir.new(WarVOX::Config.data_path)\n\tdfd.entries.each do |ent|\n\t\tj,m = ent.split('-', 2)\n\t\tif (m and j == jid)\n\t\t\tdir = File.join(WarVOX::Config.data_path, ent)\n\t\tend\n\tend\n\t\n\tFileUtils.rm_rf(dir) if dir\n\n respond_to do |format|\n format.html { redirect_to :action => 'index' }\n format.xml { head :ok }\n end\n end",
"def delete(*uris); end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def deleteFlatpackLinkAll( flatpack_id)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n return doCurl(\"delete\",\"/flatpack/link/all\",params)\n end"
] | [
"0.64729553",
"0.6457131",
"0.6360469",
"0.6329929",
"0.59976476",
"0.589152",
"0.5880542",
"0.58798677",
"0.5838007",
"0.5838007",
"0.582222",
"0.5818429",
"0.5811634",
"0.5777692",
"0.57700217",
"0.57662344",
"0.5757047",
"0.5741342",
"0.57393384",
"0.57297313",
"0.5726183",
"0.5722067",
"0.571867",
"0.5717466",
"0.57060474",
"0.569841",
"0.569841",
"0.56857216",
"0.5651816",
"0.56242996",
"0.5623666",
"0.561105",
"0.5591244",
"0.5588024",
"0.55872416",
"0.558564",
"0.557669",
"0.5566865",
"0.5566535",
"0.55536777",
"0.55536777",
"0.55459964",
"0.5533718",
"0.553041",
"0.5528792",
"0.55283153",
"0.5518124",
"0.5501728",
"0.5501237",
"0.5501237",
"0.5492161",
"0.5477936",
"0.54756033",
"0.54724896",
"0.5462483",
"0.5462483",
"0.5462483",
"0.5462483",
"0.5462483",
"0.5462483",
"0.5462483",
"0.5451657",
"0.5446016",
"0.5441743",
"0.5438923",
"0.5432735",
"0.5427777",
"0.5427159",
"0.5425574",
"0.54190636",
"0.54166764",
"0.54166764",
"0.54166764",
"0.54166764",
"0.54166764",
"0.54166764",
"0.54166764",
"0.54166764",
"0.54166764",
"0.54166764",
"0.5415083",
"0.5414154",
"0.5407051",
"0.5403134",
"0.540213",
"0.540116",
"0.5398693",
"0.5398693",
"0.5398693",
"0.5398693",
"0.5396253",
"0.53940904",
"0.53859514",
"0.5377985",
"0.53772473",
"0.5376831",
"0.5376785",
"0.53747785",
"0.5372314",
"0.537218"
] | 0.68560266 | 0 |
denoted by `n!`, is the product of all positive integers less than or equal to `n`. Solution Write a function called factorial() that takes a number and multiplies up all numbers from 1 through that number. Example: factorial(5) should equal 1 2 3 4 5. | def factorial(num)
result = 1;
for i in 1..num
result *= i
end
puts result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factorial(n)\n product = 1\n for i in (1..n)\n product *= i\n end\n product\nend",
"def factorial(n)\n if n == 0 || n == 1 \n \treturn 1\n else\n numbers = []\n n.downto(1) { |x| numbers << x }\n numbers.inject(1) { |x,y| x * y }\n end\nend",
"def factorial(n)\n result = 1\n\n while n > 1\n result *= n\n n -= 1\n end\n\n result\n end",
"def factorial(n)\n if n == 0\n \t1\n else\n (1..n).inject {|product, n| product * n }\n end\nend",
"def factorial(n) \r\n \r\n answer = 1\r\n \r\n for i in 2..n do\r\n answer *= i\r\n end\r\n\r\n return answer\r\n\r\nend",
"def factorial(n)\n result = 1\n (1..n).each do |n|\n result *= n\n end\n return result\nend",
"def factorial n\n if n == 0\n return 1\n end\n return (1..n).inject(:*)\nend",
"def factorial(n)\r\n ret = 1\r\n for i in 1..n \r\n ret *= i\r\n end\r\n return ret\r\nend",
"def factorial(n)\n if n == 0; return 1; end\n return (1..n).reduce(:*)\nend",
"def factorial(n)\n nil if n.negative?\n\n result = 1\n while n.positive?\n result *= n\n n -= 1\n end\n puts result\n end",
"def factorial(n)\n\tif n < 0\n\t\treturn nil \n\tend\n\tvalue = 1\n\twhile n > 0\n\t\tvalue = value * n \n\t\tn -= 1 \n\tend\n\treturn value \n end",
"def factorial(n)\n \n result = 1\n while n > 0\n result *= n\n n -= 1\n end\n \n result\nend",
"def factorial(n)\n (1..n).inject(1) {|product, n| product * n }\nend",
"def factorial(n)\n fact = 1;\n for i in 1..n; fact *= i; end;\n return fact;\nend",
"def factorial(n)\n\tsum = 1\n\tfor i in 1..n\n\t\tsum*=i \n\tend \nreturn sum \nend",
"def n_factorial(n)\n\tif n == 0\n\t\tx_factorial = 1\n\telse\n\t\tx_factorial = 1\n\t\tfor x in 1..n\n\t\tx_factorial *= x \n\t\tend\n\tend\n\treturn x_factorial\nend",
"def factorial(n)\n factorial = 1\n while n > 0\n factorial *= n\n n -= 1\n end\n factorial\nend",
"def factorial(n)\r\n\tif n < 0\r\n\t\tnil\r\n\tend\r\n\r\n\tresult = 1\r\n\twhile n > 0\r\n\t\tresult = result * n\r\n\r\n\t\tn -= 1\r\n\tend\r\n\tresult\r\n\r\n\r\nend",
"def factorial(n)\n f = 1\n (1..n).each do |i|\n f *= i\n end\n f\nend",
"def factorial(n)\n f = 1\n (1..n).each do |i|\n f *= i\n end\n f\nend",
"def factorial(n)\n f = 1\n (1..n).each do |i|\n f *= i\n end\n f\nend",
"def factorial(n)\n f = 1\n (1..n).each do |i|\n f *= i\n end\n f\nend",
"def factorial(n)\n (1..n).reduce(:*)\nend",
"def factorial(n)\n\tx = 1\n\t## SOLUTION WITH WHILE LOOP: NEXT 3 LINES\n#\twhile n > 1\n#\t\tx *= n\n#\t\tn -= 1\n\t##SOLUTION WITH FOR LOOP: NEXT 2 LINES\n\tfor i in (2 .. n)\n\t\tx *= i\n\tend\n\treturn x\nend",
"def n_factorial(n)\n\tx_factorial = 1\n\t\n\tif n == 0\n\t\tx_factorial = 1\n\telse\n\n\t\tfor x in 1..n\n\t\t\tx_factorial *= x \n\t\tend\n\tend\n\n\treturn x_factorial\nend",
"def factorial(n)\n (1..n).inject(:*)\nend",
"def factorial(n)\n (1..n).inject(:*)\nend",
"def factorial(n)\n\tif n == 0\n\t\t1\n\telse\n\t\tn * factorial(n-1)\n\tend\nend",
"def factorial n\n\treturn (1..n).reduce(:*)\nend",
"def factorial(n)\n tot = 1\n (1..n).each do |n|\n tot *= x\n end\n\n tot\nend",
"def factorial(n)\n product = n\n p \"at the start product is #{product}\"\n while n > 1\n n -= 1\n p \"we multiply #{product} by #{n}\"\n product *= n\n p \"we get #{product}\"\n end\n product\nend",
"def factorial(n)\n\traise ArgumentError if n.nil? || n < 0\n\n\tif n == 0 || n == 1\n\t\t1\n\telse\n\t\tn * factorial(n-1)\n\tend\nend",
"def factorial(n)\n (1..n).inject(1) {|a,b| a*=b}\nend",
"def factorial(n)\n\treturn 1 if n <= 1\n\tn * factorial(n - 1)\nend",
"def factorial(n)\n i = 1\n result = 1\n until i > n\n result *= i\n i+=1\n end\n return result\nend",
"def factorial(n)\n\tif 0 == n or 1 == n\n\t\treturn 1\n\telse\n\t\treturn n * factorial(n - 1)\n\tend\nend",
"def factorial_n(num)\n result = 1\n num.times { |i| result *= i + 1 }\n result\nend",
"def factorial(num)\n product = num\n (1...num).each{|n| product *= n}\n product\nend",
"def factorial(number)\n product = 1\n (1..number).each do |n|\n product *= n\n end\n return product\nend",
"def factorial(number)\n if number <= 1\n 1\n else\n (1..number).each.reduce(:*)\n end\nend",
"def factorial(number)\n (1..number).each do |n|\n total *= n\n end\nend",
"def factorial(n)\n raise ArgumentError.new \"N must be greater than or equal to 0\" if n < 0\n return 1 if n <= 1\n return n * factorial(n - 1)\nend",
"def factorial(n)\nend",
"def factorial(n)\n return 1 if n == 0\n new_num = 0\n (n - 1).times do\n new_num += 1\n n *= new_num\n end\n n\nend",
"def factorial(n)\n if n < 0\n return false\n end\n return 1\n while n > 0\n factorial_number = n * factorial_number\n n-= 1\n end\n return factorial_number\nend",
"def factorial (n)\n \t\tn == 0? 1 : n * factorial(n-1);\n\t\tend",
"def factorial(num)\n product = 1\n for factor in 1..num\n product *= factor\n end\n product\nend",
"def computeFactorial(n)\n a = 1.0\n for i in 2..n\n a = a*i\n end\n return a\nend",
"def factorial(n)\n return 1 if n <= 1\n\n (1..n).reduce(1) do |acc, i|\n acc * i\n end\nend",
"def factorial(n)\n if n == 0\n n = 1\n else\n x = n - 1\n while x > 0\n n*=x\n x = x-1 \n end\n end\n puts n\nend",
"def factorial(n)\n (1..n).reduce(:*) || 1\nend",
"def factorial(n)\n (1..n).reduce(:*) || 1\nend",
"def factorial(n)\n\treturn 1 if n == 0\n\traise ArgumentError, \"Sorry! I can't calculate negative numbers!\" if n < 0\n\treturn (n * factorial(n - 1))\nend",
"def factorial(n)\r\n\tresult = 1\r\n if(n < 0)\r\n return nil\r\n end\r\n\twhile n > 0\r\n result= result*n\r\n n = n - 1\r\n\tend\r\n return result\r\nend",
"def factorial(n)\n (1..n).inject { |product, n| product * n }\nend",
"def factorial(n)\n if n == 0\n 1\n else\n n * factorial(n-1)\n end\nend",
"def get_factorial(n)\r\n total = 1\r\n while n > 1\r\n total *= n\r\n n -= 1\r\n end\r\n return total\r\nend",
"def factorial(n)\n if n == 1 || n == 0\n 1\n else\n n * factorial(n-1)\n end\nend",
"def factorial(num)\n product = 1\n (1..num).each {|n| product *= n}\n product\nend",
"def factorial(n)\n (1..n).inject(:*) || 1\nend",
"def factorial n\n arr = []\n while n >= 1\n arr.push n\n n -=1\n end\n arr.reduce(:*)\nend",
"def factorial(n)\n if n <= 0\n 1\n else\n n * factorial(n - 1)\n end\nend",
"def factorial(n)\n raise ArgumentError, \"A number must be greater than or equal to 0\" if n < 0\n return 1 if n == 0\n\n return n * factorial(n - 1)\nend",
"def factorial(n)\n if n <= 1\n 1\n else\n n * factorial(n - 1)\n end\nend",
"def factorial(n)\n if n <= 1\n 1\n else\n n * factorial(n - 1)\n end\nend",
"def factorial(number)\n if number <= 1\n 1\n else\n number.downto(1).reduce(:*)\n end\nend",
"def factorial(number) \n if number == 0\n return 1\n end\n \n product = 1\n \n for number in (1..number)\n product = product * number\n \t\n end\n \n return product\n end",
"def factorial(n)\n counter = n\n factorial = 1\n while counter > 0\n factorial *= counter\n counter -= 1\n end\n p factorial\nend",
"def factorial(n)\n return n if n == 1\n return 1 if n == 0\n raise ArgumentError if n < 0\n \n n = n * factorial(n-1)\n end",
"def factorial(n)\n if n == 1\n return 1\n end\n \n return factorial(n-1)*n\n\n\nend",
"def factorial(n)\n\t\n\tif n == 0\n\t\tputs(1)\n\t\treturn 1\n\tend\n\t\n\tfactored = n\n\tidx = 0\n\t\n\twhile idx < n\n\t\tfactored = n*(n - idx)\n\t\tidx += 1\n\t\tputs(factored)\n\tend\n\treturn factored\nend",
"def factorial(n)\n raise ArgumentError if n < 0\n if n == 0\n return 1\n end\n return n * (factorial(n-1))\nend",
"def factorial(number)\n product = 1\n while number >= 1\n product *= number\n number = number - 1\n end\n product\nend",
"def factorial(n)\r\n return 1 if n <= 1\r\n return n*factorial(n-1)\r\nend",
"def factorial(number)\n product = 1\n while number > 1\n product *= number\n number -= 1\n end\n product\nend",
"def factorial(number)\n total = 1\n for i in 1..number\n total *= i \n end\n total\nend",
"def factorial(number)\n total = 1\n for i in 1..number\n total *= i \n end\n total\nend",
"def factorial(n)\n result = 1\n i = 1\n\n until i > n\n result *= i\n i += 1\n end\n\n puts result\n\nend",
"def factorial(n)\n if n < 2\n 1\n else\n n * factorial(n-1)\n end\nend",
"def factorial(n)\n SwingFactorial.new(n).result\n end",
"def factorial(n)\n raise ArgumentError, \"Number is less then 0\" if n < 0\n return 1 if n == 0\n\n return n * factorial(n - 1)\nend",
"def factorial(n)\n return 1 if n == 0\n return factorial(n - 1) * n\nend",
"def factorial(n1)\n i = 0\n output = 1\n\n while i < n1\n i += 1\n output = output * i \n \n end\n return output \nend",
"def factorial(num)\n(1..num).reduce(:*)\nend",
"def factorial_method(n)# define the method and argument\n factorial = n#the value of facotorial asiggned equal the value if n\n factorial = 1 if n < 2# if n < 2 then factorial is 1\n if n >= 2# if n is bigger o equal to 2 then...\n for i in 2..n-1#run i to n-1\n factorial = factorial * i#factorial assigned the product of factorial and i, each time the value of i grows\n end#end of for loop\n end#end of if condition\n factorial#implicit return\nend",
"def factorial(n)\n # until ((n - 1) = 0)\n # do n - 1\n if n == 0\n return 1\n else\n fact_array = Array.new(n) {|f| f = f + 1}\n fact_array.inject(:*)\n end\nend",
"def factorial(n)\n if n == 0\n return 1\n end\n return n * factorial(n-1)\nend",
"def factorial(n)\n if n != 0\n return n *= factorial(n-1)\nelse\n return 1\nend\nend",
"def factorial(n)\n raise ArgumentError.new(\"Number must be at least 0!\") if n < 0\n return 1 if n == 0\n return n * factorial(n-1)\nend",
"def factorial(n)\n for i in (1...n)\n n = n * i\n # puts n\n end\n puts n\nend",
"def factorial(n)\n return 1 if n <= 1\n n * factorial(n-1)\nend",
"def factorial(number)\n number.downto(1).reduce(:*)\nend",
"def factorial(num)\n result = 1\n (2..num).each do |number|\n result *= number\n end\n result\nend",
"def factorial(n)\n if n < 0 \n raise ArgumentError.new('Provide a number greater than 0.')\n end\n return 1 if n == 0\n\n return (n * factorial(n - 1))\nend",
"def factorial(n)\n raise ArgumentError if n < 0\n return 1 if n == 0\n return n * factorial(n - 1)\nend",
"def factorial(number)\n product = 1\n while number > 1\n product *= number\n number -= 1\n end\n p product\nend",
"def factorial(n)\n raise ArgumentError, 'Must provide a number greater than 1' unless n >= 0\n\n if n == 1 || n == 0\n return 1\n else\n return n * factorial(n - 1)\n end \n \nend",
"def factorial(number)\n # Your code goes here\n if number == 0\n return 1\n end\n\n factorial = number\n for next_number in 2...number\n factorial *= next_number\n #longhand\n #factorial = factorial * next_number\n end\n\n return factorial\nend",
"def factorial2(n)\n\tproduct = 1\n\t(2..n).each { |i| product*=i // product = product*i}\n\tproduct\nend",
"def factorial(n)\n raise ArgumentError if n < 0\n return 1 if n == 1 || n == 0\n return n * factorial(n-1)\nend",
"def factorial(n)\n return 1 if n <= 0\n n * factorial(n-1)\nend"
] | [
"0.8794431",
"0.87536556",
"0.8735388",
"0.8666659",
"0.8665695",
"0.8648504",
"0.8642203",
"0.864168",
"0.8617912",
"0.86042565",
"0.85957146",
"0.85886884",
"0.85623807",
"0.85420895",
"0.85265267",
"0.8525576",
"0.852055",
"0.85158575",
"0.8515507",
"0.8515507",
"0.8515507",
"0.8515507",
"0.84991384",
"0.848965",
"0.8489383",
"0.8479887",
"0.8477424",
"0.84510386",
"0.84430224",
"0.84303313",
"0.8417198",
"0.8412451",
"0.83642524",
"0.83445215",
"0.83332795",
"0.8332556",
"0.83159924",
"0.8315569",
"0.8315454",
"0.8306889",
"0.8298355",
"0.8286888",
"0.8283139",
"0.82818604",
"0.8279298",
"0.82731444",
"0.8269997",
"0.82651275",
"0.82600015",
"0.82565296",
"0.8254162",
"0.8254162",
"0.8250539",
"0.82417196",
"0.8233484",
"0.82270706",
"0.822429",
"0.82229924",
"0.8211121",
"0.82103074",
"0.82038414",
"0.8199869",
"0.8198606",
"0.8194682",
"0.8194682",
"0.81934357",
"0.81933254",
"0.81889737",
"0.8179581",
"0.8172807",
"0.81714183",
"0.8167826",
"0.8158333",
"0.8157715",
"0.81575054",
"0.81475025",
"0.81475025",
"0.8137912",
"0.8135372",
"0.81332576",
"0.8130448",
"0.81213737",
"0.8118619",
"0.8117287",
"0.8115423",
"0.81120825",
"0.8108162",
"0.8104374",
"0.80986804",
"0.80960125",
"0.8095095",
"0.8094462",
"0.80857944",
"0.80848956",
"0.80832756",
"0.8079072",
"0.8069863",
"0.80695736",
"0.8068302",
"0.80501956",
"0.80448973"
] | 0.0 | -1 |
Return the maximum number of vdevs without which the pool is still guaranteed to be available. For simple examples: stripe: 0 mirror: 1 raidz1: 1 raidz2: 2 raidz3: 3 | def redundancy_level
# Note that the slog devices show up in @root_vdev.children, but l2arc
# and spare devices don't. That's exactly what we want.
top_level_parities = @root_vdev.children.map do |top_level_vdev|
case top_level_vdev.type
when "mirror"
top_level_vdev.children.count - 1
when "raidz"
top_level_vdev.nparity
else
0
end
end
top_level_parities.min
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_free_gigabytes\n if plan_id == 'pro'\n 100\n elsif plan_id == 'basic'\n 10\n else\n 1\n end\n end",
"def largest_length\n @executor.getLargestPoolSize\n end",
"def get_max_haplotype_size\n max_haplotype = 0\n @blocks.values.each do |block|\n if block.haplotypes.length > max_haplotype\n max_haplotype = block.haplotypes.length\n end\n end\n return max_haplotype\n end",
"def item_max() SES::Bestiary.get_enemy_list.size end",
"def max_box\n return @boxes.size\n end",
"def free_block_count\n dev_stat ? dev_stat.blocks_free / (Block.size / dev_stat.block_size) : 0\n end",
"def CPU_max_number_of_cpu(value)\n if resource.class.name.ends_with?(\"Container\")\n numcpus = resource.vim_performance_states.last.state_data[:numvcpus]\n else\n numcpus = if resource.methods.include?(:cpu_total_cores) then resource.cpu_total_cores else 0 end\n end\n [value, numcpus].max.to_i\n end",
"def maximum_size\n @ids.size\n end",
"def remaining\n max - used\n end",
"def size\n @max\n end",
"def item_max\r\n $game_troop.alive_members.size\r\n end",
"def find_max_descriptors(max_descripors)\n i = max_descripors\n max_size = 1024\n while i != max_size && i > 1024\n max_size = EM.set_descriptor_table_size i\n i /= 2 if max_size < i\n end\n max_size\nend",
"def item_max; @data ? @data.size : 0; end",
"def get_max_system_token_count\n max = []\n get_pool_names.each do |pool_name|\n\tmax.push( self.pools[pool_name].max_counted_token[0] )\n end\n max = max.sort {|a,b| b[1] <=> a[1]}\n #puts max.inspect\n return max[0] \n end",
"def pool_size\n @pool.pool_size\n end",
"def item_max\n return 0 unless @data\n @data.size\n end",
"def max_value_size\n @max_value_size ||= options[:values].max { |a, b| a.size <=> b.size }.size\n end",
"def max_items\n main.max_items\n end",
"def max_count\n multiple? ? (@schema['max_count'] || :unlimited) : nil\n end",
"def item_max\n $game_party.battle_members.size\n end",
"def pool_capacity; end",
"def maximum_bytes_billed\n Integer @gapi.configuration.query.maximum_bytes_billed\n rescue StandardError\n nil\n end",
"def item_max\n return @data.size\n end",
"def item_max\n return @data.size\n end",
"def current_pool_size(pool_name)\n pool(pool_name).count\n end",
"def item_max\n @dataConsumable ? @dataConsumable.size : 1\n end",
"def max_allocated_storage\n data[:max_allocated_storage]\n end",
"def max_available_electricity\n @max_available_electricity ||=\n @producer.demand * @producer.output(:electricity).conversion\n end",
"def item_max\r\n @list.size\r\n end",
"def count_used_instances\n count = 0\n return count\n end",
"def specific_max_size(number)\n [self.size, number].min\n end",
"def allowed_device_count\n return @allowed_device_count\n end",
"def log_max_prune_count\n @max_prunes += 1\n end",
"def pool \n @pool.select(&:alive?).size\n end",
"def calc_gpus_unallocated\n @gpus_unallocated = 0\n #if @cluster_title.eql?('Owens')\n # @gpus_unallocated = nodes_info.lines(\"\\n\\n\").select { |node|\n # !node.include?(\"dedicated_threads = 28\") && node.include?(\"Unallocated\") }.size\n # elsif @cluster_title.eql?('Pitzer')\n # @gpus_unallocated = nodes_info.lines(\"\\n\\n\").select { |node| !node.include?(\"dedicated_threads = 40\") }.to_s.scan(/gpu_state=Unallocated/).size\n # else @cluster_title.eql?('Ruby')\n # # See line 62. Excluding the two debug nodes from the calculation.\n # @gpus_unallocated = nodes_info.lines(\"\\n\\n\").select { |node| node.include?(\"Unallocated\") && !node.include?(\"dedicated_threads = 20\") && node.include?(\"np = 20\") }.size\n # @oodClustersAdapter.info_all_each { |job| p job}\n #end\n end",
"def maximum_number_of_instances_are_not_running?\n list_of_running_instances.size < maximum_instances.to_i\n end",
"def item_max\r\n $game_party.members.size\r\n end",
"def check_allowed_bytesize(v, max)\n end",
"def size\n @pool.size\n end",
"def item_max\n @data ? @data.size : 0\n end",
"def item_max\n @data ? @data.size : 0\n end",
"def item_max\n @data ? @data.size : 0\n end",
"def item_max\n @data ? @data.size : 0\n end",
"def item_max\n @data ? @data.size : 0\n end",
"def item_max\n @data ? @data.size : 0\n end",
"def item_max\n @data ? @data.size : 0\n end",
"def item_max\n $game_party.members.size\n end",
"def item_max\n $game_party.members.size\n end",
"def num_non_responsive\n @hops.find_all { |hop| !hop.ping_responsive }.size\n end",
"def max_pool_size(val = nil)\n if val\n @j_del.setMaxPoolSize(val)\n self\n else\n @j_del.getMaxPoolSize\n end\n end",
"def max_size\n @group.max_size\n end",
"def item_max\r\n @actor ? @actor.equip_slots.size : 0\r\n end",
"def item_max; 64; end",
"def item_max\n return @data.nil? ? 0 : @data.size\n end",
"def num_free_processors\n num_processors - processors_in_use\n end",
"def item_max\n @data ? @data.size : 1;\n end",
"def item_max\n @data.nil? ? 0 : @data.size\n end",
"def size_without_waiters\n clients.inject(0) do |sum, element|\n sum += 1 unless element.waiting?\n sum\n end\n end",
"def candidate_limit(uuid); end",
"def spaceAvailable\n\t\treturn @maxElements > @weapons.length + @shieldBoosters.length\n\tend",
"def max_blocks; end",
"def next_size\n primes.detect { |p| p > (max_size * 2) }\n end",
"def max_virtual_cpus\n FFI::Libvirt.virDomainGetMaxVcpus(self)\n end",
"def max_candidates\n return @max_candidates\n end",
"def max_duffel_bag_value(cakes, capacity)\n maxes = {0 => 0}\n (1..capacity).each do |constraint|\n current_max = 0\n cakes.each do |cake|\n next if cake[1] == 0\n if (constraint - cake[0] >= 0)\n test_value = cake[1] + maxes[constraint - cake[0]]\n current_max = test_value > current_max ? test_value : current_max\n end\n end\n maxes[constraint] = current_max\n end\n maxes[capacity]\nend",
"def max_mem\n @max_mem ||= defaults[:max_mem]\n end",
"def variable_size\n @variable_size ||= if image_sets.none?(&:repeated?)\n max_variable_size\n else\n lcm = image_sets.select(&:repeated?).collect(&variable_size_method).reduce(:lcm)\n\n lcm * (max_variable_size / lcm.to_f).ceil\n end\n end",
"def spaceAvailable\n return @maxElements > @weapons.length + @shieldBoosters.length\n end",
"def length\n mutex.synchronize { running? ? @pool.length : 0 }\n end",
"def max_consumption\n @max_consumption ||= begin\n augment = max_repeats == Float::INFINITY ? 10 : max_repeats\n self.next&.max_consumption.to_i + augment\n end\n end",
"def size\n Float::MAX.to_i\n end",
"def item_max\n @data ? @data.size : 1\n end",
"def item_max\n @data ? @data.size : 1\n end",
"def item_max\n @data ? @data.size : 1\n end",
"def item_max\n @data ? @data.size : 1\n end",
"def item_max\n @data ? @data.size : 1\n end",
"def item_max\n @data ? @data.size : 1\n end",
"def specific_max_size(number); end",
"def storage_pool_size\n @storage_pool_size ||= 20\n end",
"def storage_pool_size\n @storage_pool_size ||= 20\n end",
"def max_number_of_investor_proofs_allowed\n 2\n end",
"def get_max_value()\n temp = @symtable.values\n temp.keep_if { |x| x.to_i < 16384 }\n temp.max\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 max_queue_count()\n @max_queue_count\n end",
"def item_max\r\r\n @data ? @data.size : 1\r\r\n end",
"def available_slots()\n return @size - @used_spaces\n end",
"def non_compliant_device_count\n return @non_compliant_device_count\n end",
"def size\n @max_entries\n end",
"def nbds_max\n File.read('/sys/module/nbd/parameters/nbds_max').chomp.to_i\n rescue StandardError => e\n OpenNebula.log_error(\"Cannot load kernel module parameter\\n#{e}\")\n 0\n end",
"def local_maximum_packet_size; end",
"def limit\n components.fetch(:size)\n end",
"def item_max\r\n \t@data ? @data.size : 1\r\n end",
"def max_iso_packet_size(endpoint_number); end",
"def remaining_ads_slots\n #num de anuncios dos pacotes - num de anuncios que possui ativos\n self.max_ads - self.active_ads_count\n end",
"def slots_available\n 5 - users.size\n end",
"def max_version\n all_versions.max\n end",
"def max_memory\n domain_info[:maxMem]\n end",
"def max_memory\n domain_info[:maxMem]\n end",
"def blocked_device_count\n return @blocked_device_count\n end",
"def vsize\n (weight.to_f / 4).ceil\n end",
"def nic_count\n vm.network_profile.network_interfaces.length\n end"
] | [
"0.61479676",
"0.61266536",
"0.60445374",
"0.60064226",
"0.5991015",
"0.5935252",
"0.5917585",
"0.5894255",
"0.5893222",
"0.5885927",
"0.58676416",
"0.5825332",
"0.58093035",
"0.580604",
"0.58006436",
"0.57750165",
"0.57748914",
"0.5773723",
"0.5765105",
"0.57554466",
"0.575544",
"0.57532334",
"0.57504416",
"0.57504416",
"0.57369137",
"0.57275957",
"0.5724905",
"0.57194996",
"0.5704382",
"0.56886727",
"0.56814325",
"0.567735",
"0.5676161",
"0.56621444",
"0.5656337",
"0.5655495",
"0.5651565",
"0.5639799",
"0.5633456",
"0.5619829",
"0.5619829",
"0.5619829",
"0.5619829",
"0.5619829",
"0.5619829",
"0.5619829",
"0.56172407",
"0.56172407",
"0.5616048",
"0.5613329",
"0.5594045",
"0.557924",
"0.55741656",
"0.5571674",
"0.5566053",
"0.556305",
"0.5560728",
"0.5554302",
"0.55490994",
"0.5546103",
"0.5544063",
"0.5538943",
"0.5536832",
"0.5536642",
"0.5531629",
"0.55302817",
"0.5527807",
"0.552349",
"0.5523231",
"0.551591",
"0.55156547",
"0.55127984",
"0.55127984",
"0.55127984",
"0.55127984",
"0.55127984",
"0.55127984",
"0.55125535",
"0.5504331",
"0.5504331",
"0.5497981",
"0.5497827",
"0.54967093",
"0.54800165",
"0.5461997",
"0.5449706",
"0.54462594",
"0.5442574",
"0.54367954",
"0.5434673",
"0.54267746",
"0.54157066",
"0.54077446",
"0.5406482",
"0.53945833",
"0.5390046",
"0.5388835",
"0.5388835",
"0.5386255",
"0.5378369",
"0.53709286"
] | 0.0 | -1 |
Refresh the pool properties and child lists. | def refresh
self.class.base_properties.each_with_index do |prop, prop_id|
@properties[prop] = get_property(prop_id)
end
refresh_features
refresh_status
refresh_config
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reload_pool_nodes\n @mutex.synchronize do\n reload_pool_nodes_unsync\n end\n end",
"def reload!\n LOG.debug \"Attempting to reload #{self}.\"\n @lock.synchronize do\n expected = @pool_initializer.call \n actual = @pool\n # remove old destinations\n (actual - expected).each{|d| @pool.delete(d) }\n # append new ones \n @pool += (expected - actual)\n end\n LOG.debug \"Successfully to reloaded #{self}.\"\n end",
"def flush\n flush_instance\n\n # Collect the resources again once they've been changed (that way `puppet\n # resource` will show the correct values after changes have been made).\n @property_hash = read_instance\n end",
"def update\n @transparent_pools = []\n @anonymous_pools = []\n\n res = HTTP.get 'https://raw.githubusercontent.com/fate0/proxylist/master/proxy.list'\n raise HTTPError, \"invalid http code #{res.code}\" if res.code != 200\n\n res.body.to_s.split(\"\\n\").each {|line| _pool_parse(line)}\n end",
"def deep_refresh\n recalc_height\n update_placement\n create_contents\n refresh\n end",
"def reload_pool_nodes_unsync\n if @hosts.is_a?(Array)\n create_multi_node_pool\n refresh_startup_nodes\n else\n create_single_node_pool\n end\n end",
"def refresh\n set_attributes\n end",
"def all\n @pool\n end",
"def _pool\n @pool._dump\n end",
"def refresh!\n @buckets = init_buckets\n @full_buckets = Hash.new\n end",
"def reload\n begin_reset_model\n clear\n\n @items_to_models = Hash.new\n @models_to_items = Hash.new\n @names_to_item = Hash.new\n @items_metadata = Hash[self => Metadata.new([], [], Set.new)]\n @resolver_from_model = Hash.new\n\n seen = Set.new\n sorted_roots = @root_models.\n sort_by(&:priority).reverse\n\n sorted_roots.each do |root_model|\n models = discover_model_hierarchy(root_model.model, root_model.categories, root_model.resolver, seen)\n models.each do |m|\n @resolver_from_model[m] = root_model.resolver\n end\n end\n\n rowCount.times do |row|\n compute_and_store_metadata(item(row))\n end\n self.horizontal_header_labels = [\"\"]\n ensure\n end_reset_model\n end",
"def refresh(*args)\n alloc(*args).refresh\n end",
"def reload_data\n reset_collection_data\n reload_collection_data\n end",
"def flush\n return if @property_hash.empty?\n\n if @resource.should(:primitive)\n target = @resource.should(:primitive)\n elsif @resource.should(:group)\n target = @resource.should(:group)\n else\n raise Puppet::Error, 'No primitive or group'\n end\n updated = 'clone '\n updated << \"#{@resource.value(:name)} \"\n updated << \"#{target} \"\n meta = []\n {\n clone_max: 'clone-max',\n clone_node_max: 'clone-node-max',\n notify_clones: 'notify',\n globally_unique: 'globally-unique',\n ordered: 'ordered',\n interleave: 'interleave'\n }.each do |property, clone_property|\n meta << \"#{clone_property}=#{@resource.should(property)}\" unless @resource.should(property) == :absent\n end\n updated << 'meta ' << meta.join(' ') unless meta.empty?\n debug \"Update: #{updated}\"\n Tempfile.open('puppet_crm_update') do |tmpfile|\n tmpfile.write(updated)\n tmpfile.flush\n cmd = [command(:crm), 'configure', 'load', 'update', tmpfile.path.to_s]\n self.class.run_command_in_cib(cmd, @resource.value(:cib))\n end\n end",
"def reload\n reset\n fetch\n end",
"def reload\n reset\n fetch\n end",
"def pools\n @pools ||= {}\n end",
"def pools\n @pools ||= {}\n end",
"def avail\n updatePool\n @pool\n end",
"def update\n @resource_pool_master.update(resource_pool_master_params)\n @resource_pool_master = ResourcePoolMaster.new\n @resource_pool_masters = ResourcePoolMaster.all\n end",
"def reload_pool_nodes(raise_error)\n @mutex.synchronize do\n reload_pool_nodes_unsync(raise_error)\n end\n end",
"def refresh\n @all = nil\n @player_hashes = nil\n self\n end",
"def after_sync_configuration\n unless Jetpants.topology.pools.include? self\n Jetpants.topology.add_pool self\n end\n end",
"def pool\n @pool.dup\n end",
"def reload!\n # Reload the configuration\n load_config!\n\n # Clear the VMs because this can now be diferent due to configuration\n @vms = nil\n end",
"def pool \n @pool\n end",
"def refresh; end",
"def reload\n refresh\n end",
"def reload\n refresh\n end",
"def update_volume_info\n\t\t#\t\t@pool = Pool.find(self.pool_id)\n\t\t#\t\t@host = Host.find(@pool.host_id)\n\t\t#\n\t\t#\t\tconnection = ConnectionsManager.instance\n\t\t#\t\tconnection_hash = connection.get(@host.name)\n\t\t#\t\tconn = connection_hash[:conn]\n\n\t\t# get pool reference in order to get a reference to the volume\n\t\t@pool = @conn.lookup_storage_pool_by_name(@pool.name)\n\t\tvolume = @pool.lookup_volume_by_name(self.name)\n\t\tvolume_info = volume.info\n\t\t\n\t\t# add some stats to pool object\n\t\tdivide_to_gigabytes = (1024 * 1024 * 1024).to_f\n\t\tself.allocation = (volume_info.allocation.to_f / divide_to_gigabytes).to_f\n\tend",
"def refresh\n # FIXME\n end",
"def reload\n Config.object.inject_shortcuts self\n @trees.each(&:reload)\n end",
"def across_pool_state\n super\n end",
"def load_pools_to_redis\n @redis.with_metrics do |redis|\n previously_configured_pools = redis.smembers('vmpooler__pools')\n currently_configured_pools = []\n config[:pools].each do |pool|\n currently_configured_pools << pool['name']\n redis.sadd('vmpooler__pools', pool['name'].to_s)\n pool_keys = pool.keys\n pool_keys.delete('alias')\n to_set = {}\n pool_keys.each do |k|\n to_set[k] = pool[k]\n end\n to_set['alias'] = pool['alias'].join(',') if to_set.key?('alias')\n to_set['domain'] = Vmpooler::Dns.get_domain_for_pool(config, pool['name'])\n\n redis.hmset(\"vmpooler__pool__#{pool['name']}\", *to_set.to_a.flatten) unless to_set.empty?\n end\n previously_configured_pools.each do |pool|\n unless currently_configured_pools.include? pool\n redis.srem('vmpooler__pools', pool.to_s)\n redis.del(\"vmpooler__pool__#{pool}\")\n end\n end\n end\n nil\n end",
"def loadAll()\n # Load the configuration from global.rb\n SHAREDPOOLS.each_key do |k|\n p = Pool.new(k, SHAREDPOOLS[k][:zone],\n SHAREDPOOLS[k][:allocateable_cpus],\n SHAREDPOOLS[k][:allocateable_mem],\n SHAREDPOOLS[k][:service_class])\n\n @poolList.push(p)\n end\n SERVICES.each_key do |k|\n s = Service.new(k, SERVICES[k][:authinfo],\n SERVICES[k][:maxcpus],\n SERVICES[k][:maxmemory],\n SERVICES[k][:priority])\n @svcList.push(s)\n end\n # Load the requests from redis\n @reqList = $eventProcessor.loadRequests()\n # Compute the free/used stats from state of requests\n @reqList.each { |req|\n if req.status == \"ALLOCATED\"\n pmatches = @poolList.select {|p| p.name == req.pool}\n if pmatches == nil || pmatches[0] == nil\n $Logger.error \"Unable to find pool #{req.pool} for ALLOCATED request #{req.reqid}\"\n next\n end\n smatches = @svcList.select {|s| s.name == req.service}\n if smatches == nil || smatches[0] == nil\n $Logger.error \"Unable to find service #{req.service} for ALLOCATED request #{req.reqid}\"\n next\n end\n pool = pmatches[0]\n pool.availvcpus = pool.availvcpus.to_i - req.vcpus.to_i\n pool.availmem = pool.availmem.to_i - req.mem.to_i\n service = smatches[0]\n service.vcpusallocated = service.vcpusallocated.to_i + req.vcpus.to_i\n service.memallocated = service.memallocated.to_i + req.mem.to_i\n end\n }\n end",
"def pool(session)\n read_task('rvpe.host.pool', session) do\n call_one_xmlrpc('one.hostpool.info', session)\n end\n end",
"def repaint\n # we need to see if structure changed then regenerate @list\n _list()\n super\n end",
"def reload\n proxy_owner.queues(true)\n end",
"def refresh!(*args)\n alloc(*args).refresh!\n end",
"def clone_pool\n super\n end",
"def reload_pool_nodes_unsync(raise_error)\n if @hosts.is_a?(Array)\n create_multi_node_pool(raise_error)\n refresh_startup_nodes\n else\n create_single_node_pool\n end\n end",
"def create_pools\n @old_store = store.dup\n pools.map do |key, value|\n # convert the requests to vm names\n pools[key]['requests'] = value['requests'].find_all do |req|\n puts \"Checking request: #{req}\"\n r = req_obj(req)\n if r.completed?\n puts \"The request #{req} has completed, getting hostname\"\n hostnames = resolve_vm_name(r)\n # remove request from pool file by not returning anything\n # if hostname does not exist but request completed don't update pool\n if ! hostnames\n puts \"Provisioning seemed to have failed for #{req}\"\n puts \"Removing request #{req} from pool #{key}\"\n false\n else\n pools[key]['pool_instances'] = value['pool_instances'] + hostnames\n false\n end\n else \n # has not completed\n # keep the request, since it is not finished\n puts \"The request #{req} is still running\"\n req\n end\n end\n\n # return the alive instances and save to the pool\n pools[key]['pool_instances'] = pools[key]['pool_instances'].find_all {|h| is_alive?(h) }\n\n # delete any old instances from used pool\n pools[key]['used_instances'] = pools[key]['used_instances'].find_all {|h| is_alive?(h) }\n\n # create the pool, and save the request in the requests\n # do not create if the number of systems and requests are more than the requested amount\n current_total = value['pool_instances'].count + pools[key]['requests'].count\n unless current_total >= value['size']\n reqs = create_pool(value)\n pools[key]['requests'] = reqs\n end\n end\n # prevents updates from occuring when they are not required\n store.save if store_changed?(@old_store, store)\nend",
"def reload\n begin_reset_model\n @id_to_module = []\n @filtered_out_modules = Set.new\n \n info = discover_module(Object)\n info.id = id_to_module.size\n info.name = title\n update_module_type_info(info)\n info.row = 0\n id_to_module << info\n\n @object_paths = Hash.new\n generate_paths(object_paths, info, \"\")\n ensure\n end_reset_model\n end",
"def pool\n @pool\n end",
"def initialize\n self.list = []\n self.refresh\n end",
"def refresh\n do_refresh\n self\n end",
"def update\n cluster_tree.root.children.each do |child|\n decrease_keepalive(child)\n end\n ready_n, allocating_n, executing_n, @finished_parameters, current_finished = @database_connector.update_parameter_state(@parameter_execution_expired_timeout)\n current_finished.each do |finished_id|\n @paramValueSet_pool.each do |p|\n if p.uid == finished_id\n @paramValueSet_pool.delete(p)\n break\n end\n end\n end\n\n debug(\"id_queue flag: #{@to_be_varriance_analysis}\")\n\n if @paramDefSet.get_available <= 0 && @to_be_varriance_analysis\n @mutexAnalysis.synchronize{variance_analysis} \n end\n\n debug(cluster_tree.to_s)\n info(\"not allocated parameters: #{@paramDefSet.get_available}, \" +\n \"paramValueSet pool: #{@paramValueSet_pool.length}, \" + \n \"ready: #{ready_n}, \" +\n \"allocating: #{allocating_n}, \" +\n \"executing: #{executing_n}, \" +\n \"finish: #{@finished_parameters}, \" +\n \"total: #{@total_parameters}\")\n unless @message_handler.alive?\n warn(\"message_handler not alive\")\n @message_handler.join\n end\n\n if @paramDefSet.get_available <= 0 and @paramValueSet_pool.length <= 0\n if !@to_be_varriance_analysis # 2013/08/01\n if (retval = allocate_paramValueSets(1, 1)).length == 0\n retval.each {|r| debug(\"#{r}\")} \n debug(\"call finalize !\")\n finalize\n # @doe_file.close\n else\n error(\"all parameter is finished? Huh???\")\n end\n end\n end\n # @doe_file.flush\n end",
"def clear_reloadable_connections!\n self.ensure_ready\n self.connection_pool_list.each(&:clear_reloadable_connections!)\n end",
"def refresh\n list.clear\n\n Ginatra.load_config[\"git_dirs\"].map do |git_dir|\n if Dir.exist?(git_dir.chop)\n dirs = Dir.glob(git_dir).sort\n else\n dir = File.expand_path(\"../../../#{git_dir}\", __FILE__)\n dirs = Dir.glob(dir).sort\n end\n\n dirs = dirs.select {|f| File.directory? f }\n dirs.each {|d| add(d) }\n end\n\n list\n end",
"def refresh\n load if changed?\n end",
"def remove_all_clone_pools\n super\n end",
"def update_top_descriptor_list\n \n end",
"def reload!\n obj_ids = memoize(:bogo_reloadable_configs, :global)\n objects = Thread.exclusive do\n ObjectSpace.each_object.find_all do |obj|\n obj_ids.include?(obj.object_id)\n end\n end\n objects.map(&:init!)\n memoize(:bogo_reloadable_configs, :global).delete_if do |oid|\n !obj_ids.include?(oid)\n end\n true\n end",
"def sync\n @cache.flush(true)\n @nodes.sync\n end",
"def load_all!\n Log.info \"Loading #{self} list\"\n old_objs = @objs_list || {}\n @objs_list = {}\n each_api_item do |api_hsh|\n params = api_hsh_to_params(api_hsh)\n if obj = old_objs[params[:id]] then obj.update! params\n else obj = self.new(params) end\n register obj\n end\n Log.info \"Loaded list of #{@objs_list.length} #{self}s\"\n @objs_list\n end",
"def refresh\n do_refresh\n end",
"def refresh\n do_refresh\n end",
"def refresh_subresources\n %w( projects categories ).each do |attr|\n self[attr] = API.instance.ontology_resource(acronym, attr).map{|h| h['acronym']}.join(\"\\n\")\n end\n end",
"def pool=(new_value)\n @pool = new_value\n @pool << self if @pool\n end",
"def refresh\n raise NotImplementedError.new('I do not know how to refresh myself, please implement it in subclass.')\n end",
"def refresh\n end",
"def reload!\n fetch_data!\n end",
"def reload_hosts_list\n self.hosts = self.storage_servers\n write_hosts_to_file\n end",
"def refresh\r\n end",
"def set_entries\n @pool = Pool.find(params[:pool_id])\n end",
"def reload\n clear_memoizations!\n perform_reload\n self\n end",
"def refresh_cache\n self.class.connection.execute \"UPDATE #{self.class.table_name} SET #{ancestors_count_column}=#{self.ancestors.size}, #{descendants_count_column}=#{self.descendants.size} WHERE id=#{self.id}\"\n end",
"def refresh\n update_attributes_from_id(@id)\n end",
"def refresh\n @deserialized_values = {}\n super\n end",
"def refresh_object_summaries()\n Fl::Framework::List::ListItem.refresh_item_summaries(self)\n end",
"def refresh\n self.class.new(__getobj__)\n end",
"def reload # :nodoc:\n @ordered_objects = nil\n ordered_objects\n super\n end",
"def refresh_dependents(options = {}); end",
"def current_pool_settings\n pool.symbolize_keys.reverse_merge(POOL.dup)\n end",
"def ceph_chef_pool_set(pool)\n if !node['ceph']['pools'][pool]['federated_names'].empty? && node['ceph']['pools'][pool]['federated_enable']\n node_loop = node['ceph']['pools'][pool]['federated_names']\n node_loop.each do |name|\n # if node['ceph']['pools'][pool]['settings']['type'] == 'replicated'\n next unless name['type'] == 'replicated'\n val = if node['ceph']['pools'][pool]['settings']['size']\n node['ceph']['pools'][pool]['settings']['size']\n else\n node['ceph']['osd']['size']['max']\n end\n\n ceph_chef_pool name do\n action :set\n key 'size'\n value val\n only_if \"ceph osd pool #{name} size | grep #{val}\"\n end\n end\n else\n node_loop = node['ceph']['pools'][pool]['pools']\n node_loop.each do |pool_val|\n # if node['ceph']['pools'][pool]['settings']['type'] == 'replicated'\n next unless pool_val['type'] == 'replicated'\n val = if node['ceph']['pools'][pool]['settings']['size']\n node['ceph']['pools'][pool]['settings']['size']\n else\n node['ceph']['osd']['size']['max']\n end\n\n ceph_chef_pool pool_val['name'] do\n action :set\n key 'size'\n value val\n only_if \"ceph osd pool #{pool_val['name']} size | grep #{val}\"\n end\n end\n end\nend",
"def finalize\n @list.each do |bp|\n bp.related_bp.each { |bp| bp.remove! }\n bp.remove!\n end\n clear\n end",
"def refresh_all\n\t\tputs \"Refresh all the entries in the local host repository in one shot.\"\n\t\tchanges=Hash.new\n\t\thosts=@known_hosts.keys\n\t\t@known_hosts=Hash.new\n\t\tchanges=bulk_add(hosts)\n\t\t@known_hosts.merge!(changes)\n\t\t#@known_hosts.keys.map do |key|\n\t\t#\tunless is_ip?(key)\n\t\t#\t\thost=refresh(key)\n\t\t#\t\tchanges.push(host) unless host.nil?\n\t\t#\tend\n\t\t#end\n\t\tputs \"\\n#{changes.size} Entries Refreshed:\" if changes.size>0\n\t\t#changes.map { |x| puts x }\n\t\tputs \"Done refreshing the local hosts.\"\n\t\treturn changes\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend",
"def flush\n if @hosttemplate_json\n @updated_json = @hosttemplate_json.dup\n else\n @updated_json = default_hosttemplate\n end\n \n # Update the hosttemplate's JSON values based on any new params. Sadly due to the\n # structure of the JSON vs the flat nature of the puppet properties, this\n # is a bit of a manual task.\n @updated_json[\"name\"] = @resource[:name]\n @updated_json[\"description\"] = @property_hash[:description]\n @updated_json[\"servicechecks\"] = []\n if not @property_hash[:servicechecks].empty?\n @property_hash[:servicechecks].each do |sc_hash|\n @updated_json[\"servicechecks\"] << {:name => sc_hash[\"name\"], :event_handler => sc_hash[\"event_handler\"],\n\t\t\t\t\t\t:exception => sc_hash[\"exception\"]\n }\n end\n end\n\n # If managementurls are set in the manifest update the JSON content for the\n # managementurls object with a list of hashes where each hash has a \"name\"\n # and an \"url\" key.\n @updated_json[\"managementurls\"] = []\n if not @property_hash[:managementurls].empty?\n @property_hash[:managementurls].each do |mu|\n @updated_json[\"managementurls\"] << { \"name\" => mu[\"name\"], \"url\" => mu[\"url\"] }\n end\n end\n \n # Flush changes:\n put @updated_json.to_json\n\n if defined? @resource[:reload_opsview]\n if @resource[:reload_opsview].to_s == \"true\"\n Puppet.notice \"Configured to reload opsview\"\n do_reload_opsview\n else\n Puppet.notice \"Configured NOT to reload opsview\"\n end\n end\n\n @property_hash.clear\n @hosttemplate_properties.clear\n\n false\n end",
"def reload\n @items = nil\n\n attributes = self.class.client.get_list(id: id)\n initialize(attributes)\n\n self\n end",
"def reload\n answer = connection.protocol::DbReload.new(params).process(connection)\n @clusters = answer[:clusters]\n self\n end",
"def update\n @parent.gemset_update\n end",
"def refresh!\n @roots.keys.each { |key| @roots[key].delete(:up_to_date) }\n end",
"def reload\n new_attributes = resource.find(self)._attributes_\n @_attributes_ = nil\n mass_assign(new_attributes)\n self\n end",
"def reload!\n unload!\n versions\n get_json\n get_map\n last_updated\n third_party_links\n mappings\n end",
"def close\n @pool.dispose\n end",
"def refresh_list\n clear_elements\n Game.instance.database.each_pair do |_, map|\n next unless Models::Map === map\n add_entry :map,\n name: \"#{map.id} - #{map.name}\",\n map_id: map.id,\n map: map,\n enabled: true\n end\n self\n end",
"def refresh\n generate_part_rects\n generate_buffers\n self\n end",
"def update!(**args)\n @address_pools = args[:address_pools] if args.key?(:address_pools)\n @load_balancer_node_pool_config = args[:load_balancer_node_pool_config] if args.key?(:load_balancer_node_pool_config)\n end",
"def pool; end",
"def pool; end",
"def refresh_all!\n self.size!\n refresh_all_digests! if respond_to?(:refresh_all_digests!)\n self.mimetype!\n self\n end",
"def refresh!\n mutex.synchronize do\n old = current\n\n new_hash = Hash[*(provider.all.map { |s|\n [s.name.intern, convert(s.value, s.data_type, s.name)]\n }.to_a.flatten)]\n\n # add defaults, cause they are cached\n new_hash = defaults.merge(new_hash)\n\n # add shadowed\n shadowed_settings.each { |ss| new_hash[ss] = GlobalSetting.send(ss) }\n\n changes, deletions = diff_hash(new_hash, old)\n\n changes.each { |name, val| current[name] = val }\n deletions.each { |name, val| current[name] = defaults[name] }\n\n clear_cache!\n end\n end",
"def reload(*)\n super.tap do\n clear_changes_information\n end\n end",
"def index\n @resource_pool_master = ResourcePoolMaster.new\n @resource_pool_masters = ResourcePoolMaster.all\n end",
"def refresh\n end",
"def refresh\n end",
"def perform_reload\n api.group_reload(self)\n end",
"def perform_reload\n api.balancer_reload(self)\n end",
"def refresh_all(ping_relation = Ping.all)\n grouped_pings = ping_relation\n .select_average(average_column_name)\n .select_and_group_by_truncated_date(average_interval)\n .select(:origin)\n .group(:origin)\n\n refresh_from_grouped_pings(grouped_pings)\n end",
"def refresh!; end"
] | [
"0.7100571",
"0.6721935",
"0.6373797",
"0.6280679",
"0.6131214",
"0.6063424",
"0.5996053",
"0.5947397",
"0.58811545",
"0.58314586",
"0.5796762",
"0.5795837",
"0.5770083",
"0.576221",
"0.5739193",
"0.5739193",
"0.57170373",
"0.57170373",
"0.5684405",
"0.5661635",
"0.56103134",
"0.559435",
"0.55909854",
"0.5581206",
"0.5575822",
"0.55642134",
"0.55541456",
"0.5553621",
"0.5553621",
"0.5553298",
"0.5551197",
"0.55401134",
"0.55293393",
"0.55218977",
"0.55217355",
"0.55201787",
"0.55187815",
"0.5514344",
"0.5510468",
"0.5503457",
"0.5484881",
"0.5482928",
"0.5467459",
"0.54581296",
"0.54510534",
"0.5435057",
"0.54345256",
"0.54341024",
"0.5426233",
"0.5420113",
"0.5415742",
"0.54123145",
"0.5372551",
"0.53694886",
"0.53679645",
"0.5359379",
"0.5359379",
"0.5357922",
"0.5351187",
"0.5348832",
"0.53447795",
"0.53443074",
"0.5341578",
"0.53401023",
"0.5329598",
"0.5317357",
"0.53160214",
"0.53061295",
"0.5297102",
"0.52955806",
"0.5289542",
"0.52845144",
"0.5281534",
"0.5277482",
"0.52768093",
"0.5272305",
"0.527186",
"0.5261741",
"0.5259294",
"0.5250821",
"0.52502453",
"0.5246839",
"0.5241524",
"0.52391297",
"0.52365863",
"0.5225862",
"0.5220081",
"0.5217443",
"0.5209283",
"0.5209283",
"0.51922846",
"0.5177554",
"0.51750475",
"0.5173095",
"0.5167851",
"0.5167851",
"0.51619464",
"0.5159328",
"0.515555",
"0.5148719"
] | 0.65775394 | 2 |
Look up an attribute of the node by the name it has in the OpenAPI document. | def [](value)
node_data[value.to_s]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attribute(node, attr_name)\n node.attribute(attr_name)\n end",
"def get_attribute(node, attr_name)\n #There has been a method shift between 0.5 and 0.7\n if defined?(node.property) == nil\n return node.attributes[attr_name]\n else\n if defined?(node[attr_name])\n return node[attr_name]\n else\n return node.property(attr_name)\n end\n end\n end",
"def attr(node,name_attribute='Name')\n node.attributes[name_attribute].value\n end",
"def get_attribute(name); end",
"def get_attribute(name); end",
"def attribute(name)\n read_attribute(name)\n end",
"def attribute(name)\n attributes[name]\n end",
"def [](name)\n @_node.hasAttribute(name.to_s) ? @_node.getAttribute(name.to_s) : nil\n end",
"def get_attribute(name)\n @attributes[name]\n end",
"def getAttributeNode(name)\n @attr.getNamedItem(name)\n end",
"def read_attribute name\n @attributes[name.to_s]\n end",
"def attribute(name)\n attr = nc.att(name)\n get(attr)\n end",
"def attribute(name)\n return attributes[name]\n end",
"def attribute\n @attribute ||= Pod::Specification::DSL.attributes.find { |attr| attr.reader_name.to_s == name }\n end",
"def attr(node, attribute_name, namespace = nil)\n attr = (attribute_name.is_a? Symbol) ? attribute_name.to_s : attribute_name\n node.attribute(attr, namespace).value if node.attribute(attr) \n end",
"def fetch_attribute(path, default = nil)\n node.dig(*path.split('.')) || default\nend",
"def attribute_get(name)\n @attributes[:current][name]\n end",
"def [](name)\n read_attribute(name)\n end",
"def get_attribute(name)\n @attributes[name.to_s]\n end",
"def attribute(name)\n @attributes[name.to_sym]\n end",
"def getNamedItem(name)\n node.getAttributeNode(name)\n end",
"def attribute(name)\n current_attributes[name]\n end",
"def read_attribute(name)\n fields[name].get(@attributes[name])\n end",
"def [](name)\n attributes[canonical_name(name)]\n end",
"def [](name)\n attributes[canonical_name(name)]\n end",
"def [](attr_name)\n read_attribute(attr_name)\n end",
"def attribute(name)\n attributes.each { |a| return a if a.property.id == name }\n nil\n end",
"def attribute(name); end",
"def [](name)\n attributes.fetch(name)\n end",
"def [](attr_name)\n read_attribute(attr_name)\n end",
"def [](attr_name) \n read_attribute(attr_name)\n end",
"def [](name)\n @attributes[name]\n end",
"def [](name)\n @attributes[name]\n end",
"def [](name)\n @attributes[name]\n end",
"def get_attribute( name )\n @attr_nodes.each do |attr|\n if attr.name == name then\n #//////////////////////////\n # 変更する\n #//////////////////////////\n return attr.value\n end\n end\n return \"\"\n end",
"def [](attr_name)\n @attributes.fetch_value(attr_name.to_s)\n end",
"def get_attribute(name)\n return @attrs[name] if attrs.key?(name)\n end",
"def attribute(name)\n @attributes ||= {}\n @attributes[name]\n end",
"def attribute_get(name)\n \n name = name.to_sym\n \n if properties.has_key?(name)\n properties[name].get(self)\n else\n nil\n end\n \n end",
"def lookup_attribute (attname, workitem)\n\n attname\n end",
"def find_attribute(name)\n NetCDF::Attribute.new(@netcdf_elmt.findAttribute(name))\n end",
"def [](name) \n self.attributes[name]\n end",
"def a(name)\n self.attributes[name]\n end",
"def get_attribute(name)\n str = name.to_s\n \n # try fetching an instance variable first\n value = instance_variable_get(\"@#{str}\")\n return value unless value.nil?\n \n # not an instance variable -- try fetching from @metadata\n load_metadata unless @metadata_loaded\n value = @metadata[str]\n return value unless value.nil?\n \n # not in metadata under that name -- is there another variant?\n alternate_name = nil\n self.class.md_key_map.each do |md_name, var_name|\n if str == md_name.to_s\n alternate_name = var_name.to_s\n break\n end\n end\n \n # if we couldn't find anything, return nil\n return nil if alternate_name.nil?\n \n # otherwise, try looking in metadata using the alternate name\n # if this doesn't work, we'll just let the method return nil\n @metadata[alternate_name]\n end",
"def read_attribute(name)\n inflect! self[name]\n end",
"def [](attr_name)\n if self.attribute_names.include?(attr_name)\n read_attribute(attr_name)\n else\n get_custom_attribute(attr_name)\n end\n end",
"def attr(name); end",
"def _read_attribute(attr)\n @attributes[attr]\n end",
"def attr(key,name)\n value = nil\n\n if NOKOGIRI\n [email protected](key.to_s.upcase)\n if element.size == 0\n return nil\n end\n\n attribute = element.attr(name)\n\n value = attribute.text if attribute != nil\n else\n [email protected][key.to_s.upcase]\n\n value = element.attributes[name] if element != nil\n end\n\n return value\n end",
"def attribute_lookup(attribute_name)\n a = nil\n @current_relation.attributes.each do |attribute|\n return attribute if attribute.name == attribute_name\n end\n a\n end",
"def [](attr_name)\n @attributes[attr_name.to_s]\n end",
"def get_attribute(attr_name)\n return nil unless @attributes.key? attr_name\n\n @attributes[attr_name]\n end",
"def _read_attribute(attr_name, &block) # :nodoc:\n @attributes.fetch_value(attr_name, &block)\n end",
"def [](name)\n `#{@el}.getAttribute(#{name})`\n end",
"def get_property(node, name)\n node.xpath(name).text\n end",
"def find_attribute_named(name)\n @attributes.find { |m| m.name == name }\n end",
"def [](key_name)\n read_attribute(key_name)\n rescue MissingAttribute\n nil\n end",
"def get attribute\n attributes[attribute]\n end",
"def []( name )\n send name if attribute?( name )\n end",
"def attribute(x)\n\t prefix = x.namespace.nil? ? nil : x.namespace.prefix\n self.class.find_attribute(qualified_name(x), prefix, x.name)\n end",
"def dom_attribute(name); end",
"def attribute attr\n real_attr = attribute_for attr\n raise LookupFailure.new(self, attr) unless real_attr\n self.class.attribute_for @ref, real_attr\n end",
"def method_missing(name, *args, &block)\n @attributes[name]\n end",
"def name\n read_attr :name\n end",
"def [](name, node)\n value(name, node)\n end",
"def [](attr_name)\n attr_name = attr_name.to_sym\n unless @attributes.key?(attr_name)\n raise NameError, \"undefined attribute #{attr_name.inspect}\"\n end\n @attributes[attr_name]\n end",
"def [](key)\n key = key.to_sym if key.respond_to?(:to_sym)\n unless key.to_s.empty?\n val = data_bag_item(key) if lookup_allowed?(key)\n if val\n val.delete('id')\n atr = Chef::Node::Attribute.new(\n node.normal_attrs,\n node.default_attrs,\n Chef::Mixin::DeepMerge.merge(\n node.override_attrs,\n Mash.new(key => val.to_hash)\n ),\n node.automatic_attrs\n )\n res = atr[key]\n end\n res || node[key]\n end\n end",
"def resource_attribute(name, resource)\n resource_attributes(resource)[name]\n end",
"def resource_attribute(name, resource)\n resource_attributes(resource)[name]\n end",
"def [](name, options = {})\n attributes.get(name, options)\n end",
"def with(name)\r\n @attributes.find { |attr| attr.name == name }\r\n end",
"def resource_attribute(resource, name)\n raise ArgumentError, \"Attribute name cannot be empty\" if name.empty?\n resource_attributes(resource)[name.to_s]\n end",
"def attribute(_name)\n raise Orocos::NotFound, \"#attribute is not implemented in #{self.class}\"\n end",
"def value(node, attribute); end",
"def value(node, attribute); end",
"def _read_attribute(key); end",
"def read_attribute(key)\n @attributes[key]\n end",
"def read_attribute(key)\n @attributes[key]\n end",
"def attribute(vertex, name)\n vertex.is_a?(::Oga::XML::Element) ? vertex.get(name) : nil\n end",
"def node\n attributes['node']\n end",
"def node\n attributes['node']\n end",
"def read_attribute(key)\n @attributes[key.to_sym]\n end",
"def getAttribute(name)\n attr = getAttributeNode(name)\n if attr.nil?\n ''\n else\n attr.nodeValue\n end\n end",
"def name\n read_attribute(:name)\n end",
"def [] (name)\n field = schema.fields[name.to_s]\n read_attribute(field, self) if field\n end",
"def attributes_for_node(node_name)\n node(node_name).attributes\nend",
"def get_attribute( asset, attr_name, slide_name_or_index )\r\n\t\tgraph_element = asset.el\r\n\t\t((addsets=@addsets_by_graph[graph_element]) && ( # State (slide) don't have any addsets\r\n\t\t\t( addsets[slide_name_or_index] && addsets[slide_name_or_index][attr_name] ) || # Try for a Set on the specific slide\r\n\t\t\t( addsets[0] && addsets[0][attr_name] ) # …else try the master slide\r\n\t\t) || graph_element[attr_name]) # …else try the graph\r\n\t\t# TODO: handle animation (child of addset)\r\n\tend",
"def [](name)\n @nodes[name.to_s]\n end",
"def name\n @name ||= @node['name']\n end",
"def get_attribute(name)\n rule_properties_scope = self.attr_grammar_type_to_rule_properties_scope[self.attr_grammar.attr_type]\n if (!(rule_properties_scope.get_attribute(name)).nil?)\n return rule_properties_scope.get_attribute(name)\n end\n if (!(@referenced_rule.attr_return_scope).nil?)\n return @referenced_rule.attr_return_scope.get_attribute(name)\n end\n return nil\n end",
"def get_attr(attribute)\n @top_level_object[attribute]\n end",
"def attribute attr\n @ref.attribute(TRANSLATOR.cocoaify(attr)).to_ruby\n end",
"def get(attribute_name)\n # label, attribute = attribute_name.split('_')\n # self.send(\"#{attribute}s\").first_for(label)\n attributes[attribute_name.to_sym] ||= get_field(attribute_map[attribute_name])\n end",
"def name\n attrs[:name]\n end",
"def attribute attr\n real_attr = attribute_for attr\n raise Accessibility::LookupFailure.new(self, attr) unless real_attr\n self.class.attribute real_attr, for: @ref\n end",
"def name\n @attributes[:name]\n end",
"def name\n @attributes[:name]\n end",
"def name\n @attributes[:name]\n end",
"def name\n @attributes[:name]\n end",
"def name\n attributes.fetch(:name)\n end",
"def name\n @name ||= @node['name']\n end"
] | [
"0.7586056",
"0.74624944",
"0.741198",
"0.7194562",
"0.7194562",
"0.7175515",
"0.7147677",
"0.7043587",
"0.7038855",
"0.7035356",
"0.70238584",
"0.7018633",
"0.7001013",
"0.69599706",
"0.6941388",
"0.69199353",
"0.6915854",
"0.6894896",
"0.6868919",
"0.6850737",
"0.6843978",
"0.6824",
"0.6795317",
"0.6792238",
"0.6792238",
"0.67450947",
"0.67433524",
"0.6717705",
"0.6715057",
"0.6710972",
"0.6710667",
"0.6684375",
"0.66734576",
"0.66734576",
"0.66541374",
"0.66395867",
"0.6609379",
"0.66010875",
"0.65950745",
"0.65597725",
"0.6549968",
"0.65443254",
"0.6535209",
"0.65261924",
"0.6521324",
"0.65176636",
"0.6507333",
"0.64935994",
"0.6466098",
"0.6459871",
"0.6447024",
"0.6423902",
"0.6406565",
"0.6403443",
"0.64015025",
"0.63821465",
"0.63755465",
"0.63552666",
"0.6306102",
"0.63039994",
"0.62968254",
"0.62848896",
"0.62656343",
"0.6209625",
"0.6205163",
"0.6204311",
"0.6202479",
"0.61838126",
"0.61838126",
"0.6176159",
"0.61569077",
"0.6148977",
"0.6145559",
"0.6109296",
"0.6109296",
"0.6107162",
"0.6094806",
"0.6094806",
"0.6073218",
"0.6060048",
"0.6060048",
"0.60546136",
"0.60482574",
"0.60426223",
"0.6035427",
"0.6021171",
"0.59985095",
"0.5984385",
"0.59732985",
"0.5965306",
"0.5965097",
"0.5960238",
"0.594404",
"0.59420174",
"0.59372985",
"0.5921094",
"0.5921094",
"0.5921094",
"0.5921094",
"0.5918777",
"0.5916827"
] | 0.0 | -1 |
Look up an extension provided for this map, doesn't need a prefix of "x" | def extension(value)
node_data["x-#{value}"]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extension(key)\n @extensions[key.to_s]\n end",
"def extension(key)\r\n return nil unless @extensions.has_key?(key)\r\n return @extensions[key]\r\n end",
"def extension(value)\n self[\"x-#{value}\"]\n end",
"def by_extension(ext); end",
"def [](key)\n @extensions_for.\n find_all {|data_type, _| key.to_s.start_with?(data_type) }.\n flat_map {|_, extensions| extensions }\n end",
"def extension(key)\n return nil unless @extensions\n sequence = @extensions[key] || @extensions[key = key.downcase]\n return sequence unless String === sequence\n @extensions[key] = sequence.split(HYPHEN) #lazy\n @extensions[key]\n end",
"def render_map_extension(maps, map_id, extension)\n return unless maps && maps.any? && map_id && extension\n map_sym = map_id.to_sym\n return unless maps.keys.include?(map_sym)\n \n case extension\n when \"gpx\"\n render_extension(maps[map_sym].gpx, :xml, 'application/gpx+xml')\n when \"kml\"\n render_extension(maps[map_sym].kml, :xml, 'application/vnd.google-earth.kml+xml')\n when \"geojson\"\n render_extension(maps[map_sym].geojson, :json, 'application/geo+json')\n when \"graphml\"\n render_extension(maps[map_sym].graphml, :xml)\n end\n end",
"def extension\n return _meta_data['extension'] if _meta_data.has_key? 'extension'\n ext\n end",
"def _extension_for(thing)\n MIMETypes.extension_for(thing) || @_extension\n end",
"def select_extension_point(point)\n @@extension_points_registry[point]\n end",
"def real_extension(filename)\n ext = File.extname(filename)\n return ext if ext.empty?\n ext = ext[1, ext.length - 1].sub('.', '_').downcase\n e_s = ext.to_sym\n return ext unless ALT_EXTENSIONS.key?(e_s)\n ALT_EXTENSIONS[e_s].dup\n end",
"def extension_from_path(path)\n @extensions.find {|e| e.path == path}\n end",
"def extension_setting(name)\n extension_settings.find{ |setting| setting.key == name.to_s }\n end",
"def parse_extensions(extension_request)\n extension_request_hash = {}\n extension_request.each do |extension|\n extension_request_hash[extension.value[0].value] = extension.value[1].value\n end\n return extension_request_hash\nend",
"def fetch(key, default = nil)\n return nil if super_fetch(key, nil).is_a?(Extension::UnknownExtension)\n\n super_fetch(key, default)\n end",
"def add_encoded_extension(encoded); end",
"def sub_ext(ext); end",
"def get_extensions\n get_siteinfo('extensions')['query']['extensions'].collect { |e| e['name'] }\n end",
"def maybe_convert_extension(ext); end",
"def extension; end",
"def extension; end",
"def extension; end",
"def extension; end",
"def extension(*extensions)\n if extensions[0].is_a?(Array)\n @_ext = extensions[0]\n else\n @_ext = extensions\n end\n end",
"def get_extension_by_oid(cert, oid)\n cert.extensions.each do |extension|\n return extension if extension.oid == oid\n end\n nil\n end",
"def get_extension(path)\n return path[/^.+(\\.[a-z0-9]+)$/i, 1]\n end",
"def map_config_extensions\n @extensions = Hash.new\n @config[\"types\"].each do |k,v|\n puts \"#{k} => #{v}\"\n v.each do |ext|\n @extensions[ext] = k\n end\n end\n return @extensions\n end",
"def get_ext_field_by_name(name)\n extension_fields.values.find {|field| field.name == name.to_sym}\n end",
"def alias_extension(new_extension, old_extension)\n aliases[normalize_extension(new_extension)] = normalize_extension(old_extension)\n end",
"def extension\n name.downcase\n end",
"def get_extension(cert, oid)\n extension = cert.extensions.select { |ext| ext.oid == oid }[0]\n\n return nil if extension.nil?\n\n value = extension.value\n # Weird ssl cert issue - have to strip the leading dots:\n value = value[2..-1] if value.match(/^\\.\\./)\n\n return value\n end",
"def _xfext(io)\n _, ixfe, _, cexts = io.read(8).unpack('v4')\n\n result = {\n # reserved1 (2 bytes): MUST be zero and MUST be ignored.\n ixfe: ixfe, # ixfe (2 bytes): An XFIndex structure that specifies the XF record in the file that this record extends.\n # reserved2 (2 bytes): MUST be zero and MUST be ignored.\n cexts: cexts, # cexts (2 bytes): An unsigned integer that specifies the number of elements in rgExt.\n rgExt: [] # rgExt (variable): An array of ExtProp. Each array element specifies a formatting property extension.\n }\n\n cexts.times { result[:rgExt] << extprop(io) }\n\n result\n end",
"def get_ext_field_by_name(name)\n name = name.to_sym\n extension_fields.values.find {|field| field.name == name}\n end",
"def pure_ext(ext)\n ext = ext.to_s and ext.start_with?('.') ? ext[1..-1] : ext\n end",
"def getExtension(eType)\r\n return @langProfile.getExtension(eType)\r\n end",
"def ext_sym(name)\r\n return name if name.kind_of?(Symbol)\r\n return ext_name(name).to_sym\r\n end",
"def extensions\r\n e = []\r\n @extensions.each_key do |k|\r\n e.push k\r\n end\r\n return e\r\n end",
"def using *extension_names\n extension_names.each do |extension_name|\n if extension = @@__extensions.find{|ext| ext.__name.to_s == extension_name.to_s }\n extension.extension_used self if extension.respond_to? :extension_used\n self.metaclass.send :define_method, :\"#{extension_name}\" do\n return extension\n end\n else\n raise ExtensionNotFoundError, \"Extension not found: #{extension_name}\"\n end\n end\n end",
"def extension? name\n @extensions.include? name\n end",
"def extensions\n data.extensions\n end",
"def extended_with(hash)\n hash.__angry_hash_extension if hash.respond_to?(:__angry_hash_extension)\n end",
"def undercase_ext_get(ext, recurse)\n transfer = Hash.new\n allexts = ext.empty?\n Modder.files(recurse).each do |file|\n ext = file.split(\".\").last if allexts\n\n new = file.sub(/#{ext}$/i, ext.downcase)\n next if new == file || ext == file # no changes or extension\n\n transfer[file] = new\n end\n\n transfer\n end",
"def known_extension?(f)\n f = \".#{f}\" unless f[0,1] == '.'\n EXTENSION_TO_FORMAT[f]\n end",
"def getExtension(eType)\n return @langProfile.getExtension(eType)\n end",
"def getExtension(eType)\n return @langProfile.getExtension(eType)\n end",
"def with_extension(template, extension)\n if has_extension?(template, extension)\n template\n else\n [template, extension].join(\".\")\n end\n end",
"def select_ext(ext)\r\n @list.each_index {|i| select(i) if @list[i][:ext] == ext }\r\n end",
"def add_extension(ext, *args)\n raise BadExtension unless valid_extension?(ext)\n extensions[ext] = args\n return ext::NS_URI\n end",
"def sub_ext(repl)\n ext = File.extname(@path)\n self.class.new(@path.chomp(ext) + repl)\n end",
"def enable_extension(name, **)\n end",
"def st_extension\n return \"jpg\" unless self.class.st_config[:extension].present?\n if self.class.st_config[:extension].is_a?(String)\n self.class.st_config[:extension]\n else\n self.send(self.class.st_config[:extension])\n end\n end",
"def add_extension(path, name = T.unsafe(nil)); end",
"def extension_attribute1\n return @extension_attribute1\n end",
"def extension\n extension_from_disk.blank? ? extension_from_feed : extension_from_disk\n end",
"def template_extensions\n EXTENSIONS.keys\n end",
"def ext_name(name)\r\n return name.to_s if name.kind_of?(Symbol)\r\n return name.gsub(/\\s/, '_')\r\n end",
"def register(thing, *extensions)\n return if extensions.empty?\n extensions.map! { |ext| ext[0] == ?. ? ext.downcase : \".#{ext.downcase}\" }\n extensions.each { |ext| REGISTRY[ext] = thing }\n EXTENSIONS[thing] = extensions.first\n nil\n end",
"def sanitize_extension_key(value)\n value = value.to_s.gsub(/[^a-zA-Z0-9]/, \"\")\n return value\n end",
"def sanitize_extension_key(value)\n value.to_s\n .gsub(/[^a-zA-Z0-9]/, \"\")\n end",
"def supported_extensions\n\t\treturn self.supported_extension_oids.collect {|oid| EXTENSION_NAMES[oid] || oid }\n\tend",
"def get_icon(extension)\n ICONS.each do |ext_type|\n # Compare the extension to each value in the list\n ext_type.each do |value|\n if extension == value\n return ext_type[0]\n end\n end\n end\n \n # If extension doesn\"t match anything on the list, return default\n return \"default\"\n end",
"def preferred_extension\n @preferred_extension || extensions.first\n end",
"def add_extension(path); end",
"def extension(style = nil)\n style and\n self.styles and\n self.styles[style] and\n self.styles[style][:extension] or\n instance_get(:extension)\n end",
"def extensions=(extensions); end",
"def extension\n extensions.last || \"\"\n end",
"def set_extensions(val)\n @extensions = val\n build_path_query\n @extensions\n end",
"def extension=(_arg0); end",
"def extension=(_arg0); end",
"def [](key)\n Extension.mixin_to(self,key,super)\n end",
"def dotted_ext(ext)\n ext = ext.to_s and (ext.empty? or ext.start_with?('.')) ? ext : \".#{ext}\"\n end",
"def extensions\n form_data = { 'action' => 'query', 'meta' => 'siteinfo', 'siprop' => 'extensions' }\n res = make_api_request(form_data)\n REXML::XPath.match(res, \"//ext\").inject(Hash.new) do |extensions, extension|\n name = extension.attributes[\"name\"] || \"\"\n extensions[name] = extension.attributes[\"version\"]\n extensions\n end\n end",
"def add_extension(extension)\n @parts[-1] += extension\n self\n end",
"def extensions; end",
"def extensions; end",
"def extensions; end",
"def extensions=(_arg0); end",
"def get_extension_tags\n get_siteinfo('extensiontags')['query']['extensiontags']\n end",
"def file_extension(extension = T.unsafe(nil)); end",
"def register_for_extensions(extensions)\n extensions = [*extensions]\n ExtensionMap.parsers ||= []\n ExtensionMap.parsers << self\n ExtensionMap.extensions_for ||= {}\n ExtensionMap.parsers_for ||= {}\n extensions.each do |extension|\n ExtensionMap.parsers_for[extension] ||= []\n ExtensionMap.parsers_for[extension] << self\n ExtensionMap.extensions_for[self] ||= []\n ExtensionMap.extensions_for[self] << extension\n end\n end",
"def extensions\n @config[:extensions]\n end",
"def extensions\n unless @extensions\n @extensions={}\n cert.extensions.each {|e| @extensions[e.oid]=e.value} if cert.extensions\n end\n @extensions\n end",
"def enable_extension(name)\n end",
"def extension\n message_descriptor_proto.extension\n end",
"def ext(ext)\n self.map do |f|\n Neutron.file_to_ext(f, ext)\n end\n end",
"def suffixes_in_set\n druid_version_zip.expected_part_keys(parts_count).map { |key| File.extname(key) }\n end",
"def select_ext(ext, cat = current_category)\n @list[cat].each_index {|i| select(i) if @list[cat][i][:ext] == ext }\n end",
"def extension_parameters\n @extension_parameters ||= {}\n end",
"def ext_of(filename)\n filename =~ extension_regex ? $2 : ''\n end",
"def extensions\n @@extensions\n end",
"def extensions\n @@extensions\n end",
"def ext_obj\n \"ext(#{ext_channel}, #{ext_type}, #{ext_id})\"\n end",
"def extension\n split_extension(filename)[1] if filename\n end",
"def add_extension(point, *extension_options)\n extension_point = @@extension_points_registry[point]\n unless extension_point\n klass_name = point.scan(/^(.*)::(.*)$/)[0][1]\n# file = klass_name.scan(/^([A-Z][a-z]*)(.*)$/)[0].collect{|s| s.downcase}.join('_')\n file = klass_name.underscore\n require \"extension_points/#{file}\"\n# klass = Object.const_get(point)\n klass = point.split(\"::\").inject(Object) {|x,y| x.const_get(y)}\n extension_point = klass.new\n @@extension_points_registry[point] = extension_point\n end\n extension = generate_extension(*extension_options)\n extension_point.add_extension(extension)\n end",
"def target_extension; end",
"def update_extension_list\n @extensible_abos = {}\n @all_abos.each_pair.map do |acronym, abos|\n @extensible_abos[acronym] = abos.reject(&:marked?)\n end\n end",
"def uuid_extension\n (UUID_EXTENSIONS & available_extensions).first\n end",
"def search_ext(file)\n fs = @s3.list_objects_v2 bucket: ENV.fetch(\"AWS_BUCKET\"), prefix: \"#{file}.\"\n fs.contents.first&.key\n end",
"def extension=(v) Axlsx::validate_string v; @extension = v end",
"def get(attrib)\n if attrib.is_a? String and attrib.include? \".\"\n syms = attrib.split(\".\")\n first = syms[0]\n rest = syms[1..-1].join(\".\")\n self.send(first).get(rest)\n else\n self.send(attrib.to_sym)\n end\n end"
] | [
"0.7432741",
"0.7142958",
"0.6967343",
"0.69126326",
"0.676964",
"0.6508039",
"0.64826035",
"0.6421745",
"0.62816036",
"0.62020713",
"0.6185295",
"0.6155714",
"0.6079679",
"0.5983031",
"0.59774756",
"0.5930489",
"0.58469635",
"0.5842816",
"0.5836051",
"0.5821867",
"0.5821867",
"0.5821867",
"0.5821867",
"0.58057344",
"0.5792919",
"0.5777769",
"0.5750541",
"0.5730219",
"0.5726531",
"0.57185674",
"0.5705361",
"0.5704836",
"0.57032096",
"0.5680144",
"0.56701916",
"0.56641567",
"0.5638856",
"0.560543",
"0.5603798",
"0.5558868",
"0.55579495",
"0.55438596",
"0.5541223",
"0.5537097",
"0.5537097",
"0.5534938",
"0.55294585",
"0.5523199",
"0.5491369",
"0.54725295",
"0.5465951",
"0.5460308",
"0.54575914",
"0.54519594",
"0.54337037",
"0.54325265",
"0.5429304",
"0.5420458",
"0.54184127",
"0.541443",
"0.54122996",
"0.5411916",
"0.54028153",
"0.53859365",
"0.53787965",
"0.5377824",
"0.53749686",
"0.5370352",
"0.5370352",
"0.5370306",
"0.536159",
"0.53594095",
"0.5356961",
"0.53543794",
"0.53543794",
"0.53543794",
"0.53522974",
"0.53405493",
"0.5318259",
"0.53028065",
"0.5300827",
"0.52987534",
"0.5298033",
"0.5297518",
"0.52901965",
"0.52830213",
"0.52669024",
"0.52647513",
"0.52639586",
"0.52579397",
"0.52579397",
"0.5257368",
"0.5255222",
"0.5250617",
"0.52389735",
"0.5237999",
"0.5236562",
"0.5231422",
"0.5230471",
"0.52299434"
] | 0.63881344 | 8 |
Used to access a node relative to this node | def node_at(pointer_like)
current_pointer = node_context.document_location.pointer
node_context.document.node_at(pointer_like, current_pointer)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node\n @node\n end",
"def node\n @node\n end",
"def node\n return @node\n end",
"def node\n @context.node\n end",
"def node\n attributes['node']\n end",
"def node\n attributes['node']\n end",
"def get\n if @position.access\n data = @node.send(@position.access) \n else\n data = @node\n end\n end",
"def node\r\n\t\t\tparent\r\n\t\tend",
"def get_node(node)\n\t\t\t@nodes[node]\n\t\tend",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node; end",
"def node()\n self.root.node()\n end",
"def node\n items_node[:node]\n end",
"def node\n scope.node\n end",
"def current\n return nil unless @node\n @node.item\n end",
"def node\n retract[:node]\n end",
"def child_node; end",
"def for_node; end",
"def current_node\n Neo4j.load(@traversal_position.currentNode.getId)\n end",
"def node\n run_context.node\n end",
"def raw_node; end",
"def accessor_start(node); end",
"def node(name)\n nodes[name]\n end",
"def node\n datasource.document.xpath(xpath).first\n end",
"def child_node=(_); end",
"def node\n run_context.node\n end",
"def node\n run_context.node\n end",
"def get_node(key); end",
"def node=(_); end",
"def node=(_); end",
"def next_node\n @current_node = @current_node.children[0]\n end",
"def nodes\n @current\n end",
"def node(node_name)\n nodes(node_name).first\nend",
"def node(x, y)\n @nodes[y][x]\n end",
"def node\n Component.span\n end",
"def node\n Component.span\n end",
"def get_node_data()\n return @node_data\n end",
"def next_node\n @current_node = @current_node.children[0]\n end",
"def node\n @node ||= args.dig(:node)\n end",
"def base\n node.base\n end",
"def node(klass = nil)\n return @context[:node] if !klass\n @context[:node].get(klass)\n end",
"def node=(_arg0); end",
"def node\n returning \"#{@name}_node\" do |nodename|\n @canvas << \"var #{nodename} = #{@name}.node;\"\n end\n end",
"def node_ant\n return @ant\n end",
"def ref_node_for_class\n Neo4j.ref_node\n end",
"def node=(node)\n @node = node\n end",
"def node_at(line, column); end",
"def getAsCircle\n @node\n end",
"def get id\n @nodes[id]\n end",
"def pull_node(xn)\n # nothing to do with node\n end",
"def node; changeset.node; end",
"def node(name)\n return node_manager.find(name)\n end",
"def get_node(id)\n get_object('node', id)\n end",
"def node\n publish[:node]\n end",
"def get_node(letter)\n @node_pointers[letter.to_sym]\n end",
"def parent\n self.node && self.node.parent && self.node.parent.content\n end",
"def [](uri)\n @nodes[uri]\n end",
"def nodes; end",
"def nodes; end",
"def nodes; end",
"def get_node_value(node)\n node\n end",
"def name\n node.name\n end",
"def name\n node.name\n end",
"def peek\n @nodes[0]\n end",
"def ref\n @ref ||= self.node.attributes.to_h[\"ref\"]\n end",
"def view\n node = @first_node\n puts '---------------------------'\n while node != nil\n puts node.identifier\n node = node.next\n end\n puts '---------------------------'\n end",
"def nodes_field\n define_nodes_field\n end",
"def get_node\n # @@neo = Neography::Rest.new\n begin\n # qur = \"MATCH (n {object_id: \"+self.id.to_s+\", object_type: \\'\"+self.class.to_s+\"\\' }) RETURN n LIMIT 1\"\n # response = @@neo.execute_query(qur)\n # node_id = response[\"data\"].flatten.first[\"metadata\"][\"id\"]\n node_id = self.get_node_id\n node = (node_id ? Neography::Node.load(node_id, @@neo) : nil)\n return node\n rescue Exception\n return nil\n end\n end",
"def id\n @node.id\n end",
"def moved_node\n current_tree.find(node_2.id)\n end",
"def my_node(allow_caching = true)\n graph = SourceClass.class_graph(allow_caching)\n graph.get_node(@uri_s) || OntologyGraph::ClassNode.new(@uri_s)\n end",
"def sibling; end",
"def node(node)\n true\n end"
] | [
"0.7731943",
"0.7731943",
"0.7568608",
"0.7457841",
"0.74190134",
"0.74190134",
"0.741819",
"0.7388837",
"0.73212653",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.71706474",
"0.7114836",
"0.6999049",
"0.696224",
"0.6857673",
"0.6841547",
"0.6777266",
"0.66201204",
"0.65900064",
"0.6568845",
"0.6564243",
"0.65316",
"0.65045655",
"0.64429617",
"0.6428574",
"0.64151204",
"0.64151204",
"0.63709736",
"0.6362936",
"0.6362936",
"0.63580316",
"0.63513005",
"0.63399917",
"0.63354933",
"0.63211715",
"0.63211715",
"0.6316429",
"0.63114613",
"0.62781155",
"0.62746435",
"0.624868",
"0.6238654",
"0.6237626",
"0.6233072",
"0.6209563",
"0.61872995",
"0.61835444",
"0.61827326",
"0.61744964",
"0.614163",
"0.6133884",
"0.6133168",
"0.6123045",
"0.61202174",
"0.6111862",
"0.61083496",
"0.61043644",
"0.6083676",
"0.6083676",
"0.6083676",
"0.60809165",
"0.6073997",
"0.6073997",
"0.6066363",
"0.60471994",
"0.60421735",
"0.60134816",
"0.60108036",
"0.6003523",
"0.59966063",
"0.59954756",
"0.5991942",
"0.59913874"
] | 0.6687805 | 44 |
Creates a new load balancer policy that contains the necessary attributes depending on the policy type. Policies are settings that are saved for your load balancer and that can be applied to the frontend listener, or the backend application server, depending on your policy type. == Applying Policies To apply a policy to a frontend listener: each listener may only have a single policy load_balancer.listener[80].policy = listener_policy To apply a policy to backend instance port back end servers can have multiple policies per instance port load_balancer.backend_server_policies.add(80, back_end_policy) | def create name, type, attributes = {}
attribute_list = []
attributes.each do |attr_name,values|
[values].flatten.each do |value|
attribute_list << {
:attribute_name => attr_name,
:attribute_value => value.to_s
}
end
end
client.create_load_balancer_policy(
:load_balancer_name => load_balancer.name,
:policy_name => name.to_s,
:policy_type_name => type.to_s,
:policy_attributes => attribute_list)
LoadBalancerPolicy.new(load_balancer, name, :type => type.to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def []= instance_port, policy\n\n client.set_load_balancer_policies_for_backend_server(\n :load_balancer_name => load_balancer.name,\n :instance_port => instance_port.to_i,\n :policy_names => [policy_name(policy)].compact)\n\n nil\n\n end",
"def create_load_balancer_policy(lb_name, name, type_name, attributes = {})\n params = {}\n\n attribute_name = []\n attribute_value = []\n attributes.each do |name, value|\n attribute_name.push(name)\n attribute_value.push(value)\n end\n\n params.merge!(Fog::AWS.indexed_param('PolicyAttributes.member.%d.AttributeName', attribute_name))\n params.merge!(Fog::AWS.indexed_param('PolicyAttributes.member.%d.AttributeValue', attribute_value))\n\n request({\n 'Action' => 'CreateLoadBalancerPolicy',\n 'LoadBalancerName' => lb_name,\n 'PolicyName' => name,\n 'PolicyTypeName' => type_name,\n :parser => Fog::Parsers::AWS::ELB::Empty.new\n }.merge!(params))\n end",
"def update_backend_policies(elb_name, backend_added, backend_removed = [], backend_modified = [])\n\n # Update the created and modified policies\n (backend_added + backend_modified).each do |backend|\n # First make sure each policy exists\n backend.local_policies.each do |policy_name|\n ensure_policy_exists(elb_name, policy_name)\n end\n\n @elb.set_load_balancer_policies_for_backend_server({\n load_balancer_name: elb_name,\n instance_port: backend.port,\n policy_names: backend.local_policies\n })\n end\n\n # Update the deleted ones by setting policy names to []\n backend_removed.each do |backend|\n @elb.set_load_balancer_policies_for_backend_server({\n load_balancer_name: elb_name,\n instance_port: backend.port,\n policy_names: []\n })\n end\n end",
"def update_listener_policies(elb_name, port, policy_names)\n # Make sure a policy exists for each policy on the listener\n policy_names.each do |policy_name|\n ensure_policy_exists(elb_name, policy_name)\n end\n\n @elb.set_load_balancer_policies_of_listener({\n load_balancer_name: elb_name,\n load_balancer_port: port,\n policy_names: policy_names\n })\n end",
"def init_policy\n policy = PolicyConfig.new\n static_statements.each do |statement|\n policy.add_statement(statement)\n end\n template_statements.each do |statement|\n policy.add_statement(statement)\n end\n inline_statements.each do |statement|\n policy.add_statement(statement)\n end\n policy\n end",
"def create\n @load_balancer_policy = LoadBalancerPolicy.new(params[:load_balancer_policy])\n\n respond_to do |format|\n if @load_balancer_policy.save\n flash[:notice] = 'LoadBalancerPolicy was successfully created.'\n format.html { redirect_to(@load_balancer_policy) }\n format.xml { render :xml => @load_balancer_policy, :status => :created, :location => @load_balancer_policy }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @load_balancer_policy.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_policies(*policies_or_labels)\n add_policies_to_labels(policies_or_labels, false)\n end",
"def use_policies(*policies_or_labels)\n add_policies_to_labels(policies_or_labels, true)\n end",
"def create_load_balancer_h_t_t_p_listener(backend_server_port, bandwidth, health_check, listener_port, load_balancer_id, sticky_session, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateLoadBalancerHTTPListener'\n\t\targs[:query]['HealthCheck'] = health_check\n\t\targs[:query]['LoadBalancerId'] = load_balancer_id\n\t\targs[:query]['StickySession'] = sticky_session\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :cookie\n\t\t\targs[:query]['Cookie'] = optional[:cookie]\n\t\tend\n\t\tif optional.key? :cookie_timeout\n\t\t\traise ArgumentError, 'cookie_timeout must be equal or greater than 1' unless optional[:cookie_timeout] < 1\n\t\t\traise ArgumentError, 'cookie_timeout must be equal or less than 86400' unless optional[:cookie_timeout] > 86400\n\t\t\targs[:query]['CookieTimeout'] = optional[:cookie_timeout]\n\t\tend\n\t\tif optional.key? :health_check_connect_port\n\t\t\traise ArgumentError, 'health_check_connect_port must be equal or greater than -520' unless optional[:health_check_connect_port] < -520\n\t\t\traise ArgumentError, 'health_check_connect_port must be equal or less than 65535' unless optional[:health_check_connect_port] > 65535\n\t\t\targs[:query]['HealthCheckConnectPort'] = optional[:health_check_connect_port]\n\t\tend\n\t\tif optional.key? :health_check_domain\n\t\t\targs[:query]['HealthCheckDomain'] = optional[:health_check_domain]\n\t\tend\n\t\tif optional.key? :health_check_http_code\n\t\t\targs[:query]['HealthCheckHttpCode'] = optional[:health_check_http_code]\n\t\tend\n\t\tif optional.key? :health_check_interval\n\t\t\traise ArgumentError, 'health_check_interval must be equal or greater than 1' unless optional[:health_check_interval] < 1\n\t\t\traise ArgumentError, 'health_check_interval must be equal or less than 5' unless optional[:health_check_interval] > 5\n\t\t\targs[:query]['HealthCheckInterval'] = optional[:health_check_interval]\n\t\tend\n\t\tif optional.key? :health_check_timeout\n\t\t\traise ArgumentError, 'health_check_timeout must be equal or greater than 1' unless optional[:health_check_timeout] < 1\n\t\t\traise ArgumentError, 'health_check_timeout must be equal or less than 50' unless optional[:health_check_timeout] > 50\n\t\t\targs[:query]['HealthCheckTimeout'] = optional[:health_check_timeout]\n\t\tend\n\t\tif optional.key? :health_check_u_r_i\n\t\t\targs[:query]['HealthCheckURI'] = optional[:health_check_u_r_i]\n\t\tend\n\t\tif optional.key? :healthy_threshold\n\t\t\traise ArgumentError, 'healthy_threshold must be equal or greater than 1' unless optional[:healthy_threshold] < 1\n\t\t\traise ArgumentError, 'healthy_threshold must be equal or less than 10' unless optional[:healthy_threshold] > 10\n\t\t\targs[:query]['HealthyThreshold'] = optional[:healthy_threshold]\n\t\tend\n\t\tif optional.key? :max_conn_limit\n\t\t\targs[:query]['MaxConnLimit'] = optional[:max_conn_limit]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tif optional.key? :scheduler\n\t\t\targs[:query]['Scheduler'] = optional[:scheduler]\n\t\tend\n\t\tif optional.key? :sticky_session_type\n\t\t\targs[:query]['StickySessionType'] = optional[:sticky_session_type]\n\t\tend\n\t\tif optional.key? :unhealthy_threshold\n\t\t\traise ArgumentError, 'unhealthy_threshold must be equal or greater than 1' unless optional[:unhealthy_threshold] < 1\n\t\t\traise ArgumentError, 'unhealthy_threshold must be equal or less than 10' unless optional[:unhealthy_threshold] > 10\n\t\t\targs[:query]['UnhealthyThreshold'] = optional[:unhealthy_threshold]\n\t\tend\n\t\tif optional.key? :x_forwarded_for\n\t\t\targs[:query]['XForwardedFor'] = optional[:x_forwarded_for]\n\t\tend\n\t\traise ArgumentError, 'backend_server_port must be equal or greater than 1' unless backend_server_port < 1\n\t\traise ArgumentError, 'backend_server_port must be equal or less than 65535' unless backend_server_port > 65535\n\t\targs[:query]['BackendServerPort'] = backend_server_port\n\t\traise ArgumentError, 'bandwidth must be equal or greater than -1' unless bandwidth < -1\n\t\traise ArgumentError, 'bandwidth must be equal or less than 1000' unless bandwidth > 1000\n\t\targs[:query]['Bandwidth'] = bandwidth\n\t\traise ArgumentError, 'listener_port must be equal or greater than 1' unless listener_port < 1\n\t\traise ArgumentError, 'listener_port must be equal or less than 65535' unless listener_port > 65535\n\t\targs[:query]['ListenerPort'] = listener_port\n\t\tself.run(args)\n\tend",
"def store_definition policies\n # Policies may have been defined by other means. If it's not a hash, stop\n return unless policies.is_a? Hash\n\n base = current_base\n policies.each_pair do |widget, conditions|\n policy = base[widget] || {\n :self => true,\n :params => [],\n :models => {},\n :procs => [],\n :widget_params => true\n }\n add_conditions(policy, conditions)\n base[widget] = policy\n end\n end",
"def policy=( val )\n val = val.to_s\n raise \"Invalid policy\" unless val == \"allow\" || val == \"deny\"\n\n self.permissions['policy'] = val\n end",
"def create_lb_cookie_stickiness_policy(lb_name, policy_name, cookie_expiration_period=nil)\n params = {'PolicyName' => policy_name, 'CookieExpirationPeriod' => cookie_expiration_period}\n\n request({\n 'Action' => 'CreateLBCookieStickinessPolicy',\n 'LoadBalancerName' => lb_name,\n :parser => Fog::Parsers::AWS::ELB::Empty.new\n }.merge!(params))\n end",
"def policy\n @policy ||= init_policy\n end",
"def create_load_balancer_h_t_t_p_s_listener(backend_server_port, bandwidth, health_check, listener_port, load_balancer_id, server_certificate_id, sticky_session, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateLoadBalancerHTTPSListener'\n\t\targs[:query]['HealthCheck'] = health_check\n\t\targs[:query]['LoadBalancerId'] = load_balancer_id\n\t\targs[:query]['ServerCertificateId'] = server_certificate_id\n\t\targs[:query]['StickySession'] = sticky_session\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :cookie\n\t\t\targs[:query]['Cookie'] = optional[:cookie]\n\t\tend\n\t\tif optional.key? :cookie_timeout\n\t\t\traise ArgumentError, 'cookie_timeout must be equal or greater than 1' unless optional[:cookie_timeout] < 1\n\t\t\traise ArgumentError, 'cookie_timeout must be equal or less than 86400' unless optional[:cookie_timeout] > 86400\n\t\t\targs[:query]['CookieTimeout'] = optional[:cookie_timeout]\n\t\tend\n\t\tif optional.key? :health_check_connect_port\n\t\t\traise ArgumentError, 'health_check_connect_port must be equal or greater than -520' unless optional[:health_check_connect_port] < -520\n\t\t\traise ArgumentError, 'health_check_connect_port must be equal or less than 65535' unless optional[:health_check_connect_port] > 65535\n\t\t\targs[:query]['HealthCheckConnectPort'] = optional[:health_check_connect_port]\n\t\tend\n\t\tif optional.key? :health_check_domain\n\t\t\targs[:query]['HealthCheckDomain'] = optional[:health_check_domain]\n\t\tend\n\t\tif optional.key? :health_check_http_code\n\t\t\targs[:query]['HealthCheckHttpCode'] = optional[:health_check_http_code]\n\t\tend\n\t\tif optional.key? :health_check_interval\n\t\t\traise ArgumentError, 'health_check_interval must be equal or greater than 1' unless optional[:health_check_interval] < 1\n\t\t\traise ArgumentError, 'health_check_interval must be equal or less than 5' unless optional[:health_check_interval] > 5\n\t\t\targs[:query]['HealthCheckInterval'] = optional[:health_check_interval]\n\t\tend\n\t\tif optional.key? :health_check_timeout\n\t\t\traise ArgumentError, 'health_check_timeout must be equal or greater than 1' unless optional[:health_check_timeout] < 1\n\t\t\traise ArgumentError, 'health_check_timeout must be equal or less than 50' unless optional[:health_check_timeout] > 50\n\t\t\targs[:query]['HealthCheckTimeout'] = optional[:health_check_timeout]\n\t\tend\n\t\tif optional.key? :health_check_u_r_i\n\t\t\targs[:query]['HealthCheckURI'] = optional[:health_check_u_r_i]\n\t\tend\n\t\tif optional.key? :healthy_threshold\n\t\t\traise ArgumentError, 'healthy_threshold must be equal or greater than 1' unless optional[:healthy_threshold] < 1\n\t\t\traise ArgumentError, 'healthy_threshold must be equal or less than 10' unless optional[:healthy_threshold] > 10\n\t\t\targs[:query]['HealthyThreshold'] = optional[:healthy_threshold]\n\t\tend\n\t\tif optional.key? :max_conn_limit\n\t\t\targs[:query]['MaxConnLimit'] = optional[:max_conn_limit]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tif optional.key? :scheduler\n\t\t\targs[:query]['Scheduler'] = optional[:scheduler]\n\t\tend\n\t\tif optional.key? :sticky_session_type\n\t\t\targs[:query]['StickySessionType'] = optional[:sticky_session_type]\n\t\tend\n\t\tif optional.key? :unhealthy_threshold\n\t\t\traise ArgumentError, 'unhealthy_threshold must be equal or greater than 1' unless optional[:unhealthy_threshold] < 1\n\t\t\traise ArgumentError, 'unhealthy_threshold must be equal or less than 10' unless optional[:unhealthy_threshold] > 10\n\t\t\targs[:query]['UnhealthyThreshold'] = optional[:unhealthy_threshold]\n\t\tend\n\t\tif optional.key? :x_forwarded_for\n\t\t\targs[:query]['XForwardedFor'] = optional[:x_forwarded_for]\n\t\tend\n\t\traise ArgumentError, 'backend_server_port must be equal or greater than 1' unless backend_server_port < 1\n\t\traise ArgumentError, 'backend_server_port must be equal or less than 65535' unless backend_server_port > 65535\n\t\targs[:query]['BackendServerPort'] = backend_server_port\n\t\traise ArgumentError, 'bandwidth must be equal or greater than -1' unless bandwidth < -1\n\t\traise ArgumentError, 'bandwidth must be equal or less than 1000' unless bandwidth > 1000\n\t\targs[:query]['Bandwidth'] = bandwidth\n\t\traise ArgumentError, 'listener_port must be equal or greater than 1' unless listener_port < 1\n\t\traise ArgumentError, 'listener_port must be equal or less than 65535' unless listener_port > 65535\n\t\targs[:query]['ListenerPort'] = listener_port\n\t\tself.run(args)\n\tend",
"def policy\n ensure_service!\n grpc = service.get_database_policy instance_id, database_id\n policy = Policy.from_grpc grpc\n return policy unless block_given?\n yield policy\n update_policy policy\n end",
"def policy\n ensure_service!\n grpc = service.get_database_policy instance_id, database_id\n policy = Policy.from_grpc grpc\n return policy unless block_given?\n yield policy\n update_policy policy\n end",
"def policy(user, record)\n policy = policy_finder(record).policy\n policy.new(user, record) if policy\n end",
"def create_load_balancer_t_c_p_listener(backend_server_port, bandwidth, listener_port, load_balancer_id, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateLoadBalancerTCPListener'\n\t\targs[:query]['LoadBalancerId'] = load_balancer_id\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :health_check_connect_port\n\t\t\traise ArgumentError, 'health_check_connect_port must be equal or greater than 1' unless optional[:health_check_connect_port] < 1\n\t\t\traise ArgumentError, 'health_check_connect_port must be equal or less than 65535' unless optional[:health_check_connect_port] > 65535\n\t\t\targs[:query]['HealthCheckConnectPort'] = optional[:health_check_connect_port]\n\t\tend\n\t\tif optional.key? :health_check_connect_timeout\n\t\t\traise ArgumentError, 'health_check_connect_timeout must be equal or greater than 1' unless optional[:health_check_connect_timeout] < 1\n\t\t\traise ArgumentError, 'health_check_connect_timeout must be equal or less than 50' unless optional[:health_check_connect_timeout] > 50\n\t\t\targs[:query]['HealthCheckConnectTimeout'] = optional[:health_check_connect_timeout]\n\t\tend\n\t\tif optional.key? :health_check_domain\n\t\t\targs[:query]['HealthCheckDomain'] = optional[:health_check_domain]\n\t\tend\n\t\tif optional.key? :health_check_http_code\n\t\t\targs[:query]['HealthCheckHttpCode'] = optional[:health_check_http_code]\n\t\tend\n\t\tif optional.key? :health_check_interval\n\t\t\traise ArgumentError, 'health_check_interval must be equal or greater than 1' unless optional[:health_check_interval] < 1\n\t\t\traise ArgumentError, 'health_check_interval must be equal or less than 5' unless optional[:health_check_interval] > 5\n\t\t\targs[:query]['healthCheckInterval'] = optional[:health_check_interval]\n\t\tend\n\t\tif optional.key? :health_check_type\n\t\t\targs[:query]['HealthCheckType'] = optional[:health_check_type]\n\t\tend\n\t\tif optional.key? :health_check_u_r_i\n\t\t\targs[:query]['HealthCheckURI'] = optional[:health_check_u_r_i]\n\t\tend\n\t\tif optional.key? :healthy_threshold\n\t\t\traise ArgumentError, 'healthy_threshold must be equal or greater than 1' unless optional[:healthy_threshold] < 1\n\t\t\traise ArgumentError, 'healthy_threshold must be equal or less than 10' unless optional[:healthy_threshold] > 10\n\t\t\targs[:query]['HealthyThreshold'] = optional[:healthy_threshold]\n\t\tend\n\t\tif optional.key? :max_conn_limit\n\t\t\targs[:query]['MaxConnLimit'] = optional[:max_conn_limit]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :persistence_timeout\n\t\t\traise ArgumentError, 'persistence_timeout must be equal or greater than 0' unless optional[:persistence_timeout] < 0\n\t\t\traise ArgumentError, 'persistence_timeout must be equal or less than 86400' unless optional[:persistence_timeout] > 86400\n\t\t\targs[:query]['PersistenceTimeout'] = optional[:persistence_timeout]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tif optional.key? :scheduler\n\t\t\targs[:query]['Scheduler'] = optional[:scheduler]\n\t\tend\n\t\tif optional.key? :unhealthy_threshold\n\t\t\traise ArgumentError, 'unhealthy_threshold must be equal or greater than 1' unless optional[:unhealthy_threshold] < 1\n\t\t\traise ArgumentError, 'unhealthy_threshold must be equal or less than 10' unless optional[:unhealthy_threshold] > 10\n\t\t\targs[:query]['UnhealthyThreshold'] = optional[:unhealthy_threshold]\n\t\tend\n\t\traise ArgumentError, 'backend_server_port must be equal or greater than 1' unless backend_server_port < 1\n\t\traise ArgumentError, 'backend_server_port must be equal or less than 65535' unless backend_server_port > 65535\n\t\targs[:query]['BackendServerPort'] = backend_server_port\n\t\traise ArgumentError, 'bandwidth must be equal or greater than -1' unless bandwidth < -1\n\t\traise ArgumentError, 'bandwidth must be equal or less than 1000' unless bandwidth > 1000\n\t\targs[:query]['Bandwidth'] = bandwidth\n\t\traise ArgumentError, 'listener_port must be equal or greater than 1' unless listener_port < 1\n\t\traise ArgumentError, 'listener_port must be equal or less than 65535' unless listener_port > 65535\n\t\targs[:query]['ListenerPort'] = listener_port\n\t\tself.run(args)\n\tend",
"def setPolicies\n=begin\n Util.modifyPolicy(ncaEnclave, '', '\nPolicy DamlBootPolicyNCAServletForRearPolicyAdmin = [\n A user in role RearPolicyAdministration can access a servlet named NCAServlets\n]\n')\n=end\n end",
"def assignment_policies=(value)\n @assignment_policies = value\n end",
"def add_policy_uri(policy_uri)\n unless @preferred_auth_policies.member? policy_uri\n @preferred_auth_policies << policy_uri\n end\n end",
"def policy(policy_file)\n Policy.new(policy_file)\n end",
"def set_policy\n @policy = Policy.find(params[:id])\n @broker = @policy.broker\n end",
"def ensure_policy_exists(elb_name, policy_name)\n existing_policies = ELB::elb_policies(elb_name)\n\n if !existing_policies[policy_name]\n local_policy = (Loader.policy(policy_name) rescue nil)\n if local_policy.nil?\n raise \"#{policy_name} is not already defined on the load balancer and not defined locally\"\n end\n\n @elb.create_load_balancer_policy({\n load_balancer_name: elb_name,\n policy_name: local_policy.policy_name,\n policy_type_name: local_policy.policy_type_name,\n policy_attributes: local_policy.policy_attribute_descriptions.map(&:to_h)\n })\n end\n end",
"def create_app_cookie_stickiness_policy(lb_name, policy_name, cookie_name)\n params = {'CookieName' => cookie_name, 'PolicyName' => policy_name}\n\n request({\n 'Action' => 'CreateAppCookieStickinessPolicy',\n 'LoadBalancerName' => lb_name,\n :parser => Fog::Parsers::AWS::ELB::Empty.new\n }.merge!(params))\n end",
"def add_resource_policies request_pb, options:, &block\n uri = \"/compute/v1/projects/#{request_pb.project}/zones/#{request_pb.zone}/disks/#{request_pb.disk}/addResourcePolicies\"\n body = request_pb.disks_add_resource_policies_request_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 policy\n ensure_service!\n grpc = service.get_instance_policy path\n policy = Policy.from_grpc grpc\n return policy unless block_given?\n yield policy\n update_policy policy\n end",
"def create_policy(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreatePolicy'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :description\n\t\t\targs[:query]['Description'] = optional[:description]\n\t\tend\n\t\tif optional.key? :policy_document\n\t\t\targs[:query]['PolicyDocument'] = optional[:policy_document]\n\t\tend\n\t\tif optional.key? :policy_name\n\t\t\targs[:query]['PolicyName'] = optional[:policy_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def applied_policies=(value)\n @applied_policies = value\n end",
"def create\n begin\n @new_policy = @@stripper.hashData(params[:policy])\n @new_policy[:mypclient_id] = @@client_id\n @new_policy[:isactive] = 1\n @new_policy[:createdby] = session[:username]\n\n @@request_result[:data] = @new_policy\n\n @policy = Workskedpolicy.new(@new_policy)\n if @policy.save\n @@request_result[:success] = true\n @@request_result[:notice] = 'Policy was successfully created.'\n else\n @@request_result[:errormsg] = @policy.errors.full_messages[0]\n end\n rescue Exception => e \n @@request_result[:errormsg] = e.message\n end\n render json: @@request_result\n end",
"def allocate_load_balancer(action_handler, lb_spec, lb_options, machine_specs)\n end",
"def create_policy_override(opts = {})\n data, _status_code, _headers = create_policy_override_with_http_info(opts)\n data\n end",
"def add_policy(_sec, ptype, rule)\n db[table_name].insert(policy_line(ptype, rule))\n end",
"def policy(auth)\n # Dynamically create an instance of appropriate policy.\n class_name = \"#{auth['provider']}\".classify\n \"OAuthPolicy::#{class_name}\".constantize.new(auth)\n end",
"def policy(user, record)\n policy = ::Pundit::PolicyFinder.new(record).policy\n policy.new(user, record, self) if policy\n end",
"def modify_backup_policy(d_b_instance_id, preferred_backup_period, preferred_backup_time, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'ModifyBackupPolicy'\n\t\targs[:query]['DBInstanceId'] = d_b_instance_id\n\t\targs[:query]['PreferredBackupPeriod'] = preferred_backup_period\n\t\targs[:query]['PreferredBackupTime'] = preferred_backup_time\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend",
"def add_conditions policy, conditions, current_model = nil\n case conditions\n when Symbol\n if conditions == :self\n policy[:self] = true\n elsif conditions == :params\n policy[:widget_params] = true\n else\n policy[:models][conditions.to_s] = {:params => [],\n :procs => [],\n :identifier => nil}\n end\n when Proc\n policy[:procs] << conditions\n when String\n policy[:models][conditions] = {:params => [],\n :procs => [],\n :identifier => nil}\n when Array\n conditions.each do |condition|\n add_conditions policy, condition\n end\n when Hash\n conditions.each do |key, val|\n if val.is_a?(Hash)\n policy[:models][key.to_s] = {:params => [],\n :procs => [],\n :identifier => nil}\n add_conditions policy, val, key.to_s\n else\n if key == :expires_in\n policy[:expires_in] = val\n else\n if key.is_a?(Proc) || val.is_a?(Proc)\n policy[:models][current_model][:procs] << [val, key]\n else\n policy[:models][current_model][:params] << {val => key}\n end\n end\n end\n end\n end\n\n end",
"def describe_load_balancer_policy_types(type_names = [])\n params = Fog::AWS.indexed_param('PolicyTypeNames.member', [*type_names])\n request({\n 'Action' => 'DescribeLoadBalancerPolicyTypes',\n :parser => Fog::Parsers::AWS::ELB::DescribeLoadBalancerPolicyTypes.new\n }.merge!(params))\n end",
"def addPolicy(_class, log_level)\n\t\tkey = _class.to_s\n\n\t\tif @logger_policies.has_key?(key) == true\n\t\t\t@logger_policies[key] |= log_level\n\t\telse\n\t\t\t@logger_policies[key] = log_level\n\t\tend\n\tend",
"def policies()\n return MicrosoftGraph::Policies::PoliciesRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def add_policy_uri(policy_uri)\n @auth_policies << policy_uri unless @auth_policies.member?(policy_uri)\n end",
"def create_load_balancer_u_d_p_listener(backend_server_port, bandwidth, listener_port, load_balancer_id, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateLoadBalancerUDPListener'\n\t\targs[:query]['LoadBalancerId'] = load_balancer_id\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :health_check_connect_port\n\t\t\traise ArgumentError, 'health_check_connect_port must be equal or greater than 1' unless optional[:health_check_connect_port] < 1\n\t\t\traise ArgumentError, 'health_check_connect_port must be equal or less than 65535' unless optional[:health_check_connect_port] > 65535\n\t\t\targs[:query]['HealthCheckConnectPort'] = optional[:health_check_connect_port]\n\t\tend\n\t\tif optional.key? :health_check_connect_timeout\n\t\t\traise ArgumentError, 'health_check_connect_timeout must be equal or greater than 1' unless optional[:health_check_connect_timeout] < 1\n\t\t\traise ArgumentError, 'health_check_connect_timeout must be equal or less than 50' unless optional[:health_check_connect_timeout] > 50\n\t\t\targs[:query]['HealthCheckConnectTimeout'] = optional[:health_check_connect_timeout]\n\t\tend\n\t\tif optional.key? :health_check_interval\n\t\t\traise ArgumentError, 'health_check_interval must be equal or greater than 1' unless optional[:health_check_interval] < 1\n\t\t\traise ArgumentError, 'health_check_interval must be equal or less than 5' unless optional[:health_check_interval] > 5\n\t\t\targs[:query]['healthCheckInterval'] = optional[:health_check_interval]\n\t\tend\n\t\tif optional.key? :healthy_threshold\n\t\t\traise ArgumentError, 'healthy_threshold must be equal or greater than 1' unless optional[:healthy_threshold] < 1\n\t\t\traise ArgumentError, 'healthy_threshold must be equal or less than 10' unless optional[:healthy_threshold] > 10\n\t\t\targs[:query]['HealthyThreshold'] = optional[:healthy_threshold]\n\t\tend\n\t\tif optional.key? :max_conn_limit\n\t\t\targs[:query]['MaxConnLimit'] = optional[:max_conn_limit]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :persistence_timeout\n\t\t\traise ArgumentError, 'persistence_timeout must be equal or greater than 0' unless optional[:persistence_timeout] < 0\n\t\t\traise ArgumentError, 'persistence_timeout must be equal or less than 86400' unless optional[:persistence_timeout] > 86400\n\t\t\targs[:query]['PersistenceTimeout'] = optional[:persistence_timeout]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tif optional.key? :scheduler\n\t\t\targs[:query]['Scheduler'] = optional[:scheduler]\n\t\tend\n\t\tif optional.key? :unhealthy_threshold\n\t\t\traise ArgumentError, 'unhealthy_threshold must be equal or greater than 1' unless optional[:unhealthy_threshold] < 1\n\t\t\traise ArgumentError, 'unhealthy_threshold must be equal or less than 10' unless optional[:unhealthy_threshold] > 10\n\t\t\targs[:query]['UnhealthyThreshold'] = optional[:unhealthy_threshold]\n\t\tend\n\t\traise ArgumentError, 'backend_server_port must be equal or greater than 1' unless backend_server_port < 1\n\t\traise ArgumentError, 'backend_server_port must be equal or less than 65535' unless backend_server_port > 65535\n\t\targs[:query]['BackendServerPort'] = backend_server_port\n\t\traise ArgumentError, 'bandwidth must be equal or greater than -1' unless bandwidth < -1\n\t\traise ArgumentError, 'bandwidth must be equal or less than 1000' unless bandwidth > 1000\n\t\targs[:query]['Bandwidth'] = bandwidth\n\t\traise ArgumentError, 'listener_port must be equal or greater than 1' unless listener_port < 1\n\t\traise ArgumentError, 'listener_port must be equal or less than 65535' unless listener_port > 65535\n\t\targs[:query]['ListenerPort'] = listener_port\n\t\tself.run(args)\n\tend",
"def create\n\t\t@policy = current_company.policies.build(policy_params)\n\t\[email protected]_status_id = 1;\n\t\tif @policy.save\n\t\t\tredirect_to show_individual_policy_path(@policy), :flash => { :notice => \"Policy has been drafted successfully\" }\n\t\telse\n\t\t\trender \"new\"\n\t\tend\n\tend",
"def create\n @client_policy = ClientPolicy.new(client_policy_params)\n\n respond_to do |format|\n if @client_policy.save\n format.html { redirect_to @client_policy, notice: 'Client policy was successfully created.' }\n format.json { render :show, status: :created, location: @client_policy }\n else\n format.html { render :new }\n format.json { render json: @client_policy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(policy, scale)\n\n puts \"Creating scale policy: #{policy}\"\n scale_policy = @policy.create(policy,\n **scale)\n\n scale_alert = {\n alarm: scale[:alarm],\n comparison_operator: scale[:comparison_operator],\n evaluation_periods: 3,\n threshold: scale[:threshold],\n actions: [scale_policy]\n }\n\n puts \"Creating alarms for scale policy: #{scale_policy}\"\n Tapjoy::AutoscalingBootstrap::Cloudwatch.create_alarm(scale_alert)\n end",
"def create_adr_policy(policy, password)\n adr_policy_name_select.select(policy)\n save_adr_policy_btn.click\n password_input.type_text(password)\n submit_adr_policy_btn.click\n if alert_present?\n alert_accept\n Log.debugger \"Input incorrect password and get alert dialog\"\n end\n end",
"def populate_policies(policies)\n @policies = policies.map do |policy|\n config = PolicyConfig.new()\n config.populate(policy)\n config\n end\n end",
"def policy_klass\n resource_module::Policy\n end",
"def new\n @load_balancer_policy = LoadBalancerPolicy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @load_balancer_policy }\n end\n end",
"def policy(name, &b)\n @policies ||= []\n @policies << Proc.new do |subject_class|\n args = send(name, subject_class)\n if args.kind_of? Array\n if args.reverse!.pop\n subject_class.instance_exec(args.reverse!) &b\n true\n else\n false\n end\n else\n if args\n subject_class.instance_eval &b\n true\n else\n false\n end\n end\n end\n end",
"def create\n @new_policy = NewPolicy.new(params[:new_policy])\n\n respond_to do |format|\n if @new_policy.save\n format.html { redirect_to @new_policy, notice: 'New policy was successfully created.' }\n format.json { render json: @new_policy, status: :created, location: @new_policy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @new_policy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def policy\n ensure_service!\n grpc = service.get_topic_policy name\n policy = Policy.from_grpc grpc\n return policy unless block_given?\n yield policy\n update_policy policy\n end",
"def add_resource_policies request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_add_resource_policies_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def create\n @loadbalancer = Loadbalancer.new(params[:loadbalancer])\n @loadbalancer.account_id = @oeaccount.id\n respond_to do |format|\n if @loadbalancer.save\n format.html { redirect_to loadbalancers_url, notice: 'Loadbalancer was successfully created.' }\n format.json { render json: @loadbalancer, status: :created, location: @loadbalancer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @loadbalancer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def policy_class\n Hydra.config.permissions.policy_class || Hydra::AdminPolicy\n end",
"def add_backend(auth_backend)\n @backends << auth_backend\n end",
"def load_balancer # rubocop:disable AbcSize\n raise 'Can not determine hostname to load client for' if @new_resource.f5.nil?\n @@load_balancers ||= []\n add_lb(@new_resource.f5) if @@load_balancers.empty?\n add_lb(@new_resource.f5) if @@load_balancers.find { |lb| lb.name == @new_resource.f5 }.nil?\n @@load_balancers.find { |lb| lb.name == @new_resource.f5 }\n end",
"def add_backend_servers(load_balancer_id, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'AddBackendServers'\n\t\targs[:query]['LoadBalancerId'] = load_balancer_id\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :backend_servers\n\t\t\targs[:query]['BackendServers'] = optional[:backend_servers]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend",
"def create_policy(filtertype)\n\n # Initialize vars, sets, string, hashes, etc\n filter = String.new\n fwconfig = String.new\n result = String.new\n service_negate = String.new\n newaddresses = Set.new\n\n case filtertype\n when :ipv4_input_filter\n fwconfig += \"#### Firewall Interface Policy ####\\n\"\n fwconfig += \"config firewall interface-policy\\n\"\n h_filters = $h_filters\n when :ipv6_input_filter\n fwconfig += \"#### Firewall IPv6 Interface Policy ####\\n\"\n fwconfig += \"config firewall interface-policy6\\n\"\n h_filters = $h_filters6\n when :ipv4_output_filter\n fwconfig += \"#### Firewall Policy ####\\n\"\n fwconfig += \"config firewall policy\\n\"\n h_filters = $h_filters\n when :ipv6_output_filter\n fwconfig += \"#### Firewall IPv6 Policy ####\\n\"\n fwconfig += \"config firewall policy6\\n\"\n h_filters = $h_filters6\n else\n p \"create_fg_intf_policy_rules: filtertype not supported - #{filtertype}\" if $opts[:verbose]\n return\n end\n\n # For each interface/sub-interface, process each unique filter matching the passed filtertype option\n # We are iterating through each used filter and checking the terms for compatibility. If compatible\n # then we will go ahead and process/convert to FG config.\n $h_interfaces.each_key do |int|\n $h_interfaces[int].each_key do |sub|\n if ($opts[:interfacemapout] && $h_ints_map_out.has_key?(\"#{int}-#{sub}\")) || !$opts[:interfacemapout]\n filter = $h_interfaces[int][sub][filtertype]\n\n ruletype = '' # for supportability checks\n filterref = '' # for referenced filters (aka linked filters)\n\n ### if interfacemapout option specified then we will change the dst interace to zone name supplied by file\n if $opts[:interfacemapout]\n interface = $h_ints_map_out[\"#{int}-#{sub}\"]\n else\n interface = \"#{int}-#{sub}\"\n end\n\n unless filter == 'nil' || filter == nil\n if h_filters.has_key?(filter)\n h_filters[filter].each_key do |term|\n\n # check to see if this policy is derived from dscp, forwarding-class, etc. if so, we will skip\n ruletype, filterref = check_rule_support_type(filter, term, h_filters)\n\n # Call action_rule_support_type which will call the right methods to build the fg config\n # based on the juniper filter/term detail, including handling nested filters/terms\n # will return the completed FG config for that filter/term. Also, if int2sub option is enabled\n # may return a list of subnets that need to be additionally created as address objects.\n newconfig, newaddobj = action_rule_support_type(ruletype,\\\n filterref,\\\n h_filters,\\\n filtertype,\\\n filter,\\\n term,\\\n interface,\\\n int,\\\n sub)\n\n fwconfig += newconfig\n\n # Add any new address objects that need to be configured to a set (due to any dst int map)\n newaddresses << newaddobj if newaddobj\n end\n\n else\n p \"create_fg_policy_rules: filter \\\"#{filter} referenced by interface does not exist for #{int}-#{sub}\"\\\n if $opts[:debug] || $opts[:verbose]\n end\n\n end\n else\n p \"Skipping interface #{int}-#{sub} due to, is not included in --interfacemapout file\"\\\n if $opts[:debug] || $opts[:verbose]\n end\n end\n end\n fwconfig += \"end \\n\"\n\n # If new address objects need to be created due that here, and insert them in the config ahead of creating\n # rules that will need to use these objects.\n if newaddresses.count > 0\n newconfig = \"### Additional FW Addresses from derived subnets ###\"\n newconfig += \"config firewall address\\n\"\n\n newaddresses.each do |x|\n newconfig += <<-EOS\n edit #{x}\n set type subnet\n set subnet #{x}\n set comment \"Derived subnet from interface IP due to rule with dst of any\"\n next\n EOS\n end\n\n newconfig += \"end\\n\"\n\n fwconfig = newconfig + fwconfig\n end\n\n return fwconfig\n end",
"def policies; end",
"def add_load_balancer(name, ports, ip_address)\n\n unless ports.is_a? Array\n ports = [ ports ]\n end\n\n if name.nil?\n name = \"lb#{RandomName.create(5,3)}\"\n end\n\n if ip_address.is_a? String\n ip_address = public_ipaddress \"#{name}-addr\" do\n dns_settings domain_name_label: ip_address\n end\n end\n\n lb = load_balancer name do\n\n if ip_address.nil?\n fics = frontend_ipconfigurations name: name + '-feconf'\n else\n fics = frontend_ipconfigurations name: name + '-feconf',\n public_ipaddress: ip_address\n end\n\n pools = backend_address_pools name: name + '-pool'\n\n ports.each do |port|\n\n p = probes name: name + \"-probe#{port}\",\n protocol: 'Tcp',\n port: port,\n number_of_probes: 2,\n interval_in_seconds: 15\n\n load_balancing_rules name: \"rule#{port}\",\n frontend_ipconfiguration: fics[0],\n backend_address_pool: pools[0],\n protocol: 'Tcp',\n frontend_port: port,\n backend_port: port,\n idle_timeout_in_minutes: 15,\n probe: p[0]\n end\n\n end\n\n end",
"def intended_policies=(value)\n @intended_policies = value\n end",
"def add_ingestion_policy(policy_id, id_list)\n wf_ingestionpolicy_id?(policy_id)\n validate_account_list(id_list)\n api.post('addingestionpolicy',\n { ingestionPolicyId: policy_id,\n accounts: id_list },\n 'application/json')\n end",
"def policy\n ensure_service!\n grpc = service.get_table_policy instance_id, name\n policy = Policy.from_grpc grpc\n return policy unless block_given?\n yield policy\n update_policy policy\n end",
"def policy(options = {})\n HtmlPolicyBuilder.new\n end",
"def update_policy(new_policy)\n return false unless supported_by_platform?\n\n # As a sanity check, filter out any expired users. The core should never send us these guys,\n # but by filtering here additionally we prevent race conditions and handle boundary conditions, as well\n # as allowing our internal expiry timer to simply call us back when a LoginUser expires.\n # All users are added to RightScale account's authorized keys.\n new_users = new_policy.users.select { |u| (u.expires_at == nil || u.expires_at > Time.now) }\n user_lines = modify_keys_to_use_individual_profiles(new_users)\n\n InstanceState.login_policy = new_policy\n\n write_keys_file(user_lines, RIGHTSCALE_KEYS_FILE, { :user => 'rightscale', :group => 'rightscale' })\n\n tags = [ACTIVE_TAG, RESTRICTED_TAG]\n AgentTagsManager.instance.add_tags(tags)\n\n # Schedule a timer to handle any expiration that is planned to happen in the future\n schedule_expiry(new_policy)\n\n # Return a human-readable description of the policy, e.g. for an audit entry\n return describe_policy(new_users, new_users.select { |u| u.superuser })\n end",
"def policy_class\n @policy_class ||= Lookup::Policy.class_from_model(model_name)\n end",
"def policy_class\n @policy_class ||= Lookup::Policy.class_from_model(model_name)\n end",
"def new\n\t\t@policy = Policy.new\n\tend",
"def assign_policy(*args)\n target.target.send(\"assign_policy\",*args)\n end",
"def update_policy new_policy_hash\n new_policy_hash = new_policy_hash.try(:to_hash) || {}\n\n new_policy = new_policy_hash.underscorify_keys\n policy = to_hash.underscorify_keys.deep_reset(false)\n\n policy.deep_merge! new_policy\n update_attribute(:the_policy, _jsonable(policy))\n end",
"def add(policy)\n @sets[policy.name.to_s].add(policy.schema)\n end",
"def add(policy)\n @sets[policy.name.to_s].add(policy.schema)\n end",
"def policy_hash\n @policy_hash ||= policy.try(:to_hash) || {}\n end",
"def bucket_policy\n @bucket_policy ||= fetch_bucket_policy\n end",
"def bindTo(entitytype, entityname)\n if entitytype == \"instance_profile\"\n begin\n resp = MU::Cloud::AWS.iam(credentials: @credentials).get_instance_profile(\n instance_profile_name: entityname\n ).instance_profile\n\n if !resp.roles.map { |r| r.role_name}.include?(@mu_name)\n MU::Cloud::AWS.iam(credentials: @credentials).add_role_to_instance_profile(\n instance_profile_name: entityname,\n role_name: @mu_name\n )\n end\n rescue StandardError => e\n MU.log \"Error binding role #{@mu_name} to instance profile #{entityname}: #{e.message}\", MU::ERR\n raise e\n end\n elsif [\"user\", \"group\", \"role\"].include?(entitytype)\n mypolicies = MU::Cloud::AWS.iam(credentials: @credentials).list_policies(\n path_prefix: \"/\"[email protected]_id+\"/\"\n ).policies\n mypolicies.reject! { |p|\n !p.policy_name.match(/^#{Regexp.quote(@mu_name)}(-|$)/)\n }\n\n if @config['attachable_policies']\n @config['attachable_policies'].each { |policy_hash|\n policy = policy_hash[\"id\"]\n p_arn = if !policy.match(/^arn:/i)\n \"arn:\"+(MU::Cloud::AWS.isGovCloud?(@region) ? \"aws-us-gov\" : \"aws\")+\":iam::aws:policy/\"+policy\n else\n policy\n end\n\n subpaths = [\"service-role\", \"aws-service-role\", \"job-function\"]\n begin\n mypolicies << MU::Cloud::AWS.iam(credentials: @credentials).get_policy(\n policy_arn: p_arn\n ).policy\n rescue Aws::IAM::Errors::NoSuchEntity => e\n if subpaths.size > 0\n p_arn = \"arn:\"+(MU::Cloud::AWS.isGovCloud?(@region) ? \"aws-us-gov\" : \"aws\")+\":iam::aws:policy/#{subpaths.shift}/\"+policy\n retry\n end\n raise e\n end\n }\n end\n\n if @config['raw_policies']\n raw_arns = MU::Cloud::AWS::Role.manageRawPolicies(\n @config['raw_policies'],\n basename: @deploy.getResourceName(@config['name']),\n credentials: @credentials\n )\n raw_arns.each { |p_arn|\n mypolicies << MU::Cloud::AWS.iam(credentials: @credentials).get_policy(\n policy_arn: p_arn\n ).policy\n }\n end\n\n mypolicies.each { |p|\n if entitytype == \"user\"\n resp = MU::Cloud::AWS.iam(credentials: @credentials).list_attached_user_policies(\n path_prefix: \"/\"[email protected]_id+\"/\",\n user_name: entityname\n )\n if !resp or !resp.attached_policies.map { |a_p| a_p.policy_name }.include?(p.policy_name)\n MU.log \"Attaching IAM policy #{p.policy_name} to user #{entityname}\", MU::NOTICE\n MU::Cloud::AWS.iam(credentials: @credentials).attach_user_policy(\n policy_arn: p.arn,\n user_name: entityname\n )\n end\n elsif entitytype == \"group\"\n resp = MU::Cloud::AWS.iam(credentials: @credentials).list_attached_group_policies(\n path_prefix: \"/\"[email protected]_id+\"/\",\n group_name: entityname\n )\n if !resp or !resp.attached_policies.map { |a_p| a_p.policy_name }.include?(p.policy_name)\n MU.log \"Attaching policy #{p.policy_name} to group #{entityname}\", MU::NOTICE\n MU::Cloud::AWS.iam(credentials: @credentials).attach_group_policy(\n policy_arn: p.arn,\n group_name: entityname\n )\n end\n elsif entitytype == \"role\"\n resp = MU::Cloud::AWS.iam(credentials: @credentials).list_attached_role_policies(\n role_name: entityname\n )\n\n if !resp or !resp.attached_policies.map { |a_p| a_p.policy_name }.include?(p.policy_name)\n MU.log \"Attaching policy #{p.policy_name} to role #{entityname}\", MU::NOTICE\n MU::Cloud::AWS.iam(credentials: @credentials).attach_role_policy(\n policy_arn: p.arn,\n role_name: entityname\n )\n end\n end\n }\n else\n raise MuError, \"Invalid entitytype '#{entitytype}' passed to MU::Cloud::AWS::Role.bindTo. Must be be one of: user, group, role, instance_profile\"\n end\n cloud_desc(use_cache: false)\n end",
"def remove_load_balancer_properties\n properties = []\n properties << :AccessLoggingPolicy\n properties << :AppCookieStickinessPolicy\n properties << :ConnectionDrainingPolicy\n properties << :CrossZone\n properties << :LBCookieStickinessPolicy\n properties << :LoadBalancerName\n properties << 'Listeners.PolicyNames'\n properties << 'Listeners.SSLCertificateId '\n properties << :Policies\n properties << :Scheme\n properties << :SecurityGroups\n properties << :Subnets\n add_patch Patches::RemoveProperty.new 'AWS::ElasticLoadBalancing::LoadBalancer', properties\n end",
"def create_load_balancer_h_t_t_p_listener(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateLoadBalancerHTTPListener'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :backend_server_port\n\t\t\targs[:query]['BackendServerPort'] = optional[:backend_server_port]\n\t\tend\n\t\tif optional.key? :cookie\n\t\t\targs[:query]['Cookie'] = optional[:cookie]\n\t\tend\n\t\tif optional.key? :cookie_timeout\n\t\t\targs[:query]['CookieTimeout'] = optional[:cookie_timeout]\n\t\tend\n\t\tif optional.key? :domain\n\t\t\targs[:query]['Domain'] = optional[:domain]\n\t\tend\n\t\tif optional.key? :health_check\n\t\t\targs[:query]['HealthCheck'] = optional[:health_check]\n\t\tend\n\t\tif optional.key? :health_check_timeout\n\t\t\targs[:query]['HealthCheckTimeout'] = optional[:health_check_timeout]\n\t\tend\n\t\tif optional.key? :healthy_threshold\n\t\t\targs[:query]['HealthyThreshold'] = optional[:healthy_threshold]\n\t\tend\n\t\tif optional.key? :host_id\n\t\t\targs[:query]['HostId'] = optional[:host_id]\n\t\tend\n\t\tif optional.key? :interval\n\t\t\targs[:query]['Interval'] = optional[:interval]\n\t\tend\n\t\tif optional.key? :listener_port\n\t\t\targs[:query]['ListenerPort'] = optional[:listener_port]\n\t\tend\n\t\tif optional.key? :listener_status\n\t\t\targs[:query]['ListenerStatus'] = optional[:listener_status]\n\t\tend\n\t\tif optional.key? :load_balancer_id\n\t\t\targs[:query]['LoadBalancerId'] = optional[:load_balancer_id]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :scheduler\n\t\t\targs[:query]['Scheduler'] = optional[:scheduler]\n\t\tend\n\t\tif optional.key? :sticky_session\n\t\t\targs[:query]['StickySession'] = optional[:sticky_session]\n\t\tend\n\t\tif optional.key? :sticky_session_type\n\t\t\targs[:query]['StickySessionType'] = optional[:sticky_session_type]\n\t\tend\n\t\tif optional.key? :u_r_i\n\t\t\targs[:query]['URI'] = optional[:u_r_i]\n\t\tend\n\t\tif optional.key? :unhealthy_threshold\n\t\t\targs[:query]['UnhealthyThreshold'] = optional[:unhealthy_threshold]\n\t\tend\n\t\tif optional.key? :x_forwarded_for\n\t\t\targs[:query]['XForwardedFor'] = optional[:x_forwarded_for]\n\t\tend\n\t\tself.run(args)\n\tend",
"def ostiary_policy(role = nil, only: nil, except: nil, method: nil)\n raise ArgumentError, \"Use at least role or method\" unless method || role\n raise ArgumentError, \"Use either role or method\" if method && role\n raise ArgumentError, \"Use either only or except\" if except && only\n raise ArgumentError, \"Use a symbol for method:\" if method && !(method.is_a? Symbol)\n\n if only\n ostiary.policies << PolicyLimited.new(role, only, method: method&.to_proc)\n elsif except\n ostiary.policies << PolicyExempted.new(role, except, method: method&.to_proc)\n else\n ostiary.policies << Policy.new(role, method: method&.to_proc)\n end\n end",
"def app_management_policies=(value)\n @app_management_policies = value\n end",
"def services_web_application_name_servers_web_server_name_load_balancing_put(authorization, web_application_name, web_server_name, load_balancing, opts = {})\n data,status_code,headers = services_web_application_name_servers_web_server_name_load_balancing_put_with_http_info(authorization, web_application_name, web_server_name, load_balancing, opts)\n return data,status_code,headers\n end",
"def create\n @policy = Policy.new(policy_params)\n\n respond_to do |format|\n if @policy.save\n format.html { redirect_to @policy, notice: 'Policy was successfully created.' }\n format.json { render :show, status: :created, location: @policy }\n else\n format.html { render :new }\n format.json { render json: @policy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def load_policy\n model.clear_policy\n adapter.load_policy model\n\n init_rm_map\n model.print_policy\n build_role_links if auto_build_role_links\n end",
"def set_backup_policy instance_id, cluster_id, backup_id, policy\n tables.set_iam_policy resource: backup_path(instance_id, cluster_id, backup_id), policy: policy\n end",
"def migrate_default_policies\n policies_dir = \"#{@migration_root}/elb-default-policies\"\n\n if !Dir.exists?(@migration_root)\n Dir.mkdir(@migration_root)\n end\n if !Dir.exists?(policies_dir)\n Dir.mkdir(policies_dir)\n end\n\n default_policies = ELB::default_policies\n default_policies.map do |policy_name, policy|\n puts \"Processing #{policy_name}\"\n\n cumulus_name = \"Cumulus-#{policy_name}\"\n json = JSON.pretty_generate(policy.to_cumulus_hash)\n\n File.open(\"#{policies_dir}/#{cumulus_name}.json\", \"w\") { |f| f.write(json) }\n end\n end",
"def create\n @priv_policy = PrivPolicy.new(priv_policy_params)\n\n respond_to do |format|\n if @priv_policy.save\n format.html { redirect_to @priv_policy, notice: 'Priv policy was successfully created.' }\n format.json { render :show, status: :created, location: @priv_policy }\n else\n format.html { render :new }\n format.json { render json: @priv_policy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def generate_policy\n statements = []\n compile.resources.keys!.each do |r_name|\n r_object = compile.resources[r_name]\n if(r_object['Policy'])\n r_object['Policy'].keys!.each do |effect|\n statements.push(\n 'Effect' => effect.to_s.capitalize,\n 'Action' => [r_object['Policy'][effect]].flatten.compact.map{|i| \"Update:#{i}\"},\n 'Resource' => \"LogicalResourceId/#{r_name}\",\n 'Principal' => '*'\n )\n end\n r_object.delete!('Policy')\n end\n end\n statements.push(\n 'Effect' => 'Allow',\n 'Action' => 'Update:*',\n 'Resource' => '*',\n 'Principal' => '*'\n )\n Smash.new('Statement' => statements)\n end",
"def create_server_tls_policy request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_create_server_tls_policy_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def create_load_balancer_listeners(lb_name, listeners)\n params = {}\n\n listener_protocol = []\n listener_lb_port = []\n listener_instance_port = []\n listener_instance_protocol = []\n listener_ssl_certificate_id = []\n listeners.each do |listener|\n listener_protocol.push(listener['Protocol'])\n listener_lb_port.push(listener['LoadBalancerPort'])\n listener_instance_port.push(listener['InstancePort'])\n listener_instance_protocol.push(listener['InstanceProtocol'])\n listener_ssl_certificate_id.push(listener['SSLCertificateId'])\n end\n\n params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.Protocol', listener_protocol))\n params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.LoadBalancerPort', listener_lb_port))\n params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.InstancePort', listener_instance_port))\n params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.InstanceProtocol', listener_instance_protocol))\n params.merge!(Fog::AWS.indexed_param('Listeners.member.%d.SSLCertificateId', listener_ssl_certificate_id))\n\n request({\n 'Action' => 'CreateLoadBalancerListeners',\n 'LoadBalancerName' => lb_name,\n :parser => Fog::Parsers::AWS::ELB::Empty.new\n }.merge!(params))\n end",
"def managed_app_policies=(value)\n @managed_app_policies = value\n end",
"def create_elb(elb)\n resp = aws_api_connect(\"ELB_Client\")\n begin\n pants = resp.create_load_balancer({\n load_balancer_name: elb[:name],\n listeners: [\n {\n protocol: elb[:protocol],\n load_balancer_port: elb[:port],\n instance_protocol: elb[:instnace_protocol],\n instance_port: elb[:instance_port],\n ssl_certificate_id: elb[:ssl_cert],\n },\n ],\n subnets: elb[:subnets],\n security_groups: elb[:security_groups],\n })\n rescue Aws::ElasticLoadBalancing::Errors::DuplicateLoadBalancerName\n puts \"Load Balancer #{elb[:name]} already exists, bypassing\"\n rescue Aws::ElasticLoadBalancing::Errors::Throttling\n puts \"api throttled, retrying\"\n # TODO: Add exponential backoff\n sleep(5)\n retry\n end\n end",
"def policy(target, options={})\n user = options[:user] || current_user\n klass = options[:policy] || \"#{target.model_name.name}Policy\".constantize\n\n klass.new(user, target, options[:context] || {})\n end",
"def initialize(endpoints, options={})\n @options = DEFAULT_OPTIONS.merge(options)\n\n unless endpoints && !endpoints.empty?\n raise ArgumentError, \"Must specify at least one endpoint\"\n end\n\n @options[:policy] ||= RightSupport::Net::LB::RoundRobin\n @policy = @options[:policy]\n @policy = @policy.new(options) if @policy.is_a?(Class)\n\n unless test_policy_duck_type(@policy)\n raise ArgumentError, \":policy must be a class/object that responds to :next, :good and :bad\"\n end\n\n unless test_callable_arity(options[:retry], 2)\n raise ArgumentError, \":retry callback must accept two parameters\"\n end\n\n unless test_callable_arity(options[:fatal], 1)\n raise ArgumentError, \":fatal callback must accept one parameter\"\n end\n\n unless test_callable_arity(options[:on_exception], 3, false)\n raise ArgumentError, \":on_exception callback must accept three parameters\"\n end\n\n unless test_callable_arity(options[:health_check], 1, false)\n raise ArgumentError, \":health_check callback must accept one parameter\"\n end\n\n unless test_callable_arity(options[:on_health_change], 1, false)\n raise ArgumentError, \":on_health_change callback must accept one parameter\"\n end\n\n @endpoints = endpoints\n\n if @options[:resolve]\n @resolved_at = 0\n else\n @policy.set_endpoints(@endpoints)\n end\n end",
"def update\n @load_balancer_policy = LoadBalancerPolicy.find(params[:id])\n\n respond_to do |format|\n if @load_balancer_policy.update_attributes(params[:load_balancer_policy])\n flash[:notice] = 'LoadBalancerPolicy was successfully updated.'\n format.html { redirect_to(@load_balancer_policy) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @load_balancer_policy.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_policy(node)\n policy_group, policy_name = @name_args[1..]\n node.policy_name = policy_name\n node.policy_group = policy_group\n end",
"def policy name, &body\n self.active_policy = {}\n instance_exec &body\n self.ctx[name] = self.active_policy\n end",
"def policies\n @policies = Policy.all\n end",
"def initialize(endpoints, options={})\n @options = DEFAULT_OPTIONS.merge(options)\n\n unless endpoints && !endpoints.empty?\n raise ArgumentError, \"Must specify at least one endpoint\"\n end\n\n @options[:policy] ||= RightSupport::Net::LB::RoundRobin\n @policy = @options[:policy]\n @policy = @policy.new(options) if @policy.is_a?(Class)\n\n unless test_policy_duck_type(@policy)\n raise ArgumentError, \":policy must be a class/object that responds to :next, :good and :bad\"\n end\n\n unless test_callable_arity(options[:retry], 2)\n raise ArgumentError, \":retry callback must accept two parameters\"\n end\n\n unless test_callable_arity(options[:fatal], 1)\n raise ArgumentError, \":fatal callback must accept one parameter\"\n end\n\n unless test_callable_arity(options[:on_exception], 3, false)\n raise ArgumentError, \":on_exception callback must accept three parameters\"\n end\n\n unless test_callable_arity(options[:health_check], 1, false)\n raise ArgumentError, \":health_check callback must accept one parameter\"\n end\n\n unless test_callable_arity(options[:on_health_change], 1, false)\n raise ArgumentError, \":on_health_change callback must accept one parameter\"\n end\n\n @endpoints = endpoints\n\n if @options[:resolve]\n # Perform initial DNS resolution\n resolve\n else\n # Use endpoints as-is\n @policy.set_endpoints(@endpoints)\n end\n end",
"def policies_for_widget widget, options\n widget = widget.is_a?(Widget) ? widget : Widget.find(widget)\n policies = UbiquoDesign::CachePolicies.get(options[:policy_context])[widget.key]\n [widget, policies]\n end",
"def set_backend_servers(load_balancer_id, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'SetBackendServers'\n\t\targs[:query]['LoadBalancerId'] = load_balancer_id\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :backend_servers\n\t\t\targs[:query]['BackendServers'] = optional[:backend_servers]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend"
] | [
"0.6613577",
"0.6293767",
"0.6085485",
"0.593681",
"0.56331176",
"0.54778725",
"0.54384965",
"0.52465326",
"0.520651",
"0.5175385",
"0.51662636",
"0.514898",
"0.5141088",
"0.51317406",
"0.51284635",
"0.51284635",
"0.5116953",
"0.5097152",
"0.505784",
"0.5038275",
"0.500837",
"0.49789295",
"0.4973561",
"0.49595758",
"0.49589565",
"0.49536186",
"0.49472868",
"0.48480424",
"0.48429987",
"0.48404363",
"0.48343733",
"0.48132125",
"0.4811696",
"0.48106223",
"0.4795847",
"0.47887242",
"0.47847733",
"0.47843868",
"0.47729102",
"0.47716197",
"0.47444305",
"0.472931",
"0.4717352",
"0.47128782",
"0.46962774",
"0.46928737",
"0.4685006",
"0.4675447",
"0.46720067",
"0.4662285",
"0.4657425",
"0.46344206",
"0.46261016",
"0.4621428",
"0.46187082",
"0.46086514",
"0.4605191",
"0.46047476",
"0.45958814",
"0.45891136",
"0.4578123",
"0.4573599",
"0.45580322",
"0.45499876",
"0.454505",
"0.45412505",
"0.45259738",
"0.45259738",
"0.45257825",
"0.45195168",
"0.4502177",
"0.4501622",
"0.4501622",
"0.4493264",
"0.44926596",
"0.44869342",
"0.44799662",
"0.44791824",
"0.44745559",
"0.44744173",
"0.4468764",
"0.44615406",
"0.4455619",
"0.4448487",
"0.44447052",
"0.4433846",
"0.44289422",
"0.4418654",
"0.44177562",
"0.4405612",
"0.43944323",
"0.4392475",
"0.43856058",
"0.43833205",
"0.43693507",
"0.4359548",
"0.43550315",
"0.4352316",
"0.43503895",
"0.43428054"
] | 0.668007 | 0 |
Helper method for showing brief view composers who have composed works based on this superwork are requierd to be shown | def works_evidenced_composers
all_composers = []
works.map{|w| all_composers << w.composers}
all_composers.flatten!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @other_tools = @tool.others_from_this_owner\n @collaborators = @tool.collaborators\n end",
"def displayed?; end",
"def draw_tactic_overview\n end",
"def show_full\n @show_full=true\n end",
"def show_works_widget\n @show_works_widget = true\n end",
"def display\n # If the DUT responds to a sub_block \"display\" return the sub_block\n if model.sub_blocks.include? 'display'\n Origen.log.debug \"Found a sub_block \\'display\\', passing control to the #{model.class}...\"\n model.sub_blocks['display']\n else\n # Else, pass control to the ruby core.\n super\n end\n end",
"def show\n\t\t@works = @anthology.works.decorate\n\tend",
"def display_results\n make\n display_best\n display_mutations unless @mutations\n end",
"def display\n # Don't no why i thought i would need that. or if i need this.\n end",
"def to_show *ignore\n ignore.map! &:to_name\n\n show_parts = parts.map do |part|\n reject = ( part.empty? or part =~ /^_/ or ignore.member? part.to_name )\n reject ? nil : part\n end\n\n show_name = show_parts.compact.to_name.s\n \n case\n when show_parts.compact.empty?; self\n when show_parts[0].nil? ; self.class.joint + show_name\n else show_name\n end\n end",
"def modeler_description\n return 'This can be modifed to alter a sub-set of the windows by filtering by sub urface type, construction, name, or orientation. '\n end",
"def show_libra_work( work )\n\n return if work.nil?\n j = JSON.parse( work.to_json )\n j.keys.sort.each do |k|\n val = j[ k ]\n if k.end_with?( '_id' ) == false && k.end_with?( '_ids' ) == false\n show_field( k, val, ' ' )\n end\n end\n\n show_field( 'visibility', work.visibility, ' ' )\n\n Author.sort( work.authors ).each_with_index do |p, ix|\n show_person( \" author #{ix + 1}:\", p )\n end\n\n Contributor.sort( work.contributors ).each_with_index do |p, ix|\n show_person( \" contributor #{ix + 1}:\", p )\n end\n\n if work.file_sets\n file_number = 1\n fs = work.file_sets.sort { |x, y| x.date_uploaded <=> y.date_uploaded }\n fs.each do |file_set|\n puts \" file #{file_number} => #{file_set.label}/#{file_set.title[0]} (/downloads/#{file_set.id})\"\n file_number += 1\n end\n end\n\n puts '*' * 40\n\n end",
"def show_about\n @metadata_profile = @unit.effective_metadata_profile\n @num_downloads = MonthlyUnitItemDownloadCount.sum_for_unit(unit: @unit)\n @num_submitted_items = @unit.submitted_item_count\n @collections = Collection.search.\n institution(@unit.institution).\n filter(Collection::IndexFields::PRIMARY_UNIT, @unit.id).\n order(\"#{Collection::IndexFields::TITLE}.sort\").\n limit(999)\n @subunits = Unit.search.\n institution(@unit.institution).\n parent_unit(@unit).\n order(\"#{Unit::IndexFields::TITLE}.sort\").\n limit(999)\n render partial: \"show_about_tab\"\n end",
"def show\n render_default_format(@our_works, true, 200)\n rescue Exception => e\n puts e.inspect\n end",
"def display_tasks_and_comments\n puts \"Displaying tasks... \\n\"\n puts\n if(options.show_tasks == :tasks)\n # Get the maximum width of all task names\n all_displayable_tasks = tasks.select { |t|\n t.comment && t.name =~ options.show_task_pattern\n }\n \n #puts \"Displayable tasks: #{all_displayable_tasks}\\n\"\n \n width = all_displayable_tasks.collect { |t| t.name_with_args.length }.max || 10\n max_column = truncate_output? ? terminal_width() - name.size - width - 7 : nil\n \n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n if(projectFile.HasTasks())\n headline = \"Tasks in project file: '#{projectFile.Path().RelativePath()}'\\n\"\n puts headline\n puts \"-\" * headline.length\n puts projectFile.GetTaskDescriptions(width, max_column)\n end \n end\n else\n super\n end\n end",
"def show_build\n end",
"def complete_briefing\n output = \"\\n\"\n output << \"#### ABMIRAL BATTLE PLAN #{name}\\n\"\n output << self.orders.map { |order| order.briefing }.join(\"\\n\") + \"\\n\"\n output << \"#### ABMIRAL BATTLE PLAN END\"\n output\n end",
"def show\n\t\t#no need b/c we just show all at once\n\tend",
"def look\n puts \"*#{@short_description}*\"\n puts \"#{@long_description}\"\n puts\n to_show = contents.reject{|o| o.name == 'self'}\n room_descr_items = to_show.select{|o| o.room_description} #items that have a special room_description value, which is prose overriding \n #the simple behavior of just listing the name of an item during room description.\n to_show.reject! {|x| room_descr_items.include?(x) }\n room_descr_items.each do |item|\n puts item.room_description\n end\n if not to_show.empty?\n print \"You can see \"\n to_show.each do |obj|\n print \"and \" if obj == to_show.last && obj != to_show.first\n print \"#{obj.name} \"\n end\n puts \"here.\"\n end\n end",
"def show\n @parts = @recipe.parts\n @avaliable = @recipe.avaliable\n end",
"def display\n puts (\"[\" + @id.name + \", \" + @id.version + \"]\").green.bold\n puts \"author = \".blue + @author\n print \"wrapper = \".blue + @wrapper.to_s\n puts \", unique = \".blue + @unique.to_s\n puts\n\n puts \"[Path:]\".green.bold\n puts @path\n\n #\n # Display the provided elements\n #\n\n puts \"\\n[Provide]\".green.bold\n @provide.each do |context|\n puts \"\\n<Context #{context.name}>\".blue.bold\n OCMSet::SECTIONS.each { |section| context[section].each { |k| puts k } }\n end\n\n #\n # Display the required elements\n #\n\n if @require != nil then\n puts \"\\n[Require]\".green.bold\n OCMSet::SECTIONS.each { |section| @require[section].each { |k| puts k } }\n end\n\n end",
"def parent_work\n find_related_frbr_objects( :is_part_of, :which_works?) \n end",
"def show \r\n end",
"def show\n @components = @project.components\n @for_bidding = @components.where(status: 1).order('created_at desc')\n @ongoing = @components.where(status: 2).order('created_at desc')\n @completed = @components.where(status: 3).order('created_at desc')\n @funding = @components.where(status: 4).order('created_at desc')\n end",
"def show\n render_default_format(@work, true, 200)\n rescue Exception => e\n puts e.inspect\n end",
"def redisplay\n if @scope == 0\n redisplay_bill\n else\n redisplay_custom\n end\n redisplay_tip_and_total\n redisplay_splits\n redisplay_clear\n end",
"def overview\n\n end",
"def team_work_show\n\t\tif self.team_work == true\n\t\t\t\"小組\"\n\t\telse\n\t\t\t\"個人\"\n\t\tend\t\n\tend",
"def show\n @unit_planner = UnitPlanner.find(params[:id])\n \n @skills = Skill.all(:include=>{:strategies=>:approaches}, :order=>\"skills.label\", :conditions=>[\"approaches.unit_planner_id=?\", @unit_planner.id])\n\n # move to model? Also, this seems a bit complicated. Any way to simplify?\n x = @unit_planner.objectives\n y = @unit_planner.formative_tasks.collect{|ft| ft.objectives}.flatten.uniq\n @objectives_sans_formative_tasks = (x - y).collect{|z| \"#{z.criterion.category}.#{z.subcategory}\"}.sort\n @criterions_sans_summative_tasks = (@unit_planner.criterions - @unit_planner.summative_tasks.collect(&:criterions).flatten.uniq).collect(&:category).join(\", \")\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unit_planner }\n end\n end",
"def brief_battle_plans\n @battle_plans.map { |battle_plan| battle_plan.complete_briefing }.join(\"\\n\")\n end",
"def detail_for record, &block\n concat(render_default_css, block.binding) unless @_showhide_css_done\n div_for(record, 'detail_for', :style => 'display: none;', :class => 'detail', &block)\n @_showhide_css_done = true # prevents to print the CSS multiple times\n nil\n end",
"def show\n\t\traise NotImplementedError, \"FIXME: Implement showing comments.\"\n\tend",
"def info_show\n chosen_baptized_at_home_parish?\n end",
"def show_help\n display banner\n display \"\"\n display short_help\n display \"\"\n end",
"def _filter_display\n @apotomo_emit_raw_view = true\n render :view => '_filters'\n end",
"def show_mix_and_spin_reagents\n show do\n title 'Mix and spin down reagents'\n\n note 'Mix buffer, enzyme, and primer/probes by inversion 5 times.'\n note 'Centrifuge reagents and primers/probes for 5 seconds to collect' \\\n ' contents at the bottom of the tube.'\n note 'Place the tubes on ice or in a cold-block.'\n end\n end",
"def show\n @public_view = true\n page_meta[:workout_description] = @workout.short_description\n page_meta[:user_description] = @workout.user.name\n end",
"def show( observer )\n if observer.can_see? self\n out = \"#{ @name }\\n\" +\n \" #{ @short_description }\\n\\n\" +\n \"[Exits: #{ @exits.select.map(&:to_s).join(\" \") }]\"\n description_data = {extra_show: \"\"}\n Game.instance.fire_event(self, :calculate_room_description, description_data)\n out += description_data[:extra_show]\n else\n out = \"It is pitch black ...\"\n end\n item_list = @inventory.show(observer, true, nil)\n out += \"\\n#{item_list}\" if item_list\n\n visible_occupant_longs = observer.target(list: occupants, not: observer).map{ |t| t.show_short_description(observer) }\n out += \"\\n#{visible_occupant_longs.join(\"\\n\")}\" if visible_occupant_longs.length > 0\n return out\n end",
"def show_make_master_mixes(compositions:, sample_number:)\n show do\n title 'Pipet master mix components'\n\n note 'Pipet the following components into each labeled master mix tube'\n table master_mix_table(\n compositions: compositions,\n sample_number: sample_number\n )\n separator\n\n note 'Pipet the primer/probe mixes into each corresponding' \\\n ' master mix tube'\n table primer_probe_table(\n compositions: compositions,\n sample_number: sample_number\n )\n end\n end",
"def render(promotion = false)\n @highlight = false if promotion\n system(\"clear\")\n puts \" #{build_piece_bank(:white)[0]}\"\n puts \" #{build_piece_bank(:white)[1]}\"\n build_grid.each { |row| puts row.join }\n puts footer\n puts \"Press TAB to choose\".colorize(color: :red) if promotion\n puts \"Press and ENTER to confirm\".colorize(color: :red) if promotion\n @highlight = true\n end",
"def show\n @subprocesses = @order.subprocesses\n @has_leftovers = @order.has_leftovers\n @comment = OrderComment.new\n @modification = Modification.new\n @modifications = @order.modifications\n end",
"def show\n @task = Task.find(params[:id])\n authorize @task\n @strands = @task.strands\n .order(objective_id: :asc) # XXX: hack, should be objective.group\n strand_ids = @strands.map &:id\n @strands_grid = initialize_grid @strands\n strand_ids = @strands.map(&:id)\n # Find applicable Rubrics\n @rubrics = []\n rubric_candidates = Rubric\n .where(\n strand_id: strand_ids,\n rubricable: [[@task], nil]\n )\n strand_ids.each do |sid|\n strand_rubrics = rubric_candidates.select { |r| r.strand_id == sid }\n bands = strand_rubrics.map &:band\n bands.each do |band|\n band_max = strand_rubrics.select { |r| r.band == band }.max_by &:level\n @rubrics += [band_max]\n end\n end\n # TODO: figure out why this hack is necessary\n @rubrics_hack = Rubric.where(id: (@rubrics.map &:id))\n .order(\n strand_id: :asc, # XXX - Hack, should be...\n # strand.objective.group: :asc,\n # strand.number: :asc,\n band: :asc)\n @rubrics_grid = initialize_grid @rubrics_hack\n end",
"def show\n #TODO: this needs to be locked down\n self.not_implemented\n end",
"def find_bins\n render :inline => %{\n <% @content_header_caption = \"'find bins'\"%> \n\n\t\t <%= build_bin_search_form()%>\n },:layout => 'content'\n end",
"def show\n #not needed for our implementation\n end",
"def show\n @booth_chairs = @organization.booth_chairs\n @tools = Tool.checked_out_by_organization(@organization).just_tools\n @shifts = @organization.shifts\n @participants = @organization.participants\n @charges = @organization.charges\n end",
"def show\n @workout_block = @workout_plan.workout_block if @workout_plan\n @program = @workout_block.program if @workout_block\n respond_to do |format|\n format.html { render :template => 'programs/index' }\n format.xml { render :xml => @workout_plan }\n end\n end",
"def cut_fragments grouped_ops \n show {\n title \"Cut Out Fragments\"\n check \"Take out #{grouped_ops.length} 1.5 mL tubes and label accordingly: #{grouped_ops.map { |op| \"#{op.output(\"Fragment\").item}\" }.to_sentence}\"\n check \"Now, cut out the bands and place them into the 1.5 mL tubes according to the following table:\"\n table grouped_ops.start_table \n .custom_column(heading: \"Gel ID\") { |op| \"#{op.input(FRAGMENT).item}\" }\n .custom_column(heading: \"Row\") { |op| op.input(FRAGMENT).row + 1 }\n .custom_column(heading: \"Column\", checkable: true) { |op| op.input(FRAGMENT).column + 1 }\n .custom_column(heading: \"1.5 mL Tube ID\") { |op| \"#{op.output(FRAGMENT_OUT).item}\" }\n .custom_column(heading: \"Length\") { |op| op.output(FRAGMENT_OUT).sample.properties[\"Length\"] }\n .end_table\n }\n end",
"def show\n setup_download_list\n render partial: \"browse_#{view_type}\"\n end",
"def show_result(collection:)\n show do\n title 'Test Plate Setup'\n table highlight_non_empty(collection)\n end\n end",
"def _display(replace)\n\t\treturn @contents._display(replace)\n\tend",
"def show() end",
"def show() end",
"def show() end",
"def human_readable?\n display_component.blank?\n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def display_intro\n # Display Company Logo\n display_logo\n # Display Emergency Information\n display_emergency_info\n end",
"def describe\n base = \"\"\n\n if !described? && respond_to?(:desc)\n self.described = true\n base << desc.to_s\n elsif described? && respond_to?(:short_desc)\n base << short_desc.to_s\n elsif described? && !respond_to?(:short_desc)\n base << desc.to_s\n else\n base << \"I see nothing special\"\n end\n\n if open && !children.empty?\n base << \"<br>\"\n\n if parent.tag == :root\n base << \"You also see:\" + \"<br>\"\n else\n base << \"Inside it you see:\" + \"<br>\"\n end\n\n children.each do |c|\n base << \"#{c.presence}<br>\" if c.presence\n end\n end\n\n puts base\n end",
"def show_erred_operations(failed_ops)\n show do \n title \"Some Operations have failed QC\"\n note \"<b>#{failed_ops.length}</b> Operations have Items that failed QC\"\n note \"The next few pages will show which Operations and Items\n are at fault\"\n end\n\n failed_ops.each do |op, erred_items|\n show do\n title \"Failed Operation and Items\"\n note \"Operation <b>#{op.id}</b> from Plan <b>#{op.plan.id}</b>\"\n erred_items.each do |item|\n note \"Item <b>#{item.id}</b>\"\n end\n end\n end\n end",
"def cvv_help_displayed?\n cvv_help_div.visible?\n end",
"def render\n\t\tprint \"cl1 cl2 cl3 cl4 cl5 cl6 cl7 cl8 cl9 c10\\n\"\n\t\t(0..9).each do |row|\n\t\t\t(0..9).each do |col|\n\t\t\t\tif @grid[row][col].is_flagged\n\t\t\t\t\tprint \"FLG\"\n\t\t\t\telsif @grid[row][col].is_hidden\n\t\t\t\t\tprint \" \"\n\t\t\t\telsif @grid[row][col].surrounding_bombs > 0\n\t\t\t\t\tprint \" #{@grid[row][col].surrounding_bombs} \"\n\t\t\t\telsif @grid[row][col].has_bomb\n\t\t\t\t\tprint \"POW\"\t\t\t\t\t\n\t\t\t\telse print \"xxx\"\n\t\t\t\tend\n\t\t\t\tprint \"|\" unless col == 9\n\t\t\t\tprint \"row#{row + 1}\\n\" if col == 9\n\t\t\tend\n\t\tend\n\tend",
"def display_str\n \"#{objective.code} - #{short_desc}\"\n end",
"def visibilities; end",
"def display_details\n return @selected.details\n end",
"def work_presenter\n @work_presenter||= CurationConcerns::GenericWorkShowPresenter.new(\n SolrDocument.find(work_id),\n Ability.new(nil)\n )\n end",
"def show_partial_for(o)\n \"#{o.class.name.underscore}s/show\"\n end",
"def for_show_action(content, user)\n decorated_content = for_index_action(content, user)\n decorated_content[:genres_data] = @genres_decorator.genres_data(content)\n decorated_content[:personalities_data] = @personality_decorator.personalities_data(content)\n decorated_content[:reviews_collection] = decorated_reviews(content, user)\n decorated_content[:new_review] = build_new_review(content, user)\n decorated_content.merge! subclass_show_data(content, user)\n decorated_content\n end",
"def show_full\n frows = []\n frows << show_headers\n #frows << show_body\n\n return frows\n end",
"def ab_show(_experiment, _identity, _alternative)\n raise \"Not implemented\"\n end",
"def title_comp; end",
"def render_summary\n summary = nil\n\n end",
"def show_includes\n preview_includes\n end",
"def display_header\n self.design.directory_name + ' - ' +\n self.design.board.platform.name + ' / ' + self.design.board.project.name\n end",
"def edit\n if( not @rep )\n UI.beep\n return\n end\n @rep.edit true\n self.show_height\nend",
"def show_previews\n session[:solution] == nil && generate\n load_sections(nil, true)\n end",
"def show_pipet_mmix(primer_mix_name:, volume:, collection:, layout_group:)\n show do\n title \"Pipet #{primer_mix_name} master mix into plate\"\n\n note \"Pipet #{volume} #{MICROLITERS} of #{primer_mix_name}\" \\\n \" master mix into the plate #{collection}\"\n table highlight_collection_rc(collection, layout_group, check: false)\n end\n end",
"def work_presenter\n @work_presenter||= CurationConcerns::GenericWorkShowPresenter.new(\n SolrDocument.find(work_id),\n Ability.new(nil)\n )\n end",
"def view_info\n super\n end",
"def show\n #debugger\n @photos = @listing.photos.order(\"order_priority ASC\")\n @main_photo = Photo.where(listing_id: @listing.id, main_photo: true).first\n if @main_photo \n @main_photo = @main_photo.image_url\n end\n\n @title = \"\"\n @title = \"#{@listing.street_number} \" if @listing.show_street_number\n @title = @title + \"#{@listing.address}, \"\n @title = @title + \"Unit #{@listing.unit_number}, \" unless @listing.unit_number.blank? || [email protected]_unit_number\n @title = @title + \"#{@listing.city_province}\"\n\n end",
"def info_show_baptized_catholic\n chosen_baptized_at_home_parish? # chosen_baptized_catholic? && !baptized_at_home_parish && baptized_catholic\n end",
"def display_featured_works?\n Flipflop.show_featured_works?\n end",
"def do_filtered_plan_display\n filter_plans @arguments.pattern\n\n unless plans.empty?\n frame('Plans') do\n puts build_display_string\n end\n else\n puts stylize(\"{{x}} No plans match #{@arguments.pattern.source}\")\n end\n end",
"def modeler_description\n return 'Replaces exterior window constructions with a different construction from the model.'\n end",
"def output_details(files) \n @stdout.puts\n @stdout.puts \"Details\".bold\n files.each do |t|\n fname = t.path\n @stdout.puts \"File: %s\" % [((t.status == FileData::STATUS_OK) ? fname : fname.red)]\n @stdout.puts \"Includes: %s\" % [format_fds(t.includes)] unless t.includes.empty?\n @stdout.puts \"Included by: %s\" % [format_fds(t.included_by)] unless t.included_by.empty?\n @stdout.puts \"References: %s\" % [format_fds(t.references)] unless t.references.empty?\n @stdout.puts \"Referenced by: %s\" % [format_fds(t.referenced_by)] unless t.referenced_by.empty?\n unless t.status == FileData::STATUS_NOT_FOUND\n # show that part only if file exists\n @stdout.puts \"Size: %s (%d)\" % [format_size(t.size),t.size]\n if (t.docbook)\n @stdout.puts \"Type: DocBook, Version #{t.version}, Tag: #{t.tag}\"\n else\n @stdout.puts \"MIME: #{val_s(t.mime)}\"\n end\n @stdout.puts \"Timestamp: %s\" % [t.ts]\n @stdout.puts \"SHA1: %s\" % [t.checksum]\n end\n @stdout.puts \"Error: %s\" % [t.error_string.to_s.red] unless (t.error_string.nil?) \n @stdout.puts\n end\n end",
"def inspect\n\t\tparts = []\n\t\tparts << self.one_of_description\n\t\tparts << self.all_of_description\n\t\tparts << self.none_of_description\n\t\tparts.compact!\n\n\t\tstr = \"#<%p:%#0x matching entities\" % [ self.class, self.object_id * 2 ]\n\t\tif parts.empty?\n\t\t\tstr << \" with any components\"\n\t\telse\n\t\t\tstr << parts.join( ', ' )\n\t\tend\n\t\tstr << \">\"\n\n\t\treturn str\n\tend",
"def display_featured_researcher?\n Flipflop.show_featured_researcher?\n end",
"def show\n update_and_decorate\n smartrender\n end",
"def ab_showing(_experiment, _identity)\n raise \"Not implemented\"\n end",
"def show\n\t\t#show now run by find_book and before_action\n\t\t#keeps code dry\n\tend",
"def show\n initialize_tabs\n @mycometer_coc_sample = MycometerCocSample.new \n @sample_number = @mycometer_coc.job.jobsite[:street].split[0] + \"-\" + (@mycometer_coc.mycometer_coc_samples.length + 1).to_s\n\n end",
"def show_qualified\n pp ordered_by_qualifications\nend",
"def presents(_obj)\n raise NotImplementedError\n end",
"def long_desc\n desc = \"\" << super << \"\\r\\n#{self.pronoun.capitalize} is holding \"\n desc << @inventory.show << \".\\r\\n\" << @equipment.show(self)\n\n return desc\n end"
] | [
"0.5758615",
"0.56742543",
"0.56047547",
"0.55751497",
"0.5482914",
"0.5413041",
"0.53686714",
"0.5345104",
"0.534279",
"0.53310424",
"0.5324569",
"0.53068936",
"0.5306546",
"0.53005964",
"0.525008",
"0.52456075",
"0.52089113",
"0.5192857",
"0.51906866",
"0.5184041",
"0.5171527",
"0.51669276",
"0.5166441",
"0.51577693",
"0.5157397",
"0.515506",
"0.51547563",
"0.5148127",
"0.51285577",
"0.51151586",
"0.51001805",
"0.50918555",
"0.50906605",
"0.5088018",
"0.5086774",
"0.5085779",
"0.5081538",
"0.50778514",
"0.5076655",
"0.5075537",
"0.5075289",
"0.50697577",
"0.5062299",
"0.5060394",
"0.5059098",
"0.505887",
"0.5053955",
"0.5046795",
"0.50437427",
"0.5039882",
"0.50359774",
"0.5031052",
"0.5031052",
"0.5031052",
"0.5007684",
"0.50043905",
"0.50043905",
"0.50043905",
"0.50043905",
"0.50043905",
"0.50043905",
"0.50043905",
"0.50043905",
"0.50043905",
"0.49943727",
"0.49901748",
"0.4985442",
"0.49840778",
"0.49764243",
"0.4975417",
"0.4969391",
"0.4966865",
"0.4965491",
"0.4962097",
"0.49616203",
"0.4958551",
"0.4947975",
"0.49427336",
"0.49424267",
"0.49413243",
"0.4940766",
"0.49375573",
"0.49371555",
"0.4931299",
"0.4930584",
"0.49288797",
"0.49252802",
"0.49221584",
"0.49122092",
"0.4906021",
"0.49050173",
"0.49041784",
"0.4903492",
"0.49032262",
"0.4902442",
"0.489669",
"0.48898476",
"0.48895195",
"0.4884497",
"0.48780167",
"0.48775733"
] | 0.0 | -1 |
should remove the current single role (set = nil) only if it is contained in the list of roles to be removed | def remove_roles *role_names
role_names = role_names.flat_uniq
set_empty_roles and return if roles_diff(role_names).empty?
roles_to_remove = select_valid_roles(role_names)
set_roles roles_diff(role_names)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_role(role)\n role_obj = Role.find_by_name(role)\n roles.delete(role_obj) unless role_obj.nil?\n roles\n end",
"def remove_role (role_in)\n Rails.logger.debug (\"#{self.class}.remove_role(#{role_in.to_s}) - #{self.username.to_s} \")\n cur_roles = to_array_if_not(self.roles)\n role_at = (cur_roles).index(role_in)\n if role_at != nil\n cur_roles.delete_at(role_at)\n self.roles = cur_roles.join(' ')\n true\n else\n false\n end\n end",
"def remove_role (role_name=nil)\n self.update_attribute(:role_id,nil) unless !self.role ||(role_name && role_name.to_s != self.role.name)\n end",
"def remove_role (role_name=nil)\n self.update_attribute(:role_id,nil) unless !self.role ||(role_name && role_name.to_s != self.role.name)\n end",
"def delete_role_if_present(role)\n @roles.delete(role.name) if @roles\n end",
"def removerole(userrole)\n userrole.delete if userroles.count > 1\n end",
"def remove_role(role)\n roles.delete(role)\n end",
"def remove_role!(role_name)\n role = Role.find_by_name!(role_name.to_s)\n self.roles.delete(role) if self.roles.include?(role)\n end",
"def remove_roles *roles\n roles = roles.flatten.compact\n return nil if roles_diff(roles).empty?\n roles_to_remove = select_valid_roles(roles)\n self.roles = self.roles - roles_to_remove\n true\n end",
"def remove_role _role\n if _role.is_a?(Array)\n update!(roles: roles - _role.map{|a| a.to_sym })\n else\n update!(roles: roles - [_role.to_sym])\n end\n end",
"def delrole(event, role)\n if @assignable_roles.include? role then\n if event.message.author.roles.find {|r| r.name == role}\n event.message.author.remove_role get_role(event, role)\n event.send_message(\"alright hun, #{role} removed\")\n else\n event.send_message(\"i don't see that role, you sure have an imagination sometimes, hun\")\n end\n else\n if event.message.author.roles.find {|r| r.name == role}\n event.send_message(\"only big kids can touch that role, cutie pie\")\n else\n event.send_message(\"tsk tsk tsk!\")\n end\n end\n end",
"def remove_roles(roles)\n return self.roles = (self.roles - Array(roles))\n end",
"def remove_roles *role_names\n roles = role_names.flat_uniq\n set_empty_role if roles_diff(roles).empty?\n true\n end",
"def remove_role(role)\n self.roles.destroy(role)\n end",
"def remove_role(role)\n self.roles.destroy(role)\n end",
"def remove_role(role_name)\n return false unless User.roles.keys.include?(role_name)\n r = User.roles[role_name]\n self.role ^= (1 << r)\n self.save\n end",
"def remove_role\n if @user.has_role? params[:role]\n @user.remove_role params[:role]\n render json: { :success => 'role successfully removed' } \n else \n render json: { :success => 'The user does not have this role' }\n end\n end",
"def remove_role(index)\n role = @roles.delete_at(index)\n if role && role.role\n Role.delete_role(role.role.role_id)\n else\n raise \"Bad role index #{role_index}\"\n end\n end",
"def delete_role(role)\n res1 = remove_filtered_grouping_policy(1, role)\n res2 = remove_filtered_policy(0, role)\n res1 || res2\n end",
"def bot_delrole(event, role=nil)\n if role.nil?\n event.send_message <<-MESSAGE\n the roles i'll let you remove are #{@assignable_roles.to_a.join \", \"}\n MESSAGE\n else\n delrole(event, role)\n end\n end",
"def delete_standard_roles_from_user\n standard_roles = []\n [\"staff\", \"student\", \"guest\"].each {|r| standard_roles << Role.find_or_initialize_by_name(r) } \n\n self.roles.each do |role|\n if standard_roles.include?(role)\n #delete the role\n self.roles.delete(role)\n end\n end\t\t\n end",
"def remove!(role)\n role_id = get!(role).id\n\n roles[role_id][:children].each do |child_id, child|\n roles[child_id][:parents].delete(role_id)\n end\n\n roles[role_id][:parents].each do |parent_id, parent|\n roles[parent_id][:children][role_id]\n end\n\n roles.delete(role_id)\n\n self\n end",
"def delete(role:, type:)\n\t\t\t\t\tconnection.post(build_path('removeRoles'), nil, roleNames: [role].flatten.join(','),\n\t\t\t\t\t\ttype: type).code == '200'\n\t\t\t\tend",
"def revoke_role(role)\n self.roles.delete(role) if roles\n end",
"def unassign_role(role, context=nil, force_context=nil)\n auth_scope do\n context = Zuul::Context.parse(context)\n target = target_role(role, context, force_context)\n return false if target.nil?\n\n assigned_role = role_subject_for(target, context)\n return false if assigned_role.nil?\n return assigned_role.destroy\n end\n end",
"def remove_role\n Ops::Member::RemoveRole.call(user: @user, role: params[:role], size: @user.roles.size)\n redirect_to dashboard_user_url(@user),\n flash: { success: \"#{params[:role].capitalize} #{t('dashboard.users.notices.remove_role')}\" }\n end",
"def remove_roles(*values)\n self.roles = roles - values.map(&:to_s)\n end",
"def remove\n `cd #{self.project_root} && rm -r puppet/roles/#{self.name}`\n end",
"def remove_user_from_role(role_id)\n # subject = Subject.find(preallowed_id)\n role = Role.find(role_id)\n\n # put :remove_subject, :id => role.id, :subject_id => @subject.id, :client_id => @subject.client.id\n res = role.put(:remove_subject, :id => role.id, :subject_id => preallowed_id, :client_id => CLIENT_ID)\n \n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n logger.debug \"successfully removed preallowed_user from role\"\n return true\n else\n logger.error \"error removing preallowed_user from role\" \n return false\n end\n end",
"def remove_role(role)\n make_call(NO_TIMEOUT, RETRY_ON_FAIL, \"remove_role\") { @conn.remove_role(role, @secret) }\n end",
"def remove_rolegroups *the_rolegroups\n group_store.set_rolegroups (rolegroup_list - the_rolegroups.to_symbols_uniq)\n end",
"def clear_role!\n store.clear!\n end",
"def purge_roles \n xml=self.roleMetadata.ng_xml\n nodes = xml.search('/roleMetadata/role')\n nodes.each do |node|\n node.remove\n end\n end",
"def delete_role\n role = Role.find(params[:role_id])\n\n # Make sure no users are assigned to the role and the role isn't a reserved role\n # before deleting\n if role.users.count.positive?\n flash[:alert] = I18n.t(\"administrator.roles.role_has_users\", user_count: role.users.count)\n return redirect_to admin_roles_path(selected_role: role.id)\n elsif Role::RESERVED_ROLE_NAMES.include?(role) || role.provider != @user_domain ||\n role.priority <= current_user.role.priority\n return redirect_to admin_roles_path(selected_role: role.id)\n else\n role.role_permissions.delete_all\n role.delete\n end\n\n redirect_to admin_roles_path\n end",
"def delete(role)\n @role_array.delete(role.to_s.intern)\n end",
"def take_role(name)\n r = self.roles.find_by_name(name)\n r.destroy unless r.nil?\n save(false)\n end",
"def withdraw_role role\n self.roles.delete role\n end",
"def destroy\n chef_server_rest.delete(\"roles/#{@name}\")\n end",
"def remove_right\n role = Role.find(params[:role_id])\n\tright = Right.find(params[:id])\n\trole.rights.delete(right)\n\tredirect_to roles_rights_url\n end",
"def remove_roles_from_admin group\n group.roles.each do |role|\n if admin_roles.map(&:role).include?(role) and not role_in_groups?(role.name)\n admin_roles.find_by_role_id(role.id).destroy\n end\n end\n end",
"def remove_role(role)\n return ServiceContract.error('Role must be a symbol') if role.class.name.to_sym != :Symbol\n\n return ServiceContract.error(\"Role type '#{role}' is not available.\") unless Role.valid_role?(role)\n\n role = Role.find_by_slug(role)\n if user_roles.where(role: role).destroy_all\n ServiceContract.success(nil)\n else\n ServiceContract.error(\"Could not destroy #{role}\")\n end\n end",
"def destroy\n id=params[:id]\n @role = Role.find(params[:id])\n if id.to_a.include?(self.current_user.role_id.to_s)\n flash[:error] = \"不能删除自身角色\"\n redirect_to :action => 'index'\n elsif @role.role_name == \"admin\"\n flash[:error] = \"不能删除缺省角色\"\n redirect_to :action => 'index'\n elsif @role.destroy\n flash[:notice] = \"删除成功\"\n redirect_to :action => 'index'\n else\n flash[:error] =\"删除失败,该角色正在被引用,请先删除该角色的用户。\"\n redirect_to :action => 'index'\n end\n end",
"def remove_from_subject(subject)\n res = subject.put(:remove_role, :id => subject.id, :role_id => self.id, :client_id => CLIENT_ID)\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n return true\n else\n return false\n end\n end",
"def revoke_roles_permitted?(role)\n revoke_roles_permitted.include?(role)\n end",
"def retract\n # Delete from the constellation first, so it can remember our identifying role values\n @constellation.__retract(self) if @constellation\n\n # Now, for all roles (from this class and all supertypes), assign nil to all functional roles\n # The counterpart roles get cleared automatically.\n ([self.class]+self.class.supertypes_transitive).each do |klass|\n klass.roles.each do |role_name, role|\n next if role.unary?\n next if !role.unique\n\n counterpart = role.counterpart\n puts \"Nullifying mandatory role #{role.name} of #{role.owner.name}\" if counterpart.mandatory\n\n send \"#{role.name}=\", nil\n end\n end\n end",
"def remove_member_role(auth, server_id, user_id, role_id, reason = nil)\n MijDiscord::Core::API.request(\n :guilds_sid_members_uid_roles_rid,\n server_id,\n :delete,\n \"#{MijDiscord::Core::API::APIBASE_URL}/guilds/#{server_id}/members/#{user_id}/roles/#{role_id}\",\n Authorization: auth,\n 'X-Audit-Log-Reason': reason\n )\n end",
"def destroy\n @role = Role.find(params[:id])\n \n @users = User.find_by_role_id(@role.id)\n respond_to do |format|\n if @users == nil\n @role.destroy\n format.html { redirect_to roles_url, :notice => t(:role_deleted) }\n format.json { head :no_content }\n else\n format.html { redirect_to roles_url, :alert => t(:role_inuse) }\n format.json { head :no_content }\n end\n end\n end",
"def delete_role(name)\n client.delete(\"/v1/auth/approle/role/#{encode_path(name)}\")\n return true\n end",
"def destroy\n @screen = session.active_screen\n \n @role = Role.find(params[:id])\n\n ActiveRecord::Base.transaction do\n @role.destroy\n end\n end",
"def destroy\n @role.destroy\n\n redirect_to roles_path\n end",
"def unassign(role:, type:, rsuser:)\n\t\t\t\t\tconnection.post(build_path('unassignRole'), nil, roleName: role, type: type, sid: rsuser).\n\t\t\t\t\t\tcode == '200'\n\t\t\t\tend",
"def destroy\n if !grant_access(\"alter_roles\", current_user)\n head(403)\n end\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def set_role(role_name, value)\n if value == \"1\"\n for role in self.roles\n if role.name == role_name\n return\n end\n end\n r = Role.find(:first, :conditions => ['name =?', role_name])\n self.roles.push(r)\n else\n for role in self.roles\n if role.name == role_name\n self.roles.delete(role)\n return\n end\n end\n end\n end",
"def destroy\n @user = User.find(params[:user_id])\n @role = Role.find(params[:id])\n if @user.has_role?(@role.name)\n @user.roles.delete(@role)\n end\n respond_to do |format|\n format.html {redirect_to :action => 'index' }\n format.xml { head :ok }\n end\n \n end",
"def remove_role_action(external_user, service_id, role)\n rc = @srv_pool.get(service_id, external_user) do |service|\n unless service.running?\n break OpenNebula::Error.new(\n \"Cannot modify roles in state: #{service.state_str}\"\n )\n end\n\n unless service.roles[role]\n break OpenNebula::Error.new(\"Role #{role} does not exist\")\n end\n\n remove_role(external_user, service, service.roles[role])\n end\n\n Log.error LOG_COMP, rc.message if OpenNebula.is_error?(rc)\n\n rc\n end",
"def delete_role_and_associated_nodes\n search_glob = \"#{self.role_name}*\"\n skip_list = Array(self.node_name)\n\n puts \"deleting role with name = '#{search_glob}'\"\n ::Chef::Search::Query\n .new\n .search('role', \"name:#{search_glob}\")\n .first\n .reject { |role| skip_list.include?(role.name)}\n .each { |role| puts role.as_json; role.destroy }\n puts \"deleted role with name = '#{search_glob}'\"\n\n puts \"deleting node with role = '#{search_glob}'\"\n ::Chef::Search::Query\n .new\n .search('node', \"role:#{search_glob}\")\n .first\n .reject { |node| skip_list.any? { |item| node.run_list.include?(item) } }\n .each { |node| puts node['hostname']; node.destroy }\n puts \"deleted node with role = '#{search_glob}'\"\n end",
"def remove_profile_from_role\n profileId = params[:profile_id]\n roleId = params[:role_id]\n # find the roles_permission based on the Params\n rp = ProfileRole.where(:role_id => roleId, :profile_id => profileId).first\n rp.destroy\n response = Hash.new\n response[:success] = rp.destroyed?\n response[:role_id] = roleId\n response[:profile_id] = profileId\n respond_to do |format|\n format.json {\n render json: response\n }\n end\n end",
"def clear_user_role_cache\n user&.clear_role_names!\n end",
"def has_no_role( role_name )\n role_name = role_name.to_s\n role = get_role( role_name )\n delete_role( role )\n end",
"def delete_role\n\t\t@role = Role.find(params[:id])\n\n\t\tif @role.destroy\n\t\t\tredirect_to \"/details\"\n\t\telse\n\t\t\treder :action => \"delete_role\"\n\t\tend\n\tend",
"def replace_roles(role_names)\n removals = []\n for role in self.roles do\n if !role_names.include?(role.name)\n removals << role \n else\n role_names.delete(role.name)\n end\n end\n self.roles = self.roles - removals\n # all that's left in role_names now is the names of roles to add\n for role_name in role_names do\n add_role(role_name) unless role_name == ''\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n if @role && @role.destroy\n redirect_to dashboard_vendor_vendor_roles_path(@vendor), notice: 'User successfully removed.'\n else\n redirect_to dashboard_vendor_vendor_roles_path(@vendor)\n end\n end",
"def remove_member\n @team = Team.find(params[:id])\n authorize @team, :update?\n\n @user = User.find(params[:user_id])\n @user.remove_role :member, @team\n\n respond_to do |format|\n format.html { redirect_to @team, notice: 'User was successfully removed as member.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role = @client.roles.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n flash[:notice] = 'Role was successfully removed.' \n format.html { redirect_to(client_roles_url(@client)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_role = UserRole.find(params[:id])\n @user_role.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_user_roles_url) }\n end\n end",
"def delete_roles_from_role_context_by_uid(context_name, role_context_remove_role_model, uid)\n if isNullOrWhiteSpace(context_name)\n raise LoginRadius::Error.new, getValidationMessage('context_name')\n end\n if role_context_remove_role_model.blank?\n raise LoginRadius::Error.new, getValidationMessage('role_context_remove_role_model')\n end\n if isNullOrWhiteSpace(uid)\n raise LoginRadius::Error.new, getValidationMessage('uid')\n end\n\n query_parameters = {}\n query_parameters['apiKey'] = @api_key\n query_parameters['apiSecret'] = @api_secret\n\n resource_path = 'identity/v2/manage/account/' + uid + '/rolecontext/' + context_name + '/role'\n delete_request(resource_path, query_parameters, role_context_remove_role_model)\n end",
"def delete_unused_members\n if !member.nil? && !member.is_a?(User) and \nmember.roles(:true).empty?\n member.destroy\n end\n end",
"def role?(role)\n !(roles.map(&:name) & Array(role)).empty?\n end",
"def destroy\n @rolid = params[:id]\n Role.destroy(@rolid)\n end",
"def destroy\n\n @role.stop_user_id = session[:user_id]\n @role.stoped_at = DateTime.now\n @role.state = \"N\"\n @role.save\n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n super\n # if resource.destroy\n # @rolesuser = @Rolesuser.find_all_by_user_id(resource.id)\n # @rolesuser.each do |rolesuser|\n # rolesuser.destroy\n # end\n # end\n end",
"def destroy\n team_members = User.with_role :member, @team\n team_members.each do |member|\n member.remove_role :member, @team\n member.remove_role :team_owner, @team\n end\n @team.destroy\n redirect_to teams_url, notice: 'Team was successfully destroyed.'\n end",
"def remove_admin\n @team = Team.find(params[:id])\n authorize @team, :update?\n\n @user = User.find(params[:user_id])\n @user.remove_role :admin, @team\n\n respond_to do |format|\n format.html { redirect_to @team, notice: 'User was successfully removed as admin.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n \n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end",
"def mate_roles_of(rolekey)\n roles.dup.tap do |roles|\n roles.delete(rolekey)\n end\n end",
"def after_remove_role(role)\n role.send(:record_destroy).tap do\n last_version = role.versions.last\n update_role_version_attributes(last_version, role) if last_version.event == 'destroy'\n end if PaperTrail.enabled? && Role.paper_trail_enabled_for_model?\n end",
"def check_role(role_name)\n role = Role.find_by_name(role_name)\n unless roles.include?(role)\n roles << role\n end\n end",
"def remove_role_from_project\n @project_role = ProjectRole.find(params[:id])\n @project_role.destroy\n\n respond_to do |format|\n format.html { redirect_to assign_roles_project_path(@project_role.project) , notice: 'New project role was successfully added.' }\n end\n end",
"def destroy \r\n @role = Role.find(params[:id])\r\n if @role.destroy\r\n msg= \"Role deleted successfully!\"\r\n else\r\n msg= \"Role delete failed!\"\r\n end\r\n redirect_to roles_path, :flash => { :notice => msg }\r\n end",
"def remove_role_assignments_from_group_members_if_needed\n return unless entity.type == 'Group'\n\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n entity.members.each do |m|\n logger.info \"Removing role (#{role.id}, #{role.token}, #{role.application.name}) about to be removed from group (#{entity.id}/#{entity.name} from its member #{m.id}/#{m.name})\"\n ra = RoleAssignment.find_by_role_id_and_entity_id_and_parent_id(role.id, m.id, self.id)\n if ra\n ra.destroy!\n else\n logger.warn \"Failed to remove role (#{role.id}, #{role.token}, #{role.application.name}) assigned to group member (#{m.id}/#{m.name}) which needs to be removed as the group (#{entity.id}/#{entity.name}) is losing that role.\"\n end\n end\n end\n end",
"def remove c\n if components.summands.any? {|list| list.delete(c)}\n raise unless c.world == self\n c.__set__world(nil)\n else\n raise \"Tried to remove #{c} from #{self}, but its world is #{c.world}.\"\n end\n end",
"def destroy\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n\n\n @correo = Correo.find(params[:id])\n @correo.destroy\n\nelse\n @correo = Correo.find(params[:id])\n flash[:error] ='No tienes permiso para realizar esta accion'\n redirect_to \"/correos/#{@correo.id}/edit/\"\n return\nend\n\n\n\n respond_to do |format|\n format.html { redirect_to \"/correos\", notice: 'correo was successfully deleted.' }\n format.json { head :ok }\n end\n end",
"def remove_guild_member_role(guild_id, user_id, role_id, reason: nil)\n request(\n :guilds_gid_members_uid_roles_rid, guild_id,\n :delete,\n \"guilds/#{guild_id}/members/#{user_id}/roles/#{role_id}\",\n nil,\n 'X-Audit-Log-Reason': reason,\n )\n end",
"def remove_role_assignments_from_group_members_if_needed\n if entity.type == 'Group'\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n # Tell trigger_sync! to ignore any requests it receives - we'll just put in one\n # sync request after all the new RoleAssignments exist.\n Thread.current[:will_sync_role] = [] unless Thread.current[:will_sync_role]\n Thread.current[:will_sync_role] << role.id\n \n entity.members.each do |m|\n logger.info \"Removing role (#{role.id}, #{role.token}, #{role.application.name}) about to be removed from group (#{entity.id}/#{entity.name} from its member #{m.id}/#{m.name})\"\n ra = RoleAssignment.find_by_role_id_and_entity_id_and_parent_id(role.id, m.id, entity.id)\n if ra\n destroying_calculated_role_assignment do\n ra.destroy\n end\n else\n logger.warn \"Failed to remove role (#{role.id}, #{role.token}, #{role.application.name}) assigned to group member (#{m.id}/#{m.name}) which needs to be removed as the group (#{entity.id}/#{entity.name}) is losing that role.\"\n end\n end\n \n Thread.current[:will_sync_role].delete(role.id)\n role.trigger_sync!\n end\n end\n end",
"def unassign_role\n\t\[email protected]_id = Role.get_user_id\n\t\[email protected]_id = nil\n\t\[email protected]\n\t\tredirect_to :administrations\n\tend",
"def destroy\n ActiveRecord::Base.transaction do\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to(roles_url) }\n format.xml { head :ok }\n end\n end\n end",
"def destroy\n @role.destroy\n\n flash[:notice] = \"Role successfully destroyed.\"\n\n redirect_to roles_path\n end",
"def clear\n @role_array.clear\n end",
"def assignrole(role)\n roles << role unless roles.exists?(role)\n end",
"def destroy\n return unless check_permission\n\n @role.destroy\n respond_to do |format|\n format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' }\n end\n end",
"def delete_role(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'DeleteRole'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :role_name\n\t\t\targs[:query]['RoleName'] = optional[:role_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def destroy\n @security_role = Security::Role.find_by(id: @security_role_menu.security_role.id)\n @security_role.update(:user_updated_id => current_user.id)\n @security_role_menu.destroy\n respond_to do |format|\n format.html { redirect_to security_role_menus_url, notice: 'Menú eliminado exitosamente para este rol.' }\n format.json { head :no_content }\n format.js { render :layout => false }\n end\n end",
"def destroy\n\n\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n @role_permision = RolePermision.find(params[:id])\n @role_permision.destroy\nelse\n flash[:error] ='No tienes permiso para realizar esta accion'\n\nend\n \n \n\n respond_to do |format|\n format.html { redirect_to role_permisions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n \n @ultimo_grado_de_estudio = UltimoGradoDeEstudio.find(params[:id])\n @ultimo_grado_de_estudio.destroy\n\nelse\n flash[:error] ='No tienes permiso para realizar esta accion'\n\nend\n\n\n respond_to do |format|\n format.html { redirect_to ultimo_grado_de_estudios_url }\n format.json { head :ok }\n end\n end",
"def destroy\n\n\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n \n \n @rpm = Rpm.find(params[:id])\n @rpm.destroy\nelse\n flash[:error] ='No tienes permiso para realizar esta accion'\n\nend\n\n respond_to do |format|\n format.html { redirect_to rpms_url }\n format.json { head :ok }\n end\n end",
"def destroy\n\n\nrol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"ACRM\"\n\n \n @mercado_metum = MercadoMetum.find(params[:id])\n @mercado_metum.destroy\nelse\n flash[:error] ='No tienes permiso para realizar esta accion'\n\nend\n \n\n respond_to do |format|\n format.html { redirect_to mercado_meta_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @role = Role.find(params[:id])\n @role.destroy\n\n respond_to do |format|\n format.html { redirect_to roles_url }\n format.json { head :no_content }\n end\n end",
"def undo_update\n # CreateDefaultRoles.where(:type_code => 'very_shiny').first.delete\n end",
"def test_has_role_and_unset\n new_session do |test|\n david = test.login :david\n test.controller 'object_roles' do\n test.cannot_access 'moderate_meeting'\n david.has_role 'moderator'\n test.cannot_access 'moderate_meeting'\n david.has_role 'moderator', Meeting\n david.has_no_role 'moderator', Meeting\n test.cannot_access 'moderate_meeting'\n\n test.cannot_access 'group_members'\n david.has_role 'site_admin'\n test.can_access 'group_members'\n david.has_no_role 'site_admin'\n test.cannot_access 'group_members'\n\n hacker = Role.find_by_name('hacker')\n Role.delete(hacker.id) if hacker\n assert Role.find_by_name('hacker').nil?\n david.has_role 'hacker'\n assert !Role.find_by_name('hacker').nil?\n david.has_role 'hacker'\n assert !Role.find_by_name('hacker').nil? # Removing a role for a user shouldn't delete the actual Role record\n end\n end\n end",
"def destroy\n @team_roleset = TeamRoleset.find(params[:id])\n rolesets_in_map = TeamRolesetsMap.find_all_by_team_rolesets_id(params[:id])\n\n rolesets_in_map.each do |x|\n x.destroy\n end\n\n @team_roleset.destroy\n\n respond_to do |format|\n format.html { redirect_to(team_rolesets_url) }\n format.xml { head :ok }\n end\n end"
] | [
"0.7705658",
"0.7692161",
"0.7629407",
"0.7629407",
"0.7472426",
"0.7464963",
"0.742721",
"0.74058014",
"0.73950243",
"0.7291196",
"0.72170496",
"0.7170516",
"0.7122717",
"0.709785",
"0.709785",
"0.6998709",
"0.69846267",
"0.6929257",
"0.6921377",
"0.691297",
"0.68795323",
"0.6874576",
"0.682777",
"0.6796504",
"0.6785556",
"0.6673525",
"0.6599652",
"0.65850544",
"0.6563177",
"0.65551317",
"0.648948",
"0.6484807",
"0.6462409",
"0.6447456",
"0.6443608",
"0.64379597",
"0.64337265",
"0.6427169",
"0.6333699",
"0.63267905",
"0.6290223",
"0.62716806",
"0.6261201",
"0.62554705",
"0.6244349",
"0.62413406",
"0.6233729",
"0.6225153",
"0.61978275",
"0.61877656",
"0.61801535",
"0.6155463",
"0.61437106",
"0.61336493",
"0.6131456",
"0.6126673",
"0.6089371",
"0.6069056",
"0.6060093",
"0.60389215",
"0.6036166",
"0.6030279",
"0.5968869",
"0.59538245",
"0.5952788",
"0.59357995",
"0.59352225",
"0.590088",
"0.5898622",
"0.58969533",
"0.58818567",
"0.586336",
"0.5858546",
"0.5855904",
"0.5851852",
"0.58485115",
"0.5845894",
"0.58444077",
"0.5842944",
"0.5842645",
"0.584007",
"0.583248",
"0.58238316",
"0.5817697",
"0.5804778",
"0.57890564",
"0.5787304",
"0.5787175",
"0.5781311",
"0.5769774",
"0.5764465",
"0.5759638",
"0.5755395",
"0.57552826",
"0.57449245",
"0.5741663",
"0.5739015",
"0.57365865",
"0.573465",
"0.5732435"
] | 0.7080716 | 15 |
Defines the path, file or content of the csv file. Also allows you to overwrite the configuration at runtime. Example: .new(file: my_csv_file) .new(path: "subscribers.csv", model: newsletter.subscribers) | def initialize(*args, &block)
@csv = CSVReader.new(*args)
@config = self.class.config.dup
@config.attributes = args.last
@report = Report.new
Configurator.new(@config).instance_exec(&block) if block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_csv_file\n \t@csv_file = CsvFile.find(params[:id])\n end",
"def csv_filename\n raise NotImplementedError\n end",
"def initialize(csv_file_path)\n # take recipe from csv file\n @csv_file_path = csv_file_path\n @recipes = []\n parse\n end",
"def initialize(csv, importer)\n @source_csv = CSV.read(csv, headers: true)\n @is_for_bulkrax = importer == 'bulkrax'\n @fileset_model_or_type = @is_for_bulkrax ? 'FileSet' : 'fileset'\n directory = File.dirname(csv)\n extension = File.extname(csv)\n filename = File.basename(csv, extension)\n @processed_csv = File.join(directory, filename + \"-processed.csv\")\n @merged_headers = exclusion_guard(additional_headers + @source_csv.headers)\n @tree = {}\n end",
"def file=(value)\n @file = value\n csv\n @file\n end",
"def csv=(klass); end",
"def initialize(csv_source)\n @csv_source = csv_source\n end",
"def initialize( record, column, filename, options = {} )\n @record = record\n @model = record.class\n @column = column.to_sym\n @filename = filename\n settings.merge! options\n end",
"def initialize(csv_file) # csv_fi\n @csv_file = csv_file # we store it in a variable in case it's added later\n @recipes = []\n read_recipe_from_csv_file\n end",
"def initialize(csv_filename)\n LOGGER.info 'Konvertierung Commerzbank .csv-Kontoauszugsdatei ins Format .mt940 (SWIFT):'\n\n @csv_filename = csv_filename\n end",
"def load_csv(csv_file_or_object, table_name, log_name = nil)\n log_name ||= \"load_csv '#{csv_file_or_object.kind_of?(CSV::Table) ? 'CSV Object' : csv_file_or_object }', 'table_name'\"\n csv_object = case csv_file_or_object\n when String then Slacker.get_csv(csv_file_or_object)\n when CSV::Table then csv_file_or_object\n when Array then Slacker.hash_array_to_csv(csv_file_or_object)\n end\n\n Slacker.load_csv(example, csv_object, table_name, log_name)\n end",
"def touch_csv(csv_file_or_object, fields, field_generators = {})\n Slacker.touch_csv(csv_file_or_object, fields, field_generators)\n end",
"def initialize(csv_class_path)\n @path = csv_class_path\n @recipes = CSV.open(@path).map do |row|\n Recipe.new(name: row[0], ingredients: row[1], prep_time: row[2], difficulty: row[3])\n end\n end",
"def initialize(str,file = true)\n if file\n @data = CSV.read(str)\n else\n @data = CSV.parse(str) \n end\n parse\n end",
"def csv_file_path\n @csv_file_path ||= File.join(\n task_config[\"export_folder\"],\n task_config[\"file_name\"].downcase\n )\n end",
"def initialize\n @meals = []\n @csv_file = File.join(File.dirname(__FILE__), '..','..','data','meal.csv')\n load\n end",
"def csv(csv_file)\n Slacker.get_csv(csv_file)\n end",
"def initialize(instructions_csv=\"instructions.csv\", format)\n\t\t\t#check for errors in parameters\n\t\t\traise \"instructions_csv must not be null\" unless !instructions_csv.nil?\n\t\t\traise \"#{instructiosn_csv} is not a readable file\" unless File.exist?(instructions_csv) and File.readable?(instructions_csv)\n\t\t\t#assign parameters to object variables\n\t\t\t@instructions_csv = instructions_csv\n\t\t\t#format can be 'a' for assembly or 'b' for binary\n\t\t\t@format = format\n\t\tend",
"def seed_model(model_class, options={})\n if model_class.count == 0 or options[:force]\n puts \"Seeding #{model_class.to_s.pluralize}...\"\n file_name = options[:file_name] || \"#{model_class.table_name}.csv\"\n file_path = options[:file_path] || 'db/csv'\n csv_file = @@csv_class.open(File.join(Rails.root, file_path, file_name), :headers => true)\n seed_from_csv(model_class, csv_file)\n end\n end",
"def csv\n @csv_table ||= begin\n csv_raw = File.read(CSV_PATH)\n CSV.parse(csv_raw, headers: true)\n end\n\nend",
"def csv_import_path\n File.join(ENV['IMPORT_PATH'], 'csv', self.id.to_s)\n end",
"def csv(options={})\n get_location\n # TODO: validate options\n @params[:csv] = FEATURE_DEFAULTS[:csv].merge(options)\n @params[:csv][:generate] = true\n end",
"def post_csv(path, csv)\n file = Tempfile.new(['dotmailer-contacts', '.csv'])\n file.write csv\n file.rewind\n\n post path, :csv => file\n end",
"def initialize(args)\n @creator_csv = CSV.read(args[:creator_csv_path])\n @title_csv = CSV.read(args[:title_csv_path])\n @contributor_csv = CSV.read(args[:contributor_csv_path])\n @logger = Logger.new(File.join(Rails.root, 'log', 'ordered-metadata-migration.log'))\n end",
"def seed_from_csv(migration_class, csv_file)\n migration_class.transaction do\n csv_file.each do |line_values|\n record = migration_class.new\n line_values.to_hash.keys.map do |attribute|\n record.send(\"#{attribute.strip}=\",line_values[attribute].strip) rescue nil\n end\n record.save(:validate => false)\n end\n end\n end",
"def initialize_csv\n CSV.open(\"results.csv\", \"wb\") do |csv|\n csv << [\"class\", \"title of course\", \"credits\"]\n end\nend",
"def set_csv_import\n @csv_import = CsvImport.find(params[:id])\n end",
"def parse_csv(path)\n require 'csv'\n\n str = Nitro::Template.new.render(File.read(path))\n\n reader = CSV::Reader.create(str)\n header = reader.shift\n\n reader.each_with_index do |row, i|\n data = {}\n row.each_with_index do |cell, j|\n data[header[j].to_s.strip] = cell.to_s.strip\n end\n self[\"#{@name}_#{i+1}\"] = obj = instantiate(data)\n @objects << obj\n end\n end",
"def initialize(database, file_path)\n @file_path = file_path\n @entries = database.entries\n validate_csv_header\n end",
"def initialize(path, normalizer = KEY_NORMALIZER)\n @path = Pathname.new(path)\n\n @table = CSV.table(@path.to_s, {\n converters: [YEAR_NORMALIZER, :all],\n header_converters: [normalizer]\n })\n\n @headers = @table.headers\n rescue InvalidKeyError\n raise BlankCSVHeaderError.new(path)\n end",
"def modelo_start\n $productos = 'Productos.csv'\n $clientes = 'Usuarios.csv'\n $vendedores = 'Vendedores.csv'\nend",
"def csv_file\n if File.size? csv_filename\n CSV.read(csv_filename, headers: true, col_sep: ';', header_converters: :symbol, converters: :all)\n else\n LOGGER.error(\"File not found or empty: #{csv_filename}\")\n abort('ABORTED!')\n end\n end",
"def load_file(model)\n model.delete_all\n record_name = model.to_s.downcase.pluralize\n record_count = 0\n CSV.foreach(\"#{Rails.root}/db/data/#{record_name}.csv\", {headers: true}) do |line|\n model.create(line.to_hash)\n record_count += 1\n end\n puts \"Created #{record_count} #{model.to_s} records.\"\n end",
"def initialize(name, file, opt={:type => :auto, :escape_char => '\\\\'})\n super(name)\n @file = file\n @delim = case opt[:type]\n when :auto then raise \"File-type auto-detection is not yet supported\"\n when :csv then ','\n when :tsv then \"\\t\"\n else opt[:delim]\n end\n @opt = opt\n end",
"def setup(csv, config, schema, host, accepted_domain)\n #parse the csv\n @url, @path, @title = csv[0], csv[1], csv[2]\n @url = fix_oneoff @url\n @fields = []\n csv[3..-1].each do |field|\n unless field.nil?\n @fields << (field.strip! || field)\n else\n @fields << -1 #flag\n end\n end\n\n #current directory, we want http://example.com/about/ or http://example.com/home/\n @cd = (@url[-1,1] == '/')? @url: @url.slice([email protected]('/'))\n @schema = schema\n @host = host\n @accepted_domain = accepted_domain\n @local_source = config['local_source'].nil? ? '': config['local_source']\n default_exts = ['.doc', '.docx', '.pdf', '.pptx', '.ppt', '.xls', '.xlsx']\n @file_whitelist = config['file_whitelist'].nil? ? default_exts : config['file_whitelist']\n @img_blacklist = config['img_blacklist'].nil? ? ['spacer.gif']: config['img_blacklist']\n\n # handle url == host, fix mangled @cd\n if @url == @host\n @cd = @url + '/'\n end\n Flatfish::Url.creds = {:http_basic_authentication => [config['basic_auth_user'], config['basic_auth_pass']]}\n end",
"def initialize(name, file, opt={:escape_char => '\\\\'})\n super(name)\n @file = file\n @delim = case opt[:type]\n when :csv then ','\n when :tsv then \"\\t\"\n else opt[:delim]\n end\n @opt = opt\n end",
"def load_csv\n CSV.foreach(@csv_file_path) do |row|\n @recipes << Recipe.new(name: row[0], description: row[1], rating: row[2], prep_time: row[3], tried: row[4])\n end\n end",
"def upload_csv\n\t\t@shortened_url = ShortenedUrl.new\n\t\t@url = parse_csv_shorten_urls_path\n\tend",
"def set_csv_attribute\n @csv_attribute = CsvAttribute.find(params[:id])\n end",
"def generate_csv_file(file_path, row_data)\n CSV.open(file_path, \"wb\") do |csv|\n csv << [\"first_name\", \"last_name\", \"dob\", \"member_id\", \"effective_date\", \"expiry_date\", \"phone_number\"]\n row_data.each { |row| csv << row }\n end\nend",
"def load_csv\n # read each line frmo csv and append to recipes collection\n CSV.foreach(@csv_file) do |row|\n # puts \"#{row[0]} | #{row[1]}\"\n @recipes << Recipe.new(name: row[0], description: row[1], cooking_time: row[2], difficulty: row[3], tested: row[4])\n end\n end",
"def initialize(logger, file_reader_class = StandardCSVReader)\n @file_reader_class = file_reader_class\n @logger = logger\n end",
"def read(path)\n new(CSV.read(path, **table_opts), path)\n end",
"def create\n\n @csv_upload = CsvUpload.new\n @csv_upload.Type = params[:Type]\n\n if params[:csv_upload][:csv_file].present? \n @csv_upload.uploadCSVFile(params[:csv_upload][:csv_file]) \n @csv_upload.filename = params[:csv_upload][:csv_file].original_filename\n end\n\n if not params[:csv_upload][:company_id].nil?\n @company = Company.find(params[:csv_upload][:company_id])\n @csv_upload.company = @company\n end\n\n respond_to do |format|\n if @csv_upload.save\n format.html { redirect_to edit_csv_upload_path(@csv_upload)}\n format.json { render json: @csv_upload, status: :created, location: @csv_upload }\n else\n format.html { render action: \"new\" }\n format.json { render json: @csv_upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def default_file\n \"default_data_store.csv\"\n end",
"def send_csv_file\n if @csv_file.present?\n data = CsvStorage.find_by(csv_file_type: @csv_file.type).try(:data_store)\n send_data(data, filename: @csv_file.name) if data.present?\n end\n end",
"def initialize(file_name)\n super()\n @file_name = file_name\n @headers = nil\n @headers_map = {}\n \n # default options we use for CSV files\n @csv_options = {\n headers: true, # assume input file has headers\n return_headers: false, # all rows will be treated as data by each_row()\n col_sep: \",\",\n row_sep: \"\\n\",\n quote_char: '\"',\n }\n end",
"def initialize(source, *options) \n case source\n when File, Tempfile\n raise \"#{source} does not exist\" unless File.exists?(source.path)\n @file = source\n if excel?\n lines = GridFile.read_excel(@file)\n else\n lines = source.readlines\n end\n super(lines, options)\n\n when String\n super(source, options)\n\n when Array\n super(source, options)\n\n else\n raise(ArgumentError, \"Expected String or File, but was #{source.class}\")\n end\n end",
"def initialize(options)\n options.each { |k, v| self.send :\"#{k}=\", v }\n self.file = File.expand_path file\n end",
"def initialize(file, options = {})\n @rows = []\n opts = { row_sep: \"\\n\", col_sep: ',', skip_blanks: true }.merge(options)\n CSV(file, opts) do |csv|\n csv.each do |r|\n @rows.push(r)\n end\n end\n @column_index = {\n name: 3, route: 4, city: 5, state: 6, zip: 7, td_linx_code: 8\n }\n end",
"def initialize(csv_in_filename)\n @in_file = csv_in_filename\n @csv_out_headers = nil\n @index = nil\n @csv_out_data = nil\n convert\n end",
"def initialize(lists = nil)\n\t\t\t\tif !lists.nil?\n\t\t\t\t\t@lists = lists\n\t\t\t\tend\n\t\t\t\t@file_type = 'CSV'\n\t\t\t\t@sort_by = 'EMAIL_ADDRESS'\n\t\t\t\t@export_date_added = true\n\t\t\t\t@export_added_by = true\n\t\t\t\t@column_names = ['Email Address', 'First Name', 'Last Name']\n\t\t\tend",
"def create\n imported_file = params[:csv_file][:file]\n @csv_file = CsvFile.new(params[:csv_file])\n @csv_file.name = params[:csv_file][:file].original_filename rescue nil\n\n respond_to do |format|\n if @csv_file.save\n format.html { redirect_to @csv_file, notice: 'Csv file was successfully created.' }\n format.json { render json: @csv_file, status: :created, location: @csv_file }\n else\n format.html { render action: \"new\" }\n format.json { render json: @csv_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def csv_location\n return @@csv_location\n end",
"def initialize(file_path)\n\t\t@path = file_path\n\tend",
"def initialize(filename,\n col_sep: \",\",\n comment_starts: false,\n comment_matches: false,\n ignore_empty_lines: true,\n surrounding_space_need_quotes: false,\n quote_char: \"\\\"\",\n default_filter: Jcsv.optional,\n strings_as_keys: false,\n format: :list,\n headers: true,\n custom_headers: nil,\n chunk_size: 0,\n deep_map: false,\n dimensions: nil,\n suppress_warnings: false)\n \n @filename = filename\n @col_sep = col_sep\n @comment_starts = comment_starts\n @comment_matches = comment_matches\n @default_filter = default_filter\n @filters = false\n @strings_as_keys = strings_as_keys\n @headers = headers\n @custom_headers = custom_headers\n @ignore_empty_lines = ignore_empty_lines\n @format = format\n @surrounding_space_need_quotes = surrounding_space_need_quotes\n @quote_char = quote_char\n @chunk_size = (chunk_size == :all)? 1.0/0.0 : chunk_size\n @deep_map = (@format == :list)? false : deep_map\n @dimensions_names = dimensions\n @column_mapping = Mapping.new\n @suppress_warnings = suppress_warnings\n \n prepare_dimensions if dimensions\n\n # set all preferences. To create a new reader we need to have the dimensions already\n # prepared as this information will be sent to supercsv for processing.\n new_reader(set_preferences)\n\n # Dynamic class change without writing subclasses. When headers, extend this class\n # with methods that assume there is a header, when no headers, then extend this class\n # with methods that know there is no header. Could have being done with subclasses,\n # but this would all subclasses to have two subclasses one inheriting from the header\n # class and one inheriting from the headerless classes. In this way we reduce the\n # subclasses need.\n @headers? prepare_headers : (@custom_headers? set_headers(@custom_headers) :\n headerless)\n\n # if there are dimensions, then we need to prepare the mappings accordingly. With\n # dimensions defined, users cannot defined mappings.\n dimensions_mappings if dimensions\n \n end",
"def seed\n # get csv url from user\n @csv_url = params[:csv_url]\n @page_string = \"\"\n \n #functionality for user to input csv URL\n # require 'open-uri'\n # open(@csv_url) do |f|\n # @page_string = f.read\n # end\n \n # File.open('db/seeds_data/products.csv', 'w') do |file|\n # file << @page_string\n # end\n\n Rails.application.load_seed\n end",
"def initialize(model, column, value)\n @model, @column, @value = model, column, value\n\n case @value\n when String\n @filename_without_extension = File.basename @value\n when File\n @original_file = @value\n @original_filename = File.basename @value.path\n model.converted = false\n when ActionDispatch::Http::UploadedFile\n @original_file = @value.tempfile\n @original_filename = @value.original_filename\n model.converted = false\n when Hash\n @converted_files = @value.select{ |k| formats.include? k }\n @original_filename_without_extension = @value[:filename]\n formats.each { |f| instance_variable_set :\"@#{duration_keys[f]}\", @value[ duration_keys[f] ] }\n version_formats.each{ |v, _| instance_variable_set :\"@#{version_input_path_keys[v]}\", @value[ version_input_path_keys[v] ] }\n else\n @filename_without_extension ||= ''\n end\n end",
"def initialize(csv_file)\n @csv_file = csv_file\n\n @invalid_sites = []\n\n @valid_sites = []\n\n @already_imported_sites = []\n\n parse_csv_file\n end",
"def csv_import_params\n params.require(:csv_import).permit(:file, :processor)\n end",
"def load_csv(csv_path)\n raise Error::InvalidCSV unless File.exist? csv_path\n begin\n vals = CSV.read(csv_path)\n rescue CSV::MalformedCSVError\n raise Error::InvalidCSV\n end \n\n raise Error::BlankCSV if vals.length == 0\n raise Error::InvalidCSV if vals[0].length != 3\n\n # remove optional header\n vals.shift if vals[0][0] == HEADER_VAL\n\n @data = vals.collect do |data|\n {\n \"image_path\" => data[0],\n \"id\" => data[1],\n \"label\" => data[2]\n }\n end\n end",
"def create_assignment_csv(args)\n [:path, :urls].each{|arg| args[arg] or raise Error::Argument, \"Missing arg '#{arg}'\" }\n headers = ['audio_url',\n 'project_id',\n 'unusual',\n 'chunk',\n 'chunk_hours',\n 'chunk_minutes',\n 'chunk_seconds',\n 'voices_count',\n (1 .. args[:voices].count).map{|n| [\"voice#{n}\", \"voice#{n}title\"]}\n ].flatten\n csv = args[:urls].map do |url|\n [url, \n local.id,\n args[:unusual].join(', '),\n interval_as_time_string,\n interval_as_hours_minutes_seconds.map{|n| (n == 0) ? nil : n },\n args[:voices].count,\n args[:voices].map{|v| [v[:name], v[:description]]}\n ].flatten\n end\n local.file(*args[:path]).as(:csv).write_arrays(csv, headers)\n local.file_path(*args[:path])\n end",
"def initialize(model_path)\n\t\t\tif File.exists?(model_path)\n\t\t\t\t@file = File.open(model_path,'r')\n\t\t\telse\n\t\t\t\traise NoFileError.new(model_path), \"file not found: #{model_path}\"\n\t\t\tend\n\t\tend",
"def initialize(filename)\n puts \"EventManager Initialized.\"\n @file = CSV.open(filename, {:headers => true, :header_converters => :symbol })\n end",
"def initialize(doc, result_location, settings)\n\t\text = File.extname(doc)\n\t\t@doc_reader = (ext == '.ach') ? AchReader.new(doc, settings['file']['acn']) : CsvReader.new(doc, settings['file']['csv'])\n\t\t@doc = doc\n\t\t@result_file = File.join(result_location, \"#{File.basename(@doc, '.*')}_complete.csv\")\n\t\t@mailer = Mailer.new\n\t\t@result_location = result_location\n\t\t@email_settings = settings['email_smtp']\n\tend",
"def initialize(params = {})\r\n @uploaded_file = params[:roster]\r\n @column_hash = params[:columns] || {}\r\n @has_headers = params[:has_headers]\r\n @course_role_id = params[:course_role_id]\r\n @course_offering = CourseOffering.find_by_id(params[:id])\r\n\r\n @users_created = []\r\n @users_enrolled = []\r\n\r\n @preview_rows = []\r\n @column_array = []\r\n\r\n process_csv if @uploaded_file\r\n end",
"def set_csvupload\n @csvupload = Csvupload.find(params[:id])\n end",
"def import_from_csv\n puts 'Which file would you like to import?'\n file_path = gets.chomp\n CsvImporter.new(@database, file_path).import\n puts 'Import complete.'\n rescue FileNotFoundError\n puts 'The specified file was not found.'\n rescue CsvInvalidError => e\n puts e.message\n end",
"def import_csv_full\n \n end",
"def write_email_to_csv_file\n require 'ftools'\n begin\n file = File.open(\"public/#{ @csv_file_name.nil? ? 'newsLatterSubscribers.csv' : @csv_file_name }\", \"a\")\n file << \"#{ email }\\n\"\n file.close\n rescue Exception => e\n self.errors << e.message\n end\n end",
"def initialize(path, headers, fw_version = nil)\n new_headers = headers + [HDR_DTP, HDR_FW, HDR_SN]\n old_headers = []\n @old_log_name = nil\n\n log_file = path.basename\n log_dir = path.dirname\n log_ext = path.extname\n log_base = log_file.basename log_ext\n @log_path = path\n\n if @log_path.exist?\n CSV.open(@log_path, \"r\", headers: true, return_headers: true) do |log|\n log.readline\n old_headers = log.headers\n end\n end\n\n if old_headers.class == TrueClass || old_headers.size == 0\n # log_file is empty, does not exist yet or has no headers: create/overwrite!\n @log = CSV.open @log_path, \"wb\"\n @log << new_headers\n elsif old_headers == new_headers\n # OK to keep adding log records to the existing file\n @log = CSV.open @log_path, \"ab\"\n else\n # log file exists but it's the wrong format so start a new log\n time_stamp = DateTime.now.strftime(\"%Y%m%dT%H%M%S\")\n @old_log_name = log_base.sub_ext(\"_\" + time_stamp).sub_ext(log_ext)\n rename_path = log_dir.join @old_log_name\n File.rename @log_path, rename_path\n raise \"unable to rename log to #{rename_path}\" if File.exist? @log_path\n @log = CSV.open @log_path, \"wb\"\n @log << new_headers\n end\n\n @fw_version = fw_version\n end",
"def initialize(file_path)\n @filepath = file_path\n @lines = []\n @empty = true\n @error = false\n @description = \"none\"\n @format = \"unknown\"\n @rows = []\n end",
"def load_csv\n CSV.foreach(@file_path) do |row|\n # Our CSV stores strings only - so we must initialize all our recipes\n recipe = Recipe.new(row[0],row[1])\n # We push them into the cookbook recipes array\n @recipes << recipe\n end\n end",
"def initialize(file_path)\n @file_path = file_path\n end",
"def assign_csv_report\n unless @csv.nil?\n csv_header = ['Time', 'Req/s', 'Avg. resp. (ms)']\n @csvexport = Ralphttp::CsvExport.new(csv_header)\n end\n end",
"def import_csv_smart\n \n end",
"def csv_to_table\n\t\tpath = File.join(Rails.root, \"db/seed_data\")\n\t\tDir.foreach(path) do |file|\n\t\t\tif file.include?(\".csv\")\n\t\t\t\theader_row = nil\n\t\t\t\tmodel = File.basename(file, File.extname(file)).camelcase.constantize\n\t\t\t\tmodel.delete_all\n\t\t\t\tCSV.foreach(File.join(path,file)) do |row|\n\t\t\t\t\tif header_row.nil?\n\t\t\t\t\t\theader_row = row\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\t\tattributes = {}\n\t\t\t\t\trow.each_index do |i|\n\t\t\t\t\t\tattributes[header_row[i].to_sym] = row[i]\n\t\t\t\t\tend\n\t\t\t\t\tmodel.create!(attributes)\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\tend",
"def csv_to_table\n\t\tpath = File.join(Rails.root, \"db/seed_data\")\n\t\tDir.foreach(path) do |file|\n\t\t\tif file.include?(\".csv\")\n\t\t\t\theader_row = nil\n\t\t\t\tmodel = File.basename(file, File.extname(file)).camelcase.constantize\n\t\t\t\tmodel.delete_all\n\t\t\t\tCSV.foreach(File.join(path,file)) do |row|\n\t\t\t\t\tif header_row.nil?\n\t\t\t\t\t\theader_row = row\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\t\tattributes = {}\n\t\t\t\t\trow.each_index do |i|\n\t\t\t\t\t\tattributes[header_row[i].to_sym] = row[i]\n\t\t\t\t\tend\n\t\t\t\t\tmodel.create!(attributes)\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\tend",
"def initialize file_path\n\t\t\t@file_path = file_path\n\t\t\t@meta = {}\n\t\tend",
"def csv_params\n params.require(:import_database).permit(:csv, :csv_cache)\n end",
"def write_email_to_csv_file\n require 'ftools'\n begin\n file = File.open(\"public/#{ @csv_file_name.nil? ? 'newsLatterSubscribers.csv' : @csv_file_name }\", \"a\")\n file << \"#{ email }\\n\"\n file.close\n rescue Exception => e\n self.errors.add_to_base(e.message + \" (CSV)\")\n end\n end",
"def initialize(table, path = nil)\n @headers = table.headers\n @path = Pathname(path) if path\n @table = table\n\n # Delete the header row for the internal representation. This will be (re-)created when saved.\n @table.delete(0)\n\n raise(BlankCSVHeaderError, path || '<no path>') if @headers.any?(&:nil?)\n end",
"def initialize(filename)\n @path = filename\n end",
"def create_from_csv\n CSV.parse(csv_params[:csv]) do |row|\n @tarot.cards << Card.new(name: row[0], text: row[1], description: row[2])\n end\n\n respond_to do |format|\n if @tarot.save\n format.html { redirect_to tarot_cards_path(@tarot), notice: 'Card was successfully created.' }\n format.json { render action: 'show', status: :created, location: @card }\n else\n format.html { render action: 'new' }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @csv = Csv.new(params[:csv])\n\n send_data @csv.csv_from_xml, filename: \"import.csv\", type: 'text/csv', disposition: \"attachment\" and return\n #send_data @csv.csv_from_html, filename: \"import.csv\", type: 'text/csv', disposition: \"attachment\" and return\n\n\n\n #respond_to do |format|\n #if @csv.save\n # format.csv { send_data @csv_from_html, filename: \"import.csv\", type: 'text/csv', disposition: \"attachment\" }\n # format.html { redirect_to root_url, notice: 'CSV was successfully created.' }\n #format.json { render json: @csv, status: :created, location: @csv }\n #else\n # format.html { render action: \"new\" }\n # format.json { render json: @csv.errors, status: :unprocessable_entity }\n #end\n #end\n end",
"def set_csv_filter\n @csv_filter = CsvFilter.find(params[:id])\n end",
"def init_with_file(model_path, policy_path, logger: Logger.new($stdout))\n a = Persist::Adapters::FileAdapter.new(policy_path)\n init_with_adapter(model_path, a, logger: logger)\n end",
"def csv_file_format\n if file.original_filename !~ /.*\\.csv/\n errors.add :file, 'is not a .csv file'\n end\n end",
"def import_csv\n if current_admin.present? \n updated_user_id = current_admin.id\n create_user_id = current_admin.id\n else\n updated_user_id = current_user.id\n create_user_id = current_user.id\n end\n if (params[:file].nil?)\n redirect_to upload_csv_posts_path, notice: Messages::REQUIRE_FILE_VALIDATION \n elsif !File.extname(params[:file]).eql?(\".csv\")\n redirect_to upload_csv_posts_path, notice: Messages::WRONG_FILE_TYPE \n else\n error_msg = PostsHelper.check_header(Constants::HEADER,params[:file])\n if error_msg.present?\n redirect_to upload_csv_posts_path, notice: error_msg\n else \n Post.import(params[:file],create_user_id,updated_user_id)\n redirect_to posts_path, notice: Messages::UPLOAD_SUCCESSFUL\n end\n end\n end",
"def generate(with_headers: true)\n @file = Tempfile.new([row_model_class.name, \".csv\"])\n CSV.open(file.path, \"wb\") do |csv|\n @csv = csv\n row_model_class.setup(csv, context, with_headers: with_headers)\n yield Proxy.new(self)\n end\n ensure\n @csv = nil\n end",
"def create_csv &block\n file = create_tempfile \"csv\"\n CSV.open file.path, \"w\", &block\n file\n end",
"def csv_data\n case\n when google_key || url then Curl::Easy.perform(uri).body_str\n when file then File.open(uri).read\n end\n end",
"def set_json_data\n csvfile = params[:csvfile]\n return unless csvfile\n # See if the file was uploaded as a multipart file.\n if csvfile.respond_to?(:tempfile)\n params[:json_data] = load(csvfile.tempfile)\n else\n # Load from a local file provided\n params[:json_data] = load(csvfile) if File.file?(csvfile)\n end\n end",
"def initialize(csv, dam_name)\n\t\t#Load initial csv, and fix\n\t\tcrude = CSV.read(\"public/#{csv}.csv\")\n\t\tfix_csv(crude)\n\t\t@report = CSV.read(\"public/ephemeral.csv\", headers:true)\n\t\t@dam_id = extract_dam(dam_name)\n\tend",
"def make_history_csv\n FileUtils.mkdir_p(@@csv_location.dirname) unless Dir.exist?(csv_location.dirname)\n create_stub_csv_file unless File.exist?(@@csv_location)\n end",
"def initialize(**opts)\n @account = opts[:account].nil? ? get_account_name : opts[:account].downcase\n opts[:destination] ||= '~/Library/RyPass'\n @destination = File.expand_path(opts[:destination]).downcase\n @username = opts[:username].nil? ? nil : opts[:username].downcase\n load_csv\n end",
"def initialize(source, options = {})\n if source.is_a?(String)\n require 'csv'\n mode_string = options[:encoding] ? \"r:#{options[:encoding]}\" : 'r'\n csv_options = options.fetch(:csv_options, {})\n @path = source\n source = CSV.open(@path, mode_string, csv_options).readlines\n elsif !source.is_a?(Enumerable) || (source.is_a?(Enumerable) && source.size > 0 &&\n !source.first.is_a?(Enumerable))\n raise ArgumentError, \"source must be a path to a file or an Enumerable<Enumerable>\"\n end\n if (options.keys & [:parent_field, :parent_fields, :child_field, :child_fields]).empty? &&\n (kf = options.fetch(:key_field, options[:key_fields]))\n @key_fields = [kf].flatten\n @parent_fields = @key_fields[0...-1]\n @child_fields = @key_fields[-1..-1]\n else\n @parent_fields = [options.fetch(:parent_field, options[:parent_fields]) || []].flatten\n @child_fields = [options.fetch(:child_field, options[:child_fields]) || [0]].flatten\n @key_fields = @parent_fields + @child_fields\n end\n @field_names = options[:field_names]\n @warnings = []\n index_source(source, options)\n end",
"def initialize(filepath, current_user, relation)\n\n # Open the new file & get the attributes row from it\n @relation = relation\n @import_file = Roo::Spreadsheet.open(filepath, extension: :xlsx)\n @excel_attributes_raw = @import_file.sheet(0).row(1)\n @excel_attributes = @excel_attributes_raw.map{ |el| el.downcase.gsub(\" \", \"_\") }\n\n # validate attributes row\n @invalid_rows = false\n @valid_attributes_from_db = getAllValidAttributes\n @mandatory_attributes_from_db = getAllMandatoryAttributes(current_user)\n \n # get valid and invalid attributes based on name\n getValidAndInvalidAttributes\n\n # valid attributes found and all mandatory attributes are there\n if checkAttributeRequirements\n # get valid listings from excel\n getValidListingsFromExcel\n\n # handle title and shipment to countries\n handleTitle\n handleCountries\n handleUSPs\n\n # check if there exists a value for mandatory attributes\n checkListingAttributeRequirements\n\n # handle listings which have to be updated\n listingsToUpdate current_user\n end\n end",
"def csv_output_path()\n return @base_path\n end",
"def initialize(filename)\n\t\tmyCSV = CSV.new File.new(filename), {:headers => true}\n\t\t@matrix = myCSV.read\n\t\t@headers = @matrix.headers\n\tend"
] | [
"0.63111824",
"0.63063574",
"0.6291434",
"0.61375433",
"0.6103567",
"0.61031485",
"0.61011624",
"0.6090713",
"0.60613924",
"0.6050992",
"0.6019264",
"0.58894736",
"0.5876875",
"0.5874358",
"0.5872753",
"0.5869697",
"0.584772",
"0.58409953",
"0.58012336",
"0.58008945",
"0.57771254",
"0.577417",
"0.5751534",
"0.5744653",
"0.5738427",
"0.57341933",
"0.5728418",
"0.5714188",
"0.5651752",
"0.56515956",
"0.5647548",
"0.56353915",
"0.56314",
"0.56296533",
"0.5623391",
"0.5617519",
"0.56078714",
"0.5591747",
"0.5575649",
"0.5572904",
"0.5557986",
"0.55524373",
"0.55518866",
"0.55283",
"0.55179703",
"0.5510416",
"0.5500322",
"0.54996914",
"0.54950273",
"0.5494312",
"0.5483247",
"0.54789865",
"0.5442351",
"0.5430337",
"0.5421941",
"0.5418724",
"0.53896624",
"0.53879905",
"0.53850174",
"0.535904",
"0.5353059",
"0.5345659",
"0.5343467",
"0.53430605",
"0.53427935",
"0.5340927",
"0.5339035",
"0.5337695",
"0.5331602",
"0.5330441",
"0.53295714",
"0.5327808",
"0.53181726",
"0.5317842",
"0.53115547",
"0.53086287",
"0.53019637",
"0.5300638",
"0.5293578",
"0.5291381",
"0.5287388",
"0.52781665",
"0.5277673",
"0.52764386",
"0.5274763",
"0.52577615",
"0.52525127",
"0.5249371",
"0.5241845",
"0.52364653",
"0.5235659",
"0.5234051",
"0.5227321",
"0.5226172",
"0.5225659",
"0.5220359",
"0.5219531",
"0.521317",
"0.520869",
"0.52079284"
] | 0.5856602 | 16 |
Initialize and return the `Header` for the current CSV file | def header
@header ||= Header.new(
column_definitions: config.column_definitions,
column_names: csv.header
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header\n @header ||= csv_rows.first\n end",
"def header\n @header ||= csv_rows.first\n end",
"def csv_header\n #empty by default\n []\n end",
"def csv_header\n #empty by default\n []\n end",
"def header\n @header ||= create_header\n end",
"def header_fields\n @csv.headers\n end",
"def csv_headers\n return @@csv_headers\n end",
"def parse_headers!(csv_file)\n csv = CSV.open(csv_file, :headers => true)\n csv.gets\n csv.headers\n end",
"def grab_header\n return @header if (@header and [email protected]?)\n @file.rewind\n fields.each_with_index do |field_name, i|\n @header[i]= field_name.strip\n end\n @header\n end",
"def csv_header(*columns)\n csv.start(columns.flatten)\n end",
"def csv_headers\n raise NotImplementedError\n end",
"def header\n return @header\n end",
"def header=(_arg0); end",
"def csv_header(header_prefix)\n @csv_header << header_prefix\n end",
"def csv_header\n [\n 'project key',\n 'key',\n 'summary',\n 'description',\n 'issue type',\n 'epic name'\n ]\n end",
"def csv_file_headers\n # Open file\n CSV.foreach(self.file.path, headers: true) do |row|\n # Transform row to hash\n row = row.to_hash\n # Normalize it\n row = normalize_row(row)\n errors.add(:file, \"Invalid CSV headers, please check if #{required_csv_headers.join(', ')} are present.\") unless valid_headers?(row)\n break\n end\n end",
"def initialize(path, normalizer = KEY_NORMALIZER)\n @path = Pathname.new(path)\n\n @table = CSV.table(@path.to_s, {\n converters: [YEAR_NORMALIZER, :all],\n header_converters: [normalizer]\n })\n\n @headers = @table.headers\n rescue InvalidKeyError\n raise BlankCSVHeaderError.new(path)\n end",
"def actual_header\n data.lines.first.chomp\n end",
"def header_parameters\n return @header_parameters unless @header_parameters.nil?\n io = header_parameters_with_io._io\n _pos = io.pos\n io.seek(0)\n @header_parameters = HeaderParameters.new(io, self, @_root)\n io.seek(_pos)\n @header_parameters\n end",
"def header(value = nil)\n value ? self.header = value : @header\n end",
"def initialize category\n #\n # array of header lines\n @header = []\n #\n # hash of header keys => [ index into @header, start pos of value ]\n @headerpos = {}\n \n @category = category\n\n end",
"def getHeader() @header1 end",
"def create_header(meta_data)\n station = meta_data.station\n start_date = meta_data.start_date\n @header = I18n.t(\"forecast_text.main.header_start\")\n @header.concat(station.name)\n @header.concat(I18n.t(\"forecast_text.main.header_conn\"))\n @header.concat(start_date.to_s)\n nil\n end",
"def initialize(table, path = nil)\n @headers = table.headers\n @path = Pathname(path) if path\n @table = table\n\n # Delete the header row for the internal representation. This will be (re-)created when saved.\n @table.delete(0)\n\n raise(BlankCSVHeaderError, path || '<no path>') if @headers.any?(&:nil?)\n end",
"def headers\n @headers ||= next_row\n end",
"def csv\n @csv_table ||= begin\n csv_raw = File.read(CSV_PATH)\n CSV.parse(csv_raw, headers: true)\n end\n\nend",
"def create_header\n @sheet.row(0).concat @header_row\n end",
"def parse_headers(row = nil)\n if @headers.nil? # header row\n @headers = case @use_headers # save headers\n # Array of headers\n when Array then @use_headers\n # HBCSV header String\n when String\n self.class.parse_line( @use_headers,\n col_sep: @col_sep,\n row_sep: @row_sep,\n quote_char: @quote_char )\n # first row is headers\n else row\n end\n\n # prepare converted and unconverted copies\n row = @headers if row.nil?\n @headers = convert_fields(@headers, true)\n @headers.each { |h| h.freeze if h.is_a? String }\n\n if @return_headers # return headers\n return self.class::Row.new(@headers, row, true)\n elsif not [Array, String].include? @use_headers.class # skip to field row\n return shift\n end\n end\n\n self.class::Row.new(@headers, convert_fields(row)) # field row\n end",
"def header_build\n header = \"customer name\" + @delimiter + \"gender\" + @delimiter\n header += \"age\" + @delimiter + \"birthday\" + @delimiter + \"cpf\" + @delimiter + \"id\" + @delimiter\n header += \"state\" + @delimiter + \"city\" + @delimiter + \"street\" + @delimiter + \"zip_code\" + @delimiter\n header += \"company name\" + @delimiter + \"industry\" + @delimiter + \"cnpj\"\n header\nend",
"def header\n chunk_header = nil\n File.open(@file_name) do |file|\n file.seek(@offset + 4 + @size_length, IO::SEEK_CUR)\n chunk_header = file.read(@header_size)\n end\n chunk_header\n end",
"def initialize(filename)\n\t\tmyCSV = CSV.new File.new(filename), {:headers => true}\n\t\t@matrix = myCSV.read\n\t\t@headers = @matrix.headers\n\tend",
"def empty(headers, path)\n path = Pathname(path) unless path.nil?\n\n raise(ExistingCSVHeaderError, path) if path&.file?\n\n headers = headers.map { |header| normalize_key(header) }\n new(CSV::Table.new([CSV::Row.new(headers, headers, true)]), path)\n end",
"def header=(header)\n @header = header\n end",
"def header\n\t\t@json_file\n\tend",
"def header=(header)\n @header = header\n end",
"def getSampleHeader()\n r = File.open(@communityFile, \"r\")\n @sampleHeader = r.gets.split(\"\\t\")[0]\n r.close()\n end",
"def header\n self.mult_table.header_line.to_s + \"\\n\"\n end",
"def initialize(filepath, col_sep: \"\\t\")\n @filepath = filepath\n @col_sep = col_sep\n @file_handle = File.open(filepath)\n @headers = @file_handle.gets.chomp!.split(col_sep, -1).map(&:downcase).map(&:to_sym)\n end",
"def initialize(header_text = nil, charset = nil)\n @charset = charset\n self.raw_source = header_text\n split_header if header_text\n end",
"def mark_csv_headers\n \"Username,Name,Tutorial,Task,ID,Student's Last Comment,Your Last Comment,Status,New Grade,New Comment\"\n end",
"def csv_attributes\n @csv_attributes ||= Hash[header.column_names.zip(row_array)]\n end",
"def header\n if defined?(@header) && (@header == false)\n false\n elsif defined?(@header) && @header\n @header\n else\n first\n end\n end",
"def initialize(header, options = {})\n @header_cols = split_by_comma_regex(header || \"\")\n @insert_cols = (options[:insert] || \"\").split(/,|;/)\n @positions = options[:pos] || []\n @sort = options[:sort]\n end",
"def first\n header_data\n end",
"def import_hdr\n if @hdr_reader == nil\n case @file_type\n when \"pfile\" then printraw_summary_import\n when \"scan_archive_h5_json\" then printraw_scan_archive_h5_json\n end\n else\n raise(IndexError, \"No Header Data Available.\") if @hdr_data == nil\n case @hdr_reader\n when \"rubydicom\" then rubydicom_hdr_import\n when \"dicom_hdr\" then dicom_hdr_import\n when \"printraw\" then printraw_import\n when \"rdgehdr\" then rdgehdr_import\n when \"cat\" then printraw_summary_import\n end\n end\n end",
"def headers\n rows.first\n end",
"def header\n new_header = GElf::SectionHeader.new\n\n GElf.gelf_getshdr(self,new_header)\n return new_header\n end",
"def header\n @result['_header']\n end",
"def monta_header_arquivo\n raise Brcobranca::NaoImplementado, 'Sobreescreva este método na classe referente ao banco que você esta criando'\n end",
"def header\n end",
"def initialize(csv, importer)\n @source_csv = CSV.read(csv, headers: true)\n @is_for_bulkrax = importer == 'bulkrax'\n @fileset_model_or_type = @is_for_bulkrax ? 'FileSet' : 'fileset'\n directory = File.dirname(csv)\n extension = File.extname(csv)\n filename = File.basename(csv, extension)\n @processed_csv = File.join(directory, filename + \"-processed.csv\")\n @merged_headers = exclusion_guard(additional_headers + @source_csv.headers)\n @tree = {}\n end",
"def csv_header\n header = CSV.generate_line([\"Application Path\", \"Report Generation Time\", \"Checks Performed\", \"Rails Version\"])\n header << CSV.generate_line([File.expand_path(tracker.app_path), Time.now.to_s, checks.checks_run.sort.join(\", \"), rails_version])\n \"BRAKEMAN REPORT\\n\\n\" + header\n end",
"def header\n @header ||= HeaderController.new config\n end",
"def validate_header(header)\n import_failed(0, t(:header_invalid)) if self.class.csv_header != header\n end",
"def initialize(header)\n @header = header\n @items = []\n end",
"def header=(value)\n @header = Mail::Header.new(value, charset)\n end",
"def required_csv_headers\n [:email, :name]\n end",
"def parse_header\n header.each do |field, value|\n self.instance_variable_set(\"@#{field}\", value) if HEADER_FIELDS.include? field\n end\n end",
"def head\n header = ''\n File.open(@file).each_line do |line|\n break if line.chomp.empty?\n header << line\n end\n return header\n end",
"def set_header\n @header = Header.find(params[:id])\n end",
"def set_header\n @header = Header.find(params[:id])\n end",
"def csv_file_header_array\n\t\tScreeningDatumUpdate.expected_column_names\n\tend",
"def generate_header(provider = nil)\n header = Qrda::Header.new(@@cda_header)\n\n header.identifier.root = UUID.generate\n header.authors.each {|a| a.time = Time.now}\n header.legal_authenticator.time = Time.now\n header.performers << provider\n\n header\n end",
"def csv_parsed\n transform_to_hash(@csv_array, @header)\n end",
"def generate_header_info\n magic = FileMagic.new\n @header_info = magic.file(@file_name)\n magic.close\n\n @header_info\n end",
"def initialize(csv_in_filename)\n @in_file = csv_in_filename\n @csv_out_headers = nil\n @index = nil\n @csv_out_data = nil\n convert\n end",
"def start_header(attributes)\n @element_stack << :header\n end",
"def start_header(attributes)\n @element_stack << :header\n end",
"def initialize(file_name)\n super()\n @file_name = file_name\n @headers = nil\n @headers_map = {}\n \n # default options we use for CSV files\n @csv_options = {\n headers: true, # assume input file has headers\n return_headers: false, # all rows will be treated as data by each_row()\n col_sep: \",\",\n row_sep: \"\\n\",\n quote_char: '\"',\n }\n end",
"def record_header(cursor)\n origin = cursor.position\n header = RecordHeader.new\n cursor.backward.name(\"header\") do |c|\n case page_header.format\n when :compact\n # The \"next\" pointer is a relative offset from the current record.\n header.next = c.name(\"next\") { origin + c.read_sint16 }\n\n # Fields packed in a 16-bit integer (LSB first):\n # 3 bits for type\n # 13 bits for heap_number\n bits1 = c.name(\"bits1\") { c.read_uint16 }\n header.type = RECORD_TYPES[bits1 & 0x07]\n header.heap_number = (bits1 & 0xfff8) >> 3\n when :redundant\n # The \"next\" pointer is an absolute offset within the page.\n header.next = c.name(\"next\") { c.read_uint16 }\n\n # Fields packed in a 24-bit integer (LSB first):\n # 1 bit for offset_size (0 = 2 bytes, 1 = 1 byte)\n # 10 bits for n_fields\n # 13 bits for heap_number\n bits1 = c.name(\"bits1\") { c.read_uint24 }\n header.offset_size = (bits1 & 1).zero? ? 2 : 1\n header.n_fields = (bits1 & (((1 << 10) - 1) << 1)) >> 1\n header.heap_number = (bits1 & (((1 << 13) - 1) << 11)) >> 11\n end\n\n # Fields packed in an 8-bit integer (LSB first):\n # 4 bits for n_owned\n # 4 bits for flags\n bits2 = c.name(\"bits2\") { c.read_uint8 }\n header.n_owned = bits2 & 0x0f\n header.info_flags = (bits2 & 0xf0) >> 4\n\n case page_header.format\n when :compact\n record_header_compact_additional(header, cursor)\n when :redundant\n record_header_redundant_additional(header, cursor)\n end\n\n header.length = origin - cursor.position\n end\n\n header\n end",
"def Header(*args)\n Stupidedi::Schema::TableDef.header(*args)\n end",
"def header\n header = \"%FDF-1.2\\n\\n1 0 obj\\n<<\\n/FDF << /Fields 2 0 R\"\n # /F\n header << \"/F (#{options[:file]})\" if options[:file]\n # /UF\n header << \"/UF (#{options[:ufile]})\" if options[:ufile]\n # /ID\n header << \"/ID[\" << options[:id].join << \"]\" if options[:id]\n header << \">>\\n>>\\nendobj\\n2 0 obj\\n[\"\n return header\n end",
"def initialize(options = {})\n @options = options\n @header = options[:header]\n end",
"def parse_header(header_line)\n entries = delete_special_chars(header_line)\n # switch entries for geo coordinates since latitude comes before longitude\n geo_coordinate = Entity::Coordinate.new(entries[6].to_f, entries[5].to_f)\n @grid_data = Entity::GridPoint.new(entries[8].to_f, entries[9].to_f,\n entries[12].to_f, entries[11].to_f)\n # special case for multi word locations\n station_name = entries[0].sub(\"_\", \" \")\n @station = Entity::Station.new(station_name, entries[3], entries[13].to_f,\n geo_coordinate)\n nil\n end",
"def parse_header(row)\r\n @first_month = 0 # January.\r\n row.each do |col|\r\n next unless col.nil?\r\n index = Date::MONTHNAMES.index(col.strip)\r\n unless index.nil?\r\n @first_month = index\r\n break\r\n end\r\n end\r\n @header_parsed = true\r\n end",
"def get_csv_data(csv_file)\n\t\tcsv_file = File.read(csv_file)\n\t\tcsv = CSV.parse(csv_file, :headers => true)\t\n\t\tcsv\n\tend",
"def generate_header_row\n generate_row(@header)\n end",
"def generate_header_row\n generate_row(@header)\n end",
"def get_header_info\n @data.rewind\n \n #column_count_offset = 33, record_count_offset = 24, record_length_offset = 36\n @record_count, @data_offset, @record_length = data.read(HEADER_LENGTH).unpack(\"@24 I x4 I I\")\n @column_count = (@data_offset-400)/200\n end",
"def initialize_generator\n @csv_report_generator ||= CSVReportGenerator.new(method_names: csv_headers)\n end",
"def header(key = nil, val = nil)\n if key\n val ? @header[key.to_s] = val : @header.delete(key.to_s)\n else\n @header\n end\n end",
"def header= h\n @header = if h.is_a? Numeric\n self[h]\n else\n h\n end\n end",
"def define_row headers\n headers ||= {}\n\n # get the superclass for Row\n baseclass = if superclass.const_defined? :Row\n superclass::Row\n else\n Object\n end\n\n # remove class definition\n if const_defined? :Row and baseclass != self::Row\n self.send :remove_const, :Row\n end\n\n # define Row class\n const_set :Row, (Class.new(baseclass) do\n\n attr_accessor *headers.keys\n\n define_method :initialize do |line = {}|\n headers.each do |k, v|\n instance_variable_set \"@#{k.to_s}\", line[v]\n end\n end\n\n define_method :to_csv do\n CSV.generate_line headers.map { |k, v| self.send k }\n end\n\n end)\n end",
"def header(args = {}, &block)\n build_base_component :header, args, &block\n end",
"def initialize(csv_source)\n @csv_source = csv_source\n end",
"def on_header_init()\n end",
"def build_table_header\n names = column_names(data)\n build_md_row(output, names)\n build_md_row(output, alignment_strings(names))\n end",
"def new_header\n SimpleOAuth::Header.new(\n request_method,\n API_URL,\n params,\n client.oauth_options\n )\n end",
"def initialize klass\n @klass = klass\n\n @column_descriptions = klass.column_descriptions\n\n @headers = @column_descriptions.map do |_, header, format,|\n header\n end\n end",
"def setup_header(dat)\n @headers = { to: to }\n dat.each do |key, val|\n key = key.to_s.downcase\n raise \"invalid field #{key}\" unless valid_fields.include?(key)\n @headers[key.to_sym] = val unless val.nil?\n end\n end",
"def headers(header = nil)\n if header.is_a?(Hash)\n @headers ||= {}\n @headers.merge!(header)\n end\n\n return @headers if @headers\n\n superclass.respond_to?(:headers) ? superclass.headers : nil\n end",
"def header; end",
"def header; end",
"def header; end",
"def table_header\n line = \"File|Total\".dup\n line << \"|Line\" if header_line_rate?\n line << \"|Branch\" if header_branch_rate?\n line << \"\\n\"\n end",
"def create_stub_csv_file\n File.rm(@@csv_location) if File.exist?(@@csv_location)\n CSV.open(@@csv_location, 'w') do |row|\n row << @@csv_headers\n end\n end",
"def initialize(filename)\n puts \"EventManager Initialized.\"\n @file = CSV.open(filename, {:headers => true, :header_converters => :symbol })\n end",
"def header(haders, name)\n headers[name]\n end",
"def initialize(path, headers, fw_version = nil)\n new_headers = headers + [HDR_DTP, HDR_FW, HDR_SN]\n old_headers = []\n @old_log_name = nil\n\n log_file = path.basename\n log_dir = path.dirname\n log_ext = path.extname\n log_base = log_file.basename log_ext\n @log_path = path\n\n if @log_path.exist?\n CSV.open(@log_path, \"r\", headers: true, return_headers: true) do |log|\n log.readline\n old_headers = log.headers\n end\n end\n\n if old_headers.class == TrueClass || old_headers.size == 0\n # log_file is empty, does not exist yet or has no headers: create/overwrite!\n @log = CSV.open @log_path, \"wb\"\n @log << new_headers\n elsif old_headers == new_headers\n # OK to keep adding log records to the existing file\n @log = CSV.open @log_path, \"ab\"\n else\n # log file exists but it's the wrong format so start a new log\n time_stamp = DateTime.now.strftime(\"%Y%m%dT%H%M%S\")\n @old_log_name = log_base.sub_ext(\"_\" + time_stamp).sub_ext(log_ext)\n rename_path = log_dir.join @old_log_name\n File.rename @log_path, rename_path\n raise \"unable to rename log to #{rename_path}\" if File.exist? @log_path\n @log = CSV.open @log_path, \"wb\"\n @log << new_headers\n end\n\n @fw_version = fw_version\n end",
"def header\n @message.header\n end"
] | [
"0.81811714",
"0.81811714",
"0.7482727",
"0.7482727",
"0.7353371",
"0.70078933",
"0.70057446",
"0.6968203",
"0.69610083",
"0.6796678",
"0.6750354",
"0.65901566",
"0.6551267",
"0.65221846",
"0.65061986",
"0.6496908",
"0.6492711",
"0.6470569",
"0.6459076",
"0.6450369",
"0.64484346",
"0.643117",
"0.63923645",
"0.6383927",
"0.6373452",
"0.6336701",
"0.633109",
"0.6310318",
"0.6300902",
"0.6287741",
"0.6273548",
"0.62640446",
"0.62539214",
"0.6227659",
"0.62130505",
"0.6207779",
"0.61964786",
"0.6169691",
"0.6155945",
"0.6151122",
"0.61275405",
"0.61258554",
"0.6116184",
"0.6089434",
"0.6071074",
"0.60706675",
"0.6054444",
"0.60332716",
"0.6017825",
"0.6007612",
"0.5993701",
"0.5980682",
"0.59727645",
"0.59712905",
"0.5965323",
"0.59419066",
"0.5938554",
"0.59091777",
"0.5906789",
"0.5904228",
"0.5904228",
"0.58955806",
"0.5882149",
"0.5876744",
"0.58705914",
"0.5854984",
"0.5852195",
"0.5852195",
"0.5848788",
"0.5826552",
"0.5823542",
"0.58226305",
"0.58219874",
"0.5820448",
"0.5800393",
"0.57961804",
"0.579168",
"0.579168",
"0.57637084",
"0.57576084",
"0.57519263",
"0.57465",
"0.574599",
"0.5739947",
"0.5731706",
"0.5711905",
"0.5710821",
"0.57048357",
"0.5701864",
"0.57017744",
"0.569759",
"0.56929046",
"0.56929046",
"0.56929046",
"0.5684443",
"0.567791",
"0.56704646",
"0.56701446",
"0.5660534",
"0.5655732"
] | 0.8598381 | 0 |
Initialize and return the `Row`s for the current CSV file | def rows
csv.rows.map { |row_array|
Row.new(header: header, row_array: row_array).to_a
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rows\n @rows ||= csv_rows[1..-1]\n end",
"def rows\n @rows ||= csv_rows[1..-1]\n end",
"def rows\n @rows ||= [].tap do |rows|\n CSV.foreach(csv_file, headers: @has_header_row) do |row|\n rows << columns.map { |column, index| normalize(column, row[index].try(:strip).presence) }\n end\n end\n end",
"def read_row\n @row ||= Row.new([nil] * @key_map.size, key_map: @key_map)\n\n # Need to read ahead by one record in order to get EOF flag\n @prev_read ||= @data_stream.readline\n\n self.eof_flag = @data_stream.eof?\n @row.last_row = self.eof_flag\n\n this_read = @data_stream.readline\n\n if @data_lib.csv_opt[:headers] && @data_lib.header_as_variables\n row_array = @prev_read.fields\n else\n row_array = @key_map.map.with_index do |v,i|\n variable_idx_to_csv_col(@prev_read.size)[i] && @prev_read[variable_idx_to_csv_col(@prev_read.size)[i]]\n end\n end\n\n @row.set_values(row_array)\n @prev_read = this_read\n\n @row\n end",
"def csv_row\n #empty by default\n []\n end",
"def csv_row\n #empty by default\n []\n end",
"def create_item_rows_from_csv \n item_rows = []\n CSV.foreach('./data/items.csv', headers: true, header_converters: :symbol) do |row|\n item_rows << row\n end \n return item_rows\n end",
"def csv\n @csv_table ||= begin\n csv_raw = File.read(CSV_PATH)\n CSV.parse(csv_raw, headers: true)\n end\n\nend",
"def csvReader(file, headers)\n begin\n csvTable = CSV.read(file, {col_sep:\"\\t\", quote_char:\"\\0\", headers:headers})\n rescue ArgumentError\n puts \"Error: Unsupported encoding, tabulated/CSV file must be in UTF-8 format.\"\n abort\n end\n parsedObj = OpenStruct.new()\n parsedObj.rowArray = []\n parsedObj.belArray = []\n csvTable.each do |row|\n unless row.length == 0\n current = OpenStruct.new()\n current.bel_id = row[0]\n current.bel_id.slice! \"BEL:\"\n current.bel = row[1]\n current.sentence = row[2]\n current.sentence_id = row[3]\n current.sentence_id.slice! \"SEN:\"\n current.pmid = row[4]\n parsedObj.rowArray << current\n parsedObj.belArray << row[1]\n end\n end\n parsedObj.linecount = csvTable.length\n return parsedObj\nend",
"def each\n\t\t\t@csv_contents.each { |csv_row| yield CsvRow.new(csv_row, @headers) } \n\t\t\tnil\n\t\tend",
"def row_from_csv(csv, line:)\n row_args = %i[timestamp speaker settings content].each_with_object({}) do |key, args|\n args[key] = csv[@key_map[key]]\n args\n end\n\n Row.new(line_number: line, **row_args)\n end",
"def each_row(input)\n csv = ::CSV.new(input, csv_options)\n # Skip skipRows and headerRows\n rownum = dialect.skipRows.to_i + dialect.headerRowCount\n (1..rownum).each {csv.shift}\n csv.each do |row|\n rownum += 1\n yield(Row.new(row, self, rownum))\n end\n end",
"def load_csv\n CSV.foreach(@csv_file_path) do |row|\n @recipes << Recipe.new(name: row[0], description: row[1], rating: row[2], prep_time: row[3], tried: row[4])\n end\n end",
"def each\n @csv_contents.each do |line|\n yield CsvRow.new(@headers, line)\n end\n end",
"def parse_csv(path)\n require 'csv'\n\n str = Nitro::Template.new.render(File.read(path))\n\n reader = CSV::Reader.create(str)\n header = reader.shift\n\n reader.each_with_index do |row, i|\n data = {}\n row.each_with_index do |cell, j|\n data[header[j].to_s.strip] = cell.to_s.strip\n end\n self[\"#{@name}_#{i+1}\"] = obj = instantiate(data)\n @objects << obj\n end\n end",
"def import_base\n CSV.foreach(@file.path, encoding: detect_encoding, headers: true) do |row|\n next if row.blank?\n yield ActiveSupport::HashWithIndifferentAccess.new(row)\n end\n end",
"def initialize(file, options = {})\n @rows = []\n opts = { row_sep: \"\\n\", col_sep: ',', skip_blanks: true }.merge(options)\n CSV(file, opts) do |csv|\n csv.each do |r|\n @rows.push(r)\n end\n end\n @column_index = {\n name: 3, route: 4, city: 5, state: 6, zip: 7, td_linx_code: 8\n }\n end",
"def load\n CSV.foreach(@csv_file, headers: :first_row, header_converters: :symbol) do |row|\n @data << Employee.new(row)\n end\n end",
"def read_in_csv_data(csv_file_name)\n begin\n CSV.foreach(csv_file_name, headers: true) do |row|\n @songs << Song.new(row['name'], row['location'])\n end\n rescue Exception\n @songs = nil\n end\n @songs\n end",
"def initialize(rowdata)\n @rowdata = rowdata\n end",
"def rows\n return enum_for(:rows) unless block_given?\n\n safe_path = SafeFile.safepath_to_string(@filename)\n\n # By now, we know `encodings` should let us read the whole\n # file succesfully; if there are problems, we should crash.\n CSVLibrary.foreach(safe_path, encodings(safe_path)) do |line|\n yield line.map(&:to_s)\n end\n end",
"def initialize(csv_class_path)\n @path = csv_class_path\n @recipes = CSV.open(@path).map do |row|\n Recipe.new(name: row[0], ingredients: row[1], prep_time: row[2], difficulty: row[3])\n end\n end",
"def initialize(csv_file_path)\n # take recipe from csv file\n @csv_file_path = csv_file_path\n @recipes = []\n parse\n end",
"def initialize(row)\n @row = row\n end",
"def each_row(batch = ETL::Batch.new)\n log.debug(\"Reading from CSV input file #{file_name}\")\n @rows_processed = 0\n ::CSV.foreach(file_name, csv_options) do |row_in|\n # Row that maps name => value\n row = {}\n\n # If we weren't given headers then we use what's in the file\n if headers.nil?\n # We have a hash - OK we'll use it\n if row_in.respond_to?(:to_hash)\n row = row_in.to_hash\n # We have an array - use numbers as the keys\n elsif row_in.respond_to?(:to_a)\n ary = row_in.to_a\n ary.each_index do |i|\n row[i] = ary[i]\n end\n # Error out since we don't know how to process this\n else\n raise ETL::InputError, \"Input row class #{row_in.class} needs to be a hash or array\"\n end\n # if we were given the headers to use then we just need to grab the\n # values out of whatever we have\n else\n values = row_in.kind_of?(::CSV::Row) ? row_in.fields : row_in.to_a\n\n if headers.length != values.length\n raise ETL::InputError, \"Must have the same number of headers #{headers.length} \" + \n \"and values #{values.length}\"\n end\n\n # match up headers and values\n (0...headers.length).each do |i|\n row[headers[i]] = values[i]\n end\n end\n\n # now we apply our header map if we have one\n @headers_map.each do |name, new_name|\n if row.has_key?(name)\n # remap old name to new name\n row[new_name] = row[name]\n row.delete(name)\n else\n raise ETL::InputError, \"Input row does not have expected column '#{name}'\"\n end\n end\n\n transform_row!(row)\n yield row\n @rows_processed += 1\n end\n end",
"def read(path)\n new(CSV.read(path, **table_opts), path)\n end",
"def convert_csv_file_to_object\n begin\n CSV.foreach(@file_name) do |row|\n @csv_object.push(row)\n end \n rescue => exception\n raise FileReadError, exception\n end\n end",
"def initialize(rows = [])\n @rows = rows || []\n end",
"def initialize(row)\n @row = row\n end",
"def load_csv\n options = { headers: :first_row, header_converters: :symbol }\n\n CSV.foreach(@csv_path, options) do |row|\n row[:id] = row[:id].to_i\n row[:price] = row[:price].to_i\n @elements << Meal.new(row)\n end\n @next_id = @elements.empty? ? 1 : @elements.last.id + 1\n end",
"def load_csv\n # read each line frmo csv and append to recipes collection\n CSV.foreach(@csv_file) do |row|\n # puts \"#{row[0]} | #{row[1]}\"\n @recipes << Recipe.new(name: row[0], description: row[1], cooking_time: row[2], difficulty: row[3], tested: row[4])\n end\n end",
"def initialize(rows)\n @rows = rows\n end",
"def initialize(csv_file) # csv_fi\n @csv_file = csv_file # we store it in a variable in case it's added later\n @recipes = []\n read_recipe_from_csv_file\n end",
"def rows\n return enum_for(:rows) unless block_given?\n\n col_sep = @options['col_sep']\n liberal = @options['liberal_parsing'].presence\n\n delimited_rows(@filename, col_sep, liberal) { |row| yield row }\n end",
"def parsed_data\n @parsed_data ||= begin\n CSV.read(full_filename, col_sep: col_sep, quote_char: quote_char, encoding: encoding)\n rescue => e #CSV::MalformedCSVError => er\n @parse_error = e.to_s\n rows = []\n #one more attempt. If BOM is present in the file.\n begin\n f = File.open(full_filename, \"rb:bom|utf-8\")\n rows = CSV.parse(f.read.force_encoding(\"ISO-8859-1\"))\n ensure\n return rows\n end\n end\n end",
"def each_row(&block)\n ::Enumerator.new { |enumerator|\n headers, eof = *self.read_headers\n\n until eof\n row, eof = *self.read_row\n\n unless eof\n enumerator << row\n end\n end\n }.each(&block)\n end",
"def load\n CSV.foreach(@csv_file, headers: :first_row, header_converters: :symbol) do |row|\n @meals << Meal.new(row)\n end\n end",
"def load_csv\n CSV.foreach(@file_path) do |row|\n # Our CSV stores strings only - so we must initialize all our recipes\n recipe = Recipe.new(row[0],row[1])\n # We push them into the cookbook recipes array\n @recipes << recipe\n end\n end",
"def import_csv_full\n \n end",
"def init_object_from_row(row)\n if row\n data = Hash[columns.zip(row)]\n new(data)\n end\n end",
"def import_from_csv(file_name)\r\n #implementation goes here\r\n csv_text = File.read(file_name)\r\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\r\n # #8 iterate over table rows, create hash for each, then convert to Entry using 'add_entry' method\r\n csv.each do |row|\r\n row_hash = row.to_hash\r\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\r\n end #end csv.each loop\r\n end",
"def initialize(source = nil)\n parsed_row = process_source(source)\n\n @cells = []\n\n build_row(parsed_row) if parsed_row\n end",
"def parse_csv(file_path)\n record_list = []\n header = []\n is_header = true\n \n CSV.foreach(file_path) do |row|\n if (is_header)\n\theader = row\n\tis_header = false\n else\n\trecord = Record.new\n\trecord.create(header, row)\n\trecord_list.push(record)\n end\n end\n return record_list\n end",
"def csv_import(the_file)\n import_list = []\n CSV.foreach(the_file, headers: true) do |row|\n import_list << row.to_hash\n end\n import_list\n end",
"def initialze(csv_row)\n cols = []\n cols = csv_row.entries.select{|c,v| !v.nil?}.collect{|c| c[0]}\n @lumps = Taxonifi::Lumper.available_lumps(cols)\n end",
"def build_rows(csv, activity)\n funding_sources = get_funding_sources(activity)\n funding_sources_total = get_funding_sources_total(funding_sources, false) # for spent\n\n funding_sources.each do |funding_source|\n funding_source_amount = get_funding_source_amount(funding_source, false) # for spent\n funding_source_ratio = get_ratio(funding_sources_total, funding_source_amount)\n\n row = []\n row << get_funding_source_name(activity)\n row << activity.organization.try(:raw_type)\n row << activity.organization.try(:name)\n row << activity.provider.try(:name)\n row << get_locations(activity)\n row << get_sub_implementers(activity)\n row << activity.name\n row << activity.description\n row << activity.currency\n row << activity.spend_q1\n row << activity.spend_q2\n row << activity.spend_q3\n row << activity.spend_q4\n row << activity.spend\n row << Money.new(activity.spend.to_i * 100, get_currency(activity)).exchange_to(:USD)\n\n build_code_assignment_rows(csv, activity, row, funding_source_ratio)\n end\n end",
"def rows\n @rows ||= _row_args.map.with_index do |row_args, i|\n klass, args = row_args\n\n args = args.dup\n options = args.extract_options!\n proc = _row_scopes[i]\n scope = self.instance_eval(&proc)\n\n klass.new(*args, scope, options)\n end\n end",
"def read_row\n @row ||= Row.new([nil]*@key_map.size, last_row: false, key_map: @key_map)\n @row.clear\n end",
"def parse\r\n\t\tCSV.foreach(self.filepath) {|row| @list << row}\r\n\t\[email protected]!\r\n\tend",
"def each\n\t\t\tfilename = self.class.to_s.downcase + '.txt'\n\t\t\tfile = File.new(filename)\n\t\t\t@headers = file.gets.chomp.split(', ')\n\n\t\t\tfile.each { |row| yield CsvRow.new(row.chomp.split(', ')) }\n\t\tend",
"def rows=(source)\n for row in source\n #row = row.split(/#{@delimiter}/) unless row.is_a?(Array)\n unless row.is_a?(Array)\n RAILS_DEFAULT_LOGGER.debug(\"source_row: \" + row.inspect) if RAILS_DEFAULT_LOGGER.debug?\n #alp: remove any trailing commas from each line - apparent bug in Excel causes these sometimes\n row.sub!(/\\,\\r\\n$/, \"\\r\\n\")\n row = CSV::parse_line(row)\n end\n index = 0\n row = row.collect {|cell|\n if cell\n#alphere: the following not needed now that I am using CSV::parse\n# cell.strip!\n# if quoted\n# cell.gsub!(/^\"/, '')\n# cell.gsub!(/\"$/, '')\n# end\n\n if index >= column_count\n columns << Column.new\n end\n \n column = columns[index]\n if !column.fixed_size && (cell.size > column.size)\n column.size = cell.size\n end\n end\n\n index = index + 1\n cell\n }\n \n rows << Row.new(row, self)\n end\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # #8 iterate over the CSV::Table rows then create a hash for each row, convert each row_hash\n #to an Entry by using the add_entry method\n csv.each do |row|\n row_hash = row.to_hash\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def read_csv_data file\n rows = []\n readerIn = CSV.open(file, 'r')\n row = readerIn.shift\n while row!= nil && !row.empty?\n rows << row\n row = readerIn.shift\n end\n readerIn.close\n \n return rows\nend",
"def row(row)\n Row.new(@data, row)\n end",
"def initialize(data, row)\n @data = data\n @row = row\n end",
"def initialize(path, int_fields = nil)\n\t\t@int_fields = int_fields || proc { |f| false }\n\t\t@csv = CSV.open(path, :col_sep => ';', :headers => :first_row,\n\t\t\t:encoding => 'ISO-8859-1:UTF-8')\n\t\[email protected] { |v,f| @int_fields[f.header] ? v.to_i : v }\n\tend",
"def rows\n RowCollection.new(@data)\n end",
"def import_csv\n @records = CSV.read(@filename, :headers => true, :row_sep => :auto)\n unless @records.blank?\n @linenum = 0\n if @filename.index('att') || @filename.index('Att')\n @school_year = Time.parse(@records[0][\"AbsenceDate\"]).year\n end\n @records.each { |rec |\n @linenum += 1\n @record = rec\n next unless check_record(@record)\n seed_record(@record)\n process_record(@record, rec2attrs(@record)) if rec2attrs(@record) != false\n }\n end \n end",
"def initialize(options={})\n options ||= {} # make sure options can't be nil\n @rows = []\n self.title = options[:title]\n @row_colors = options[:row_colors]\n self.format = options[:format]||[]\n self.header = options[:header]||[]\n self.font_size = options[:font_size]||:normal\n self.size = header.size\n @table_key = options[:table_key]\n @sortable = options[:sortable].nil? ? true : options[:sortable]\n @sort_by = options[:sort_by]||header.first\n \n @sort_order = options[:sort_order].blank? ? \"asc\" : options[:sort_order].downcase\n @sort_order = @sort_order == \"desc\" ? false : true\n\n import_row_data(options[:row_data]) if options[:row_data]\n end",
"def initialize (row_list)\n @rows = row_list\n @rows_reduced = 0\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true)\n # Iterate over the table object's rows\n csv.each do |row|\n # Create a hash for each row\n row_hash = row.to_hash\n # Convert each row_hash to an Entry by using add_entry method\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n\n # Get the number of items parsed by calling the count method\n return csv.count\n end",
"def initialize(num_rows,num_columns)\n @num_rows = num_rows\n @num_columns = num_columns\n @rows = []\n for x in 1..num_rows\n fresh_row = Row.new(num_columns)\n @rows << fresh_row\n end\n end",
"def load_data\n @data ||= CSV.read(@file)\n end",
"def read_csv(file)\n reading_list = []\n CSV.foreach(file, :headers => true) do |row|\n reading_list << Book.new({\n 'book_title' => row['book_title'],\n 'isbn' => row['isbn'],\n 'description' => row['description'],\n 'read_date' => row['read_date']\n })\n end\n reading_list\nend",
"def initialize(data=[], options={})\n @headers = options[:headers]\n if @headers\n @column_names = data.shift\n @rows = data\n else\n @rows = data\n end\n end",
"def product_import_initial_values\n if @temp_file.blank?\n errors.add(:file_missing, \"file missing\")\n return false\n end\n\n begin\n file_content = read_import_csv(@temp_file)\n rescue Exception => e\n errors.add(:encoding_failed, \"<br />#{e.backtrace.join('<br />')}\")\n return false\n end\n\n begin\n data = CSV.parse(file_content)\n rescue Exception => e\n errors.add(:invalid_csv, \"<br />#{e.backtrace.join('<br />')}\")\n return false\n end\n\n if has_header?\n header_row = parse_header(data.first)\n errors.add(:has_header) unless valid_header?(header_row, import_kind)\n end\n end",
"def initialize(name)\n @name = name\n @rows = Array.new\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # Iterate over the CSV::Table object's rows. Then create a has for each row.\n # Convert each row_hash to an entry by using add_entry method.\n csv.each do |row|\n row_hash = row.to_hash\n add_entry(row_hash[\"name\"], row_hash[\"phone_number\"], row_hash[\"email\"])\n end\n end",
"def loadCSV\n csvFile = File.open(\"app/assets/csv/test.csv\", \"r\") #Open file with readpermissions\n if csvFile #if file was successfully opened \n csvRowArray = IO.readlines(csvFile) # Turn each row into an array element\n rowId=1 #0 is the Header Row, 1 is the first dataset.\n recordsArray = Array.new(csvRowArray.size-1)\n while csvRowArray[rowId] do #for each row that exists \n rowEntry = csvRowArray[rowId]\n rowEntry.gsub!(/\"/,'') # Remove all the '\"'s\n wordArr = rowEntry.split(\",\") #Split the array on ','s into a new array \n newRecord = Record.new\n newRecord.REF_DATE = wordArr[0]\n newRecord.GEO = wordArr[1]\n newRecord.DGUID = wordArr[2]\n newRecord.Sex = wordArr[3]\n newRecord.Age_group = wordArr[4]\n newRecord.Student_response = wordArr[5]\n newRecord.UOM = wordArr[6]\n newRecord.UOM_ID = wordArr[7]\n newRecord.SCALAR_FACTOR = wordArr[8]\n newRecord.SCALAR_ID = wordArr[9]\n newRecord.VECTOR = wordArr[10]\n newRecord.COORDINATE = wordArr[11]\n newRecord.VALUE = wordArr[12]\n newRecord.STATUS = wordArr[13]\n newRecord.SYMBOL = wordArr[14]\n newRecord.TERMINATED = wordArr[15]\n newRecord.DECIMALS = wordArr[16]\n newRecord.save\n puts rowId\n rowId = rowId+1 \n end\n return recordsArray\n else #file not opened\n puts \"Unable to open file\" \n return \n end \n end",
"def rows\n (report[\"data\"][\"rows\"] || []).map { |row| Row.new(self, row) }\n end",
"def initialize \n #local variable csv will be created. It will = instance of CSV reader, drawn from \"./zipcode-db.cvs\"\n csv = CSVReader.new(\"./free-zipcode-database.csv\")\n #areas will have default value of an empty array\n @areas = []\n #I will run csv.read, which will return a hash based on a file of information.\n csv.read do |item|\n #the hash I get from csv.read will be formatted according to the Area class, and then put into the @areas array.\n @areas << Area.new(item)\n end\n end",
"def rows\n rows_to_skip = data_start_index\n cached_columns = columns\n\n Rximport.logger.info \"Parser: Reading rows in sheet #{sheet.name}, starting at row #{data_start_index + 1}\"\n\n data_rows = sheet.simple_rows.lazy\n .drop(rows_to_skip)\n .reject(&:blank?)\n .each_with_index\n .map { |r, idx| Row.new(cached_columns, r, idx + rows_to_skip, sheet.name) }\n\n data_rows.map do |row|\n if block_given?\n yield row\n else\n row\n end\n end\n end",
"def read_1d_csv_file(state_table_path) \r\n rows_read=0\r\n\t\tstate_transition_list= Array.new\r\n\t\tignore_first_row = true\r\n\r\n\t\tCSV::Reader.parse(File.open(state_table_path, 'r').read.gsub(/\\r/,\"\\n\")) do |row_array|\r\n\t\t\t# First row should be the header\r\n\t\t\tif ignore_first_row\r\n\t\t\t\tignore_first_row=false\r\n\t\t\telse\r\n\t\t\t\ttransition = TransitionHolder.new(row_array[STATE1].to_s,row_array[ACTION].to_s,row_array[STATE2].to_s)\r\n\t\t\t\tputs_debug \"Read in transitions: #{transition}\"\r\n\t\t\t\tstate_transition_list.push transition \r\n\t\t\tend # if first row\r\n\t\t\trows_read +=1\r\n\t\tend # end csv block\r\n\r\n raise \"CSV File Empty\" if rows_read==0\r\n raise \"Missing Data in CSV File\" if rows_read==1\r\n \r\n\t\t# return state table, its a raw list of transition objects\r\n\t\treturn state_transition_list\r\n\r\n\tend",
"def import\n CSV.new(open(uri), headers: :first_row).each_with_index do |csv_row, i|\n begin\n create_departure(csv_row: csv_row)\n rescue => e\n # this is a catch all for all the types of parsing errors that could\n # occur above\n csv_logger.info(\n I18n.t('import_exception', scope: LOCALE, row_number: i)\n )\n csv_logger.error(e)\n end\n end\n end",
"def parse_csv_file\n csv_data = CSV.read(\"../artists_for_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash\n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n \n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painter_num => painter_row_arr[6]\n }\n painter_object_array.push(painter_object)\n end\n painter_object_array.flatten\nend",
"def prepare_csv\n unparsed_file = File.open(csv.path)\n self.parsed_csv_string = \"\"\n string = unparsed_file.readlines()\n string.each_with_index do |line,i|\n parsed_line = line.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/,\\\"\\\"/,'')\n # for some reason the iRacing CSV file is buggy.\n unless parsed_line == \"\\n\"\n if i == 5 or i == 6\n parsed_line = parsed_line.gsub(/\\n/,\"\\r\\n\")\n end\n self.parsed_csv_string << parsed_line\n end\n end\n unparsed_file.close\n end",
"def read_row\n return if end_of_file?\n\n @current_row = @next_row || _read_row\n @line_number = current_row.nil? ? nil : @line_number + 1\n @next_row = nil\n\n current_row\n end",
"def each\n rewind\n return self.enum_for(:each) unless block_given?\n csv.each do |row|\n next unless out = convert_row(row)\n yield(out)\n end\n end",
"def csv_to_array(file)\n @recipes = []\n CSV.foreach(file){|row| @recipes << Recipe.new(row[0], row[1].to_i, row[2].to_i, row[3].to_i)}\n end",
"def load_from_row(row)\n row.each_with_index { |val, i| self[i] = val } # @dbs[i].kind_of?(Numeric) ? val.to_i : val }\n return self\n end",
"def parse\n results = []\n\n CSV.parse(read_data).each do |row|\n row = parse_row(row)\n keep = block_given? ? yield(row) == true : true\n results << row if keep\n end\n\n results\n end",
"def import_csv_smart\n \n end",
"def lazy_read(file)\n Enumerator.new do |yielder|\n CSV.foreach(file, DEFAULT_CSV_OPTIONS) do |row|\n yielder.yield(row)\n end\n end\n end",
"def initialize(csv_in_filename)\n @in_file = csv_in_filename\n @csv_out_headers = nil\n @index = nil\n @csv_out_data = nil\n convert\n end",
"def initialize(rows, rownames: nil, colnames: nil)\n @rows = rows\n @rownames = (rownames || Hash[*rows.length.times.map do |i| [i, i] end.flatten(1)]).to_ordered_hash\n unless colnames then\n colnames = {}\n rows.each do |row| row.keys.each do |colname| colnames[colname] = true end end\n colnames = colnames.keys\n end\n @colnames = colnames.collect do |colname| colname.to_s.to_sym end\n end",
"def load_row_data(headers, row)\n # Hash of field values\n fields = {}\n\n # List of alternate spellings found in current row\n alt_spellings = []\n\n # Related words for current row\n see_also = []\n\n # List of hashes of source data for current row\n sources = []\n\n # Loop through the cells in the row\n row.each_with_index do |field_value, col_index|\n # Skip empty cells\n next unless field_value\n\n # Remove leading/trailing whitespace from field value\n field_value = field_value.strip\n\n # Get current header\n header = headers[col_index]\n\n if header.start_with? 'headword'\n headword_data = headword_data field_value\n fields = fields.merge headword_data\n next\n end\n\n if header.start_with? 'altspelling'\n alt_spellings << field_value\n next\n end\n\n if header.start_with? 'source'\n match = self.class.source_header_regex.match header\n\n # Get source number i.e. source1\n source_num = match[1].to_i - 1 # Subtract 1 since CSV vals are 1-based, and arrays are 0-based\n\n # Ref/original_ref/date/place\n source_component = match[2]\n\n # Find or create source record for current source\n current_source = sources[source_num] ||= {}\n\n # Add current field to source obj\n current_source[source_component.to_sym] = field_value\n current_source[:source_num] = source_num\n next\n end\n\n if header == 'see also'\n current_see_also = see_also_from_string field_value\n see_also += current_see_also\n next\n end\n\n # No match, so just add as is\n fields[header.to_sym] = field_value\n end\n\n # Fields that are handled specially\n special_fields = { alt_spellings: alt_spellings, see_also: see_also, sources: sources }\n\n # Add special fields to all others\n all_fields = special_fields.merge fields\n\n all_fields\n end",
"def initialize(csv, importer)\n @source_csv = CSV.read(csv, headers: true)\n @is_for_bulkrax = importer == 'bulkrax'\n @fileset_model_or_type = @is_for_bulkrax ? 'FileSet' : 'fileset'\n directory = File.dirname(csv)\n extension = File.extname(csv)\n filename = File.basename(csv, extension)\n @processed_csv = File.join(directory, filename + \"-processed.csv\")\n @merged_headers = exclusion_guard(additional_headers + @source_csv.headers)\n @tree = {}\n end",
"def initialize(df, rowid, row)\n @df = df\n @rowid = rowid\n @rowname = df.rownames[rowid]\n @row = row\n end",
"def initialize(row = [], last_row: false, row_number: nil, key_map: nil)\n @last_row = last_row\n @row_number = row_number\n @key_map = key_map\n @row = row.empty? ? nilified_row : row.to_a\n\n initialize_accessor\n end",
"def initialize\n @columns = []\n @columns_lookup = []\n @rows = []\n @newline = \"\\r\\n\"\n end",
"def all\n CSV.read(@@file_path).map { |row| Contact.new(row[0].to_i, row[1], row[2], deserialize_phones(row[3])) }\n end",
"def lazy_read(file)\n Enumerator.new do |yielder|\n CSV.foreach(file, DEFAULT_CSV_OPTIONS) do |row|\n yielder.yield(row)\n end\n end\n end",
"def loadCSVFile(filePath)\n data = []\n CSV.foreach(filePath, :headers => true) do |row|\n row = row.to_h\n row.each do |k, v|\n v = v.to_s\n row[k] = v\n end\n data << row\n end\n data\n end",
"def rows\n @rows ||= star_file.sheets.first.rows\n end",
"def rows\n @rows ||=\n begin\n rows = []\n @facet_values.each_slice(2) do |pair|\n rows << new_row(pair)\n end\n rows\n end\n end",
"def array_of_articles\n articles = []\n #binding.pry\n CSV.foreach('articles.csv', headers: true) do |row|\n articles << Article.new(row[\"id\"], row[\"title\"], row[\"description\"], row[\"url\"])\n end\n articles\nend",
"def read_rows\n line_no = 0\n\n @sheet.rows.each do |r|\n line_no += 1\n row = row_as_array(r)\n next if empty_row?(row)\n\n data = convert_row(row, line_no)\n yield data if block_given?\n end\n end",
"def import_from_csv(file_name)\n csv_text = File.read(file_name)\n csv = CSV.parse(csv_text, headers: true, skip_blanks: true)\n # Iterate over the CSV::Table object's rows, create a string for each row, and convert each row to a Client by using the create_client method.\n csv.each do |row|\n name, facebook_id, twitter_handle = row.to_s.split(\",\").map(&:chomp)\n create_client(name, facebook_id, twitter_handle)\n end\n end",
"def parse_painter_csv_file\n csv_data = CSV.read(\"db/painter_seed_data.csv\")\n csv_data.shift\n # iterate over each element and send back a hash \n # need to shift again at the beginning to get rid of id on the row\n painter_object_array = []\n csv_data.each do |painter_row_arr|\n painter_row_arr.shift\n painter_object = {\n :name => painter_row_arr[0],\n :years => painter_row_arr[1],\n :genre => painter_row_arr[2],\n :nationality => painter_row_arr[3],\n :bio => painter_row_arr[4],\n :painting_num => painter_row_arr[6],\n :portrait => painter_row_arr[7]\n }\n painter_object_array.push(painter_object) \n end\n painter_object_array.flatten\nend",
"def rows\n RowEnum.new(self)\n end"
] | [
"0.73947436",
"0.73947436",
"0.7231613",
"0.7112304",
"0.70487416",
"0.70487416",
"0.68859357",
"0.681869",
"0.66462904",
"0.66247207",
"0.6590753",
"0.6569246",
"0.6490851",
"0.64713776",
"0.6465624",
"0.6465203",
"0.6464063",
"0.64581937",
"0.6452828",
"0.64308774",
"0.6425225",
"0.6414548",
"0.6396838",
"0.6388743",
"0.6377486",
"0.6374201",
"0.6373571",
"0.6364987",
"0.63606226",
"0.63489646",
"0.6315449",
"0.63060737",
"0.62938106",
"0.6289418",
"0.62695676",
"0.6236863",
"0.6232946",
"0.6227642",
"0.62042403",
"0.62016565",
"0.6189435",
"0.61723465",
"0.61711603",
"0.61541736",
"0.6146213",
"0.6145834",
"0.6134233",
"0.61262107",
"0.610444",
"0.6098109",
"0.60949457",
"0.6078294",
"0.606982",
"0.60667306",
"0.6051533",
"0.6045249",
"0.6038194",
"0.6032765",
"0.6026228",
"0.60232264",
"0.59939563",
"0.59886634",
"0.59750396",
"0.59737116",
"0.5969682",
"0.5964148",
"0.59535867",
"0.5950333",
"0.594897",
"0.59231037",
"0.58939433",
"0.58776027",
"0.587598",
"0.5875493",
"0.5861564",
"0.58594626",
"0.58557147",
"0.5855452",
"0.58515185",
"0.58376306",
"0.5819262",
"0.5817375",
"0.58062357",
"0.5793645",
"0.5792401",
"0.5790673",
"0.57883084",
"0.57777524",
"0.5774016",
"0.57716614",
"0.5754542",
"0.57526654",
"0.5752061",
"0.5749752",
"0.5747928",
"0.57475376",
"0.5742791",
"0.5733772",
"0.57294244",
"0.5726356"
] | 0.74670786 | 0 |
Run the import. Return a Report. | def run!
if valid_header?
@report = Runner.call(header: header, rows: rows, config: config)
else
@report
end
rescue CSV::MalformedCSVError => e
@report = Report.new(status: :invalid_csv_file, parser_error: e.message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n @report = Report.new\n @report.plugin = self\n build_report\n rescue Exception => e\n @report.error e\n ensure\n return @report\n end",
"def import\n ret = @uri.import\n render plain: ret[:message], status: ret[:status]\n end",
"def import\n Rails.logger.info(\"Results::ResultsFile #{Time.zone.now} import\")\n\n Event.transaction do\n event.disable_notification!\n book = ::Spreadsheet.open(source.path)\n book.worksheets.each do |worksheet|\n race = nil\n create_rows(worksheet)\n\n rows.each do |row|\n Rails.logger.debug(\"Results::ResultsFile #{Time.zone.now} row #{row.spreadsheet_row.to_a.join(', ')}\") if debug?\n if race?(row)\n race = find_or_create_race(row)\n # This row is also a result. I.e., no separate race header row.\n if usac_results_format?\n create_result(row, race)\n end\n elsif result?(row)\n create_result(row, race)\n end\n end\n end\n event.enable_notification!\n CombinedTimeTrialResults.create_or_destroy_for!(event)\n end\n Rails.logger.info(\"Results::ResultsFile #{Time.zone.now} import done\")\n end",
"def run_report(report)\n report.update! status: 'running'\n\n klass = report.name.constantize\n\n r = klass.new(report.parameters)\n if r.parameters_valid?\n record_set = r.query\n report_template = klass.template\n\n output = ApplicationController.new\n .render_to_string(template: report_template, formats: report.format,\n locals: { klass: klass, record_set: record_set,\n created_at: report.created_at })\n report.update! status: 'completed', output: output\n else\n report.update status: 'error'\n report.update status_message: r.error_message\n end\n end",
"def perform(report)\n generate_excel_file(report)\n end",
"def report_load\n self.report('load_report')\n end",
"def import!\n return selected_importer.import!\n end",
"def report_report(opts)\n return if not active\n created = opts.delete(:created_at)\n updated = opts.delete(:updated_at)\n state = opts.delete(:state)\n\n ::ApplicationRecord.connection_pool.with_connection {\n report = Report.new(opts)\n report.created_at = created\n report.updated_at = updated\n\n unless report.valid?\n errors = report.errors.full_messages.join('; ')\n raise \"Report to be imported is not valid: #{errors}\"\n end\n report.state = :complete # Presume complete since it was exported\n report.save\n\n report.id\n }\n end",
"def run_report(options = {})\n options = argument_cleaner(required_params: %i( reportid entityid ), optional_params: %i( format content_disposition nodata AsOf), options: options )\n authenticated_get cmd: \"runreport\", **options\n end",
"def import\n end",
"def import\n end",
"def import\n end",
"def import\n end",
"def report\n\t\tend",
"def import()\n # TODO\n end",
"def run\n\t\tmy_credentials = {\"user\" => \"test.api\", 'password' => '5DRX-AF-gc4', 'client_id' => 'Test', 'client_secret' => 'xIpXeyMID9WC55en6Nuv0HOO5GNncHjeYW0t5yI5wpPIqEHV'}\n\t\taccess_token = self.class.post('http://testcost.platform161.com/api/v2/access_tokens/', { query: my_credentials })['token']\n\t\theaders = {:headers => {'PFM161-API-AccessToken' => access_token}}\n\t\tadvertiser_reports = self.class.post('https://testcost.platform161.com/api/v2/advertiser_reports/', headers )\n\t\tcreate_local_report advertiser_reports['id']\n\t\tcampaign = self.class.get('https://testcost.platform161.com/api/v2/campaigns/' + campaign_id.to_s, headers )\n\t\tif advertiser_reports['results'] && advertiser_reports['results'].select { |campaign| campaign['campaign_id'] == campaign_id }.present?\n\t\t\tadvertiser_report = advertiser_reports['results'].select { |campaign| campaign['campaign_id'] == campaign_id }\n\t\t\tReportGeneratorCsvBuilder.new({advertiser_report: advertiser_report, campaign: campaign}).build\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def report\n \n end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report\n require File.join File.expand_path(File.dirname(__FILE__)), \"report\"\n Brakeman::Report.new(self)\n end",
"def importing\n @dataset = Dataset.where(id: params.fetch(:id)).first\n render plain: @dataset.import_status\n end",
"def execute\n puts @robot.report\n end",
"def test_import\n Log.remove(ArtworkDataPlugin.log_name)\n \n query = 'SELECT * FROM artwork'\n sth = $dbh_pg.execute(query)\n\n while row = sth.fetch\n ArtworkDataPlugin.new('data', row)\n end\n \n ArtworkDataPlugin.flush_logs\n Log.test_regression(ArtworkDataPlugin.log_name)\n ArtworkDataPlugin.write_report\n IdStore.write_report\n end",
"def import\n task = Task.create!(name: 'Preparing to import MARCXML records',\n service: Service::LOCAL_STORAGE,\n status: Task::Status::SUBMITTED)\n RecordSource.new.import_async(task)\n rescue => e\n handle_error(e)\n else\n flash['success'] = 'Import will begin momentarily.'\n ensure\n redirect_back fallback_location: tasks_path\n end",
"def run\n schedule_data_reports\n end",
"def request_import\n end",
"def do_import\n if(reset)\n TaliaUtil::Util.full_reset\n puts \"Data Store has been completely reset\"\n end\n errors = []\n run_callback(:before_import)\n if(index_data)\n import_from_index(errors)\n else\n puts \"Importing from single data file.\"\n TaliaCore::ActiveSource.create_from_xml(xml_data, :progressor => progressor, :reader => importer, :base_file_uri => @true_root, :errors => errors, :duplicates => duplicates)\n end\n if(errors.size > 0)\n puts \"WARNING: #{errors.size} errors during import:\"\n errors.each { |e| print_error e }\n end\n run_callback(:after_import)\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 export_report\n @report.export_report\n end",
"def export_report\n @report.export_report\n end",
"def start\n setup_files\n create_report\nend",
"def report\n ktlint_report_file_complete = \"#{Dir.pwd}/#{ktlint_report_file}\"\n detekt_report_file_complete= \"#{Dir.pwd}/#{detekt_report_file}\"\n\n check_file_integrity(ktlint_report_file_complete)\n check_file_integrity(detekt_report_file_complete)\n\n ktlint_issues = read_issues_from_report(ktlint_report_file)\n detekt_issues = read_issues_from_report(detekt_report_file)\n\n report_issues(ktlint_issues)\n report_issues(detekt_issues)\n end",
"def new_match_report\n @trials = Trial.all\n @sites = Site.all\n @import = Import.last\n mail( :to => ClinicalTrialMatcher::Application.config.import_report_recipient,\n :subject => 'Clinial Trial Import Report: ' + Time.new.strftime(\"%m/%d/%Y\") )\n end",
"def run\n @file_paths.each do |path|\n process_file(path)\n end\n @report\n end",
"def import\n Worker.import(params[:file])\n redirect_to tenant_workers_path(@tenant), notice: \"Worker list imported.\"\n end",
"def import\n scan_files\n # import non-imported files\n\tto_be_executed = Execution.where(:passerelle_id => @passerelle.id, :statut => \"nex\").order('created_at')\n\tto_be_executed.each{ |execution|\n\t\texecution.statut = \"ece\" #note : En Cours d'Execution\n\t\texecution.save!\n\t}\n\tto_be_executed.each{ |execution|\n\t\n\t\n\tbegin\n\t import_exe execution\n\t statut = \"ok\"\n\trescue Exception => e\n\t\t @rapport_import << \"Fail<\\br>\"\n\t\t @rapport_import << \"Error message => : #{e.message}<\\br>\"\n\t\t @rapport_import << \"Error backtrace => #{e.backtrace}<\\br>\"\n\t\t Logger.send(\"warn\",\"[Passerelle] Import FAIL !\")\n\t\t Logger.send(\"warn\",\"[Passerelle] Rapport : #{@rapport_import}\")\n\t\t statut = \"err\"\n\tend\n\t\t\n\t\texe_to_save = Execution.find execution.id\n\t\texe_to_save.statut = statut\n\t\texe_to_save.description = @result[:description]\n\t\texe_to_save.save!\n\t}\n @passerelle.updated_at = DateTime.now\n @passerelle.save!\n\t\n\tres = Hash.new\n\tres[\"updated\"] = true\n\t# res[\"message\"] = \"desc\"\n\t\n\treturn res\n end",
"def import(_, project)\n project.after_import\n report_import_time(project)\n end",
"def create\n begin\n\n ProcessCsvUploadService.call! nbs: report_params[:nbs_file].read,\n ovrs: report_params[:ovrs_file].read\n rescue => ex\n logger.error ex.message\n redirect_to new_report_path, alert: 'Failed to load files, csv format was not correct (csv headers may not be correct)'\n return\n end\n \n begin\n\n @report = BatchCompareService.call\n\n rescue => ex\n logger.error ex.message\n redirect_to new_report_path, alert: 'Failed to compare records, an error occured'\n return\n end\n\n begin\n if @report.save\n\n redirect_to @report, notice: 'Report was successfully created.'\n \n else\n redirect_to new_report_path, alert: 'Could not generate a report.'\n end\n rescue => ex\n logger.error ex.message\n redirect_to new_report_path, alert: 'Failed to save report, an error occured' \n end\n\n end",
"def run\n start_time = Time.now\n\n setup\n\n importer_run.update_attributes( started_at: start_time,\n source_model: source_model.name,\n destination_model: destination_model.name,\n importer_version: VERSION )\n\n # get a total count of records to process, bail out if none are found\n count = base_query(false).count\n\n logger.info \"\"\n if count == 0\n logger.info \"no #{source_model.name.pluralize} to import, exiting\"\n return\n end\n\n logger.info \"Starting import from #{source_model.table_name} into #{destination_model.name}...\"\n\n # step through the records in batches\n (0..count).step(batch_size) do |offset|\n thread_pool.schedule do\n with_connections do\n batch_elapsed_time = Benchmark.realtime do\n logger.info \"Importing from #{source_model.table_name} into #{destination_model.name} (#{offset / batch_size + 1}/#{count / batch_size + 1})\"\n\n # wipe the slate from the last batch\n prepare_for_new_batch\n\n benchmarks[:source_db] << Benchmark.realtime do\n # grab this batch of records from source\n fetch_records(offset)\n end\n\n # bail if there aren't any\n next if records.empty?\n\n logger.info \" #{records.count} source records fetched in #{benchmarks[:source_db].last}s\"\n if source_order_by\n logger.info \" #{source_order_by}: from #{records.first.read_attribute(source_order_by)} to #{records.last.read_attribute(source_order_by)}\"\n end\n\n # process this batch of records\n process_batch(records)\n\n logger.info \" #{records.count} records processed in #{benchmarks[:processing].last}s\"\n\n insert_and_update_batch\n end\n logger.info \" batch processed in #{batch_elapsed_time}s\"\n end\n end\n end\n thread_pool.shutdown\n \n print_validation_errors\n\n logger.info \"-------------------------------------------------\"\n logger.info \"Processing: #{benchmarks[:processing].sum}s total, #{benchmarks[:processing].sum / count}s per record\"\n logger.info \"source Database: #{benchmarks[:source_db].sum}s total, #{benchmarks[:source_db].sum / count}s per record\"\n logger.info \"dest Database: #{benchmarks[:destination_db].sum}s total, #{benchmarks[:destination_db].sum / count}s per record\"\n logger.info \"Total: #{Time.now - start_time}s elapsed\"\n importer_run.update_attributes( completed_at: Time.now )\n rescue Exception => e\n importer_run.update_attributes( error_trace: \"#{e.class} - #{e.message}\\n#{e.backtrace.join(\"\\n\")}\" )\n raise e\n ensure\n importer_run.update_attributes( records_created: records_created,\n records_updated: records_updated,\n duration: ((Time.now - start_time) * 1000).round,\n validation_errors: validation_errors )\n end",
"def create\n @import_results = TextImporter.new.import_from_file(file.open)\n\n respond_to do |format|\n if @import_results\n format.html { redirect_to imported_purchases_url(@import_results.purchases.first, @import_results.purchases.last),\n notice: 'Purchases successfully imported.' }\n format.json { render action: 'show', status: :created, location: @import_results.total }\n else\n format.html { render action: 'new' }\n format.json { render json: @import_result.errors, status: :unprocessable_entity }\n end\n end\n end",
"def perform\n import = TransportPassengerImport.find self.id\n import.update_attributes(:status => 1)\n load_all_data\n @rollback = false\n @errors = Array.new\n ActiveRecord::Base.transaction do\n import_csv(import.attachment.to_file)\n raise ActiveRecord::Rollback if @rollback\n end\n if @errors.present?\n import.update_attributes(:status => 4, :last_message => @errors)\n else\n import.update_attributes(:status => 2, :last_message => nil)\n end\n rescue Exception => e\n import.update_attributes(:status => 3, :last_message => ['-', e.message])\n end",
"def import!\n t = Thread.new do\n begin\n do_import\n rescue Exception => ex\n Rails.logger.error \"ERROR in import thread: #{ex.inspect}\"\n throw ex\n end\n end\n at_exit { t.join }\n t\n end",
"def import(filename)\n logger.info \"#{Time.now} start import #{self.class.display_name}\"\n logger.info \"id=#{id} filename=#{filename}\"\n\n #Proccess\n\n logger.info \"#{Time.now} end import #{self.class.display_name}\"\n end",
"def import\n @scenario.import\n respond_to do |format|\n format.html { redirect_to scenarios_url, notice: 'Scenario was successfully imported.' }\n format.json { head :no_content }\n end\n end",
"def importer\n Importer.new context\n end",
"def run( uri, test = false )\n \n login\n internal_puts 'running report...'\n \n # Convert the report to only return a csv\n uri = RDTQuery.new( uri )\n uri[ 'givecsvonly' ] = 'Yes'\n \n # Get the report page from our list of arguments\n page = agent.get( uri.to_s )\n \n # Wait until the session ID shows up with our CSV link (AJAX)\n regex = /[\\w\\/]+#@sess[\\w\\/\\.]+/\n internal_puts 'waiting for download link'\n wait_for_it( 60, MechReporterTimeout.new( 'Failed to find CSV download link.' ) ) { page.body =~ regex }\n filename = page.body.match( regex ).to_s\n \n internal_puts 'downloading report file...'\n \n # Download & Interpret the CSV, and drop the data into RubyExcel\n RubyExcel::Workbook.new.load( CSV.parse( agent.get('http://' + domain + filename ).content ) )\n end",
"def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end",
"def report\n return @report\n end",
"def report\n @scan = find_scan( params.require( :id ) )\n\n format = URI( request.url ).path.split( '.' ).last\n render layout: false,\n content_type: FrameworkHelper.content_type_for_report( format ),\n text: FrameworkHelper.framework { |f| f.report_as format, @scan.report.object }\n end",
"def create\n @import_batch = TransloaditParser.parse_recordings( params[:transloadit], @account.id, current_user )\n flash[:info] = \"Import completed\" \n redirect_to account_import_batch_path(@account, @import_batch)\n end",
"def data_import\n message = I18n.t(\"ag2_human.import.index.result_ok_message_html\")\n @json_data = { \"DataImport\" => message, \"Result\" => \"OK\" }\n # $alpha = \"\\xC1\\xC9\\xCD\\xD3\\xDA\\xDC\\xD1\\xC7\\xE1\\xE9\\xED\\xF3\\xFA\\xFC\\xF1\\xE7\\xBF\\xA1\\xAA\\xBA\".force_encoding('ISO-8859-1').encode('UTF-8')\n # $gamma = 'AEIOUUNCaeiouunc?!ao'\n # $ucase = \"\\xC1\\xC9\\xCD\\xD3\\xDA\\xDC\\xD1\\xC7\".force_encoding('ISO-8859-1').encode('UTF-8')\n # $lcase = \"\\xE1\\xE9\\xED\\xF3\\xFA\\xFC\\xF1\\xE7\".force_encoding('ISO-8859-1').encode('UTF-8')\n # $positions = \"presidentedirectorjeferesponsablegerentetecnicoauxauxiliaradmadminadministrativoadministrativa\"\n incidents = false\n message = ''\n first_name = ''\n last_name = ''\n\n # Read parameters from data import config\n data_import_config = DataImportConfig.find_by_name('workers')\n source = source_exist(data_import_config.source, nil)\n if source.nil?\n message = I18n.t(\"ag2_human.import.index.result_error_message_html\")\n @json_data = { \"DataImport\" => message, \"Result\" => \"ERROR\" }\n render json: @json_data\n return\n end\n # Loop thru 'empresa' records\n empresa = DBF::Table.new(source + \"empresa.dbf\")\n empresa.each do |e|\n # Do not import deleted 'empresa'\n if e.nil?\n next\n end\n # Search linked office\n office = Office.find_by_nomina_id(e.ccodemp)\n if !office.nil?\n company = office.company\n # Loop thru 'trabaja.dbf' records for current 'empresa/company' record\n source = source_exist(data_import_config.source, e.ccodemp)\n if !source.nil?\n # Import account code\n cctagene = nil\n empnomi = DBF::Table.new(source + \"empnomi.dbf\")\n enf = empnomi.first\n if !enf.nil?\n cctagene = enf.cctagene\n end\n # Import workers\n trabaja = DBF::Table.new(source + \"trabaja.dbf\")\n trabaja.each do |t|\n # Do not import deleted worker\n if t.nil?\n next\n end\n # Do not import worker with active withdrawal date\n if !t.dfecbaj.blank? && t.dfecbaj <= DateTime.now.to_date\n next\n end\n # Setup nomina_id & fiscal_id\n nomina_id = e.ccodemp + '-' + t.ccodtra\n fiscal_id = sanitize_string(t.cdni, true, false, false, false) unless t.cdni.blank?\n # Store names for error messages\n first_name = sanitize_string(t.cnomtra, true, false, false, true) unless t.cnomtra.blank?\n last_name = sanitize_string(t.capetra, true, false, false, true) unless t.capetra.blank?\n # Maybe worker & item exist\n new_worker = false\n new_worker_item = false\n new_worker_salary = false\n # Search for worker by fiscal_id\n worker = Worker.find_by_fiscal_id(fiscal_id)\n if worker.nil?\n # Yes, it's new, but do not import new worker with blank email\n if t.cemail.blank?\n next\n end\n # New worker\n new_worker = true\n new_worker_item = true\n new_worker_salary = true\n worker = Worker.new\n worker_item = WorkerItem.new\n worker_salary = WorkerSalary.new\n # Initialize worker (fiscal_id) & worker item (nomina_id)\n worker.fiscal_id = fiscal_id\n worker_item.nomina_id = nomina_id\n else # Worker exists, check for item\n # Search for worker_item by nomina_id\n worker_item = WorkerItem.find_by_nomina_id(nomina_id)\n if worker_item.nil?\n # New worker_item\n new_worker_item = true\n new_worker_salary = true\n worker_item = WorkerItem.new\n worker_salary = WorkerSalary.new\n # Initialize worker item (nomina_id)\n worker_item.nomina_id = nomina_id\n end\n end\n # Update worker first\n worker = update_worker(worker, t, company, office, new_worker, cctagene)\n # And then worker item\n worker_item = update_worker_item(worker_item, t, company, office, new_worker_item, cctagene)\n # Try save them\n if worker.user_id > 0\n # Save worker\n if !worker.save\n # Error: Workers Updater finished unexpectedly!\n incidents = true\n message += \"<br/>\".html_safe + e.ccodemp + \" - \" + last_name + \" \" + first_name + \" - \" + t.cemail\n #break # Import cancelled at company level\n else\n # Save worker item\n if new_worker_item\n worker_item.worker_id = worker.id\n end\n if !worker_item.save\n # Error: Workers Updater finished unexpectedly!\n incidents = true\n message += \"<br/>\".html_safe + e.ccodemp + \" - \" + last_name + \" \" + first_name + \" - \" + t.cemail\n else\n if new_worker_salary\n # Save worker salary\n worker_salary.worker_item_id = worker_item.id\n worker_salary.year = Date.today.year\n worker_salary.gross_salary = t.nbruto unless t.nbruto.blank?\n if !worker_salary.save\n # Error: Workers Updater finished unexpectedly!\n incidents = true\n message += \"<br/>\".html_safe + e.ccodemp + \" - \" + last_name + \" \" + first_name + \" - \" + t.cemail\n end # worker_salary.save if\n end # new_worker_salary if\n end # worker_item.save if\n end # worker.save if\n end # worker.user_id if\n end # trabaja do\n end # source if\n end # office if\n end # empresa do\n if incidents\n message = I18n.t(\"ag2_human.import.index.result_ok_with_error_message_html\") + message\n @json_data = { \"DataImport\" => message, \"Result\" => \"ERROR\" }\n end\n render json: @json_data\n end",
"def analyze\n log_files = FileGate.filter(:log, @file_names)\n\n if log_files.any?\n analysis_config = APP_CONFIG[:analysis_config]\n analysis_types = analysis_config[:import_defaults].gsub(' ', '').split(',')\n analysis_types.each do |type|\n AnalysisService.new(type: type).analyze\n end\n info = \"+analysis: #{analysis_types}\"\n else\n info = \".no analysis run (no logs included in import)\"\n end\n\n self.results << info\n logger.info info\n end",
"def import\n url = \"#{self.url}/import?auth=#{self.authtoken}\"\n status, response = rest_post( url, nil )\n if ok?( status )\n return status, response['new_count'], response['update_count'], response['duplicate_count'], response['error_count']\n end\n return status, 0, 0, 0, 0\n end",
"def import!\n # TODO: this should only create a competitor if in the correct \"mode\"\n competitor = matching_competitor\n if competitor.nil? && EventConfiguration.singleton.can_create_competitors_at_lane_assignment\n registrant = matching_registrant\n competition.create_competitor_from_registrants([registrant], nil)\n competitor = competition.find_competitor_with_bib_number(bib_number)\n end\n\n tr1 = build_result_from_imported(minutes_1, seconds_1, thousands_1, status_1)\n tr1.competitor = competitor\n tr1.is_start_time = is_start_time\n tr1.save!\n\n if minutes_2\n tr2 = build_result_from_imported(minutes_2, seconds_2, thousands_2, status_2)\n tr2.competitor = competitor\n tr2.is_start_time = is_start_time\n tr2.save!\n end\n end",
"def report\n @scan = find_scan( params.require( :id ) )\n\n format = URI( request.url ).path.split( '.' ).last\n render layout: false,\n text: FrameworkHelper.\n framework { |f| f.report_as format, @scan.report.object }\n end",
"def import_job\n return nil if completed?\n logger.info '** SieImport start'\n parse_and_import = Services::ImportSie.new(self)\n logger.info '** SieImport start - 1'\n if parse_and_import.read_and_save(sie_type)\n logger.info \"** SieImport #{id} parse/import returned ok, marking complete\"\n complete\n else\n logger.info \"** SieImport #{id} parse/import did NOT return ok, not marking complete\"\n end\n end",
"def import(options = {})\n project_id = options[\"id\"]\n if project_id.nil?\n $stderr.puts \"\\nError: import requires a --project argument\"\n raise OptionParser::InvalidOption\n end\n\n stories = Project.new(project_id).stories\n stories_imported = 0\n Jira.new(options).bugs.each do |issue|\n story_exists = stories.find { |s| s.jira_id == issue.jira_id }\n if story_exists\n @logger.debug \"- Already imported JIRA issue: #{issue.jira_id}\"\n else\n issue = Jira.find(issue.jira_id)\n story = Story.from_jira(project_id, issue)\n story.add\n stories_imported += 1\n story.notes.each { |note| story.add_note(note) }\n end\n end\n\n @logger.info \"JIRA: #{stories_imported} #{(stories_imported == 1) ? 'story' : 'stories'} imported\"\n end",
"def create\n records = if file_upload?\n case file_upload_params['records']['file'].content_type\n when 'text/xml' then FileParser::XMLRecordParser.call( file_upload_params['records']['file'].path )\n when 'text/csv' then FileParser::CSVRecordParser.call( file_upload_params['records']['file'].path )\n when 'application/json' then FileParser::JSONRecordParser.call( file_upload_params['records']['file'].path )\n end\n else # non file upload\n form_submission_params['records'].is_a?(Array) ? form_submission_params['records'] : [ form_submission_params['records'] ]\n end\n\n begin\n @report = ReportCreator.new(records).results\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @report, status: :ok }\n end\n rescue => exception\n respond_to do |format|\n redirect_to :new, error: \"Invalid Information\", status: :unprocessable_entity\n\n format.json { render status: :unprocessable_entity }\n end\n end\n end",
"def import\n #throws error if importing csv file fails\n begin\n Category.import\n notice = \"Import Complete\"\n rescue\n notice = \"There was an error whilst importing!\"\n ensure\n redirect_to start_path, notice: notice\n end\n end",
"def run\n case @options.scan_type\n when :directory\n scan_dirs\n parse_files\n excel_report\n when :file\n @scan_files = Array.new\n @scan_files << @options.scan_file\n parse_files\n excel_report\n end\n end",
"def run\n Salesforce.set_http(session[:accesstoken], session[:accessurl])\n \t@response = Salesforce.run_report(params)\n @describe = Salesforce.describe_report(params)\n \trespond_to do |format|\n format.json { render :json => {:data => @response, :meta => @describe}.to_json}\n \tend\n end",
"def run\n connect if cn.state.zero?\n sql || get_sql\n replace_placeholders\n \n # If we already hold a Sheet\n if result \n \n # Take the Workbook which holds the current Sheet\n rwb = result.parent\n \n # Run the Report and bring back a new Sheet\n self.result = query( sql )\n \n # Add the new Sheet onto the existing Workbook\n rwb << result\n \n else\n \n # Create a new Sheet\n self.result = query( sql )\n \n end\n \n # Use the SQL report naming convention to guess at a sheet name.\n # Max Sheet name length in Excel is 31 characters.\n result.name = clean_name if name\n \n # Set the result to be invisible by default\n result.parent.standalone = true\n \n # Return the Sheet\n result\n \n end",
"def start\n self.started_at = Time.zone.now\n save\n instance = name.constantize.new(self)\n instance.start\n rescue => e\n Rails.logger.error \"ImportJob '#{name}' failed: #{e.message}\"\n Rails.logger.error e\n\n # rubocop:disable Style/RedundantSelf\n if !self.result.is_a?(Hash)\n self.result = {}\n end\n self.result[:error] = e.message\n # rubocop:enable Style/RedundantSelf\n ensure\n self.finished_at = Time.zone.now\n save\n end",
"def create\n @run = Run.new(params[:run])\n @project = Project.find(params[:run][:project_id])\n @run.import_project(@project)\n\n respond_to do |format|\n if @run.save\n format.json { render :json => @run, :status => :created, :location => @run }\n format.html { redirect_to(runs_path) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @run.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @import_job = ImportJob.find(params[:import_job_id])\n # if job is running, stay on the current step\n if @import_job.running?\n @status = 'running'\n render_wizard\n return\n end\n\n # if job is failed, show the errors\n handle_step\n render_wizard\n end",
"def run\n self.report_type = :daily_tasks\n self.failures = []\n\n EmailSubmission.where(\n created_at: Date.yesterday...Date.current\n ).joins(:c100_application).find_each(batch_size: 25) do |record|\n reference_code = record.c100_application.reference_code\n\n find_failures(record, reference_code, COURT_EMAIL_TYPE)\n\n # Only if the applicant chose to receive a confirmation, otherwise\n # these emails are not sent and there is no need to do any check.\n find_failures(record, reference_code, USER_EMAIL_TYPE) if record.c100_application.receipt_email?\n end\n\n send_email_report if failures.any?\n end",
"def perform(import, group_ids)\n\n filepath = import.file.current_path\n user = import.user\n\n puts \"Prepare to import #{filepath} ...\"\n\n #faz um array de grupos validos do usuario\n groups = []\n group_ids.each do |g|\n if user.groups.exists?(g)\n groups.push Group.find(g)\n end\n end if group_ids.length > 0\n\n begin\n #le todas as linhas do csv\n lines = CSV.read filepath, headers: true, col_sep: import.separator\n\n #atualiza o numero de linhas de contatos para importar\n import.update! contacts_count: lines.count\n\n #hash de colunas dos contatos\n contacts_columns = Contact.column_names.reject{|key| key==\"id\"}\n\n lines.each_with_index do |row, row_n|\n\n #verifica se a chave da coluna do csv é uma coluna na tabela\n row = row.to_hash\n row.select! do |key,_|\n contacts_columns.include? key\n end\n\n contact = Contact.new row\n contact.user_id = import.user_id\n if contact.valid?\n #se tem grupos para por os contatos\n if groups.size > 0\n groups.each do |group|\n group.contacts << contact\n end\n else\n #para os contatos do usuario\n user.contacts << contact\n end\n else\n #escreve os erros no import_infos caso o contato não seja valido\n contact.errors.full_messages.each do |message|\n error = \"Um problema ocorreu na linha #{row_n+1}, #{message}\"\n import.import_infos.create! message: error\n puts error\n end\n end\n end\n\n puts \"Import #{filepath} completed\"\n ensure\n #atualiza a importação para terminado\n import.done!\n #envia a notificação para view do usuario usando o pusher\n Pusher[user.id.to_s].trigger('import_group_done', {:status => 'success', :message => \"A importação do arquivo #{import.file.identifier} está pronto!\"})\n\n puts \"Job completed with problems!\"\n end\n\n\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 import\n if params[:file].present?\n status = Device.import(params[:file])\n flash[status[:alert]] = status[:message]\n\n respond_with(status, location: device_manage_path)\n else\n flash[:danger] = 'You need to upload at least one document (.xls / .csv / .xlsx)'\n\n respond_with(params[:file], location: device_manage_path)\n end\n end",
"def execute\n uri = URI.parse(\"https://analyticsreporting.googleapis.com/v4/reports:batchGet\")\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = true\n # https.set_debug_output($stdout)\n request = Net::HTTP::Post.new(uri.request_uri,\n \"Content-Type\" => \"application/json\",\n \"Authorization\" => \"Bearer #{access_token}\")\n request.body = query.to_json\n Response.new(https.request(request))\n end",
"def import\n Gift.import(params[:file], params[:activity])\n redirect_to import_export_url, notice: \"Gifts imported.\"\n end",
"def start_importation!\n if can?(:import)\n importing!\n Courses::ImportJob.perform_later self\n end\n end",
"def create\n @import = Import.new(import_params)\n\n respond_to do |format|\n if @import.save\n format.html { redirect_to courses_path, notice: 'Datei erfolgreich importiert.' }\n format.json { render action: 'show', status: :created, location: @import }\n else\n format.html { render action: 'new' }\n format.json { render json: @import.errors, status: :unprocessable_entity }\n end\n end\n import_file(@import)\n end",
"def run(limit, offset)\n timestamp = Time.now.utc.iso8601.gsub(/\\W/, '')\n @log = File.open(\"import_#{timestamp}.log\", 'w')\n create_indexes\n load_institutions\n import_objects(limit, offset)\n import_work_items(limit, offset)\n @log.close\n end",
"def call(_obj, args, ctx)\n if ctx[:current_user].blank?\n raise GraphQL::ExecutionError.new(\"Authentication required\")\n end\n\n # only admins can do mass imports\n unless ctx[:current_user].admin\n raise GraphQL::ExecutionError.new(\"You do not have permission to do bulk uploads\")\n end\n\n model_name_to_model = {\n 'cataloger' => Cataloger,\n 'collection' => Collection,\n 'composer' => Composer,\n 'country' => Country,\n 'director' => Director,\n 'production_company' => ProductionCompany,\n 'repository' => Repository,\n 'resource' => Resource,\n 'work' => Work,\n }\n\n unless model_name_to_model[args[:model]]\n raise GraphQL::ExecutionError.new(\"Model not recognized or not suitable for bulk import. Import failed\")\n end\n\n import(\n model_name_to_model[args[:model]],\n args[:file].tempfile,\n ctx[:current_user]\n )\n end",
"def delegate_import\n if Rails.env == 'development'\n # use local file path on development\n csv = open(self.import.import_file.time_slots.path)\n else\n # use s3 file on production\n csv = open_tmp_file(self.import.import_file.time_slots.url)\n end\n\n\n # Send file to attendance module using import api\n # The last two headers are: vacancy (it doesn't matter) and school_id (already imported)\n response = RestClient.post Attendance::HOST + '/api/v0/imports',\n app_key: Attendance::API_KEY,\n account_name: self.import.account.name,\n import: {\n object: 'TimeSlot',\n csv_file: csv,\n headers: headers\n }\n if response.code == 201\n # If import was created successfully create a time_slot importer\n #that will show the status of this import\n remote_import_id = JSON.parse(response.body)['id']\n self.update_attributes(status_url: Attendance::HOST + '/api/v0/imports/' + remote_import_id.to_s)\n end\n end",
"def main_build_loop\n @import = Import.find_or_create_by(name: IMPORT_NAME) \n @import.metadata ||= {} \n handle_projects_and_users(@data, @import)\n raise '$project_id or $user_id not set.' if $project_id.nil? || $user_id.nil?\n handle_namespaces(@data, @import)\n handle_preparation_types(@data, @import)\n handle_controlled_vocabulary(@data, @import)\n\n handle_people(@data, @import) ## !created as new\n\n handle_taxa(@data, @import)\n\n checkpoint_save(@import) if ENV['no_transaction']\n\n # !! The following can not be loaded from the database they are always created anew.\n handle_collecting_events(@data, @import)\n handle_specimens(@data, @import)\n\n # handle_users(@data, @import)\n\n @import.save!\n puts \"\\n\\n !! Success \\n\\n\"\n end",
"def perform(report_id)\n report = Report.find(report_id)\n\n # Check if the report is already being processed or was processed (it has a parser_status)\n return if report.parser_status\n\n report.update!(parser_status: 'parsing')\n\n # Start a timeout worker for the parser\n ReportWorker::Parser::TimeoutChecker.perform_in(ReportWorker::Parser::TimeoutChecker::PARSING_TIMEOUT, report.id)\n\n parsers_for(report.data[\"reporter\"][\"type\"]).each do |parser|\n begin\n parser::REQUIRE.each do |requirement|\n raise InformationMissing, \"The #{parser} parser requires information from the #{requirement} collector.\" unless report.data[requirement.to_s]\n end\n p = parser.new(report)\n p.analyze\n # refresh the report object, in case the parser made any changes to it\n report.reload\n rescue => exception\n report.update!(parser_status: 'failure')\n raise exception\n end\n end\n\n # Everything went well\n report.update!(parser_status: 'success')\n end",
"def run\n print_line\n print_status 'Creating HTML report...'\n\n plugins = format_plugin_results( auditstore.plugins )\n @base_path = File.dirname( options['tpl'] ) + '/' +\n File.basename( options['tpl'], '.erb' ) + '/'\n\n title_url = auditstore.options['url']\n begin\n title_url = uri_parse( auditstore.options['url'] ).host\n rescue\n end\n\n params = prepare_data.merge(\n title_url: escapeHTML( title_url ),\n audit_store: auditstore,\n plugins: plugins,\n base_path: @base_path\n )\n\n File.open( outfile, 'w' ) { |f| f.write( erb( options['tpl'], params ) ) }\n\n print_status \"Saved in '#{outfile}'.\"\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = ReportPostResultSet.new(resp)\n return results\n end",
"def create\n return redirect_to(ticket_sales_imports_path, :alert => 'Please choose a will-call list to upload.') if params[:file].blank?\n @import = TicketSalesImport.new(ticketsalesimport_params)\n @import.processed_by = current_user\n return redirect_to(ticket_sales_imports_path(:vendor => @import.vendor), :alert => @import.errors.as_html) unless @import.valid?\n @import.parser.parse or return redirect_to(ticket_sales_imports_path(:vendor => @import.vendor), :alert => @import.errors.as_html)\n @import.save or return redirect_to(ticket_sales_imports_path(:vendor => @import.vendor), :alert => @import.errors.as_html)\n redirect_to edit_ticket_sales_import_path(@import), :alert => (@import.warnings.as_html if [email protected]?)\n end",
"def create_import\n begin\n @computers = ComputerService.import(params[:computer],current_unit)\n rescue NoMethodError\n end\n \n unless @computers.nil?\n @total = @computers.count\n # Save each computer. If it doesn't save, leave it out of the array\n @computers = @computers.collect {|e| e if e.save}.compact\n end\n \n respond_to do |format|\n if @computers.nil?\n flash[:error] = \"There was a problem while parsing the plist\"\n format.html { redirect_to import_new_computer_path }\n elsif @computers.count > 0\n flash[:notice] = \"#{@computers.count} of #{@total} computers imported into #{@computers.first.computer_group}\"\n format.html { redirect_to computers_path }\n else\n flash[:warning] = \"Zero computers were imported. Did the ARD list have any members?\"\n format.html { redirect_to computers_path }\n end\n end\n end",
"def import_statement\n if params[:file_upload] && params[:file_upload][:file]\n csv_text = params[:file_upload][:file].read\n file_name = params[:file_upload][:file].original_filename\n StatementImportHelper.process_statement(current_user, @ledger_account, csv_text, file_name)\n flash[:notice] = \"File has been uploaded successfully\"\n end\n respond_with @ledger_account\n end",
"def import(date, file, min_page = 0, max_page)\r\n\r\n \tputs \"Importing data from: #{file}\"\r\n\r\n # Load date\r\n @date = date\r\n\r\n # Regex patterns\r\n id_regex = /^(0|\\d{6,9}|\\d{12,13}|X{13}|UPI\\d{8,10}(?:\\/\\d)?|U\\/I-\\d{4}\\/\\d{2}|UF\\/I\\d{4}\\/\\d{2}|\\d{2,3}-\\d{1,7}-\\d{1,7}(?:[\\/|\\-|\\s]\\d{1,4})?)$/\r\n\r\n # output dir\r\n out_dir = File.join(Rails.root, \"db\", \"export\")\r\n Dir.mkdir(out_dir) if !Dir.exist?(out_dir)\r\n\r\n @banks = Set.new\r\n\r\n # Output CSV files\r\n @result_csv = CSV.open(File.join(out_dir, \"#{date}.csv\"), \"w\")\r\n\r\n owner_lines = []\r\n\r\n # Statistics\r\n @total = {}\r\n @total.default = 0\r\n\r\n @cases = [0, 0, 0, 0, 0, 0]\r\n\r\n start = Time.now\r\n \tPDF::Reader.new(file).pages.each_with_index do |page, page_num|\r\n \t\t#Skip first min_page\r\n next if page_num < min_page\r\n\r\n # Stop after max_page \r\n \t\tbreak if page_num > max_page\r\n\r\n @total[:pages] += 1\r\n\r\n \t\t\tpage.text.lines.each do |line|\r\n # skip empty lines\r\n \t\t\t\tif !line.strip!.blank?\r\n\r\n \t\t\t\t\t# Match owner ID - this is new owner\r\n \t\t\t\t\tif line =~ id_regex\r\n \t\t\t\t\t\t# parse and save owner info but skip first line\r\n \t\t\t\t\t\tparse(owner_lines) if !owner_lines.empty?\r\n\r\n \t\t\t\t\t\t# start capturing data for new owner\r\n \t\t\t\t\t\towner_lines = [$~[1]]\r\n # skip strings which are not accounts: headers and footers\r\n \t\t\t\t\telsif !(line =~ /Broj racuna/i || line =~ /^\\d{2}\\/\\d{2}\\/\\d{4}/ || line =~ /^JIB/) && (!owner_lines.empty?)\r\n \t\t\t\t\t\towner_lines << line.gsub(/\\s{2,}/,'\\t')\r\n \t\t\t\t\tend\r\n \t\t\t\tend\r\n \t\t\tend\r\n \t\tend\r\n\r\n @result_csv.close\r\n\r\n puts \"Statistics: #{@total.to_yaml}\\n#{@cases}\"\r\n puts \"Loading finished in: %3d:%04.2f\"%(Time.now-start).divmod(60.0)\r\n \tend",
"def initial_import(username, projectname)\n # set import status\n project = GithubRepo.find_by(github_user: username, project_name: projectname, user_id: current_user.id)\n\n if project.imported.nil? || !project.imported\n\n project.imported = 1\n project.save\n\n\n # encounter stop\n if Encounter.last\n Encounter.last.close\n end\n\n # new encounter\n import_campaign = Campaign.create({name: projectname,\n description: \"Imported Project for #{projectname}\",\n user_id: current_user.id\n })\n\n create_round(import_campaign, action_name, import_campaign)\n\n # import commits & issues\n list_commits username, projectname, Encounter.last, import_campaign\n list_issues username, projectname, Encounter.last, import_campaign\n\n\n end\n\n\n end",
"def create\n respond_to do |format|\n if @import.save\n\n if @import.file_file_name?\n @import.import\n end\n\n format.html { redirect_to(\"/users/edit#imports\", :notice => I18n.t('backend.actions.success_create', :model => I18n.t('activerecord.capitalized_models.import'))) }\n format.xml { render :xml => @import, :status => :created, :location => @import }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @import.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def run\n # Try to get the diff_filename and open it for the comparison\n # And if this is the first time the import is run, there wont be any diff_filename whatsoever, so we loop from the file directly =)\n get_diff_from_previous_file if @diff_filename.nil?\n \n # If this is run for the first time, we are not gonna have the diff_file, so\n # What we are doing is to read all of the lines, and put them under \"added\" section\n if (File.file? @diff_filename)\n # Parse the diff file\n parse_diff \n else\n # We read it from the file directly\n parse_file\n end\n \n # Return with the hash representation of the difference\n return self.line_diff\n end",
"def import\n Schedule.import(params[:file])\n redirect_to schedules_path, notice: \"Schedules imported successfully\"\n end",
"def report\n report_metrics\n report_resources\n if run_status.failed?\n report_backtrace\n end\n end",
"def import\n Project.import(params[:file])\n redirect_to students_path, notice: \"Projects imported.\"\n end",
"def report\n # generate_report()\n ReportWorker.perform_async(\"07-01-2018\", \"08-01-2018\")\n render \\\n json: {status: 'SUCCESS', message:'REQUEST TO GENERATE A REPORT ADDED TO THE QUEUE'},\n status: :ok\n end",
"def parse\n raise ERROR_FILE_NOT_SET if report.nil? || report.empty?\n raise format(ERROR_FILE_NOT_FOUND, report) unless File.exist?(report)\n\n Oga.parse_xml(File.read(report))\n end",
"def create\n bgeigie_import.user = current_user\n if bgeigie_import.save\n bgeigie_import.delay.process\n @result = bgeigie_import\n else\n @result = bgeigie_import.errors\n end\n respond_with @result, :location => bgeigie_import\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 run\n build_report if self.class.needs.all? { |l| library_available?(l) }\n data_for_server\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 fetch(id)\n response = api_get('/report/', query: {\n action: 'fetch',\n id: id\n })\n\n # check if report exist\n return unless response.parsed_response.keys.include?('ASSET_DATA_REPORT')\n\n Report.new(response.parsed_response)\n end"
] | [
"0.6796825",
"0.6345392",
"0.6336648",
"0.6246904",
"0.6195034",
"0.6164449",
"0.6162187",
"0.60573727",
"0.6048603",
"0.60405004",
"0.60405004",
"0.60405004",
"0.60405004",
"0.59835815",
"0.59653956",
"0.59631217",
"0.5943379",
"0.5909817",
"0.5909817",
"0.5909817",
"0.5909817",
"0.5909817",
"0.58705544",
"0.58565307",
"0.5803443",
"0.5790734",
"0.5790264",
"0.5789159",
"0.57706034",
"0.5754749",
"0.575235",
"0.57520217",
"0.57520217",
"0.5738282",
"0.5713638",
"0.5699124",
"0.5699035",
"0.5693256",
"0.5687977",
"0.5671298",
"0.5663786",
"0.5658002",
"0.5650244",
"0.5633307",
"0.56240046",
"0.5602107",
"0.5577495",
"0.5567633",
"0.55179113",
"0.5517872",
"0.5509442",
"0.5493996",
"0.5480527",
"0.5468799",
"0.5464565",
"0.54630303",
"0.54423094",
"0.54314166",
"0.54211056",
"0.54110634",
"0.5404259",
"0.5401642",
"0.5397338",
"0.5393307",
"0.5391146",
"0.5382913",
"0.53733706",
"0.5363366",
"0.53592974",
"0.5339573",
"0.5317947",
"0.53111064",
"0.530926",
"0.5306588",
"0.5303484",
"0.5301992",
"0.5300317",
"0.52947396",
"0.52936935",
"0.528946",
"0.5288798",
"0.52880526",
"0.52745634",
"0.52724284",
"0.52654475",
"0.52636427",
"0.525948",
"0.5255938",
"0.5253715",
"0.5250674",
"0.5238033",
"0.5236085",
"0.5234812",
"0.5229065",
"0.5224695",
"0.5223188",
"0.521725",
"0.5215488",
"0.51997125",
"0.5196308"
] | 0.62847245 | 3 |
GET /allocation_tests or /allocation_tests.json | def index
@allocation_tests = AllocationTest.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @allocations = Allocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @allocations }\n end\n end",
"def show\n @allocation = Allocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @allocation }\n end\n end",
"def get_ab_tests(opts = {})\n @transporter.read(:GET, '/2/abtests', {}, opts)\n end",
"def set_allocation_test\n @allocation_test = AllocationTest.find(params[:id])\n end",
"def allocation(id)\n connection.get do |req|\n req.url \"client/allocation/#{id}/stats\"\n end\n end",
"def test\n get(\"/help/test.json\")\n end",
"def test\n get(\"/help/test.json\")\n end",
"def index\n @resource_allocations = ResourceAllocation.scoped\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @resource_allocations }\n end\n end",
"def show\n @res_allocation = ResAllocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @res_allocation }\n end\n end",
"def destroy\n @allocation_test.destroy\n respond_to do |format|\n format.html { redirect_to allocation_tests_url, notice: \"Allocation test was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def index\n @allocations = Allocation.all\n end",
"def update\n respond_to do |format|\n if @allocation_test.update(allocation_test_params)\n format.html { redirect_to @allocation_test, notice: \"Allocation test was successfully updated.\" }\n format.json { render :show, status: :ok, location: @allocation_test }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @allocation_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n permitted_to! :inspect, Problem.find(params[:problem_id])\n @test_sets = TestSet.where(:problem_id => params[:problem_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @test_sets }\n end\n end",
"def create\n @allocation_test = AllocationTest.new(allocation_test_params)\n redirect_path = nil\n if not current_user.allocation_tests.any?\n redirect_path = new_gamble_path\n else\n redirect_path = survey_path\n end\n\n respond_to do |format|\n if @allocation_test.save\n format.html { redirect_to redirect_path}\n format.json { render :show, status: :created, location: @allocation_test }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @allocation_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n render status: :ok, json: @test_guide_scenarios\n end",
"def show\n @test_suite = TestSuite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_suite }\n end\n end",
"def index\n @allocations = Allocation.all.includes(:project).page(params[:page]).per(20)\n end",
"def index\n render status: :ok, json: @tests\n end",
"def test_list_agents\n login_as :oleg\n get :index\n assert_response :success\n assert_tag :tag => 'div', :content => /Add New Agent/\n assert_tag :tag => 'a', :attributes => {:href => /admin\\/users\\//}, :ancestor => {:tag => 'table'}\n # checking if 10 agents are displayed + 1 row for headers\n assert_tag :tag => \"table\", :children => {:count => 11, :only => {:tag => 'tr'}}\n \n get :index, :page => 10\n assert_response :success\n # checking if 10 agents are displayed + 1 row for headers\n assert_tag :tag => \"table\", :children => {:count => 11, :only => {:tag => 'tr'}}\n end",
"def index\n @test_runs = TestRun.accessible_by(current_ability).order(\"updated_at DESC\").page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @test_runs }\n end\n end",
"def show\n @resource_allocation = ResourceAllocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @resource_allocation }\n end\n end",
"def test_get_index\n get :index\n assert_response :success\n end",
"def test_show\n get '/category/1'\n end",
"def investigate\n puts \"\\nRequesting JSON from #{url} and testing\"\n tests.each_pair do |test, block|\n print \" - #{test}\\n\"\n check test, block\n end\n summary\n exit_status\n end",
"def new\n @allocation = Allocation.new params[:allocation]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @allocation }\n end\n end",
"def index\n render status: :ok, json: @test_guide_scenario_sas\n end",
"def test_index \n get :index \n assert_response :success \n end",
"def index\n @allocation_dates = AllocationDate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @allocation_dates }\n end\n end",
"def allocations(id)\n connection.get do |req|\n req.url \"job/#{id}/allocations\"\n end\n end",
"def listing\n tests = Test.where( user_id: test_params[:user_id] )\n all = TestSerializer.new.all_test(tests)\n return render json: all.as_json\n end",
"def show\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_plan }\n end\n end",
"def show\n @asset_allocation_history = AssetAllocationHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset_allocation_history }\n end\n end",
"def test_index\n get :index\n assert_response :success\n end",
"def test_index\n get :index\n assert_response :success\n end",
"def test_list_pools\n get '/pools'\n assert last_response.ok?\n end",
"def index\n #pseudo scope \n if params[:phone] \n @agencies = Agency.find_by_phone(params[:phone]);\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n else\n # Aqui estoy haciendo que el api responda en mas de 1 formato\n @agencies = Agency.all\n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end\n\n end \n end",
"def index\n @tests = Test.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tests }\n end\n end",
"def show\n\n\t\tsession[:return_to] ||= request.referer\n @allocation = Allocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @allocation }\n end\n end",
"def show\n @test_run = TestRun.accessible_by(current_ability).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_run }\n end\n end",
"def show\n render status: :ok, json: @test_guide_scenario_sa\n end",
"def test_basic_pages\n %w{ free lite hardcore ultimate }.each do |page|\n get page\n assert_response :success\n end\n end",
"def show\n @testbed_owner = TestbedOwner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testbed_owner }\n end\n end",
"def get_client_summary_for_tenant(args = {}) \n get(\"/tenants.json/backoffice/clients/summary/#{args[:tenantId]}\", args)\nend",
"def create\n @allocation = Allocation.new(allocation_params)\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: t(:allocation_created) }\n format.json { render :show, status: :created, location: @allocation }\n else\n format.html { render :new }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def index\n @test_environments = TestEnvironment.paginate(:page => params[:page])\n end",
"def show\n @testing_algorithm = TestingAlgorithm.find(params[:id])\n\n render json : @testing_algorithm\n end",
"def show\n @test_summary = TestSummary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_summary }\n end\n end",
"def testable\n require_parameters :resource\n\n resource=Project.by_key(params[:resource])\n not_found(\"Not found: #{params[:resource]}\") unless resource\n access_denied unless has_role?(:user, resource)\n\n testable = java_facade.testable(resource.key)\n json = {}\n if testable\n resource = testable.component\n json[:key] = resource.key\n json[:name] = resource.name if resource.name\n json[:longName] = resource.longName if resource.longName\n json[:coveredLines] = testable.testedLines\n\n json[:coverages] = testable.coverageBlocks.map do |coverage|\n test_case = coverage.testCase\n coverage_json = {}\n coverage_json[:lines] = coverage.lines\n coverage_json[:name] = test_case.name\n coverage_json[:status] = test_case.status.to_s if test_case.status\n coverage_json[:durationInMs] = test_case.durationInMs\n coverage_json[:testPlan] = test_case.testPlan.component.key\n\n coverage_json.delete_if { |k, v| v.nil? }\n coverage_json\n end\n\n end\n json.delete_if { |k, v| v.nil? }\n\n respond_to do |format|\n format.json { render :json => jsonp(json) }\n format.xml { render :xml => xml_not_supported }\n format.text { render :text => text_not_supported }\n end\n end",
"def index\n @usages = get_usages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usages }\n end\n end",
"def tests\n CircleCi.request(conf, \"#{base_path}/#{build}/tests\").get\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def show\n render status: :ok, json: @test_guide_scenario\n end",
"def index\n\t@instruction = Instruction.find( params[ :instruction_id ] )\n @testimonies = @instruction.testimonies.page( params[ :page ] ).per(20)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @testimonies }\n end\n end",
"def show\n @test = LoadTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test }\n end\n end",
"def index\n @assessment_insti_tests = AssessmentInstiTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_insti_tests }\n end\n end",
"def create\n @allocation = Allocation.new(params[:allocation])\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: 'Allocation was successfully created.' }\n format.json { render json: @allocation, status: :created, location: @allocation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @assertions = Assertion.all.sample(10)\n\n respond_to do |format|\n format.html\n format.json { render json: @assertions }\n end\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 index\n @fundamental_resource_pools = Fundamental::ResourcePool.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fundamental_resource_pools }\n end\n end",
"def allocation_test_params\n params.require(:allocation_test).permit(:test_id, :user_id,\n allocation_items_attributes: [:name, :points, :allocation_test_id])\n end",
"def show\n @test_run = TestRun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_run }\n end\n end",
"def gettestcoverage\n\tstandName = params[:release]\n\t# получаем список тестов\n\n\ttestlist = ''\n\tTCPSocket.open('172.20.5.130', 2000){ |client|\n\t# say Hello to server\n\tclient.puts \"MasterOnline\"\n\tclient.gets\n\tclient.puts \"master_set get_test_coverage \" + standName\n\t#workerList = JSON.parse(client.gets)\n\ttestlist = client.gets\n\tclient.puts \"master_set close_connection\"\n\t}\n\tputs \"TestcontrolController - gettestcoverage\"\n\ttest = '{\"dataArray\" : [{\"name\" : \"PriorityName\", \"value\" : [\"testName1\", \"testName2\", \"testName3\"]}, {\"name\" : \"PriorityName\", \"value\" : [\"testName1\", \"testName2\", \"testName3\"]}]}'\n\trender :text => testlist\n end",
"def index\n @assessment_practice_tests = AssessmentPracticeTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_practice_tests }\n end\n end",
"def index\n @allocation_masters = AllocationMaster.all\n end",
"def index\n @employing_units = EmployingUnit.page params[:page]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employing_units }\n end\n end",
"def create\n @allocation = Allocation.new(allocation_params)\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: 'Allocation was successfully created.' }\n format.json { render :show, status: :created, location: @allocation }\n else\n format.html { render :new }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def test_post_request_collection\n params = {\n size: 3,\n employmentTypeUris: ['/dk/atira/pure/person/employmenttypes/academic'],\n employmentStatus: 'ACTIVE'\n }\n response = client.persons.all_complex params: params\n assert_equal response.code, 200\n assert_instance_of HTTP::Response, response\n end",
"def show\n @allocation_date = AllocationDate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @allocation_date }\n end\n end",
"def index\n @software_tests = SoftwareTest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @software_tests }\n end\n end",
"def show\n @section_test = SectionTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_test }\n end\n end",
"def test\n get(\"/help/test\")\n end",
"def test_index\n assert_response 200\n end",
"def test_list_available_resources\n puts \"## list_available_resources (retrieveable SF objects) ##\"\n resp = Salesforce::Rest::AsfRest.xlist_available_resources()\n\n resp.each {|key, val| pp key + ' => ' + val.to_s}\n assert !resp.nil?\n end",
"def index(environments = Environment.active)\n respond_with(@environments = environments)\n end",
"def index\n render jsonapi: Seances::UseCases::FetchAll.new.call\n end",
"def index\n @nginxtests = Nginxtest.all\n end",
"def show\n @editability = Editability.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test }\n end\n end",
"def show\n @testcase = Testcase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @testcase }\n end\n end",
"def index\n @space = Space.find(params[:space_id])\n @leases = Lease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leases }\n end\n end",
"def show\n @test_page = TestPage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_page }\n end\n end",
"def test(*args)\n Gitlab::PrometheusClient.new(prometheus_client).ping\n\n { success: true, result: 'Checked API endpoint' }\n rescue Gitlab::PrometheusClient::Error => err\n { success: false, result: err }\n end",
"def test_read_all_info\n get '/v1/read_all?data=eyJOYW1lIjogIkVkdWFyZG8iLCAiQ291bnRyeSI6ICJCcmF6aWwiIH0%3D'\n assert last_response.ok?\n assert last_response.body.include?('Eduardo')\n assert last_response.body.include?('Brazil')\n end",
"def new\n @resource_allocation = ResourceAllocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource_allocation }\n end\n end",
"def test_get_invalid_metric_metric1\n get '/metric1/param1/param2/param3'\n assert_equal 404, last_response.status\n end",
"def index\n puts \"test/index\"\n ap params\n done 404\n end",
"def test_test_get_assets()\r\n # Parameters for the API call\r\n category = 'cryptocurrency'\r\n\r\n # Perform the API call through the SDK function\r\n result = self.class.controller.get_assets(category)\r\n\r\n # Test response code\r\n assert_equal(@response_catcher.response.status_code, 200)\r\n\r\n # Test headers\r\n expected_headers = {}\r\n expected_headers['content-type'] = 'application/json'\r\n\r\n assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))\r\n end",
"def test_home\n get '/'\n assert last_response.ok?\n data = JSON.parse(last_response.body)\n assert data.count > 0\n end",
"def test_all \n get :all\n assert_response :success\n assert_template 'all'\n\n\n end",
"def show\n @test10 = Test10.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test10 }\n end\n end",
"def show\n @assessment_practice_test = AssessmentPracticeTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@assessment_practice_test }\n end\n end",
"def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tester }\n end\n end",
"def destroy\n @allocation.destroy\n respond_to do |format|\n format.html { redirect_to allocations_url, notice: t(:allocation_deleted) }\n format.json { head :no_content }\n end\n end",
"def show\n @performance_test = PerformanceTest.find(params[:id])\n # @performance_test_results = @performance_test.performance_test_results\n @performance_test_results = PerformanceTestResult.show_query(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @performance_test }\n end\n end",
"def test_view_user_account\n get :view\n assert_response :not_found\n \n get :view, {:display_name => \"test\"}\n assert_response :success\n end",
"def show\n @test_result = TestResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_result }\n end\n end",
"def show\n @testdb = Testdb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testdb }\n end\n end",
"def show\n @organizational_unit = resource\n\n# @compliance = EmployeeComplianceStatusCubicle.query do\n# select :employee_id, :employee_name, :requirement_status, :all_measures\n# by :mandatory\n# where :requirement_id=>BSON::ObjectId(id)\n# order_by :compliant, :employee_name\n# end\n# puts resource.class.name.underscore + \"_id[\" + params[:id] + \"]\"\n\n if request.xhr?\n render :partial=>\"/admin/organizational_units/show\"\n else\n index\n end\n end",
"def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end"
] | [
"0.6131166",
"0.6069248",
"0.6000204",
"0.5999134",
"0.5969513",
"0.59063035",
"0.59063035",
"0.5813263",
"0.579941",
"0.5640044",
"0.5614283",
"0.56085396",
"0.5586211",
"0.5583955",
"0.5577205",
"0.5563409",
"0.55596966",
"0.55421823",
"0.5538621",
"0.55183303",
"0.55061877",
"0.5502933",
"0.5495155",
"0.5478911",
"0.5467583",
"0.54648066",
"0.5444522",
"0.54331344",
"0.54320246",
"0.5426941",
"0.54137343",
"0.54123956",
"0.5400491",
"0.5400491",
"0.5395789",
"0.5389934",
"0.5378299",
"0.53673685",
"0.536488",
"0.5357874",
"0.53546053",
"0.53539044",
"0.5335363",
"0.53265226",
"0.5321245",
"0.5318967",
"0.52948916",
"0.52938706",
"0.5291288",
"0.52879506",
"0.5284171",
"0.5279852",
"0.5276874",
"0.52711594",
"0.5260611",
"0.52576566",
"0.52443904",
"0.52380735",
"0.5236549",
"0.52351105",
"0.5234873",
"0.52340955",
"0.52181756",
"0.52078635",
"0.5206988",
"0.5203754",
"0.51970816",
"0.51914227",
"0.5188134",
"0.5180279",
"0.51596355",
"0.5148835",
"0.5140863",
"0.5138092",
"0.51374793",
"0.5135825",
"0.5135596",
"0.5117265",
"0.51112765",
"0.51108706",
"0.5104357",
"0.5103659",
"0.51022816",
"0.5094988",
"0.5091353",
"0.5089188",
"0.50880307",
"0.50872624",
"0.5087051",
"0.5085086",
"0.508064",
"0.5076309",
"0.5072042",
"0.50694525",
"0.5065577",
"0.5063545",
"0.5059246",
"0.50582945",
"0.5056613",
"0.50562346"
] | 0.7029506 | 0 |
GET /allocation_tests/1 or /allocation_tests/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @allocation_tests = AllocationTest.all\n end",
"def show\n @allocation = Allocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @allocation }\n end\n end",
"def allocation(id)\n connection.get do |req|\n req.url \"client/allocation/#{id}/stats\"\n end\n end",
"def set_allocation_test\n @allocation_test = AllocationTest.find(params[:id])\n end",
"def index\n @allocations = Allocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @allocations }\n end\n end",
"def show\n @res_allocation = ResAllocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @res_allocation }\n end\n end",
"def get_ab_tests(opts = {})\n @transporter.read(:GET, '/2/abtests', {}, opts)\n end",
"def update\n respond_to do |format|\n if @allocation_test.update(allocation_test_params)\n format.html { redirect_to @allocation_test, notice: \"Allocation test was successfully updated.\" }\n format.json { render :show, status: :ok, location: @allocation_test }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @allocation_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @test_suite = TestSuite.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_suite }\n end\n end",
"def new\n @allocation = Allocation.new params[:allocation]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @allocation }\n end\n end",
"def show\n @test_run = TestRun.accessible_by(current_ability).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_run }\n end\n end",
"def show\n @resource_allocation = ResourceAllocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @resource_allocation }\n end\n end",
"def destroy\n @allocation_test.destroy\n respond_to do |format|\n format.html { redirect_to allocation_tests_url, notice: \"Allocation test was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def show\n @asset_allocation_history = AssetAllocationHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset_allocation_history }\n end\n end",
"def index\n @resource_allocations = ResourceAllocation.scoped\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @resource_allocations }\n end\n end",
"def index\n permitted_to! :inspect, Problem.find(params[:problem_id])\n @test_sets = TestSet.where(:problem_id => params[:problem_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @test_sets }\n end\n end",
"def investigate\n puts \"\\nRequesting JSON from #{url} and testing\"\n tests.each_pair do |test, block|\n print \" - #{test}\\n\"\n check test, block\n end\n summary\n exit_status\n end",
"def show\n @test_summary = TestSummary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_summary }\n end\n end",
"def get_one\n test_data = @test.get_one\n return render json: test_data\n end",
"def show\n\n\t\tsession[:return_to] ||= request.referer\n @allocation = Allocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @allocation }\n end\n end",
"def show\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_plan }\n end\n end",
"def test\n get(\"/help/test.json\")\n end",
"def test\n get(\"/help/test.json\")\n end",
"def index\n @test_runs = TestRun.accessible_by(current_ability).order(\"updated_at DESC\").page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @test_runs }\n end\n end",
"def index\n render status: :ok, json: @test_guide_scenarios\n end",
"def show\n @allocation_date = AllocationDate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @allocation_date }\n end\n end",
"def show\n @test_run = TestRun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_run }\n end\n end",
"def show\n @testing_algorithm = TestingAlgorithm.find(params[:id])\n\n render json : @testing_algorithm\n end",
"def create\n @allocation_test = AllocationTest.new(allocation_test_params)\n redirect_path = nil\n if not current_user.allocation_tests.any?\n redirect_path = new_gamble_path\n else\n redirect_path = survey_path\n end\n\n respond_to do |format|\n if @allocation_test.save\n format.html { redirect_to redirect_path}\n format.json { render :show, status: :created, location: @allocation_test }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @allocation_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @allocations = Allocation.all\n end",
"def index\n render status: :ok, json: @tests\n end",
"def index\n @allocation_dates = AllocationDate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @allocation_dates }\n end\n end",
"def show\n @testbed_owner = TestbedOwner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testbed_owner }\n end\n end",
"def show\n render status: :ok, json: @test_guide_scenario_sa\n end",
"def index\n render status: :ok, json: @test_guide_scenario_sas\n end",
"def allocations(id)\n connection.get do |req|\n req.url \"job/#{id}/allocations\"\n end\n end",
"def index\n @allocations = Allocation.all.includes(:project).page(params[:page]).per(20)\n end",
"def show\n @test = LoadTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test }\n end\n end",
"def show\n @testcase = Testcase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @testcase }\n end\n end",
"def show\n render status: :ok, json: @test_guide_scenario\n end",
"def show\n @assessment_insti_test = AssessmentInstiTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@assessment_insti_test }\n end\n end",
"def index\n @assertions = Assertion.all.sample(10)\n\n respond_to do |format|\n format.html\n format.json { render json: @assertions }\n end\n end",
"def create\n @allocation = Allocation.new(allocation_params)\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: t(:allocation_created) }\n format.json { render :show, status: :created, location: @allocation }\n else\n format.html { render :new }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_client_summary_for_tenant(args = {}) \n get(\"/tenants.json/backoffice/clients/summary/#{args[:tenantId]}\", args)\nend",
"def index\n @assessment_insti_tests = AssessmentInstiTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_insti_tests }\n end\n end",
"def index\n\t@instruction = Instruction.find( params[ :instruction_id ] )\n @testimonies = @instruction.testimonies.page( params[ :page ] ).per(20)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @testimonies }\n end\n end",
"def test_inclusive_bounded_range_name_1_to_4_max_4\n header 'Range', 'name my-app-1..my-app-4; max=4'\n\n get '/'\n json_response = JSON.parse(last_response.body)\n\n assert last_response.ok?\n assert_equal Array, json_response.class\n assert_equal 4, json_response.count\n assert_equal 1, json_response.first['id']\n assert_equal 101, json_response.last['id']\n end",
"def show\n @assessment_practice_test = AssessmentPracticeTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@assessment_practice_test }\n end\n end",
"def index\n @tests = Test.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tests }\n end\n end",
"def show\n @editability = Editability.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test }\n end\n end",
"def index\n #pseudo scope \n if params[:phone] \n @agencies = Agency.find_by_phone(params[:phone]);\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n else\n # Aqui estoy haciendo que el api responda en mas de 1 formato\n @agencies = Agency.all\n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end\n\n end \n end",
"def show\n @test10 = Test10.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test10 }\n end\n end",
"def show\n @test_result = TestResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_result }\n end\n end",
"def create\n @allocation = Allocation.new(params[:allocation])\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: 'Allocation was successfully created.' }\n format.json { render json: @allocation, status: :created, location: @allocation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_exclusive_bounded_range_id_5_to_10_order_desc\n header 'Range', 'id ]5..10; order=desc'\n\n get '/'\n json_response = JSON.parse(last_response.body)\n\n assert last_response.ok?\n assert_equal Array, json_response.class\n assert_equal 5, json_response.count\n assert_equal 10, json_response.first['id']\n assert_equal 6, json_response.last['id']\n end",
"def show\n @section_test = SectionTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_test }\n end\n end",
"def test_show\n get '/category/1'\n end",
"def test_list_agents\n login_as :oleg\n get :index\n assert_response :success\n assert_tag :tag => 'div', :content => /Add New Agent/\n assert_tag :tag => 'a', :attributes => {:href => /admin\\/users\\//}, :ancestor => {:tag => 'table'}\n # checking if 10 agents are displayed + 1 row for headers\n assert_tag :tag => \"table\", :children => {:count => 11, :only => {:tag => 'tr'}}\n \n get :index, :page => 10\n assert_response :success\n # checking if 10 agents are displayed + 1 row for headers\n assert_tag :tag => \"table\", :children => {:count => 11, :only => {:tag => 'tr'}}\n end",
"def test_get_index\n get :index\n assert_response :success\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 listing\n tests = Test.where( user_id: test_params[:user_id] )\n all = TestSerializer.new.all_test(tests)\n return render json: all.as_json\n end",
"def testable\n require_parameters :resource\n\n resource=Project.by_key(params[:resource])\n not_found(\"Not found: #{params[:resource]}\") unless resource\n access_denied unless has_role?(:user, resource)\n\n testable = java_facade.testable(resource.key)\n json = {}\n if testable\n resource = testable.component\n json[:key] = resource.key\n json[:name] = resource.name if resource.name\n json[:longName] = resource.longName if resource.longName\n json[:coveredLines] = testable.testedLines\n\n json[:coverages] = testable.coverageBlocks.map do |coverage|\n test_case = coverage.testCase\n coverage_json = {}\n coverage_json[:lines] = coverage.lines\n coverage_json[:name] = test_case.name\n coverage_json[:status] = test_case.status.to_s if test_case.status\n coverage_json[:durationInMs] = test_case.durationInMs\n coverage_json[:testPlan] = test_case.testPlan.component.key\n\n coverage_json.delete_if { |k, v| v.nil? }\n coverage_json\n end\n\n end\n json.delete_if { |k, v| v.nil? }\n\n respond_to do |format|\n format.json { render :json => jsonp(json) }\n format.xml { render :xml => xml_not_supported }\n format.text { render :text => text_not_supported }\n end\n end",
"def index\n @usages = get_usages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usages }\n end\n end",
"def show\n @test = Test.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test }\n end\n end",
"def create\n @allocation = Allocation.new(allocation_params)\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: 'Allocation was successfully created.' }\n format.json { render :show, status: :created, location: @allocation }\n else\n format.html { render :new }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @organizational_unit = resource\n\n# @compliance = EmployeeComplianceStatusCubicle.query do\n# select :employee_id, :employee_name, :requirement_status, :all_measures\n# by :mandatory\n# where :requirement_id=>BSON::ObjectId(id)\n# order_by :compliant, :employee_name\n# end\n# puts resource.class.name.underscore + \"_id[\" + params[:id] + \"]\"\n\n if request.xhr?\n render :partial=>\"/admin/organizational_units/show\"\n else\n index\n end\n end",
"def show\n @tester = Tester.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tester }\n end\n end",
"def new\n @resource_allocation = ResourceAllocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource_allocation }\n end\n end",
"def index\n @assessment_practice_tests = AssessmentPracticeTest.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@assessment_practice_tests }\n end\n end",
"def show\n @performance_test = PerformanceTest.find(params[:id])\n # @performance_test_results = @performance_test.performance_test_results\n @performance_test_results = PerformanceTestResult.show_query(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @performance_test }\n end\n end",
"def test_get_invalid_metric_metric1\n get '/metric1/param1/param2/param3'\n assert_equal 404, last_response.status\n end",
"def test_list_pools\n get '/pools'\n assert last_response.ok?\n end",
"def test_index \n get :index \n assert_response :success \n end",
"def get_kubernetes_aci_cni_tenant_cluster_allocation_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.get_kubernetes_aci_cni_tenant_cluster_allocation_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.get_kubernetes_aci_cni_tenant_cluster_allocation_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/AciCniTenantClusterAllocations/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', '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] || 'KubernetesAciCniTenantClusterAllocation'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.get_kubernetes_aci_cni_tenant_cluster_allocation_by_moid\",\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: KubernetesApi#get_kubernetes_aci_cni_tenant_cluster_allocation_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def set_allocation\n @allocation = Allocation.find(params[:id])\n end",
"def set_allocation\n @allocation = @license.allocations.find(params[:id])\n end",
"def test_inclusive_unbounded_range_id_1_order_desc\n header 'Range', 'id 1..; order=desc'\n\n get '/'\n json_response = JSON.parse(last_response.body)\n\n assert last_response.ok?\n assert_equal Array, json_response.class\n assert_equal 200, json_response.count\n assert_equal 201, json_response.first['id']\n assert_equal 2, json_response.last['id']\n end",
"def show\n @testdb = Testdb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @testdb }\n end\n end",
"def test_unbounded_range\n header 'Range', 'id ..'\n\n get '/'\n json_response = JSON.parse(last_response.body)\n\n assert last_response.ok?\n assert_equal Array, json_response.class\n assert_equal 200, json_response.count\n assert_equal 1, json_response.first['id']\n assert_equal 200, json_response.last['id']\n end",
"def new\n @asset_allocation_history = AssetAllocationHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asset_allocation_history }\n end\n end",
"def get_single_job_sample(client)\n response = client[\"jobs/#{$job_id}\"].get\n\n p ''\n p 'Get single job'\n p response\nend",
"def show\n @comparison = Comparison.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comparison }\n end\n end",
"def show\n @ref_diagnostic_test_type = Ref::DiagnosticTestType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ref_diagnostic_test_type }\n end\n end",
"def index\n @employing_units = EmployingUnit.page params[:page]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employing_units }\n end\n end",
"def show\n @test_page = TestPage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @test_page }\n end\n end",
"def show\n @software_test = SoftwareTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @software_test }\n end\n end",
"def gettestcoverage\n\tstandName = params[:release]\n\t# получаем список тестов\n\n\ttestlist = ''\n\tTCPSocket.open('172.20.5.130', 2000){ |client|\n\t# say Hello to server\n\tclient.puts \"MasterOnline\"\n\tclient.gets\n\tclient.puts \"master_set get_test_coverage \" + standName\n\t#workerList = JSON.parse(client.gets)\n\ttestlist = client.gets\n\tclient.puts \"master_set close_connection\"\n\t}\n\tputs \"TestcontrolController - gettestcoverage\"\n\ttest = '{\"dataArray\" : [{\"name\" : \"PriorityName\", \"value\" : [\"testName1\", \"testName2\", \"testName3\"]}, {\"name\" : \"PriorityName\", \"value\" : [\"testName1\", \"testName2\", \"testName3\"]}]}'\n\trender :text => testlist\n end",
"def allocation_test_params\n params.require(:allocation_test).permit(:test_id, :user_id,\n allocation_items_attributes: [:name, :points, :allocation_test_id])\n end",
"def get_ab_test(ab_test_id, opts = {})\n raise AlgoliaError, 'ab_test_id cannot be empty.' if ab_test_id.nil?\n\n @transporter.read(:GET, path_encode('/2/abtests/%s', ab_test_id), {}, opts)\n end",
"def show\n @expectation = Expectation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expectation }\n end\n end",
"def get_basic_lab_tests(i, params)\n # Attribute Filters\n must_filter = []\n\n if params[:featured]\n params[:id] = '1545,1068,1698,387,784,1017,1073'\n end\n\n # Search by single or multiple ids (comma separated)\n if params[:id]\n if params[:id].include? ','\n ids = params[:id].split(\",\").map { |s| s.to_i }\n must_filter.push({ terms: { id: ids }})\n else\n must_filter.push({term: { id: params[:id] }})\n end\n end\n\n # Search by name (autocomplete)\n must_filter.push(match_phrase_prefix: { name: params[:name] }) if params[:name]\n\n # Page filters\n perpage = params[:perpage] ? params[:perpage].to_i : 10\n page = params[:page] ? ((params[:page].to_i - 1) * perpage.to_i) : 0\n\n # Sort filters\n sort_filter = basic_lab_tests_sort_filter(params[:sort_order], params[:sort_by])\n\n # Elasticsearch DSL Query\n search_query = {\n query: {\n bool: {\n must: must_filter\n }\n },\n sort: sort_filter,\n from: page,\n size: perpage\n }\n\n client = Elasticsearch::Client.new #host:'https://search-kulcare-search-a5gec72fgr3kghfjyvb3anac74.ap-southeast-1.es.amazonaws.com'\n results = client.search index: i, body: search_query\n results[\"hits\"].to_json\n end",
"def get_test_plan\n @takt = Taktinfo.find(params[:id])\n @testplans = @takt.testplans.where(:format =>params[:testp])\n\n respond_to do |format|\n format.json{render json:@testplans.as_json(root:false),:callback =>params[:callback]}\n end\n end",
"def test_index\n get :index\n assert_response :success\n end",
"def test_index\n get :index\n assert_response :success\n end",
"def index\n @allocation_masters = AllocationMaster.all\n end",
"def show\n @generation = Generation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @generation }\n end\n end",
"def show\n @scenario = Scenario.find(params[:scenario_id])\n @result = @scenario.results.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @result }\n end\n end",
"def show\n @tooling_specification = ToolingSpecification.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tooling_specification }\n end\n end",
"def getFullStatus\n JSON.parse(@client[\"/LoadTest?loadTestId=#{@test_id}\"].get)[0].to_h\n end",
"def index\n @software_tests = SoftwareTest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @software_tests }\n end\n end",
"def get_api_results(_url)\n JSON.parse File.read('spec/inspector/stubbed_example.json')\n end"
] | [
"0.69436985",
"0.6305407",
"0.6286053",
"0.624435",
"0.60783",
"0.6051012",
"0.57828885",
"0.5768882",
"0.5744177",
"0.5704603",
"0.56784326",
"0.56774116",
"0.56721216",
"0.5670114",
"0.56609786",
"0.56437653",
"0.5635185",
"0.5634303",
"0.5612641",
"0.5600295",
"0.5596388",
"0.55919856",
"0.55919856",
"0.55905086",
"0.5556513",
"0.5544725",
"0.5540461",
"0.5530113",
"0.5521865",
"0.551403",
"0.55009454",
"0.5493721",
"0.54921263",
"0.54892564",
"0.54783833",
"0.5472539",
"0.5461968",
"0.54507285",
"0.543269",
"0.54141504",
"0.53837407",
"0.5373389",
"0.53667367",
"0.53646016",
"0.5355644",
"0.5349668",
"0.53439504",
"0.533392",
"0.53325963",
"0.53226095",
"0.5321507",
"0.53143346",
"0.53142726",
"0.5312333",
"0.53099686",
"0.5307372",
"0.53071326",
"0.5304841",
"0.5304643",
"0.5298322",
"0.527523",
"0.5272645",
"0.5268688",
"0.5253844",
"0.5251508",
"0.5251038",
"0.5241013",
"0.52348834",
"0.52323264",
"0.52234054",
"0.52231884",
"0.5222481",
"0.52167153",
"0.52130544",
"0.51919156",
"0.51897866",
"0.51894295",
"0.51887363",
"0.5187007",
"0.51813316",
"0.518123",
"0.5180833",
"0.51798815",
"0.5177137",
"0.517628",
"0.51759285",
"0.51709497",
"0.51646966",
"0.51628494",
"0.51603097",
"0.5159495",
"0.51585215",
"0.51550114",
"0.51550114",
"0.51546615",
"0.5151064",
"0.51390785",
"0.51363516",
"0.51286227",
"0.5119943",
"0.5117986"
] | 0.0 | -1 |
POST /allocation_tests or /allocation_tests.json | def create
@allocation_test = AllocationTest.new(allocation_test_params)
redirect_path = nil
if not current_user.allocation_tests.any?
redirect_path = new_gamble_path
else
redirect_path = survey_path
end
respond_to do |format|
if @allocation_test.save
format.html { redirect_to redirect_path}
format.json { render :show, status: :created, location: @allocation_test }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @allocation_test.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allocation_test_params\n params.require(:allocation_test).permit(:test_id, :user_id,\n allocation_items_attributes: [:name, :points, :allocation_test_id])\n end",
"def create\n @allocation = Allocation.new(allocation_params)\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: t(:allocation_created) }\n format.json { render :show, status: :created, location: @allocation }\n else\n format.html { render :new }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_allocation_test\n @allocation_test = AllocationTest.find(params[:id])\n end",
"def create\n @allocation = Allocation.new(params[:allocation])\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: 'Allocation was successfully created.' }\n format.json { render json: @allocation, status: :created, location: @allocation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @allocation_test.update(allocation_test_params)\n format.html { redirect_to @allocation_test, notice: \"Allocation test was successfully updated.\" }\n format.json { render :show, status: :ok, location: @allocation_test }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @allocation_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @allocation = Allocation.new(allocation_params)\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: 'Allocation was successfully created.' }\n format.json { render :show, status: :created, location: @allocation }\n else\n format.html { render :new }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @allocation_tests = AllocationTest.all\n end",
"def create\n @res_allocation = ResAllocation.new(params[:res_allocation])\n\n respond_to do |format|\n if @res_allocation.save\n format.html { redirect_to @res_allocation, notice: 'Res allocation was successfully created.' }\n format.json { render json: @res_allocation, status: :created, location: @res_allocation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @res_allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @allocation_test.destroy\n respond_to do |format|\n format.html { redirect_to allocation_tests_url, notice: \"Allocation test was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def create\n @allocation = @license.allocations.new(allocation_params)\n @allocation.state = :active\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to license_allocation_path(@license, @allocation), notice: 'Allocation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @allocation }\n else\n format.html { render action: 'new' }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @allocation_master = AllocationMaster.new(allocation_master_params)\n\n respond_to do |format|\n if @allocation_master.save\n format.html { redirect_to @allocation_master, notice: 'Allocation master was successfully created.' }\n format.json { render :show, status: :created, location: @allocation_master }\n else\n format.html { render :new }\n format.json { render json: @allocation_master.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subject_allocation = SubjectAllocation.new(subject_allocation_params)\n\n respond_to do |format|\n if @subject_allocation.save\n format.html { redirect_to subject_allocations_path, notice: 'Subject allocation was successfully created.' }\n format.json { render :show, status: :created, location: @subject_allocation }\n else\n format.html { render :new }\n format.json { render json: @subject_allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resource_allocation = ResourceAllocation.new(params[:resource_allocation])\n\n respond_to do |format|\n if @resource_allocation.save\n format.html { redirect_to(@resource_allocation, :notice => 'Resource allocation was successfully created.') }\n format.xml { render :xml => @resource_allocation, :status => :created, :location => @resource_allocation }\n format.js\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @resource_allocation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def v2_tests_post(test_detail, opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: TestsApi#v2_tests_post ...\"\n end\n \n # verify the required parameter 'test_detail' is set\n fail \"Missing the required parameter 'test_detail' when calling v2_tests_post\" if test_detail.nil?\n \n # resource path\n path = \"/v2/tests\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'text/json', 'application/xml', 'text/xml']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(test_detail)\n \n\n auth_names = []\n result = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TestSummary')\n if Configuration.debugging\n Configuration.logger.debug \"API called: TestsApi#v2_tests_post. Result: #{result.inspect}\"\n end\n return result\n end",
"def create\n @allocation = Allocation.new(params[:allocation])\n @allocation.appointment_count = @allocation.allocation_type.default_appointment_count\n \n# @practitioners = Practitioner.find :all\n#\t\tif (@allocation.appointment.appointment_date == '')\n#\t\t\[email protected] = nil\n#\t\tend\n\n respond_to do |format|\n if @allocation.save\n\t\t\t\[email protected](params[:template], current_user) unless params[:template].nil?\n\t\t\t\t@episode = @allocation.episode\n @client = @allocation.episode.client\n\n\t\t\t\ttopractitioner = @allocation.practitioner.nil? ? '' : \" to #{@allocation.practitioner.fullname}\"\n notice = \"Client successfully allocated#{topractitioner}\"\n if (params[:bookappointment])\n format.html { redirect_to new_appointment_path(:allocation_id => @allocation), :notice => notice }\n else\n format.html { redirect_to Client.find(@allocation.episode.client_id), :notice => notice }\n end\n format.json { render :json => @allocation, :status => :created, :location => @allocation }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @allocation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @allocation = Allocation.new params[:allocation]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @allocation }\n end\n end",
"def allocation_params\n params.require(:allocation).permit(:protocol, :start_date, :amount_cents, :amount, :project_id)\n end",
"def allocation_params\n params.require(:allocation).permit(:allocation_master_id, :product_id, :allocation_input_id, :date_dim_id, :allocation_factor, :allocation_date, :allocation_name, :allocation_basis)\n end",
"def test_post_success_with_param\n post \"/\", {:data => @test_obj} do |response|\n assert response.ok?, \"Create test object failed\"\n assert_equal response.body, @test_obj.to_json, \"Did not get @test_obj back\"\n end\n end",
"def allocation_params\n params.require(:allocation).permit(:license_id, :user_id, :project_code, :state)\n end",
"def create\n tp = test_params.merge!(plate_id: params[:plate_id])\n @test = Test.new(tp)\n authorize Test\n respond_to do |format|\n if @test.save\n @test.plate.complete!\n @test.auto_retest!\n format.html { redirect_to plate_url(@test.plate), notice: 'Test was successfully created.'}\n format.json { render :show, status: :created, location: test }\n else\n format.html { render :new, status: :unprocessable_entity}\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_show_add\n xhr :get, :show_add, :contract_id => @contract.id\n \n assert_template 'assignment/_assignment_form'\n end",
"def create\n @grass_allocation = GrassAllocation.new(grass_allocation_params)\n\n respond_to do |format|\n if @grass_allocation.save\n format.html { redirect_to @grass_allocation, notice: 'Grass allocation was successfully created.' }\n format.json { render :show, status: :created, location: @grass_allocation }\n else\n format.html { render :new }\n format.json { render json: @grass_allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @allocation_date = AllocationDate.new(params[:allocation_date])\n respond_to do |format|\n if @allocation_date.save\n# redirect_to controller: \"res_allocations\", action: \"new\", date_id: @allocation_date.id\n format.html { redirect_to @allocation_date, notice: 'Resource allocation was successfully created.' }\n format.json { render json: @allocation_date, status: :created, location: @allocation_date }\n else\n format.html { render action: \"new\" }\n format.json { render json: @allocation_date.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end",
"def create\n @applicant_test = @applicant.applicant_tests.new(applicant_test_params)\n\n respond_to do |format|\n if @applicant_test.save\n format.html { redirect_to applicant_url(@applicant), notice: \"Test Agregado Correctamente.\" }\n format.json { render :show, status: :created, location: applicant_url(@applicant) }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @applicant_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @testing_algorithm = TestingAlgorithm.new(params[:testing_algorithm])\n\n if @testing_algorithm.save\n render json : @testing_algorithm, status : :created, location : @testing_algorithm\n else\n render json : @testing_algorithm.errors, status : :unprocessable_entity\n end\n end",
"def test_post_request_collection\n params = {\n size: 3,\n employmentTypeUris: ['/dk/atira/pure/person/employmenttypes/academic'],\n employmentStatus: 'ACTIVE'\n }\n response = client.persons.all_complex params: params\n assert_equal response.code, 200\n assert_instance_of HTTP::Response, response\n end",
"def create\n @testing_ = Testing.new(testing__params)\n\n respond_to do |format|\n if @testing_.save\n format.html { redirect_to @testing_, notice: 'Testing was successfully created.' }\n format.json { render action: 'show', status: :created, location: @testing_ }\n else\n format.html { render action: 'new' }\n format.json { render json: @testing_.errors, status: :unprocessable_entity }\n end\n end\n end",
"def allocation_master_params\n params.require(:allocation_master).permit(:allocation_name, :allocation_input_id)\n end",
"def create\n @test = Test.create!(test_params)\n\n render json: @test\n end",
"def create\n @choice_test = ChoiceTest.new(choice_test_params)\n if current_user.tests.count.between?(0,number_of_screens - 1)\n redirect_path = new_test_path\n elsif current_user.tests.count == number_of_screens\n redirect_path = new_allocation_test_path\n else\n if current_user.tests.count.between?(number_of_screens - 1, (number_of_screens * 2) -1)\n redirect_path = after_test_show_path\n else\n redirect_path = new_allocation_test_path\n end\n end\n\n respond_to do |format|\n if @choice_test.save\n format.html { redirect_to redirect_path }\n format.json { render :show, status: :created, location: @choice_test }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @choice_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @performance_test = PerformanceTest.new(params[:performance_test])\n\n respond_to do |format|\n if @performance_test.save\n format.html { redirect_to @performance_test, :notice => 'Performance test was successfully created.' }\n format.json { render :json => @performance_test, :status => :created, :location => @performance_test }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @performance_test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def testing_params\n params.require(:testing).permit(:requiredtests, :name, :customer, :description, :supplier, :supplierrefferenceno, :leadtime, :testdate, :results, :retestdate, :reresults, :cost, :trackingsheet)\n end",
"def create\n @project_code_allocation = ProjectCodeAllocation.new(project_code_allocation_params)\n\n respond_to do |format|\n if @project_code_allocation.save\n format.html { redirect_to @project_code_allocation, notice: 'Project code allocation was successfully created.' }\n format.json { render :show, status: :created, location: @project_code_allocation }\n else\n format.html { render :new }\n format.json { render json: @project_code_allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @case_test = CaseTest.new(case_test_params)\n\n respond_to do |format|\n if @case_test.save\n format.html { redirect_to @case_test, notice: 'Case test was successfully created.' }\n format.json { render :show, status: :created, location: @case_test }\n else\n format.html { render :new }\n format.json { render json: @case_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_case = TestCase.new(test_case_params)\n\n respond_to do |format|\n if @test_case.save\n TestMailer.admin_new_test_email(@test_case).deliver\n \n format.html { redirect_to @test_case, notice: 'Your test was successfully added.' }\n format.json { render action: 'show', status: :created, location: @test_case }\n else\n format.html { render action: 'new' }\n format.json { render json: @test_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resource_allocation_matrix = ResourceAllocationMatrix.new(resource_allocation_matrix_params)\n\n respond_to do |format|\n if @resource_allocation_matrix.save\n format.html { redirect_to @resource_allocation_matrix, notice: 'Resource Allocation Matrix wurde erfolgreich angelegt' }\n format.json { render :show, status: :created, location: @resource_allocation_matrix }\n else\n format.html { render :new }\n format.json { render json: @resource_allocation_matrix.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_create\n\n fab_house_count = FabHouse.count\n new_fab_house = { 'active' => '1', 'name' => 'FabsRus' }\n\n admin_session = cathy_admin_session\n \n post(:create, { :new_fab_house => new_fab_house }, admin_session)\n fab_house_count += 1\n assert_equal(fab_house_count, FabHouse.count)\n assert_equal(\"FabsRus added\", flash['notice'])\n assert_redirected_to(:action => 'list')\n\n post(:create, { :new_fab_house => new_fab_house }, admin_session)\n assert_equal(fab_house_count, FabHouse.count)\n #assert_equal(\"Name has already been taken\", flash['notice'])\n assert_redirected_to(:action => 'add')\n\n end",
"def create\n @ab_test = AbTest.new(ab_test_params)\n\n respond_to do |format|\n if @ab_test.save\n format.html { redirect_to @ab_test, notice: 'Ab test was successfully created.' }\n format.json { render :show, status: :created, location: @ab_test }\n else\n format.html { render :new }\n format.json { render json: @ab_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def report_test\n report_data = params.require(:api).permit(:code,:stdout,:project,:suite,:section)\n report = api_user.test_reports.create(report_data)\n if report.valid?\n render text: \"ok\"\n else\n raise \"Invalid report\"\n end\n end",
"def test_create_iphone_report\n post(:create, \"reporter\"=>{\"uniqueid\"=>\"13506d733bc5372a3b818fdf29ef8fb7386b3dc3\", \"zipcode\"=>\"21012\", \"firstname\"=>\"David\", \"lastname\"=>\"Troy\", \"email\"=>\"[email protected]\"},\n \"format\"=>\"iphone\",\n \"report\"=>{\"latlon\"=>\"39.025,-76.511:114\", \"title\"=>\"This is a test\", \"body\" => \"Body text\" } )\n assert_response :success\n assert_equal \"OK\", @response.body\n reporter = IphoneReporter.find_by_uniqueid(\"13506d733bc5372a3b818fdf29ef8fb7386b3dc3\")\n assert_equal \"David Troy\", reporter.name\n end",
"def create\n tp = test_params.merge!(plate_id: params[:plate_id])\n @test = Test.new(tp)\n @test.plate.complete!\n authorize @test\n respond_to do |format|\n if @test.save\n format.html { redirect_to plate_url(@plate), notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @test }\n else\n format.html { render :new }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(attrs, user = @@default_user)\n attrs = { project_token: @project_token }.merge(attrs)\n @attributes = send_request('test_plans', :post) do |req|\n req.body = {\n test_plan: attrs.except(:project_token),\n token: attrs[:project_token],\n auth_token: user.auth_token\n }\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def generatesingletestplan\n\trelease = params[:release]\n\tpriority = params[:priority]\n\texectype = params[:exectype]\n\ttimelimit = params[:timelimit]\n\t# получаем с сервера нужные данные\n\tmds = Hash.new()\n\tTCPSocket.open('172.20.5.130', 2000){ |client|\n\t\t# say Hello to server\n\t\tclient.puts \"MasterOnline\"\n\t\tclient.gets\n\t\tclient.puts \"master_set get_singletestplan #{release} #{priority} #{exectype} #{timelimit}\"\n\t\tmds = JSON.parse(client.gets)\n\t\tclient.puts \"master_set close_connection\"\n\t}\n\t# подготавливаем данные для отправки на веб страницу\n\tnewTree = mds\n\t#newTree = newTree[\"TestItem\"][0]\n\t# новое дерево\n\t# вводим фиктивную вершину\n\tvalue = Hash.new()\n\tvalue[:data] = \"Тестирование \" + release\n\t\tfalseAttr = Hash.new()\n\t\tfalseAttr[:class] = \"jstree-checked\"\n\t\tfalseAttr[:id] = \"0001\"\n\t\tfalseAttr[:MethodName] = \"\"\n\t\tfalseAttr[:UnitName] = \"\"\n\tvalue[:attr] = falseAttr\n\t# получаем дерево\n\tchildrens = Array.new()\n\tnewTree[\"TestItem\"].each do |x|\n\t\ttree = createTreeForView(x)\n\t\tchildrens.push(tree)\n\tend\n\tvalue[:children] = childrens\n\trawarray = { :data => value}\n\tmds_for_send = rawarray.to_json\n\trender :text => mds_for_send\n end",
"def test_new_microtask\r\n #@assignment = assignments(:Assignment_Microtask1)\r\n questionnaire_id = questionnaires(:questionnaire1).id\r\n instructorid = users(:instructor1).id\r\n courseid = courses(:course_object_oriented).id,\r\n number_of_topics = SignUpTopic.count\r\n # create a new assignment\r\n post :new, :assignment => { :name => \"Assignment_Microtask1\",\r\n :directory_path => \"CSC517_instructor1/Assignment_Microtask1\",\r\n :submitter_count => 0,\r\n :course_id => courseid,\r\n :instructor_id => instructorid,\r\n :num_reviews => 1,\r\n :num_review_of_reviews => 0,\r\n :num_review_of_reviewers => 0,\r\n :review_questionnaire_id => questionnaire_id,\r\n :reviews_visible_to_all => 0,\r\n :require_signup => 0,\r\n :num_reviewers => 3,\r\n :team_assignment => 0,\r\n :team_count => 1,\r\n :microtask => true }\r\n\r\n assert_response 200\r\n assert Assignment.find(:all, :conditions => \"name = 'Assignment_Microtask1'\")\r\n\r\n end",
"def create\n @testing = Testing.new(testing_params)\n\n respond_to do |format|\n if @testing.save\n format.html { redirect_to @testing, notice: 'Testing was successfully created.' }\n format.json { render :show, status: :created, location: @testing }\n else\n format.html { render :new }\n format.json { render json: @testing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_ab_test(ab_test, opts = {})\n @transporter.write(:POST, '/2/abtests', ab_test, opts)\n end",
"def update\n\n respond_to do |format|\n if @allocation.update(allocation_params)\n format.html { redirect_to @allocation, notice: t(:allocation_updated) }\n format.json { render :show, status: :ok, location: @allocation }\n else\n format.html { render :edit }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_agent_new_enquiries\n agent_id = Agents::Branches::AssignedAgent.last.id\n verification_status = true\n get :agent_new_enquiries, { agent_id: agent_id }\n attach_agent_to_property_and_update_details(agent_id, SAMPLE_UDPRN, 'Green', \n verification_status, SAMPLE_BEDS, SAMPLE_BATHS, \n SAMPLE_RECEPTIONS)\n\n # assert_response 200\n # earlier_response = Oj.load(@response.body)\n # assert_equal earlier_response['enquiries'].length, 0\n len = 0\n buyer_id = PropertyBuyer.last.id\n\n property_details = get_es_address(SAMPLE_UDPRN)\n Trackers::Buyer::ENQUIRY_EVENTS.each do |event|\n process_event_helper(event, @address_doc['_source'], agent_id)\n get :agent_new_enquiries, { agent_id: agent_id }\n len += 1\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response['enquiries'].length, len\n\n ### Test property attributes\n attrs = ['price', 'street_view_image_url', 'udprn', 'offers_over', \n 'fixed_price', 'asking_price', 'dream_price', 'current_valuation', 'verification_status']\n attrs.each do |attr_val|\n assert_equal response['enquiries'].last[attr_val], property_details['_source'][attr_val]\n end\n\n assert_equal response['enquiries'].last['status'], property_details['_source']['property_status_type']\n\n ### Test buyer attributes\n buyer = PropertyBuyer.find(buyer_id).as_json\n buyer_attrs = ['id', 'status', 'full_name', 'email', 'image_url', 'mobile', 'budget_from', 'budget_to']\n buyer_attrs.each do |attr_val|\n assert_equal response['enquiries'].last[\"buyer_#{attr_val}\"], buyer[attr_val]\n end\n\n assert_equal response['enquiries'].last['buyer_funding'], PropertyBuyer::REVERSE_FUNDING_STATUS_HASH[buyer['funding']]\n assert_equal response['enquiries'].last['buyer_biggest_problem'], PropertyBuyer::REVERSE_FUNDING_STATUS_HASH[buyer['biggest_problem']]\n assert_equal response['enquiries'].last['buyer_buying_status'], PropertyBuyer::REVERSE_FUNDING_STATUS_HASH[buyer['buying_status']]\n \n ### Test enquiries, views, hotness and qualifying_stage \n enquiries = response['enquiries'].last['enquiries']\n buyer_enquiries = enquiries.split('/')[0].to_i\n total_enquiries = enquiries.split('/')[1].to_i\n assert_equal buyer_enquiries, total_enquiries\n end\n\n ### Test viewed\n process_event_helper('viewed', @address_doc['_source'])\n get :agent_new_enquiries, { agent_id: agent_id }\n response = Oj.load(@response.body)\n views = response['enquiries'].last['views']\n buyer_views = views.split('/')[0].to_i\n total_views = views.split('/')[1].to_i\n assert_equal total_views, 1\n assert_equal buyer_views, 1\n\n\n ### Test hotness\n assert_equal response['enquiries'].last['hotness'], 'cold_property'\n process_event_helper('warm_property', @address_doc['_source'])\n get :agent_new_enquiries, { agent_id: agent_id }\n response = Oj.load(@response.body)\n hotness = response['enquiries'].last['hotness']\n assert_equal hotness, 'warm_property'\n\n process_event_helper('hot_property', @address_doc['_source'])\n get :agent_new_enquiries, { agent_id: agent_id }\n response = Oj.load(@response.body)\n hotness = response['enquiries'].last['hotness']\n assert_equal hotness, 'hot_property'\n\n #### Test qualifying stage filter\n (Trackers::Buyer::QUALIFYING_STAGE_EVENTS-[:qualifying_stage, :viewing_stage]).each do |event|\n process_event_helper(event, @address_doc['_source'])\n get :agent_new_enquiries, { agent_id: agent_id }\n response = Oj.load(@response.body)\n stage = response['enquiries'].last['qualifying']\n assert_equal stage, event.to_s\n\n get :agent_new_enquiries, { agent_id: agent_id, qualifying_stage: event }\n response = Oj.load(@response.body)\n response['enquiries'].each do |each_elem|\n assert_equal each_elem['qualifying'], event.to_s\n end\n\n end\n\n ### Test Filters\n ### i) enquiry_type\n (Trackers::Buyer::ENQUIRY_EVENTS-[:viewing_stage]).each do |event|\n get :agent_new_enquiries, { agent_id: agent_id, enquiry_type: event }\n response = Oj.load(@response.body)\n assert_equal response['enquiries'].length, 1\n end\n\n ### ii) type_of_match\n get :agent_new_enquiries, { agent_id: agent_id }\n response = Oj.load(@response.body)\n response_length = response['enquiries'].length\n\n get :agent_new_enquiries, { agent_id: agent_id, type_of_match: 'Potential' }\n response = Oj.load(@response.body)\n assert_equal response['enquiries'].length, 0\n\n get :agent_new_enquiries, { agent_id: agent_id, type_of_match: 'Perfect' }\n response = Oj.load(@response.body)\n # assert_equal response['enquiries'].length, response_length\n\n ### Test for rent properties\n create_rent_enquiry_event\n attach_agent_to_property_and_update_details(agent_id, '123456', 'Rent', \n verification_status, SAMPLE_BEDS, SAMPLE_BATHS, \n SAMPLE_RECEPTIONS)\n\n\n property_status_type = 'Rent'\n\n get :agent_new_enquiries, { agent_id: agent_id, property_for: 'Rent' }\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response.length, 1\n destroy_rent_enquiry_event\n end",
"def create\n \t# add actions here\n # This action takes place in the test suite controller\n end",
"def create\n @nginxtest = Nginxtest.new(nginxtest_params)\n\n respond_to do |format|\n if @nginxtest.save\n format.html { redirect_to @nginxtest, notice: \"Nginxtest was successfully created.\" }\n format.json { render :show, status: :created, location: @nginxtest }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @nginxtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test!\n @@api.post(endpoint: self.endpoint + ['test'])\n end",
"def test_the_application_can_create_an_item\n # Send a POST request to '/items' endpoint that creates a new item\n # with a title of 'Learn to test controllers' and a description 'This is great'\n # Assert that the controller responds with a status of 200\n # Assert that the controller responds with a body of 'Item created'\n # Assert that the ToDo table has an item in it\n end",
"def create\n @testbed_owner = TestbedOwner.new(params[:testbed_owner])\n\n respond_to do |format|\n if @testbed_owner.save\n format.html { redirect_to @testbed_owner, notice: 'Testbed owner was successfully created.' }\n format.json { render json: @testbed_owner, status: :created, location: @testbed_owner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @testbed_owner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @editability = Editability.new(params[:test])\n\n respond_to do |format|\n if @editability.save\n format.html { redirect_to @editability, notice: 'Test was successfully created.' }\n format.json { render json: @editability, status: :created, location: @test }\n else\n format.html { render action: \"new\" }\n format.json { render json: @editability.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @allocation.destroy\n respond_to do |format|\n format.html { redirect_to allocations_url, notice: t(:allocation_deleted) }\n format.json { head :no_content }\n end\n end",
"def create\n @terra_nova_test_benchmark = TerraNovaTestBenchmark.new(terra_nova_test_benchmark_params)\n\n respond_to do |format|\n if @terra_nova_test_benchmark.save\n format.html { redirect_to @terra_nova_test_benchmark, notice: 'Terra nova test benchmark was successfully created.' }\n format.json { render :show, status: :created, location: @terra_nova_test_benchmark }\n else\n format.html { render :new }\n format.json { render json: @terra_nova_test_benchmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_suite = TestSuite.new(params[:test_suite])\n\n respond_to do |format|\n if @test_suite.save\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully created.' }\n format.json { render json: @test_suite, status: :created, location: @test_suite }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_new\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: SAMPLE_UDPRN,\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n prev_quote_count = Agents::Branches::AssignedAgents::Quote.count\n post :new, params_hash\n assert_response 200\n assert_equal Agents::Branches::AssignedAgents::Quote.count, (prev_quote_count + 1)\n end",
"def grass_allocation_params\n params.require(:grass_allocation).permit(:grass_allocation_id, :grass_id, :plotsubplot_id, :year_observation, :percentage_100_dm_gm1, :percentage_100_dm_gm2, :percentage_100_dm_gm3, :percentage_100_dm_gm4, :percentage_100_dm_gm5, :percentage_100_dm_gm6, :percentage_100_dm_silage1, :percentage_100_dm_silage2, :d_value_1, :d_value_2, :me_1, :me_2, :lugd, :percentage_prg_a, :percentage_tim_a, :percentage_wc_a, :percentage_tug_a, :percentage_tw_a, :ph, :p, :k, :mg, :om, :replication, :rotation)\n end",
"def create\n @asset_allocate = AssetAllocate.new(asset_allocate_params)\n\n respond_to do |format|\n if @asset_allocate.save\n format.html { redirect_to @asset_allocate, notice: 'Asset allocate was successfully created.' }\n format.json { render :show, status: :created, location: @asset_allocate }\n else\n format.html { render :new }\n format.json { render json: @asset_allocate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def agencies_create_test_agency_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_create_test_agency ...'\n end\n # resource path\n local_var_path = '/v1/agencies/_testAgency'\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', 'text/html', 'application/xml', 'text/xml'])\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(: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 => 'DomainAgencyServiceV2ModelAgency')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_create_test_agency\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @test_suite = TestSuite.new(test_suite_params)\n\n respond_to do |format|\n if @test_suite.save\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully created.' }\n format.json { render :show, status: :created, location: @test_suite }\n else\n format.html { render :new }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @validation_test = ValidationTest.new(validation_test_params)\n\n respond_to do |format|\n if @validation_test.save\n format.html { redirect_to @validation_test, notice: 'Validation test was successfully created.' }\n format.json { render :show, status: :created, location: @validation_test }\n else\n format.html { render :new }\n format.json { render json: @validation_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_should_create_group_invite_via_API_JSON\r\n \r\n end",
"def create\n if has_missing_params?([:test_output, :test_run_id])\n # incomplete/invalid HTTP params\n render 'shared/http_status', locals: {code: '422', message:\n HttpStatusHelper::ERROR_CODE['message']['422']}, status: 422\n return\n end\n test_run = TestRun.find(params[:test_run_id])\n begin\n test_run.create_test_script_results_from_json(params[:test_output])\n render 'shared/http_status', locals: {code: '201', message:\n HttpStatusHelper::ERROR_CODE['message']['201']}, status: 201\n rescue\n # Some other error occurred\n render 'shared/http_status', locals: { code: '500', message:\n HttpStatusHelper::ERROR_CODE['message']['500'] }, status: 500\n end\n rescue ActiveRecord::RecordNotFound => e\n # Could not find submission\n render 'shared/http_status', locals: {code: '404', message:\n e}, status: 404\n end",
"def create\n @application_test = ApplicationTest.new(application_test_params)\n\n respond_to do |format|\n if @application_test.save\n format.html { redirect_to @application_test, notice: 'Application test was successfully created.' }\n format.json { render :show, status: :created, location: @application_test }\n else\n format.html { render :new }\n format.json { render json: @application_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_kubernetes_aci_cni_tenant_cluster_allocation_with_http_info(kubernetes_aci_cni_tenant_cluster_allocation, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.create_kubernetes_aci_cni_tenant_cluster_allocation ...'\n end\n # verify the required parameter 'kubernetes_aci_cni_tenant_cluster_allocation' is set\n if @api_client.config.client_side_validation && kubernetes_aci_cni_tenant_cluster_allocation.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_aci_cni_tenant_cluster_allocation' when calling KubernetesApi.create_kubernetes_aci_cni_tenant_cluster_allocation\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/AciCniTenantClusterAllocations'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_aci_cni_tenant_cluster_allocation)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesAciCniTenantClusterAllocation'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.create_kubernetes_aci_cni_tenant_cluster_allocation\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#create_kubernetes_aci_cni_tenant_cluster_allocation\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def set_allocation\n @allocation = Allocation.find(params[:id])\n end",
"def test_index \n post :index \n assert_response :success \n end",
"def test_create\n @batch = Batch.new\n assert_invalid @batch, :batchid\n assert_invalid @batch, :facility\n end",
"def create\n @test_detail = TestDetail.new(test_detail_params)\n\n respond_to do |format|\n if @test_detail.save\n format.html { redirect_to @test_detail, notice: 'Test detail was successfully created.' }\n format.json { render :show, status: :created, location: @test_detail }\n else\n format.html { render :new }\n format.json { render json: @test_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_create_transaction\n params = {\n bank_transaction: {\n bank_account_id: 1,\n date: Time.local(2012, 4, 16),\n amount: 55\n }\n }\n\n post '/api/banks/1/transactions', params\n data = ActiveSupport::JSON.decode last_response.body\n\n assert last_response.successful?\n assert_match('application/json', last_response.content_type)\n assert BankTransaction.find(data['id'])\n end",
"def test_submit\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: SAMPLE_UDPRN,\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: SAMPLE_UDPRN, quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end",
"def assignment_params\n params.require(:assignment).permit(:metric_id, :test_id, :test_slot)\n end",
"def create\n @testmonial = Testmonial.new(testmonial_params)\n\n if @testmonial.save\n render json: @testmonial, status: :created\n else\n render json: @testmonial.errors, status: :unprocessable_entity\n end\n end",
"def test_should_create_project_via_API_JSON\r\n get \"/logout\"\r\n post \"/projects.json\", :api_key => 'testapikey',\r\n :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response :created\r\n project = JSON.parse(response.body)\r\n check_new_project(project) \r\n end",
"def create_agent_via_api(agent_type, opts = {})\n case agent_type\n when :person\n agent_json = if opts[:create_subrecords]\n build(:json_agent_person_full_subrec)\n else\n build(:json_agent_person)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/people\")\n when :corporate_entity\n agent_json = if opts[:create_subrecords]\n build(:json_agent_corporate_entity_full_subrec)\n else\n build(:json_agent_corporate_entity)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/corporate_entities\")\n when :family\n agent_json = if opts[:create_subrecords]\n build(:json_agent_family_full_subrec)\n else\n build(:json_agent_familly)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/families\")\n when :software\n agent_json = if opts[:create_subrecords]\n build(:json_agent_software_full_subrec)\n else\n build(:json_agent_software)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/software\")\n end\n\n response = JSONModel::HTTP.post_json(url, agent_json.to_json)\n json_response = ASUtils.json_parse(response.body)\n\n if json_response['status'] == 'Created'\n json_response['id']\n else\n -1\n end\nrescue StandardError => e\n -1\nend",
"def allocate_to_employee\n @inventory_release = InventoryRelease.find params[:id]\n authorize! :update, @inventory_release\n\n\n if @inventory_release.allocate_to_employee(params[:employee_id], params[:count])\n head :no_content\n else\n head :unprocessable_entity\n end\n\n # head :no_content # everything went well!\n end",
"def create\n @testcase = Testcase.new(params[:testcase])\n\n respond_to do |format|\n if @testcase.save\n format.html { redirect_to @testcase, :notice => 'Test was successfully created.' }\n format.json { render :json => @testcase, :status => :created, :location => @test }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @testcase.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_test_order(options)\n request :account, :post, 'order/test', options\n end",
"def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend",
"def destroy\n @allocation.destroy\n respond_to do |format|\n format.html { redirect_to allocations_url, notice: 'Allocation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create_or_patch_ip_address_pool_allocation_0_with_http_info(ip_pool_id, ip_allocation_id, ip_address_allocation, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation_0 ...'\n end\n # verify the required parameter 'ip_pool_id' is set\n if @api_client.config.client_side_validation && ip_pool_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_pool_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation_0\"\n end\n # verify the required parameter 'ip_allocation_id' is set\n if @api_client.config.client_side_validation && ip_allocation_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_allocation_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation_0\"\n end\n # verify the required parameter 'ip_address_allocation' is set\n if @api_client.config.client_side_validation && ip_address_allocation.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_address_allocation' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation_0\"\n end\n # resource path\n local_var_path = '/global-infra/ip-pools/{ip-pool-id}/ip-allocations/{ip-allocation-id}'.sub('{' + 'ip-pool-id' + '}', ip_pool_id.to_s).sub('{' + 'ip-allocation-id' + '}', ip_allocation_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['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 = @api_client.object_to_http_body(ip_address_allocation)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi#create_or_patch_ip_address_pool_allocation_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def test_should_create_link_via_API_JSON\r\n get \"/logout\"\r\n post \"/links.json\", :api_key => 'testapikey',\r\n :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response :created\r\n link = JSON.parse(response.body)\r\n check_new_link(link) \r\n end",
"def submit_report(json, cookbookname)\n data = File.read(json)\n uri = URI.parse($SPEC_ENDPOINT)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(\"/api/reports\")\n request.add_field('Content-Type', 'application/json')\n request.body = {\n :spec_result => data,\n :hostname => `hostname`.chomp,\n :cookbook_name => cookbookname\n }.to_json\n response = http.request(request)\n end",
"def create\n if @test.done.blank?\n redirect_to root_path, warning: \"This test have not finished yet\"\n return\n end\n params[:submission] = {}\n params[:submission][:user_id] = current_user.id\n @submission = @test.submissions.create(submission_params)\n respond_to do |format|\n if @submission.save\n @test.questions.each do |question|\n question.answers.each do |answer|\n answer.answers_of_questions.create({choice: false, question_id: question.id, submission_id: @submission.id})\n end\n end\n format.html { redirect_to edit_test_submission_path(@test, @submission) }\n else\n format.html { render :new }\n end\n end\n end",
"def update\n respond_to do |format|\n if @allocation.update(allocation_params)\n format.html { redirect_to @allocation, notice: 'Allocation was successfully updated.' }\n format.json { render :show, status: :ok, location: @allocation }\n else\n format.html { render :edit }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_case_params\n params.require(:test_case).permit(:input, :output)\n end",
"def set_allocation\n @allocation = Allocation.find(params[:id])\n end",
"def create\n @test10 = Test10.new(params[:test10])\n\n respond_to do |format|\n if @test10.save\n format.html { redirect_to @test10, notice: 'Test10 was successfully created.' }\n format.json { render json: @test10, status: :created, location: @test10 }\n else\n format.html { render action: \"new\" }\n format.json { render json: @test10.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_submit_rent\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: '123456',\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n post :new, params_hash\n assert_response 200\n\n quote = Agents::Branches::AssignedAgents::Quote.last\n ### Now lets submit the quote\n post :submit, { udprn: '123456', quote_id: quote.id }\n response = Oj.load(@response.body)\n assert_response 200\n assert_equal response['message'], 'The quote is accepted'\n end",
"def test_create_fail\n post '/resources'\n assert_equal 400, last_response.status\n last_response.headers['Content-Type'].must_equal 'application/json;charset=utf-8'\n assert_json_match error_message_pattern, last_response.body\n end",
"def test_create_a_task_with_valid_attributes\n post '/tasks', { task: { title: \"something\", description: \"else\", user_id: 1 } } # post '/tasks', { task: { title: \"something\", description: \"else\", user_id: 1, status_id: 1 } }\n assert_equal 1, Task.count # count is a method that ActiveRecord gives us\n assert_equal 200, last_response.status\n assert_equal \"created!\", last_response.body\n end",
"def create\n @runscope_test = RunscopeTest.new(runscope_test_params)\n\n respond_to do |format|\n if @runscope_test.save\n format.html { redirect_to @runscope_test, notice: 'Runscope test was successfully created.' }\n format.json { render :show, status: :created, location: @runscope_test }\n else\n format.html { render :new }\n format.json { render json: @runscope_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_or_replace_ip_address_pool_allocation_0_with_http_info(ip_pool_id, ip_allocation_id, ip_address_allocation, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_replace_ip_address_pool_allocation_0 ...'\n end\n # verify the required parameter 'ip_pool_id' is set\n if @api_client.config.client_side_validation && ip_pool_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_pool_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_replace_ip_address_pool_allocation_0\"\n end\n # verify the required parameter 'ip_allocation_id' is set\n if @api_client.config.client_side_validation && ip_allocation_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_allocation_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_replace_ip_address_pool_allocation_0\"\n end\n # verify the required parameter 'ip_address_allocation' is set\n if @api_client.config.client_side_validation && ip_address_allocation.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_address_allocation' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_replace_ip_address_pool_allocation_0\"\n end\n # resource path\n local_var_path = '/global-infra/ip-pools/{ip-pool-id}/ip-allocations/{ip-allocation-id}'.sub('{' + 'ip-pool-id' + '}', ip_pool_id.to_s).sub('{' + 'ip-allocation-id' + '}', ip_allocation_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['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 = @api_client.object_to_http_body(ip_address_allocation)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'IpAddressAllocation')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi#create_or_replace_ip_address_pool_allocation_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def test_params\n params.require(:test).permit(:number, :model, :sample_received, :report_received, :inspection_id, :standard_id, :project_id, :comments)\n end",
"def create\n @jsontest = Jsontest.new(jsontest_params)\n\n respond_to do |format|\n if @jsontest.save\n format.html { redirect_to @jsontest, notice: 'Jsontest was successfully created.' }\n format.json { render :show, status: :created, location: @jsontest }\n else\n format.html { render :new }\n format.json { render json: @jsontest.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.66239893",
"0.63554347",
"0.6350287",
"0.6298568",
"0.6263548",
"0.624127",
"0.61448866",
"0.6057474",
"0.60164624",
"0.5960756",
"0.5751927",
"0.5751536",
"0.5728472",
"0.5684383",
"0.56291664",
"0.5620527",
"0.56042695",
"0.5595294",
"0.5548781",
"0.5495598",
"0.5493918",
"0.54874355",
"0.547395",
"0.5428263",
"0.5391826",
"0.5378977",
"0.53714365",
"0.5371063",
"0.536945",
"0.5357068",
"0.5349745",
"0.5349036",
"0.5339653",
"0.5317671",
"0.5304904",
"0.53021544",
"0.5300843",
"0.5291653",
"0.5287064",
"0.52853733",
"0.5262153",
"0.52620363",
"0.5257869",
"0.5254844",
"0.5252051",
"0.5251519",
"0.5244126",
"0.5242911",
"0.52370644",
"0.5232852",
"0.52265674",
"0.52130777",
"0.521055",
"0.5206837",
"0.519406",
"0.518937",
"0.5181039",
"0.5180935",
"0.5179453",
"0.51754606",
"0.5168265",
"0.5163776",
"0.5157477",
"0.5157285",
"0.51537627",
"0.51507443",
"0.5147703",
"0.5147636",
"0.51457405",
"0.51370895",
"0.51341295",
"0.51324636",
"0.5130086",
"0.51279986",
"0.5127648",
"0.5124035",
"0.51213884",
"0.5119854",
"0.5099869",
"0.50961185",
"0.5091196",
"0.509089",
"0.5077894",
"0.507472",
"0.5066986",
"0.50635695",
"0.50564045",
"0.5053343",
"0.50512064",
"0.5047229",
"0.5041223",
"0.5033277",
"0.5026301",
"0.5025589",
"0.50253254",
"0.50192016",
"0.5010899",
"0.5008205",
"0.50062263",
"0.5001938"
] | 0.6723118 | 0 |
PATCH/PUT /allocation_tests/1 or /allocation_tests/1.json | def update
respond_to do |format|
if @allocation_test.update(allocation_test_params)
format.html { redirect_to @allocation_test, notice: "Allocation test was successfully updated." }
format.json { render :show, status: :ok, location: @allocation_test }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @allocation_test.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_allocation_test\n @allocation_test = AllocationTest.find(params[:id])\n end",
"def update\n\n respond_to do |format|\n if @allocation.update(allocation_params)\n format.html { redirect_to @allocation, notice: t(:allocation_updated) }\n format.json { render :show, status: :ok, location: @allocation }\n else\n format.html { render :edit }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @allocation.update(allocation_params)\n format.html { redirect_to @allocation, notice: 'Allocation was successfully updated.' }\n format.json { render :show, status: :ok, location: @allocation }\n else\n format.html { render :edit }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @allocation.update(allocation_params)\n format.html { redirect_to license_allocation_path(@license, @allocation), notice: 'Allocation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @allocation = Allocation.find(params[:id])\n\n respond_to do |format|\n if @allocation.update_attributes(params[:allocation])\n format.html { redirect_to @allocation, notice: 'Allocation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @allocation_master.update(allocation_master_params)\n format.html { redirect_to @allocation_master, notice: 'Allocation master was successfully updated.' }\n format.json { render :show, status: :ok, location: @allocation_master }\n else\n format.html { render :edit }\n format.json { render json: @allocation_master.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @res_allocation = ResAllocation.find(params[:id])\n\n respond_to do |format|\n if @res_allocation.update_attributes(params[:res_allocation])\n format.html { redirect_to @res_allocation, notice: 'Res allocation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @res_allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def allocation_test_params\n params.require(:allocation_test).permit(:test_id, :user_id,\n allocation_items_attributes: [:name, :points, :allocation_test_id])\n end",
"def update\n @allocation = Allocation.find(params[:id])\n\n respond_to do |format|\n if @allocation.update_attributes(params[:allocation])\n\t\t @allocation.generate_print_jobs_async(current_user)\n \n format.html { redirect_to session[:return_to], :notice => 'Allocation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @allocation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subject_allocation.update(subject_allocation_params)\n format.html { redirect_to subject_allocations_path, notice: 'Subject allocation was successfully updated.' }\n format.json { render :show, status: :ok, location: @subject_allocation }\n else\n format.html { render :edit }\n format.json { render json: @subject_allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @resource_allocation = ResourceAllocation.find(params[:id])\n\n respond_to do |format|\n if @resource_allocation.update_attributes(params[:resource_allocation])\n format.html { redirect_to(@resource_allocation, :notice => 'Resource allocation was successfully updated.') }\n format.xml { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @resource_allocation.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n respond_to do |format|\n if @tests_specification.update(tests_specification_params)\n format.html { redirect_to edit_tests_specification_path(@tests_specification), notice: \"Tests specification was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tests_specification }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tests_specification.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch_kubernetes_aci_cni_tenant_cluster_allocation_with_http_info(moid, kubernetes_aci_cni_tenant_cluster_allocation, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.patch_kubernetes_aci_cni_tenant_cluster_allocation ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.patch_kubernetes_aci_cni_tenant_cluster_allocation\"\n end\n # verify the required parameter 'kubernetes_aci_cni_tenant_cluster_allocation' is set\n if @api_client.config.client_side_validation && kubernetes_aci_cni_tenant_cluster_allocation.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_aci_cni_tenant_cluster_allocation' when calling KubernetesApi.patch_kubernetes_aci_cni_tenant_cluster_allocation\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/AciCniTenantClusterAllocations/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_aci_cni_tenant_cluster_allocation)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesAciCniTenantClusterAllocation'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.patch_kubernetes_aci_cni_tenant_cluster_allocation\",\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(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#patch_kubernetes_aci_cni_tenant_cluster_allocation\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n respond_to do |format|\n if @project_code_allocation.update(project_code_allocation_params)\n format.html { redirect_to @project_code_allocation, notice: 'Project code allocation was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_code_allocation }\n else\n format.html { render :edit }\n format.json { render json: @project_code_allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resource_allocation_matrix.update(resource_allocation_matrix_params)\n format.html { redirect_to @resource_allocation_matrix, notice: 'Resource Allocation Matrix wurde erfolgreich aktualisiert' }\n format.json { render :show, status: :ok, location: @resource_allocation_matrix }\n else\n format.html { render :edit }\n format.json { render json: @resource_allocation_matrix.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @testing_.update(testing__params)\n format.html { redirect_to @testing_, notice: 'Testing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @testing_.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_allocation\n @allocation = Allocation.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @case_test.update(case_test_params)\n format.html { redirect_to @case_test, notice: 'Case test was successfully updated.' }\n format.json { render :show, status: :ok, location: @case_test }\n else\n format.html { render :edit }\n format.json { render json: @case_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @grass_allocation.update(grass_allocation_params)\n format.html { redirect_to @grass_allocation, notice: 'Grass allocation was successfully updated.' }\n format.json { render :show, status: :ok, location: @grass_allocation }\n else\n format.html { render :edit }\n format.json { render json: @grass_allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @allocation_test.destroy\n respond_to do |format|\n format.html { redirect_to allocation_tests_url, notice: \"Allocation test was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def update\n if @test_guide_scenario_sa.update(test_guide_scenario_sa_params)\n render status: :ok, json: @test_guide_scenario_sa\n else\n self.send(:edit)\n end\n end",
"def update\n if @test.update(test_params)\n render status: :ok, json: @test\n else\n self.send(:edit)\n end\n end",
"def update\n tp = test_params.merge!(plate_id: params[:plate_id])\n respond_to do |format|\n if @test.update(tp)\n format.html { redirect_to [@plate, @test], notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fixit_test.update(fixit_test_params)\n format.html { redirect_to @fixit_test, notice: 'Fixit test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fixit_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @allocation_tests = AllocationTest.all\n end",
"def set_allocation\n @allocation = Allocation.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @test_detail.update(test_detail_params)\n format.html { redirect_to @test_detail, notice: 'Test detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_detail }\n else\n format.html { render :edit }\n format.json { render json: @test_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_kubernetes_aci_cni_tenant_cluster_allocation_with_http_info(moid, kubernetes_aci_cni_tenant_cluster_allocation, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.update_kubernetes_aci_cni_tenant_cluster_allocation ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.update_kubernetes_aci_cni_tenant_cluster_allocation\"\n end\n # verify the required parameter 'kubernetes_aci_cni_tenant_cluster_allocation' is set\n if @api_client.config.client_side_validation && kubernetes_aci_cni_tenant_cluster_allocation.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_aci_cni_tenant_cluster_allocation' when calling KubernetesApi.update_kubernetes_aci_cni_tenant_cluster_allocation\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/AciCniTenantClusterAllocations/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_aci_cni_tenant_cluster_allocation)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesAciCniTenantClusterAllocation'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.update_kubernetes_aci_cni_tenant_cluster_allocation\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#update_kubernetes_aci_cni_tenant_cluster_allocation\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n respond_to do |format|\n if @application_test.update(application_test_params)\n format.html { redirect_to @application_test, notice: 'Application test was successfully updated.' }\n format.json { render :show, status: :ok, location: @application_test }\n else\n format.html { render :edit }\n format.json { render json: @application_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n update_args = {}\n if params[:reupload].blank?\n properties_array = Array.new\n property_names = params[:test_plan]['property_name']\n property_values = params[:test_plan]['property_value']\n\n count = 0\n property_names.each_with_index.each do |name, index|\n if(!name.strip.empty? and !property_values[index].strip.empty?)\n properties_array[count] = {\"name\" => name.strip, \"value\" => property_values[index].strip}\n count += 1\n end\n end\n\n update_args[:properties] = properties_array.to_json\n else\n update_args = params.require(:test_plan).permit(:jmx)\n end\n\n respond_to do |format|\n if @test_plan.update(update_args)\n format.html { redirect_to project_test_plans_path(@project), flash: {success: 'Test plan was successfully updated.'} }\n format.json { render :show, status: :ok, location: @test_plan }\n else\n format.html { render :edit }\n format.json { render json: @test_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @terra_nova_test_benchmark.update(terra_nova_test_benchmark_params)\n format.html { redirect_to @terra_nova_test_benchmark, notice: 'Terra nova test benchmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @terra_nova_test_benchmark }\n else\n format.html { render :edit }\n format.json { render json: @terra_nova_test_benchmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @alram_test.update(alram_test_params_for_update)\n format.html { redirect_to @alram_test, notice: 'Alram test was successfully updated.' }\n format.json { render :show, status: :ok, location: @alram_test }\n else\n format.html { render :edit }\n format.json { render json: @alram_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_allocation\n @allocation = @license.allocations.find(params[:id])\n end",
"def update\n @testbed_owner = TestbedOwner.find(params[:id])\n\n respond_to do |format|\n if @testbed_owner.update_attributes(params[:testbed_owner])\n format.html { redirect_to @testbed_owner, notice: 'Testbed owner was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @testbed_owner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @warehouse_allocation.update(warehouse_allocation_params)\n format.html { redirect_to @warehouse_allocation, notice: 'Warehouse allocation was successfully updated.' }\n format.json { render :show, status: :ok, location: @warehouse_allocation }\n else\n format.html { render :edit }\n format.json { render json: @warehouse_allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @testmonial = Testmonial.find(params[:id])\n\n if @testmonial.update(testmonial_params)\n head :no_content\n else\n render json: @testmonial.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @validation_test.update(validation_test_params)\n format.html { redirect_to @validation_test, notice: 'Validation test was successfully updated.' }\n format.json { render :show, status: :ok, location: @validation_test }\n else\n format.html { render :edit }\n format.json { render json: @validation_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @performance_test = PerformanceTest.find(params[:id])\n\n respond_to do |format|\n if @performance_test.update_attributes(params[:performance_test])\n format.html { redirect_to @performance_test, :notice => 'Performance test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @performance_test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @testing_algorithm = TestingAlgorithm.find(params[:id])\n\n if @testing_algorithm.update(params[:testing_algorithm])\n head :no_content\n else\n render json : @testing_algorithm.errors, status : :unprocessable_entity\n end\n end",
"def update\n @test_run = TestRun.accessible_by(current_ability).find(params[:id])\n\n respond_to do |format|\n if @test_run.update_attributes(params[:test_run])\n format.html { redirect_to @test_run, notice: 'Test run was successfully updated.' }\n format.json { head :no_content }\n else\n @scenario = @test_run.scenario || Scenario.new\n @registration_scenario = @scenario.registration_scenario || Scenario.new\n @profile = @test_run.profile || Profile.new\n @target = @test_run.target || Target.new\n flash[:error] = @test_run.errors.full_messages\n format.html { render action: \"edit\" }\n format.json { render json: @test_run.errors, status: 422 }\n end\n end\n end",
"def update\n if @test_guide_scenario.update(test_guide_scenario_params)\n render status: :ok, json: @test_guide_scenario\n else\n self.send(:edit)\n end\n end",
"def update\n respond_to do |format|\n if @benchmark_test.update(benchmark_test_params)\n format.html { redirect_to @benchmark_test, notice: 'Benchmark test was successfully updated.' }\n format.json { render :show, status: :ok, location: @benchmark_test }\n else\n format.html { render :edit }\n format.json { render json: @benchmark_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to root_path, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_unsuccessful\n data = {\n firstname: \"\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"[email protected]\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 1002\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update\n # respond_to do |format|\n # if @ab_test.update(ab_test_params)\n # format.html { redirect_to @ab_test, notice: 'Ab test was successfully updated.' }\n # format.json { render :show, status: :ok, location: @ab_test }\n # else\n # format.html { render :edit }\n # format.json { render json: @ab_test.errors, status: :unprocessable_entity }\n # end\n # end\n\n #render :json @data\n end",
"def update\n respond_to do |format|\n if @asset_allocate.update(asset_allocate_params)\n format.html { redirect_to @asset_allocate, notice: 'Asset allocate was successfully updated.' }\n format.json { render :show, status: :ok, location: @asset_allocate }\n else\n format.html { render :edit }\n format.json { render json: @asset_allocate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test1.update(test1_params)\n format.html { redirect_to @test1, notice: \"Test1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @test1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @test1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @section_test = SectionTest.find(params[:id])\n\n respond_to do |format|\n if @section_test.update_attributes(params[:section_test])\n format.html { redirect_to @section_test, notice: 'Section test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @section_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @allocation = @license.allocations.new(allocation_params)\n @allocation.state = :active\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to license_allocation_path(@license, @allocation), notice: 'Allocation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @allocation }\n else\n format.html { render action: 'new' }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(attrs, user = @@default_user)\n attrs = { id: @id, project_token: @project_token }.merge(attrs)\n @attributes = send_request(\"test_cases/#{attrs[:id]}\", :put) do |req|\n req.body = {\n test_case: attrs.except(:project_token, :id),\n token: attrs[:project_token],\n auth_token: user.auth_token\n }\n end\n end",
"def update\n @test_submission = TestSubmission.find(params[:id])\n\n respond_to do |format|\n if @test_submission.update_attributes(params[:test_submission])\n format.html { redirect_to @test_submission, :notice => 'Test submission was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @test_submission.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_case.update(test_case_params)\n TestMailer.admin_test_updated_email(@test_case).deliver\n \n format.html { redirect_to @test_case, notice: 'Your test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @test.update(test_params)\n respond_to do |format|\n format.html { redirect_to admin_tests_path }\n format.json { render :show, status: :ok, location: admin_tests_path }\n end\n else\n respond_to do |format|\n format.html { render :edit, notice: \"Please do you test again. An unexpected error has occured!\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end \n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_suite.update(test_suite_params)\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_suite }\n else\n format.html { render :edit }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test.update(test_params)\n format.html { redirect_to patient_path(@test.patient), notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @test }\n else\n format.html { render :edit }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_or_patch_ip_address_pool_allocation_0_with_http_info(ip_pool_id, ip_allocation_id, ip_address_allocation, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation_0 ...'\n end\n # verify the required parameter 'ip_pool_id' is set\n if @api_client.config.client_side_validation && ip_pool_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_pool_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation_0\"\n end\n # verify the required parameter 'ip_allocation_id' is set\n if @api_client.config.client_side_validation && ip_allocation_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_allocation_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation_0\"\n end\n # verify the required parameter 'ip_address_allocation' is set\n if @api_client.config.client_side_validation && ip_address_allocation.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_address_allocation' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation_0\"\n end\n # resource path\n local_var_path = '/global-infra/ip-pools/{ip-pool-id}/ip-allocations/{ip-allocation-id}'.sub('{' + 'ip-pool-id' + '}', ip_pool_id.to_s).sub('{' + 'ip-allocation-id' + '}', ip_allocation_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['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 = @api_client.object_to_http_body(ip_address_allocation)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi#create_or_patch_ip_address_pool_allocation_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n respond_to do |format|\n if @test_instance.update(test_instance_params)\n format.html { redirect_to @test_instance, notice: 'Test instance was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_instance }\n else\n format.html { render :edit }\n format.json { render json: @test_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_set = TestSet.find(params[:id])\n permitted_to! :update, @test_set.problem\n respond_to do |format|\n if @test_set.update_attributes(permitted_params)\n format.html { redirect_to @test_set, :notice => 'Test set was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @test_set.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_fee_allocation(params)\n transaction_uuid = params[:transaction_uuid]\n transaction = Transaction.by_uuid(transaction_uuid)\n\n allocation = params[:fee_allocation]\n #todo: validation\n transaction.update!(fee_allocation: allocation)\n transaction.fee_allocation\n end",
"def test_update\n\n admin_session = cathy_admin_session\n \n ibm = fab_houses(:ibm)\n fab_house = FabHouse.find(ibm.id)\n fab_house.name = 'new_fab_house'\n\n post(:update, { :fab_house => fab_house.attributes }, admin_session)\n assert_redirected_to(:action => 'edit', :id => fab_house.id)\n assert_equal('Update recorded', flash['notice'])\n assert_equal('new_fab_house', fab_house.name)\n \n post(:update, \n { :fab_house => { :name => fab_house.name, \n :id => fab_house.id.to_s, \n :active => fab_house.active.to_s } }, \n cathy_admin_session)\n assert_redirected_to(:action => 'edit', :id => fab_house.id)\n #assert_equal('Update recorded', flash['notice'])\n \n end",
"def update\n respond_to do |format|\n if @test_instance.update(test_instance_params)\n # jankety solution to set version properly\n @test_instance.update_version(true)\n\n format.html do\n redirect_to test_case_test_instances_url(@test_case),\n notice: 'Test instance was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @test_instance }\n else\n format.html { render :edit }\n format.json do\n render json: @test_instance.errors, status: :unprocessable_entity\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @testsuite.update(testsuite_params)\n format.html { redirect_to @testsuite, notice: 'Testsuite was successfully updated.' }\n format.json { render :show, status: :ok, location: @testsuite }\n else\n format.html { render :edit }\n format.json { render json: @testsuite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_stall.update(test_stall_params)\n format.html { redirect_to @test_stall, notice: 'Test stall was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_stall }\n else\n format.html { render :edit }\n format.json { render json: @test_stall.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_suite = TestSuite.find(params[:id])\n\n respond_to do |format|\n if @test_suite.update_attributes(params[:test_suite])\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_suite.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(attrs, user = @@default_user)\n attrs = { id: @id, project_token: @project_token }.merge(attrs)\n @attributes = send_request(\"test_plans/#{attrs[:id]}\", :put) do |req|\n req.body = {\n test_plan: attrs.except(:project_token, :id),\n token: attrs[:project_token],\n auth_token: user.auth_token\n }\n end\n end",
"def test_update_object_by_id\r\n\t VCR.use_cassette('edit_object') do\r\n\t\t cred=JSON.parse(YAML::load_file('test/fixtures/credential.yml').to_json)\r\n\t\t json = JSON.parse(File.read(\"test/fixtures/edit_specimen.json\"))\r\n\t\t id = json[\"id\"]\r\n\t\t json[\"id\"] = \"\" #id cannot be updated\r\n\t\t result=CordraRestClient::DigitalObject.update(API_URL, id, json, cred[\"uc_1\"])\r\n\r\n\t\t #check that the result is saved\r\n\t\t assert_equal 200, result[:code]\r\n\t\t assert_equal \"OK\", result[\"message\"]\r\n\t\tend\r\n\t end",
"def allocation_master_params\n params.require(:allocation_master).permit(:allocation_name, :allocation_input_id)\n end",
"def update\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n if @test_plan.update_attributes(params[:test_plan])\n format.html { redirect_to @test_plan, notice: 'Test plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def allocation_params\n params.require(:allocation).permit(:allocation_master_id, :product_id, :allocation_input_id, :date_dim_id, :allocation_factor, :allocation_date, :allocation_name, :allocation_basis)\n end",
"def update\n respond_to do |format|\n if @jsontest.update(jsontest_params)\n format.html { redirect_to @jsontest, notice: 'Jsontest was successfully updated.' }\n format.json { render :show, status: :ok, location: @jsontest }\n else\n format.html { render :edit }\n format.json { render json: @jsontest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @testing123.update(testing123_params)\n format.html { redirect_to @testing123, notice: 'Testing123 was successfully updated.' }\n format.json { render :show, status: :ok, location: @testing123 }\n else\n format.html { render :edit }\n format.json { render json: @testing123.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @smoke_test = SmokeTest.find(params[:id])\n\n if not params[:smoke_test][:test_suite_ids] and not params[:smoke_test][:config_templates]\n @smoke_test.config_templates.clear\n @smoke_test.test_suites.clear\n end\n respond_to do |format|\n if @smoke_test.update_attributes(params[:smoke_test])\n\n @smoke_test.test_suites.clear if @smoke_test.test_suites.size == 0\n format.html { redirect_to(@smoke_test, :notice => 'Smoke test was successfully updated.') }\n format.json { render :json => @smoke_test, :status => :ok }\n format.xml { render :xml => @smoke_test, :status => :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @smoke_test.errors, :status => :unprocessable_entity }\n format.xml { render :xml => @smoke_test.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_dep_collector.update(test_dep_collector_params)\n format.html {redirect_to @test_dep_collector, notice: 'Test dep collector was successfully updated.'}\n format.json {render :show, status: :ok, location: @test_dep_collector}\n else\n format.html {render :edit}\n format.json {render json: @test_dep_collector.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n @allocation_date = AllocationDate.find(params[:id])\n\n respond_to do |format|\n if @allocation_date.update_attributes(params[:allocation_date])\n \n# format.html { redirect_to controller: \"res_allocations\", action: \"new\", date_id: @allocation_date.id }\n format.html { redirect_to \"/allocation_dates\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @allocation_date.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nginxtest.update(nginxtest_params)\n format.html { redirect_to @nginxtest, notice: \"Nginxtest was successfully updated.\" }\n format.json { render :show, status: :ok, location: @nginxtest }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @nginxtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @applicant_test.update(applicant_test_params)\n format.html { redirect_to applicant_url(@applicant), notice: \"Test editado correctamente\" }\n format.json { render :show, status: :ok, location: applicant_url(@applicant) }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @applicant_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test = Test.find(params[:id])\n\n respond_to do |format|\n if @test.update_attributes(params[:test])\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_successful\n data = {\n firstname: \"Anh\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"[email protected]\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 200\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update\n respond_to do |format|\n if @testtest.update(testtest_params)\n format.html { redirect_to @testtest, notice: 'Testtest was successfully updated.' }\n format.json { render :show, status: :ok, location: @testtest }\n else\n format.html { render :edit }\n format.json { render json: @testtest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @allocation_test = AllocationTest.new(allocation_test_params)\n redirect_path = nil\n if not current_user.allocation_tests.any?\n redirect_path = new_gamble_path\n else\n redirect_path = survey_path\n end\n\n respond_to do |format|\n if @allocation_test.save\n format.html { redirect_to redirect_path}\n format.json { render :show, status: :created, location: @allocation_test }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @allocation_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_new_inbox_ruleset_with_http_info(test_new_inbox_ruleset_options, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: InboxRulesetControllerApi.test_new_inbox_ruleset ...'\n end\n # verify the required parameter 'test_new_inbox_ruleset_options' is set\n if @api_client.config.client_side_validation && test_new_inbox_ruleset_options.nil?\n fail ArgumentError, \"Missing the required parameter 'test_new_inbox_ruleset_options' when calling InboxRulesetControllerApi.test_new_inbox_ruleset\"\n end\n # resource path\n local_var_path = '/rulesets'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\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 = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(test_new_inbox_ruleset_options) \n\n # return_type\n return_type = opts[:return_type] || 'InboxRulesetTestResult' \n\n # auth_names\n auth_names = opts[:auth_names] || ['API_KEY']\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(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: InboxRulesetControllerApi#test_new_inbox_ruleset\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n @asset_allocation_history = AssetAllocationHistory.find(params[:id])\n\n respond_to do |format|\n if @asset_allocation_history.update_attributes(params[:asset_allocation_history])\n format.html { redirect_to @asset_allocation_history, notice: 'Asset allocation history was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset_allocation_history.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_or_replace_ip_address_pool_allocation_0_with_http_info(ip_pool_id, ip_allocation_id, ip_address_allocation, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_replace_ip_address_pool_allocation_0 ...'\n end\n # verify the required parameter 'ip_pool_id' is set\n if @api_client.config.client_side_validation && ip_pool_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_pool_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_replace_ip_address_pool_allocation_0\"\n end\n # verify the required parameter 'ip_allocation_id' is set\n if @api_client.config.client_side_validation && ip_allocation_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_allocation_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_replace_ip_address_pool_allocation_0\"\n end\n # verify the required parameter 'ip_address_allocation' is set\n if @api_client.config.client_side_validation && ip_address_allocation.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_address_allocation' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_replace_ip_address_pool_allocation_0\"\n end\n # resource path\n local_var_path = '/global-infra/ip-pools/{ip-pool-id}/ip-allocations/{ip-allocation-id}'.sub('{' + 'ip-pool-id' + '}', ip_pool_id.to_s).sub('{' + 'ip-allocation-id' + '}', ip_allocation_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['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 = @api_client.object_to_http_body(ip_address_allocation)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'IpAddressAllocation')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi#create_or_replace_ip_address_pool_allocation_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @allocation = Allocation.new(params[:allocation])\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: 'Allocation was successfully created.' }\n format.json { render json: @allocation, status: :created, location: @allocation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @allocation = Allocation.new(allocation_params)\n\n respond_to do |format|\n if @allocation.save\n format.html { redirect_to @allocation, notice: t(:allocation_created) }\n format.json { render :show, status: :created, location: @allocation }\n else\n format.html { render :new }\n format.json { render json: @allocation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test10 = Test10.find(params[:id])\n\n respond_to do |format|\n if @test10.update_attributes(params[:test10])\n format.html { redirect_to @test10, notice: 'Test10 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test10.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 new\n @allocation = Allocation.new params[:allocation]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @allocation }\n end\n end",
"def update\n respond_to do |format|\n if @test_stuff.update(test_stuff_params)\n format.html { redirect_to @test_stuff, notice: 'Test stuff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_stuff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update\n #Again the delete feature from ActiveResource does not work out of the box.\n #Using custom delete function\n puts \"--create a new account--\"\n new_acct = Salesforce::Rest::Account.new(:Name => \"test numero uno\", :BillingStreet=> \"Fairway Meadows\",\n :BillingState => \"NY\", :ShippingCity => \"New York\")\n resp = new_acct.save()\n\n assert (resp.code == 201)\n j = ActiveSupport::JSON\n @sf_oid = j.decode(resp.body)[\"id\"]\n puts \"New Object created: id -> \" + @sf_oid\n\n puts \"--update that new account--\"\n serialized_json = '{\"BillingState\":\"WA\"}'\n #http = Net::HTTP.new(@rest_svr_url, 443)\n http = Net::HTTP.new('na7.salesforce.com', 443)\n http.use_ssl = true\n \n class_name = \"Account\"\n path = \"/services/data/v21.0/sobjects/#{class_name}/#{@sf_oid}\"\n headers = {\n 'Authorization' => \"OAuth \"+ @oauth_token,\n \"content-Type\" => 'application/json',\n }\n code = serialized_json\n\n \n req = Net::HTTPGenericRequest.new(\"PATCH\", true, true, path, headers)\n\n resp = http.request(req, code) { |response| }\n assert !resp.nil?\n\n puts resp.to_s\n end",
"def create_or_patch_ip_address_pool_allocation_with_http_info(ip_pool_id, ip_allocation_id, ip_address_allocation, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation ...'\n end\n # verify the required parameter 'ip_pool_id' is set\n if @api_client.config.client_side_validation && ip_pool_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_pool_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation\"\n end\n # verify the required parameter 'ip_allocation_id' is set\n if @api_client.config.client_side_validation && ip_allocation_id.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_allocation_id' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation\"\n end\n # verify the required parameter 'ip_address_allocation' is set\n if @api_client.config.client_side_validation && ip_address_allocation.nil?\n fail ArgumentError, \"Missing the required parameter 'ip_address_allocation' when calling PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi.create_or_patch_ip_address_pool_allocation\"\n end\n # resource path\n local_var_path = '/infra/ip-pools/{ip-pool-id}/ip-allocations/{ip-allocation-id}'.sub('{' + 'ip-pool-id' + '}', ip_pool_id.to_s).sub('{' + 'ip-allocation-id' + '}', ip_allocation_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['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 = @api_client.object_to_http_body(ip_address_allocation)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingIPManagementIPAddressPoolsIPPoolsApi#create_or_patch_ip_address_pool_allocation\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n @test = LoadTest.find(params[:id])\n\n respond_to do |format|\n if @test.update_attributes(params[:load_test])\n format.html { redirect_to @test, notice: 'Test was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @choice_test.update(choice_test_params)\n format.html { redirect_to @choice_test, notice: \"Choice test was successfully updated.\" }\n format.json { render :show, status: :ok, location: @choice_test }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @choice_test.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6691268",
"0.65710807",
"0.6443952",
"0.6376934",
"0.6359231",
"0.6197849",
"0.6166732",
"0.6073905",
"0.59780383",
"0.5933964",
"0.5912709",
"0.58222693",
"0.5817471",
"0.5729198",
"0.5619015",
"0.5586988",
"0.55792004",
"0.55767983",
"0.5576299",
"0.5570958",
"0.55604804",
"0.556041",
"0.55350566",
"0.55023366",
"0.5494339",
"0.54928356",
"0.54892105",
"0.5481115",
"0.547185",
"0.54651505",
"0.54619503",
"0.54535496",
"0.5452835",
"0.54457736",
"0.5440852",
"0.5430367",
"0.5426716",
"0.5425306",
"0.5409757",
"0.5402659",
"0.54010975",
"0.5399291",
"0.53913134",
"0.5375426",
"0.53718007",
"0.53696454",
"0.53603",
"0.53590536",
"0.5351948",
"0.53512704",
"0.5349593",
"0.5341898",
"0.53358924",
"0.53349763",
"0.53349763",
"0.53349763",
"0.53349763",
"0.53349763",
"0.53349763",
"0.53349763",
"0.53245693",
"0.53150845",
"0.5309593",
"0.5300206",
"0.5299545",
"0.5298744",
"0.5298454",
"0.52968216",
"0.529649",
"0.5294481",
"0.529291",
"0.5291136",
"0.52762616",
"0.5273005",
"0.5263849",
"0.5259542",
"0.5252283",
"0.52505183",
"0.52476114",
"0.52472144",
"0.5246403",
"0.5241688",
"0.52379334",
"0.5231644",
"0.52307683",
"0.5226684",
"0.5223434",
"0.52216923",
"0.521798",
"0.5210236",
"0.5208723",
"0.52035445",
"0.51974255",
"0.5196047",
"0.51917297",
"0.51916707",
"0.517631",
"0.5171252",
"0.51695234",
"0.5164567"
] | 0.75359327 | 0 |
DELETE /allocation_tests/1 or /allocation_tests/1.json | def destroy
@allocation_test.destroy
respond_to do |format|
format.html { redirect_to allocation_tests_url, notice: "Allocation test was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @allocation.destroy\n respond_to do |format|\n format.html { redirect_to allocations_url, notice: t(:allocation_deleted) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @allocation = Allocation.find(params[:id])\n @allocation.destroy\n\n respond_to do |format|\n format.html { redirect_to allocations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testing_.destroy\n respond_to do |format|\n format.html { redirect_to testing_s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @res_allocation = ResAllocation.find(params[:id])\n @res_allocation.destroy\n\n respond_to do |format|\n format.html { redirect_to res_allocations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @allocation.destroy\n respond_to do |format|\n format.html { redirect_to allocations_url, notice: 'Allocation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @editability = Editability.find(params[:id])\n @editability.destroy\n\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @performance_test = PerformanceTest.find(params[:id])\n @performance_test.destroy\n\n respond_to do |format|\n format.html { redirect_to performance_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test_case.destroy\n respond_to do |format|\n format.html { redirect_to test_cases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_run = TestRun.accessible_by(current_ability).find(params[:id])\n @test_run.destroy\n\n respond_to do |format|\n format.html { redirect_to test_runs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test = LoadTest.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to load_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @allocation = Allocation.find(params[:id])\n @episode = @allocation.episode\n @allocation.destroy\n\n respond_to do |format|\n format.html { redirect_to client_path(@episode.client) }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @test_plan = TestPlan.find(params[:id])\n @test_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to test_plans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_run.destroy\n respond_to do |format|\n format.html { redirect_to test_runs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_summary = TestSummary.find(params[:id])\n @test_summary.destroy\n\n respond_to do |format|\n format.html { redirect_to test_summaries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ab_test.destroy\n respond_to do |format|\n format.html { redirect_to ab_tests_url, notice: 'Ab test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_suite = TestSuite.find(params[:id])\n @test_suite.destroy\n\n respond_to do |format|\n format.html { redirect_to test_suites_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Prueba eliminada exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @section_test = SectionTest.find(params[:id])\n @section_test.destroy\n\n respond_to do |format|\n format.html { redirect_to section_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test = Mg::Test.find(params[:id])\n @test.destroy\n\n respond_to do |format|\n format.html { redirect_to(mg_tests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test_stall.destroy\n respond_to do |format|\n format.html { redirect_to test_stalls_url, notice: 'Test stall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @alram_test.destroy\n respond_to do |format|\n format.html { redirect_to alram_tests_url, notice: 'Alram test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @expectation = Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to expectations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unsigned_columns_test = UnsignedColumnsTest.find(params[:id])\n @unsigned_columns_test.destroy\n\n respond_to do |format|\n format.html { redirect_to unsigned_columns_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @expectation = RiGse::Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @fixit_test.destroy\n respond_to do |format|\n format.html { redirect_to fixit_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testcase = Testcase.find(params[:id])\n @testcase.destroy\n\n respond_to do |format|\n format.html { redirect_to testcases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nginxtest.destroy\n respond_to do |format|\n format.html { redirect_to nginxtests_url, notice: \"Nginxtest was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource_allocation = ResourceAllocation.find(params[:id])\n @resource_allocation.destroy\n\n respond_to do |format|\n format.html { redirect_to(resource_allocations_url) }\n format.xml { head :ok }\n format.js\n end\n end",
"def destroy\n @assert = Assert.find(params[:id])\n @assert.destroy\n\n respond_to do |format|\n format.html { redirect_to asserts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testbed_owner = TestbedOwner.find(params[:id])\n @testbed_owner.destroy\n\n respond_to do |format|\n format.html { redirect_to testbed_owners_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @test_detail.destroy\n respond_to do |format|\n format.html { redirect_to test_details_url, notice: 'Test detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_run = TestRun.find(params[:id])\n @test_run.destroy\n\n respond_to do |format|\n format.html { redirect_to test_runs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test.destroy\n respond_to do |format|\n format.html { redirect_to tests_url, notice: 'Test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assert = Assert.find(params[:id])\n @assert.destroy\n\n respond_to do |format|\n format.html { redirect_to asserts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @metric_speedtest.destroy\n respond_to do |format|\n format.html { redirect_to metric_speedtests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @allocation_master.destroy\n respond_to do |format|\n format.html { redirect_to allocation_masters_url, notice: 'Allocation master was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testdb = Testdb.find(params[:id])\n @testdb.destroy\n\n respond_to do |format|\n format.html { redirect_to testdbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @terra_nova_test_benchmark.destroy\n respond_to do |format|\n format.html { redirect_to terra_nova_test_benchmarks_url, notice: 'Terra nova test benchmark was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @smoke_test = SmokeTest.find(params[:id])\n @smoke_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(smoke_tests_url) }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test10 = Test10.find(params[:id])\n @test10.destroy\n\n respond_to do |format|\n format.html { redirect_to test10s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @case_test.destroy\n respond_to do |format|\n format.html { redirect_to case_tests_url, notice: 'Case test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_dep_collector.destroy\n respond_to do |format|\n format.html {redirect_to test_dep_collectors_url, notice: 'Test dep collector was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @testing.destroy\n respond_to do |format|\n format.html { redirect_to testings_url, notice: 'Testing was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testmonial.destroy\n\n head :no_content\n end",
"def destroy\n\t\t\t\n\t\t\t\tTestimony.find(params[:id]).destroy\n\n\t\t\t\trender json: nil,status: 200\n\t\t\t\n\t\t\tend",
"def destroy\n @test_submission = TestSubmission.find(params[:id])\n @test_submission.destroy\n\n respond_to do |format|\n format.html { redirect_to test_submissions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @admin_test = Admin::Test.find(params[:id])\n @admin_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_tests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ref_diagnostic_test_type = Ref::DiagnosticTestType.find(params[:id])\n @ref_diagnostic_test_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_diagnostic_test_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @testtest.destroy\n respond_to do |format|\n format.html { redirect_to testtests_url, notice: 'Testtest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @operations_check = OperationsCheck.find(params[:id])\n @operations_check.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_checks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_test = TestTest.find(params[:id])\n @test_test.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_tests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @testpat.destroy\n respond_to do |format|\n format.html { redirect_to testpats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test1.destroy\n respond_to do |format|\n format.html { redirect_to test1s_url, notice: \"Test1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crash_test = CrashTest.find(params[:id])\n @crash_test.destroy\n\n respond_to do |format|\n format.html { redirect_to crash_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @translations_versions_test.destroy\n respond_to do |format|\n format.html { redirect_to translations_versions_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jquery_test.destroy\n respond_to do |format|\n format.html { redirect_to jquery_tests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_set = TestSet.find(params[:id])\n permitted_to! :destroy, @test_set\n @test_set.destroy\n\n respond_to do |format|\n format.html { redirect_to test_sets_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @jsontest.destroy\n respond_to do |format|\n format.html { redirect_to jsontests_url, notice: 'Jsontest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testsuite.destroy\n respond_to do |format|\n format.html { redirect_to testsuites_url, notice: 'Testsuite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_plan = TestPlan.find(params[:id])\n @test_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_plans_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @grass_allocation.destroy\n respond_to do |format|\n format.html { redirect_to grass_allocations_url, notice: 'Grass allocation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testing = Testing.find(params[:id])\n @testing.destroy\n\n respond_to do |format|\n format.html { redirect_to(testings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @benchmark_test.destroy\n respond_to do |format|\n format.html { redirect_to benchmark_tests_url, notice: 'Benchmark test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dtest = Dtest.find(params[:id])\n @dtest.destroy\n\n respond_to do |format|\n format.html { redirect_to dtests_url, notice: t(:dest_test) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_call.destroy\n respond_to do |format|\n format.html { redirect_to test_calls_url }\n format.json { head :no_content }\n end\n end",
"def deleteExecution(execution_id)\n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/12/execution/' + execution_id)\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {'Content-Type'=> 'application/jsonr','X-RunDeck-Auth-Token'=> API_KEY }\n r = http.delete(uri.path, headers) \n return r\nend",
"def destroy\n operations_check = OperationsCheck.find(params[:operations_check_id])\n @load_balancer_check = LoadBalancerCheck.find(params[:id])\n @load_balancer_check.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_check_path(operations_check, tab: \"load_balancers\") }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise_plan = ExercisePlan.find(params[:id])\n @exercise_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_plans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exercise_execution.destroy\n respond_to do |format|\n format.html { redirect_to exercise_executions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testis = Teste.find(params[:id])\n @testis.destroy\n\n respond_to do |format|\n format.html { redirect_to testes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tktest = Tktest.find(params[:id])\n @tktest.destroy\n\n respond_to do |format|\n format.html { redirect_to tktests_url }\n format.json { head :no_content }\n end\n end",
"def delete_ab_test(ab_test_id, opts = {})\n raise AlgoliaError, 'ab_test_id cannot be empty.' if ab_test_id.nil?\n\n @transporter.write(:DELETE, path_encode('/2/abtests/%s', ab_test_id), {}, opts)\n end",
"def destroy\n @online_test.destroy\n respond_to do |format|\n format.html { redirect_to admin_online_tests_url, notice: 'Online test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def destroy\n @test_case = TestCase.find(params[:id])\n @test_case.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_cases_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test_case = current_user.test_cases.find(params[:id])\n @test_case.logical_delete\n \n respond_to do |format|\n format.html { redirect_to(test_cases_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @runscope_test.destroy\n respond_to do |format|\n format.html { redirect_to runscope_tests_url, notice: 'Runscope test was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student_test = StudentTest.find(params[:id])\n @student_test.destroy\n\n respond_to do |format|\n format.html { redirect_to student_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @atest = Atest.find(params[:id])\n @atest.destroy\n\n respond_to do |format|\n format.html { redirect_to(atests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @asset_allocation_history = AssetAllocationHistory.find(params[:id])\n @asset_allocation_history.destroy\n\n respond_to do |format|\n format.html { redirect_to asset_allocation_histories_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 @test_datum.destroy\n respond_to do |format|\n format.html { redirect_to test_data_url, notice: 'Test datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scenario = Scenario.find(params[:id])\n @scenario.destroy\n\n respond_to do |format|\n format.html { redirect_to scenarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scenario = Scenario.find(params[:id])\n @scenario.destroy\n\n respond_to do |format|\n format.html { redirect_to scenarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_suite = TestSuite.find(params[:id])\n @test_suite.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_suites_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @patienttest.destroy\n respond_to do |format|\n format.html { redirect_to patienttests_url, notice: 'Patienttest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @choice_test.destroy\n respond_to do |format|\n format.html { redirect_to choice_tests_url, notice: \"Choice test was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end"
] | [
"0.6911397",
"0.6892234",
"0.6850457",
"0.67834747",
"0.67834747",
"0.6739281",
"0.67143124",
"0.6706566",
"0.66820115",
"0.6669262",
"0.6650305",
"0.6618751",
"0.6611394",
"0.6605287",
"0.66007185",
"0.65891427",
"0.65774184",
"0.65707254",
"0.65693647",
"0.6555484",
"0.6554559",
"0.6545436",
"0.653786",
"0.6517655",
"0.6509361",
"0.6504864",
"0.65024483",
"0.6493275",
"0.64868695",
"0.64658093",
"0.6460604",
"0.64481866",
"0.6445433",
"0.64445305",
"0.64337516",
"0.6428162",
"0.6424687",
"0.6424687",
"0.6424687",
"0.6424687",
"0.6424687",
"0.6424687",
"0.6424687",
"0.64238703",
"0.64229184",
"0.6421775",
"0.6413953",
"0.6409449",
"0.6388973",
"0.6383057",
"0.6380739",
"0.6379024",
"0.636306",
"0.63576895",
"0.635678",
"0.63525856",
"0.6348684",
"0.63451934",
"0.63369125",
"0.6334723",
"0.6333417",
"0.6328185",
"0.63191825",
"0.6314512",
"0.6310252",
"0.6299698",
"0.6299012",
"0.62914085",
"0.62840194",
"0.62777215",
"0.627735",
"0.6276235",
"0.6276126",
"0.6271925",
"0.6270758",
"0.6267132",
"0.62617946",
"0.6260841",
"0.6253456",
"0.62507993",
"0.62493575",
"0.62461513",
"0.62427354",
"0.6242655",
"0.6240535",
"0.624027",
"0.62396413",
"0.6232502",
"0.62278175",
"0.6227394",
"0.62253875",
"0.6224556",
"0.6221026",
"0.6220008",
"0.62140423",
"0.620999",
"0.620999",
"0.62099826",
"0.6206754",
"0.62004083"
] | 0.7617036 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_allocation_test
@allocation_test = AllocationTest.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 list of trusted parameters through. | def allocation_test_params
params.require(:allocation_test).permit(:test_id, :user_id,
allocation_items_attributes: [:name, :points, :allocation_test_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\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 strong_params\n params.require(:user).permit(param_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 allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); 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 param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\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 allowed?(*_)\n true\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 secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\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 permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; 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 url_allowlist=(_arg0); 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 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 list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def params(list)\n @declared_params = list\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def safelist; end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\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 shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def url_allowlist; end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] | [
"0.6950644",
"0.68134046",
"0.68034387",
"0.6796522",
"0.674668",
"0.6742105",
"0.6527854",
"0.65214247",
"0.6491907",
"0.64294493",
"0.64294493",
"0.64294493",
"0.64004904",
"0.6356768",
"0.63556653",
"0.6348119",
"0.6344521",
"0.63386923",
"0.632588",
"0.632588",
"0.632588",
"0.6315317",
"0.6300307",
"0.6266357",
"0.62616897",
"0.62586933",
"0.623662",
"0.6228699",
"0.6222646",
"0.6221808",
"0.62095183",
"0.6200624",
"0.6197454",
"0.61747247",
"0.6158626",
"0.61565846",
"0.6152596",
"0.6137625",
"0.6123762",
"0.61105245",
"0.6076312",
"0.6071771",
"0.60621834",
"0.60548234",
"0.6044156",
"0.603494",
"0.6019818",
"0.60173535",
"0.60154593",
"0.60121197",
"0.6008601",
"0.6008049",
"0.60078037",
"0.60059106",
"0.60059106",
"0.5997147",
"0.599462",
"0.59918606",
"0.5984179",
"0.59706646",
"0.59698576",
"0.5966363",
"0.5965114",
"0.59620297",
"0.5961917",
"0.59358233",
"0.5929989",
"0.59241587",
"0.59088653",
"0.59052056",
"0.59033877",
"0.58932143",
"0.58890563",
"0.5880874",
"0.5880874",
"0.5880874",
"0.58739555",
"0.5863163",
"0.585503",
"0.5845768",
"0.58438927",
"0.58353096",
"0.583153",
"0.58292353",
"0.58277905",
"0.58186984",
"0.58164775",
"0.581428",
"0.58108085",
"0.5805045",
"0.5805045",
"0.58009875",
"0.5796557",
"0.5785622",
"0.57814676",
"0.5777818",
"0.577579",
"0.57690275",
"0.5768062",
"0.57632935",
"0.57591033"
] | 0.0 | -1 |
Return or set the fetch limit. If passed an argument, return a new query with the specified limit value. Otherwise, return the current value. | def limit(value = EMPTY)
if value == EMPTY
@limit
else
clone(limit: value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def limit(limit)\n self.query.limit = limit\n self\n end",
"def apply_limit\n @query = @query.limit(@options[:limit])\n end",
"def limit(limit)\n @last_query_context.limit = limit\n self\n end",
"def limit(value)\n update_query(:limit => value)\n end",
"def limit(value)\n update_query(:limit => value)\n end",
"def limit(value)\n using(limit: value)\n end",
"def limit!(limit = nil)\n mutate(:limit, limit)\n end",
"def limit( new_limit=nil )\n\t\tif new_limit.nil?\n\t\t\treturn self.options[:limit]\n\t\telse\n\t\t\tself.log.debug \"cloning %p with new limit: %p\" % [ self, new_limit ]\n\t\t\treturn self.clone( :limit => Integer(new_limit) )\n\t\tend\n\tend",
"def add_limit(limit)\r\n filter.max_returned = limit if limit\r\n end",
"def select_limit_sql(sql)\n if @opts[:limit]\n sql << \" FETCH FIRST ROW ONLY\" if @opts[:limit] == 1\n sql << \" FETCH FIRST #{@opts[:limit]} ROWS ONLY\" if @opts[:limit] > 1\n end\n end",
"def limit(limit = nil)\n set_option(:limit, limit)\n end",
"def limit(limit); end",
"def limit\n meta.fetch('limit', nil)\n end",
"def limit\n pagination.fetch(:limit, 10).to_i\n end",
"def get_limit\n return request.query_parameters['limit'] || 100\n end",
"def query_limit(query, table, limit=nil)\n\tquery = \"select #{query} form #{table}\"\n\tif limit != nil\n\t\tquery += \" LIMIT #{limit}\"\n\tend\n\treturn query\nend",
"def limit(value)\n query_proxy = OData::Model::QueryProxy.new(self)\n query_proxy.limit(value.to_i)\n end",
"def select_limit_sql(sql)\n sql << \" TOP #{@opts[:limit]}\" if @opts[:limit]\n end",
"def limit(_limit)\n @limit = _limit\n self\n end",
"def limit(count)\n scoped(:row_limit => count)\n end",
"def limit\n @options[:limit]\n end",
"def limit(val)\n @params[:retmax] = val\n self\n end",
"def limit(value)\n\t\t\tparam(\"limit\", value)\n\t\tend",
"def limit\n @limit ||= begin\n limit_from_arguments = if first\n first\n else\n if previous_offset < 0\n previous_offset + (last ? last : 0)\n else\n last\n end\n end\n [limit_from_arguments, max_page_size].compact.min\n end\n end",
"def result_limit(offset, limit)\n proxy = APIParameterFilter.new(self)\n return proxy.result_limit(offset, limit)\n end",
"def limit(amount)\n from(default_table).limit(amount)\n end",
"def limit\n @request.params[:limit] || 10\n end",
"def limit(value)\n @query[:top] = value.to_i\n self\n end",
"def limit limit\n unless limit.is_a? Fixnum\n raise ArgumentError, 'Limit must be an integer'\n end\n @options[:limit] = limit.to_s\n self\n end",
"def select_limit_sql(sql)\n l = @opts[:limit]\n o = @opts[:offset]\n\n return unless l || o\n\n if @opts[:limit_with_ties]\n if o\n sql << \" OFFSET \"\n literal_append(sql, o)\n end\n\n if l\n sql << \" FETCH FIRST \"\n literal_append(sql, l)\n sql << \" ROWS WITH TIES\"\n end\n else\n if l\n sql << \" LIMIT \"\n literal_append(sql, l)\n end\n\n if o\n sql << \" OFFSET \"\n literal_append(sql, o)\n end\n end\n end",
"def last(*args)\n last_arg = args.last\n\n limit = args.first if args.first.kind_of?(Integer)\n with_query = last_arg.respond_to?(:merge) && !last_arg.blank?\n\n query = with_query ? last_arg : {}\n query = scoped_query(query.merge(:limit => limit || 1)).reverse\n\n # tell the Query to prepend each result from the adapter\n query.update(:add_reversed => !query.add_reversed?)\n\n if !with_query && (loaded? || lazy_possible?(tail, limit || 1))\n if limit\n new_collection(query, super(limit))\n else\n super()\n end\n else\n if limit\n all(query)\n else\n relate_resource(query.repository.read_one(query))\n end\n end\n end",
"def limit\n @column[:limit] if @column\n end",
"def limit\n self[:limit]\n end",
"def limit=(x); @opts['limit'] = x; end",
"def limit\n limit = @params[:limit].to_i\n limit = 1 if limit < 1\n [limit, MAX_LIMIT].min\n end",
"def result_limit(offset, limit)\n # we create a new object in case the user wants to store off the\n # filter chain and reuse it later\n APIParameterFilter.new(self.target, @parameters.merge({ :result_offset => offset, :result_limit => limit }))\n end",
"def retrieve_limit_value(env)\n retrieve_integer_value('LIMIT', env)\n end",
"def to_find_limit\n @limit\n end",
"def limit; @opts['limit']; end",
"def miter_limit(limit)\n end",
"def limit(to = 0)\n clone.tap { |query| query.to = to - 1 }\n end",
"def limit(value)\n merge(rvlimit: value.to_s)\n end",
"def limit( pair )\n get(\"/limit/#{pair}\")\n end",
"def default_limit\n 10\n end",
"def limit(value)\n merge(orlimit: value.to_s)\n end",
"def select_limit_sql(sql)\n if limit = @opts[:limit]\n if (offset = @opts[:offset]) && (offset > 0)\n sql.replace(\"SELECT * FROM (SELECT raw_sql_.*, ROWNUM raw_rnum_ FROM(#{sql}) raw_sql_ WHERE ROWNUM <= #{limit + offset}) WHERE raw_rnum_ > #{offset}\")\n else\n sql.replace(\"SELECT * FROM (#{sql}) WHERE ROWNUM <= #{limit}\")\n end\n end\n end",
"def limit(number)\n @options[:limit] = number\n self\n end",
"def limit(criteria, relation)\n return relation unless criteria.limit?\n\n relation.limit(criteria.limit)\n end",
"def limit; end",
"def limit; end",
"def limit; end",
"def limit=(_arg0); end",
"def limit(num_or_start, num = nil)\n if num.nil?\n raise ArgumentError, \"invalid limit\" unless num_or_start.kind_of?(Integer)\n @options['recordstoreturn'] = num_or_start\n else\n raise ArgumentError, \"invalid limit start\" unless num_or_start.kind_of?(Integer)\n raise ArgumentError, \"invalid limit size\" unless num_or_start.kind_of?(Integer)\n @options['recordstoreturn'] = num\n @options['startposition'] = num_or_start\n end\n self\n end",
"def limit(value)\n relation = clone\n relation.limit_value = value\n relation\n end",
"def visit_Arel_Nodes_SelectStatement(o, collector)\n if o.offset && !o.limit\n o.limit = Arel::Nodes::Limit.new(18446744073709551615)\n end\n super\n end",
"def limit?() @limit; end",
"def limit(value = 20)\n clone.tap { |crit| crit.options[:limit] = value.to_i }\n end",
"def limit_to(limit)\n dup(options: @options.limit_to(limit))\n end",
"def limit(amount)\n self.parameters[:limit] = amount\n self\n end",
"def limit(max_results)\n params[:max_results] = max_results\n self\n end",
"def limit(limit)\n if loaded? || proxy_owner.new_record?\n proxy_target.slice(0, limit)\n elsif find_with_proc?\n find_proxy_target_with_proc(:limit => limit)\n else\n ids = proxy_owner.send(metadata.foreign_key).slice(0, limit)\n ids = ids.first if ids.length == 1\n Array(find_proxy_target(:ids => ids))\n end\n end",
"def limit(l, o = (no_offset = true; nil))\n return from_self.limit(l, o) if @opts[:sql]\n\n if l.is_a?(Range)\n no_offset = false\n o = l.first\n l = l.last - l.first + (l.exclude_end? ? 0 : 1)\n end\n l = l.to_i if l.is_a?(String) && !l.is_a?(LiteralString)\n if l.is_a?(Integer)\n raise(Error, 'Limits must be greater than or equal to 1') unless l >= 1\n end\n\n ds = clone(:limit=>l)\n ds = ds.offset(o) unless no_offset\n ds\n end",
"def api_limit(params)\n dataset = self\n\n if num = params['limit'] || params['per_page']\n i = num.to_i\n if num =~ /[^\\d]/\n raise ApiException.new(\"invalid limit (#{num}) is not an integer\")\n elsif i > model.maximum_limit\n raise ApiException.new(\"limit (#{i}) is higher than the maximum #{model.maximum_limit}\")\n else\n dataset = dataset.limit(i)\n end\n else\n # Apply the default for limits if none is set.\n dataset.opts[:limit] ||= model.default_limit\n end\n\n dataset\n end",
"def last(limit = 1)\n from(-limit) || self\n end",
"def limit\n return 0 if just_count?\n limit = if list?\n @params[:limit_per_page_for_list].to_i\n else\n @params[:limit_per_page_for_details].to_i\n end\n limit = 1 if limit < 1\n [limit, MAX_LIST_LIMIT].min\n end",
"def limit(count)\n new(relation.take(count))\n end",
"def first(*args)\n last_arg = args.last\n\n limit = args.first if args.first.kind_of?(Integer)\n with_query = last_arg.respond_to?(:merge) && !last_arg.blank?\n\n query = with_query ? last_arg : {}\n query = scoped_query(query.merge(:limit => limit || 1))\n\n if !with_query && (loaded? || lazy_possible?(head, limit || 1))\n if limit\n new_collection(query, super(limit))\n else\n super()\n end\n else\n if limit\n all(query)\n else\n relate_resource(query.repository.read_one(query))\n end\n end\n end",
"def limit\n raise \"'iDisplayStart' was not given? #{@dts}\" unless @dts.key?(\"iDisplayStart\")\n raise \"'iDisplayEnd' was not given? #{@dts}\" unless @dts.key?(\"iDisplayLength\")\n\n disp_start = @dts[\"iDisplayStart\"].to_i\n disp_length = @dts[\"iDisplayLength\"].to_i\n\n @query = @query.page((disp_start / disp_length) + 1).per(disp_length)\n end",
"def limit(value)\n merge(cmlimit: value.to_s)\n end",
"def limit(value)\n merge(bklimit: value.to_s)\n end",
"def limit(value)\n merge(gcllimit: value.to_s)\n end",
"def limit(value)\n merge(geulimit: value.to_s)\n end",
"def limit_to(n)\n self.limit = n\n self\n end",
"def limit\n 7\n end",
"def limit(l, o = nil)\n return from_self.limit(l, o) if @opts[:sql]\n\n if Range === l\n o = l.first\n l = l.interval + 1\n end\n l = l.to_i\n raise(Error, 'Limits must be greater than or equal to 1') unless l >= 1\n opts = {:limit => l}\n if o\n o = o.to_i\n raise(Error, 'Offsets must be greater than or equal to 0') unless o >= 0\n opts[:offset] = o\n end\n clone(opts)\n end",
"def limit(value)\n merge(agulimit: value.to_s)\n end",
"def limit(value)\n merge(lelimit: value.to_s)\n end",
"def limit(n)\n unless n.is_a? Integer\n raise ArgumentError, \"#{n.inspect} not an Integer\"\n end\n\n with_options(:limit => n.to_i)\n end",
"def limit(value)\n merge(mpdlimit: value.to_s)\n end",
"def limit(value)\n merge(srlimit: value.to_s)\n end",
"def resolve_limit_options(options, sql)\n if limit = options[:limit]\n sql << \" LIMIT #{limit}\"\n\n if offset = options[:offset]\n sql << \" OFFSET #{offset}\"\n end\n end\n end",
"def limit(value)\n merge(smlimit: value.to_s)\n end",
"def limit(value)\n merge(pslimit: value.to_s)\n end",
"def limit(value)\n merge(pslimit: value.to_s)\n end",
"def limit(value)\n merge(notlimit: value.to_s)\n end",
"def limit(per_page,page=0)\n @limit = per_page\n @page = page\n\n self\n end",
"def eager_limit_strategy\n cached_fetch(:_eager_limit_strategy) do\n if self[:limit] || !returns_array?\n case s = cached_fetch(:eager_limit_strategy){default_eager_limit_strategy}\n when true\n true_eager_limit_strategy\n else\n s\n end\n end\n end\n end",
"def limit(value)\n merge(lhlimit: value.to_s)\n end",
"def limit(value)\n merge(grclimit: value.to_s)\n end",
"def build_limit(limit)\n if limit\n Arelastic::Searches::Size.new(limit)\n end\n end",
"def limit lim, off = nil\n @limit = ( lim || @limit ).to_i\n @offset = ( off || @offset ).to_i\n end",
"def take(limit = nil)\n limit ? find_take_with_limit(limit) : find_take\n end",
"def limit(num)\n self.class.new @_original_array, limit: num, offset: @_offset_value, total_count: @_total_count, padding: @_padding\n end",
"def limit(value)\n merge(wbeulimit: value.to_s)\n end",
"def limit(value)\n merge(gmclimit: value.to_s)\n end",
"def per_page(limit)\n @size = limit.to_i\n @current_page ||= 1\n self\n end",
"def set_limit\n @limit = 250\n end",
"def limit(model)\n self.table_preferences&.[](model.to_s)&.[]('limit')\n end",
"def set_limit(n)\n @limit = n\n end",
"def limit(value)\n merge(gpwplimit: value.to_s)\n end"
] | [
"0.72889",
"0.7169501",
"0.7139718",
"0.7067749",
"0.70223385",
"0.7004306",
"0.69932073",
"0.6865179",
"0.6802621",
"0.677243",
"0.6695933",
"0.6680929",
"0.66650116",
"0.66567755",
"0.66511065",
"0.6649006",
"0.66412556",
"0.6609347",
"0.6583515",
"0.6561679",
"0.65508574",
"0.65363526",
"0.6515145",
"0.64599013",
"0.64595485",
"0.64444125",
"0.64143896",
"0.6397518",
"0.63492435",
"0.6347159",
"0.6343679",
"0.63416",
"0.6268645",
"0.62452525",
"0.62434417",
"0.6216945",
"0.6207583",
"0.61996275",
"0.6181251",
"0.6176072",
"0.61729634",
"0.61503404",
"0.614325",
"0.6134471",
"0.6124288",
"0.6116728",
"0.61072373",
"0.6099238",
"0.60821515",
"0.60821515",
"0.60821515",
"0.6081184",
"0.60770065",
"0.6066708",
"0.605885",
"0.604989",
"0.60457295",
"0.6030134",
"0.601174",
"0.5990285",
"0.5989575",
"0.5974317",
"0.5963816",
"0.5958656",
"0.594323",
"0.5934911",
"0.5901909",
"0.5901014",
"0.5900781",
"0.5891309",
"0.5859107",
"0.5847076",
"0.5845037",
"0.5842462",
"0.5842098",
"0.5836881",
"0.5826353",
"0.58194625",
"0.58193463",
"0.58186287",
"0.5816955",
"0.5815686",
"0.5809166",
"0.5809166",
"0.5807542",
"0.5805487",
"0.575854",
"0.57501054",
"0.57380176",
"0.5733587",
"0.5724511",
"0.57202107",
"0.5720034",
"0.5699169",
"0.5692629",
"0.56897074",
"0.56880826",
"0.5685991",
"0.56835806",
"0.56718767"
] | 0.6559211 | 20 |
Return or set the fetch offset. If passed an argument, return a new query with the specified offset value. Otherwise, return the current value. | def offset(value = EMPTY)
if value == EMPTY
@offset
else
clone(offset: value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def offset(offset)\n self.query.offset = offset\n self\n end",
"def offset(offset)\n @last_query_context.offset = offset\n self\n end",
"def offset(count)\n Fetcher.new(self).offset(count)\n end",
"def offset(count=nil)\n if count\n count = 1 if count < 1\n @offset = count.to_i\n return self\n else\n @offset\n end\n end",
"def offset\n @options[:offset] || ((current_page - 1) * per_page)\n end",
"def offset(offset)\n @conjunction.add_offset(offset)\n nil\n end",
"def offset\n execute['offset']\n end",
"def api_offset(params)\n dataset = self\n\n # Offset results\n if num = params['offset']\n i = num.to_i\n if num =~ /[^\\d]/\n raise ApiException.new(\"invalid offset (#{num}) is not an integer\")\n else\n dataset.opts[:offset] = i\n end\n elsif num = params['page']\n i = num.to_i\n if num =~ /[^\\d]/\n raise ApiException.new(\"invalid page (#{num}) is not an integer\")\n elsif i <= 0\n raise ApiException.new(\"invalid page (#{num}) is less than 1\")\n else\n dataset.opts[:offset] = (i - 1) * dataset.opts[:limit]\n end\n end\n\n dataset\n end",
"def offset(num)\n new(relation.skip(num))\n end",
"def offset(count=nil)\n if count\n @offset = count\n self\n else\n @offset\n end\n end",
"def get_result_set_offset(page_num)\n page_num = get_validated_page_num(page_num)\n @items_per_page * (page_num -1)\n end",
"def offset\n if page <= 1\n # We want first page of results\n 0\n else\n # Max offset for search API is 999\n # If there are 20 results and the user requests page 3, there will be an empty result set\n [((page - 1) * limit), 999].min\n end\n end",
"def offset(value)\n using(offset: value)\n end",
"def offset\n limit_and_offset.last\n end",
"def at(offset)\n if loaded? || (offset >= 0 ? lazy_possible?(head, offset + 1) : lazy_possible?(tail, offset.abs))\n super\n elsif offset >= 0\n first(:offset => offset)\n else\n last(:offset => offset.abs - 1)\n end\n end",
"def offset(from = 0)\n clone.tap { |query| query.from = from }\n end",
"def offset!(offset)\n @offset = offset || 0\n self\n end",
"def offset(val)\n @params[:retstart] = val\n self\n end",
"def to_find_offset\n @offset\n end",
"def offset(off)\n return self if off == 0\n next_item.offset(off - 1)\n end",
"def offset(*args)\n args.size > 0 ? skip(args.first) : options[:skip]\n end",
"def get_offset\n @offset\n end",
"def offset(*) end",
"def add_limit_offset!(statement, limit, offset, bind_values)\n # Limit and offset is handled by subqueries (see #select_statement).\n if limit\n # If there is just a limit on rows to return, but no offset, then we\n # can use TOP clause.\n statement.sub!(/^\\s*SELECT(\\s+DISTINCT)?/i) { \"SELECT#{$1} TOP #{limit}\" }\n # bind_values << limit\n end\n end",
"def offset! attribute, offset\n if new_record?\n log \"Can't offset! a new record.\"\n else\n # Update the in-memory model\n send \"#{attribute}=\", send(attribute) + offset\n # Update the DB\n run_updater_sql 'Offset', \"#{connection.quote_column_name(attribute)} = #{connection.quote_column_name(attribute)} + #{quote_value(offset)}\"\n end\n end",
"def offset\n sanitize search_params['offset']\n end",
"def to_find_offset\n @conditions.to_find_offset\n end",
"def current_results_first\n offset + 1\n end",
"def get_current_offset\n @offset < 0 ? 0 : @offset\n end",
"def offset(num)\n self.class.new @_original_array, limit: @_limit_value, offset: num, total_count: @_total_count, padding: @_padding\n end",
"def select_sql\n return super unless o = @opts[:offset]\n raise(Error, \"#{db.database_type} requires an order be provided if using an offset\") unless order = @opts[:order]\n dsa1 = dataset_alias(1)\n rn = row_number_column\n sql = @opts[:append_sql] || ''\n subselect_sql_append(sql, unlimited.\n unordered.\n select_append{ROW_NUMBER(:over, :order=>order){}.as(rn)}.\n from_self(:alias=>dsa1).\n limit(@opts[:limit]).\n where(SQL::Identifier.new(rn) > o).\n order(rn))\n sql\n end",
"def select_sql\n return super unless o = @opts[:offset]\n l = @opts[:limit]\n order = @opts[:order]\n dsa1 = dataset_alias(1)\n dsa2 = dataset_alias(2)\n rn = row_number_column\n irn = Sequel::SQL::Identifier.new(rn).qualify(dsa2)\n subselect_sql(unlimited.\n from_self(:alias=>dsa1).\n select_more(Sequel::SQL::QualifiedIdentifier.new(dsa1, WILDCARD),\n Sequel::SQL::WindowFunction.new(SQL::Function.new(:ROW_NUMBER), Sequel::SQL::Window.new(:order=>order)).as(rn)).\n from_self(:alias=>dsa2).\n select(Sequel::SQL::QualifiedIdentifier.new(dsa2, WILDCARD)).\n where(l ? ((irn > o) & (irn <= l + o)) : (irn > o))) # Leave off limit in case of limit(nil, offset)\n end",
"def paginate_row_offset_assign(per_page = 8)\n @row_offset = params[:page] ? 1 + (params[:page].to_i - 1) * per_page : 1\n end",
"def cursor_query_for(sql, limit, offset)\n cursor = \"__arel_cursor_#{rand(0xffff)}\"\n\n return <<-eosql\n DECLARE #{cursor} SCROLL CURSOR FOR #{sql} FOR READ ONLY\n SET CURSOR ROWS #{limit} FOR #{cursor}\n OPEN #{cursor}\n FETCH ABSOLUTE #{offset+1} #{cursor}\n CLOSE #{cursor}\n DEALLOCATE #{cursor}\n eosql\n end",
"def offset\n 1\n end",
"def next_offset\n next_offset = offset + limit\n return nil if next_offset >= total\n\n next_offset\n end",
"def populate(pre_offset=nil)\n if pre_offset.nil?\n calculate_fill_indexes(nil)\n raw_populate()\n elsif @pre_offset && pre_offset == @pre_offset # Nothing need to change -- new data set bounded the same\n return self.index_range\n elsif @pre_offset && pre_offset < @pre_offset\n map_local_range()\n else\n calculate_fill_indexes(pre_offset)\n raw_populate()\n end\n end",
"def query_response(offset = 0)\n query = \"#{@query}&$offset=#{offset}\"\n return self.class.get(query).parsed_response\n end",
"def offset\n (current_page - 1) * per_page\n end",
"def offset\n (current_page - 1) * per_page\n end",
"def offset\n (current_page - 1) * per_page\n end",
"def set_offset(offset)\n @offset = offset\n self\n end",
"def offset\n (current_page - 1) * per_page\n end",
"def offset()\n @offset__\n end",
"def add_limit_offset!(statement, limit, offset, bind_values)\n if limit && offset > 0\n statement.replace \"select * from (select raw_sql_.*, rownum raw_rnum_ from (#{statement}) raw_sql_ where rownum <= ?) where raw_rnum_ > ?\"\n bind_values << offset + limit << offset\n elsif limit\n statement.replace \"select raw_sql_.* from (#{statement}) raw_sql_ where rownum <= ?\"\n bind_values << limit\n elsif offset > 0\n statement.replace \"select * from (select raw_sql_.*, rownum raw_rnum_ from (#{statement}) raw_sql_) where raw_rnum_ > ?\"\n bind_values << offset\n end\n end",
"def get_relative_position(offset, limit)\n if self.query.limit.nil? && self.query.offset == 0\n # original query is unbounded, do nothing\n return offset, limit\n elsif offset == 0 && limit && self.query.limit && limit <= self.query.limit\n # new query is subset of original query, do nothing\n return offset, limit\n end\n\n # find the relative offset\n first_pos = self.query.offset + offset\n\n # find the absolute last position (if any)\n if self.query.limit\n last_pos = self.query.offset + self.query.limit\n end\n\n # if a limit was specified, and there is no last position, or\n # the relative limit is within range, narrow the window\n if limit && (last_pos.nil? || first_pos + limit < last_pos)\n last_pos = first_pos + limit\n end\n\n # the last position is below the relative offset then the\n # query cannot be satisfied. throw an exception\n if last_pos && first_pos >= last_pos\n raise 'outside range' # TODO: raise a proper exception object\n end\n\n return first_pos, last_pos ? last_pos - first_pos : nil\n end",
"def select_sql\n return super unless o = @opts[:offset]\n raise(Error, 'MSSQL requires an order be provided if using an offset') unless order = @opts[:order]\n dsa1 = dataset_alias(1)\n dsa2 = dataset_alias(2)\n rn = row_number_column\n unlimited.\n unordered.\n from_self(:alias=>dsa2).\n select{[WILDCARD, ROW_NUMBER(:over, :order=>order){}.as(rn)]}.\n from_self(:alias=>dsa1).\n limit(@opts[:limit]).\n where(rn > o).\n select_sql\n end",
"def original_query_offset\n (hits_requested - 1) / 2\n end",
"def offset\n (page - 1) * PER_PAGE\n end",
"def get_next_offset(current)\n context.select_value(sanitize([\n %Q{\n SELECT MAX(id)\n FROM (\n SELECT id FROM #{source}\n WHERE id > ?\n ORDER BY id\n LIMIT ?\n ) AS t\n },\n current,\n chunk_size\n ])).tap do |next_offset|\n logger.debug(\"-> Next offset is: #{next_offset}\")\n end\n end",
"def limit_and_offset\n r = super\n if r.first == 1\n r\n else\n [1, r[1]]\n end\n end",
"def select_limit_sql(sql)\n l = @opts[:limit]\n o = @opts[:offset]\n\n return unless l || o\n\n if @opts[:limit_with_ties]\n if o\n sql << \" OFFSET \"\n literal_append(sql, o)\n end\n\n if l\n sql << \" FETCH FIRST \"\n literal_append(sql, l)\n sql << \" ROWS WITH TIES\"\n end\n else\n if l\n sql << \" LIMIT \"\n literal_append(sql, l)\n end\n\n if o\n sql << \" OFFSET \"\n literal_append(sql, o)\n end\n end\n end",
"def offset\n (current_page - 1) * per_page\n end",
"def select_sql\n return super unless l = @opts[:limit]\n o = @opts[:offset] || 0\n order = @opts[:order]\n dsa1 = dataset_alias(1)\n dsa2 = dataset_alias(2)\n rn = row_number_column\n irn = Sequel::SQL::Identifier.new(rn).qualify(dsa2)\n subselect_sql(unlimited.\n from_self(:alias=>dsa1).\n select_more(Sequel::SQL::QualifiedIdentifier.new(dsa1, WILDCARD),\n Sequel::SQL::WindowFunction.new(SQL::Function.new(:ROW_NUMBER), Sequel::SQL::Window.new(:order=>order)).as(rn)).\n from_self(:alias=>dsa2).\n select(Sequel::SQL::QualifiedIdentifier.new(dsa2, WILDCARD)).\n where((irn > o) & (irn <= l + o)))\n end",
"def [](offset)\n iterator = self.iterator\n iterator[offset]\n end",
"def pagination_from(collection)\n collection.offset_value + 1\n end",
"def offset\n\t\t\t@position + @offset\n\t\tend",
"def offset= offset\n @value = nil\n @offset = offset\n end",
"def item_at_offset(offset)\n item_index = self.simple_acts_as_list_scope.index(self)\n index = item_index + offset\n index < 0 ? nil : self.simple_acts_as_list_scope[index]\n end",
"def offset(arg0)\n end",
"def offset(value)\n merge(offset: value.to_s)\n end",
"def cells_per_row_offset offset\n @grpc.cells_per_row_offset_filter = offset\n self\n end",
"def pagy_get_items(collection, pagy)\n # handle arrays\n return collection[pagy.offset, pagy.items] if collection.is_a? Array\n # this should work with ActiveRecord, Sequel, Mongoid...\n collection.offset(pagy.offset).limit(pagy.items)\nend",
"def get_offset_and_limit\n if @request_params[:offset].present?\n offset = @request_params[:offset].to_i\n offset = 0 if offset < 0\n end\n\n limit = @request_params[:limit].to_i\n if limit < 1\n limit = 25\n elsif limit > 100\n limit = 100\n end\n\n if offset.nil? && @request_params[:page].present?\n offset = (@request_params[:page].to_i - 1) * limit\n offset = 0 if offset < 0\n end\n\n offset ||= 0\n\n @params = {offset: offset, limit: limit}\n end",
"def [](*args)\n case args.size\n when 1\n index = args[0]\n if index.kind_of?(Range)\n offset = index.begin\n limit = index.end - index.begin\n limit += 1 unless index.exclude_end?\n self.limit(limit, offset)\n else\n by_id(ids[index])\n end\n when 2\n offset, limit = args\n self.limit(limit, offset)\n else\n raise ArgumentError.new(\"wrong number of arguments (#{args.size} for 1 or 2)\")\n end\n end",
"def apply_paging(query, offset, limit)\n validate_paging(offset, limit)\n query.offset(offset).limit(limit)\n end",
"def update!(**args)\n @offset = args[:offset] if args.key?(:offset)\n end",
"def offset_params\n if params[:offset].present?\n @offset = params[:offset].to_i\n end\n if params[:limit].present?\n @limit = params[:limit].to_i\n end\n @offset ||= OFFSET\n @limit ||= LIMIT\n end",
"def offset_params\n if params[:offset].present?\n @offset = params[:offset].to_i\n end\n if params[:limit].present?\n @limit = params[:limit].to_i\n end\n @offset ||= OFFSET\n @limit ||= LIMIT\n end",
"def offset_params\n if params[:offset].present?\n @offset = params[:offset].to_i\n end\n if params[:limit].present?\n @limit = params[:limit].to_i\n end\n @offset ||= OFFSET\n @limit ||= LIMIT\n end",
"def offset_params\r\n if params[:offset]\r\n @offset = params[:offset].to_i\r\n end\r\n if params[:limit]\r\n @limit = params[:limit].to_i\r\n end\r\n @offset ||= OFFSET\r\n @limit ||= LIMIT\r\n end",
"def current_offset; end",
"def get_offset(opts)\n phash = Hash[@processors.map.with_index.to_a]\n if opts[:before]\n offset = phash[Mdoc.get_processor(opts[:before])]\n elsif opts[:after]\n offset = phash[Mdoc.get_processor(opts[:after])] + 1\n end\n offset\n end",
"def server_result_offset\n self.parameters[:result_offset]\n end",
"def find_by_sql(options, results_accumulator=nil, &block)\n # SugarCRM REST API has a bug (fixed in release _6.4.0.patch as indicated in SugarCRM bug number 43338)\n # where, when :limit and :offset options are passed simultaneously,\n # :limit is considered to be the smallest of the two, and :offset is the larger\n # In addition to allowing querying of large datasets while avoiding timeouts (by fetching results in small slices),\n # this implementation fixes the :limit - :offset bug so that it behaves correctly\n \n offset = options[:offset].to_i >= 1 ? options[:offset].to_i : nil\n \n # if many results are requested (i.e. multiple result slices), we call this function recursively\n # this array keeps track of which slice we are retrieving (by updating the :offset and :limit options)\n local_options = {}\n # ensure results are ordered so :limit and :offset option behave in a deterministic fashion\n local_options[:order_by] = :id unless options[:order_by]\n \n # we must ensure limit <= offset (due to bug mentioned above)\n if offset\n local_options[:limit] = [offset.to_i, SLICE_SIZE].min\n local_options[:offset] = offset if offset\n else\n local_options[:limit] = options[:limit] ? [options[:limit].to_i, SLICE_SIZE].min : SLICE_SIZE\n end\n local_options[:limit] = [local_options[:limit], options[:limit]].min if options[:limit] # don't retrieve more records than required\n local_options = options.merge(local_options)\n \n query = query_from_options(local_options)\n result_slice = connection.get_entry_list(self._module.name, query, local_options)\n return results_accumulator unless result_slice\n \n result_slice_array = Array.wrap(result_slice)\n if block_given?\n result_slice_array.each{|r| yield r }\n else\n results_accumulator = [] unless results_accumulator\n results_accumulator = results_accumulator.concat(result_slice_array)\n end\n \n # adjust options to take into account records that were already retrieved\n updated_options = {:offset => options[:offset].to_i + result_slice_array.size}\n updated_options[:limit] = (options[:limit] ? options[:limit] - result_slice_array.size : nil)\n updated_options = options.merge(updated_options)\n \n # have we retrieved all the records?\n if (updated_options[:limit] && updated_options[:limit] < 1) || local_options[:limit] > result_slice_array.size\n return results_accumulator\n else\n find_by_sql(updated_options, results_accumulator, &block)\n end\n end",
"def api_offset_and_limit(options=params)\n offset = 0\n\n if options[:offset].present?\n offset = options[:offset].to_i\n offset = 0 if offset < 0\n end\n\n limit = options[:limit].to_i\n if limit < 1\n limit = 25\n elsif limit > 100\n limit = 100\n end\n\n if offset.nil? && options[:page].present?\n offset = (options[:page].to_i - 1) * limit\n offset = 0 if offset < 0\n end\n\n [offset, limit]\n end",
"def begin; pager.offset page; end",
"def offset\n operation.offset\n end",
"def offset\n @object.send(:read_attribute,@startAttribute)\n end",
"def [](offset = 0)\n return self.array_element(- 1 + offset)\n end",
"def first_offset; end",
"def first_offset; end",
"def offset_and_limit_params\n # Ternary Logic :D\n @offset = params[:offset].nil? ? 0 : params[:offset].to_i\n @limit = params[:limit].nil? ? 20 : params[:limit].to_i\n end",
"def index(loc, offset=0) end",
"def record_cursor(offset = :min, direction = :forward)\n RecordCursor.new(self, offset, direction)\n end",
"def offset(offset)\n self.class.new(@grouping, @date_time + offset.send(@grouping.identifier))\n end",
"def new_offset(offset=0)\n self.class.new!(:civil=>civil, :parts=>time_parts, :offset=>(offset*86400).to_i)\n end",
"def offset; end",
"def offset; end",
"def offset; end",
"def offset(o)\n o = o.to_i if o.is_a?(String) && !o.is_a?(LiteralString)\n if o.is_a?(Integer)\n raise(Error, 'Offsets must be greater than or equal to 0') unless o >= 0\n end\n clone(:offset => o)\n end",
"def slice!(*args)\n offset, limit = extract_slice_arguments(*args)\n\n if self.limit || self.offset > 0\n offset, limit = get_relative_position(offset, limit)\n end\n\n update(:offset => offset, :limit => limit)\n end",
"def query_paging_custom(query, offset, limit)\n apply_paging(query, offset, limit)\n end",
"def fetch\n @fetched_record = nil\n return nil if @index >= @records.size\n rec = @records[@index]\n @index += 1\n @fetched_record = rec\n return rec\n end",
"def first(n=1)\n query(@sql + ' LIMIT ' + n.to_s, cache: false)\n end",
"def modify_limit_offset(sql)\n modified_sql = \"\"\n subquery_sql = \"\"\n in_single_quote = false\n in_double_quote = false\n nesting_level = 0\n if sql =~ /(OFFSET|LIMIT)/xmi then\n if sql =~ /\\(/ then\n sql.split(//).each_with_index do |x, i|\n case x[0]\n when 40 # left brace - (\n modified_sql << x if nesting_level == 0\n subquery_sql << x if nesting_level > 0\n nesting_level = nesting_level + 1 unless in_double_quote || in_single_quote\n when 41 # right brace - )\n nesting_level = nesting_level - 1 unless in_double_quote || in_single_quote\n if nesting_level == 0 and !in_double_quote and !in_single_quote then\n modified_sql << modify_limit_offset(subquery_sql)\n subquery_sql = \"\"\n end\n modified_sql << x if nesting_level == 0\n subquery_sql << x if nesting_level > 0 \n when 39 # single quote - '\n in_single_quote = in_single_quote ^ true unless in_double_quote\n modified_sql << x if nesting_level == 0\n subquery_sql << x if nesting_level > 0 \n when 34 # double quote - \"\n in_double_quote = in_double_quote ^ true unless in_single_quote\n modified_sql << x if nesting_level == 0\n subquery_sql << x if nesting_level > 0\n else\n modified_sql << x if nesting_level == 0\n subquery_sql << x if nesting_level > 0\n end\n raise ActiveRecord::StatementInvalid.new(\"Braces do not match: #{sql}\") if nesting_level < 0\n end\n else\n modified_sql = sql\n end\n raise ActiveRecord::StatementInvalid.new(\"Quotes do not match: #{sql}\") if in_double_quote or in_single_quote\n return \"\" if modified_sql.nil?\n select_components = modified_sql.scan(/\\ASELECT\\s+(DISTINCT)?(.*?)(?:\\s+LIMIT\\s+(.*?))?(?:\\s+OFFSET\\s+(.*?))?\\Z/xmi)\n return modified_sql if select_components[0].nil?\n final_sql = \"SELECT #{select_components[0][0]} \"\n final_sql << \"TOP #{select_components[0][2].nil? ? 1000000 : select_components[0][2]} \" \n final_sql << \"START AT #{(select_components[0][3].to_i + 1).to_s} \" unless select_components[0][3].nil?\n final_sql << \"#{select_components[0][1]}\"\n return final_sql\n else\n return sql\n end\n end",
"def fetch(name, offset=0)\n addr = pfa(name)\n @vm.fetch(addr + cells(offset))\n end",
"def []=(offset, value)\n iterator = self.iterator\n iterator[offset] = value\n end",
"def default_offset_amount\n 50\n end",
"def set_Offset(value)\n set_input(\"Offset\", value)\n end"
] | [
"0.71616685",
"0.7020441",
"0.6692578",
"0.65077627",
"0.63418084",
"0.6278891",
"0.62192494",
"0.6185706",
"0.61695546",
"0.6160593",
"0.6132295",
"0.60971963",
"0.60947216",
"0.60680705",
"0.6029035",
"0.59772104",
"0.59589416",
"0.5885133",
"0.58766437",
"0.584784",
"0.58163273",
"0.5808487",
"0.57796",
"0.5777729",
"0.5773504",
"0.5772952",
"0.5696631",
"0.5687687",
"0.5668421",
"0.56393754",
"0.56188047",
"0.56177247",
"0.5590526",
"0.5584649",
"0.5581322",
"0.5538932",
"0.5509287",
"0.55071765",
"0.5499855",
"0.5499855",
"0.5499855",
"0.5490036",
"0.5479228",
"0.5465243",
"0.5462611",
"0.54477066",
"0.54461074",
"0.5443795",
"0.5443525",
"0.54406756",
"0.5412311",
"0.54017687",
"0.5380823",
"0.5368677",
"0.53680027",
"0.5341876",
"0.5327175",
"0.5319065",
"0.52804565",
"0.52711576",
"0.5268125",
"0.5265194",
"0.5235878",
"0.5231536",
"0.5228104",
"0.52136093",
"0.5210095",
"0.5194341",
"0.5194341",
"0.5194341",
"0.5188841",
"0.5145548",
"0.5144966",
"0.5141926",
"0.5128946",
"0.51242244",
"0.5111305",
"0.51085025",
"0.5087093",
"0.50631565",
"0.5042095",
"0.5042095",
"0.5032692",
"0.5020954",
"0.50035536",
"0.5000912",
"0.49918267",
"0.49877748",
"0.49877748",
"0.49877748",
"0.49871272",
"0.49384356",
"0.49122307",
"0.49099615",
"0.49073738",
"0.4895105",
"0.48861235",
"0.48780474",
"0.4868839",
"0.4859369"
] | 0.6199856 | 7 |
Combine this query with others in an intersection ("and") relationship. Can be used to begin a new query as well, especially when called in its where variant. The query passed in can be a wide variety of types: Symbol: This is by far the most common, and it is also a special case the return value when passing a symbol is a CDQPartialPredicate, rather than CDQQuery. Methods on CDQPartialPredicate are then comparison operators against the attribute indicated by the symbol itself, which take a value operand. For example: query.where(:name).equal("Chuck").and(:title).not_equal("Manager") | def and(query = nil, *args)
merge_query(query, :and, *args) do |left, right|
NSCompoundPredicate.andPredicateWithSubpredicates([left, right])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_scope_with_and(query, &block)\n if Query === query && Query::Conditions::AbstractOperation === query.conditions\n query = query.dup\n scope_stack = self.scope_stack\n scope_stack << query\n\n begin\n yield\n ensure\n scope_stack.pop\n end\n\n else\n with_scope_without_and(query, &block)\n end\n end",
"def and(*exps)\n joined_exps = exps.join(' and ')\n @query[:filters] += \" and #{joined_exps}\"\n self\n end",
"def with(**kwargs)\n fail ArgumentError, \"with requires exactly one predicate\" if kwargs.size != 1\n\n key, predicate = kwargs.first\n predicate = expand_predicate(predicate)\n\n select do |candidate|\n methods = [key, \"query_for_#{key}\", \"names_for_#{key}\"].select do |m|\n candidate.respond_to?(m)\n end\n\n methods.any? do |method|\n Array(candidate.send(method)).any? do |r|\n begin\n predicate === r # rubocop:disable Style/CaseEquality\n rescue StandardError\n # We're going to assume this is a result of a string comparison to a custom #==\n false\n end\n end\n end\n end\n end",
"def andand(*spec)\n AndAnd.new(self, spec.flatten)\n end",
"def and(*others)\n self.class.and(self, *others)\n end",
"def and( c )\n\t\t@conditions = self.class.and( conditions, c )\n\t\tself\n\tend",
"def all_and(*args)\n Term.get AndTerm, *args\n end",
"def find_class_options_for_query_with_and(query, options={})\n options\n end",
"def and_ a, b\n self.and a, b\n end",
"def compose_and(first_condition, second_condition)\n validate_condition(first_condition)\n validate_condition(second_condition)\n first_condition.and(second_condition)\n end",
"def containing(query)\n @query[:Query] << query\n self\n end",
"def find_class_options_for_query_with_and(query, options={})\n find_options_for_visible(options)\n end",
"def and other_result\n result = dup\n result.matched = hash_intersection(matched, other_result.matched)\n result.not_matched = hash_intersection(not_matched, other_result.not_matched)\n result\n end",
"def &(ce)\n BooleanExpression.new(:AND, self, ce)\n end",
"def andand(*)\n self\n end",
"def where(*args)\n self & Criteria.new(*args)\n end",
"def and(state)\n safe_statement(state) do |st|\n @statement = Sower::Relation::AndStatement.new(@statement,st)\n end\n end",
"def and_expr\n expr = equality()\n\n while match(:and)\n operator = previous()\n right = equality()\n expr = Expr::Logical.new expr, operator, right\n end\n\n expr\n end",
"def field_search(field_queries, query)\n return query unless field_check? field_queries\n\n field_queries.each do |exps|\n sub_queries = build_sub_queries_with exps\n query = query.try(:and, sub_queries) || sub_queries\n end\n query\n end",
"def where(query_hash)\n self & self.class.new(query_hash)\n end",
"def rewrite_and(expression)\n first = expression[1]\n second = expression[2]\n\n VirtualKeywords.call_operator_replacement(:call_and, first, second)\n end",
"def and_clause\n a = factor_list\n\n space\n if accept(/and +/i)\n b = and_clause\n AST.new(:and, [a, b])\n else\n a\n end\n end",
"def search query\n @content = @reader.read if @content.nil?\n @content.select do |doc|\n rs = []\n query.terms.each do |term|\n if term.compare(doc.send(term.field))\n rs << true\n end\n end\n if query.relation == :and\n rs.count == query.terms.count\n else\n !rs.empty?\n end\n end\n end",
"def And(concat)\n @condition.and when_factory(concat)\n end",
"def where(args)\n @query.merge!(args)\n self.all\n end",
"def and_relation(relation)\n q = all\n q = q.where(relation.where_clause.ast) if relation.where_clause.present?\n q = q.joins(relation.joins_values + q.joins_values) if relation.joins_values.present?\n q = q.order(relation.order_values) if relation.order_values.present?\n q\n end",
"def and_exp(expression)\n @use_conjunction = true\n @conjunction = @builder.and(@conjunction,expression)\n\n self\n end",
"def and?\n AndPredicate.new self.to_parseable\n end",
"def and(*cond, &block)\n raise(Error::NoExistingFilter, \"No existing filter found.\") unless @opts[:having] || @opts[:where]\n filter(*cond, &block)\n end",
"def build_query(params)\n query = UserInteraction.includes(:user, :interaction, :answer)\n fields = get_fields()\n params.each do |filter|\n field_id = filter['field'].to_sym\n operator = filter['operand']\n operand = filter['value']\n if operator == FILTER_OPERATOR_CONTAINS\n query = query.where( get_active_record_expression(fields[field_id]['column_name'], operator, fields[field_id]['model']), \"%\"+operand.to_s+\"%\" )\n else\n query = query.where( get_active_record_expression(fields[field_id]['column_name'], operator, fields[field_id]['model']), operand )\n end\n end\n return query \n end",
"def and(other)\n raise TypeError, \"no conversion from #{other.class.name} to ClaimPredicate\" unless ClaimPredicate === other\n ClaimPredicate.new(ClaimPredicateType::AND, [self, other])\n end",
"def and(other)\n self\n end",
"def logical_and\n expr = equality\n\n while match?(:and)\n operator = previous\n right = equality\n expr = Ringo::Logical.new(expr, operator, right)\n end\n\n expr\n end",
"def m_ar_and_chain_1\n Rows.where(:x && :y)\n end",
"def and_c\n end",
"def &(predicate)\n predicate.is_a?(Predicate) ? Predicate::Intersection.new(self, predicate) : self\n end",
"def fn_and(*conditions)\n {\n \"Fn::And\" => conditions\n }\n end",
"def query\n ([query_for_one_keyword] * split_query_string.size).join(' AND ')\n end",
"def virtual_and(&block)\n virtualize_keyword(:and, @and_rewriter, block)\n end",
"def and(other_predicate)\n if self == other_predicate then self\n elsif other_predicate.kind_of?(UnboundTaskPredicate::False)\n other_predicate\n else\n And.new(self, other_predicate)\n end\n end",
"def where(query)\n @last_query_context = QL::QueryContext.new(self)\n @last_query_context.register_query(query)\n @last_query_context = QL.to_query(query, @last_query_context)\n self\n end",
"def build_where(query)\n where = \"\"\n query.each_pair do |k, v| \n if (k!='include' and k!='exclude')\n where += \"(`#{escape_str_field(k)}` #{build_equal_condition(v)}) AND \"\n end\n end\n where.chomp(' AND ')\n end",
"def and(other)\n to_unbound_task_predicate\n .and(other.to_unbound_task_predicate)\n end",
"def and\n @conjuncted_restriction_type = :all_of\n @conjuncted_restriction = Restriction.new(@column)\n end",
"def where(query={}, options={})\n new.where(query)\n end",
"def where( expression )\n dup.use do |result|\n if expression.is_a?(Hash) then\n found = expression.keys.select{|k| @fields.member?(k.to_s)}\n assert(found.length == expression.length, \"where set references non-existent fields\")\n\n comparisons = expression.collect do |k, v|\n field = @fields[k.to_s]\n create_comparison(field, create_literal(field.type_info, v))\n end\n\n result.and_where!(create_and(comparisons))\n else\n result.and_where!(expression)\n end\n \n Schemaform.debug.dump(result, \"AFTER WHERE: \")\n end\n end",
"def query_full\n query = @initial_query.dup\n\n # restrict to select columns\n query = query_projection(query)\n\n #filter\n query = query_filter(query)\n\n # sorting\n query = query_sort(query)\n\n # paging\n query_paging(query)\n end",
"def simple_equals_in other\n Search.alive?\n .where(query: other.query)\n .joins(:pseudo_graph_pattern)\n .where(pseudo_graph_patterns: { read_timeout: other.read_timeout })\n .where(pseudo_graph_patterns: { sparql_limit: other.sparql_limit })\n .where(pseudo_graph_patterns: { answer_limit: other.answer_limit })\n .where(pseudo_graph_patterns: { target: other.target })\n .where(pseudo_graph_patterns: { private: false })\n .order(created_at: :desc)\n .first\n end",
"def and_op(left, right, result) #method\n left = get_dir(left)\n right = get_dir(right)\n @current_context[result] = get_value(left) && get_value(right)\n end",
"def apply(query)\n queries_sql = queries.map do |context_query|\n context_query.to_where_sql(enclose_with_parentheses: queries.size > 1)\n end.join(\" OR \")\n query.to_active_record_query.where(queries_sql).to_seek_query\n end",
"def query_search(query, options={})\n run_query query, options\n end",
"def and\n self\n end",
"def and(*array_matchers, **keyword_matchers)\n create_matcher('and', array_matchers, keyword_matchers)\n end",
"def and(*array_matchers, **keyword_matchers)\n create_matcher('and', array_matchers, keyword_matchers)\n end",
"def and_matcher(*args)\n AndMatcher.new(args)\n end",
"def expert_equals_in other\n Search.alive?\n .joins(pseudo_graph_pattern: :term_mappings)\n .where(pseudo_graph_patterns: { read_timeout: other.read_timeout })\n .where(pseudo_graph_patterns: { sparql_limit: other.sparql_limit })\n .where(pseudo_graph_patterns: { answer_limit: other.answer_limit })\n .where(pseudo_graph_patterns: { target: other.target })\n .where(pseudo_graph_patterns: { private: false })\n .where(pseudo_graph_patterns: { term_mappings: { dataset_name: other.target } })\n .where(pseudo_graph_patterns: { term_mappings: { mapping: other.mappings } })\n .order(created_at: :desc)\n .first\n end",
"def where(*args)\n execute_in_union_relations(union_relations, :where, *args)\n self\n end",
"def logical_and(input_a, input_b, name: nil)\n check_data_types(input_a, input_b)\n _op(:logical_and, input_a, input_b, name: name)\n end",
"def where(*exps)\n joined_exps = exps.join(' and ')\n return self if joined_exps.empty?\n\n if @query[:filters].nil?\n @query[:filters] = joined_exps\n else\n @query[:filters] += \" and #{joined_exps}\"\n end\n\n self\n end",
"def in(table,column,list,and_or=\"and\")\n if and_or == \"and\"\n @use_conjunction = true\n @conjunction = @builder.and(@conjunction,@builder.in(@alias[table].get(column),list))\n else # or\n @use_disjunction = true\n @disjunction = @builder.and(@disjunction,@builder.in(@alias[table].get(column),list))\n end\n self\n end",
"def query1\n @cquery = \"\"\n @tquery = \"\"\n if params[:condition_query].present?\n @cquery = params[:condition_query]\n responses = AlternateName.search(@cquery).records\n @conditions = []\n responses.each do |response|\n response.medical_conditions.each do |condition|\n @conditions << condition\n end\n end\n else\n @conditions = MedicalCondition.all\n end\n if params[:therapy_query].present?\n @tquery = params[:therapy_query]\n @therapies = MedicalTherapy.search(@tquery).records\n else\n @therapies = []\n end\n end",
"def build_query(*args)\n opts = {}\n opts = args.pop if args.last.kind_of? Hash\n\n # Add the default query, if there is one\n if not @default_query.nil? then\n # make sure there is an AND if working with a cmdline supplied part\n args.push('AND') unless args.empty?\n case @default_query\n when Array\n args.push @default_query.join(' AND ')\n when Proc\n args.push @default_query.call()\n else\n args.push @default_query.to_s\n end\n end\n\n # Get prefix as a String.\n case @prefix_query\n when Array\n prefix = @prefix_query.join(' AND ') + ' AND'\n when Proc\n prefix = @prefix_query.call()\n else\n prefix = @prefix_query.to_s\n end\n args.unshift(prefix) unless opts.has_key? :noprefix\n\n # Get suffix as a String.\n case @suffix_query\n when Array\n suffix = 'AND ' + @suffix_query.join(' AND ')\n when Proc\n suffix = @suffix_query.call()\n else\n suffix = @suffix_query.to_s\n end\n args.push(suffix) unless opts.has_key? :nosuffix\n\n args.flatten.compact.join(' ')\n end",
"def intersect(dataset, opts=OPTS)\n raise(InvalidOperation, \"INTERSECT not supported\") unless supports_intersect_except?\n raise(InvalidOperation, \"INTERSECT ALL not supported\") if opts[:all] && !supports_intersect_except_all?\n compound_clone(:intersect, dataset, opts)\n end",
"def and_d\n end",
"def logical_and(input_a, input_b, name: nil)\n input_a, input_b = check_data_types(input_a, input_b)\n _op(:logical_and, input_a, input_b, name: name)\n end",
"def & other\n call_enum \"boolean\", other, :and\n end",
"def &(expr2)\n Operator.new(S_AND, self, expr2)\n end",
"def and_b\n end",
"def andp(rule, &block)\n ext(AndPredicate.new(rule), block)\n end",
"def andp(rule, &block)\n ext(AndPredicate.new(rule), block)\n end",
"def and(other)\n if self && !self.nil?\n other\n else\n self\n end\n end",
"def query_constraints\n # the `+` with @facet_constraint_component is copied from original implementation, and\n # I think is about \"advanced search\" feature?\n\n helpers.render(@query_constraint_component.new(\n search_state: @search_state\n )) + helpers.render(@facet_constraint_component.with_collection(clause_presenters.to_a, **@facet_constraint_component_options))\n end",
"def on_and(ast_node, context)\n left, right = *ast_node\n\n return on_call_boolean(context, left) && on_call_boolean(context, right)\n end",
"def compile_query\n #puts \"DATASET COMPILE self #{self}\"\n #puts \"DATASET COMPILE queries #{queries}\"\n \n # Old way: works but doesn't handle fmp compound queries.\n #query.each_with_object([{},{}]){|x,o| o[0].merge!(x[0] || {}); o[1].merge!(x[1] || {})}\n \n # New way: handles compound queries. Reqires ginjo-rfm 3.0.11.\n return unless queries # This should help introspecting dataset that results from record deletion. TODO: test this.\n queries.inject {|new_query,scope| apply_scope(new_query, scope)} ##puts \"SCOPE INJECTION scope:#{scope} new_query:#{new_query}\"; \n end",
"def matches(other)\n other.kind_of?(QueryField) && other.name == @name && other.operation == @operation && other.boost == @boost \n end",
"def AndExpr(path, parsed); end",
"def results(base_query)\n return base_query if @filters.nil?\n base_query.where @filters\n end",
"def intersect_all(other)\n set_operation(other, :intersect, distinct: false)\n end",
"def queries(with_orgs=true)\n condition_parts(with_orgs).reduce(:merge)\n end",
"def search_conditions(query, fields=nil)\n return nil if query.blank?\n fields ||= @search_columns\n\n # split the query by commas as well as spaces, just in case\n words = query.split(\",\").map(&:split).flatten\n\n binds = {} # bind symbols\n or_frags = [] # OR fragments\n count = 1 # to keep count on the symbols and OR fragments\n\n words.each do |word|\n like_frags = [fields].flatten.map { |f| \"LOWER(#{f}) LIKE :word#{count}\" }\n or_frags << \"(#{like_frags.join(\" OR \")})\"\n binds[\"word#{count}\".to_sym] = \"%#{word.to_s.downcase}%\"\n count += 1\n end\n [or_frags.join(\" AND \"), binds]\n end",
"def for_query(query)\n all.find { |f| f.query == query }\n end",
"def query(query=nil, options={})\n options = options.symbolize_keys\n query_params = query ? options.merge({ql: query}) : options\n self.get({params: query_params })\n self\n end",
"def merge_query_objects(*query_objects)\n merged_query = {}.with_indifferent_access\n query_objects.compact.each do |query|\n query.each_pair do |facet_name, opts|\n if merged_query[facet_name].nil?\n merged_query[facet_name] = opts\n else\n opts.each_pair do |operator, values|\n values.each do |value|\n merged_query[facet_name][operator] << value unless merged_query[facet_name][operator].include?(value)\n end\n end\n end\n end\n end\n merged_query\n end",
"def conditions(model, hash)\n validate_model(model)\n validate_hash(hash)\n\n definition = select_definition_from_model(model)\n cleaned_query_hash = Clearly::Query::Cleaner.new.do(hash)\n\n # default combiner is :and\n parse_conditions(definition, :and, cleaned_query_hash)\n end",
"def and_a\n end",
"def of(query)\n query\n end",
"def apply_narrowing_filters\n @filters[:narrowing].each do |filter|\n @query = @query.where(filter => @options[filter])\n end\n @query\n end",
"def query_for_one_keyword\n return @query_for_one_keyword if @query_for_one_keyword\n\n query = fields.map { |field| \"lower(#{field}) LIKE ?\" }\n .join(' OR ')\n @query_for_one_keyword = \"(#{query})\"\n end",
"def intersection\n self.reduce(&:intersection)\n end",
"def query_chain(qlass = self, &block)\n chain = QueryChain.new(qlass)\n chain.instance_exec &block if block_given?\n chain._result\n end",
"def construct_query(ids)\n # Some descendants of ActiveFedora::Base are anonymous classes. They don't have names. Filter them out.\n candidate_classes = klass.descendants.select(&:name)\n candidate_classes += [klass] unless klass == ActiveFedora::Base\n model_pairs = candidate_classes.each_with_object([]) { |klass, arr| arr << [:has_model, klass.to_class_uri] }\n '(' + ActiveFedora::SolrQueryBuilder.construct_query_for_ids(ids) + ') AND (' +\n ActiveFedora::SolrQueryBuilder.construct_query_for_rel(model_pairs, 'OR') + ')'\n end",
"def handle_AND(clause)\n \"#{clause.gsub!(' AND ', ' ').strip!}\"\n clause.gsub!('( ', '(')\n clause.gsub!(' )', ')')\n clause\n end",
"def apply_filters(query)\n query\n end",
"def query(query, phrase=false)\n if phrase\n q = %q[]\n params['q'] = query.gsub(\" \",\"+\").gsub('\"',\"'\")\n else\n params['q'] = CGI.escape(query)\n end\n params.merge!({'fq' => query_filters.uniq.join(\"+AND+\")}) unless query_filters.empty?\n self\n end",
"def and(e1, e2)\n eval_ex(e1) & eval_ex(e2)\n end",
"def create_query!(cond, keys, invert = false)\n keys.map { |key|\n values = cond.delete(key)\n values = [values] unless values.is_a?(Array)\n values.map { |value| create_query_op(key, value, invert) }.inject(&:|)\n }.inject(invert ? :| : :&)\n end",
"def bt_intersect(*args)\n where(arel_bt_intersect(*bt_temporal(*args)))\n end",
"def build_where_ns(query,ns)\n where = \"\"\n query.each_pair do |k, v| \n if (k!='include' and k!='exclude')\n where += \"(`#{ns}`.`#{escape_str_field(k)}` #{build_equal_condition(v)}) AND \"\n end\n end\n where.chomp(' AND ')\n end",
"def intersect(other)\n set_operation(other, :intersect, distinct: true)\n end",
"def create_query!(cond, keys, invert = false)\n keys.map { |key|\n values = cond.delete(key)\n values = values.is_a?(Array) ? values.uniq: [values]\n create_query_op(key, values, invert)\n }.inject(invert ? :| : :&)\n end"
] | [
"0.6269062",
"0.61989015",
"0.6102245",
"0.60790914",
"0.6026933",
"0.59913754",
"0.59749824",
"0.59085655",
"0.5833891",
"0.5806791",
"0.5798313",
"0.5752054",
"0.5740845",
"0.57124114",
"0.5711134",
"0.5710215",
"0.5708985",
"0.5690314",
"0.5680164",
"0.5673887",
"0.5619271",
"0.56170046",
"0.5579291",
"0.55669194",
"0.55589443",
"0.5507134",
"0.5490104",
"0.5483905",
"0.54808974",
"0.5463322",
"0.54606634",
"0.5459736",
"0.5449239",
"0.5448696",
"0.5443932",
"0.5440518",
"0.54263675",
"0.5379494",
"0.53569347",
"0.53444004",
"0.53288925",
"0.53200823",
"0.53136027",
"0.531326",
"0.52714306",
"0.5227827",
"0.5227054",
"0.5200076",
"0.51959485",
"0.5157681",
"0.51552975",
"0.5151707",
"0.514627",
"0.514627",
"0.514606",
"0.5139041",
"0.51207423",
"0.50907636",
"0.508492",
"0.50699335",
"0.5064529",
"0.5057686",
"0.5048558",
"0.5047887",
"0.50419277",
"0.5020732",
"0.50114286",
"0.49858522",
"0.4961889",
"0.4961889",
"0.4960935",
"0.49577194",
"0.4947099",
"0.49378753",
"0.4928426",
"0.4914821",
"0.49128503",
"0.49097785",
"0.49059185",
"0.4904363",
"0.49040467",
"0.48998645",
"0.48995367",
"0.48993862",
"0.48947385",
"0.4890031",
"0.48877692",
"0.4873803",
"0.48715532",
"0.4870517",
"0.48696002",
"0.48629755",
"0.48624322",
"0.4860328",
"0.48545298",
"0.4853985",
"0.4842814",
"0.4838398",
"0.4836138",
"0.48326892"
] | 0.7037875 | 0 |
Combine this query with others in a union ("or") relationship. Accepts all the same argument types as and. | def or(query = nil, *args)
merge_query(query, :or, *args) do |left, right|
NSCompoundPredicate.orPredicateWithSubpredicates([left, right])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def or(*others)\n self.class.or(self, *others)\n end",
"def combine_or(left, right)\n OrQuery.new(left, right)\n end",
"def all_or(*args)\n Term.get OrTerm, *args\n end",
"def or(*exps)\n joined_exps = exps.join(' and ')\n @query[:filters] += \" or #{joined_exps}\"\n self\n end",
"def or( *args ); { $or => args } end",
"def union_all(other)\n set_operation(\n other,\n :+,\n distinct: false,\n add_boundaries: true,\n inherit_boundaries: true\n )\n end",
"def and(*others)\n self.class.and(self, *others)\n end",
"def union(*relations)\n relations.all?{|r| is_relation!(r)}\n relations.inject(nil){|memo,r| memo.nil? ? r : memo.union(r)}\n end",
"def union?(*types)\n tm = types.map { |t| wrap(t) }\n ->(o) { tm.map { |t| t.call(o) }.any? }\n end",
"def m_ar_or_chain_1\n Rows.where(:x || :y)\n end",
"def union(other)\n self.class.from_a(to_a | other.to_a)\n end",
"def union(ele1, ele2, *other_args)\n new = [ele1, ele2, *other_args]\n return new.flatten\nend",
"def union(other)\n set_operation(other, :+,\n distinct: true,\n add_boundaries: true)\n end",
"def where(*args)\n execute_in_union_relations(union_relations, :where, *args)\n self\n end",
"def union itemA, itemB\n\tend",
"def union(*arrs)\n arrs.flatten\nend",
"def or(other)\n other\n end",
"def union(other)\n self.class.from_a(to_a | other.to_a)\n end",
"def or(query_hash)\n self | self.class.new(query_hash)\n end",
"def on_union(plan, expr, left, right)\n rewrite(plan, expr, left, Processor::Merge, [:union, right.sexpr])\n end",
"def compose_or(first_condition, second_condition)\n validate_condition(first_condition)\n validate_condition(second_condition)\n first_condition.or(second_condition)\n end",
"def or_clause\n a = and_clause\n\n space\n if accept(/or +/i)\n b = or_clause\n AST.new(:or, [a, b])\n else\n a\n end\n end",
"def union(lb)\n\n\n\n\n\n end",
"def unionise *sub_queries\n sub_queries_with_parens = sub_queries.map do |i| \n \"{ #{i} }\" \n end\n\n sub_queries_with_parens.join(' UNION ')\n end",
"def or other_result\n result = dup\n result.matched = hash_union(matched, other_result.matched)\n result.not_matched = hash_union(not_matched, other_result.not_matched)\n result\n end",
"def or(other)\n if self && !self.nil?\n self\n else\n other\n end\n end",
"def logical_or\n expr = logical_and\n\n while match?(:or)\n operator = previous\n right = logical_and\n expr = Ringo::Logical.new(expr, operator, right)\n end\n\n expr\n end",
"def or(argument1, argument2)\n argument1 || argument2\n end",
"def or(e1, e2)\n eval_ex(e1) | eval_ex(e2)\n end",
"def or_filter(filters)\n @orFilter ||= {}\n @orFilter.merge!(filters)\n self\n end",
"def union(other)\n new(to_ary | other.to_ary)\n end",
"def union(other)\n if union_compatible?(other)\n UnitedRelation.new(self, other)\n else\n raise 'Cannot create a union with the given relation'\n end\n end",
"def union_all!\n @union_all = true if recursive?\n end",
"def |( other_filter )\n\t\treturn other_filter if self.promiscuous?\n\t\treturn self.dup if other_filter.promiscuous?\n\n\t\t# Collapse nested ORs into a single one with an additional alternation\n\t\t# if possible.\n\t\tif self.component.respond_to?( :add_alternation )\n\t\t\tself.log.debug \"collapsing nested ORs...\"\n\t\t\tnewcomp = self.component.dup\n\t\t\tnewcomp.add_alternation( other_filter )\n\t\t\treturn self.class.new( newcomp )\n\t\telse\n\t\t\treturn self.class.new( :or, [self, other_filter] )\n\t\tend\n\tend",
"def | other\n call_enum \"boolean\", other, :or\n end",
"def or(arg)\n if condition_specifier?(arg)\n SQL::BooleanExpression.from_value_pairs(arg, :OR, false)\n else\n raise Error, 'must pass a conditions specifier to Sequel.or'\n end\n end",
"def or(policy, *others)\n __factory_method__(Or, policy, others)\n end",
"def union(value1, value2)\n union_by_size find(value1), find(value2)\n end",
"def union(arg1, *arg2)\n first = arg1\n rest = []\n arg2.each do |char|\n char.each do |subchar|\n rest << subchar\n end\n end\n return first + rest\n \nend",
"def build_query(base)\n # Expose columns and get the list of the ones for select\n columns = expose_columns(base, @query.try(:arel_table))\n sub_columns = columns.dup\n type = @union_all.present? ? 'all' : ''\n\n # Build any extra columns that are dynamic and from the recursion\n extra_columns(base, columns, sub_columns)\n\n # Prepare the query depending on its type\n if @query.is_a?(String) && @sub_query.is_a?(String)\n args = @args.each_with_object({}) { |h, (k, v)| h[k] = base.connection.quote(v) }\n ::Arel.sql(\"(#{@query} UNION #{type.upcase} #{@sub_query})\" % args)\n elsif relation_query?(@query)\n @query = @query.where(@where) if @where.present?\n @bound_attributes.concat(@query.send(:bound_attributes))\n\n if relation_query?(@sub_query)\n @bound_attributes.concat(@sub_query.send(:bound_attributes))\n\n sub_query = @sub_query.select(*sub_columns).arel\n sub_query.from([@sub_query.arel_table, table])\n else\n sub_query = ::Arel.sql(@sub_query)\n end\n\n @query.select(*columns).arel.union(type, sub_query)\n else\n raise ArgumentError, <<-MSG.squish\n Only String and ActiveRecord::Base objects are accepted as query and sub query\n objects, #{@query.class.name} given for #{self.class.name}.\n MSG\n end\n end",
"def |(other)\n Or.new(self, other)\n end",
"def rewrite_or(expression)\n first = expression[1]\n second = expression[2]\n\n VirtualKeywords.call_operator_replacement(:call_or, first, second)\n end",
"def or(attribute, value, options = {})\n options[:comparison] ||= value.is_a?(Regexp) ? :match : '=='\n if empty?\n @type.where(attribute, value, comparison: options[:comparison], api_client: @api_client)\n else\n merge first.class.where(\n attribute, value,\n comparison: options[:comparison],\n api_client: @api_client\n )\n end\n end",
"def or_expr\n expr = and_expr()\n\n while match(:or)\n operator = previous()\n right = and_expr()\n expr = Expr::Logical.new expr, operator, right\n end\n\n expr\n end",
"def or(*cond, &block)\n clause = (@opts[:having] ? :having : :where)\n cond = cond.first if cond.size == 1\n if @opts[clause]\n clone(clause => SQL::BooleanExpression.new(:OR, @opts[clause], filter_expr(block || cond)))\n else\n raise Error::NoExistingFilter, \"No existing filter found.\"\n end\n end",
"def or_else(*args, &block)\n Utils.assert_arg_or_block!(\"or_else\", *args, &block)\n super.tap do |result|\n Utils.assert_type!(result, left_class, right_class)\n end\n end",
"def or\n @options[:conditional_operator] = \"OR\"\n self\n end",
"def union(dataset, opts=OPTS)\n compound_clone(:union, dataset, opts)\n end",
"def combine_squeel_expressions(left_expression, left_expression_joins, operator,\n right_expression, right_expression_joins)\n case operator\n when :& then conjunction_expressions(left_expression, left_expression_joins,\n right_expression, right_expression_joins)\n when :| then disjunction_expressions(left_expression, left_expression_joins,\n right_expression, right_expression_joins)\n else\n raise ArgumentError, \"#{operator} must either be :& or :|\"\n end\n end",
"def merge(*others)\n constraints = ([self]+others).flat_map(&:to_constr)\n return TypeInference.unify(*constraints)\n end",
"def union(other)\n new(to_ary | other)\n end",
"def union(dataset, all = false)\n clone(:union => dataset, :union_all => all)\n end",
"def or_a\n end",
"def queries(with_orgs=true)\n condition_parts(with_orgs).reduce(:merge)\n end",
"def union(another_geometry)\n raise Error::UnsupportedOperation, \"Method Geometry#union not defined.\"\n end",
"def or(*cond, &block)\n if @opts[:where].nil?\n self\n else\n add_filter(:where, cond, false, :OR, &block)\n end\n end",
"def combine exp, line = nil\n combined = Sexp.new(:or, self, exp).line(line || -2)\n\n combined.or_depth = [self.or_depth, exp.or_depth].compact.reduce(0, :+) + 1\n\n combined\n end",
"def where_union(*relations, primary_key: :id, foreign_key: :id)\n arels = relations.map { |relation| relation.select(foreign_key).arel }\n union = arels.reduce do |left, right|\n Arel::Nodes::UnionAll.new(left, right)\n end\n\n where(arel_table[primary_key].in(union))\n end",
"def union(query)\n union_context = QL::QueryContext.new(self)\n union_context.register_query(query)\n union_context = QL.to_query(query, union_context)\n\n @last_query_context.union(union_context)\n self\n end",
"def or(other)\n to_unbound_task_predicate\n .or(other.to_unbound_task_predicate)\n end",
"def or a, b\n a.prove { yield }\n b.prove { yield }\n end",
"def union(op_izq, op_der)\n op_izq | op_der # ese | es el mensaje (union) entre arrays, no confundir con los | entre JPs y PCs\n end",
"def or( c )\n\t\t@conditions = self.class.or( conditions, c )\n\t\tself\n\tend",
"def union\n @grpc.union\n end",
"def execute_OR(destination, source)\n\t\t# all flags are affected except AF is undefined\n\t\tdestination.value |= source.value\n\t\tset_logical_flags_from destination.value, destination.size\n\tend",
"def all_and(*args)\n Term.get AndTerm, *args\n end",
"def union(other)\n @bits | bits_from_object(other)\n end",
"def or_b\n end",
"def fn_or(*conditions)\n {\n \"Fn::Or\" => conditions\n }\n end",
"def or(state)\n safe_statement(state) do |st|\n @statement = Sower::Relation::OrStatement.new(@statement,st)\n end\n end",
"def on_or(ast_node, context)\n left, right = *ast_node\n\n return on_call_boolean(context, left) || on_call_boolean(context, right)\n end",
"def add_or\n\t\[email protected]([]) if @filters.last && @filters.last.size > 0\n\t\treturn self\n\tend",
"def andand(*)\n self\n end",
"def union(a,b)\n print a | b # union([1,2,3],[2,3,4]) => [1, 2, 3, 4] \nend",
"def |(other)\n a = first_param\n b = other.first_param\n\n case\n when a.is_a?(RequiredPositional) && b.is_a?(RequiredPositional)\n AST::Types::Union.build(types: [a.type, b.type]).yield_self do |type|\n (self.drop_first | other.drop_first)&.with_first_param(RequiredPositional.new(type))\n end\n when a.is_a?(RequiredPositional) && b.is_a?(OptionalPositional)\n AST::Types::Union.build(types: [a.type, b.type]).yield_self do |type|\n (self.drop_first | other.drop_first)&.with_first_param(OptionalPositional.new(type))\n end\n when a.is_a?(RequiredPositional) && b.is_a?(RestPositional)\n AST::Types::Union.build(types: [a.type, b.type]).yield_self do |type|\n (self.drop_first | other.drop_first)&.with_first_param(OptionalPositional.new(type))\n end\n when a.is_a?(RequiredPositional) && b.nil?\n self.drop_first&.with_first_param(OptionalPositional.new(a.type))\n when a.is_a?(OptionalPositional) && b.is_a?(RequiredPositional)\n AST::Types::Union.build(types: [a.type, b.type]).yield_self do |type|\n (self.drop_first | other.drop_first)&.with_first_param(OptionalPositional.new(type))\n end\n when a.is_a?(OptionalPositional) && b.is_a?(OptionalPositional)\n AST::Types::Union.build(types: [a.type, b.type]).yield_self do |type|\n (self.drop_first | other.drop_first)&.with_first_param(OptionalPositional.new(type))\n end\n when a.is_a?(OptionalPositional) && b.is_a?(RestPositional)\n AST::Types::Union.build(types: [a.type, b.type]).yield_self do |type|\n (self.drop_first | other.drop_first)&.with_first_param(OptionalPositional.new(type))\n end\n when a.is_a?(OptionalPositional) && b.nil?\n (self.drop_first | other)&.with_first_param(a)\n when a.is_a?(RestPositional) && b.is_a?(RequiredPositional)\n AST::Types::Union.build(types: [a.type, b.type]).yield_self do |type|\n (self.drop_first | other.drop_first)&.with_first_param(OptionalPositional.new(type))\n end\n when a.is_a?(RestPositional) && b.is_a?(OptionalPositional)\n AST::Types::Union.build(types: [a.type, b.type]).yield_self do |type|\n (self | other.drop_first)&.with_first_param(OptionalPositional.new(type))\n end\n when a.is_a?(RestPositional) && b.is_a?(RestPositional)\n AST::Types::Union.build(types: [a.type, b.type]).yield_self do |type|\n (self.drop_first | other.drop_first)&.with_first_param(RestPositional.new(type))\n end\n when a.is_a?(RestPositional) && b.nil?\n (self.drop_first | other)&.with_first_param(a)\n when a.nil? && b.is_a?(RequiredPositional)\n other.drop_first&.with_first_param(OptionalPositional.new(b.type))\n when a.nil? && b.is_a?(OptionalPositional)\n (self | other.drop_first)&.with_first_param(b)\n when a.nil? && b.is_a?(RestPositional)\n (self | other.drop_first)&.with_first_param(b)\n when a.nil? && b.nil?\n required_keywords = {}\n optional_keywords = {}\n\n (Set.new(self.required_keywords.keys) & Set.new(other.required_keywords.keys)).each do |keyword|\n required_keywords[keyword] = AST::Types::Union.build(\n types: [\n self.required_keywords[keyword],\n other.required_keywords[keyword]\n ]\n )\n end\n\n self.optional_keywords.each do |keyword, t|\n unless optional_keywords.key?(keyword) || required_keywords.key?(keyword)\n case\n when s = other.required_keywords[keyword]\n optional_keywords[keyword] = AST::Types::Union.build(types: [t, s])\n when s = other.optional_keywords[keyword]\n optional_keywords[keyword] = AST::Types::Union.build(types: [t, s])\n when r = other.rest_keywords\n optional_keywords[keyword] = AST::Types::Union.build(types: [t, r])\n else\n optional_keywords[keyword] = t\n end\n end\n end\n other.optional_keywords.each do |keyword, t|\n unless optional_keywords.key?(keyword) || required_keywords.key?(keyword)\n case\n when s = self.required_keywords[keyword]\n optional_keywords[keyword] = AST::Types::Union.build(types: [t, s])\n when s = self.optional_keywords[keyword]\n optional_keywords[keyword] = AST::Types::Union.build(types: [t, s])\n when r = self.rest_keywords\n optional_keywords[keyword] = AST::Types::Union.build(types: [t, r])\n else\n optional_keywords[keyword] = t\n end\n end\n end\n self.required_keywords.each do |keyword, t|\n unless optional_keywords.key?(keyword) || required_keywords.key?(keyword)\n case\n when s = other.optional_keywords[keyword]\n optional_keywords[keyword] = AST::Types::Union.build(types: [t, s])\n when r = other.rest_keywords\n optional_keywords[keyword] = AST::Types::Union.build(types: [t, r])\n else\n optional_keywords[keyword] = t\n end\n end\n end\n other.required_keywords.each do |keyword, t|\n unless optional_keywords.key?(keyword) || required_keywords.key?(keyword)\n case\n when s = self.optional_keywords[keyword]\n optional_keywords[keyword] = AST::Types::Union.build(types: [t, s])\n when r = self.rest_keywords\n optional_keywords[keyword] = AST::Types::Union.build(types: [t, r])\n else\n optional_keywords[keyword] = t\n end\n end\n end\n\n rest = case\n when self.rest_keywords && other.rest_keywords\n AST::Types::Union.build(types: [self.rest_keywords, other.rest_keywords])\n when self.rest_keywords\n if required_keywords.empty? && optional_keywords.empty?\n self.rest_keywords\n end\n when other.rest_keywords\n if required_keywords.empty? && optional_keywords.empty?\n other.rest_keywords\n end\n else\n nil\n end\n\n Params.new(\n required: [],\n optional: [],\n rest: nil,\n required_keywords: required_keywords,\n optional_keywords: optional_keywords,\n rest_keywords: rest)\n end\n end",
"def combine_filtered_ids(u_filtered_ids, b_filtered_ids, m_filtered_ids, d_filtered_ids, tenant_filter_ids)\n intersection = ->(operand1, operand2) { [operand1, operand2].compact.reduce(&:&) }\n union = ->(operand1, operand2, operand3 = nil) { [operand1, operand2, operand3].compact.reduce(&:|) }\n\n b_intersection_m = intersection.call(b_filtered_ids, m_filtered_ids)\n u_union_d_union_b_intersection_m = union.call(u_filtered_ids, d_filtered_ids, b_intersection_m)\n\n intersection.call(u_union_d_union_b_intersection_m, tenant_filter_ids)\n end",
"def or(*conditions)\n unless (2..10).cover?(conditions.length)\n raise ArgumentError, \"You must specify AT LEAST 2 and AT MOST 10 conditions\"\n end\n {\"Fn::Or\" => conditions}\n end",
"def and_relation(relation)\n q = all\n q = q.where(relation.where_clause.ast) if relation.where_clause.present?\n q = q.joins(relation.joins_values + q.joins_values) if relation.joins_values.present?\n q = q.order(relation.order_values) if relation.order_values.present?\n q\n end",
"def union(fa)\n perform_set_operation(:union, fa)\n end",
"def apply(query)\n queries_sql = queries.map do |context_query|\n context_query.to_where_sql(enclose_with_parentheses: queries.size > 1)\n end.join(\" OR \")\n query.to_active_record_query.where(queries_sql).to_seek_query\n end",
"def join_with_or ar, **options\n\n\t\t::Xqsr3::Quality::ParameterChecking.check_parameter ar, 'ar', type: ::Array, allow_nil: true\n\t\t::Xqsr3::Quality::ParameterChecking.check_parameter options, 'options', type: ::Hash, allow_nil: false\n\n\t\t::Xqsr3::Quality::ParameterChecking.check_parameter options[:or], ':or', type: ::String, option: true, allow_nil: true\n\t\t::Xqsr3::Quality::ParameterChecking.check_parameter options[:oxford_comma], ':oxford_comma', types: [ ::FalseClass, ::TrueClass ], option: true, allow_nil: true\n\t\t::Xqsr3::Quality::ParameterChecking.check_parameter options[:quote_char], ':quote_char', type: ::String, option: true, allow_nil: true\n\t\t::Xqsr3::Quality::ParameterChecking.check_parameter options[:separator], ':separator', type: ::String, option: true, allow_nil: true\n\n\t\treturn '' if ar.nil?\n\t\treturn '' if ar.empty?\n\n\t\tseparator\t=\toptions[:separator] || ','\n\t\tor_word\t\t=\toptions[:or] || 'or'\n\t\tox_comma\t=\t(options.has_key?(:oxford_comma) && !options[:oxford_comma]) ? '' : separator\n\t\tquote_char\t=\toptions[:quote_char]\n\n\t\tar\t\t\t=\tar.map { |v| \"#{quote_char}#{v}#{quote_char}\" } if quote_char\n\n\t\tcase ar.size\n\t\twhen 1\n\t\t\tar[0]\n\t\twhen 2\n\t\t\t\"#{ar[0]} #{or_word} #{ar[1]}\"\n\t\telse\n\t\t\t\"#{ar[0...-1].join(separator + ' ')}#{ox_comma} #{or_word} #{ar[-1]}\"\n\t\tend\n\tend",
"def or_exp(expression)\n @use_disjunction = true\n @disjunction = @builder.and(@disjunction,expression)\n\n self\n end",
"def to_sparql(**options)\n \"(#{operands.first.to_sparql(**options)} && #{operands.last.to_sparql(**options)})\"\n end",
"def union! newFA\n end",
"def complex_expression_sql(op, args)\n case op\n when :'||'\n super(:+, args)\n else\n super(op, args)\n end\n end",
"def call_or(caller_object, first, second)\n or_lambda = lambda_or_raise(caller_object, :or)\n or_lambda.call(first, second)\n end",
"def test_or\n assert_false F | F, 'F | F'\n assert_maybe F | M, 'F | M'\n assert_true F | T, 'F | T'\n\n assert_maybe M | F, 'M | F'\n assert_maybe M | M, 'M | M'\n assert_true M | T, 'M | T'\n\n assert_true T | F, 'T | F'\n assert_true T | M, 'T | M'\n assert_true T | T, 'T | T'\n end",
"def zunion(*args, **_arg1); end",
"def or(*array_matchers, **keyword_matchers)\n create_matcher('or', array_matchers, keyword_matchers)\n end",
"def or(*array_matchers, **keyword_matchers)\n create_matcher('or', array_matchers, keyword_matchers)\n end",
"def rewrite_opts\n rewrite do |ast|\n # ... ~A ~B ... = ... (or A B) ...\n # ... ~A ... = ... (or A) ... = ... A ...\n if ast.children.any?(&:opt?)\n opts, non_opts = ast.children.partition(&:opt?)\n or_node = node(:or, *opts.flat_map(&:children))\n node(ast.type, or_node, *non_opts)\n else\n ast\n end\n end\n end",
"def and_relation(relation)\n q = all\n raise \"incompatible FROM clauses: #{q.to_sql}; #{relation.to_sql}\" if !q.from_clause.empty? && q.from_clause != relation.from_clause\n raise \"incompatible GROUP BY clauses: #{q.to_sql}; #{relation.to_sql}\" if !q.group_values.empty? && q.group_values != relation.group_values\n\n q = q.select(q.select_values + relation.select_values) if !relation.select_values.empty?\n q = q.from(relation.from_clause.value) if !relation.from_clause.empty?\n q = q.joins(relation.joins_values + q.joins_values) if relation.joins_values.present?\n q = q.where(relation.where_clause.ast) if relation.where_clause.present?\n q = q.group(relation.group_values) if relation.group_values.present?\n q = q.order(relation.order_values) if relation.order_values.present? && !relation.reordering_value\n q = q.reorder(relation.order_values) if relation.order_values.present? && relation.reordering_value\n q\n end",
"def union_scope(*scopes)\n id_column = \"#{table_name}.id\"\n sub_query = scopes.map { |s| s.select(id_column).to_sql }.join(\" UNION \")\n where \"#{id_column} IN (#{sub_query})\"\n end",
"def process_or(exp)\n a = exp.shift\n b = exp.shift\n\n res = without_result do\n want_expression do\n with_temporary_variable do |tmp|\n @local_variables_need_no_initialization.add(tmp)\n \"(#{tmp}=#{process(a)}, (#{tmp}!==false&&#{tmp}!==nil) ? #{tmp} : (#{process(b)}))\"\n end\n end\n end\n\n return resultify(res)\n end",
"def or_(a)\n if ((a).nil?)\n return self\n end\n s = self.clone\n s.or_in_place(a)\n return s\n end",
"def union(p, q)\n p_root, q_root = root(p), root(q)\n shorter(p_root, q_root) ? link(p_root, q_root) : link(q_root, p_root)\n end",
"def or( *filterspec )\n\t\topts = self.options\n\t\texisting_filter = self.filter\n\t\traise Treequel::ExpressionError, \"no existing filter\" if\n\t\t\texisting_filter.promiscuous?\n\n\t\tnewfilter = Treequel::Filter.new( *filterspec )\n\n\t\tself.log.debug \"cloning %p with alternative filterspec: %p\" % [ self, filterspec ]\n\t\treturn self.clone( :filter => (self.filter | newfilter) )\n\tend",
"def merge_query_objects(*query_objects)\n merged_query = {}.with_indifferent_access\n query_objects.compact.each do |query|\n query.each_pair do |facet_name, opts|\n if merged_query[facet_name].nil?\n merged_query[facet_name] = opts\n else\n opts.each_pair do |operator, values|\n values.each do |value|\n merged_query[facet_name][operator] << value unless merged_query[facet_name][operator].include?(value)\n end\n end\n end\n end\n end\n merged_query\n end",
"def and_ a, b\n self.and a, b\n end",
"def union(*arrays)\n arrays # () => []\nend"
] | [
"0.75229627",
"0.7424549",
"0.66974527",
"0.6671067",
"0.65888315",
"0.65782046",
"0.63999754",
"0.62737834",
"0.62258154",
"0.6222271",
"0.617718",
"0.61576843",
"0.6147056",
"0.61453295",
"0.61273444",
"0.6122767",
"0.6120874",
"0.60838884",
"0.6072722",
"0.6014629",
"0.5989953",
"0.59592205",
"0.5946807",
"0.5937927",
"0.5924892",
"0.5880783",
"0.5867676",
"0.58641195",
"0.5850787",
"0.5845275",
"0.5840517",
"0.5839693",
"0.5836552",
"0.58285934",
"0.57786006",
"0.57780176",
"0.57750374",
"0.57741064",
"0.57712716",
"0.57453644",
"0.5734973",
"0.5720018",
"0.56794876",
"0.56409913",
"0.56301373",
"0.56289744",
"0.5627087",
"0.5620056",
"0.56116056",
"0.56039274",
"0.5597151",
"0.5597116",
"0.5584719",
"0.5577462",
"0.55446684",
"0.55292076",
"0.55252564",
"0.5518848",
"0.5518016",
"0.5516733",
"0.5513868",
"0.55124",
"0.5503081",
"0.55002636",
"0.5498175",
"0.5481722",
"0.54763454",
"0.5467931",
"0.54674894",
"0.54510623",
"0.54468775",
"0.5410234",
"0.540405",
"0.54029256",
"0.53989905",
"0.5394245",
"0.53940165",
"0.5390442",
"0.5385156",
"0.53832626",
"0.53829724",
"0.53665566",
"0.5346652",
"0.53381556",
"0.5337776",
"0.5333279",
"0.5311842",
"0.52926964",
"0.5287486",
"0.5287486",
"0.52839226",
"0.5280019",
"0.5263494",
"0.52629024",
"0.5261592",
"0.524485",
"0.52359957",
"0.5232845",
"0.5232121",
"0.5228082"
] | 0.6931823 | 2 |
Add a new sort key. Multiple invocations add additional sort keys rather than replacing old ones. | def sort_by(key, options = {})
# backwards compat: if options is not a hash, it is a sort ordering.
unless options.is_a?Hash
sort_order = options
options = {
order: sort_order,
case_insensitive: false,
}
end
options = {
order: :ascending,
}.merge(options)
order = options[:order].to_s
if order[0,4].downcase == 'desc'
ascending = false
else
ascending = true
end
if options[:case_insensitive]
descriptor = NSSortDescriptor.sortDescriptorWithKey(key, ascending: ascending, selector: "localizedCaseInsensitiveCompare:")
else
descriptor = NSSortDescriptor.sortDescriptorWithKey(key, ascending: ascending)
end
clone(sort_descriptors: @sort_descriptors + [descriptor])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_sort_key\n @item.sort_key = @sortable[@parent.sort_index]\n @item.reversed = @parent.reversed? ? -1 : 1\n end",
"def sort_key(value)\n @sort = value\n end",
"def add_key(key)\n keys.add(key)\n end",
"def add_sort(field)\n @order_by.push(field)\n end",
"def add_sort_field(*) super end",
"def sort(key, **options); end",
"def sort_key=(sort_key)\n if !sort_key.nil? && sort_key.to_s.length > 255\n fail ArgumentError, 'invalid value for \"sort_key\", the character length must be smaller than or equal to 255.'\n end\n\n @sort_key = sort_key\n end",
"def sort_by_key(ascending=true, num_partitions=nil)\n self.sort_by('lambda{|(key, _)| key}')\n end",
"def add(key, value); end",
"def insert(key)\n @keys << key\n swim(@keys.length - 1)\n end",
"def add_sorting_to_solr(solr_parameters)\n solr_parameters[:sort] = sort if sort.present?\n end",
"def add(key, value)\n @hash[key] = value\n @reverse[value] ||= []\n @reverse[value] << key\n end",
"def sort(sort_keys, *args)\n raise NotImplementedError\n end",
"def new_key(list, key, value)\n\tlist[key] = value\nend",
"def order(*value)\n @keys_order = value\n end",
"def add_sorting_to_solr(solr_parameters, user_params)\n if user_params[:sort].blank? and sort_field = blacklight_config.default_sort_field\n # no sort param provided, use default\n solr_parameters[:sort] = sort_field.sort unless sort_field.sort.blank?\n elsif sort_field = blacklight_config.sort_fields[user_params[:sort]]\n # check for sort field key \n solr_parameters[:sort] = sort_field.sort unless sort_field.sort.blank?\n else \n # just pass the key through\n solr_parameters[:sort] = user_params[:sort]\n end\n end",
"def sort(key, by: T.unsafe(nil), limit: T.unsafe(nil), get: T.unsafe(nil), order: T.unsafe(nil), store: T.unsafe(nil)); end",
"def add_new_key(school, ranking, value)\n\tschool[ranking] = value\nend",
"def add_key(key)\n numkeys = @worksheet_obj.list.keys.length\n @worksheet_obj[1, numkeys+1] = key\n @worksheet_obj.save\n end",
"def add(key, value)\n end",
"def add(key, value)\n change(:add, key, value)\n end",
"def zadd(key, *args, **_arg2); end",
"def incr(key); end",
"def incr(key); end",
"def zadd(key, *args)\n node_for(key).zadd(key, *args)\n end",
"def append(key, value); end",
"def append(key, value); end",
"def add_key(arg)\n \"key=#{arg.to_json}\"\n end",
"def add_sort_by(field, dir = \"desc\")\n @sort_fields << {field => dir}\n end",
"def add_item(hash, new_key, new_value)\n hash[new_key] = new_value\n p hash\nend",
"def sort_docs_by_key!; end",
"def insert(key)\n end",
"def incrby(key, increment); end",
"def incrby(key, increment); end",
"def +(other)\n Key.new( [to_s, other.to_s].join(SEPARATOR) )\n end",
"def add(key)\n @internal_hash[key] = true\n end",
"def add(key, value)\n update_array(key, value, :add)\n end",
"def add(val)\n @nums = SortHelper.insert(@nums, val)\n @nums[@nums.length - @k]\n end",
"def add_key(key)\n deprecate # 07/31/2012\n post(\"/user/keys\", key, { 'Content-Type' => 'text/ssh-authkey' }).to_s\n end",
"def inc(key)\n \n end",
"def insert(key, value)\n i = index(key)\n buckets[i] = [key, value]\n end",
"def add_key_data(key_data_); end",
"def add(key, value)\n @hash[key] = value\n self\n end",
"def lpush(key, value); end",
"def lpush(key, value); end",
"def default_sort=(field)\n @order_by.unshift(field)\n end",
"def add_to_sort_array(sort_type, quest_id)\n @sort_arrays[sort_type].delete(quest_id) # Make sure always unique\n case sort_type\n when :reveal, :change, :complete, :failed\n @sort_arrays[sort_type].unshift(quest_id)\n when :id\n @sort_arrays[sort_type].maqj_insert_sort(quest_id)\n when :alphabet \n @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].name.downcase <=> @data[b].name.downcase }\n when :level\n @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].level <=> self[b].level }\n end\n end",
"def add_key(user_name, key)\n\tabort \"Cannot add key, user not found!\" unless users(:return => :array).include?(user_name)\n\t@ssh_keys << {:user_name => user_name, :key => key}\n end",
"def prepend(key, value)\n perform(:prepend, key, value.to_s)\n end",
"def add_ssh_key(key)\n if persisted?\n pending_op = PendingUserOps.new(op_type: :add_ssh_key, arguments: key.attributes.dup, state: :init, on_domain_ids: self.domains.map{|d|d._id.to_s}, created_at: Time.new)\n CloudUser.where(_id: self.id).update_all({ \"$push\" => { pending_ops: pending_op.serializable_hash_with_timestamp , ssh_keys: key.serializable_hash }})\n reload.run_jobs\n else\n ssh_keys << key\n end\n end",
"def << (item)\n (@usableItems ||= []) << item.to_sym\n sortItems\n end",
"def double_sorted_add(item)\n raise NotImplementedError, \"Double Sorted Linked Lists are not supported\"\n end",
"def new_key(old_key)\n key_store[old_key] || old_key\n end",
"def add_key(name, type, clustering_order = nil)\n if @partition_key_columns.empty?\n unless clustering_order.nil?\n raise ArgumentError,\n \"Can't set clustering order for partition key #{name}\"\n end\n add_partition_key(name, type)\n else\n add_clustering_column(name, type, clustering_order)\n end\n end",
"def add_column_key(key)\n\t\tself.google_doc.restart_session_if_necessary #TODO do we actually need to do these?\n\t\treset_worksheet_obj if @worksheet_obj == nil\n\t\t@worksheet_obj[1, num_keys+1] = key\n\t\t@worksheet_obj.save\n\tend",
"def sort_entries=(_arg0); end",
"def add_key_path(key_name, *path)\n fields.merge!({ key_name => path })\n end",
"def add(key, value)\n\t\t\t\tself[key] = value\n\t\t\tend",
"def key=(new_key)\n @key = new_key\n end",
"def zadd(key, *args, nx: T.unsafe(nil), xx: T.unsafe(nil), lt: T.unsafe(nil), gt: T.unsafe(nil), ch: T.unsafe(nil), incr: T.unsafe(nil)); end",
"def add_key(key_id, key_content)\n system(\"#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys add-key #{key_id} \\\"#{key_content}\\\"\")\n end",
"def add(item)\n if @double\n @sorted ? double_sorted_add(item) : double_unsorted_add(item)\n else\n @sorted ? sorted_add(item) : unsorted_add(item)\n end\n end",
"def add_to_index(name, key, node); end",
"def sort(key, opts={})\n cmd = \"SORT #{key}\"\n cmd << \" BY #{opts[:by]}\" if opts[:by]\n cmd << \" GET #{opts[:get]}\" if opts[:get]\n cmd << \" INCR #{opts[:incr]}\" if opts[:incr]\n cmd << \" DEL #{opts[:del]}\" if opts[:del]\n cmd << \" DECR #{opts[:decr]}\" if opts[:decr]\n cmd << \" #{opts[:order]}\" if opts[:order]\n cmd << \" LIMIT #{opts[:limit].join(' ')}\" if opts[:limit]\n cmd << \"\\r\\n\"\n write cmd\n multi_bulk_reply\n end",
"def add(key, value = key)\n new_node = HeapNode.new(key, value)\n @store << new_node\n\n heap_up(@store.length - 1)\n end",
"def add_key(key)\n post(\"/api/v1/ssh_keys\", :key => key).to_s\n end",
"def new_key(school,key,value)\n school[key.to_sym] = value\nend",
"def add(key, value = key)\n new_node = HeapNode.new(key, value)\n @store << new_node\n heap_up(@store.length-1)\n end",
"def sort_by_key(key = :name)\n sort do |x, y|\n x_value = x[key]\n y_value = y[key]\n x_value <=> y_value\n end\n end",
"def add(k, v)\n\t\titem = Item.new(k, v)\n\t\[email protected](item)\n\t\treturn\n\tend",
"def add(key, value = key)\n @store.append(HeapNode.new(key, value))\n curr = @store.length - 1\n\n curr = heap_up(curr)\n end",
"def add(key, value = key)\n new_node = HeapNode.new(key, value)\n @store << new_node\n heap_up(@store.size-1)\n end",
"def add_key(key)\n\t\tpost(\"/user/keys\", key, { 'Content-Type' => 'text/ssh-authkey' })\n\tend",
"def add_key(key)\n\t\tpost(\"/user/keys\", key, { 'Content-Type' => 'text/ssh-authkey' })\n\tend",
"def key_order\n # order(key: :asc)\n all.to_a.sort_by {|n| n.key }\n end",
"def add(key, value)\n index = key_index(key)\n\n # Only happens if we didn't check the presence before calling this method\n return nil if index == -1\n\n rehash_step if rehashing?\n\n hash_table = rehashing? ? rehashing_table : main_table\n entry = hash_table.table[index]\n\n entry = entry.next while entry && entry.key != key\n\n if entry.nil?\n entry = DictEntry.new(key, value)\n entry.next = hash_table.table[index]\n hash_table.table[index] = entry\n hash_table.used += 1\n else\n raise \"Unexpectedly found an entry with same key when trying to add #{ key } / #{ value }\"\n end\n end",
"def add_key(key_string, key_type=nil, comment=nil, login=nil )\n #@container.logger.info \"Adding new key #{key_string} #{key_type} #{comment} #{login}\"\n comment = \"\" unless comment\n\n modify do |keys|\n keys[key_id(comment)] = key_entry(key_string, key_type, comment, login)\n end\n\n end",
"def my_hash_sorting_method(source)\n p source.sort_by { |key, value| value }\nend",
"def addArg(val)\n @args << val.to_sym\n updateKey\n self\n end",
"def hincrby(key, field, increment); end",
"def hincrby(key, field, increment); end",
"def lpushx(key, value); end",
"def lpushx(key, value); end",
"def add(key, value, placer = AppendPlacer.new)\n element = placer.new_element(self)\n element[:key] = key\n element[:value] = value\n element[:operation] = :add\n end",
"def add_ordering step1, step2\n ver = @orderings.cur_version\n @orderings.add step1, step2\n ver\n end",
"def sorted_keys; end",
"def add_key(key,value) \n\t\tSCHOOL[key]=[value]\n\tend",
"def updateKey; @key = getKey; self end",
"def add_key(key)\n begin\n file = Tempfile.new('key')\n file.puts(key)\n file.close\n\n add_keyfile(file.path)\n ensure\n file.close(true) unless file.nil?\n end\n end",
"def add_to_index(key, item)\n index = @indexes[key]\n index[item] = index[item].nil? ? [page_number] : index[item] << page_number\n end",
"def add( key_file )\n @key_files.push( key_file ).uniq!\n self\n end",
"def add(key, value = key)\n newNode = HeapNode.new(key, value)\n @store << newNode\n \n # compare up from this newNode\n heap_up(@store.length-1)\n end",
"def sort_data_ascending!(*sort_keys)\n self.sort_data!(true, sort_keys)\n end",
"def insert_ascending(value)\r\n raise NotImplementedError\r\n end",
"def add(obj)\n return self if self.has_key? name_of(obj)\n\n hook_wrap :add, obj do\n begin\n name = name_of(obj)\n insert_sorted(obj)\n hashed[name] = obj\n obj\n rescue Exception => e\n delete(name)\n raise e\n end\n end\n\n self\n end",
"def append!(key, value); end",
"def append!(key, value); end",
"def add(key, value = key)\n node = HeapNode.new(key, value)\n @store << node\n heap_up(@store.length - 1)\n end",
"def add_ordering step1, step2\r\n ver = @orderings.cur_version\r\n @orderings.add step1, step2\r\n ver\r\n end",
"def my_hash_sorting_method(source)\n source.sort {|k,v| k[1]<=>v[1]}\nend",
"def push_into_hash(hash, key, data)\n if hash[key.to_sym].nil?\n hash[key.to_sym] = [data]\n else # existing key\n hash[key.to_sym].push(data)\n end\n end"
] | [
"0.65199274",
"0.6416684",
"0.6356432",
"0.6125981",
"0.60693586",
"0.60305905",
"0.59715337",
"0.5865316",
"0.58565366",
"0.5788275",
"0.5765549",
"0.57413036",
"0.5739954",
"0.56203586",
"0.5556833",
"0.55378854",
"0.5529041",
"0.55149317",
"0.5500996",
"0.5489865",
"0.54574144",
"0.5439196",
"0.54352033",
"0.54352033",
"0.54289114",
"0.5428464",
"0.5428464",
"0.5425635",
"0.54256123",
"0.53857934",
"0.537942",
"0.53737116",
"0.5373507",
"0.5373507",
"0.5360649",
"0.5358322",
"0.5349799",
"0.53494483",
"0.53465134",
"0.53290796",
"0.5298005",
"0.52954483",
"0.5288611",
"0.5280872",
"0.5280872",
"0.5273509",
"0.5272976",
"0.5267038",
"0.5255271",
"0.52517056",
"0.52460194",
"0.5239689",
"0.52384937",
"0.5231132",
"0.52283657",
"0.5227776",
"0.5215335",
"0.52137905",
"0.5213444",
"0.5212087",
"0.5210037",
"0.51884973",
"0.5186593",
"0.51747584",
"0.5168218",
"0.5166718",
"0.51570237",
"0.5156543",
"0.5156441",
"0.51540226",
"0.5150001",
"0.5137402",
"0.5135876",
"0.5135876",
"0.51228124",
"0.51183796",
"0.51114535",
"0.51024264",
"0.5091809",
"0.507074",
"0.507074",
"0.50586426",
"0.50586426",
"0.50500745",
"0.50409144",
"0.5028579",
"0.5023011",
"0.5019952",
"0.5019304",
"0.50192463",
"0.50101376",
"0.5002605",
"0.4994054",
"0.49923897",
"0.49865842",
"0.49725088",
"0.49725088",
"0.49716818",
"0.49638462",
"0.4957193",
"0.4956502"
] | 0.0 | -1 |
Return an NSFetchRequest that will implement this query | def fetch_request
NSFetchRequest.new.tap do |req|
req.predicate = predicate
req.fetchLimit = limit if limit
req.fetchOffset = offset if offset
req.sortDescriptors = sort_descriptors unless sort_descriptors.empty?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetchRequest\n # Start with a predicate which selects those entities that belong to the owner.\n predicate = Predicate::Builder.new(inverseRelationshipName) == @owner\n # Then apply the scope's predicate.\n predicate = predicate.and(@predicate) if @predicate\n\n request = NSFetchRequest.new\n request.entity = targetClass.entityDescription\n request.predicate = predicate\n request.sortDescriptors = @sortDescriptors unless @sortDescriptors.empty?\n request\n end",
"def to_query(_model)\n raise 'subclasses should implement this method.'\n end",
"def method_missing(method, *args)\n if method =~ /find/\n finder = method.to_s.split('_by_').first\n attributes = method.to_s.split('_by_').last.split('_and_')\n\n chain = Dynamoid::Criteria::Chain.new(self)\n chain.query = Hash.new.tap {|h| attributes.each_with_index {|attr, index| h[attr.to_sym] = args[index]}}\n \n if finder =~ /all/\n return chain.all\n else\n return chain.first\n end\n else\n super\n end\n end",
"def query\n super\n end",
"def query\n get_query_object\n end",
"def find(selector = {})\n Query.new(self, selector)\n end",
"def query\n self\n end",
"def query\n self\n end",
"def query\n @operation = :query\n self\n end",
"def query\n return @query\n end",
"def query\n return @query\n end",
"def query\n return @query\n end",
"def queryable\n crit = Threaded.current_scope(self) || Criteria.new(self)\n crit.embedded = true if (crit.klass.embedded? && !crit.klass.cyclic?)\n crit\n end",
"def criteria\n Criteria.new(self)\n end",
"def query_full\n query = @initial_query.dup\n\n # restrict to select columns\n query = query_projection(query)\n\n #filter\n query = query_filter(query)\n\n # sorting\n query = query_sort(query)\n\n # paging\n query_paging(query)\n end",
"def where(attrs = {})\n return self if attrs.blank?\n self.clone.tap do |r|\n r.query_attrs = r.query_attrs.merge(attrs)\n r.clear_fetch_cache!\n end\n end",
"def query\n @query ||= \n Content::Query.new(query_options.merge(:user_query => search))\n end",
"def query_for_self\n query = Ferret::Search::TermQuery.new(:id, self.id.to_s)\n if self.class.configuration[:single_index]\n bq = Ferret::Search::BooleanQuery.new\n bq.add_query(query, :must)\n bq.add_query(Ferret::Search::TermQuery.new(:class_name, self.class.name), :must)\n return bq\n end\n return query\n end",
"def default_query\n base_where_query(nil, nil)\n end",
"def fetch_query args={}\n query(args.clone)\nend",
"def fetch_query args={}\n query(args.clone)\nend",
"def query_builder\n QueryBuilder.new(self)\n end",
"def criteria\n @criteria ||= _association.criteria(_base)\n end",
"def query\n case query_type_str\n when 'empty'\n return\n when 'iso'\n return iso_query_builder\n when 'multi'\n return multi_query_builder\n end\n end",
"def find(query); end",
"def find(query); end",
"def self_query\n self.class.where(id: id)\n end",
"def query\n\t\tQuery.new(\"true\")\n\tend",
"def query\n unless @query\n parse_query()\n end\n @query\n end",
"def query\n attributes.fetch(:query)\n end",
"def query\n @query ||= Waves::Request::Query.new( \n Waves::Request::Utilities.destructure( request.query ) )\n end",
"def of(query)\n query\n end",
"def query(&block)\n Query.new(self, &block)\n end",
"def fetch\n @_fetch ||= begin\n path = @parent.build_request_path(@query_attrs)\n @parent.request(@query_attrs.merge(:_method => :get, :_path => path)) do |parsed_data, response|\n @parent.new_collection(parsed_data)\n end\n end\n end",
"def queryable_class\n @queryable_class || self.class.queryable_class\n end",
"def criteria(base, id_list = nil)\n query_criteria(id_list || base.send(foreign_key))\n end",
"def retrieve_query\n session_key = :resource_booking_query\n if params[:set_filter] || session[session_key].nil? || session[session_key][:project_id] != (@project ? @project.id : nil)\n # Give it a name, required to be valid\n @query = ResourceBookingQuery.new(name: '_', project: @project)\n @query.build_from_params(params)\n session[session_key] = { project_id: @query.project_id, filters: @query.filters, options: @query.options }\n else\n # retrieve from session\n session[session_key][:options][:date_from] = params[:date_from].to_date if params[:date_from]\n @query = ResourceBookingQuery.new(name: '_', filters: session[session_key][:filters], options: session[session_key][:options])\n @query.project = @project\n end\n @query\n end",
"def retrieve_query\n if params[:set_filter] or !session[:query] or session[:query].project_id\n # Give it a name, required to be valid\n @query = Query.new(:name => \"_\", :executed_by => logged_in_user)\n if params[:fields] and params[:fields].is_a? Array\n params[:fields].each do |field|\n @query.add_filter(field, params[:operators][field], params[:values][field])\n end\n else\n @query.available_filters.keys.each do |field|\n @query.add_short_filter(field, params[field]) if params[field]\n end\n end\n session[:query] = @query\n else\n @query = session[:query]\n end\n end",
"def query\n @query ||= search.query\n end",
"def query_without_paging_sorting\n query = @initial_query.dup\n\n # restrict to select columns\n query = query_projection(query)\n\n #filter\n query_filter(query)\n end",
"def query sel, &b\n collection = document.query sel\n \n collection.instance_exec(self, &b) if b\n \n return collection\n end",
"def create_query( relation )\n Query.new(relation)\n end",
"def query(_tql)\n raise NotImplementedError.new\n end",
"def query ; @query ||= Waves::Request::Query.new( request.query ) ; end",
"def query(expr=\"\", query_options={})\n result = []\n self.domain.query(query_options.merge({:expr => expr})).each do |i|\n result << self.new(i.key, i.attributes, false)\n end\n return result\n end",
"def scoped_query(query = nil)\n # a nil query, or an empty Hash signal that we want to use the\n # same scope as is currently in effect\n if query.blank?\n return self.query\n end\n\n # a Query object signals that we want to use an absolute query\n if query.kind_of?(Query)\n return query\n end\n\n # use current query scope to start\n relative_query = query_to_hash(self.query)\n\n # merge in query to further scope the results\n relative_query.update(query)\n\n # use the repository if explicitly specified, otherwise use the current scope's repository\n repository = relative_query.delete(:repository) || self.repository\n\n # figure out the offset and limit relative to the current query\n if relative_query[:offset] > 0 || relative_query[:limit]\n offset, limit = get_relative_position(*relative_query.values_at(:offset, :limit))\n\n relative_query.update(:offset => offset)\n\n if limit\n relative_query.update(:limit => limit)\n end\n end\n\n Query.new(repository, model, relative_query)\n end",
"def make_query\n run_callbacks :make_query do\n self.scope.search(get_query_params)\n end\n end",
"def get_model_query\n\n user_relational_query = User.using_client_shard(client: @client).\n where(client_id: @client_id).is_active.filter_by(@allowed_filters)\n user_relational_query.sorting_by(@sortings)\n end",
"def query_for(source, other_query = nil)\n repository_name = relative_target_repository_name_for(source)\n\n DataMapper.repository(repository_name).scope do\n query = target_model.query.dup\n query.update(self.query)\n query.update(source_scope(source))\n query.update(other_query) if other_query\n query.update(:fields => query.fields | target_key)\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SpecialNeedsResultSet.new(resp)\n return results\n end",
"def base_query\n DataServicesApi::QueryGenerator.new\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FindResultSet.new(resp)\n return results\n end",
"def where(args)\n @query.merge!(args)\n self.all\n end",
"def raw_query\n @raw_query\n end",
"def select_statement(query)\n model = query.model\n fields = query.fields\n conditions = query.conditions\n limit = query.limit\n offset = query.offset\n order = query.order\n group_by = nil\n\n # FIXME: using a boolean for qualify does not work in some cases,\n # such as when you have a self-referrential many to many association.\n # if you don't qualfiy the columns with a unique alias, then the\n # SQL query will fail. This may mean though, that it might not\n # be enough to pass in a Property, but we may need to know the\n # table and the alias we should use for the column.\n\n qualify = query.links.any?\n\n if query.unique?\n group_by = fields.select { |p| p.kind_of?(Property) }\n end\n\n # create subquery to find all valid keys and then use these keys to retrive all other columns\n use_subquery = qualify\n\n # when we can include ROWNUM condition in main WHERE clause\n use_simple_rownum_limit = limit && (offset||0 == 0) && group_by.blank? && order.blank?\n\n unless (limit && limit > 1) || offset > 0 || qualify\n # TODO: move this method to Query, so that it walks the conditions\n # and finds an OR operator\n\n # TODO: handle cases where two or more properties need to be\n # used together to be unique\n\n # if a unique property is used, and there is no OR operator, then an ORDER\n # and LIMIT are unecessary because it should only return a single row\n if conditions.kind_of?(Query::Conditions::AndOperation) &&\n conditions.any? { |operand| operand.kind_of?(Query::Conditions::EqualToComparison) && operand.subject.respond_to?(:unique?) && operand.subject.unique? } &&\n !conditions.any? { |operand| operand.kind_of?(Query::Conditions::OrOperation) }\n order = nil\n limit = nil\n end\n end\n\n conditions_statement, bind_values = conditions_statement(conditions, qualify)\n\n statement = \"SELECT #{columns_statement(fields, qualify)}\"\n if use_subquery\n statement << \" FROM #{quote_name(model.storage_name(name))}\"\n statement << \" WHERE (#{columns_statement(model.key, qualify)}) IN\"\n statement << \" (SELECT DISTINCT #{columns_statement(model.key, qualify)}\"\n end\n statement << \" FROM #{quote_name(model.storage_name(name))}\"\n statement << join_statement(query, qualify) if qualify\n statement << \" WHERE (#{conditions_statement})\" unless conditions_statement.blank?\n if use_subquery\n statement << \")\"\n end\n if use_simple_rownum_limit\n statement << \" AND rownum <= ?\"\n bind_values << limit\n end\n statement << \" GROUP BY #{columns_statement(group_by, qualify)}\" unless group_by.blank?\n statement << \" ORDER BY #{order_statement(order, qualify)}\" unless order.blank?\n\n add_limit_offset!(statement, limit, offset, bind_values) unless use_simple_rownum_limit\n\n return statement, bind_values\n end",
"def fetch\n @raw_result = opts_for_cache_proxy[:raw] == true\n\n result = if refresh_cache?\n execute_find(@raw_result)\n elsif cached.is_a?(AridCache::CacheProxy::Result)\n if cached.has_ids? && @raw_result\n self.cached # return it unmodified\n elsif cached.has_ids?\n fetch_from_cache # return a list of active records after applying options\n else # true if we have only calculated the count thus far\n execute_find(@raw_result)\n end\n else\n cached # some base type, return it unmodified\n end\n end",
"def base_query(select_columns = true)\n if source_query\n if select_columns && source_select_columns\n source_query.call.select(*source_select_columns).where(source_conditions)\n else\n source_query.call.where(source_conditions)\n end\n else\n query = source_model.where(source_conditions).order(source_order_by => :asc)\n query = query.select(*source_select_columns) if select_columns && source_select_columns\n !force_full_update && highest_known_destination_order_by ? query.where(\"#{source_order_by} >= ?\", highest_known_destination_order_by) : query\n end\n end",
"def query\n @klass.where(:_id.in => only_saved_ids)\n end",
"def find(conditions)\n self.request.new(self.seed, conditions)\n end",
"def method_missing(method_name, *args, &block)\n if Query.instance_methods(false).include?(method_name)\n Query.new(self).send(method_name, *args, &block)\n else\n super\n end\n end",
"def query(query)\n check_reader\n\n Query.new(self, @reader, query)\n end",
"def criteria(base, target)\n criterion = klass.scoped\n criterion.embedded = true\n criterion.documents = target\n criterion.parent_document = base\n criterion.association = self\n apply_ordering(criterion)\n end",
"def select_statement(query)\n model = query.model\n fields = query.fields\n conditions = query.conditions\n limit = query.limit\n offset = query.offset\n order = query.order\n group_by = nil\n\n # FIXME: using a boolean for qualify does not work in some cases,\n # such as when you have a self-referrential many to many association.\n # if you don't qualfiy the columns with a unique alias, then the\n # SQL query will fail. This may mean though, that it might not\n # be enough to pass in a Property, but we may need to know the\n # table and the alias we should use for the column.\n\n qualify = query.links.any?\n\n if qualify || query.unique?\n group_by = fields.select { |property| property.kind_of?(Property) }\n end\n\n unless (limit && limit > 1) || offset > 0 || qualify\n # TODO: move this method to Query, so that it walks the conditions\n # and finds an OR operator\n\n # TODO: handle cases where two or more properties need to be\n # used together to be unique\n\n # if a unique property is used, and there is no OR operator, then an ORDER\n # and LIMIT are unecessary because it should only return a single row\n if conditions.kind_of?(Query::Conditions::AndOperation) &&\n conditions.any? { |operand| operand.kind_of?(Query::Conditions::EqualToComparison) && operand.subject.respond_to?(:unique?) && operand.subject.unique? } &&\n !conditions.any? { |operand| operand.kind_of?(Query::Conditions::OrOperation) }\n order = nil\n limit = nil\n end\n end\n\n conditions_statement, bind_values = conditions_statement(conditions, qualify)\n\n statement = \"SELECT #{columns_statement(fields, qualify)}\"\n statement << \" FROM #{quote_name(model.storage_name(name))}\"\n statement << join_statement(query, qualify) if qualify\n statement << \" WHERE #{conditions_statement}\" unless conditions_statement.blank?\n statement << \" GROUP BY #{columns_statement(group_by, qualify)}\" unless group_by.blank?\n statement << \" ORDER BY #{order_statement(order, qualify)}\" unless order.blank?\n\n if limit\n statement << ' LIMIT ?'\n bind_values << limit\n end\n\n if limit && offset > 0\n statement << ' OFFSET ?'\n bind_values << offset\n end\n\n return statement, bind_values\n end",
"def fetch\n @result = Result.new(data, :query => self)\n end",
"def retrieve_query\r\n if !params[:query_id].blank?\r\n cond = \"project_id IS NULL\"\r\n cond << \" OR project_id = #{@project.id}\" if @project\r\n @query = Query.find(params[:query_id], :conditions => cond)\r\n @query.project = @project\r\n session[:query] = {:id => @query.id, :project_id => @query.project_id}\r\n else\r\n if params[:set_filter] || session[:query].nil? || session[:query][:project_id] != (@project ? @project.id : nil)\r\n # Give it a name, required to be valid\r\n @query = Query.new(:name => \"_\")\r\n @query.project = @project\r\n if params[:fields] and params[:fields].is_a? Array\r\n params[:fields].each do |field|\r\n @query.add_filter(field, params[:operators][field], params[:values][field])\r\n end\r\n else\r\n @query.available_filters.keys.each do |field|\r\n @query.add_short_filter(field, params[field]) if params[field]\r\n end\r\n end\r\n session[:query] = {:project_id => @query.project_id, :filters => @query.filters}\r\n else\r\n @query = Query.find_by_id(session[:query][:id]) if session[:query][:id]\r\n @query ||= Query.new(:name => \"_\", :project => @project, :filters => session[:query][:filters])\r\n @query.project = @project\r\n end\r\n end\r\n end",
"def execute_find(raw = false)\n get_records\n cached = AridCache::CacheProxy::Result.new\n\n if !records.is_a?(Enumerable) || (!records.empty? && !records.first.is_a?(::ActiveRecord::Base))\n cached = records # some base type, cache it as itself\n else\n cached.ids = records.collect(&:id)\n cached.count = records.size\n if records.respond_to?(:proxy_reflection) # association proxy\n cached.klass = records.proxy_reflection.klass\n elsif !records.empty?\n cached.klass = records.first.class\n else\n cached.klass = object_base_class\n end\n end\n Rails.cache.write(cache_key, cached, opts_for_cache)\n self.cached = cached\n\n # Return the raw result?\n return self.cached if raw\n\n # An order has been specified. We have to go to the database\n # to order because we can't be sure that the current order is the same as the cache.\n if cached.is_a?(AridCache::CacheProxy::Result) && combined_options.include?(:order)\n self.klass = self.cached.klass # TODO used by fetch_from_cache needs refactor\n fetch_from_cache\n else\n process_result_in_memory(records)\n end\n end",
"def for_query(query)\n all.find { |f| f.query == query }\n end",
"def query_class\n Query.get_subclass(params[:type] || 'IssueQuery')\n end",
"def query(options={})\n qry = Query.new(table)\n options[:transformer] ||= begin\n lambda { |ct_record|\n instance = allocate\n instance.init_with(ct_record)\n instance\n }\n end\n qry.merge(options)\n end",
"def query(options) # :nodoc:\n @next_token = options[:next_token]\n query_expression = build_conditions(options[:query_expression])\n # add sort_options to the query_expression\n if options[:sort_option]\n sort_by, sort_order = sort_options(options[:sort_option])\n sort_query_expression = \"['#{sort_by}' starts-with '']\"\n sort_by_expression = \" sort '#{sort_by}' #{sort_order}\"\n # make query_expression to be a string (it may be null)\n query_expression = query_expression.to_s\n # quote from Amazon:\n # The sort attribute must be present in at least one of the predicates of the query expression.\n if query_expression.blank?\n query_expression = sort_query_expression\n elsif !query_attributes(query_expression).include?(sort_by)\n query_expression += \" intersection #{sort_query_expression}\"\n end\n query_expression += sort_by_expression\n end\n # request items\n query_result = self.connection.query(domain, query_expression, options[:max_number_of_items], @next_token)\n @next_token = query_result[:next_token]\n items = query_result[:items].map do |name|\n new_item = self.new('id' => name)\n new_item.mark_as_old\n reload_if_exists(record) if options[:auto_load]\n new_item\n end\n items\n end",
"def query; end",
"def base_query_for(name)\n # Load issues\n query = mr_closing_issues_table.join(issue_table).on(issue_table[:id].eq(mr_closing_issues_table[:issue_id])).\n join(issue_metrics_table).on(issue_table[:id].eq(issue_metrics_table[:issue_id])).\n where(issue_table[:project_id].eq(@project.id)).\n where(issue_table[:deleted_at].eq(nil)).\n where(issue_table[:created_at].gteq(@from))\n\n query = query.where(build_table[:ref].eq(@branch)) if name == :test && @branch\n\n # Load merge_requests\n query = query.join(mr_table, Arel::Nodes::OuterJoin).\n on(mr_table[:id].eq(mr_closing_issues_table[:merge_request_id])).\n join(mr_metrics_table).\n on(mr_table[:id].eq(mr_metrics_table[:merge_request_id]))\n\n if DEPLOYMENT_METRIC_STAGES.include?(name)\n # Limit to merge requests that have been deployed to production after `@from`\n query.where(mr_metrics_table[:first_deployed_to_production_at].gteq(@from))\n end\n\n query\n end",
"def base_where_query(where_clause, params)\n Entry.where(where_clause, params)\n .paginate(page: page_number)\n .order(checkin_at: :desc)\n end",
"def select(*args)\n Criteria.new(:all, self).select(*args)\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FindByURLResultSet.new(resp)\n return results\n end",
"def get_relation(params = {})\n # make params coming from Ext grid filters understandable by meta_where\n conditions = params[:filter] && convert_filters(params[:filter]) || {}\n\n relation = data_class.where(conditions)\n\n if params[:extra_conditions]\n extra_conditions = normalize_extra_conditions(ActiveSupport::JSON.decode(params[:extra_conditions]))\n relation = relation.extend_with_netzke_conditions(extra_conditions) if params[:extra_conditions]\n end\n\n if params[:query]\n # array of arrays of conditions that should be joined by OR\n query = ActiveSupport::JSON.decode(params[:query])\n meta_where = query.map do |conditions|\n normalize_and_conditions(conditions)\n end\n\n # join them by OR\n meta_where = meta_where.inject(meta_where.first){ |r,c| r | c } if meta_where.present?\n end\n\n relation = relation.where(meta_where)\n\n relation = relation.extend_with(config[:scope]) if config[:scope]\n\n relation\n end",
"def query_without_filter_paging_sorting\n query = @initial_query.dup\n\n # restrict to select columns\n query_projection(query)\n end",
"def prepare_query\n if @taxon_concept && TaxonData.is_clade_searchable?(@taxon_concept)\n inner_query = EOL::Sparql::SearchQueryBuilder.build_query_with_taxon_filter(@taxon_concept.id, inner_select_clause, where_clause, order_clause)\n else\n inner_query = EOL::Sparql::SearchQueryBuilder.build_query(inner_select_clause, where_clause, order_clause, nil)\n end\n # this is strange, but in order to properly do sorts, limits, and offsets there should be a subquery\n # see http://virtuoso.openlinksw.com/dataspace/doc/dav/wiki/Main/VirtTipsAndTricksHowToHandleBandwidthLimitExceed\n EOL::Sparql::SearchQueryBuilder.build_query(outer_select_clause, inner_query, nil, limit_clause)\n end",
"def query(conditions = [], order = [], limit = 250)\n conditions.select!{ |h| Proc === self.class.searchable[h[:field].to_sym]}\n @conditions = conditions\n @order = Hash[order].reject { |field, dir| field.nil? || !self.class.sortable[field.to_sym] }.\n map{ |field, dir| (dir == 'asc') ? self.class.sortable[field.to_sym].asc : self.class.sortable[field.to_sym].desc }\n @limit = limit\n dataset\n end",
"def execute *args\n if args.first == :query\n self\n else\n opts = args.last.is_a?(Hash) ? args.last : {}\n results = []\n\n pagination = opts.delete(:paginate) || {}\n model.send(:with_scope, :find => opts) do\n @conditions.paginate(pagination) unless pagination.empty?\n results = model.find args[0], to_find_parameters\n if @conditions.paginate?\n paginate_result_set results, to_find_parameters\n end\n end\n results\n end\n end",
"def query(value)\n Query.new(self, @query_by, value).to_relation\n end",
"def query(*args, &block)\n @query = block ? @query = Query.new(*args, &block) : args.first\n self\n end",
"def query(query)\n url_chunk, entity_set = if query.is_a?(Frodo::Query)\n [query.to_s, query.entity_set.name]\n else\n [query]\n end\n\n body = api_get(url_chunk).body\n\n # if manual query as a string we detect the set on the response\n entity_set = body['@odata.context'].split('#')[-1] if entity_set.nil?\n build_entity(entity_set, body)\n end",
"def query_scope\n record_class.public_send(include_strategy, included_associations)\n end",
"def get_relation(params = {})\n @arel = data_class.arel_table\n\n relation = data_class.scoped\n\n relation = apply_column_filters(relation, params[:filter]) if params[:filter]\n\n if params[:extra_conditions]\n extra_conditions = normalize_extra_conditions(ActiveSupport::JSON.decode(params[:extra_conditions]))\n relation = relation.extend_with_netzke_conditions(extra_conditions) if params[:extra_conditions]\n end\n\n query = params[:query] && ActiveSupport::JSON.decode(params[:query])\n\n if query.present?\n # array of arrays of conditions that should be joined by OR\n and_predicates = query.map do |conditions|\n predicates_for_and_conditions(conditions)\n end\n\n # join them by OR\n predicates = and_predicates[1..-1].inject(and_predicates.first){ |r,c| r.or(c) }\n end\n\n relation = relation.where(predicates)\n\n relation = relation.extend_with(config[:scope]) if config[:scope]\n\n relation\n end",
"def collection_for(source, other_query=nil)\n Collection.new(source, target_model)\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = GetDocumentResultSet.new(resp)\n return results\n end",
"def query\n return nil\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FindByCoordinatesResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FindByCoordinatesResultSet.new(resp)\n return results\n end",
"def find(conditions = EMPTY_HASH)\n new(restricted_relation(conditions))\n end",
"def find_with_ferret(q, options = {}, find_options = {})\n if respond_to?(:scope) && scope(:find, :conditions)\n if find_options[:conditions]\n find_options[:conditions] = \"(#{find_options[:conditions]}) AND (#{scope(:find, :conditions)})\"\n else\n find_options[:conditions] = scope(:find, :conditions)\n end\n end\n return ActsAsFerret::find q, self, options, find_options\n end",
"def as_query(opts={})\n Tripod.logger.debug(\"TRIPOD: building select query for criteria...\")\n\n return_graph = opts.has_key?(:return_graph) ? opts[:return_graph] : true\n\n Tripod.logger.debug(\"TRIPOD: with return_graph: #{return_graph.inspect}\")\n\n select_query = \"SELECT DISTINCT ?uri \"\n\n if graph_lambdas.empty?\n\n if return_graph\n # if we are returning the graph, select it as a variable, and include either the <graph> or ?graph in the where clause\n if graph_uri\n select_query += \"(<#{graph_uri}> as ?graph) WHERE { GRAPH <#{graph_uri}> { \"\n else\n select_query += \"?graph WHERE { GRAPH ?graph { \"\n end\n else\n select_query += \"WHERE { \"\n # if we're not returning the graph, only restrict by the <graph> if there's one set at class level\n select_query += \"GRAPH <#{graph_uri}> { \" if graph_uri\n end\n\n select_query += self.query_where_clauses.join(\" . \")\n select_query += \" } \"\n select_query += \"} \" if return_graph || graph_uri # close the graph clause\n\n else\n # whip through the graph lambdas and add into the query\n # we have multiple graphs so the above does not apply\n select_query += \"WHERE { \"\n\n graph_lambdas.each do |lambda_item|\n select_query += \"GRAPH ?g { \"\n select_query += lambda_item.call\n select_query += \" } \"\n end\n\n select_query += self.query_where_clauses.join(\" . \")\n select_query += \" } \"\n end\n\n select_query += self.extra_clauses.join(\" \")\n\n select_query += [order_clause, limit_clause, offset_clause].join(\" \")\n\n select_query.strip\n end",
"def select(*args)\n Criteria.new(self).select(*args)\n end",
"def to_query\n return nil if config.nil? # not a whitelisted attr\n klass = JsonApiServer.filter_builder(builder_key) || raise(\"Query builder '#{builder_key}' doesn't exist.\")\n builder = klass.new(attr, casted_value, operator, config)\n builder.to_query(@model)\n end",
"def base_query\n @base_query ||= begin\n # In the beginning we cheat by using ActiveRecord to reduce the\n # amount of AREL code we have to write. We will convert to AREL\n # below.\n assignments = Assignment.all\n .select('\n assignments.id,\n assignments.assigned_to_type,\n assignments.assigned_to_id,\n roles.id AS role_id,\n roles.name AS role_name,\n permissions.id AS permission_id'\n )\n .joins(:permissions)\n .where(assignments: { user_id: user.id })\n\n # explicitly call .arel rather than convert Assignment.all\n # to user.assignments. The reason is that ActiveRecord::Relation\n # will produce bind parameters that will not get handled correctly\n # when AREL is asked to generate SQL\n assignments.arel\n end\n end",
"def from\n @from ||= begin\n results = relation.search_with_conditions(public_access, rows: 1, sort: MODIFIED_DATE_FIELD + ' asc')\n if results.present?\n results.first.fetch(MODIFIED_DATE_FIELD)\n else\n BEGINNING_OF_TIME\n end\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FindByEmailResultSet.new(resp)\n return results\n end",
"def where(query={}, options={})\n new.where(query)\n end",
"def prepare_query\n if @taxon_concept\n inner_query = EOL::Sparql::SearchQueryBuilder.build_query_with_taxon_filter(@taxon_concept.id, inner_select_clause, where_clause, inner_order_clause)\n else\n inner_query = EOL::Sparql::SearchQueryBuilder.build_query(inner_select_clause, where_clause, inner_order_clause, nil)\n end\n # this is strange, but in order to properly do sorts, limits, and offsets there should be a subquery\n # see http://virtuoso.openlinksw.com/dataspace/doc/dav/wiki/Main/VirtTipsAndTricksHowToHandleBandwidthLimitExceed\n EOL::Sparql::SearchQueryBuilder.build_query(outer_select_clause, inner_query, outer_order_clause, limit_clause)\n end"
] | [
"0.7018905",
"0.5848367",
"0.5704148",
"0.55644894",
"0.55564356",
"0.5513734",
"0.550383",
"0.550383",
"0.5446275",
"0.54153264",
"0.54153264",
"0.54153264",
"0.5390705",
"0.5383686",
"0.53689975",
"0.5361893",
"0.53583664",
"0.53410643",
"0.53379124",
"0.53075457",
"0.53075457",
"0.53053635",
"0.527087",
"0.5232671",
"0.5194433",
"0.5194433",
"0.5190125",
"0.5189392",
"0.5184165",
"0.5166438",
"0.516457",
"0.5118187",
"0.5096199",
"0.5093834",
"0.5085741",
"0.5071364",
"0.5069474",
"0.50651526",
"0.5065139",
"0.50612426",
"0.5050833",
"0.5048966",
"0.5048209",
"0.5027088",
"0.5023844",
"0.50221944",
"0.5007639",
"0.50017923",
"0.5000164",
"0.4995979",
"0.49768424",
"0.49650326",
"0.4958881",
"0.49550712",
"0.49535632",
"0.49439478",
"0.49424866",
"0.49402896",
"0.49372938",
"0.49226844",
"0.49222943",
"0.49221066",
"0.48970303",
"0.48900717",
"0.48788676",
"0.48634237",
"0.48624805",
"0.48587802",
"0.48580518",
"0.48521549",
"0.48465374",
"0.48464108",
"0.48328626",
"0.48257065",
"0.48150632",
"0.48106098",
"0.4806747",
"0.4806656",
"0.48060897",
"0.48048317",
"0.47972012",
"0.4795683",
"0.47895327",
"0.47839588",
"0.47826728",
"0.47805947",
"0.47785506",
"0.47782934",
"0.47752008",
"0.47752008",
"0.477262",
"0.4772226",
"0.47717673",
"0.47630942",
"0.47621635",
"0.4761668",
"0.4760792",
"0.47602212",
"0.47592902",
"0.4758911"
] | 0.7097449 | 0 |
Create a new query with the same values as this one, optionally overriding any of them in the options | def clone(opts = {})
self.class.new(locals.merge(opts))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(options={})\n self.query = Query.new\n self.query.table = options.delete(:table)\n self.query.limit = options.delete(:limit)\n self.query.offset = options.delete(:offset)\n self.query.select = options.delete(:select)\n self.query.conditions = options.delete(:conditions) || []\n self.query.uses = options.delete(:uses) || []\n self.query.tail = options.delete(:tail)\n self.query.truncate = options.delete(:truncate)\n self.query.reverse = options.delete(:reverse)\n self.query.unique = options.delete(:unique)\n self.query.sanitize = options.delete(:sanitize)\n self.query.remote_limit = options.delete(:remote_limit)\n self.query.remote_offset = options.delete(:remote_offset)\n end",
"def query_options\n # todo: support more options?\n options = {}\n options.merge!({:limit => limit_value.to_json}) if limit_value\n options.merge!({:skip => @options[:skip].to_json}) if @options[:skip]\n options.merge!({:reversed => reversed?.to_json}) if reversed?\n options.merge!({:order => @options[:order]}) if @options[:order]\n options.merge!({:cursor => @options[:cursor]}) if @options[:cursor]\n options\n end",
"def query_options\n opts = options.merge(:input => input)\n session ? session.query_options.merge(opts) : opts\n end",
"def query_options\n @query_options ||= @connection.query_options\n end",
"def query_opts!(q_opts = nil)\n return self if q_opts.nil?\n [:snapshot, :max_scan, :show_disk_loc].each do |k|\n q_opts[k].nil? ? @opts.delete(k) : @opts.merge!(k => q_opts[k])\n end\n self\n end",
"def query_options; end",
"def prep_query\n @options[:query]['region_id'] = @region_id if @region_id\n @options[:query]['state'] = @state if @state\n @options[:query]['county'] = @countye if @county\n @options[:query]['city'] = @city if @city\n @options[:query]['childtype'] = @childtype if @childtype\n @options\n end",
"def initialize(query, options = {})\n @query = query\n @options = options\n end",
"def query_options\n @query_options\n end",
"def where(query={}, options={})\n new.where(query)\n end",
"def legacy_options\n {\n :conditions => options[:where],\n :include => options[:includes],\n :limit => options[:limit],\n :order => options[:order],\n :offset => options[:offset],\n :select => options[:select],\n :group => options[:group],\n }.delete_blanks\n end",
"def initialize(options)\n initialize_params(options)\n initialize_query\n end",
"def initialize(options)\n initialize_params(options)\n initialize_query\n end",
"def query_options(options)\n options.each_with_object({}) do |(key, val), hash|\n case key\n when :date\n hash[:ShowDate] = val.to_ShowDate\n when :movie_id\n hash[:movie_id] = val\n when :movie_source\n # Set both movie_id and ShowDate.\n movie_source = val\n hash.merge! query_options(movie_id: movie_source.external_id)\n hash.merge! query_options(date: movie_source.released_on) if movie_source.released_on\n when :postal_code\n hash[:SearchZip] = val.to_s.gsub(' ', '')\n else\n raise \"unknown option: #{key}\"\n end\n end\n end",
"def new_query(**args)\n OpportunitySearchBuilder.new(args).call\n end",
"def query(options={})\n qry = Query.new(table)\n options[:transformer] ||= begin\n lambda { |ct_record|\n instance = allocate\n instance.init_with(ct_record)\n instance\n }\n end\n qry.merge(options)\n end",
"def query\n case query_type_str\n when 'empty'\n return\n when 'iso'\n return iso_query_builder\n when 'multi'\n return multi_query_builder\n end\n end",
"def query\n\t\tQuery.new(\"true\")\n\tend",
"def default_query\n base_where_query(nil, nil)\n end",
"def query\n super\n end",
"def query_full\n query = @initial_query.dup\n\n # restrict to select columns\n query = query_projection(query)\n\n #filter\n query = query_filter(query)\n\n # sorting\n query = query_sort(query)\n\n # paging\n query_paging(query)\n end",
"def initial_query(arg)\n query = Hash.new\n return query\n end",
"def create_classic_query(options)\n raise ArgumentError, \"Query name is not present\" unless options[:query_name]\n raise ArgumentError, \"Parent list id is not present\" unless options[:parent_list_id]\n raise ArgumentError, \"Criteria is required\" unless options[:criteria]\n\n options[:visibility] ||= 0\n\n request_body = ''\n xml = Builder::XmlMarkup.new(:target => request_body, :indent => 1)\n xml.instruct!\n\n xml.Envelope do\n xml.Body do\n xml.CreateQuery do\n xml.QUERY_NAME options[:query_name]\n xml.PARENT_LIST_ID options[:parent_list_id]\n xml.VISIBILITY options[:visibility]\n\n xml.PARENT_FOLDER_ID options[:parent_folder_id] if options.has_key?(:parent_folder_id)\n xml.SELECT_COLUMNS options[:select_columns] if options.has_key?(:select_columns)\n xml.ALLOW_FIELD_CHANGE options[:allow_field_change] if options.has_key?(:allow_field_change)\n\n xml.CRITERIA do\n xml.TYPE options[:criteria][:type] if options[:criteria].has_key?(:type)\n\n options[:criteria][:expressions].each do |exp|\n xml.EXPRESSION do\n xml.TYPE exp[:type] if exp.has_key?(:type)\n xml.COLUMN_NAME exp[:column_name] if exp.has_key?(:column_name)\n xml.OPERATORS exp[:operators] if exp.has_key?(:operators)\n xml.VALUES exp[:values] if exp.has_key?(:values)\n xml.TABLE_ID exp[:table_id] if exp.has_key?(:table_id)\n xml.LEFT_PARENS exp[:left_parens] if exp.has_key?(:left_parens)\n xml.RIGHT_PARENS exp[:right_parens] if exp.has_key?(:right_parens)\n xml.AND_OR exp[:and_or] if exp.has_key?(:and_or)\n if exp[:rt_expressions]\n exp[:rt_expressions].each do |rt_exp|\n xml.RT_EXPRESSION do\n xml.TYPE rt_exp[:type] if rt_exp.has_key?(:type)\n xml.COLUMN_NAME rt_exp[:column_name] if rt_exp.has_key?(:column_name)\n xml.OPERATORS rt_exp[:operators] if rt_exp.has_key?(:operators)\n xml.VALUES rt_exp[:values] if rt_exp.has_key?(:values)\n xml.LEFT_PARENS rt_exp[:left_parens] if rt_exp.has_key?(:left_parens)\n xml.RIGHT_PARENS rt_exp[:right_parens] if rt_exp.has_key?(:right_parens)\n xml.AND_OR rt_exp[:and_or] if rt_exp.has_key?(:and_or)\n end\n end\n end\n end\n end\n end\n\n if options[:behavior]\n xml.BEHAVIOR do\n xml.OPTION_OPERATOR options[:behavior] if options.has_key?(:behavior)\n xml.TYPE_OPERATOR options[:type_operator] if options.has_key?(:type_operator)\n xml.MAILING_ID options[:mailing_id] if options.has_key?(:mailing_id)\n xml.REPORT_ID options[:report_id] if options.has_key?(:report_id)\n xml.LINK_NAME options[:link_name] if options.has_key?(:link_name)\n xml.WHERE_OPERATOR options[:where_operator] if options.has_key?(:where_operator)\n xml.CRITERIA_OPERATOR options[:criteria_operator] if options.has_key?(:criteria_operator)\n xml.VALUES options[:values] if options.has_key?(:values)\n end\n end\n end\n end\n end\n\n doc = send_xml_api_request(request_body)\n result_dom(doc)['ListId']\n end",
"def find_class_options_for_query_with_and(query, options={})\n options\n end",
"def custom_query(options)\n form_data = {}\n options.each {|k,v| form_data[k.to_s] = v.to_s }\n form_data['action'] = 'query'\n make_api_request(form_data).first.elements['query']\n end",
"def find_class_options_for_query_with_or(query, options={})\n options\n end",
"def initialize(query={})\n @query = query\n end",
"def query_opts(q_opts = nil)\n return query_opts_hash if q_opts.nil?\n opts = @opts.dup\n [:snapshot, :max_scan, :show_disk_loc].each do |k|\n q_opts[k].nil? ? opts.delete(k) : opts.merge!(k => q_opts[k])\n end\n Scope.new(collection, selector, opts)\n end",
"def initialize\n super(\"query\")\n end",
"def query_builder(options)\r\n parsed_options = []\r\n\r\n options.each do |key,value|\r\n case key\r\n when :offset\r\n parsed_options << \"page[offset]=#{value}\"\r\n when :limit\r\n parsed_options << \"page[limit]=#{value}\"\r\n when :sort\r\n parsed_options << \"sort=#{value}\"\r\n when :created_at_start\r\n parsed_options << \"filter[createdAt-start]=#{value}\"\r\n when :created_at_end\r\n parsed_options << \"filter[createdAt-end]=#{value}\"\r\n when :player_ids\r\n parsed_options << \"filter[playerIds]=#{value.join(',')}\"\r\n when :game_mode\r\n parsed_options << \"filter[gameMode]=#{value}\"\r\n end\r\n end\r\n\r\n if options.empty?\r\n \"/matches\"\r\n else\r\n queries = parsed_options.join(\"&\")\r\n \"/matches?#{queries}\"\r\n end\r\n end",
"def generate_upsert_options\n if options.empty?\n ''\n else\n ' USING ' <<\n options.map do |key, value|\n serialized_value =\n case key\n when :timestamp then (value.to_f * 1_000_000).to_i\n else value\n end\n \"#{key.to_s.upcase} #{serialized_value}\"\n end.join(' AND ')\n end\n end",
"def clone(opts = nil || (return self))\n # return self used above because clone is called by almost all\n # other query methods, and it is the fastest approach\n c = super(:freeze=>false)\n c.opts.merge!(opts)\n unless opts.each_key{|o| break if COLUMN_CHANGE_OPTS.include?(o)}\n c.clear_columns_cache\n end\n c.freeze\n end",
"def combined_options(options)\n resp = @options\n resp[:query].merge! options\n resp\n end",
"def query(query=nil, options={})\n options = options.symbolize_keys\n query_params = query ? options.merge({ql: query}) : options\n self.get({params: query_params })\n self\n end",
"def update_query( hash )\n \n # Convert symbols to strings to avoid duplicate entries\n hash = Hash[hash.map {|k, v| [ k.to_s, v] }] if hash.keys.any? { |k| k.is_a?(Symbol) }\n \n # Merge the changes with the existing query\n query.query_values = query.query_values.merge!( hash )\n \n self\n end",
"def build_query(query, options={})\n queries = []\n QUERY_KEYWORDS.each do |kw|\n next unless options[kw]\n if options[kw].is_a? Array\n kw_query = options[kw].map {|s| \"#{kw}:#{s}\".strip }.join(\" OR \")\n queries << \" (#{kw_query})\"\n else\n queries << \" #{kw}:#{options[kw]}\"\n end\n end\n \"#{query} #{queries.join(' ')}\".strip\n end",
"def retrieve_query\n if params[:set_filter] or !session[:query] or session[:query].project_id\n # Give it a name, required to be valid\n @query = Query.new(:name => \"_\", :executed_by => logged_in_user)\n if params[:fields] and params[:fields].is_a? Array\n params[:fields].each do |field|\n @query.add_filter(field, params[:operators][field], params[:values][field])\n end\n else\n @query.available_filters.keys.each do |field|\n @query.add_short_filter(field, params[field]) if params[field]\n end\n end\n session[:query] = @query\n else\n @query = session[:query]\n end\n end",
"def build_query(builder)\n builder.OPTION {\n @option.each do |k, v|\n builder.PARAMETER k.to_s.upcase\n value = case v\n when Array then v.join(',')\n when Hash then v.map { |a| a.join(':') }.join(',')\n else\n v.to_s\n end\n\n # I don't know this is correct or not, but I think we should not\n # touch third party ID.\n value.upcase! unless k == :prefer_xid\n\n builder.VALUE value\n end\n }\n end",
"def default_values\n @query = \"default values\"\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 where(params = {})\n @options.merge!(params)\n self\n end",
"def generate_upsert_options\n if options.empty?\n ''\n else\n ' USING ' <<\n options.map do |key, value|\n serialized_value =\n case key\n when :consistency then value.to_s.upcase\n when :timestamp then (value.to_f * 1_000_000).to_i\n else value\n end\n \"#{key.to_s.upcase} #{serialized_value}\"\n end.join(' AND ')\n end\n end",
"def count_options\n query_options.dup.tap do |co|\n co[:conditions] = conditions_clause unless conditions_clause.empty?\n end\n end",
"def applying_deprecated_query_args( args ) # :nodoc:\n rel = self.all\n rel = rel.includes(args[:include]) if args[:include]\n rel = rel.where(args[:conditions]) if args[:conditions]\n rel = rel.order(args[:order]) if args[:order]\n rel = rel.limit(args[:limit]) if args[:limit]\n rel\n end",
"def apply_criteria_options\n unless criteria.selector.empty?\n command[:pipeline][0][\"$match\"] = criteria.selector\n end\n if sort = criteria.options[:sort]\n command[:pipeline][0][\"$sort\"] = sort\n end\n if limit = criteria.options[:limit]\n command[:pipeline][0][\"$limit\"] = limit\n end\n if skip = criteria.options[:skip]\n command[:pipeline][0][\"$skip\"] = skip\n end\n if fields = criteria.options[:fields]\n command[:pipeline][0][\"$project\"] = fields\n end\n end",
"def initialize(*)\n super\n self.options = options.dup\n end",
"def with options = {}\n # symbolize option keys\n options = symbolize_keys options\n values = supplied.merge(options)\n \n if supplied == values\n self # no changes\n else\n self.class.new(values)\n end\n end",
"def as_query(opts={})\n Tripod.logger.debug(\"TRIPOD: building select query for criteria...\")\n\n return_graph = opts.has_key?(:return_graph) ? opts[:return_graph] : true\n\n Tripod.logger.debug(\"TRIPOD: with return_graph: #{return_graph.inspect}\")\n\n select_query = \"SELECT DISTINCT ?uri \"\n\n if graph_lambdas.empty?\n\n if return_graph\n # if we are returning the graph, select it as a variable, and include either the <graph> or ?graph in the where clause\n if graph_uri\n select_query += \"(<#{graph_uri}> as ?graph) WHERE { GRAPH <#{graph_uri}> { \"\n else\n select_query += \"?graph WHERE { GRAPH ?graph { \"\n end\n else\n select_query += \"WHERE { \"\n # if we're not returning the graph, only restrict by the <graph> if there's one set at class level\n select_query += \"GRAPH <#{graph_uri}> { \" if graph_uri\n end\n\n select_query += self.query_where_clauses.join(\" . \")\n select_query += \" } \"\n select_query += \"} \" if return_graph || graph_uri # close the graph clause\n\n else\n # whip through the graph lambdas and add into the query\n # we have multiple graphs so the above does not apply\n select_query += \"WHERE { \"\n\n graph_lambdas.each do |lambda_item|\n select_query += \"GRAPH ?g { \"\n select_query += lambda_item.call\n select_query += \" } \"\n end\n\n select_query += self.query_where_clauses.join(\" . \")\n select_query += \" } \"\n end\n\n select_query += self.extra_clauses.join(\" \")\n\n select_query += [order_clause, limit_clause, offset_clause].join(\" \")\n\n select_query.strip\n end",
"def initialize(query_name, opts = {})\n @query_name = query_name\n @options = opts\n end",
"def find_options_for_query(query, options={})\n find_options_for_find_by_query(query, find_by_query_columns, options)\n end",
"def to_query(_model)\n raise 'subclasses should implement this method.'\n end",
"def retrieve_query\n store_query_params if is_new_query?\n reset_query_params if reset_new_query?\n @timesheet_query = TimesheetQuery.new({:monitoring_projects => @monitoring_projects,\n :monitoring_members => @monitoring_members,\n :timesheet_user => @timesheet_user})\n query = restore_query_params\n if query[:fields] and query[:fields].is_a? Array\n query[:fields].each do |field|\n @timesheet_query.add_filter(field,query[:operators][field], query[:values][field])\n end\n else\n @timesheet_query.available_filters.keys.each do |field|\n @timesheet_query.add_short_filter(field, params[field]) if params[field]\n end\n end\n @timesheet_query.validate\n end",
"def create_query( relation )\n Query.new(relation)\n end",
"def all(query={}, options={})\n new.all(query, options)\n end",
"def query_builder\n QueryBuilder.new(self)\n end",
"def initial_query; end",
"def solr_query(query, options = {})\n query_options = generate_query_options(query, options)\n activerecord_options = extract_activerecord_options(options)\n SolrSearchable::Handler::Select.new(query_options, self, {:format => :raw}).execute\n end",
"def initialize(options={})\n super options\n if query.nil? && filter.nil?\n raise \"Must give a query or a filter\"\n end\n end",
"def to_query\n hash = {:fields => [], :operators => {}, :values => {}}\n active_filters.each do |f|\n hash[:fields] << f.name\n hash[:operators][f.name] = f.operator\n hash[:values][f.name] = f.value\n end\n hash.to_query\n end",
"def apply_criteria_options\n if spec = criteria.options[:sort]\n query.sort(spec)\n end\n if spec = criteria.options[:fields]\n query.select(spec)\n end\n end",
"def with_options(options)\n self.class.new(@table, @options.merge(options), @col_types).freeze\n end",
"def where(attrs = {})\n return self if attrs.blank?\n self.clone.tap do |r|\n r.query_attrs = r.query_attrs.merge(attrs)\n r.clear_fetch_cache!\n end\n end",
"def to_query\n {\n params: query\n }\n end",
"def to_query\n {\n params: query\n }\n end",
"def options_for(type, query, options={})\n opts = instance_options.merge(filter_hash(options, BASE_OPTIONS))\n opts.merge!(:sources => type.to_s, :query => build_query(query, options))\n \n source_options = filter_hash(options, [:http] + BASE_OPTIONS + QUERY_KEYWORDS)\n opts.merge!(scope_source_options(type, source_options))\n \n http_options = options[:http] || {}\n http_options.merge(:query => opts)\n end",
"def initial_query=(_arg0); end",
"def initialize\n @query_fields = nil \n @query_params = {}\n \n @sql_like = 'LIKE'\n \n if ActiveRecord::Base.connected? and ActiveRecord::Base.connection.adapter_name.downcase == 'postgresql'\n @sql_like = 'ILIKE'\n end\n end",
"def initial_query(arg)\n query = Hash.new\n query[:status_id] = arg[:status_id] if arg[:status_id].present?\n return query\n end",
"def custom_queries\n @custom_queries ||= ::Valkyrie::Persistence::CustomQueryContainer.new(query_service: self)\n end",
"def initialize(query, records = nil, options = {})\n super(query, records)\n @time = options[:time]\n @total_found = options[:total_found]\n @count = options[:count]\n @keywords = options[:keywords]\n @docs = options[:docs]\n @facets = options.fetch(:facets, {})\n @pager = options[:pager]\n end",
"def reset\n self.query = Query.new\n end",
"def where(args)\n @query.merge!(args)\n self.all\n end",
"def query(args = {})\n initialize_query unless initialized?\n\n our_select = args[:select] || \"DISTINCT #{model.table_name}.id\"\n our_join = join.dup\n our_join += args[:join] if args[:join].is_a?(Array)\n our_join << args[:join] if args[:join].is_a?(Hash)\n our_join << args[:join] if args[:join].is_a?(Symbol)\n our_tables = tables.dup\n our_tables += args[:tables] if args[:tables].is_a?(Array)\n our_tables << args[:tables] if args[:tables].is_a?(Symbol)\n our_from = calc_from_clause(our_join, our_tables)\n our_where = where.dup\n our_where += args[:where] if args[:where].is_a?(Array)\n our_where << args[:where] if args[:where].is_a?(String)\n our_where = calc_where_clause(our_where)\n our_group = args[:group] || group\n our_order = args[:order] || order\n our_order = reverse_order(order) if our_order == :reverse\n our_limit = args[:limit]\n\n # Tack id at end of order to disambiguate the order.\n # (I despise programs that render random results!)\n if our_order.present? &&\n !our_order.match(/.id( |$)/)\n our_order += \", #{model.table_name}.id DESC\"\n end\n\n sql = %(\n SELECT #{our_select}\n FROM #{our_from}\n )\n sql += \" WHERE #{our_where}\\n\" if our_where.present?\n sql += \" GROUP BY #{our_group}\\n\" if our_group.present?\n sql += \" ORDER BY #{our_order}\\n\" if our_order.present?\n sql += \" LIMIT #{our_limit}\\n\" if our_limit.present?\n\n @last_query = sql\n sql\n end",
"def initialize(q = nil)\n q ||= {}\n @q = Q.new(q, columns, self.relation.table_name)\n end",
"def get_query_options(proc)\n opts = ActsAsRecursiveTree::Options::QueryOptions.new\n\n proc.call(opts) if proc\n\n opts\n end",
"def merge_finder_options_with_and!(options={})\n options.reject! {|k,v| v.blank?}\n self[:select] = [self[:select], options.delete(:select)].compact.join(\", \")\n self[:conditions] = ActiveRecord::Base.sanitize_and_merge_conditions_with_and(self[:conditions], options.delete(:conditions))\n self[:order] = ActiveRecord::Base.sanitize_and_merge_order(self[:order], options.delete(:order))\n self[:joins] = ActiveRecord::Base.sanitize_and_merge_joins(self[:joins], options.delete(:joins))\n self.reject! {|k,v| v.blank?}\n self.merge!(options)\n end",
"def query(hash = nil)\n hash ? @query = hash : @query\n end",
"def new_query(timeframe)\n klass.new(namespace, bucket, options.merge(timeframe: timeframe))\n end",
"def build_where_query(options)\n query_keys = {}\n options.each do |k,v|\n # as expected by DynamoDB\n typed_key = k.to_s\n query_keys[typed_key] = dyno_typed_key(key: typed_key, val: v)\n end\n {\n table_name: self.table_name,\n attributes_to_get: attribute_names,\n key: query_keys\n }\n end",
"def to_query\n {\n json: query\n }\n end",
"def to_query\n {\n json: query\n }\n end",
"def transform_query_options(query_options)\n query = query_options.symbolize_keys\n query.keys.each do |key|\n if mapping = mappings[key]\n new_options = mapping.perform(query)\n query.delete(key)\n query.update(new_options)\n end\n end\n query\n end",
"def query_params\n p = base_params.merge(filter_params).\n merge(options_params).\n merge(pivot_params)\n p.merge!(measures: measures_param) unless measures.empty?\n p.merge!(dimensions: dimensions_param) unless dimensions.empty?\n p.merge!(sort: sort_option) if sort_option\n p\n end",
"def query=(value)\n @query = value\n end",
"def query=(value)\n @query = value\n end",
"def query=(value)\n @query = value\n end",
"def initialize_copy(original)\n super\n @query = @query.dup\n @cache = @cache.dup\n @orphans = @orphans.dup\n end",
"def prepare_query(q_hash, options={})\n terms = options.fetch(:terms, {})\n limit = options.fetch(:limit, -1)\n skip = options.fetch(:skip, -1)\n order = options.fetch(:order, {})\n\n # Load the query but don't return any field data since we don't need it\n query = {\n 'fields' => [],\n 'query' => q_hash\n }\n\n # If we have terms that must match (such as user_id) set them\n if terms.length > 0\n if q_hash.include?('term')\n q_hash['term'].merge! terms\n else\n if q_hash.include?('bool')\n if !q_hash['bool'].include?('must')\n q_hash['bool']['must'] = []\n end\n\n q_hash['bool']['must'] << {term: terms}\n else\n query['query'] = {\n 'bool' => {\n 'must' => [q_hash]\n }\n }\n\n query['query']['bool']['must'] << {term: terms}\n end\n end\n end\n\n # Set the limit\n if limit > 0\n query['size'] = limit\n end\n\n # Set the number of records to skip\n if skip > 0\n query['from'] = skip\n end\n\n # Set the sort order, sorting by _score last\n if !query.include? 'sort'\n query['sort'] = []\n end\n\n order.map do |k, v|\n query['sort'] << {k => v}\n end\n\n if query['sort'].select { |x| x.keys.first == '_score' }.count == 0\n query['sort'] << {'_score' => 'desc'}\n end\n\n query\n end",
"def get_query_options(&block)\n ActsAsRecursiveTree::Options::QueryOptions.from(&block)\n end",
"def merge!(query)\n if !query.is_a?(SQLQuery)\n query[:context] = @context.name unless query[:context]\n\n # If we're passed a string query to merge, it must start with\n # *; if it doesn't, we supply the leading *.\n #\n # If the caller really wants to merge a query with a nick\n # selector, they may use an explicit nick dereference:\n # '@person foo=bar' etc.\n unless query[:cmdline] =~ /^\\* /\n query[:cmdline] = '* ' + query[:cmdline]\n end\n query = SQLQuery.new(query)\n end\n QueryMerger.merge_into(self, query)\n end",
"def base_query(select_columns = true)\n if source_query\n if select_columns && source_select_columns\n source_query.call.select(*source_select_columns).where(source_conditions)\n else\n source_query.call.where(source_conditions)\n end\n else\n query = source_model.where(source_conditions).order(source_order_by => :asc)\n query = query.select(*source_select_columns) if select_columns && source_select_columns\n !force_full_update && highest_known_destination_order_by ? query.where(\"#{source_order_by} >= ?\", highest_known_destination_order_by) : query\n end\n end",
"def add_general_query\n fields = [\n \"creators.name^5\",\n \"title^7\",\n \"endnotes\",\n \"notes\",\n \"summary\",\n \"tags.name\",\n \"series.title\"\n ]\n query_string = options[:q]\n return if query_string.blank?\n body.must(\n :query_string,\n fields: fields,\n query: query_string\n )\n end",
"def apply_options(options) \r\n if options.kind_of? Hash\r\n conditions = options.delete(:conditions) || {}\r\n \r\n conditions.each do | c_name, c_value |\r\n c_name = c_name.to_s\r\n \r\n case c_name\r\n when /list\\Z/i\r\n # List filters\r\n list = query.__send__(c_name.camelize)\r\n c_value = [c_value] unless c_value.kind_of?(Array)\r\n c_value.each { |i| list.Add(i) }\r\n when /range\\Z/i\r\n # Range filters\r\n c_value = parse_range_value(c_value)\r\n range_filter = filter_for(c_name)\r\n range_name = c_name.match(/(.*)_range\\Z/i)[1]\r\n if range_name == 'modified_date'\r\n # Modified Date Range use the IQBDateTimeType which requires a\\\r\n # boolean 'asDateOnly' value.\r\n range_filter.__send__(\"from_#{range_name}=\", c_value.first, true) if c_value.first\r\n range_filter.__send__(\"to_#{range_name}=\", c_value.last, true) if c_value.last\r\n else\r\n range_filter.__send__(\"from_#{range_name}=\", c_value.first) if c_value.first\r\n range_filter.__send__(\"to_#{range_name}=\", c_value.last) if c_value.last\r\n end\r\n when /status\\Z/i\r\n # Status filters\r\n filter.__send__(\"#{c_name}=\", c_value)\r\n else\r\n # Reference filters - Only using FullNameList for now\r\n ref_filter = filter_for(c_name)\r\n c_value = [c_value] unless c_value.respond_to?(:each)\r\n c_value.each do | val |\r\n ref_filter.FullNameList.Add(val)\r\n end\r\n end\r\n end\r\n \r\n add_owner_ids(options.delete(:owner_id))\r\n add_limit(options.delete(:limit))\r\n add_includes(options.delete(:include))\r\n\r\n options.each do |key, value|\r\n self.send(key.to_s.camelize).SetValue(value)\r\n end\r\n end\r\n end",
"def query\n @operation = :query\n self\n end",
"def build_meta_query(query)\n meta_query = {}\n if query.kind_of?(Hash)\n meta_query[:limit] = query.delete(:limit) if query[:limit]\n meta_query[:skip] = query.delete(:skip) if query[:skip]\n meta_query[:sort] = [query.delete(:order), 1] if query[:order] # 1 = ASC, -1 = DESC\n end\n meta_query\n end",
"def merge_query_options(opts)\n # return nil if opts is empty, else concat\n opts.blank? ? nil : '?' + opts.to_a.map {|k,v| \"#{k}=#{v}\"}.join(\"&\")\n end",
"def fetch_query args={}\n query(args.clone)\nend",
"def fetch_query args={}\n query(args.clone)\nend",
"def method_missing(method_name, *args, &block)\n if Query.instance_methods(false).include?(method_name)\n Query.new(self).send(method_name, *args, &block)\n else\n super\n end\n end",
"def n_plus_one_query_enable=(_arg0); end",
"def initialize(query)\n @query = query \n end"
] | [
"0.7084909",
"0.6825532",
"0.65663075",
"0.6455315",
"0.63708556",
"0.6317489",
"0.626224",
"0.6247702",
"0.623057",
"0.6217517",
"0.6193991",
"0.6176988",
"0.6176988",
"0.61534125",
"0.61451143",
"0.6132",
"0.611564",
"0.61147106",
"0.6100363",
"0.60006297",
"0.59986967",
"0.599485",
"0.5979269",
"0.5974053",
"0.59617764",
"0.59501",
"0.59105337",
"0.59066415",
"0.58756864",
"0.5874911",
"0.58673596",
"0.58386236",
"0.58198243",
"0.581337",
"0.58034223",
"0.5802971",
"0.57909817",
"0.5788488",
"0.57807165",
"0.57785475",
"0.57738084",
"0.577117",
"0.57515824",
"0.57301545",
"0.5720319",
"0.5713715",
"0.57089865",
"0.57049656",
"0.5702293",
"0.5701237",
"0.56804955",
"0.56700253",
"0.56536406",
"0.5649038",
"0.56482255",
"0.56481755",
"0.5635685",
"0.563531",
"0.562343",
"0.5621908",
"0.560574",
"0.5605058",
"0.56014544",
"0.56014544",
"0.5600125",
"0.5587301",
"0.5586228",
"0.55826473",
"0.5569352",
"0.5567918",
"0.55651814",
"0.55621135",
"0.5561423",
"0.555669",
"0.5552997",
"0.5552607",
"0.5549271",
"0.5548106",
"0.5548105",
"0.55327743",
"0.55327743",
"0.553184",
"0.55312693",
"0.553117",
"0.553117",
"0.553117",
"0.5520881",
"0.55205387",
"0.5516216",
"0.5512304",
"0.5507264",
"0.5502964",
"0.5502622",
"0.5490441",
"0.54752445",
"0.54747885",
"0.5459798",
"0.5459798",
"0.5456201",
"0.54494375",
"0.5438624"
] | 0.0 | -1 |
Returns whether this uritemplate is absolute. This is detected by checking for "://". | def absolute?
return @absolute unless @absolute.nil?
read_chars = ""
tokens.each do |token|
if token.expression?
read_chars << "x"
elsif token.literal?
read_chars << token.string
end
if read_chars =~ /^[a-z]+:\/\//i
return @absolute = true
elsif read_chars =~ /(^|[^:\/])\/(?!\/)/
return @absolute = false
end
end
return @absolute = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def absolute?\n @uri.absolute?\n end",
"def absolute_url?\n (self.include?('://') || self.start_with?('/')) ? true : false\n end",
"def absolute?\n if @scheme\n true\n else\n false\n end\n end",
"def absolute_url?(string); end",
"def absolute?\n #%r{\\A/} =~ @path ? true : false\n @absolute\n end",
"def absolute_uri?(source)\n source.kind_of?(String) && URI.parse(source).absolute?\n rescue URI::InvalidURIError\n false\n end",
"def absolute_url?(string)\n return unless string\n\n Addressable::URI.parse(string).absolute?\n rescue Addressable::URI::InvalidURIError\n nil\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 absolute?; !scheme.nil?; end",
"def absolute?\n !relative?\n end",
"def absolute?\n @is_absolute\n 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?\n @absolute\n end",
"def is_url?( path )\n path =~ URI::ABS_URI\nend",
"def absolute?(path); end",
"def absolute?\n\t\t!relative?\n\tend",
"def absolute_path?\n PathUtils.absolute_path?(path)\n 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 relative?\n not absolute?\n end",
"def absolute?(path)\n %r{\\A/} =~ path ? true : false\n end",
"def valid_url?(url)\n uri = URI.parse(url)\n\n uri.absolute?\n rescue\n false\n end",
"def valid?\n return false if relative?\n return false unless to_origin && to_domain\n return false unless URI::DEFAULT_PARSER.make_regexp.match(normalize)\n\n true\n end",
"def url_ok(url)\n return url =~ URI::ABS_URI\n end",
"def relative?\n !@absolute\n end",
"def relative?\n !absolute?\n end",
"def absolute?(path)\n !relative?(path)\n end",
"def absolute?; end",
"def PathAbsolute?(path)\n if(!path)\n return false\n end\n \n return path.match(\"^(([A-Za-z]:)|(\\/))\") != nil\n end",
"def valid_uri?\n !self.contentable.blank? || !self.uri_path.blank?\n end",
"def absolute?\n @string.start_with?(separator)\n end",
"def valid_url?\n\t\t# http:// or not http://\n\t\tx = self.long_url.start_with?(\"http://\", \"https://\")\n\t\tif x == false\n\t\t\treturn \"http://\" + self.long_url\n\t\telse\n\t\t\treturn self.long_url\n\t\tend\n\tend",
"def accessing_absolute_path(path)\n return true if path.start_with?('/')\n\n false\n end",
"def url?(uri)\n /\\w+\\:\\/\\// =~ uri\n end",
"def url?(uri)\n /\\w+\\:\\/\\// =~ uri\n end",
"def real_url?\n url && url.present? && url != \"#\"\n end",
"def migrate_linked_file?(uri)\n host = uri.host.to_s\n path = uri.path.to_s\n if(host == 'www.ctcc.uio.no')\n if(path != '/' and path != '')\n return true\n else\n return false\n end\n elsif(host != '')\n return false\n end\n return super(uri)\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 is_url?\n path =~ URL_PATHS\n end",
"def absolute?(path) \n p = get(path) \n File.absolute_path(p, \".\") == p # rbx\n end",
"def url?\n !urn?\n end",
"def off_site?(url)\n url !~ /^\\// # urls not starting with a /\n end",
"def valid?\n (uri.host =~ LINK_REGEX || uri.host =~ LINK_IP_REGEX) ? true : false\n end",
"def scheme_relative?\n start_with?('//')\n end",
"def relative?; !absolute?; end",
"def absolute_url(url)\n url.match?(/^http:/) ? url : \"#{url_root}#{url}\"\n end",
"def trackable?(uri)\n uri && uri.absolute? && %w(http https).include?(uri.scheme)\n end",
"def internal_source?(uri)\n uri = URI.parse(uri.to_s)\n\n internal_host?(uri.host) if uri.host\n end",
"def uri?\n children[0] && children[0].is_a?(Uri)\n end",
"def url?\n children[0] && children[0].is_a?(Url)\n end",
"def is_a_real_url?\n begin\n URI.parse(long_url)\n rescue URI::InvalidURIError\n errors.add(:message, \"must be a valid URL\")\n end \n end",
"def local?(link)\n uri = Addressable::URI.parse(link)\n return true if uri.host == @domain\n return false\n end",
"def get_absolute_file_url(url)\n orig_url = url.to_s.strip\n \n url = file_url(orig_url)\n # If a file:// was stripped from the url, this means it will always point\n # to a file\n force_file = (orig_url != url)\n # Indicates wether the base url is a network url or a file/directory\n base_is_net = !base_file_url.is_a?(String)\n # Try to find if we have a \"net\" URL if we aren't sure if this is a file. In\n # case the base url is a network url, we'll always assume that the\n # url is also a net thing. Otherwise we only have a net url if it contains a\n # '://' string\n is_net_url = !force_file && (base_is_net || url.include?('://'))\n # The url is absolute if there is a : character to be found\n \n \n if(is_net_url)\n base_is_net ? join_url(base_file_url, url) : url\n else\n base_is_net ? url : join_files(base_file_url, url)\n end\n end",
"def is_url?(path)\n path.to_s =~ %r{\\Ahttps?://}\n end",
"def uri?(word)\n return false if config.include_uris\n !(word =~ URI.regexp).nil?\n end",
"def is_a_uri?(value)\n uri = URI.parse(value)\n uri.is_a?(URI::HTTP) && !uri.host.nil? && uri.host.split(\".\").size > 1\n rescue URI::InvalidURIError\n false\n end",
"def absolute_path? path\n (path.start_with? SLASH) || (@file_separator == BACKSLASH && (WindowsRootRx.match? path))\n end",
"def absolute_url(url)\n if url && !url.include?(\"http\") \n URI.join(root_url, url)\n else\n url\n end\n end",
"def relative?\n path = @path\n while r = chop_basename(path)\n path, basename = r\n end\n path == ''\n end",
"def root?\n #%r{\\A/+\\z} =~ @path ? true : false\n @absolute and @path.empty?\n end",
"def proper_url? \n\t\tif !(self.long_url.start_with?('http://') || self.long_url.start_with?('https://'))\n\t\t\terrors.add(:long_url, \"is in invalid format.\")\n\t\tend \n\tend",
"def same_host?(uri)\n uri.host == @url.host\n end",
"def file_uri?(uri)\n uri =~ %r{\\Afile://}\n end",
"def uri?\n !!@uri\n end",
"def uri?\n !!@uri\n end",
"def internal?\n url[0] == \"#\"\n end",
"def normalize_url\n return if self.url.blank?\n normalized = self.url.normalize\n if normalized.blank?\n self.errors.add(:url, \"is invalid\")\n return false\n elsif normalized.match(\"archiveofourown.org/users\")\n self.errors.add(:url, \"cannot be ao3 user\")\n return false\n elsif normalized.match(\"(.*)/collections/(.*)/works/(.*)\")\n normalized = $1 + \"/works/\" + $3\n elsif normalized.match(\"archiveofourown.org/collections\")\n self.errors.add(:url, \"cannot be an ao3 collection\")\n return false\n end\n self.url = normalized\n end",
"def relative?\n\t\tpath[0] == 47\n\tend",
"def within_realm? uri\n uri = URI.parse(uri.to_s)\n realm = URI.parse(self.realm)\n return false unless uri.absolute?\n return false unless uri.path[0, realm.path.size] == realm.path\n return false unless uri.host == realm.host or realm.host[/^\\*\\./]\n # for wildcard support, is awkward with URI limitations\n realm_match = Regexp.escape(realm.host).\n sub(/^\\*\\./,\"^#{URI::REGEXP::PATTERN::URIC_NO_SLASH}+.\")+'$'\n return false unless uri.host.match(realm_match)\n return true\n end",
"def is_place_holder?()\n return rel_path.nil?\n end",
"def is_uri?(source)\n !!(source =~ URI_REGEXP)\n end",
"def local\n uri.local?\n end",
"def local\n uri.local?\n end",
"def link_local(link)\n begin\n u = URI.parse link\n host_match = u.host == @url.host\n nil_host = u.host.nil?\n return host_match || nil_host\n rescue\n false\n end\n end",
"def fix_host\n if host.blank?\n begin\n uri = URI(url)\n logger.debug (self.host = uri.host.match(/\\w*\\.\\w*$/)[0])\n rescue\n return false\n end\n end\n true\n end",
"def uri?(string)\n uri = URI.parse(string)\n %w[http https].include?(uri.scheme)\n rescue URI::BadURIError, URI::InvalidURIError\n false\n end",
"def uri?(string)\n\t\turi = URI.parse(string)\n\t\t%w( http https ).include?(uri.scheme)\n\trescue URI::BadURIError\n\t\tfalse\n\trescue URI::InvalidURIError\n\t\tfalse\n\tend",
"def invalid_uri?(uri)\n uri.grep(/^(#{PROTOCOLS.join('|')}):\\/\\/\\w/).empty?\n end",
"def external_asset_url?\n !same_source_host? && url_from_asset_tag?\n end",
"def url?\n !url.nil?\n end",
"def base_url?( url_path )\n @base_url ||= base_url.gsub(/http\\:\\/\\/[^\\/]+/, '')\n @base_url == url_path\n end",
"def base_url?( url_path )\n @base_url ||= base_url.gsub(/http\\:\\/\\/[^\\/]+/, '')\n @base_url == url_path\n end",
"def url?(string)\n begin\n uri = URI.parse(string)\n %w( http https ).include?(uri.scheme)\n rescue URI::BadURIError\n false\n rescue URI::InvalidURIError\n false\n end\n end",
"def validate_uri(url)\n !!URI.parse(url)\n end",
"def local?\n @uri.scheme == 'file'\n end",
"def real_url?(context = nil)\n url = url context\n url.present? && url != '#'\n end",
"def validate_uri(url)\n !!URI.parse(url)\n end",
"def absolute_url\n return unless fileable?\n Rails.application.routes.default_url_options[:host] ||= \"http://localhost:3000\"\n Rails.application.routes.url_helpers.root_url[0..-2] + file.url\n end",
"def target?\n if self.target.match(/^(http[s]?:\\/\\/)/)\n return self.target\n else\n return \"http://#{self.target}\"\n end\n end",
"def url?(value)\n URI.parse(value.to_s).scheme\n end",
"def url_valid?\n ALLOWED_URLS.each do |host, url_allowed|\n if url.include? url_allowed\n @host = host\n return true\n end\n end\n false\n end",
"def is_uri?(uri)\n URI::Generic===uri\n end",
"def is_url?\n self =~ /^#{URI::regexp}$/\n end",
"def absolutify_url(url)\n url =~ /^\\w*\\:/i ? url : File.join(@url,url)\n end",
"def email_uri?\n @url[0..6] == 'mailto:'\n end",
"def check_canonical\n canonical_element = @server.response.doc.at_xpath(\"//link[@rel = 'canonical']/@href\")\n\n return if canonical_element.nil?\n\n canonical_url = canonical_element.value\n\n if canonical_url.nil?\n @result.warned(\"HTML: No Canonical URL\") \n elsif Addressable::URI.parse(canonical_url) == @server.url\n @result.passed(\"HTML: Canonical URL matches URL\") \n else\n @result.failed(\"HTML: Canonical URL (#{canonical_url}) doesn't match given URL (#{@server.url.to_s})\") \n end\n end",
"def valid?(uri)\n uri ||= default_uri\n\n uri.host = @default_host if uri.host.nil?\n\n real_domain = domain =~ /^\\./ ? domain[1..-1] : domain\n !!((!secure? || (secure? && uri.scheme == 'https')) &&\n uri.host =~ Regexp.new(\"#{'^' if @exact_domain_match}#{Regexp.escape(real_domain)}$\", Regexp::IGNORECASE))\n end",
"def valid_url?(uri)\n parsed = URI.parse(uri)\n return (parsed.scheme == 'http' || parsed.scheme == 'https')\n rescue URI::InvalidURIError\n false\n end",
"def same_source_host?\n parse(@url).host == parse(@source_url).host\n end",
"def to_uri(url)\n uri = URI.parse(url)\n uri.host.nil? ? false : uri\n rescue URI::BadURIError\n false\n rescue URI::InvalidURIError\n false\n end"
] | [
"0.8419571",
"0.8111299",
"0.79552335",
"0.78528345",
"0.7761613",
"0.7753431",
"0.7614763",
"0.74972963",
"0.74972963",
"0.74638903",
"0.7335414",
"0.7262466",
"0.72552073",
"0.72454077",
"0.7211512",
"0.7210166",
"0.715751",
"0.71414983",
"0.7112463",
"0.707958",
"0.7067324",
"0.7022705",
"0.7008147",
"0.6987723",
"0.69509685",
"0.6934959",
"0.69274604",
"0.68458956",
"0.681726",
"0.6815007",
"0.68121225",
"0.6797559",
"0.67789096",
"0.673585",
"0.66954666",
"0.6634534",
"0.6575993",
"0.65744805",
"0.6548543",
"0.6541592",
"0.6518943",
"0.64737445",
"0.6432278",
"0.6426585",
"0.6419611",
"0.6399798",
"0.6379373",
"0.6373432",
"0.6351078",
"0.63477176",
"0.6324953",
"0.6306473",
"0.629177",
"0.6264604",
"0.62619966",
"0.62413424",
"0.6239222",
"0.6181823",
"0.61511165",
"0.61502457",
"0.61418104",
"0.61342144",
"0.6130544",
"0.61252886",
"0.61252886",
"0.6114808",
"0.61045337",
"0.6052343",
"0.60461324",
"0.6031787",
"0.60142326",
"0.5986595",
"0.5986595",
"0.59849095",
"0.597807",
"0.59762",
"0.5963843",
"0.5958791",
"0.5953531",
"0.594599",
"0.59415835",
"0.59415835",
"0.59393615",
"0.59252834",
"0.5922987",
"0.59225315",
"0.59159565",
"0.589006",
"0.5883996",
"0.5871165",
"0.58619416",
"0.5850056",
"0.58402354",
"0.583893",
"0.58290976",
"0.58167356",
"0.58047944",
"0.5797124",
"0.5796569",
"0.5780514"
] | 0.7195111 | 16 |
For now this follows v5.4 syntax... We have not yet finalised an OML syntax inside OEDL for v6 TODO: v6 currently does not support OML filters. Formerly in v5.x, these filters were defined in an optional block. | def measure(mp, opts, &block)
collect_point = opts.delete(:collect)
collect_point ||= OmfEc.experiment.oml_uri
if collect_point.nil?
warn "No OML URI configured for measurement collection! "+
"(see option 'oml_uri'). Disabling OML Collection for '#{mp}'."
return
end
stream = { :mp => mp , :filters => [] }.merge(opts)
index = @oml_collections.find_index { |c| c[:url] == collect_point }
@oml_collections << {:url => collect_point, :streams => [stream] } if index.nil?
@oml_collections[index][:streams] << stream unless index.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def or_filters\n read_attribute('or_filters') || {}\n end",
"def filters; end",
"def filters; end",
"def filters=(_arg0); end",
"def filters=(_arg0); end",
"def visit_filter(node)\n # For unknown reasons, haml doesn't escape interpolations in filters.\n # So we can rely on \\n to split / get the number of lines.\n filter_name_indent = @original_haml_lines[node.line - 1].index(/\\S/)\n if node.filter_type == 'ruby'\n # The indentation in node.text is normalized, so that at least one line\n # is indented by 0.\n lines = node.text.split(\"\\n\")\n lines.map! do |line|\n if line !~ /\\S/\n # whitespace or empty\n ''\n else\n ' ' * filter_name_indent + line\n end\n end\n\n @ruby_chunks << RubyFilterChunk.new(node, lines,\n haml_line_index: node.line, # it's one the next line, no need for -1\n start_marker_indent: filter_name_indent,\n end_marker_indent: filter_name_indent)\n elsif node.text.include?('#')\n name_indentation = ' ' * @original_haml_lines[node.line - 1].index(/\\S/)\n # TODO: HAML_LINT_FILTER could be in the string and mess things up\n lines = [\"#{name_indentation}#{script_output_prefix}<<~HAML_LINT_FILTER\"]\n lines.concat @original_haml_lines[node.line..(node.line + node.text.count(\"\\n\") - 1)]\n lines << \"#{name_indentation}HAML_LINT_FILTER\"\n @ruby_chunks << NonRubyFilterChunk.new(node, lines,\n end_marker_indent: filter_name_indent)\n # Those could be interpolation. We treat them as a here-doc, which is nice since we can\n # keep the indentation as-is.\n else\n @ruby_chunks << PlaceholderMarkerChunk.new(node, 'filter', indent: filter_name_indent,\n nb_lines: 1 + node.text.count(\"\\n\"))\n end\n end",
"def filters\n end",
"def body\n AQL::Node::Block.new([filter, return_operation])\n end",
"def ts_apply_filters\n # TODO: Make filters for Thinking Sphinx\n end",
"def add_filters(filters); end",
"def apply_filter\n end",
"def filter_by_extension\n if item[:extension] == \"haml\"\n filter :haml\n else\n filter :erb\n filter :kramdown, coderay_line_numbers: :table\n end\nend",
"def strict_filters; end",
"def liquid_filters\n [\n StylesheetFilter,\n JavascriptFilter,\n AssignToFilter,\n LinkToFilter,\n GoogleAnalyticsFilter,\n GoogleWebmasterToolsFilter,\n GoogleJavascriptFilter,\n TextileFilter,\n DesignResourceFilter,\n AttributeFilter,\n ResourceFilter,\n NodeFilter,\n FormFilter\n ]\n end",
"def strict_filters=(_arg0); end",
"def filter(&block)\n filters = self.filters << yield\n metaclass.send(:define_method, :_filters) do\n filters\n end\n end",
"def filter(name, function)\n filters = (self.model.design_doc['filters'] ||= {})\n filters[name.to_s] = function\n end",
"def Filter=(arg0)",
"def filter(pname = :mandatory, type = :mandatory, fopts = {})\n raise OEDLMissingArgumentException.new(:filter, :pname) if pname == :mandatory\n raise OEDLMissingArgumentException.new(:filter, :type) if type == :mandatory\n\n unless (fspec = FilterSpec[type])\n raise OEDLIllegalArgumentException(:filter, :fname)\n end\n\n # Build and Add the filter to this Measurement Stream\n #fopts = {}\n fopts[:pname] = pname\n fopts[:fname] = type\n fopts[:ms] = self\n fopts[:fspec] = fspec\n filter = OMF::EC::OML::Filter.new(fopts)\n @filters << filter\n end",
"def parse_filter(filter_argument = T.unsafe(nil), &filter_proc); end",
"def global_filter; end",
"def named_filter; end",
"def filter_parameters; end",
"def filter_parameters; end",
"def filter; end",
"def filter; end",
"def filter; end",
"def filter\n end",
"def or_filters_provided?\n true\n end",
"def filter(filters=nil, options={})\n Filter.new(filters, options, self).nodes()\n end",
"def filter_description\n c = self.filter_clause\n c ? \"Show where #{c}\" : \"Show all\"\n end",
"def filter(filters)\n if filters.empty?\n return nodes\n end\n if filters[0] =~ /^\\+/\n # don't let the first filter have a + prefix\n filters[0] = filters[0][1..-1]\n end\n\n node_list = Config::ObjectList.new\n filters.each do |filter|\n if filter =~ /^\\+/\n keep_list = nodes_for_name(filter[1..-1])\n node_list.delete_if do |name, node|\n if keep_list[name]\n false\n else\n true\n end\n end\n else\n node_list.merge!(nodes_for_name(filter))\n end\n end\n return node_list\n end",
"def filter_pipeline\n @filter_pipeline ||= HTML::Pipeline.new([TypogrubyFilter])\n end",
"def filter\n RuleAspect.from_hash(description['Filter'])\n end",
"def applicable_filters\n fs = []\n fs << Spree::ProductFilters.taxons_below(self)\n ## unless it's a root taxon? left open for demo purposes\n\n fs << Spree::ProductFilters.price_filter if Spree::ProductFilters.respond_to?(:price_filter)\n fs << Spree::ProductFilters.brand_filter if Spree::ProductFilters.respond_to?(:brand_filter)\n #fs << Spree::ProductFilters.occasion_filter if Spree::ProductFilters.respond_to?(:occasion_filter)\n #fs << Spree::ProductFilters.holiday_filter if Spree::ProductFilters.respond_to?(:holiday_filter)\n fs << Spree::ProductFilters.selective_occasion_filter(self) if Spree::ProductFilters.respond_to?(:selective_occasion_filter)\n fs << Spree::ProductFilters.selective_holiday_filter(self) if Spree::ProductFilters.respond_to?(:selective_holiday_filter)\n fs\n end",
"def applicable_filters\n fs = []\n fs << Spree::ProductFilters.taxons_below(self)\n ## unless it's a root taxon? left open for demo purposes\n\n fs << Spree::ProductFilters.price_filter if Spree::ProductFilters.respond_to?(:price_filter)\n fs << Spree::ProductFilters.brand_filter if Spree::ProductFilters.respond_to?(:brand_filter)\n #fs << Spree::ProductFilters.occasion_filter if Spree::ProductFilters.respond_to?(:occasion_filter)\n #fs << Spree::ProductFilters.holiday_filter if Spree::ProductFilters.respond_to?(:holiday_filter)\n fs << Spree::ProductFilters.selective_occasion_filter(self) if Spree::ProductFilters.respond_to?(:selective_occasion_filter)\n fs << Spree::ProductFilters.selective_holiday_filter(self) if Spree::ProductFilters.respond_to?(:selective_holiday_filter)\n fs\n end",
"def filter_complex\n @filtergraph ||= FilterGraph\n end",
"def liquid_filters\n [\n DesignResourceFilter,\n AttributeFilter\n ]\n end",
"def filter(expr); end",
"def filter(expr); end",
"def filters\n mentos(:get_all_filters)\n end",
"def filter(name, function)\n design_doc.create_filter(name, function)\n end",
"def filter *filters\n spawn :@filters, @filters + parse_filter_input(filters)\n end",
"def define_filter(name, &block)\n filters[name.to_sym] = block\n nil\n end",
"def filter_argument; end",
"def filter(event)\n\n #Category\n category = event.get(\"category\")\n if category.nil?\n category = \"\"\n end\n\n new_category = fn_make_cate_all(category, 0) \n event.set(\"category\", new_category)\n\n service_gubun = event.get(\"service_gubun\")\n\n new_cat1 = fn_make_cate_all(category, 2) \n event.set(\"cat1\", new_cat1)\n \n new_cat2 = fn_make_cate_all(category, 4) \n event.set(\"cat2\", new_cat2)\n \n new_cat3 = fn_make_cate_all(category, 6) \n event.set(\"cat3\", new_cat3)\n \n new_cat4 = fn_make_cate_all(category, 8) \n event.set(\"cat4\", new_cat4)\n\n new_cg = \"\"\n if service_gubun == \"1\"\n new_cg = new_cat2 \n else\n new_cg = new_cat1 \n end \n event.set(\"cg\", new_cg)\n\n #Model Factory\n #deplecated : ES에서 Model-Factory 전용 Tokenizer 사용\n=begin\n if service_gubun == \"1\"\n modelnm = event.get(\"modelnm\")\n factory = event.get(\"factory\")\n if modelnm.nil?\n modelnm = \"\"\n end\n if factory.nil?\n factory = \"\"\n end\n\n model_factory = factory_all(modelnm+\" \"+factory)\n event.set(\"model_factory\", model_factory)\n end\n=end\n \n return [event]\n\nend",
"def filters\n @filters ||= {}\n end",
"def filter_proc(filters = {})\n lambda do |p|\n (filters[:name].nil? || p.name =~ filters[:name]) &&\n (filters[:appid_name].nil? || p.app_id_name =~ filters[:appid_name]) &&\n (filters[:appid].nil? || p.entitlements.app_id =~ filters[:appid]) &&\n (filters[:uuid].nil? || p.uuid =~ filters[:uuid]) &&\n (filters[:team].nil? || p.team_name =~ filters[:team] || p.team_ids.any? { |id| id =~ filters[:team] }) &&\n (filters[:exp].nil? || (p.expiration_date < DateTime.now) == filters[:exp]) &&\n (filters[:has_devices].nil? || !(p.provisioned_devices || []).empty? == filters[:has_devices]) &&\n (filters[:all_devices].nil? || p.provisions_all_devices == filters[:all_devices]) &&\n (filters[:aps_env].nil? || match_aps_env(p.entitlements.aps_environment, filters[:aps_env])) &&\n true\n end\n end",
"def _filter_display\n @apotomo_emit_raw_view = true\n render :view => '_filters'\n end",
"def to_xml\n el = REXML::Element.new(\"f\")\n \n # In the current Filter handling by OML Server/Client\n # pname is the input for the filter, and it is an attribute\n # of the filter element in XML\n # However, in the future there could be many inputs \n # to a filter, thus input will become a child element of the\n # filter XML element.\n# if @properties.length > 0\n# @properties.each {|p|\n# el.add_attribute(\"pname\", p.value) if p.idref == :input\n# }\n# end\n \n \n el.add_attribute(\"fname\", @opts[:fname].to_s)\n # TODO: What is 'sname' used for???\n #el.add_attribute(\"sname\", @name.to_s)\n el.add_attribute(\"pname\", @opts[:pname].to_s)\n \n # Support for future evolution of Filter\n #a.add_attribute(\"idref\", idref) \n #if @properties.length > 0\n # pe = a.add_element(\"properties\")\n # @properties.each {|p|\n # pe.add_element(p.to_xml)\n # }\n #end\n return el\n end",
"def get_filters(object)\n if @options[:using].is_a?(Array)\n gen_array_attribute_filters(object, @options[:using])\n else\n gen_map_attribute_filters(object, @options[:using])\n end\n end",
"def filter(type, &b)\n @app.filters[type] << b\n end",
"def close_filtered(filter)\n @flat_spaces = -1\n if filter.is_a? String\n if filter == 'redcloth' || filter == 'markdown' || filter == 'textile'\n raise HamlError.new(\"You must have the RedCloth gem installed to use #{filter}\")\n else\n raise HamlError.new(\"Filter \\\"#{filter}\\\" is not defined!\")\n end\n else\n filtered = filter.new(@filter_buffer).render\n\n unless filter == Haml::Filters::Preserve\n push_text(filtered.rstrip.gsub(\"\\n\", \"\\n#{' ' * @output_tabs}\"))\n else\n push_silent(\"_hamlout.buffer << #{filtered.dump} << \\\"\\\\n\\\"\\n\")\n end\n end\n\n @filter_buffer = nil\n @template_tabs -= 1\n end",
"def data_context_filter_1\r\n\r\n ckie = (RUBY_VERSION =~ /^1.8/) ? Iconv.new('UTF-8//IGNORE', 'latin1').iconv(cookies[:active_filters] || \"\") : (cookies[:active_filters] || \"\").force_encoding(Encoding::ISO_8859_1).encode!(Encoding::UTF_8)\r\n if !ckie.blank?\r\n find_hash = DevFeedback.named_scope_active_filter_method(ActiveSupport::JSON.decode(ckie))\r\n conds = find_hash[:conditions]\r\n @joins_fields = find_hash[:joins]\r\n\r\n DevFeedback.send(:with_scope, {:find => {:conditions => conds, :joins => (@joins_fields || [])}}) {\r\n yield\r\n }\r\n\r\n else\r\n yield\r\n end\r\n end",
"def filter_parameters=(_arg0); end",
"def filter_parameters=(_arg0); end",
"def filter!; end",
"def filters\n [\n GoHiring::SlackMarkdown::Filters::MergeMethodFilter,\n GoHiring::SlackMarkdown::Filters::HeaderFilter,\n GoHiring::SlackMarkdown::Filters::EmptyBlockFilter,\n GoHiring::SlackMarkdown::Filters::BlockBreakerFilter\n ]\n end",
"def filter\n\tfilter_disabled\n\tfilter_repeated\n\tfilter_silenced\n\tfilter_dependencies\n end",
"def set_filters\n @filters = ''\n @filters.concat(\"status:'Available'\")\n unless @manufacturer_or_publisher.blank?\n @filters.concat(\" AND (manufacturer:'#{@manufacturer_or_publisher}'\")\n @filters.concat(\" OR publisher:'#{@manufacturer_or_publisher}')\")\n end\n @filters.concat(\" AND category:'#{@category}'\") unless @category.blank?\n @filters.concat(\" AND seller_name:'#{@seller_name}'\") unless @seller_name.blank?\n end",
"def filter_for(name)\r\n name = name.camelize + \"Filter\"\r\n f = nil\r\n \r\n # List queries place the modified_date_range directly in the filter\r\n if name == 'ModifiedDateRangeFilter'\r\n return filter if filter.respond_to_ole?('FromModifiedDate')\r\n end\r\n \r\n # Report Periods are more or less special circumstance\r\n if name =~ /^Report[Period|Date]/\r\n return @request.ORReportPeriod.ReportPeriod\r\n end\r\n \r\n # Try to get the filter directly\r\n if filter.respond_to_ole?(name)\r\n f = filter.send(name)\r\n end\r\n\r\n # Transaction Date Range Filters change name.\r\n if name == 'TxnDateRangeFilter' &&\r\n filter.respond_to_ole?('TransactionDateRangeFilter')\r\n f = filter.send(\"TransactionDateRangeFilter\").\r\n send(\"ORTransactionDateRangeFilter\").\r\n send(\"TxnDateRange\")\r\n end\r\n \r\n # Check if this is within an 'OR'\r\n if filter.respond_to_ole?(\"OR#{name}\")\r\n f = filter.send(\"OR#{name}\").send(name)\r\n elsif filter.respond_to_ole?(\"OR#{name.gsub(/Range/, '')}\")\r\n f = filter.send(\"OR#{name.gsub(/Range/, '')}\").send(name)\r\n end\r\n \r\n # DateRange OR's\r\n if filter.respond_to_ole?(\"ORDateRangeFilter\") && name =~ /DateRange/i\r\n f = filter.send(\"ORDateRangeFilter\").send(name)\r\n end\r\n\r\n # It might have a nested OR \r\n if f && f.respond_to_ole?(\"OR#{name}\")\r\n f = f.send(\"OR#{name}\")\r\n end\r\n \r\n # Ranges might have another step, with the 'Range' removed.\r\n if f && f.respond_to_ole?(name.gsub(/Range/, ''))\r\n f = f.send(name.gsub(/Range/, ''))\r\n end\r\n \r\n return f\r\n end",
"def render_with_filters\n render action: :formatted_xml_erb\n end",
"def global_filter=(_arg0); end",
"def filter_clause\n @filters[filter % @filters.size] unless @filters.size.zero?\n end",
"def filter(expression = {}, &block)\n case expression\n when SPARQL::Algebra::Expression\n filter_without_expression do |solution|\n expression.evaluate(solution).true?\n end\n filter_without_expression(&block) if block_given?\n self\n else filter_without_expression(expression, &block)\n end\n end",
"def filter\n @filter\n end",
"def filter\n\t\tchain(\n\t\t\tsuper, # Use automatic filter switching, i.e. use params[:filter] and #filter_options\n\t\t\t{:published => true}, # Only find published tags\n\t\t\tlambda { |tag| !tag.active_businesses_in_city(@city).empty? } # Only find tags with at least one active business\n\t\t)\n\tend",
"def filter\n super\n end",
"def add_tag_filters\n return if options[:filter_ids].blank?\n options[:filter_ids].each do |filter_id|\n body.filter(:term, filter_ids: filter_id)\n end\n end",
"def apply_filters(o)\n @filters.keys.find_all{|type| Splib.type_of?(o, type)}.each do |type|\n @filters[type].each_pair do |k,v|\n begin\n case k\n when :filters\n v.each{|f|o = f.filter(o)}\n when :procs\n v.each{|pr|o = pr.call(o)}\n end\n rescue ArgumentError\n # ignore this\n end\n end\n end\n o\n end",
"def filter_generator; end",
"def filter(symbol)\n match_symbol = matcher(symbol, 'symbol') \n match_quote = matcher('quote', 'event')\n quote_or_eod = ORMatcher.new(ArrayList.new([match_eod, match_quote]))\n EventMatchPassThruFilter.new(ANDMatcher.new(ArrayList.new([match_symbol, quote_or_eod])))\n end",
"def add_filter\n @filter = true \n end",
"def filter(filter)\n current_widget.filter filter\n end",
"def allowed_filters\n []\n end",
"def global_filter(&block)\n @filters[nil] = block\n end",
"def filter(name, &block)\n @filters[name.to_s] = block\n end",
"def apply_filter_expression(scope, expression)\n ast = calculator.ast(expression)\n if ast.is_a?(Keisan::AST::LogicalOperator) || boolean_function?(ast)\n apply_ast(scope, ast)\n else\n raise Kaprella::Errors::InvalidFilterExpression.new\n end\n end",
"def add_term_filters\n body.filter(:term, posted: true)\n body.filter(:term, hidden_by_admin: false)\n body.filter(:term, restricted: false) unless include_restricted?\n body.filter(:term, unrevealed: false) unless include_unrevealed?\n body.filter(:term, anonymous: false) unless include_anon?\n body.filter(:term, chapter_count: 1) if options[:single_chapter]\n\n %i(complete language crossover).map do |field|\n value = options[field]\n body.filter(:term, field => value) unless value.nil?\n end\n add_tag_filters\n end",
"def filter_expr(*args, &block)\n schema_utility_dataset.literal(schema_utility_dataset.send(:filter_expr, *args, &block))\n end",
"def filter_expr(*args, &block)\n schema_utility_dataset.literal(schema_utility_dataset.send(:filter_expr, *args, &block))\n end",
"def get_filter_string\n\t\treturn nil if @filters.size == 0\n\t\tfilters = []\n\n\t\t# Loop over each filtergroup\n\t\t# All conditions in a filtergroup are combined using AND\n\t\t# All filtergroups are combined using OR\n\t\[email protected]_with_index do |filter, index|\n\t\t\tfields = []\n\n\t\t\t# Loop over all conditions in a filter group\n\t\t\tfilter.each do |condition|\n\t\t\t\tfield = condition[:field]\n\t\t\t\toperator = condition[:operator]\n\t\t\t\tvalue = condition[:value]\n\n\t\t\t\t# Some filters operate on strings and need wildcards\n\t\t\t\t# Transform value if needed\n\t\t\t\tcase operator\n\t\t\t\t\twhen FilterOperators::LIKE\n\t\t\t\t\t\tvalue = \"%#{value}%\"\n\t\t\t\t\twhen FilterOperators::STARTS_WITH\n\t\t\t\t\t\tvalue = \"#{value}%\"\n\t\t\t\t\twhen FilterOperators::NOT_LIKE\n\t\t\t\t\t\tvalue = \"%#{value}%\"\n\t\t\t\t\twhen FilterOperators::NOT_STARTS_WITH\n\t\t\t\t\t\tvalue = \"#{value}%\"\n\t\t\t\t\twhen FilterOperators::ENDS_WITH\n\t\t\t\t\t\tvalue = \"%#{value}\"\n\t\t\t\t\twhen FilterOperators::NOT_ENDS_WITH\n\t\t\t\t\t\tvalue = \"%#{value}\"\n\t\t\t\t\twhen FilterOperators::EMPTY\n\t\t\t\t\t\t# EMPTY and NOT_EMPTY operators require the filter to be in a different format\n\t\t\t\t\t\t# This because they take no value\n\t\t\t\t\t\tfields.push(\"<Field FieldId=\\\"#{field}\\\" OperatorType=\\\"#{operator}\\\" />\")\n\t\t\t\t\t\tnext\n\t\t\t\t\twhen FilterOperators::NOT_EMPTY\n\t\t\t\t\t\tfields.push(\"<Field FieldId=\\\"#{field}\\\" OperatorType=\\\"#{operator}\\\" />\")\n\t\t\t\t\t\tnext\n\t\t\t\tend\n\n\t\t\t\t# Add this filterstring to filters\n\t\t\t\tfields.push(\"<Field FieldId=\\\"#{field}\\\" OperatorType=\\\"#{operator}\\\">#{value}</Field>\")\n\t\t\tend\n\n\t\t\t# Make sure all filtergroups are OR'ed and add them\n\t\t\tfilters.push(\"<Filter FilterId=\\\"Filter #{index}\\\">#{fields.join}</Filter>\")\n\t\tend\n\n\t\t# Return the whole filterstring\n\t\treturn \"<Filters>#{filters.join}</Filters>\"\n\tend",
"def filterable?; @filterable; end",
"def filter(*args); Typelib.filter_function_args(args, self) end",
"def filter(name, value=true)\n name = name.to_sym\n raise NameError, \":#{name} isn't in the defined filters\" unless @model.defined_filters.include? name\n new_filters = @options[:filters] + [[name, value]]\n\n chain_scope filters: new_filters\n end",
"def filter_expr(*args, &block)\n schema_utility_dataset.literal(schema_utility_dataset.send(:filter_expr, *args, &block))\n end",
"def advanced_filters_provided?\n true\n end",
"def store_mso_opt_filter #:nodoc:\n type = 0xF00B\n version = 3\n instance = 5\n data = ''\n length = nil\n\n data = [0x007F].pack('v') + # Protection -> fLockAgainstGrouping\n [0x01040104].pack('V') +\n [0x00BF].pack('v') + # Text -> fFitTextToShape\n [0x00080008].pack('V')+\n [0x01BF].pack('v') + # Fill Style -> fNoFillHitTest\n [0x00010000].pack('V')+\n [0x01FF].pack('v') + # Line Style -> fNoLineDrawDash\n [0x00080000].pack('V')+\n [0x03BF].pack('v') + # Group Shape -> fPrint\n [0x000A0000].pack('V')\n\n return add_mso_generic(type, version, instance, data, length)\n end",
"def filter_for(shortcut)\n {\n attribute_filter: [:\"MundaneSearch::Filters::AttributeMatch\", {}],\n filter_greater_than: operator_filter(:>),\n filter_less_than: operator_filter(:<),\n filter_greater_than_or_equal_to: operator_filter(:>=),\n filter_less_than_or_equal_to: operator_filter(:<=),\n }[shortcut]\n end",
"def FilterExpr(path, parsed); end",
"def applicable_filters\n fs = []\n # fs << ProductFilters.taxons_below(self)\n ## unless it's a root taxon? left open for demo purposes\n\n fs << Spree::Core::ProductFilters.price_filter if Spree::Core::ProductFilters.respond_to?(:price_filter)\n fs << Spree::Core::ProductFilters.brand_filter if Spree::Core::ProductFilters.respond_to?(:brand_filter)\n fs\n end",
"def extract_operand_filter_data(property_name, ogc_filter)\n filter_data = {}\n property_name_xpath = \"//ogc:PropertyName[contains(text(), '#{property_name}')]\"\n property_name_node_set = ogc_filter.xpath(property_name_xpath, 'ogc' => 'http://www.opengis.net/ogc')\n if (property_name_node_set != nil && property_name_node_set[0] != nil)\n property_literal_node = property_name_node_set[0].next_element\n property_parent_operator_node = property_name_node_set[0].parent\n if (property_literal_node != nil)\n filter_data[:literal_value] = property_literal_node.text\n end\n if (property_parent_operator_node != nil)\n filter_data[:operator] = property_parent_operator_node.name\n end\n end\n filter_data\n end",
"def filter(filter)\n tl = AlienTagList.new\n\n self.each do |ele|\n if ele.tag =~ filter\n tl.add_tag(ele)\n end\n end\n\n return tl\n end",
"def data_context_filter_1\r\n\r\n ckie = (RUBY_VERSION =~ /^1.8/) ? Iconv.new('UTF-8//IGNORE', 'latin1').iconv(cookies[:active_filters] || \"\") : (cookies[:active_filters] || \"\").force_encoding(Encoding::ISO_8859_1).encode!(Encoding::UTF_8)\r\n if !ckie.blank?\r\n find_hash = User.named_scope_active_filter_method(ActiveSupport::JSON.decode(ckie))\r\n conds = find_hash[:conditions]\r\n @joins_fields = find_hash[:joins]\r\n\r\n User.send(:with_scope, {:find => {:conditions => conds, :joins => (@joins_fields || [])}}) {\r\n yield\r\n }\r\n\r\n else\r\n yield\r\n end\r\n end",
"def filters\n @filters ||= {}\n end",
"def filters\n @filters ||= {}\n end",
"def typus_fields_for(filter); end",
"def filter(*args, &block)\n if args.length == 1\n args = args.first\n else\n args.freeze\n end\n\n with_opts(:filter=>args, :filter_block=>block)\n end",
"def apply_filter(filters, content)\n # anything in the rule arrau form position 2 onwards is a Filter\n filtered = content\n \n # apply each filter in the rules\n filters.each do |filter_name|\n filter = FilterStore.get(filter_name)\n filtered = filter.call(filtered)\n end\n \n filtered\n end",
"def filters(type)\n case type\n when :before\n namespaces = self.ancestors + [self]\n all_filters = namespaces.map(&:befores).flatten\n when :after\n namespaces = [self] + self.ancestors.reverse\n all_filters = namespaces.map(&:afters).flatten\n else\n raise 'Invalid filter type. Use :before or :after'\n end\n all_filters.select{|f| f[:opts][:all] || self.send(\"#{type}s\").include?(f) }\n end",
"def filtertype_op\n\t\t\tFILTERTYPE_OP[ self.filtertype.to_sym ]\n\t\tend"
] | [
"0.63526523",
"0.6338202",
"0.6338202",
"0.62142307",
"0.62142307",
"0.61139333",
"0.6054174",
"0.6032129",
"0.6017577",
"0.5977019",
"0.5916134",
"0.5874067",
"0.5858878",
"0.58500105",
"0.5849297",
"0.580708",
"0.57710034",
"0.5747855",
"0.5738424",
"0.5717974",
"0.57064384",
"0.5685603",
"0.568487",
"0.568487",
"0.5671677",
"0.5671677",
"0.5671677",
"0.5671438",
"0.5647974",
"0.5640166",
"0.5632424",
"0.56123763",
"0.5603016",
"0.5596946",
"0.55959654",
"0.55959654",
"0.55913043",
"0.5575905",
"0.5574164",
"0.5574164",
"0.55534106",
"0.55500513",
"0.5536716",
"0.5492862",
"0.5491398",
"0.54832166",
"0.5482427",
"0.54781705",
"0.5476286",
"0.54630584",
"0.5462939",
"0.5461828",
"0.54608005",
"0.5449975",
"0.54249144",
"0.54249144",
"0.54122645",
"0.5410558",
"0.54058796",
"0.54015",
"0.53898394",
"0.5388107",
"0.5385529",
"0.5384871",
"0.53815705",
"0.5372358",
"0.53696597",
"0.5369303",
"0.5364988",
"0.53625053",
"0.53579354",
"0.5354112",
"0.5346154",
"0.53445226",
"0.53439885",
"0.53414136",
"0.53400147",
"0.5338307",
"0.53382146",
"0.5335905",
"0.5335905",
"0.5328775",
"0.532075",
"0.5317002",
"0.53108186",
"0.53066593",
"0.5291711",
"0.5271222",
"0.5271197",
"0.52684295",
"0.5263296",
"0.5258851",
"0.5256999",
"0.52567184",
"0.52382827",
"0.52382827",
"0.5238051",
"0.5236892",
"0.5232631",
"0.5230668",
"0.52247715"
] | 0.0 | -1 |
All from examples here: | def test_floats
zero = "3 000 0.0000000000000000"
assert_equal zero, SimpleRecord::Translations.pad_and_offset(0.0)
puts 'induced = ' + "3.25e5".to_f.to_s
assert_equal "5 005 3.2500000000000000", SimpleRecord::Translations.pad_and_offset("3.25e5".to_f)
assert_equal "4 994 8.4000000000000000", SimpleRecord::Translations.pad_and_offset("8.4e-5".to_f)
assert_equal "4 992 8.4000000000000000", SimpleRecord::Translations.pad_and_offset("8.4e-7".to_f)
assert_equal "3 000 0.0000000000000000", SimpleRecord::Translations.pad_and_offset("0.0e0".to_f)
assert_equal "2 004 5.7500000000000000", SimpleRecord::Translations.pad_and_offset("-4.25e-4".to_f)
assert_equal "2 004 3.6500000000000000", SimpleRecord::Translations.pad_and_offset("-6.35e-4".to_f)
assert_equal "2 003 3.6500000000000000", SimpleRecord::Translations.pad_and_offset("-6.35e-3".to_f)
assert_equal "1 895 6.0000000000000000", SimpleRecord::Translations.pad_and_offset("-4.0e105".to_f)
assert_equal "1 894 6.0000000000000000", SimpleRecord::Translations.pad_and_offset("-4.0e105".to_f)
assert_equal "1 894 4.0000000000000000", SimpleRecord::Translations.pad_and_offset("-6.0e105".to_f)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def probers; end",
"def who_we_are\r\n end",
"def custom; end",
"def custom; end",
"def spec; end",
"def spec; end",
"def weber; end",
"def how_it_works\r\n end",
"def extra; end",
"def implementation; end",
"def implementation; end",
"def usage; end",
"def usage; end",
"def operations; end",
"def operations; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def formation; end",
"def schubert; end",
"def terpene; end",
"def verdi; end",
"def suivre; end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def intensifier; end",
"def refutal()\n end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def example_passed(example)\n end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def desc; end",
"def hints; end",
"def common\n \n end",
"def alternatives; end",
"def apis; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def zuruecksetzen()\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def wrapper; end"
] | [
"0.7633319",
"0.6828286",
"0.6828286",
"0.6828286",
"0.6828286",
"0.6721718",
"0.6468544",
"0.64381826",
"0.64381826",
"0.6405142",
"0.6405142",
"0.63828343",
"0.6381497",
"0.6371727",
"0.6345411",
"0.6345411",
"0.6329541",
"0.6329541",
"0.6296775",
"0.6296775",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6279973",
"0.6264765",
"0.62110746",
"0.6182436",
"0.61256903",
"0.6093481",
"0.60857916",
"0.60857916",
"0.60857916",
"0.60857916",
"0.60820717",
"0.60726327",
"0.60632986",
"0.60632986",
"0.60632986",
"0.60632986",
"0.60632986",
"0.60632986",
"0.60632986",
"0.60632986",
"0.60632986",
"0.60619295",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6061368",
"0.6030318",
"0.6023648",
"0.60162383",
"0.6013436",
"0.59955025",
"0.59847575",
"0.59847575",
"0.59847575",
"0.59847575",
"0.59847575",
"0.59847575",
"0.59847575",
"0.59847575",
"0.5984585",
"0.5970553",
"0.5970553",
"0.5970553",
"0.5970553",
"0.5966117"
] | 0.0 | -1 |
Compute number of integers divisible by k in range [a..b]. full description: | def solution(a, b, k)
first_dividend = a
remainder = first_dividend%k
while remainder != 0 && first_dividend <= b do
first_dividend += 1
remainder = first_dividend%k
end
remainder == 0 ? (b - first_dividend) / k + 1 : 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def divisible_by(a, b, k)\n a = k if a < k\n\n x = ((b-a)/k)\n x += 1 if a % k == 0\n\n #n = 0\n #(a..b).each do |i|\n # n += 1 if i % k == 0\n #end\n return x\nend",
"def intChooseInts (n, k)\n pTop = (n-k+1..n).inject(1, &:*)\n pBottom = (2..k).inject(1,&:*)\n pTop/pBottom\nend",
"def divisibleSumPairs(n, k, ar)\n ar.combination(2).count { |a, b| (a + b) % k == 0 }\nend",
"def p500_v1(k)\n n = 1\n two_k = 2 ** k\n loop do\n if divisors_v2(n) == two_k\n return n\n else\n n += 1\n end\n end\nend",
"def divisibleSumPairs(n, k, ar)\n count = 0\n ar.each_with_index do |outer, i|\n ar.each_with_index do |inner, j|\n if i != j\n count += 1 if ((outer + inner) % k == 0 and i > j)\n end\n end\n end\n count\nend",
"def divisible_sum_pairs(n,k,a)\n count = 0\n i = 0\n\n while (i < n)\n j = i + 1\n\n while (j < n)\n if ((a[i] + a[j]) % k == 0)\n count += 1\n end\n j+=1\n end\n\n i += 1\n end\n count\nend",
"def divisibleSumPairs(n, k, ar)\n combinations = ar.combination(2).to_a.count{ |pair| pair.reduce(:+) % k == 0 }\nend",
"def non_divisible_subset(s, k)\n # Initially set max size = s.length\n max_size = s.length\n\n # Get modulos of k from S. Create a hash table for checking values in constant time\n # Keys = modulos, values = count of modulo\n modulos = s.map { |n| n % k }\n modulos_hash = Hash.new(0) \n modulos.each { |modulo| modulos_hash[modulo] += 1 }\n\n # Iterate through the modulos\n # Create a visted hash to skip modulos that have already been checked\n visited = Hash.new\n modulos_hash.each do |modulo, count|\n pair = k - modulo\n # If modulo is zero or the matching pair is equal to the modulo\n # only one can exist in subset, subtract all but 1 from max_size\n # Else, subtract the lesser count between modulo and its pair\n if modulo == 0 || pair == modulo\n max_size -= (modulos_hash[modulo] - 1)\n elsif modulos_hash[pair]\n next if visited[pair]\n min_pair = [modulos_hash[modulo], modulos_hash[pair]].min\n max_size -= min_pair\n visited[modulo] = true\n end\n end\n\n max_size\nend",
"def divisibleSumPairs(n, k, ar)\n # Complete this function\n count = 0;\n (0...n-1).each do |i|\n (i+1...n).each do |j|\n count += 1 if (ar[i] + ar[j]) % k == 0\n end\n end\n\n count;\nend",
"def divisible_sum_pairs n, k, ar\n pairs = 0\n n.times do |i|\n ((i + 1)...n).each do |j|\n pairs += 1 if ((ar[i] + ar[j]) % k).zero?\n end\n end\n pairs\nend",
"def naive_non_divisible_subsets(s, k)\n modulos = s.map { |n| n % k }\n subsets = []\n \n i = 0\n while i < modulos.length\n subset = [modulos[i]]\n subsets_hash = Hash.new\n subsets_hash[modulos[i]] = true\n\n j = 0\n while j < modulos.length\n if i == j\n j += 1\n next\n else\n pair = k - modulos[j]\n if subsets_hash[pair].nil?\n subset << modulos[j]\n subsets_hash[modulos[j]] = true\n end\n j += 1\n end\n end\n\n subsets << subset\n i += 1\n end\n\n counts = subsets.map { |subset| subset.length }\n counts.max\nend",
"def divisibleSumPairs(n, k, ar) \n count = 0\n \n for a in 0..(n-2) do\n for j in (a+1)..(n-1) do\n count += 1 if ((ar[a] + ar[j]) % k == 0)\n end\n end\n count\nend",
"def solution(a, b, k)\n return (b / k) - ((a - 1) / k)\nend",
"def choose(n, k)\n numer = 1\n denom = 1\n n.downto(k + 1) do |i|\n numer *= i\n end\n (n - k).downto(1) do |i|\n denom *= i\n end\n numer/denom\nend",
"def divisors(n)\n count = 0\n (1..n).each { |div| count += 1 if n % div == 0 }\n return count\nend",
"def beautifulDays(i, j, k)\n i.upto(j).select {|n| ((n - n.to_s.reverse.to_i) / k.to_f).floor == ((n - n.to_s.reverse.to_i) / k.to_f) }.count\nend",
"def getTotalX(a,b)\n least_common_multiple = a.reduce(:lcm)\n greatest_common_factor = b.reduce(:gcd)\n counter = 0\n\n (least_common_multiple..greatest_common_factor).each do |num|\n if num % least_common_multiple == 0 && greatest_common_factor % num == 0\n counter += 1\n end\n end\n\n return counter\nend",
"def is_divisible_using_hashing(arr, k)\n n = arr.length\n hsh = {}\n # collect reminders and their occurences\n for i in 0...n\n if hsh[arr[i] % k]\n hsh[arr[i] % k] += 1\n else\n hsh[arr[i] % k] = 1 \n end \n end\n\n # traverse array again to check reminders with following possiblities\n # 1. if reminder is 0, then its occurence must be > 1\n # 2. if reminder divides k in two halves, then its occurence must be > 1\n # 3. if reminder occurence is same as k - reminder occurence\n\n for i in 0...n\n rem = arr[i] % k\n if rem * 2 == k || rem == 0\n if hsh[rem] == 1\n return false\n end \n else\n if hsh[rem] != hsh[k-rem]\n return false\n end \n end \n end \n true\nend",
"def choose n, k\n return (1..n).reduce(:*) / ( (1..k).reduce(:*) * (1..n-k).reduce(:*) )\nend",
"def aofn( n )\n# Guaranteed in this context...\n# return 0 unless n.coprime?( 10 )\n\n x, k = 1, 1\n until 0 == x\n x = (10*x + 1) % n\n k += 1\n end\n\n k\n end",
"def check_compositions(n, k, i_min = 0, i_max = nil)\n i_max ||= Math.log2(n + 1).ceil.to_i\n span = i_max - i_min\n candidates = radix_sequence(k, span)\n count = 0\n candidates.each do |exponents|\n # p(exponents.map { |i| 2**i }) if exponents.map { |i| 2**i }.sum == n\n count += 1 if exponents.map { |i| 2**(i_min + i) }.sum == n\n end\n count\nend",
"def set_mod_list(k, s)\n arr = []\n k.times do |i|\n arr.push(s.count { |a| a % k == i })\n end\n arr\nend",
"def solution(a, b, k)\n # write your code in Ruby 2.2\n e = b / k\n s = (a-1) / k\n\n e - s\nend",
"def number_combinations(n, k)\n\tnumberOfCombinations = (factorial(n))/(factorial(k) * factorial(n - k))\n\treturn numberOfCombinations\nend",
"def count_num_times(arr, k)\n # base case:\n return 0 if arr.empty?\n\n count_num_times(arr, k - arr.first) +\n count_num_times(arr.shift, k)\nend",
"def kth_divisor(k)\n\t\tndf = self.num_distinct_factors\n\t\tif ndf <= 0\n\t\t\tif !@trivial_factor.nil?\n\t\t\t\treturn @trivial_factor / @trivial_factor # abstract one\n\t\t\telse\n\t\t\t\traise << \"Factorization.kth_divisor: \"\n\t\t\t\t\t\"No factors have been inserted.\\n\"\n\t\t\tend\n\t\tend\n\n\t\tx = @factors_and_multiplicities[0][0]\n\t\trv = x / x # abstract one\n\t\tfor i in (0..(ndf-1))\n\t\t\tbase = @factors_and_multiplicities[i][1] + 1\n\t\t\tpower = k % base\n\t\t\tk = k / base\n\t\t\trv *= @factors_and_multiplicities[i][0] ** power\n\t\tend\n\t\treturn rv\n\tend",
"def sum_mults(n, k)\n n = (n - 1) / k\n return k * n * (n + 1) / 2\nend",
"def p5\n\tdivisors = (1..20).to_a\n\tnum = divisors[-1]\n\tloop do\n\t\tbreak if divisible?(num, divisors)\n\t\tnum += divisors[-1]\n\tend\n\treturn num\nend",
"def is_divisible(arr, k)\n n = arr.length\n visited = Array.new(n, 0)\n\n for i in 0...n\n\n for j in 0...n\n\n if visited[i] == 0 && visited[j] == 0 &&\n (arr[i] + arr[j]) % k == 0\n visited[i] = 1\n visited[j] = 1\n break\n end\n\n end \n end\n for i in 0...n\n if visited[i] == 0\n return false\n end \n end\n\n true \nend",
"def divisors(n)\n (1.upto(n ** 0.5).select { |d| (n % d).zero? }.size * 2) - 1\nend",
"def smallest_divisible_by_all_v2(range)\n return (range).inject(1) do |result, n| \n result.lcm n\n end\nend",
"def combinations(n, k)\n return 1 if (k == 0) || (k == n)\n\n (k + 1..n).reduce(:*) / (1..n - k).reduce(:*)\nend",
"def k_numbers_missing(arr,n)\n nums_missing = (1..n).to_a.length - arr.length\n\n expected_sum = (1..n).to_a.reduce(:+)\n actual_sum = arr.reduce(:+)\n\n expected_factorial = (1..n).to_a.reduce(:*)\n actual_factorial = arr.reduce(:*)\n\n sum_diff = expected_sum - actual_sum\n combos = all_number_combos(sum_diff,nums_missing)\n\n combos.each do |combo|\n set = expected_factorial\n combo.each do |num|\n if set / num == actual_factorial\n return combo\n else\n set = set / num\n end\n end\n end\nend",
"def divisor(n)\n count = 0\n (1..n).each do |d|\n if n % d == 0\n count += 1\n end \n end \n count \nend",
"def solution(k, a)\n count = 0\n current = 0\n a.each { |length| \n current += length\n if current >= k\n current = 0\n count += 1\n end\n }\n count\nend",
"def getTotalX(a, b)\n factors_of_b = (a.min..b.min).select do |num|\n b.all? { |n| num.factor?(n) }\n end\n\n factors_of_b.select { |num| a.all? { |n| n.factor?(num) } }.length\nend",
"def Division(num1,num2)\n factors = []\n (1..10**3).each {|idx| factors << idx if (num1 % idx == 0 && num2 % idx == 0)}\n factors.max\nend",
"def get_partial_permutations(n,k)\r\n result = 1\r\n while (k > 0)\r\n result *= n\r\n n -= 1\r\n k -= 1\r\n end\r\n return (result % 1000000)\r\nend",
"def iter\n f1,f2,k = 1,1,2\n f1,f2,k = f2,f1+f2,k+1 while f2.to_s.size < 1000\n puts k\nend",
"def sum_multiples(n1,n2,limit)\n sum = 0\n for i in 1...limit\n sum+= i if(i%n1 == 0 or i%n2 == 0)\n end \n sum\nend",
"def count_compositions(n_max, k_max, i_min = 0, i_max = nil)\n ns = (1..n_max).to_a\n ks = (2..k_max).to_a\n table = ns.map do |n|\n power_of_2?(n) && 2**i_min <= n && (i_max.nil? || n <= 2**i_max) ? [1] : [0]\n end\n ks.each do |k|\n ns.each do |n|\n next if k > n\n i_max_n = i_max || Math.log2(n).floor.to_i\n table[n - 1][k - 1] = (i_min..i_max_n).map do |i|\n n_prev = n - 2**i\n k_prev = k - 1\n k_prev > n_prev ? 0 : table[n_prev - 1][k_prev - 1]\n end.sum\n end\n end\n table\nend",
"def problem_5(lower_limit, upper_limit)\n searching = true\n numerator = upper_limit\n while searching == true\n numerator += 2\n searching = false\n (lower_limit..upper_limit).each do |denominator|\n searching = true unless numerator % denominator == 0\n end\n end\n return numerator\nend",
"def smallest_k(ranges, k)\nend",
"def solution(a, b)\n count = 0\n a.zip(b).each do |ai, bi|\n count += 1 if has_prime_divisors?(ai, bi)\n end\n count\nend",
"def number_of_divisors\n (1..Math.sqrt(self)).inject(0) {|sum, i| modulo(i) == 0 ? sum + 2 : sum}\n end",
"def find_pairs(nums, k)\n return 0 if k < 0\n hash = {}\n count = 0\n nums.each do |num|\n if hash[num]\n if k == 0 && hash[num] == 1\n count += 1\n end\n hash[num] += 1\n else\n if hash[num - k]\n count += 1\n end\n if hash[num + k]\n count += 1\n end\n hash[num] = 1\n end\n end\n count\nend",
"def sum_divisors(n)\r\n (1...n).select { |x| (n % x).zero? }.sum - 1\r\nend",
"def cantidadPrimosRango(rangoInicial, rangoFinal)\n contador = 0\n x = rangoInicial\n y = rangoFinal\n if x >= 4\n z = x - 1\n else\n z = x\n end\n for i in z..y\n if y % i == 0\n contador = contador + 1\n end\n end\n return contador\nend",
"def workbook(n, k, arr)\r\n # Write your code here\r\n sp = 0\r\n count = 0\r\n arr.each do |range|\r\n remainingArray = Array(1..range)\r\n until (remainingArray.empty?)\r\n count += 1\r\n x = remainingArray.slice!(0,k)\r\n sp +=1 if (x.include?count)\r\n end\r\n end\r\n return sp\r\nend",
"def divisor_counter(n)\n i, count = 1, 0\n\n until i * i > n\n if n % i == 0\n count += 1\n count += 1 if i * i != n\n end\n i += 1\n end\n\n count\nend",
"def recessive k, m, n\n all = k + m + n\n mix = m + n\n total = 4.0 * triangle(all) # 2 * squareish all = 2 * 2 * triangle all\n\n lhs = triangle n\n mid = n * mix - n\n rhs = triangle mix\n\n 1 - (lhs+mid+rhs) / total\n end",
"def binomial(n,k)\n return 1 if n-k <= 0\n return 1 if k <= 0\n fact(n) / ( fact(k) * fact( n - k ) )\n end",
"def solve( n = 1_000, a = 3, b = 5 )\n # Important that multiples of BOTH a and b not be double-counted.\n (0...n).select {|x| 0 == x % a || 0 == x % b}.inject( :+ )\n end",
"def k(n); 5 * n * n; end",
"def multisum(num)\n count = 0\n (1..num).each { |idx| count += idx if (idx % 3).zero? || (idx % 5).zero? }\n count\nend",
"def nontrivial_divisors_of number, options={}\n default_options = {upper_limit: number - 1}\n # Merge in default options because default options in the argument list will\n # be ignored/missed if a partial option hash is passed in\n options = default_options.merge options\n\n upper_limit = options[:upper_limit]\n\n divisors = []\n (2..upper_limit).each do |val|\n if number % val == 0\n divisors.push val\n end\n end\n divisors\nend",
"def findKth(nums1,nums2,k)\nend",
"def num_of_divisors(n)\n count = 1\n 1.upto(n/2+1) do |i|\n if n % i == 0\n count += 1\n end\n end\n count\nend",
"def howDivisible(val)\n\t#halfPower = val ** 0.5\n\t#halfPower.round()\n\t2.upto(21) do |x|\n\t\treturn x - 1 if(val % x != 0)\n\tend\n\t \n\treturn 21\nend",
"def number_of_factors(n)\n # bruteforce, simplest\n # least efficient way\n count = 0\n\n (1..n).each do |i|\n if n % i == 0\n count += 1\n end\n end\n\n count\nend",
"def nth_ugly_number(n, a, b, c)\n# a-b, a-c, b-c, ab-c\n ab_lcm = a.lcm(b) # there are some a present in b\n ac_lcm = a.lcm(c) # there are some a present in c\n bc_lcm = b.lcm(c) # there are some b present in c\n abc_lcm = ab_lcm.lcm(c) # there are some a*b in c (because c is the biggest)\n \n # using set theory for binary search\n # a + b + c - ab_lcm - ac_lcm - bc_lcm + abc_lcm\n (1..2*10**9).bsearch{|x| x/a + x/b + x/c - x/ab_lcm - x/ac_lcm - x/bc_lcm + x/abc_lcm >= n}\nend",
"def divisors(num)\n\tcount = 0\n\tfor i in 1..Math.sqrt(num)\n\t\tif num % i == 0\n\t\t\tcount += 2\n\t\tend\n\tend\n\treturn count\nend",
"def divisible_by_5_and_3\n numbers = (1..100).to_a # this will create an array from 1 to 100. Check the Range class from Ruby - https://ruby-doc.org/core-2.5.1/Range.html\nend",
"def getTotalX(a, b)\n is_factor = -> (n1, n2){n1 % n2 == 0}\n\n max = [a.max, b.max].max\n\n ns_between = (1..max).each.select{ |i|\n a.all?{|_a| is_factor.(i, _a)} && b.all?{|_b| is_factor.(_b, i)}\n }\n\n return ns_between.length\nend",
"def number_of_divisors\n return 1 if self == 1\n self.prime_division.map{|num, power| power + 1 }.inject(&:*)\n end",
"def kaprekar?(k)\n=begin\n sqr = k**2\n digits = k.to_s.length\n right_n_digits = sqr.to_s[(0-digits)..-1].to_i\n left_digits = sqr.to_s[0..(1-digits)].to_i\n left_digits + right_n_digits == k\n=end\n n = Math.log10(k).to_i + 1\n value = k**2 \n k == value % (10**n) + value / (10**n) \nend",
"def calc(n, k)\n fac(n) / (fac(k) * fac(n - k)) * ((1.0/6.0)**k * (5.0/6.0)**(n-k)) * 100\n end",
"def d(n)\n divisors = (1...n).select{ |i| n % i == 0 }\n divisors.reduce(&:+)\nend",
"def count(n)\n sum = 1\n n.prime_division.each do |x|\n sum *= (x[1] + 1)\n end\n sum\n end",
"def nck_factorial(n, k)\n factorial(n) / (factorial(k) * factorial(n - k))\nend",
"def divbyanotb(a, b)\n (1..1000).each { |e| puts e if (e % a == 0) && !(e % b == 0) }\nend",
"def sum_of_cubes(a, b)\n (a..b).inject(0) { |acc, iter| acc + iter**3 }\nend",
"def subarray_sum(nums, k)\n\n hash = {0 => 1}\n sum = 0\n count = 0\n\n for num in nums\n sum += num\n count += hash[sum - k] if !hash[sum -k].nil?\n hash[sum] ||= 0\n hash[sum] += 1\n end\n count\nend",
"def kaprekar?(k)\n\tnumber_of_k=k.to_s.size\n\tk2=(k ** 2).to_s\n\tnum_right=k2[-number_of_k..-1]\n num_left=k2[0..(k2.size-num_right.to_s.size-1)].to_i\n\tk==num_right.to_i+num_left\nend",
"def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend",
"def check_subarray_sum(nums, k)\n map = {}\n map[0] = -1\n running_sum = 0\n nums.each_with_index do |num, index|\n running_sum += nums[index]\n \n if k != 0\n # why ?\n \n running_sum = running_sum % k\n \n end\n print map, '--'\n# print running_sum, '--'\n prev = map[running_sum]\n if prev != nil\n return true if index - prev > 1\n else\n map[running_sum] = index\n end\n end\n return false\nend",
"def factor_count(x)\n range = 2..Math.sqrt(x)\n count = range.count { |i| x % i == 0 }\n count * 2\nend",
"def find_kth_largest(nums, k)\n min, max = nums[0], nums[0]\n nums.each {|x| \n min = [min, x].min\n max = [max, x].max\n }\n while min <= max \n mid = (min + max) / 2\n count = 0;\n nums.each{|x| count += 1 if x >= mid}\n if count >= k\n min = mid + 1\n else\n max = mid - 1\n end\n end\n return max\nend",
"def smallest_range_i(a, k)\n result = a.max - a.min - 2 * k\n result >= 0 ? result : 0\nend",
"def count_by_x (num1, num2)\n array = (num1..num1 * num2).to_a\n\n array.select do |num|\n num % num1 == 0\n end\nend",
"def count_divisors(num)\n\n (1..num).count {|n| num % n == 0}\n\nend",
"def solution2(a)\n\n counts = Hash.new(0)\n\n a.each do |int|\n counts[int] += 1\n end\n\n non_divisors = []\n\n a.each do |int|\n div_count = 0\n for i in 1..int do\n div_count += counts[i] if int % i == 0\n end\n non_divisors << a.length - div_count\n end\n\n non_divisors\n\nend",
"def divisor_count_of(number)\n divisors = divisors_of(number)\n\n return divisors.length\n end",
"def calc_k(n, g)\n H(n, n, g)\n end",
"def simber_count(n)\n lower_range = 10**(n - 1)\n upper_range = (10**n) - 1\n count = 0\n (lower_range..upper_range).each do |i|\n count += 1 if simber_check(i)\n end\n count\nend",
"def multiples(number1, number2, range1, range2)\n (range1...range2).select { |value| value % number1 == 0 || value % number2 == 0 }.reduce(:+)\nend",
"def min_divisible_by_all(num)\r\n (1..num).inject(:lcm)\r\nend",
"def combin(k)\n return self.factorial / (k.factorial * (n - k).factorial)\n end",
"def f(n,d) # returns total number of times d shows up in range 0..n including n\n total = 0\n (n+1).times do |k|\n total += k.to_s.count(d.to_s)\n end\n return total\nend",
"def non_divisible_subset(set, divisor)\n # key to the solution is a trick with number theory: the sum of two numbers A, B is divisible by divisor\n # k if A % k + B % k == k. So, for each pair of remainders that add up to the divisor, grab the largest\n # set. For remainders that are exactly half the divisor, you can only grab one, same with numbers that\n # are already evenly divisible (remainder 0).\n remainders = set.map { |x| x % divisor }.group_by { |x| x }\n remainders.reduce(0) do |acc, (r, rs)|\n acc + if divisor / 2.0 == r || r == 0\n 1\n elsif remainders[divisor - r].nil? || rs.length > remainders[divisor - r].length\n rs.length\n else\n 0\n end\n end\nend",
"def kaprekar?(k)\n first = (k ** 2).to_s\n first.slice!(-k.to_s.length..-1).to_i + first.to_i == k\nend",
"def twelve\n iter = 1\n trinum_temp = 0\n begin\n factors = count_factors(trinum_temp = (trinum(iter)))\n iter = iter + 1\n\n end until factors > 200\n\n return trinum_temp\nend",
"def SumDivisibleBy(n, target = 999)\n p = target / n\n return n*(p*(p+1)) / 2\nend",
"def kaprekar?(k)\n return false if !k.is_a?(Integer) || k < 1\n\n n = k.to_s.length\n k_squared = (k**2).to_s\n\n first_part = k_squared.length.even? ? k_squared[0..(n - 1)] : k_squared[0..(n - 2)]\n second_part = k_squared[-n..-1]\n\n first_part.to_i + second_part.to_i == k\nend",
"def kaprekar_wrong?(k)\n k.to_i == (k.to_i**2).to_s.scan(/.{1,#{k.to_s.length}}/).map { |nstr| nstr.to_i }.inject(0) { |sum,n| sum+n }\nend",
"def getTotalX(a, b)\n (a[-1]..b[0]).to_a.reject do |cand|\n first_issue = a.detect { |elem| !(cand % elem).zero? }\n second_issue = first_issue ? false : b.detect { |elem| !(elem % cand).zero? }\n\n second_issue.nil? ? false : true\n end.count\nend",
"def electionsWinners(votes, k)\n m = votes.max\n m_count = 0\n winners = votes.select{|x|\n m_count += 1 if m == x\n x+k > m }.size\n if( 0 == winners)\n 1 == m_count ? 1 : 0\n else \n winners\n end\nend",
"def smallest_common_multiple(n)\n\n\treturn 0\nend",
"def smallestMultiple a, b, start = 1\n \n # use start = 2520 for finding the solution in range [1,20]\n\tstart.step((Float::MAX).to_i) do |n| \n\t\tflag = (a..b).inject(true) do |flag, elem|\n\t\t\tflag &= (n % elem == 0)\n\t\t\tbreak if !flag\n\t\t\tflag\n\t\tend\t\n\t\treturn n if flag\n\tend\n\treturn -1\nend",
"def num_prime_factors(num)\r\n # your code goes here\r\n prime_factors(num).length\r\n\r\nend"
] | [
"0.8443348",
"0.7185717",
"0.71461934",
"0.6996867",
"0.6847606",
"0.68330914",
"0.6804294",
"0.67908627",
"0.675941",
"0.6745905",
"0.666709",
"0.662192",
"0.6617464",
"0.65719575",
"0.646598",
"0.6459474",
"0.64392614",
"0.64329696",
"0.64152926",
"0.638801",
"0.6383595",
"0.6353415",
"0.63516694",
"0.63425624",
"0.63395584",
"0.6339219",
"0.6307709",
"0.63015586",
"0.6258942",
"0.62484914",
"0.623675",
"0.6234994",
"0.62335825",
"0.62249905",
"0.6215149",
"0.6189338",
"0.61853355",
"0.617269",
"0.61642945",
"0.6153123",
"0.6137714",
"0.6121688",
"0.6121677",
"0.6120011",
"0.61129034",
"0.60995996",
"0.6095598",
"0.60951525",
"0.6094163",
"0.60677606",
"0.60671043",
"0.6046666",
"0.6045569",
"0.60438573",
"0.60250354",
"0.6015534",
"0.60117185",
"0.6011164",
"0.6005381",
"0.59976405",
"0.5995398",
"0.5987655",
"0.59858835",
"0.598515",
"0.59850657",
"0.5983237",
"0.5975267",
"0.59714985",
"0.59633523",
"0.59602314",
"0.5953546",
"0.59447485",
"0.59407896",
"0.5933633",
"0.5929084",
"0.59247726",
"0.5914162",
"0.5913914",
"0.59126186",
"0.5895061",
"0.5894514",
"0.58878803",
"0.58670455",
"0.5866855",
"0.58574414",
"0.58551437",
"0.5852309",
"0.58470416",
"0.58411974",
"0.58404",
"0.5839541",
"0.5836041",
"0.58356553",
"0.5821717",
"0.58200395",
"0.58129454",
"0.58121467",
"0.58106464",
"0.5808534",
"0.5799293"
] | 0.7913576 | 1 |
diffs +path+ with another revision. if no revision is specified, the previous revision is used. | def diff( path, options={} )
raise Svn::Error, "cannot diff directory #{path}@#{to_s}" if dir? path
other = options[:with] if options[:with].is_a? Root
other = repo.revision(options[:with]) if options[:with].is_a? Numeric
other ||= repo.revision(to_i - 1)
return other.diff( path, :with => self ) if other < self
content = ""
begin
content = file_content_stream( path ).to_counted_string
rescue Svn::Error => err
raise if options[:raise_errors]
end
other_content = ""
begin
other_content= other.file_content_stream( path ).to_counted_string
rescue Svn::Error => err
raise if options[:raise_errors]
end
Diff.string_diff( content, other_content ).unified(
:original_header => "#{path}@#{to_s}",
:modified_header => "#{path}@#{other}"
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_path_history(old_path, revision)\n unless (history = history_for_revision(revision))\n create_path_history(old_path, revision)\n end\n end",
"def apply(revision)\n owner.with_revision(revision) do\n owner.force_path_changes_with_history(old_value, new_value)\n end\n end",
"def revisions(path, opts = {})\n optional_inputs = opts\n input_json = {\n path: path,\n path_revision: optional_inputs[:path_revision],\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/revisions\", input_json)\n Dropbox::API::RevisionHistory.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end",
"def delta(rev)\n $repo.diff(commit, rev).path(@name).patch\n end",
"def do_diff(base_path, path)\n if base_path.nil?\n # If there's no base path, then the file\n # must have been added\n puts(\"Added: #{path}\")\n name = path\n elsif path.nil?\n # If there's no new path, then the file\n # must have been deleted\n puts(\"Removed: #{base_path}\")\n name = base_path\n else\n # Otherwise, the file must have been modified\n puts \"Modified: #{path}\"\n name = path\n end\n\n # Set up labels for the two files\n base_label = \"#{name} (original)\"\n label = \"#{name} (new)\"\n\n # Output a unified diff between the two files\n puts \"=\" * 78\n differ = Svn::Fs::FileDiff.new(@base_root, base_path, @root, path)\n puts differ.unified(base_label, label)\n puts\n end",
"def apply(revision)\n owner.with_revision(revision) do\n owner.force_path_changes\n end\n end",
"def restore(path, rev)\n params = {\n 'rev' => rev.to_s\n }\n\n response = @session.do_post build_url(\"/restore/#{@root}#{format_path(path)}\", params)\n parse_response(response)\n end",
"def save_path_history(old_path, current_path, revision)\n update_path_history(old_path, revision) if should_save_path_history?(old_path, current_path)\n end",
"def revision_from_ref(repo_path, ref)\n begin\n show_ref(repo_path, ref)\n rescue GitError\n begin\n git('rev-parse', ref)\n ref\n rescue GitError\n raise InvalidGitRef, ref\n end\n end\n end",
"def restore(path, rev, opts = {})\n input_json = {\n path: path,\n rev: rev,\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/restore\", input_json)\n Dropbox::API::File.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end",
"def delete_entry(path, revision, parent_baton)\n # Print out diffs of deleted files, but not\n # deleted directories\n unless @base_root.dir?('/' + path)\n do_diff(path, nil)\n end\n end",
"def choose_revision(path, prompt = \"Choose a revision\", number_of_revisions = 1, options = {})\n path = git.make_local_path(path)\n # Validate file\n # puts command(\"status\", path)\n if /error: pathspec .+ did not match any file.+ known to git./.match(git.command(\"status\", path))\n TextMate::UI.alert(:warning, \"File “#{File.basename(path)}” is not in the repository.\", \"Please add the file to the repository before using this command.\")\n return nil\n end\n\n # # Get the server name \n # info = YAML::load(svn_cmd(\"info #{escaped_path}\"))\n # repository = info['Repository Root']\n # uri = URI::parse(repository)\n\n # the above will fail for users that run a localized system\n # instead we should do ‘svn info --xml’, though since the\n # code is not used, I just commented it. --Allan 2007-02-20\n\n # Display progress dialog\n # Show the log\n revision = 0\n log_data = nil\n \n TextMate::UI.dialog(:nib => ListNib,\n :center => true,\n :parameters => {'title' => prompt,'entries' => [], 'hideProgressIndicator' => false}) do |dialog|\n\n # Parse the log\n log_data = stringify(git.log(:path => path, :limit => 200))\n dialog.parameters = {'entries' => log_data, 'hideProgressIndicator' => true}\n\n dialog.wait_for_input do |params|\n revision = params['returnArgument']\n button_clicked = params['returnButton']\n\n if (button_clicked != nil) and (button_clicked == 'Cancel')\n false # exit\n else\n unless (number_of_revisions == :multiple) or (revision.length == number_of_revisions) then\n TextMate::UI.alert(:warning, \"Please select #{number_of_revisions} revision#{number_of_revisions == 1 ? '' : 's'}.\", \"So far, you have selected #{revision.length} revision#{revision.length == 1 ? '' : 's'}.\")\n true # continue\n else\n false # exit\n end\n end\n end\n end\n\n # Return the revision number or nil\n revision = nil if revision == 0\n if options[:sort] && revision\n time_revision_pairs = []\n selected_entries = log_data.select{ |l| revision.include?(l[\"rev\"]) }\n selected_entries.sort!{ |a,b| a[\"date\"] <=> b[\"date\"] } # sorts them descending (latest on the bottom)\n selected_entries.reverse! if options[:sort] == :asc\n revision = selected_entries.map{|se| se[\"rev\"]}\n end\n revision\n end",
"def set(path, value, rev=-1)\n invoke(Request.new(:path => path, :value => value, :rev => rev, :verb => Request::Verb::SET), false).rev\n end",
"def diff(from, to)\n @repo.diff(from, to).path(path)\n end",
"def diff(v1, v2)\n repos.git.diff(v1, v2, path)\n end",
"def checkout(repo_path, rev)\n Dir.chdir repo_path do\n hg('update','--clean', '--rev', rev)\n end\n end",
"def get_revision(rev = 'HEAD')\n unless @resource.value(:source)\n status = at_path { git_with_identity('status') }\n is_it_new = status =~ %r{Initial commit|No commits yet}\n if is_it_new\n status =~ %r{On branch (.*)}\n branch = Regexp.last_match(1)\n return branch\n end\n end\n current = at_path { git_with_identity('rev-parse', rev).strip }\n if @resource.value(:revision) == current\n # if already pointed at desired revision, it must be a SHA, so just return it\n return current\n end\n if @resource.value(:source)\n update_references\n end\n if @resource.value(:revision)\n canonical = if tag_revision?\n # git-rev-parse will give you the hash of the tag object itself rather\n # than the commit it points to by default. Using tag^0 will return the\n # actual commit.\n at_path { git_with_identity('rev-parse', \"#{@resource.value(:revision)}^0\").strip }\n elsif local_branch_revision?\n at_path { git_with_identity('rev-parse', @resource.value(:revision)).strip }\n elsif remote_branch_revision?\n at_path { git_with_identity('rev-parse', \"#{@resource.value(:remote)}/#{@resource.value(:revision)}\").strip }\n else\n # look for a sha (could match invalid shas)\n at_path { git_with_identity('rev-parse', '--revs-only', @resource.value(:revision)).strip }\n end\n raise(\"#{@resource.value(:revision)} is not a local or remote ref\") if canonical.nil? || canonical.empty?\n current = @resource.value(:revision) if current == canonical\n end\n current\n end",
"def delete(path, rev=-1)\n invoke(Request.new(:path => path, :rev => rev, :verb => Request::Verb::DEL))\n nil\n end",
"def diff_committed(local_path, revision = nil)\n remote_files = {}\n if revision\n command = \"git diff --name-status #{revision} -- #{local_path}\"\n changed_files(command)\n else\n remote_files = {}\n `git ls-files`.split(\"\\n\").each {|file| remote_files[file] = 'M'}\n remote_files\n end\n end",
"def revision(host, scm, target, ref)\n args = []\n case scm\n when 'hg'\n args.push('update', 'clean', '-r', ref)\n when 'git'\n args.push('reset', '--hard', ref)\n else\n fail \"Unfortunately #{scm} is not supported yet\"\n end\n on host, \"cd #{target} && #{scm} #{args.flatten.join ' '}\"\nend",
"def diff(opts)\n from, to = opts[:from], opts[:to]\n if from && !(Commit === from)\n raise ArgumentError, \"Invalid sha: #{from}\" if from !~ SHA_PATTERN\n from = Reference.new(:repository => self, :id => from)\n end\n if !(Commit === to)\n raise ArgumentError, \"Invalid sha: #{to}\" if to !~ SHA_PATTERN\n to = Reference.new(:repository => self, :id => to)\n end\n Diff.new(from, to, git_diff_tree('--root', '--full-index', '-u',\n opts[:detect_renames] ? '-M' : nil,\n opts[:detect_copies] ? '-C' : nil,\n from ? from.id : nil, to.id, '--', *opts[:path]))\n end",
"def same?(previous_revision, active_revision, paths=nil)\n run_and_success?(\"#{git} diff '#{previous_revision}'..'#{active_revision}' --exit-code --name-only -- #{Array(paths).join(' ')} >/dev/null 2>&1\")\n end",
"def get_revision_by_timestamp(at_or_earlier_than, path = nil, later_than = nil)\n raise NotImplementedError\n end",
"def revert_page(page, sha1, sha2 = nil, commit = {})\n return false unless page\n left, right, options = parse_revert_options(sha1, sha2, commit)\n commit_and_update_paths(@repo.git.revert_path(page.path, left, right), [page.path], options)\n end",
"def diff(from, to)\n @repository.diff(from, to, path)\n end",
"def diff(actor, from=nil, to=nil)\n from ||= current_revision(actor)\n to ||= \"HEAD\"\n `#{svn} diff #{authorization} #{rep_path}@#{from} #{path}@#{to}`\n end",
"def version_path(path)\n version_path = []\n (path.length - 1).times.each do |i|\n version_path << correct_version(path[0, i + 2], @version_added)\n end\n version_path\n end",
"def same?(previous_revision, active_revision, paths = nil)\n run(\"#{git} diff '#{previous_revision}'..'#{active_revision}' --exit-code --name-only -- #{Array(paths).join(' ')} >/dev/null 2>&1\")\n end",
"def changed_paths_check(revision,repo)\n `svnlook changed -r #{revision} #{repo}`.split(\"\\n\")\n end",
"def diff(other_sha1)\n git \"diff #{other_sha1} -- #{@path}\"\n end",
"def revert(files=nil, opts={})\n # get the parents - used in checking if we haven an uncommitted merge\n parent, p2 = dirstate.parents\n \n # get the revision\n rev = opts[:revision] || opts[:rev] || opts[:to]\n \n # check to make sure it's logically possible\n unless rev || p2 == Amp::Mercurial::RevlogSupport::Node::NULL_ID\n raise abort(\"uncommitted merge - please provide a specific revision\")\n end\n \n # if we have anything here, then create a matcher\n matcher = if files\n Amp::Match.create :files => files ,\n :includer => opts[:include],\n :excluder => opts[:exclude]\n else\n # else just return nil\n # we can return nil because when it gets used in :match => matcher,\n # it will be as though it's not even there\n nil\n end\n \n # the changeset we use as a guide\n changeset = self[rev]\n \n # get the files that need to be changed\n stats = status :node_1 => rev, :match => matcher\n \n ###\n # now make the changes\n ###\n \n ##########\n # MODIFIED and DELETED\n ##########\n # Just write the old data to the files\n (stats[:modified] + stats[:deleted]).each do |path|\n File.open path, 'w' do |file|\n file.write changeset.get_file(path).data\n end\n UI::status \"restored\\t#{path}\"\n end\n \n ##########\n # REMOVED\n ##########\n # these files are set to be removed, and have thus far been dropped from the filesystem\n # we restore them and we alert the repo\n stats[:removed].each do |path|\n File.open path, 'w' do |file|\n file.write changeset.get_file(path).data\n end\n \n staging_area.normal path # pretend nothing happened\n UI::status \"saved\\t#{path}\"\n end\n \n ##########\n # ADDED\n ##########\n # these files have been added SINCE +rev+\n stats[:added].each do |path|\n remove path\n UI::status \"destroyed\\t#{path}\"\n end # pretend these files were never even there\n \n staging_area.save\n true # success marker\n end",
"def file_revert(file, ref)\n if file_revisions(file).map { |r| r[:commit] }.include? ref\n file = file.gsub(%r{^/}, '')\n full_path = File.expand_path(file, @root)\n content = File.read(file_revision_at(file, ref))\n File.open(full_path, 'w') { |f| f.puts content }\n end\n end",
"def revision(revision)\n revision = 'HEAD' if revision =~ /head/i\n \"`#{git_cmd} rev-parse #{revision}`\"\n end",
"def revert_commit(sha1, sha2 = nil, commit = {})\n left, right, options = parse_revert_options(sha1, sha2, commit)\n tree, files = repo.git.revert_commit(left, right)\n commit_and_update_paths(tree, files, options)\n end",
"def get(path, rev = nil)\n invoke(Request.new(:path => path, :rev => rev, :verb => Request::Verb::GET))\n end",
"def revisions(path, rev_limit=1000)\n\n params = {\n 'rev_limit' => rev_limit.to_s\n }\n\n response = @session.do_get build_url(\"/revisions/#{@root}#{format_path(path)}\", params)\n parse_response(response)\n\n end",
"def revert(path)\n cleanup(path)\n new_client.revert(path)\n rescue\n false\n else\n true\n end",
"def watch(path, rev=current_revision)\n loop do\n result = wait(path, rev, -1)\n yield result\n rev = result.rev + 1\n end\n end",
"def update!(**args)\n @path = args[:path] if args.key?(:path)\n end",
"def update!(**args)\n @path = args[:path] if args.key?(:path)\n end",
"def update!(**args)\n @path = args[:path] if args.key?(:path)\n end",
"def update!(**args)\n @path = args[:path] if args.key?(:path)\n end",
"def revision(version)\n if version == :previous || audits.last.version >= version\n revision_with Audited.audit_class.reconstruct_attributes(audits_to(version))\n end\n end",
"def test_revision_with_repository_pointing_to_a_subdirectory\n r = Project.find(1).repository\n # Changes repository url to a subdirectory\n r.update_attribute :url, (r.url + '/test/some')\n\n get :revision, :id => 1, :rev => 2\n assert_response :success\n assert_template 'revision'\n\n assert_select 'ul' do\n assert_select 'li' do\n # link to the entry at rev 2\n assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo', :text => 'repo'\n # link to partial diff\n assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo'\n end\n end\n end",
"def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &block)\r\n logger.debug \"<cvs> revisions path:'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}\"\r\n \r\n path_with_project=\"#{url}#{with_leading_slash(path)}\"\r\n cmd = \"#{CVS_BIN} -d #{root_url} rlog\"\r\n cmd << \" -d\\\">#{time_to_cvstime(identifier_from)}\\\"\" if identifier_from\r\n cmd << \" #{shell_quote path_with_project}\"\r\n shellout(cmd) do |io|\r\n state=\"entry_start\"\r\n \r\n commit_log=String.new\r\n revision=nil\r\n date=nil\r\n author=nil\r\n entry_path=nil\r\n entry_name=nil\r\n file_state=nil\r\n branch_map=nil\r\n \r\n io.each_line() do |line| \r\n \r\n if state!=\"revision\" && /^#{ENDLOG}/ =~ line\r\n commit_log=String.new\r\n revision=nil\r\n state=\"entry_start\"\r\n end\r\n \r\n if state==\"entry_start\"\r\n branch_map=Hash.new\r\n if /^RCS file: #{Regexp.escape(root_url_path)}\\/#{Regexp.escape(path_with_project)}(.+),v$/ =~ line\r\n entry_path = normalize_cvs_path($1)\r\n entry_name = normalize_path(File.basename($1))\r\n logger.debug(\"Path #{entry_path} <=> Name #{entry_name}\")\r\n elsif /^head: (.+)$/ =~ line\r\n entry_headRev = $1 #unless entry.nil?\r\n elsif /^symbolic names:/ =~ line\r\n state=\"symbolic\" #unless entry.nil?\r\n elsif /^#{STARTLOG}/ =~ line\r\n commit_log=String.new\r\n state=\"revision\"\r\n end \r\n next\r\n elsif state==\"symbolic\"\r\n if /^(.*):\\s(.*)/ =~ (line.strip) \r\n branch_map[$1]=$2\r\n else\r\n state=\"tags\"\r\n next\r\n end \r\n elsif state==\"tags\"\r\n if /^#{STARTLOG}/ =~ line\r\n commit_log = \"\"\r\n state=\"revision\"\r\n elsif /^#{ENDLOG}/ =~ line\r\n state=\"head\"\r\n end\r\n next\r\n elsif state==\"revision\"\r\n if /^#{ENDLOG}/ =~ line || /^#{STARTLOG}/ =~ line \r\n if revision\r\n \r\n revHelper=CvsRevisionHelper.new(revision)\r\n revBranch=\"HEAD\"\r\n \r\n branch_map.each() do |branch_name,branch_point|\r\n if revHelper.is_in_branch_with_symbol(branch_point)\r\n revBranch=branch_name\r\n end\r\n end\r\n \r\n logger.debug(\"********** YIELD Revision #{revision}::#{revBranch}\")\r\n \r\n yield Revision.new({ \r\n :time => date,\r\n :author => author,\r\n :message=>commit_log.chomp,\r\n :paths => [{\r\n :revision => revision,\r\n :branch=> revBranch,\r\n :path=>entry_path,\r\n :name=>entry_name,\r\n :kind=>'file',\r\n :action=>file_state\r\n }]\r\n }) \r\n end\r\n \r\n commit_log=String.new\r\n revision=nil\r\n \r\n if /^#{ENDLOG}/ =~ line\r\n state=\"entry_start\"\r\n end\r\n next\r\n end\r\n \r\n if /^branches: (.+)$/ =~ line\r\n #TODO: version.branch = $1\r\n elsif /^revision (\\d+(?:\\.\\d+)+).*$/ =~ line\r\n revision = $1 \r\n elsif /^date:\\s+(\\d+.\\d+.\\d+\\s+\\d+:\\d+:\\d+)/ =~ line\r\n date = Time.parse($1)\r\n author = /author: ([^;]+)/.match(line)[1]\r\n file_state = /state: ([^;]+)/.match(line)[1]\r\n #TODO: linechanges only available in CVS.... maybe a feature our SVN implementation. i'm sure, they are\r\n # useful for stats or something else\r\n # linechanges =/lines: \\+(\\d+) -(\\d+)/.match(line)\r\n # unless linechanges.nil?\r\n # version.line_plus = linechanges[1]\r\n # version.line_minus = linechanges[2]\r\n # else\r\n # version.line_plus = 0\r\n # version.line_minus = 0 \r\n # end \r\n else \r\n commit_log << line unless line =~ /^\\*\\*\\* empty log message \\*\\*\\*/\r\n end \r\n end \r\n end\r\n end\r\n end",
"def set_other_revision\n @other_revision = params[:revision] ? find_revision(params[:revision]) : @revisions.first\n end",
"def update!(**args)\n @new_path = args[:new_path] if args.key?(:new_path)\n @path = args[:path] if args.key?(:path)\n end",
"def update!(**args)\n @new_path = args[:new_path] if args.key?(:new_path)\n @path = args[:path] if args.key?(:path)\n end",
"def revision(version)\n revision_with audit_changes(version)\n end",
"def test_revision\n get :revision, :id => 1, :rev => 2\n assert_response :success\n assert_template 'revision'\n\n assert_select 'ul' do\n assert_select 'li' do\n # link to the entry at rev 2\n assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo', :text => 'repo'\n # link to partial diff\n assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo'\n end\n end\n end",
"def revision(revision)\n \"`#{p4_cmd} changes -s submitted -m 1 ...#{rev_no(revision)} | cut -f 2 -d\\\\ `\"\n end",
"def svn_update_with_error_tolerant(path, revision)\n msg = ''\n command = \"svn update -r#{revision} --ignore-externals '#{path}' 2>&1\"\n log \"command #{command}\"\n 3.downto(1) do\n msg = `#{command}`\n log \"result: #{msg}\"\n return if $? == 0\n sleep(5*60)\n `svn cleanup '#{path}'`\n end\n fail(msg)\n end",
"def patch(path, **args); end",
"def latest_version_of(path)\n @latest_version_of_cache ||= {}\n @latest_version_of_cache[path] ||= begin\n if relative_url_versioned?(path)\n if has_current_version_for?(path)\n non_versioned_path(path)\n else\n latest_version = list_versions_for(path).first\n path_for_version(latest_version, path)\n end\n else\n path\n end\n end\n end",
"def revision\n return @changeset.revision if @changeset\n file_log[@file_rev].link_rev\n end",
"def add_revision(path, ctype, msg)\n # FIXME: implement\n raise('not implemented')\n notify(EVENT_REV, path, ctype, msg)\n end",
"def checkout(revision)\n str = content revision\n\n # write str to current directory\n File.open(@fname, \"w\") do |f|\n f.write str\n end\n end",
"def path_diff(path1, path2)\n File.join(path1.split(\"/\") - path2.split(\"/\"))\n end",
"def revision\n return changeset.rev if @changeset || @change_id\n link_rev\n end",
"def scan_for_path(path, revision=nil)\n revision ||= 'tip'\n path = path.without_trailing_slash\n if path == '/' || path == ''\n search_for = \".*\"\n else\n path_re = Regexp.escape(path)\n search_for = \"#{ path_re }$|#{ path_re }\\/.*\"\n end\n contents(revision).scan(/^(\\w{40}) (\\d{3}) (\\*?) +(#{ search_for })/)\n end",
"def revision=(v)\r\n @revision = v\r\n end",
"def read(path, rev=nil)\n if rev.nil?\n file = pathname(path)\n return file.read\n else\n git :show, %(#{rev}:\"./#{path.shellescape}\")\n end\n rescue\n raise FileNotFound, \"no such file in repo - #{path}\"\n end",
"def revision\n # HEAD is the default, but lets just be explicit here.\n get_revision('HEAD')\n end",
"def revision(revision)\n raise NotImplementedError\n end",
"def load_rev file_path\n if File.exists? file_path\n File.open(file_path) do |file|\n line = file.readlines.select { |l| l =~ /^replRev/ }.last\n rev = line ? line.split('=')[1] : nil\n rev.chomp.to_i if rev\n end\n end || 0\n end",
"def revert(commitish = nil, opts = {})\n self.lib.revert(commitish, opts)\n end",
"def revision_file\n @root.join('REVISION')\n end",
"def set_revision\n @revision = find_revision(params[:id])\n end",
"def diff_init(diff, path)\n Smash.new.tap do |di|\n if diff.size > 1\n updated = diff.find_all { |x| x.first == \"+\" }\n original = diff.find_all { |x| x.first == \"-\" }\n di[:original] = Array(original).map(&:last).join(\", \")\n di[:updated] = Array(updated).map(&:last).join(\", \")\n else\n diff_data = diff.first\n di[:path] = path\n if diff_data.size == 3\n di[diff_data.first == \"+\" ? :updated : :original] = diff_data.last\n else\n di[:original] = diff_data[diff_data.size - 2].to_s\n di[:updated] = diff_data.last.to_s\n end\n end\n end\n end",
"def commit_diff(project, sha)\n get(\"/projects/#{project}/repository/commits/#{sha}/diff\") \n end",
"def update_with_revision\n store_revision do\n update_without_revision\n end\n end",
"def do_revision\n @record = find_if_allowed(params[:id], :read)\n @current_revision_number = @record.current_revision_number\n @revision_number ||= @current_revision_number\n @rev_record_1 = @record.restore_revision(@revision_number) if @revision_number\n @rev_record_2 = @record.restore_revision(@revision_number - 1) if @revision_number > 1\n end",
"def query_revision(revision)\n revision\n end",
"def test_changed\n dir = \"changed_dir\"\n dir1 = \"changed_dir1\"\n dir2 = \"changed_dir2\"\n dir_path = File.join(@wc_path, dir)\n dir1_path = File.join(@wc_path, dir1)\n dir2_path = File.join(@wc_path, dir2)\n dir_svn_path = dir\n dir1_svn_path = dir1\n dir2_svn_path = dir2\n\n file1 = \"changed1.txt\"\n file2 = \"changed2.txt\"\n file3 = \"changed3.txt\"\n file4 = \"changed4.txt\"\n file5 = \"changed5.txt\"\n file1_path = File.join(@wc_path, file1)\n file2_path = File.join(dir_path, file2)\n file3_path = File.join(@wc_path, file3)\n file4_path = File.join(dir_path, file4)\n file5_path = File.join(@wc_path, file5)\n file1_svn_path = file1\n file2_svn_path = [dir_svn_path, file2].join(\"/\")\n file3_svn_path = file3\n file4_svn_path = [dir_svn_path, file4].join(\"/\")\n file5_svn_path = file5\n\n first_rev = nil\n\n log = \"added 3 dirs\\nanded 5 files\"\n make_context(log) do |ctx|\n\n ctx.mkdir([dir_path, dir1_path, dir2_path])\n\n FileUtils.touch(file1_path)\n FileUtils.touch(file2_path)\n FileUtils.touch(file3_path)\n FileUtils.touch(file4_path)\n FileUtils.touch(file5_path)\n ctx.add(file1_path)\n ctx.add(file2_path)\n ctx.add(file3_path)\n ctx.add(file4_path)\n ctx.add(file5_path)\n\n commit_info = ctx.commit(@wc_path)\n first_rev = commit_info.revision\n\n editor = traverse(Svn::Delta::ChangedEditor, commit_info.revision, true)\n assert_equal([\n file1_svn_path, file2_svn_path,\n file3_svn_path, file4_svn_path,\n file5_svn_path,\n ].sort,\n editor.added_files)\n assert_equal([], editor.updated_files)\n assert_equal([], editor.deleted_files)\n assert_equal([].sort, editor.updated_dirs)\n assert_equal([].sort, editor.deleted_dirs)\n assert_equal([\n \"#{dir_svn_path}/\",\n \"#{dir1_svn_path}/\",\n \"#{dir2_svn_path}/\"\n ].sort,\n editor.added_dirs)\n end\n\n log = \"deleted 2 dirs\\nchanged 3 files\\ndeleted 2 files\\nadded 3 files\"\n make_context(log) do |ctx|\n\n dir3 = \"changed_dir3\"\n dir4 = \"changed_dir4\"\n dir3_path = File.join(dir_path, dir3)\n dir4_path = File.join(@wc_path, dir4)\n dir3_svn_path = [dir_svn_path, dir3].join(\"/\")\n dir4_svn_path = dir4\n\n file6 = \"changed6.txt\"\n file7 = \"changed7.txt\"\n file8 = \"changed8.txt\"\n file9 = \"changed9.txt\"\n file10 = \"changed10.txt\"\n file6_path = File.join(dir_path, file6)\n file7_path = File.join(@wc_path, file7)\n file8_path = File.join(dir_path, file8)\n file9_path = File.join(dir_path, file9)\n file10_path = File.join(dir_path, file10)\n file6_svn_path = [dir_svn_path, file6].join(\"/\")\n file7_svn_path = file7\n file8_svn_path = [dir_svn_path, file8].join(\"/\")\n file9_svn_path = [dir_svn_path, file9].join(\"/\")\n file10_svn_path = [dir_svn_path, file10].join(\"/\")\n\n File.open(file1_path, \"w\") {|f| f.puts \"changed\"}\n File.open(file2_path, \"w\") {|f| f.puts \"changed\"}\n File.open(file3_path, \"w\") {|f| f.puts \"changed\"}\n ctx.rm_f([file4_path, file5_path])\n FileUtils.touch(file6_path)\n FileUtils.touch(file7_path)\n FileUtils.touch(file8_path)\n ctx.add(file6_path)\n ctx.add(file7_path)\n ctx.add(file8_path)\n ctx.cp(file1_path, file9_path)\n ctx.cp(file2_path, file10_path)\n ctx.mv(dir2_path, dir3_path)\n ctx.cp(dir1_path, dir4_path)\n ctx.rm(dir1_path)\n\n commit_info = ctx.commit(@wc_path)\n second_rev = commit_info.revision\n\n editor = traverse(Svn::Delta::ChangedEditor, commit_info.revision, true)\n assert_equal([file1_svn_path, file2_svn_path, file3_svn_path].sort,\n editor.updated_files)\n assert_equal([file4_svn_path, file5_svn_path].sort,\n editor.deleted_files)\n assert_equal([file6_svn_path, file7_svn_path, file8_svn_path].sort,\n editor.added_files)\n assert_equal([].sort, editor.updated_dirs)\n assert_equal([\n [file9_svn_path, file1_svn_path, first_rev],\n [file10_svn_path, file2_svn_path, first_rev],\n ].sort_by{|x| x[0]},\n editor.copied_files)\n assert_equal([\n [\"#{dir3_svn_path}/\", \"#{dir2_svn_path}/\", first_rev],\n [\"#{dir4_svn_path}/\", \"#{dir1_svn_path}/\", first_rev],\n ].sort_by{|x| x[0]},\n editor.copied_dirs)\n assert_equal([\"#{dir1_svn_path}/\", \"#{dir2_svn_path}/\"].sort,\n editor.deleted_dirs)\n assert_equal([].sort, editor.added_dirs)\n end\n end",
"def move_to( revision )\n\t\treturn self.repo.bookmark( self.name, rev: revision, force: true )\n\tend",
"def update!(**args)\n @path = args[:path] if args.key?(:path)\n @state = args[:state] if args.key?(:state)\n end",
"def versioned_path(args)\n return args.first if args == ['/']\n path = args.flatten.join(\"/\")\n end",
"def fetch_revision\n end",
"def controRev(file)\n pathname = Pathname.new(file)\n ext = pathname.extname\n if (pathname.sub(\"#{ext}\",\"_rev2#{ext}\")).exist?\n return (pathname.sub(\"#{ext}\",\"_rev2#{ext}\"))\n elsif (pathname.sub(\"#{ext}\",\"_rev1#{ext}\")).exist?\n return (pathname.sub(\"#{ext}\",\"_rev1#{ext}\"))\n elsif pathname.exist?\n return pathname\n else\n return false\n end\n end",
"def post_revert(filename,commit_id,repo)\n curl_put(\"#{self.host}/api2/repos/#{repo}/file/revert\",{\"commit_id\" => commit_id,\"p\" => filename }).body_str\n end",
"def find(revision, options = {})\n get_path(\n path_to_find(revision),\n options,\n Tinybucket::Parser::CommitParser\n )\n end",
"def get_file(path)\n file = path[1..-1]\n case path\n when '/CURRENT_REVISION'\n change['revisions'][change['current_revision']]['_number']\n when '/COMMIT_MSG'\n commit_file(change['current_revision'])\n when '/.0_COMMIT_MSG'\n ''\n when /\\.(\\d+)_COMMIT_MSG/\n commit_file(Regexp.last_match(1)) # TODO: handle commit like a normal file (with comments for instance)\n when /\\.(\\d+)_(.*)$/\n revision = Regexp.last_match(1).to_i\n filename = file_from_sanitized(Regexp.last_match(2))\n content = get_ab_file(Regexp.last_match(2), revision)\n FileWithComments.new(Regexp.last_match(2),\n content,\n comments(filename, revision),\n comments(filename, revision, draft: true))\n else\n \"Nothing in there, see .xx_#{file} with xx the patchset version\\n\"\n end\n end",
"def fetch_revision(commit)\n `git rev-parse #{commit}`.tr(\"\\n\", '')\n end",
"def update_from_svn(node)\n attribute_set(self.class.config.body_property, node.body) if node.body\n self.path = node.short_path\n \n node.properties.each do | attr, value |\n if self.respond_to?(\"#{attr}=\")\n self.__send__(\"#{attr}=\", value)\n end\n end\n \n if !valid?\n puts \"Invalid #{node.short_path} at revision #{node.revision}\"\n puts \" - \" + errors.full_messages.join(\".\\n - \")\n end\n \n save\n end",
"def update\n @path = Path.find(params[:id])\n\n respond_to do |format|\n if @path.update_attributes(params[:path])\n format.html { redirect_to([@layer, @path], :notice => 'Path was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @path.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @subpath = args[:subpath] if args.key?(:subpath)\n end",
"def versioned_path(options = {})\n case options[:using]\n when :path\n File.join('/', options[:prefix] || '', options[:version], options[:path])\n when :header\n File.join('/', options[:prefix] || '', options[:path])\n else\n raise ArgumentError.new(\"unknown versioning strategy: #{options[:using]}\")\n end\nend",
"def set_revision\n @revision = Revision.find(params[:id])\n end",
"def parseRevision()\r\n pieces=@complete_rev.split(\".\")\r\n @revision=pieces.last.to_i\r\n baseSize=1\r\n baseSize+=(pieces.size/2)\r\n @base=pieces[0..-baseSize].join(\".\")\r\n if baseSize > 2\r\n @branchid=pieces[-2]\r\n end \r\n end",
"def file_rev\n @file_rev ||= file_log.rev(file_node)\n end",
"def revision(version)\n revision_with Audited.audit_class.reconstruct_attributes(audits_to(version))\n end",
"def get_last_changed_revision(repo, fname)\n case repository_type\n when 'git'\n %x[git log -n 1 -- \"#{fname}\"].split(\"\\n\").first[7..-1]\n when 'git-svn', 'svn'\n begin\n svn_info = %x[svn info -r head \"#{repo}/#{fname}\"]\n rescue\n puts 'we have an error in the svn info line'\n end\n begin\n svn_info.match('Last Changed Rev: ([0-9]*)').to_a[1]\n rescue\n puts 'We have an error in getting the revision'\n end\n end\nend",
"def revert_to(version_hash)\n tree = self.git.tree(version_hash)\n dir = tree.contents[0] # posts/\n data = dir.contents[0] # 6/\n data.contents.each do |f| # title.txt\n field = f.name.gsub(\".txt\",\"\")\n send(\"#{field.to_sym}=\", f.data)\n end\n save # hm, not sure if I want to do this\n end",
"def get_revision_number_by_timestamp(wanted_timestamp, path = nil)\n if @timestamps_revisions.empty?\n raise 'No revisions, so no timestamps.'\n end\n\n all_timestamps_list = []\n remaining_timestamps_list = []\n @timestamps_revisions.each_key do |time_dump|\n all_timestamps_list.push(Marshal.load(time_dump)) # rubocop:disable Security/MarshalLoad\n remaining_timestamps_list.push(Marshal.load(time_dump)) # rubocop:disable Security/MarshalLoad\n end\n\n # find closest matching timestamp\n mapping = {}\n first_timestamp_found = false\n old_diff = 0\n # find first valid revision\n all_timestamps_list.each do |best_match|\n remaining_timestamps_list.shift\n old_diff = wanted_timestamp - best_match\n mapping[old_diff.to_s] = best_match\n if path.nil? || (!path.nil? && @timestamps_revisions[Marshal.dump(best_match)].revision_at_path(path))\n first_timestamp_found = true\n break\n end\n end\n\n # find all other valid revision\n remaining_timestamps_list.each do |curr_timestamp|\n new_diff = wanted_timestamp - curr_timestamp\n mapping[new_diff.to_s] = curr_timestamp\n if path.nil? || (!path.nil? && @timestamps_revisions[Marshal.dump(curr_timestamp)].revision_at_path(path))\n if (old_diff <= 0 && new_diff <= 0) ||\n (old_diff <= 0 && new_diff > 0) ||\n (new_diff <= 0 && old_diff > 0)\n old_diff = [old_diff, new_diff].max\n else\n old_diff = [old_diff, new_diff].min\n end\n end\n end\n\n if first_timestamp_found\n wanted_timestamp = mapping[old_diff.to_s]\n @timestamps_revisions[Marshal.dump(wanted_timestamp)]\n else\n @current_revision\n end\n end",
"def braid_diff(app, path)\n if File.exist?(path)\n puts \"Braid Diff #{path} in #{app}\"\n bundle_exec(\"braid diff #{path}\")\n end\n end",
"def revision\n raise NotImplementedError.new(\"revision() must be implemented by subclasses of AbstractVersionedFile.\")\n end",
"def derivative_path(path)\n path = Array(path).map { |key| key.is_a?(String) ? key.to_sym : key }\n path = path.first if path.one?\n path\n end",
"def query_revision(revision)\n fast_remote_double_cache_remote_repository = variable(:fast_remote_double_cache_remote_repository)\n raise ArgumentError, \"Deploying remote branches is no longer supported. Specify the remote branch as a local branch for the git repository you're deploying from (ie: '#{revision.gsub('origin/', '')}' rather than '#{revision}').\" if revision =~ /^origin\\//\n return revision if revision =~ /^[0-9a-f]{40}$/\n command = scm('ls-remote', fast_remote_double_cache_remote_repository, revision)\n result = yield(command)\n revdata = result.split(/[\\t\\n]/)\n newrev = nil\n revdata.each_slice(2) do |refs|\n rev, ref = *refs\n if ref.sub(/refs\\/.*?\\//, '').strip == revision.to_s\n newrev = rev\n break\n end\n end\n raise \"Unable to resolve revision for '#{revision}' on repository '#{fast_remote_double_cache_remote_repository}'.\" unless newrev =~ /^[0-9a-f]{40}$/\n return newrev\n end",
"def get_svn_rev( dir='.' )\n\tinfo = get_svn_info( dir )\n\treturn info['Revision']\nend",
"def current_revision\n invoke(Request.new(:verb => Request::Verb::REV)).rev\n end"
] | [
"0.65200967",
"0.6305841",
"0.6121806",
"0.61095357",
"0.5987845",
"0.5865554",
"0.57444376",
"0.57370746",
"0.5523071",
"0.5497513",
"0.5457696",
"0.5422875",
"0.5416916",
"0.53977805",
"0.53865194",
"0.53601223",
"0.53591263",
"0.53428656",
"0.5292478",
"0.52867603",
"0.528364",
"0.5283294",
"0.52819",
"0.5278944",
"0.52609336",
"0.52476376",
"0.5241768",
"0.52395",
"0.5222939",
"0.5222194",
"0.5210813",
"0.51893985",
"0.51770633",
"0.5174109",
"0.5152785",
"0.51326287",
"0.51162636",
"0.51127315",
"0.5110409",
"0.5110409",
"0.5110409",
"0.5110409",
"0.5075534",
"0.50713396",
"0.50667834",
"0.50489277",
"0.50346327",
"0.50346327",
"0.50261134",
"0.50254077",
"0.50242007",
"0.50005615",
"0.4981498",
"0.49706832",
"0.49660468",
"0.4958008",
"0.4955576",
"0.49457383",
"0.4942507",
"0.49273798",
"0.49209127",
"0.49173942",
"0.4917006",
"0.49150214",
"0.48899186",
"0.48807573",
"0.48778927",
"0.4861901",
"0.48367518",
"0.48011747",
"0.47998548",
"0.4797395",
"0.47941053",
"0.4758745",
"0.47514787",
"0.47506022",
"0.47502965",
"0.47430983",
"0.4737474",
"0.472715",
"0.47256345",
"0.4722755",
"0.47192988",
"0.47119424",
"0.47073558",
"0.46977356",
"0.46918228",
"0.46910194",
"0.46908525",
"0.46823573",
"0.4677381",
"0.4668817",
"0.46683812",
"0.46584514",
"0.46360213",
"0.4624821",
"0.46239328",
"0.46239135",
"0.4619469",
"0.46146563"
] | 0.6063937 | 4 |
PLGrid with certificate (standard) | def login_openid_plgrid_url
url_for :action => 'login_openid_plgrid', :only_path => false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def certificate; end",
"def certificate; end",
"def cert; end",
"def cert; end",
"def cert; end",
"def cert_content; end",
"def register_with_pkyp\n send_to_pkyp(@cert.to_s)\n end",
"def cert_pem; end",
"def cert_store; end",
"def cert_store; end",
"def handle_auth data\n CERTIFICATE.to_pem\n end",
"def login_openid_plgrid\n begin\n oidreq = consumer.begin(PLGRID_OID_URI)\n rescue OpenID::OpenIDError => e\n flash[:error] = t('openid.provider_discovery_failed', provider_url: PLGRID_OID_URI,\n error: e.to_s)\n redirect_to login_path\n return\n end\n\n req_user_cert = (params[:no_cert] != 'true' and params[:no_cert] != true)\n\n # -- Attribute Exchange support --\n req_attributes = [:dn, :POSTresponse]\n req_attributes = req_attributes.concat([:user_cert, :proxy, :proxy_priv_key]) if req_user_cert\n OpenIDUtils.request_ax_attributes(oidreq, req_attributes)\n\n callback = req_user_cert ? :openid_callback_plgrid_url : :openid_callback_plgrid_no_cert_url\n\n return_to = send(callback, ((params[:generate_temp_pass] ? SecureRandom.hex(4) : nil)))\n\n # remove following \"/\" from url (to match PL-Grid OpenID realm)\n realm = root_url.match(/(.*)\\//)[1]\n\n if oidreq.send_redirect?(realm, return_to)\n redirect_to oidreq.redirect_url(realm, return_to)\n else\n render :text => oidreq.html_markup(realm, return_to, false, {'id' => 'openid_form'})\n end\n end",
"def make_certificates\n # @contest is fetched by CanCan\n\n # Define params for PDF output\n prawnto filename: \"urkunden#{random_number}\", prawn: { page_size: 'A4', skip_page_creation: true }\n @performances = apply_scopes(Performance)\n .joins(:contest_category)\n .where(\"contest_categories.contest_id = ?\", @contest.id)\n .accessible_by(current_ability)\n .order(:stage_time)\n .paginate(page: params[:page], per_page: 15)\n end",
"def other_certificate_file\n super\n end",
"def ca_cert\n \n end",
"def ssl_certificate\n @ssl_certificate ||= OpenSSL::X509::Certificate.new <<-CERT\n-----BEGIN CERTIFICATE-----\nMIIBQjCB7aADAgECAgEAMA0GCSqGSIb3DQEBBQUAMCoxDzANBgNVBAMMBm5vYm9k\neTEXMBUGCgmSJomT8ixkARkWB2V4YW1wbGUwIBcNMTExMTAzMjEwODU5WhgPOTk5\nOTEyMzExMjU5NTlaMCoxDzANBgNVBAMMBm5vYm9keTEXMBUGCgmSJomT8ixkARkW\nB2V4YW1wbGUwWjANBgkqhkiG9w0BAQEFAANJADBGAkEA8pmEfmP0Ibir91x6pbts\n4JmmsVZd3xvD5p347EFvBCbhBW1nv1GsbCBEFlSiT1q2qvxGb5IlbrfdhdgyqdTX\nUQIBATANBgkqhkiG9w0BAQUFAANBAAAB////////////////////////////////\n//8AMCEwCQYFKw4DAhoFAAQUePiv+QrJxyjtEJNnH5pB9OTWIqA=\n-----END CERTIFICATE-----\n CERT\n end",
"def get_certificate(aliaz)\n\n end",
"def keycerts; end",
"def certificate=(certificate); end",
"def certificate_file\n super\n end",
"def ssl_generate_certificate\n Rex::Socket::SslTcpServer.ssl_generate_certificate\n end",
"def cert_path; end",
"def cert_path; end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.pkcs12Certificate\"\n end",
"def request_cert_command\n puts(\"Please use 'choria enroll' to enroll in the security subsystem\")\n raise(Util::Choria::Abort, \"1\")\n end",
"def sellar(cert_file, key_file, password)\n nocertificado=\"\"\n certificado=\"\"\n raw = File.read cert_file\n certificate = OpenSSL::X509::Certificate.new raw\n certificate.serial.to_s(16).scan(/.{2}/).each {|v| nocertificado += v[1] }\n certificado = certificate.to_s.gsub(/^-.+/, '').gsub(/\\n/, '')\n\n digest = OpenSSL::Digest::SHA1.new\n pem_file = export_to_pem(key_file, password )\n\n pkey = OpenSSL::PKey::RSA.new( File.read(pem_file), password)\n signature = pkey.sign(OpenSSL::Digest::SHA1.new, certificado)\n #puts pkey.verify(digest, signature, certificado)\n sello =Base64.encode64(signature).gsub(/\\n/, '')\n\n set(:certificado, certificado)\n set(:nocertificado, nocertificado)\n set(:sello, sello)\n\n\n end",
"def certificate\n GeoCerts::Certificate.find_by_order_id(self.id)\n end",
"def crl_distribution_points\n extensions[R509::Cert::Extensions::CRLDistributionPoints]\n end",
"def endorsement_certificate\n \n end",
"def add_certificate(http); end",
"def certification=(value)\n @certification = value\n end",
"def ssl_client_certificate\n super\n end",
"def generate_ca_data!\n self.private_key = OpenSSL::PKey::RSA.new(2048)\n public_key = private_key.public_key\n\n self.ca_cert = OpenSSL::X509::Certificate.new\n self.ca_cert.subject = self.ca_cert.issuer = self.subject # self-signed\n self.ca_cert.not_before = Time.now\n self.ca_cert.not_after = Time.now + 365 * 24 * 60 * 60 * 10 #TODO change from hardcoded 10 years\n self.ca_cert.public_key = public_key\n self.ca_cert.serial = 0x0\n self.next_serial = 0x1\n self.ca_cert.version = 2\n\n ef = OpenSSL::X509::ExtensionFactory.new\n ef.subject_certificate = ca_cert\n ef.issuer_certificate = ca_cert\n # TODO Make this changeable\n self.ca_cert.extensions = [\n ef.create_extension(\"basicConstraints\",\"CA:TRUE\", true),\n ef.create_extension(\"subjectKeyIdentifier\", \"hash\"),\n ]\n self.ca_cert.add_extension ef.create_extension(\"authorityKeyIdentifier\", \"keyid:always,issuer:always\")\n\n self.ca_cert.sign private_key, OpenSSL::Digest::SHA1.new\n end",
"def initialize\n @ssl_cert = OpenSSL::X509::Certificate.new(File.read(get_path(OtaEnroll.settings.ssl_crt))) if File.exists?(get_path(OtaEnroll.settings.ssl_crt))\n @ssl_key = OpenSSL::PKey::RSA.new(File.read(get_path(OtaEnroll.settings.ssl_key))) if File.exists?(get_path(OtaEnroll.settings.ssl_key))\n @root_cert = OpenSSL::X509::Certificate.new(File.read(get_path(OtaEnroll.settings.ca_crt))) if File.exists?(get_path(OtaEnroll.settings.ca_crt))\n @root_key = OpenSSL::PKey::RSA.new(File.read(get_path(OtaEnroll.settings.ca_key))) if File.exists?(get_path(OtaEnroll.settings.ca_key))\n @ra_cert = OpenSSL::X509::Certificate.new(File.read(get_path(OtaEnroll.settings.ra_crt))) if File.exists?(get_path(OtaEnroll.settings.ra_crt))\n @ra_key = OpenSSL::PKey::RSA.new(File.read(get_path(OtaEnroll.settings.ra_key))) if File.exists?(get_path(OtaEnroll.settings.ra_key))\n @sign_interm_cert = OpenSSL::X509::Certificate.new(File.read(get_path(OtaEnroll.settings.sign_interm_crt))) if File.exists?(get_path(OtaEnroll.settings.sign_interm_crt))\n @server_interm_cert = OpenSSL::X509::Certificate.new(File.read(get_path(OtaEnroll.settings.server_interm_crt))) if File.exists?(get_path(OtaEnroll.settings.server_interm_crt))\n end",
"def cert=(cert); end",
"def certificate(record)\n record.public_send(options[:certificate])\n end",
"def certificate(common_name, pfx_file, key_type, password, optionals = {})\n command = []\n command << @adt_path\n command << \"-certificate\"\n command << \"-cn #{common_name}\"\n command << \"-ou #{optionals[:org_unit]}\" if !optionals[:org_unit].blank?\n command << \"-o #{optionals[:org]}\" if !optionals[:org].blank?\n command << \"-c #{optionals[:country]}\" if !optionals[:country].blank?\n command << key_type\n command << escape(pfx_file)\n command << password\n process(command)\n end",
"def cert_path=(_arg0); end",
"def peer_certification_mode\n super\n end",
"def ssl_params; end",
"def certificate\n _get_certificate\n end",
"def prepare_certificate(csr)\n cert = OpenSSL::X509::Certificate.new\n cert.subject = csr.subject\n cert.public_key = csr.public_key\n cert\n end",
"def createkey(hostname, pupmodule, pubfolder, prvfolder, subject, ca_key_file,\nca_crt_file, passphrase)\n return 'Already there' if\n File.exist?(\"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\")\n ca_key = OpenSSL::PKey::RSA.new File.read(ca_key_file), passphrase\n ca_cert = OpenSSL::X509::Certificate.new File.read ca_crt_file\n c=SignedCertificate.new(ca_key, ca_cert, subject)\n FileUtils.mkdir_p \"#{pubfolder}/#{pupmodule}/\"\n FileUtils.mkdir_p \"#{prvfolder}/#{hostname}/#{pupmodule}/\"\n #open \"#{pubfolder}/#{pupmodule}/#{hostname}.pub.pem\", 'w' do\n #|io| io.write c.key.public_key.to_pem end\n #open \"#{pubfolder}/#{pupmodule}/#{hostname}.csr.pem\", 'w' do\n #|io| io.write c.csr.to_pem end\n open \"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\", 'w' do\n |io| io.write c.cert.to_pem end\n open \"#{prvfolder}/#{hostname}/#{pupmodule}/#{hostname}.priv.pem\", 'w' do\n |io| io.write c.key.to_pem end\n 'OK'\nend",
"def setup_ssl_get_props\n ssl_props = {}\n attrs = node.workorder.rfcCi.ciAttributes\n\n if attrs.version.eql?('0.8.2.1')\n ssl_props['advertised.host.name'] = get_full_hostname(node[:hostname])\n else\n #ssl feature is available only for kafka version 9+\n # checking whether ssl is enabled. check secgroup_inbound_rules to decide if plaintext and/or ssl is enabled. 9092 port is for plaintext and 9093 is for ssl\n sslEnabled = attrs.enable_ssl.eql?('true')\n plainTextEnabled = attrs.disable_plaintext.eql?('false')\n saslPlainEnabled = attrs.enable_sasl_plain.eql?('true')\n hostname = `hostname -f`\n hostname.gsub!(\"\\n\", \"\")\n\n if sslEnabled\n keystore = node.workorder.payLoad.DependsOn.select { |d| d[:ciClassName] == \"bom.oneops.1.Keystore\" }\n if keystore.nil? || keystore.size==0\n Chef::Log.error(\"Keystore component is missing.\")\n exit 1\n end\n Chef::Log.info('keystore' + keystore.to_s)\n cert = node.workorder.payLoad.DependsOn.select { |d| d[:ciClassName] == \"bom.oneops.1.Certificate\" }\n if cert.nil? || cert.size==0\n Chef::Log.error(\"Certificate component is missing.\")\n exit 1\n end\n Chef::Log.info('cert' + cert.to_s)\n passphrase = cert.first[:ciAttributes].passphrase\n keystore_file = keystore.first[:ciAttributes].keystore_filename\n keystore_password = keystore.first[:ciAttributes].keystore_password\n ca_cert_file = '/tmp/kafka-ca-cert'\n truststore_file = File.dirname(keystore_file)+'/kafka.server.truststore.jks'\n truststore_password = attrs.truststore_password\n if truststore_password.to_s.empty?\n truststorepasswdmissing = \"Truststore password is missing.\"\n Chef::Log.error(\"#{truststorepasswdmissing}\")\n puts \"***FAULT:FATAL=#{truststorepasswdmissing}\"\n Chef::Application.fatal!(truststorepasswdmissing)\n end\n File.open(ca_cert_file, 'w') { |file| file.write(cert.first[:ciAttributes].cacertkey) }\n # import CA certificate to the truststore\n `keytool -keystore #{truststore_file} -alias CARoot -import -file #{ca_cert_file} -storepass #{truststore_password} -noprompt`\n #setup SSL properties for kafka\n ssl_props['ssl.keystore.location'] = keystore_file\n ssl_props['ssl.key.password'] = passphrase\n ssl_props['ssl.keystore.password'] = keystore_password\n ssl_props['ssl.truststore.password'] = truststore_password\n ssl_props['ssl.truststore.location'] = truststore_file\n\n if attrs.enable_client_auth.eql?('true') && (attrs.client_certs.nil? || attrs.client_certs.size == 0)\n clientcertsmissing = \"Client cert locations are missing when client authentication is enabled.\"\n Chef::Log.error(\"#{clientcertsmissing}\")\n puts \"***FAULT:FATAL=#{clientcertsmissing}\"\n Chef::Application.fatal!(clientcertsmissing)\n end \n \n if attrs.has_key?(\"client_certs\") && !attrs.client_certs.nil? && attrs.client_certs.size > 0\n ssl_props['client.security.protocol'] = \"SSL\"\n JSON.parse(attrs.client_certs).each do |key| \n tname = key.split(\"/\").last\n `keytool -keystore #{truststore_file} -alias #{tname} -import -file #{key} -storepass #{truststore_password} -noprompt`\n end\n ssl_props['client.ssl.truststore.location']= truststore_file\n ssl_props['client.ssl.truststore.password'] = truststore_password\n end\n\n ssl_props['advertised.listeners'] = ssl_props['listeners'] = plainTextEnabled ? \"PLAINTEXT://\"+ hostname +\":9092,SSL://\"+ hostname +\":9093\" : \"SSL://\"+ hostname +\":9093\"\n \n ssl_props['ssl.client.auth'] = 'required' if attrs.enable_client_auth.eql?('true')\n \n ssl_props['security.inter.broker.protocol'] = 'SSL' if attrs.disable_plaintext.eql?('true')\n ssl_props['authorizer.class.name'] = 'kafka.security.auth.SimpleAclAuthorizer' if attrs.enable_acl.eql?('true') and attrs.enable_client_auth.eql?('true')\n\n ssl_props['super.users'] = attrs.acl_super_user if attrs.enable_acl.eql?('true') and attrs.enable_client_auth.eql?('true')\n Chef::Log.info('Enabled SSL')\n elsif saslPlainEnabled\n ssl_props['advertised.listeners'] = ssl_props['listeners'] = \"SASL_PLAINTEXT://\"+ hostname +\":9092\"\n elsif plainTextEnabled\n\n ssl_props['advertised.listeners'] = ssl_props['listeners'] = \"PLAINTEXT://:9092\"\n \n if JSON.parse(attrs[\"kafka_properties\"])[\"listeners\"].to_s == \"host\"\n ssl_props['listeners'] = \"PLAINTEXT://\"+ hostname +\":9092\"\n end\n\n if JSON.parse(attrs[\"kafka_properties\"])[\"advertised.listeners\"].to_s == \"host\"\n ssl_props['advertised.listeners'] = \"PLAINTEXT://\"+ hostname +\":9092\"\n end\n\n \n else\n Chef::Log.error(\"For plaintext messaging include Port 9092 in secgroup. For SSL include port 9093 in secgroup.\")\n exit 1\n end\n end\n return ssl_props\nend",
"def get_certificate_chain(aliaz)\n\n end",
"def epoc_cert_info cert, plat\n this_dir = File.dirname(File.expand_path(__FILE__))\n caps = case plat\n when /_3[01]_/\n SELF30_CAPS\n else\n SELF32_CAPS\n end\n args = [File.join(this_dir, \"selfsigned.key\"),\n File.join(this_dir, \"selfsigned.cer\"),\n nil,\n caps]\n EpocLocalRb::CertInfo.new(*args)\nend",
"def ca_file; end",
"def ca_file; end",
"def certification\n return @certification\n end",
"def allow_additional_certificate_state\n super\n end",
"def cert_store=(cert_store); end",
"def cert_store=(cert_store); end",
"def initialize(opts = {})\n @basic_constraints = R509::Cert::Extensions::BasicConstraints.new(opts[:basic_constraints]) unless opts[:basic_constraints].nil?\n @key_usage = R509::Cert::Extensions::KeyUsage.new(opts[:key_usage]) unless opts[:key_usage].nil?\n @extended_key_usage = R509::Cert::Extensions::ExtendedKeyUsage.new(opts[:extended_key_usage]) unless opts[:extended_key_usage].nil?\n @certificate_policies = R509::Cert::Extensions::CertificatePolicies.new(opts[:certificate_policies]) unless opts[:certificate_policies].nil?\n @inhibit_any_policy = R509::Cert::Extensions::InhibitAnyPolicy.new(opts[:inhibit_any_policy]) unless opts[:inhibit_any_policy].nil?\n @policy_constraints = R509::Cert::Extensions::PolicyConstraints.new(opts[:policy_constraints]) unless opts[:policy_constraints].nil?\n @name_constraints = R509::Cert::Extensions::NameConstraints.new(opts[:name_constraints]) unless opts[:name_constraints].nil?\n @ocsp_no_check = R509::Cert::Extensions::OCSPNoCheck.new(opts[:ocsp_no_check]) unless opts[:ocsp_no_check].nil?\n @authority_info_access = R509::Cert::Extensions::AuthorityInfoAccess.new(opts[:authority_info_access]) unless opts[:authority_info_access].nil?\n @crl_distribution_points = R509::Cert::Extensions::CRLDistributionPoints.new(opts[:crl_distribution_points]) unless opts[:crl_distribution_points].nil?\n @subject_item_policy = validate_subject_item_policy(opts[:subject_item_policy])\n @default_md = validate_md(opts[:default_md] || R509::MessageDigest::DEFAULT_MD)\n @allowed_mds = validate_allowed_mds(opts[:allowed_mds])\n end",
"def cert\n @cert\n end",
"def ssl_ca_certificate_file\n super\n end",
"def ssl_cert\n datastore['SSLCert']\n end",
"def certificate_subject\n return \"CN=#{project.package_name}\" unless signing_identity\n\n store = machine_store? ? \"LocalMachine\" : \"CurrentUser\"\n cmd = [].tap do |arr|\n arr << \"powershell.exe\"\n arr << \"-ExecutionPolicy Bypass\"\n arr << \"-NoProfile\"\n arr << \"-Command (Get-Item Cert:/#{store}/#{cert_store_name}/#{thumbprint}).Subject\"\n end.join(\" \")\n\n shellout!(cmd).stdout.strip\n end",
"def use_bundled_cert!; end",
"def certificate_details\n data[:certificate_details]\n end",
"def create_leaf_certificate(info = {})\n root_ca = info[:ca]\n root_key = info[:ca_key]\n\n key = OpenSSL::PKey::RSA.new(RSA_KEY_SIZE)\n\n cert = create_certificate_skeleton(info)\n cert.issuer = root_ca.subject # root CA is the issuer\n cert.public_key = key.public_key\n\n extensions = [\n ['keyUsage', 'digitalSignature', true],\n ['subjectKeyIdentifier', 'hash', false],\n AUTHORITY_INFO_ACCESS_EXTENSION,\n ['authorityKeyIdentifier', 'keyid:always', false],\n ]\n\n unless info[:no_policies]\n extensions << [\n 'certificatePolicies',\n IdentityConfig.store.required_policies.first,\n false,\n ]\n end\n\n if info[:policy_constraints]\n extensions << [\n 'policyConstraints',\n info[:policy_constraints].to_a.map { |kv| kv.join(':') }.join(','),\n true,\n ]\n end\n\n if info[:policy_mapping]\n extensions << [\n 'policyMappings',\n info[:policy_mapping].to_a.map { |kv| kv.join(':') }.join(','),\n true,\n ]\n end\n\n add_certificate_extensions(cert, root_ca, *extensions)\n cert.sign(root_key, OpenSSL::Digest::SHA256.new)\n cert\n end",
"def x509\n @x509 ||= OpenSSL::X509::Certificate.new(as_pem)\n end",
"def setup\n generate_ca_certificate unless @host.certificate\n end",
"def run\n _log \"Enriching... SSL Certificate: #{_get_entity_name}\"\n\n not_before = _get_entity_detail(\"not_before\")\n # not before aug 31 \n # today aug 20\n if not_before && Time.parse(not_before) > Time.now\n _log \"Creating issue for certificate that is not yet valid\"\n _create_linked_issue \"invalid_certificate_premature\"\n end\n\n not_after = _get_entity_detail(\"not_after\")\n # not after aug 31 \n # today aug 20\n if not_after && Time.parse(not_after) < Time.now\n _log \"Creating issue for expired certificate\"\n _create_linked_issue \"invalid_certificate_expired\"\n end\n\n thirty_days = 2592000\n ## not afere Aug 31\n ## not afeer - 30 days = July 31\n ## Time.now = Aug 20\n ## Time.now - 30 days = July 20\n if not_after && \n !(Time.parse(not_after) < Time.now) && # expired\n (Time.parse(not_after) - thirty_days) < Time.now # expires in 30 days\n \n _log \"Creating issue for almost expired certificate\"\n _create_linked_issue \"invalid_certificate_almost_expired\"\n end\n\n # https://www.globalsign.com/en/blog/moving-from-sha-1-to-sha-256\n algo = _get_entity_detail(\"algorithm\")\n if algo && (algo == \"SHA1\" || algo == \"MD5\")\n _log \"Creating issue for certificate with invalid algorithm\"\n _create_linked_issue \"invalid_certificate_algorithm\"\n end\n\n end",
"def ssl; end",
"def enable_cert_auth(public_key = '~/.ssh/id_rsa.pub')\r\n cert_regex = /^ssh-[rd]sa (?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)? \\S*$/m\r\n\r\n # get our cert unless the user provided a full cert for us.\r\n unless public_key =~ cert_regex\r\n public_key = File.expand_path(public_key)\r\n if File.exist?(public_key)\r\n public_key = File.read(public_key).to_s.strip\r\n else\r\n raise Shells::PfSenseCommon::PublicKeyNotFound\r\n end\r\n raise Shells::PfSenseCommon::PublicKeyInvalid unless public_key =~ cert_regex\r\n end\r\n\r\n cfg = get_config_section 'system'\r\n user_id = nil\r\n user_name = options[:user].downcase\r\n cfg['user'].each_with_index do |user,index|\r\n if user['name'].downcase == user_name\r\n user_id = index\r\n\r\n authkeys = Base64.decode64(user['authorizedkeys'].to_s).gsub(\"\\r\\n\", \"\\n\").strip\r\n unless authkeys == '' || authkeys =~ cert_regex\r\n warn \"Existing authorized keys for user #{options[:user]} are invalid and are being reset.\"\r\n authkeys = ''\r\n end\r\n\r\n if authkeys == ''\r\n user['authorizedkeys'] = Base64.strict_encode64(public_key)\r\n else\r\n authkeys = authkeys.split(\"\\n\")\r\n unless authkeys.include?(public_key)\r\n authkeys << public_key unless authkeys.include?(public_key)\r\n user['authorizedkeys'] = Base64.strict_encode64(authkeys.join(\"\\n\"))\r\n end\r\n end\r\n\r\n break\r\n end\r\n end\r\n\r\n\r\n raise Shells::PfSenseCommon::UserNotFound unless user_id\r\n\r\n set_config_section 'system', cfg, \"Enable certificate authentication for #{options[:user]}.\"\r\n\r\n apply_user_config user_id\r\n end",
"def index\n @certifications = Certification.all\n end",
"def manufacturer_cert\r\n Tem::CA.ca_cert\r\n end",
"def certificate(serial_number)\n RubyAem::Resources::Certificate.new(@client, serial_number)\n end",
"def certification_name\n return @certification_name\n end",
"def update_key_cert\n converge_by(\"Update #{new_resource} cert key method\") do\n\t kid = new_resource.keyid\n\t cid = new_resource.certid\n caid = new_resource.cacertid if !new_resource.cacertid.nil?\n\t todel='-alt'\n\t if @current_resource.exists\n\t if !load_balancer.client['LocalLB.ProfileClientSSL'].get_key_file([\"/Common/#{new_resource.sslprofile_name}\"])[0].value.include?(\"#{new_resource.sslprofile_name}-alt\")\n\t\tkid = new_resource.sslprofile_name+'-alt.key'\n\t\tcid = new_resource.sslprofile_name+'-alt.crt'\n\t\tcaid = new_resource.sslprofile_name+'-alt.crt' if !new_resource.cacertid.nil?\n\t\ttodel = ''\n\t end\n\t end\n Chef::Log.info \"Update #{new_resource} cert key method with PASSPHRASE #{new_resource.passphrase}\"\n load_balancer.client['LocalLB.ProfileClientSSL'].set_key_certificate_file([new_resource.sslprofile_name], [{\"value\" => \"/Common/#{kid}\", \"default_flag\" => \"false\"}] , [{\"value\" => \"/Common/#{cid}\", \"default_flag\" => \"false\"}])\n load_balancer.client['LocalLB.ProfileClientSSL'].set_passphrase([\"/Common/#{new_resource.sslprofile_name}\"], [{\"value\" => \"#{new_resource.passphrase}\", \"default_flag\" => \"false\" }]) if !new_resource.passphrase.nil?\n load_balancer.client['LocalLB.ProfileClientSSL'].set_chain_file_v2([\"/Common/#{new_resource.sslprofile_name}\"], [{\"value\" => \"/Common/#{caid}\", \"default_flag\" => \"false\" }]) if !new_resource.cacertid.nil?\n\t \n\t ssl_d = load_balancer.ltm.ssls(\"MANAGEMENT_MODE_DEFAULT\").find { |p| p =~ /(^|\\/)#{new_resource.sslprofile_name}#{todel}$/ } \n\t if !ssl_d.nil?\n\t \tload_balancer.client['Management.KeyCertificate'].key_delete(\"MANAGEMENT_MODE_DEFAULT\", [\"/Common/#{new_resource.sslprofile_name}#{todel}\"])\n\t \tload_balancer.client['Management.KeyCertificate'].certificate_delete(\"MANAGEMENT_MODE_DEFAULT\", [\"/Common/#{new_resource.sslprofile_name}#{todel}\"])\n\t end\n current_resource.keyid(new_resource.keyid)\n current_resource.certid(new_resource.certid)\n current_resource.passphrase(new_resource.passphrase)\n current_resource.cacertid(new_resource.cacertid)\n\n new_resource.updated_by_last_action(true)\n end\n end",
"def x509_certificate_string\n t=self.metadata_nokogiri.clone\n t.remove_namespaces!\n the_xpath = \"//KeyDescriptor/KeyInfo/X509Data/X509Certificate\"\n node = t.xpath(the_xpath)\n if node.blank?\n raise \"Could not extract X509Certificate from #{site.name}\"\n else\n node.inner_text\n end\n end",
"def sign_certificate(host)\n return if [master, dashboard, database].include? host\n \n hostname = Regexp.escape host.node_name\n \n last_sleep = 0\n next_sleep = 1\n (0..10).each do |i|\n fail_test(\"Failed to sign cert for #{hostname}\") if i == 10\n \n on master, puppet(\"cert --sign --all\"), :acceptable_exit_codes => [0,24]\n break if on(master, puppet(\"cert --list --all\")).stdout =~ /\\+ \"?#{hostname}\"?/\n sleep next_sleep\n (last_sleep, next_sleep) = next_sleep, last_sleep+next_sleep\n end\n end",
"def certificate_without_head_foot\n @certificate_without_head_foot ||= read_certificate(\"certificate_without_head_foot\")\n end",
"def ca_file\n super\n end",
"def ca_file\n super\n end",
"def generate\n\n verify_cert_hash = get_ssl_cert_hash(datastore['StagerVerifySSLCert'],\n datastore['HandlerSSLCert'])\n\n super(\n ssl: true,\n verify_cert_hash: verify_cert_hash\n )\n end",
"def ca_path\n super\n end",
"def certificate_params\n params.require(:certificate).permit(:cn, :last_crt, :csr, :key, :project_id, :revoked, :environment_id, :time_renewal, :auto_renewal)\n end",
"def keycert_files; end",
"def certificate_body\n data.certificate_body\n end",
"def certificate_body\n data.certificate_body\n end",
"def list\n Puppet::SSL::Certificate.search(\"*\").collect { |c| c.name }\n end",
"def get_certificate(kerberos)\n mech = Mechanize.new do |m|\n m.user_agent_alias = 'Linux Firefox'\n # NOTE: ca.mit.edu uses a Geotrust certificate, not the self-signed one\n end\n login_page = mech.get 'https://ca.mit.edu/ca/'\n login_form = login_page.form_with :action => /login/\n login_form.field_with(:name => /login/).value = kerberos[:user]\n login_form.field_with(:name => /pass/).value = kerberos[:pass]\n login_form.field_with(:name => /mitid/).value = kerberos[:mit_id]\n keygen_page = login_form.submit login_form.buttons.first\n\n keygen_form = keygen_page.form_with(:action => /ca/)\n if /login/ =~ keygen_form.action\n raise ArgumentError, 'Invalid Kerberos credentials'\n end\n keygen_form.field_with(:name => /life/).value = kerberos[:ttl] || 1\n key_pair = keygen_form.keygens.first.key\n response_page = keygen_form.submit keygen_form.buttons.first\n \n cert_frame = response_page.frame_with(:name => /download/)\n cert_bytes = mech.get_file cert_frame.uri\n cert = OpenSSL::X509::Certificate.new cert_bytes\n {:key => key_pair, :cert => cert}\n end",
"def extended_ssl_certificates(name)\n ssl_certificates(name).extend(OpenSSLExtensions::X509::Certificate)\n end",
"def get_cert_lines()\n lines_str = get_config_data\n lines = lines_str.split(\"\\n\")\n lines\n end",
"def cert\n @agent.certificate\n end",
"def test_autocertgeneration\n ca = nil\n\n # create our ca\n assert_nothing_raised {\n ca = Puppet::Network::Handler.ca.new(:autosign => true)\n }\n\n # create a cert with a fake name\n key = nil\n csr = nil\n cert = nil\n hostname = \"test.domain.com\"\n assert_nothing_raised {\n cert = Puppet::SSLCertificates::Certificate.new(\n :name => \"test.domain.com\"\n )\n }\n\n # make the request\n assert_nothing_raised {\n cert.mkcsr\n }\n\n # and get it signed\n certtext = nil\n cacerttext = nil\n assert_nothing_raised {\n certtext, cacerttext = ca.getcert(cert.csr.to_s)\n }\n\n # they should both be strings\n assert_instance_of(String, certtext)\n assert_instance_of(String, cacerttext)\n\n # and they should both be valid certs\n assert_nothing_raised {\n OpenSSL::X509::Certificate.new(certtext)\n }\n assert_nothing_raised {\n OpenSSL::X509::Certificate.new(cacerttext)\n }\n\n # and pull it again, just to make sure we're getting the same thing\n newtext = nil\n assert_nothing_raised {\n newtext, cacerttext = ca.getcert(\n cert.csr.to_s, \"test.reductivelabs.com\", \"127.0.0.1\"\n )\n }\n\n assert_equal(certtext,newtext)\n end",
"def initialize\n @verify_certificates = true\n end",
"def set_certificate\n begin\n if current_user.admin?\n @certificate = Certificate.joins(:project => :users)\n .where(:projects => {:id => params[:project_id]})\n .where(id: params[:id]).first!\n else\n @certificate = Certificate.joins(:project => :users)\n .where(:projects => {:id => params[:project_id]})\n .where(:users => {:id => current_user.id})\n .where(id: params[:id]).first!\n\n end\n rescue ActiveRecord::RecordNotFound\n @certificate = nil\n end\n end",
"def get(certificate_thumbprint)\n cert_get(certificate_thumbprint)\n end",
"def cert_params\n params[:cert]\n end",
"def endorsement_certificate\n @ecert\n end",
"def certificate_params\n params.require(:certificate).permit(:cn, :last_crt, :csr, :key, :detail, :acme_id, :owner_id)\n end",
"def create_self_signed_cert(bits, cn, comment)\n rsa = OpenSSL::PKey::RSA.new(bits)\n cert = OpenSSL::X509::Certificate.new\n cert.version = 2\n cert.serial = 1\n name = OpenSSL::X509::Name.new(cn)\n cert.subject = name\n cert.issuer = name\n cert.not_before = Time.now\n cert.not_after = Time.now + (365*24*60*60)\n cert.public_key = rsa.public_key\n cert.sign(rsa, OpenSSL::Digest::SHA1.new)\n return [cert, rsa]\nend",
"def set_ssl_client_certificate(opts)\n opts = check_params(opts,[:certificates])\n super(opts)\n end",
"def configure(cert)\n req = signing_request\n cert.issuer = Billy.certificate_authority.cert.subject\n cert.not_before = days_ago(2)\n cert.not_after = days_from_now(2)\n cert.public_key = req.public_key\n cert.serial = serial\n cert.subject = req.subject\n cert.version = 2\n end",
"def cpl\n end",
"def initialize(certinfos, defaulthostname, config={})\n @config = config\n @defaulthostname = defaulthostname\n @parenthostname = defaulthostname.sub(/^[\\w-]+\\./, '') # remove left-most label\n @certinfos = certinfos\n @certificates = {}\n end",
"def certificate_subject\n attributes[:certificate_subject]\n end",
"def cert= cert\n @agent.certificate = cert\n end",
"def postgres_ssl_connection(ip)\n FileUtils.chmod 0600, %w(ssl/client.crt ssl/client.key ssl/root.crt)\n\n PG::Connection.new(\n host: ip,\n user: DB_USER,\n dbname: DB_NAME,\n port: DB_PORT,\n password: DB_PASSWORD,\n sslmode: \"require\",\n sslcert: \"ssl/client.crt\",\n sslkey: \"ssl/client.key\",\n sslrootcert: \"ssl/root.crt\",\n connect_timeout: \"1\",\n )\nend"
] | [
"0.6399502",
"0.6399502",
"0.62356037",
"0.62356037",
"0.62356037",
"0.59352547",
"0.5841509",
"0.5835554",
"0.5814392",
"0.5814392",
"0.5788206",
"0.5733798",
"0.57122207",
"0.57085127",
"0.56525683",
"0.56441766",
"0.5605067",
"0.56027365",
"0.55675745",
"0.5552299",
"0.5483977",
"0.5478794",
"0.5478794",
"0.54629964",
"0.54625976",
"0.5459958",
"0.54447013",
"0.5441049",
"0.5429165",
"0.54167265",
"0.5415893",
"0.54132545",
"0.5392297",
"0.53903365",
"0.5382409",
"0.5380121",
"0.53758436",
"0.53631735",
"0.5360571",
"0.53436553",
"0.533445",
"0.5319475",
"0.5315494",
"0.5311273",
"0.52983725",
"0.5291767",
"0.5291543",
"0.5291543",
"0.52657723",
"0.5255375",
"0.52478117",
"0.52478117",
"0.52458525",
"0.5244751",
"0.5225165",
"0.52176815",
"0.52154",
"0.52111316",
"0.5209591",
"0.5201255",
"0.519954",
"0.51952446",
"0.5193833",
"0.5187596",
"0.5179666",
"0.5169898",
"0.51603514",
"0.51424557",
"0.5141776",
"0.5124695",
"0.5123328",
"0.51221544",
"0.51209044",
"0.51171744",
"0.51171744",
"0.51144916",
"0.51117605",
"0.5111162",
"0.5106766",
"0.51047903",
"0.51047903",
"0.5104602",
"0.51031464",
"0.51027334",
"0.50940335",
"0.50820094",
"0.50677186",
"0.50675255",
"0.50568736",
"0.505555",
"0.5038404",
"0.5030745",
"0.502731",
"0.5023943",
"0.5017198",
"0.5016134",
"0.50128174",
"0.50073165",
"0.5001206",
"0.49868733",
"0.49726713"
] | 0.0 | -1 |
TODO: SCAL936 enable/disable PLGrid | def plgrid_enabled?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid; @parameters['GRiD']; end",
"def grid_modified!\n end",
"def toggle_grid\n if @show_grid\n self.show_grid = false\n else\n self.show_grid = true\n end\n end",
"def build_voyage_port_grid(data_set,can_edit,can_delete)\n column_configs = Array.new\n\n if can_edit\n #if session[:edit_voyage]==true\n column_configs << {:field_type => 'link_window', :field_name => 'edit',\n :settings =>\n {:link_text => 'edit ',\n :target_action => 'edit_voyage_port_from_popup',\n :id_column => 'id'}}\n\n #end\nend\n\tif can_delete\n #if session[:edit_voyage]==true\n\t\tcolumn_configs << {:field_type => 'action',:field_name => 'delete ',\n\t\t\t:settings =>\n\t\t\t\t {:link_text => 'delete ',\n\t\t\t\t:target_action => 'delete_voyage_port',\n\t\t\t\t:id_column => 'id'}}\n #end\n end\n\n column_configs << {:field_type => 'text',:field_name => 'port_type_code'}\n column_configs << {:field_type => 'text',:field_name => 'port_code'}\n column_configs << {:field_type => 'text',:field_name => 'quay'}\n column_configs << {:field_type => 'text',:field_name => 'departure_date'}\n column_configs << {:field_type => 'text',:field_name => 'arrival_date'}\n column_configs << {:field_type => 'text',:field_name => 'departure_open_stack'}\n column_configs << {:field_type => 'text',:field_name => 'departure_close_stack'}\n\n\n set_grid_min_height(150)\n set_grid_min_width(850)\n hide_grid_client_controls()\nreturn get_data_grid(data_set,column_configs,nil,true)\nend",
"def gridpoints\n gridpoints = {'l' => @ngauss, 'e' => @negrid, 's' => @nspec}\n if @grid_option == \"single\"\n gridpoints.absorb({'x'=>1, 'y'=>1})\n else\n gridpoints.absorb({'x' => (@ntheta0 or (2.0 * (@nx - 1.0) / 3.0 + 1.0).floor), 'y' => (@naky or ((@ny - 1.0) / 3.0 + 1.0).floor)})\n end\n return gridpoints\nend",
"def toggle\n\t\t@gridOn = !@gridOn\n\tend",
"def grid_role?\n true\n end",
"def grid\n @grid ||= if @opts.key? \"grid\"\n @opts.slice(\"grid\", \",\")\n else\n %w[0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%]\n end\n end",
"def grid\n state.grid\n end",
"def grid\n state.grid\n end",
"def grid\n @grid ||= {}\nend",
"def grid(index)\r\n out_short_name = FFI::MemoryPointer.new(:string)\r\n out_full_name = FFI::MemoryPointer.new(:string)\r\n out_package_name = FFI::MemoryPointer.new(:string)\r\n out_url = FFI::MemoryPointer.new(:string)\r\n out_direct_download = FFI::MemoryPointer.new(:int)\r\n out_open_license = FFI::MemoryPointer.new(:int)\r\n out_available = FFI::MemoryPointer.new(:int)\r\n\r\n result = Api.proj_coordoperation_get_grid_used(self.context, self, index,\r\n out_short_name, out_full_name, out_package_name,\r\n out_url, out_direct_download ,\r\n out_open_license, out_available)\r\n\r\n if result != 1\r\n Error.check_object(self)\r\n end\r\n\r\n name_ptr = out_short_name.read_pointer\r\n full_name_ptr = out_full_name.read_pointer\r\n package_name_ptr = out_package_name.read_pointer\r\n url_ptr = out_url.read_pointer\r\n downloadable_ptr = out_direct_download \r\n open_license_ptr = out_open_license\r\n available_ptr = out_available\r\n\r\n unless name_ptr.null?\r\n Grid.new(name_ptr.read_string_to_null, self.context,\r\n full_name: full_name_ptr.null? ? nil : full_name_ptr.read_string_to_null,\r\n package_name: package_name_ptr.null? ? nil : package_name_ptr.read_string_to_null,\r\n url: url_ptr.null? ? nil : url_ptr.read_string_to_null,\r\n downloadable: downloadable_ptr.null? ? nil : downloadable_ptr.read_int == 1 ? true : false,\r\n open_license: open_license_ptr.null? ? nil : open_license_ptr.read_int == 1 ? true : false,\r\n available: available_ptr.null? ? nil : available_ptr.read_int == 1 ? true : false)\r\n end\r\n end",
"def grid(*)\n super\n end",
"def setup_grid(skip_render, skip_set_pieces)\n @grid = Array.new(8) { Array.new(8) { EmptySquare.new } }\n unless skip_set_pieces\n set_major_minor\n set_pawns\n end\n\n render unless skip_render\n end",
"def setTerrainGrid _args\n \"setTerrainGrid _args;\" \n end",
"def drawXZGrid\n\t\tif !@gridOn then return end\n\t\tglDisable(GL_LIGHTING)\n\t\tglBegin(GL_LINES)\n\t\tglColor(@gridColorXZ)\n\t\tfor i in (-@gridLines..@gridLines)\n\t\t\t# Draw two lines for each iteration\n\t\t\tglVertex( i*@gridSpacing, 0.0, -(@gridLines*@gridSpacing))\n\t\t\tglVertex( i*@gridSpacing, 0.0, (@gridLines*@gridSpacing))\n\t\t\tglVertex( -(@gridLines*@gridSpacing), 0.0, i*@gridSpacing)\n\t\t\tglVertex( (@gridLines*@gridSpacing), 0.0, i*@gridSpacing)\n\t\tend\n\t\tglEnd\n\t\tglEnable(GL_LIGHTING)\n\tend",
"def initialize()\n\t\t@gridColorXZ = [1.0, 0.0, 0.0, 0.0] #Red\n\t\t@gridColorXY = [1.0, 1.0, 0.0, 0.0] #Yellow\n\t\t@gridColorYZ = [0.0, 0.0, 1.0, 0.0] #Blue\n\t\t@gridLines = 10 # The number of lines in HALF the grid (just to make counting easier)\n\t\t@gridSpacing = 5.0\n\t\t@gridOn = true\n\tend",
"def grid(name)\r\n out_full_name = FFI::MemoryPointer.new(:string)\r\n out_package_name = FFI::MemoryPointer.new(:string)\r\n out_url = FFI::MemoryPointer.new(:string)\r\n out_downloadable = FFI::MemoryPointer.new(:int)\r\n out_open_license = FFI::MemoryPointer.new(:int)\r\n out_available = FFI::MemoryPointer.new(:int)\r\n\r\n result = Api.proj_grid_get_info_from_database(self.context, name,\r\n out_full_name, out_package_name, out_url,\r\n out_downloadable, out_open_license, out_available)\r\n\r\n if result == 1\r\n full_name_ptr = out_full_name.read_pointer\r\n package_name_ptr = out_package_name.read_pointer\r\n url_ptr = out_url.read_pointer\r\n\r\n downloadable_ptr = out_downloadable\r\n open_license_ptr = out_open_license\r\n available_ptr = out_available\r\n\r\n full_name = full_name_ptr.read_string_to_null\r\n package_name = package_name_ptr.read_string_to_null\r\n url = url_ptr.read_string_to_null\r\n\r\n downloadable = downloadable_ptr.read_int == 1 ? true : false\r\n open_license = open_license_ptr.read_int == 1 ? true : false\r\n available = available_ptr.read_int == 1 ? true : false\r\n\r\n Grid.new(name, self.context,\r\n full_name: full_name, package_name: package_name,\r\n url: url ? URI(url) : nil,\r\n downloadable: downloadable, open_license: open_license, available: available)\r\n else\r\n Error.check_context(self.context)\r\n end\r\n end",
"def add_grid(grid)\n add_post_command(grid)\n end",
"def build_pack_materials_grid(data_set,can_create_run)\n\n\n\n column_configs = Array.new\n\n\tcolumn_configs[0] = {:field_type => 'text',:field_name => 'retail_item_pack_material_code'}\n\tcolumn_configs[1] = {:field_type => 'text',:field_name => 'retail_unit_pack_material_code'}\n\tcolumn_configs[2] = {:field_type => 'text',:field_name => 'trade_unit_pack_material_code'}\n\tcolumn_configs[3] = {:field_type => 'text',:field_name => 'pallet_pack_material_code'}\n\tcolumn_configs[4] = {:field_type => 'text',:field_name => 'fg_product_code'}\n\tcolumn_configs[5] = {:field_type => 'text',:field_name => 'carton_setup_code'}\n\tcolumn_configs[6] = {:field_type => 'text',:field_name => 'created_at'}\n\n\n\n return get_data_grid(data_set,column_configs)\nend",
"def display_grid\n # variables for grid display\n @grid = \" A B C \\n\" \\\n \"1 #{@a1} | #{@b1} | #{@c1} \\n\" \\\n \" ---+---+--- \\n\" \\\n \"2 #{@a2} | #{@b2} | #{@c2} \\n\" \\\n \" ---+---+--- \\n\" \\\n \"3 #{@a3} | #{@b3} | #{@c3} \\n\"\n end",
"def hide_gridlines(option = 1)\n if option == 0\n @print_gridlines = 1 # 1 = display, 0 = hide\n @screen_gridlines = 1\n elsif option == 1\n @print_gridlines = 0\n @screen_gridlines = 1\n else\n @print_gridlines = 0\n @screen_gridlines = 0\n end\n end",
"def drawAll\n\t\tif !@gridOn then return end\n\t\tself.drawXYGrid\n\t\tself.drawXZGrid\n\t\tself.drawYZGrid\n\tend",
"def show_grid=(value)\n old = @show_grid\n @show_grid = value\n if old != @show_grid\n @array.each do |tile|\n if @show_grid\n if !tile.sprites[999]\n tile.sprites[999] = Sprite.new($visuals.viewport, {special: true})\n tile.sprites[999].set_bitmap(GRIDBITMAP)\n tile.sprites[999].x = tile.sprites[0].x\n tile.sprites[999].y = tile.sprites[0].y\n tile.sprites[999].z = 999\n end\n else\n if tile.sprites[999]\n tile.sprites[999].dispose\n tile.sprites.delete(999)\n end\n end\n end\n end\n end",
"def drawYZGrid\n\t\tif !@gridOn then return end\n\t\tglDisable(GL_LIGHTING)\n\t\tglBegin(GL_LINES)\n\t\tglColor(@gridColorYZ)\n\t\tfor i in (-@gridLines..@gridLines)\n\t\t\t# Draw two lines for each iteration\n\t\t\tglVertex( 0.0, i*@gridSpacing, -(@gridLines*@gridSpacing))\n\t\t\tglVertex( 0.0, i*@gridSpacing, (@gridLines*@gridSpacing))\n\t\t\tglVertex( 0.0, -(@gridLines*@gridSpacing), i*@gridSpacing)\n\t\t\tglVertex( 0.0, (@gridLines*@gridSpacing), i*@gridSpacing)\n\t\tend\n\t\tglEnd\n\t\tglEnable(GL_LIGHTING)\n\tend",
"def grids\n @grids ||= {}\n end",
"def initialize(grid=empty_grid)\n @grid = grid\n end",
"def set_grid\n @grid = Grid.find(params[:id])\n end",
"def set_grid\n @grid = Grid.find(params[:id])\n end",
"def set_grid\n @grid = Grid.find(params[:id])\n end",
"def setup_grid\n empty_rows\n [:white, :light_yellow].each do |color|\n back_rows(color)\n pawn_rows(color)\n end\n end",
"def build_grid\n x = 0\n 10.times do\n row = []\n y = 0\n 10.times do\n row.push({display: \"~~\", ship: false, coord: [x, y]})\n y += 1\n end\n self.grid << row\n x += 1\n end\n p self.grid\n end",
"def set_grid\n @grid = Grid.find(params[:id])\n end",
"def make_grid\n @grid = Array.new(4){Array.new(4)}\n end",
"def grid *name_and_or_opts, &proc\n return unless configurable?\n name, opts = nil, Hash.new\n name_and_or_opts.each { |a| a.is_a?(Hash) ? opts.update(a) : name = a }\n id = Digest::MD5.hexdigest(name.to_s + proc.to_s)\n name ||= id\n if proc\n @grid, @grid_columns = name, 0\n self.instance_exec &proc\n @grid = nil\n end\n columns = opts.delete(:columns) || @grid_columns || 2\n grids[name] = Struct.new(:id, :name, :columns, :opts).new(id, name, columns, opts)\n end",
"def cell_flagger(row_num, col_num)\n\t\t@grid[row_num][col_num].flagger\n\tend",
"def gridAltered\n if helpDisplayed?\n @textUI.updateLabel \"\"\n @helpCR[1]\n # Make the concerned cells normal\n @helpCR[1].each{ |cell|\n cellUi= @gridUi.cells[cell.row][cell.column]\n cellUi.normal\n }\n helpDisplayed=false\n end\n end",
"def setGridOnClick\n end",
"def build_pack_groups_grid(data_set,can_edit)\n\n\tcolumn_configs = Array.new\n\t require File.dirname(__FILE__) + \"/../../../app/helpers/production/run_setup_plugin.rb\"\n\n\tcolumn_configs[0] = {:field_type => 'text',:field_name => 'pack_group_number',:column_caption => 'group_num',:col_width => 85}\n\tcolumn_configs[1] = {:field_type => 'text',:field_name => 'production_run_number',:column_caption => 'run_num',:col_width => 85}\n\tcolumn_configs[2] = {:field_type => 'text',:field_name => 'production_schedule_name',:col_width => 233}\n\tcolumn_configs[3] = {:field_type => 'text',:field_name => 'commodity_code',:col_width => 65}\n\tcolumn_configs[4] = {:field_type => 'text',:field_name => 'marketing_variety_code',:col_width => 85,:column_caption => 'variety'}\n\tcolumn_configs[5] = {:field_type => 'text',:field_name => 'color_sort_percentage',:col_width => 60,:column_caption => '% color'}\n\tcolumn_configs[6] = {:field_type => 'text',:field_name => 'grade_code',:col_width => 65}\n\n#\t----------------------\n#\tdefine action columns\n#\t----------------------\n\tif can_edit\n\t\tcolumn_configs[column_configs.length()] = {:field_type => 'action',:field_name => 'edit drops', :col_width => 112,\n\t\t\t:settings =>\n\t\t\t\t {:link_text => 'set_drops_to_counts',\n\t\t\t\t:target_action => 'set_drops_to_counts',\n\t\t\t\t:id_column => 'id'}}\n\n\telse\n\t column_configs[column_configs.length()] = {:field_type => 'action',:field_name => 'edit drops', :col_width => 112,\n\t\t\t:settings =>\n\t\t\t\t {:link_text => 'view drops allocation',\n\t\t\t\t:target_action => 'view_drops_to_counts',\n\t\t\t\t:id_column => 'id'}}\n\n\tend\n\n return get_data_grid(data_set,column_configs,RunSetupPlugins::PackGroupGridPlugin.new)\n\nend",
"def render_gridlines_if_needed args\n if args.state.show_gridlines && args.static_lines.length == 0\n args.static_lines << 65.times.map do |i|\n [\n [CENTER_OFFSET + i * TINY_SCALE + 1, 0,\n CENTER_OFFSET + i * TINY_SCALE + 1, 720, 128, 128, 128],\n [CENTER_OFFSET + i * TINY_SCALE, 0,\n CENTER_OFFSET + i * TINY_SCALE, 720, 128, 128, 128],\n [CENTER_OFFSET, 0 + i * TINY_SCALE,\n CENTER_OFFSET + 720, 0 + i * TINY_SCALE, 128, 128, 128],\n [CENTER_OFFSET, 1 + i * TINY_SCALE,\n CENTER_OFFSET + 720, 1 + i * TINY_SCALE, 128, 128, 128]\n ]\n end\n elsif !args.state.show_gridlines\n args.static_lines.clear\n end\nend",
"def grid_role(grid: grid_role?)\n grid ? 'grid' : 'table'\n end",
"def store_print_gridlines #:nodoc:\n record = 0x002b # Record identifier\n length = 0x0002 # Bytes to follow\n\n fPrintGrid = @print_gridlines # Boolean flag\n\n header = [record, length].pack(\"vv\")\n data = [fPrintGrid].pack(\"v\")\n\n prepend(header, data)\n end",
"def render_grid_lines\n outputs.lines << (0..grid.width).map { |x| vertical_line(x) }\n outputs.lines << (0..grid.height).map { |y| horizontal_line(y) }\n end",
"def mapGridPosition _args\n \"mapGridPosition _args;\" \n end",
"def start_grid\n Array.new(@lines) { Array.new(@columns) { Cell.new } }\n end",
"def grid\n @grid ||=\n {\n rows: lines_to_ranges(lines[:horizontal]),\n columns: lines_to_ranges(lines[:vertical])\n }\n end",
"def grid3d(*)\n super\n end",
"def index\n set_product_risk_plans_grid\n end",
"def print_grid\n rows = @grid.map do |row|\n row.join(\" \")\n end\n print rows.join(\"\\n\")\n end",
"def build_cartons_grid(data_set, is_multi_select = nil)\n\n column_configs = Array.new\n\n\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'carton_number', :col_width => 120}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'pallet_number', :col_width => 150}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'rw_receipt_unit'} if is_multi_select\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'production_run_code', :col_width => 158}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'fg_product_code', :col_width => 294}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'fg_mark_code', :col_width => 170}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => \"attributes['farm_code']\", :column_caption => \"farm_code\", :col_width => 76}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'puc', :col_width => 76}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'fg_code_old', :col_width => 161}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'organization_code', :col_width => 40}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'grade_code', :col_width => 40}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'inventory_code', :col_width => 140}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'target_market_code', :col_width => 130}\n\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'extended_fg_code', :col_width => 516}\n\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => \"attributes['line_code']\", :column_caption => \"line_code\", :col_width => 47}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'order_number', :col_width => 150}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'pack_date_time', :col_width => 162}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'pick_reference', :col_width => 56}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'is_inspection_carton', :col_width => 45}\n\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'carton_fruit_nett_mass', :col_width => 60,:column_caption => 'mass'}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'id'}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'bin_id'}\n\n if !@multi_select\n column_configs[column_configs.length()] = {:field_type => 'action', :field_name => 'carton',\n :settings =>\n {:link_text => 'view_carton',\n :target_action => 'view_carton',\n :id_column => 'id'}}\n end\n\n\n key_based_access = true\n key_based_access = @key_based_access if @key_based_access\n\n\n return get_data_grid(data_set, column_configs, nil, key_based_access)\n\n end",
"def render_grid\n\t\t@grid_w.times.with_index do |x|\n\t\t\t@grid_h.times.with_index do |y|\n\t\t\t\tif !@has_enviroment_rendered\n \t \t\trender_wall x, y if @grid[x][y]==1\n\t\t\t\tend\n\t\t \trender_player x, y if @grid[x][y]==2\n \tend\n end\n #each_cell do |x, y, v|\n # render_wall x, y if !@has_environment_rendered && v == 1 \n # render_player x, y if v == 2\n #end\n\t\t@has_enviroment_rendered = true\n\tend",
"def test_that_grid_generation_is_accurate\n end",
"def grid_header_rows\n 1\n end",
"def grid_page_size\n GRID_PAGE_SIZE\n end",
"def gridhelper ()\n $helper = \"\"\n $g = 0\n items = MEASURES\n $LEN = items.length\n $parsed = 0\n\n until $g == $LEN\n $TYPE = items[$g]['TYPE']\n if $g == 0\n $NAME = \"default\"\n else\n $NAME = \"$bp-\" + items[$g]['NAME']\n end\n $FROM = items[$g]['FROM']\n $COLS = items[$g]['COLS']\n $FLUID = items[$g]['FLUID']\n $RATIOPREGOLDEN = items[$g]['RATIOPREGOLDEN']\n $GOLDEN = items[$g]['GOLDEN']\n $RATIO = $RATIOPREGOLDEN * $GOLDEN\n $COLW = items[$g]['COLW']\n $GUTW = items[$g]['GUTW']\n $MAXW = items[$g]['MAXW']\n $COLBG = items[$g]['COLBG']\n\n \n if $TYPE == \"grid_bp\"\n $helper += \"\\n/* %s GRID */\" % [$NAME]\n $helper += \"\\n@media (min-width: #$FROM){\"\n if $FLUID == \"f\" || $FLUID == \"F\"\n $HALW = \"cal(-#$MAXW/2)\"\n $GUTW = \"cal(100%/(#$COLS+(#$COLS*#$RATIO)))\"\n $MRGW = \"cal(50%/(#$COLS+(#$COLS*#$RATIO)))\"\n $COLW = \"cal(100%*#$RATIO/(#$COLS+(#$COLS*#$RATIO)))\" \n\n else \n $HALW = \"cal(-#$COLS/2*(#$COLW+#$GUTW))\"\n $MAXW = \"cal(#$COLS*(#$COLW+#$GUTW))\"\n $MRGW = \"cal(#$GUTW/2)\"\n end\n $helper += \"\n #grid {\n margin-left: #$HALW;\n max-width: #$MAXW; \n }\n #grid div.vert {\n background: #$COLBG;\n width: #$COLW;\n margin: 0 #$MRGW;\n }\n #grid div.vert.first-line {\n margin-left: #$MRGW;\n }\n #grid div.vert.cols#$COLS { /* this grid uses #$COLS cols */\n margin-right: 0;\n }\n \"\n if $parsed > 0\n $target = $parsed - 1\n $PREVCOLS = getPreviousGridCols ( $target )\n\n $helper += \"\n #grid div.vert.cols#$PREVCOLS { /* reset previous #$PREVCOLS cols grid */\n margin-right: #$MRGW;\n }\n \"\n end\n $helper += \"\\n}\"\n\n $parsed += 1\n else\n if $FLUID == \"f\" || $FLUID == \"F\"\n $HALW = \"cal(-#$MAXW/2)\"\n\n else\n $HALW = \"cal(-#$COLS/2*(#$COLW+#$GUTW))\"\n $MAXW = \"cal(#$COLS*(#$COLW+#$GUTW))\"\n end\n $helper += \"\n /* extra breakpoint */\n @media (min-width: #$FROM){\n #grid {\n margin-left: #$HALW;\n max-width: #$MAXW; \n }\n #grid div.vert {\n background: #$COLBG;\n }\n }\n \"\n end\n $g += 1\n end\n\nreturn $helper\nend",
"def initialize(grid = Board.default_grid)\n @grid = grid\n end",
"def cheat\n Board.print_grid(@grid)\n end",
"def grid\n handle_date\n @pool = Pool.find(params[:pool_id])\n end",
"def render_grid_lines\n outputs.lines << (0..grid.width).map { |x| vertical_line(x) }\n outputs.lines << (0..grid.width).map { |x| shifted_vertical_line(x) }\n outputs.lines << (0..grid.height).map { |y| horizontal_line(y) }\n outputs.lines << (0..grid.height).map { |y| shifted_horizontal_line(y) }\n end",
"def grid_params\n params.require(:grid).permit(:difficulty, :nationality, :user_id)\n end",
"def default_grid\n Array.new(7) { Array.new(6) { Cell.new } }\n end",
"def grid\n\t\t@gridTitle = \"Subscriber Listings\"\n\t\t@searchPlaceholder = \"Search for Subscribers\"\n\t\tslim :grid, :layout => false\n\tend",
"def index\n set_risk_plan_operations_grid\n end",
"def p11\n\tgrid = Matrix[\n\t\t[8,\t2, 22,97,38,15,0, 40,0, 75,4, 5, 7, 78,52,12,50,77,91,8],\n\t\t[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,4, 56,62,0],\n\t\t[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,3, 49,13,36,65],\n\t\t[52,70,95,23,4, 60,11,42,69,24,68,56,1, 32,56,71,37,2, 36,91],\n\t\t[22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80],\n\t\t[24,47,32,60,99,3, 45,2, 44,75,33,53,78,36,84,20,35,17,12,50],\n\t\t[32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70],\n\t\t[67,26,20,68,2, 62,12,20,95,63,94,39,63,8, 40,91,66,49,94,21],\n\t\t[24,55,58,5, 66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72],\n\t\t[21,36,23,9, 75,0, 76,44,20,45,35,14,0, 61,33,97,34,31,33,95],\n\t\t[78,17,53,28,22,75,31,67,15,94,3, 80,4, 62,16,14,9, 53,56,92],\n\t\t[16,39,5, 42,96,35,31,47,55,58,88,24,0, 17,54,24,36,29,85,57],\n\t\t[86,56,0, 48,35,71,89,7, 5, 44,44,37,44,60,21,58,51,54,17,58],\n\t\t[19,80,81,68,5, 94,47,69,28,73,92,13,86,52,17,77,4, 89,55,40],\n\t\t[4,\t52,8, 83,97,35,99,16,7, 97,57,32,16,26,26,79,33,27,98,66],\n\t\t[88,36,68,87,57,62,20,72,3, 46,33,67,46,55,12,32,63,93,53,69],\n\t\t[4,\t42,16,73,38,25,39,11,24,94,72,18,8, 46,29,32,40,62,76,36],\n\t\t[20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,4, 36,16],\n\t\t[20,73,35,29,78,31,90,1, 74,31,49,71,48,86,81,16,23,57,5, 54],\n\t\t[1,\t70,54,71,83,51,54,69,16,92,33,48,61,43,52,1, 89,19,67,48]\n\t]\n\tproducts = []\n\t(0...grid.row_count).each do |row|\n\t\t(0...grid.column_count).each do |col|\n\t\t\tright = col + 3 < grid.row_count\n\t\t\tdown = row + 3 < grid.column_count\n\t\t\tleft = col - 3 >= 0\n\t\t\tif right\n\t\t\t\tset = grid.minor(row..row,col..col+3)\n\t\t\t\tproducts << set.reduce(:*)\n\t\t\tend\n\t\t\tif down and right\n\t\t\t\tdiagonal = []\n\t\t\t\t(0..3).each do |x|\n\t\t\t\t\tdiagonal << grid.minor(row+x..row+x,col+x..col+x).component(0,0)\n\t\t\t\tend\n\t\t\t\tproducts << diagonal.reduce(:*)\n\t\t\tend\n\t\t\tif down\n\t\t\t\tset = grid.minor(row..row+3,col..col)\n\t\t\t\tproducts << set.reduce(:*)\n\t\t\tend\n\t\t\tif down and left\n\t\t\t\tdiagonal = []\n\t\t\t\t(0..3).each do |x|\n\t\t\t\t\tdiagonal << grid.minor(row+x..row+x,col-x..col-x).component(0,0)\n\t\t\t\tend\n\t\t\t\tproducts << diagonal.reduce(:*)\n\t\t\tend\n\t\tend\n\tend\n\tproducts.max\nend",
"def free_form_grid(rows, cols, grid_pov=nil)\n # Make sure we are attached to a cube\n check_attached\n get_dimensions unless @dimensions\n\n # Update the POV if one is specified\n if grid_pov\n self.pov = grid_pov\n end\n\n grid = Grid.define(@dimensions, pov, rows, cols)\n\n @logger.info \"Retrieving free-form grid\"\n @req.ProcessFreeFormGrid do |xml|\n xml.sID @session_id\n @preferences.inject_xml xml, @provider_type\n xml.backgroundpov do |xml|\n pov.each do |dim,mbr|\n xml.dim :name => dim, :pov => mbr\n end\n end\n grid.to_xml(xml, false)\n grid.dims_to_xml(xml)\n end\n doc = invoke\n grid = Grid.from_xml(doc)\n\n # The grid returned does not contain data, so perform a refresh\n refresh(grid)\n end",
"def show\n @treinos_grid = initialize_grid(@aluno.treinos)\n end",
"def prepare_grid\n\t\tArray.new(rows) do |row|\n\t\t\tArray.new(columns) do |col|\n\t\t\t\tCell.new(row, col)\n\t\t\tend\n\t\tend\n\tend",
"def grid_obj?\n return (@node_type == :lasgn and [email protected] {|s| s.node_type == :call and !s.sons.select {|ss| ss.node_type == :const and ss.name == \"GObj\"}.empty? }.empty?)\n end",
"def enabled_all?; end",
"def set_board_pin_mode\n\n @axis_x.set_pin_mode()\n @axis_y.set_pin_mode()\n @axis_z.set_pin_mode()\n\n end",
"def default_grid\n Array.new(3) { Array.new(3) {Cell.new} }\n end",
"def initialize\n\t\t@grid = Array.new(10){Array.new(10)}\n\tend",
"def grid_css_class\n \"#{grid_row_model_type}-grid\"\n end",
"def create_grid\n grid = Array.new(6, Array.new(7, BLANK))\n end",
"def index\n \t @company_import_log_grid = initialize_grid(CompanyImportLog, \n order:'id', \n order_direction: 'desc')\n end",
"def create_grid\n @grid = {\"1a\" => \" \", \"1b\" => \" \", \"1c\" => \" \", \"1d\" => \" \", \"1e\" => \" \",\n \"2a\" => \" \", \"2b\" => \" \", \"2c\" => \" \", \"2d\" => \" \", \"2e\" => \" \",\n \"3a\" => \" \", \"3b\" => \" \", \"3c\" => \" \", \"3d\" => \" \", \"3e\" => \" \",\n \"4a\" => \" \", \"4b\" => \" \", \"4c\" => \" \", \"4d\" => \" \", \"4e\" => \" \",\n \"5a\" => \" \", \"5b\" => \" \", \"5c\" => \" \", \"5d\" => \" \", \"5e\" => \" \"}\n end",
"def mouse_over_grid?\n inputs.mouse.point.inside_rect?(scale_up(grid.rect))\n end",
"def PrintGrid\n\t\t(0..9).each do |i| #vertical parent grid\n\t\t\t(0..19).each do |j| #horizontal nested array\n\t\t\t\tprint @user_grid[i][j]\n\t\t\tend\n\t\tputs\n\t\tend\n\t\treturn @user_grid\n\tend",
"def jq_grid(grid)\n output = jqgrid_html(grid)\n output << jqgrid_js(grid)\n if grid.detached_javascript.present?\n output << javascript_tag{ \"jQuery(document).ready(function(){ #{grid.detached_javascript.join(\"\\n\")}});\".html_safe }\n end\n output.html_safe\n end",
"def initialize_grid_from_node(node)\n boxes_zone = node.boxes_zone\n goals_zone = node.goals_zone\n pusher_zone = node.pusher_zone\n level = node.level\n\n @rows = level.rows\n @cols = level.cols\n @name = level.name\n @copyright = level.copyright\n\n pos = 0\n pusher_flag = false\n @grid = level.grid.collect do |cell|\n # Only keep empty spaces\n if ['@', '$', '*', '+'].include? cell\n new_cell = 's'\n else\n new_cell = cell\n end\n\n if @inside_cells.include? new_cell\n # Place goals from zone\n if goals_zone.bit_1?(pos)\n new_cell = '.'\n end\n\n # Place boxes from zone\n if boxes_zone.bit_1?(pos)\n new_cell = new_cell == '.' ? '*' : '$'\n # Place pusher from zone\n elsif !pusher_flag && pusher_zone.bit_1?(pos)\n new_cell = new_cell == '.' ? '+' : '@'\n pusher_flag = true\n end\n\n pos += 1\n end\n\n new_cell\n end\n end",
"def populate_grid_data\n logger.debug \"populate_grid_data ->\"\n @insurance_eobs_saved ||= @check_information.insurance_payment_eobs.exists? if !@orbograph_correspondence_condition\n @patient_pay_eobs_saved ||= @check_information.patient_pay_eobs.exists?\n if @insurance_eobs_saved.blank? and @patient_pay_eobs_saved.blank?\n if @job.split_parent_job_id.blank?\n @check_information.index_file_check_amount = @check_information.check_amount\n @check_information.save\n end\n end\n @hide_adj_line = @insurance_pay\n if @hide_adj_line || @mpi_service_line.blank?\n svc_lines = []\n svc_lines << ServicePaymentEob.new\n @service_line = svc_lines\n end\n\n @micr_line_information = @check_information.micr_line_information unless\n @facility.details[:micr_line_info].blank?\n @amount_so_far = InsurancePaymentEob.amount_so_far(@check_information, @facility)\n @facility_name = @facility.name\n if(@facility_name == 'METROHEALTH SYSTEM' || @facility_name == 'AVITA HEALTH SYSTEMS')\n @faciltiy_lockbox = FacilityLockboxMapping.find_by_lockbox_number_and_facility_id(@batch.lockbox,@facility.id)\n @facility_lock_box_npi = @faciltiy_lockbox.npi unless @faciltiy_lockbox.nil?\n @facility_lock_box_tin = @faciltiy_lockbox.tin unless @faciltiy_lockbox.nil?\n end\n if @check_information.payer\n @payer = @check_information.payer\n elsif @micr_line_information && @micr_line_information.payer\n @payer = @micr_line_information.payer\n end\n\n if [email protected]?\n @payer_name = @payer.payer\n @payer_type = @payer.payer_type\n @payer_address_one = @payer.pay_address_one\n @payer_address_two = @payer.pay_address_two\n @payer_city = @payer.payer_city\n @payer_state = @payer.payer_state\n @payer_zip = @payer.payer_zip\n @payer_id = @payer.id\n @payid = @payer.supply_payid\n @rc_set_name_id = @payer.reason_code_set_name_id\n @payer_indicator_hash, @default_payer_indicator = applicable_payer_indicator(@payid)\n else\n @payer_indicator_hash = {\"ALL\" => \"ALL\"}\n end\n if @facility.details[:payer_tin]\n if @payer && [email protected]_tin.blank?\n @payer_tin = @payer.payer_tin\n elsif [email protected]_tin.blank?\n @payer_tin = @job.payer_tin\n elsif @patient_pay\n @payer_tin = @facility.default_patpay_payer_tin unless @facility.default_patpay_payer_tin.blank?\n else\n @payer_tin = @facility.default_insurance_payer_tin unless @facility.default_insurance_payer_tin.blank?\n end\n end\n if @patient_837_information\n @organization = (@client_name.upcase.strip == 'UPMC' || @client_name.upcase.strip == 'UNIVERSITY OF PITTSBURGH MEDICAL CENTER') ? (@check_information.payee_name.blank? ? @patient_837_information.payee_name : @check_information.payee_name ) : (@patient_837_information.payee_name || @facility.name)\n else\n if (@check_information.insurance_payment_eobs.exists? && (@client_name.upcase.strip == 'UPMC' || @client_name.upcase.strip == 'UNIVERSITY OF PITTSBURGH MEDICAL CENTER'))\n @organization = @check_information.insurance_payment_eobs.first.provider_organisation\n else\n @organization = @facility.name unless (@client_name.upcase.strip == 'UPMC' || @client_name.upcase.strip == 'UNIVERSITY OF PITTSBURGH MEDICAL CENTER')\n end\n end\n if not @insurance_pay\n @claim_type_hash = {\"--\" => \"Primary\", \"Primary\" => \"Primary\", \"Secondary\" => \"Secondary\", \"Tertiary\" => \"Tertiary\" }\n else\n @claim_type_hash = {\"--\" => \"--\", \"Primary\" => \"Primary\", \"Secondary\" => \"Secondary\", \"Tertiary\" => \"Tertiary\",\n \"Denial\" => \"Denial\", \"RPP\" => \"Reversal of Prior payment\",\n \"PPO - No Payment\" => \"Predetermination Pricing Only - No Payment\",\n \"FAP\" => \"Processed as Primary - FAP\" }\n end\n @payment_type_items = ['', 'Money Order', 'Check']\n # HLSC Requirement\n # @payment_type_items = ['']\n # Exclude CHK from the dropdown box if the check type is correspondence\n # @payment_type_items << 'CHK' unless @check_information.correspondence?\n # @payment_type_items.concat(['EOB', 'HIP', 'PAY'])\n\n @job_payment_so_far = @check_information.total_payment_amount.to_f\n @transaction_type_hash = {\"Complete EOB\" => \"Complete EOB\",\n \"Missing Check\" => \"Missing Check\", \"Check Only\" => \"Check Only\", \"Correspondence\" => \"Correspondence\"}\n # The '@transaction_type_selection_value' holds the default seletion value of 'transaction_type'\n @transaction_type_selection_value = \"Complete EOB\"\n # The '@job_payment_so_far' holds the the total payment for this check\n if @job_payment_so_far.zero?\n @transaction_type_possible_value = \"Complete EOB\"\n else\n @transaction_type_possible_value = \"Missing Check\"\n end\n @hash_for_payee_type_format = {'' => nil, 'A' => 'A', 'B' => 'B', 'C' => 'C'}\n @hash_for_patpay_statement_fields = {'' => nil, 'Yes' => true, 'No' => false}\n @hash_for_statement_receiver = {'' => nil, 'Hospital' => 'Hospital', 'Physician' => 'Physician'}\n @show_patpay_statement_fields = (@facility.details[:patpay_statement_fields] &&\n @patient_pay)\n @twice_keying_fields = TwiceKeyingField.get_all_twice_keying_fields(@batch.client_id, @batch.facility_id, current_user.id, @rc_set_name_id)\n @allow_special_characters = @facility.details[:patient_account_number_hyphen_format]\n logger.debug \"<- populate_grid_data\"\n\n end",
"def in_grid?(col, row)\n col.between?(0, COLUMNS - 1) && row.between?(0, ROWS - 1)\n end",
"def grid_mode?(items)\n # more than one question is needed for grid mode\n false unless items.size > 1\n\n items.all? do |i|\n i.is_a?(Questioning) &&\n i.qtype_name == 'select_one' &&\n i.option_set == items[0].option_set &&\n !i.multi_level?\n end\n end",
"def init_white_panel!\n grid.cells[grid.pos] = 1\n end",
"def grid(options = {}, &block)\n Grid.new({ parent: self }.merge!(options), &block)\n end",
"def print_grid\n @grid.each do |arr|\n puts arr.join(\" \")\n end\n end",
"def default_grid\n Array.new(7) { Array.new(6) { CellNode.new }}\n end",
"def print_grid\n self.print_head\n puts $line_break\n i = 0\n grid.each do |row|\n printable_row = []\n row.each do |cell|\n printable_row << cell[:display]\n end\n row_string = printable_row.join(\" | \")\n puts \"## #{$abc[i].upcase} #{row_string} ##\"\n # puts \"## #{row_string} ##\"\n puts \"##\" + \"------\" + \"+----\" * 9 + \"##\"\n i += 1\n end\n bottom_row = []\n l = 0\n 10.times do\n bottom_row << \" #{l} \"\n l += 1\n end\n print_row = bottom_row.join(\"|\")\n puts \"## #{print_row}##\"\n puts $line_break\n end",
"def jqgrid_properties\n vals = {}\n \n # data and request options\n vals['url'] = url if url\n vals['restful'] = true if restful\n vals['postData'] = { :grid => name } #identify which grid making the request\n # vals['colNames'] = column_names if columns.present?\n vals['colModel'] = column_model if columns.present?\n vals['datatype'] = data_type if data_type\n if data_format.present?\n if data_type == :xml\n vals['xmlReader'] = data_format\n elsif data_type == :json\n vals['jsonReader'] = data_format\n end\n end\n \n vals['loadonce'] = load_once if load_once\n\n vals['sortname'] = sort_by if sort_by\n vals['sortorder'] = sort_order if sort_order && sort_by\n vals['rowNum'] = rows_per_page if rows_per_page\n vals['page'] = current_page if current_page\n\n # grid options\n vals['height'] = height if height\n vals['gridview'] = true # faster views, NOTE theres cases when this needs to be disabled\n \n case width_fit\n when :fitted\n #vals[:autowidth] = false #default\n #vals[:shrinkToFit] = true #default\n vals['forceFit'] = true\n vals['width'] = width if width\n \n when :scroll\n #vals[:autowidth] = false #default\n vals['shrinkToFit'] = false\n #vals['forceFit'] = #ignored by jqGrid\n vals['width'] = width if width\n \n else #when :fluid\n vals['autowidth'] = true\n #vals['shrinkToFit'] = true #default\n vals['forceFit'] = true\n #vals['width'] = is ignored\n vals['resizeStop'] = 'javascript: gridify_fluid_recalc_width'\n end\n \n vals['sortable'] = true if arranger_type.include?(:sortable)\n \n # header layer\n vals['caption'] = title if title\n vals['hidegrid'] = false unless collapsible\n vals['hiddengrid'] = true if collapsed\n \n # row formatting\n vals['altrows'] = true if alt_rows\n vals['altclass'] = alt_rows if alt_rows.is_a?(String)\n \n vals['rowNumbers'] = true if row_numbers\n vals['rownumWidth'] = row_numbers if row_numbers.is_a?(Numeric)\n \n if select_rows.present?\n vals['scrollrows'] = true\n #handler...\n else\n vals['hoverrows'] = false\n vals['beforeSelectRow'] = \"javascript: function(){ false; }\"\n end\n \n # pager layer\n if pager\n vals['pager'] = \"##{pager}\" \n vals['viewrecords'] = true # display total records in the query (eg \"1 - 10 of 25\")\n vals['rowList'] = paging_choices\n if paging_controls.is_a?(Hash)\n # allow override of jqGrid pager options\n vals.merge!(paging_controls)\n elsif !paging_controls\n vals['rowList'] = []\n vals['pgbuttons'] = false\n vals['pginput'] = false\n vals['recordtext'] = \"{2} records\"\n end\n end\n \n # allow override of native jqGrid options\n vals.merge(jqgrid_options)\n end",
"def populateGrid\n\n\t\[email protected]_with_index do | row, i |\n\n\t\t\trow.each_with_index do | col, j |\n\n\t\t\t\[email protected][i][j] = Cell.new(i, j, false)\n\t\t\tend\n\t\tend\n\tend",
"def grids\n [grid].compact\n end",
"def set_question_grid\n @question_grid = QuestionGrid.find(params[:id])\n end",
"def jqgrid\n\n\tend",
"def gp_flags; end",
"def mouse_inside_grid?\n inputs.mouse.point.inside_rect?(scale_up(grid.rect))\n end",
"def quick_gridlayout(how, what)\n QuickGridLayout.new(self, how, what, parent_widget, window_id, :gridlayout)\n end",
"def store_gridset #:nodoc:\n record = 0x0082 # Record identifier\n length = 0x0002 # Bytes to follow\n\n fGridSet = @print_gridlines == 0 ? 1 : 0 # Boolean flag\n\n header = [record, length].pack(\"vv\")\n data = [fGridSet].pack(\"v\")\n\n prepend(header, data)\n end",
"def print_grid\n @grid.each do |row|\n row.each do |cell|\n if cell == 'X'\n print(cell.red)\n else\n print(cell)\n end\n end\n print(\"\\n\")\n end\n end",
"def test_solve_hard_grid\n log \"running hard grid\"\n grid = Grid::load(\"grids/hard_grid.txt\")\n grid.solve\n log \"solved grid:\"\n log grid.to_s\n end",
"def grid_row_skipped_columns\n row_skipped_columns\n end"
] | [
"0.6275129",
"0.62216455",
"0.6181977",
"0.61113",
"0.607926",
"0.60341907",
"0.6025261",
"0.6024623",
"0.60153353",
"0.60153353",
"0.5923404",
"0.59128314",
"0.57938933",
"0.5710799",
"0.5709018",
"0.5677611",
"0.5651054",
"0.5646655",
"0.5627494",
"0.56239116",
"0.5586932",
"0.55865556",
"0.5557433",
"0.5546547",
"0.5520401",
"0.5519296",
"0.5502406",
"0.55000126",
"0.54882044",
"0.54882044",
"0.54858303",
"0.5467102",
"0.5460439",
"0.54604274",
"0.5424518",
"0.5424184",
"0.54237914",
"0.541304",
"0.5406237",
"0.53979254",
"0.539524",
"0.5363859",
"0.53549284",
"0.53351456",
"0.5329824",
"0.532242",
"0.5309802",
"0.52985895",
"0.529601",
"0.5253202",
"0.52498883",
"0.52490306",
"0.5238278",
"0.522943",
"0.5218177",
"0.5217603",
"0.52142596",
"0.52091235",
"0.51947546",
"0.51877874",
"0.5180425",
"0.51799995",
"0.5174483",
"0.5172481",
"0.51540375",
"0.5152689",
"0.51512194",
"0.5148659",
"0.5137438",
"0.51350653",
"0.51302034",
"0.51287234",
"0.51214516",
"0.5115067",
"0.510808",
"0.5102474",
"0.5097748",
"0.5094484",
"0.5093988",
"0.5074571",
"0.50715697",
"0.5053258",
"0.5045204",
"0.50427794",
"0.5041959",
"0.5041638",
"0.50373256",
"0.5034836",
"0.5034349",
"0.5029062",
"0.50286335",
"0.5028196",
"0.5026763",
"0.5022615",
"0.5022101",
"0.5020672",
"0.5005607",
"0.50005955",
"0.4993329",
"0.49882054"
] | 0.8503345 | 0 |
TODO: SCAL936 enable/disable PLGrid | def basicauth_enabled?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plgrid_enabled?\n true\n end",
"def grid; @parameters['GRiD']; end",
"def grid_modified!\n end",
"def toggle_grid\n if @show_grid\n self.show_grid = false\n else\n self.show_grid = true\n end\n end",
"def build_voyage_port_grid(data_set,can_edit,can_delete)\n column_configs = Array.new\n\n if can_edit\n #if session[:edit_voyage]==true\n column_configs << {:field_type => 'link_window', :field_name => 'edit',\n :settings =>\n {:link_text => 'edit ',\n :target_action => 'edit_voyage_port_from_popup',\n :id_column => 'id'}}\n\n #end\nend\n\tif can_delete\n #if session[:edit_voyage]==true\n\t\tcolumn_configs << {:field_type => 'action',:field_name => 'delete ',\n\t\t\t:settings =>\n\t\t\t\t {:link_text => 'delete ',\n\t\t\t\t:target_action => 'delete_voyage_port',\n\t\t\t\t:id_column => 'id'}}\n #end\n end\n\n column_configs << {:field_type => 'text',:field_name => 'port_type_code'}\n column_configs << {:field_type => 'text',:field_name => 'port_code'}\n column_configs << {:field_type => 'text',:field_name => 'quay'}\n column_configs << {:field_type => 'text',:field_name => 'departure_date'}\n column_configs << {:field_type => 'text',:field_name => 'arrival_date'}\n column_configs << {:field_type => 'text',:field_name => 'departure_open_stack'}\n column_configs << {:field_type => 'text',:field_name => 'departure_close_stack'}\n\n\n set_grid_min_height(150)\n set_grid_min_width(850)\n hide_grid_client_controls()\nreturn get_data_grid(data_set,column_configs,nil,true)\nend",
"def gridpoints\n gridpoints = {'l' => @ngauss, 'e' => @negrid, 's' => @nspec}\n if @grid_option == \"single\"\n gridpoints.absorb({'x'=>1, 'y'=>1})\n else\n gridpoints.absorb({'x' => (@ntheta0 or (2.0 * (@nx - 1.0) / 3.0 + 1.0).floor), 'y' => (@naky or ((@ny - 1.0) / 3.0 + 1.0).floor)})\n end\n return gridpoints\nend",
"def toggle\n\t\t@gridOn = !@gridOn\n\tend",
"def grid\n @grid ||= if @opts.key? \"grid\"\n @opts.slice(\"grid\", \",\")\n else\n %w[0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%]\n end\n end",
"def grid_role?\n true\n end",
"def grid\n state.grid\n end",
"def grid\n state.grid\n end",
"def grid\n @grid ||= {}\nend",
"def grid(index)\r\n out_short_name = FFI::MemoryPointer.new(:string)\r\n out_full_name = FFI::MemoryPointer.new(:string)\r\n out_package_name = FFI::MemoryPointer.new(:string)\r\n out_url = FFI::MemoryPointer.new(:string)\r\n out_direct_download = FFI::MemoryPointer.new(:int)\r\n out_open_license = FFI::MemoryPointer.new(:int)\r\n out_available = FFI::MemoryPointer.new(:int)\r\n\r\n result = Api.proj_coordoperation_get_grid_used(self.context, self, index,\r\n out_short_name, out_full_name, out_package_name,\r\n out_url, out_direct_download ,\r\n out_open_license, out_available)\r\n\r\n if result != 1\r\n Error.check_object(self)\r\n end\r\n\r\n name_ptr = out_short_name.read_pointer\r\n full_name_ptr = out_full_name.read_pointer\r\n package_name_ptr = out_package_name.read_pointer\r\n url_ptr = out_url.read_pointer\r\n downloadable_ptr = out_direct_download \r\n open_license_ptr = out_open_license\r\n available_ptr = out_available\r\n\r\n unless name_ptr.null?\r\n Grid.new(name_ptr.read_string_to_null, self.context,\r\n full_name: full_name_ptr.null? ? nil : full_name_ptr.read_string_to_null,\r\n package_name: package_name_ptr.null? ? nil : package_name_ptr.read_string_to_null,\r\n url: url_ptr.null? ? nil : url_ptr.read_string_to_null,\r\n downloadable: downloadable_ptr.null? ? nil : downloadable_ptr.read_int == 1 ? true : false,\r\n open_license: open_license_ptr.null? ? nil : open_license_ptr.read_int == 1 ? true : false,\r\n available: available_ptr.null? ? nil : available_ptr.read_int == 1 ? true : false)\r\n end\r\n end",
"def grid(*)\n super\n end",
"def setup_grid(skip_render, skip_set_pieces)\n @grid = Array.new(8) { Array.new(8) { EmptySquare.new } }\n unless skip_set_pieces\n set_major_minor\n set_pawns\n end\n\n render unless skip_render\n end",
"def setTerrainGrid _args\n \"setTerrainGrid _args;\" \n end",
"def drawXZGrid\n\t\tif !@gridOn then return end\n\t\tglDisable(GL_LIGHTING)\n\t\tglBegin(GL_LINES)\n\t\tglColor(@gridColorXZ)\n\t\tfor i in (-@gridLines..@gridLines)\n\t\t\t# Draw two lines for each iteration\n\t\t\tglVertex( i*@gridSpacing, 0.0, -(@gridLines*@gridSpacing))\n\t\t\tglVertex( i*@gridSpacing, 0.0, (@gridLines*@gridSpacing))\n\t\t\tglVertex( -(@gridLines*@gridSpacing), 0.0, i*@gridSpacing)\n\t\t\tglVertex( (@gridLines*@gridSpacing), 0.0, i*@gridSpacing)\n\t\tend\n\t\tglEnd\n\t\tglEnable(GL_LIGHTING)\n\tend",
"def initialize()\n\t\t@gridColorXZ = [1.0, 0.0, 0.0, 0.0] #Red\n\t\t@gridColorXY = [1.0, 1.0, 0.0, 0.0] #Yellow\n\t\t@gridColorYZ = [0.0, 0.0, 1.0, 0.0] #Blue\n\t\t@gridLines = 10 # The number of lines in HALF the grid (just to make counting easier)\n\t\t@gridSpacing = 5.0\n\t\t@gridOn = true\n\tend",
"def grid(name)\r\n out_full_name = FFI::MemoryPointer.new(:string)\r\n out_package_name = FFI::MemoryPointer.new(:string)\r\n out_url = FFI::MemoryPointer.new(:string)\r\n out_downloadable = FFI::MemoryPointer.new(:int)\r\n out_open_license = FFI::MemoryPointer.new(:int)\r\n out_available = FFI::MemoryPointer.new(:int)\r\n\r\n result = Api.proj_grid_get_info_from_database(self.context, name,\r\n out_full_name, out_package_name, out_url,\r\n out_downloadable, out_open_license, out_available)\r\n\r\n if result == 1\r\n full_name_ptr = out_full_name.read_pointer\r\n package_name_ptr = out_package_name.read_pointer\r\n url_ptr = out_url.read_pointer\r\n\r\n downloadable_ptr = out_downloadable\r\n open_license_ptr = out_open_license\r\n available_ptr = out_available\r\n\r\n full_name = full_name_ptr.read_string_to_null\r\n package_name = package_name_ptr.read_string_to_null\r\n url = url_ptr.read_string_to_null\r\n\r\n downloadable = downloadable_ptr.read_int == 1 ? true : false\r\n open_license = open_license_ptr.read_int == 1 ? true : false\r\n available = available_ptr.read_int == 1 ? true : false\r\n\r\n Grid.new(name, self.context,\r\n full_name: full_name, package_name: package_name,\r\n url: url ? URI(url) : nil,\r\n downloadable: downloadable, open_license: open_license, available: available)\r\n else\r\n Error.check_context(self.context)\r\n end\r\n end",
"def add_grid(grid)\n add_post_command(grid)\n end",
"def build_pack_materials_grid(data_set,can_create_run)\n\n\n\n column_configs = Array.new\n\n\tcolumn_configs[0] = {:field_type => 'text',:field_name => 'retail_item_pack_material_code'}\n\tcolumn_configs[1] = {:field_type => 'text',:field_name => 'retail_unit_pack_material_code'}\n\tcolumn_configs[2] = {:field_type => 'text',:field_name => 'trade_unit_pack_material_code'}\n\tcolumn_configs[3] = {:field_type => 'text',:field_name => 'pallet_pack_material_code'}\n\tcolumn_configs[4] = {:field_type => 'text',:field_name => 'fg_product_code'}\n\tcolumn_configs[5] = {:field_type => 'text',:field_name => 'carton_setup_code'}\n\tcolumn_configs[6] = {:field_type => 'text',:field_name => 'created_at'}\n\n\n\n return get_data_grid(data_set,column_configs)\nend",
"def display_grid\n # variables for grid display\n @grid = \" A B C \\n\" \\\n \"1 #{@a1} | #{@b1} | #{@c1} \\n\" \\\n \" ---+---+--- \\n\" \\\n \"2 #{@a2} | #{@b2} | #{@c2} \\n\" \\\n \" ---+---+--- \\n\" \\\n \"3 #{@a3} | #{@b3} | #{@c3} \\n\"\n end",
"def hide_gridlines(option = 1)\n if option == 0\n @print_gridlines = 1 # 1 = display, 0 = hide\n @screen_gridlines = 1\n elsif option == 1\n @print_gridlines = 0\n @screen_gridlines = 1\n else\n @print_gridlines = 0\n @screen_gridlines = 0\n end\n end",
"def drawAll\n\t\tif !@gridOn then return end\n\t\tself.drawXYGrid\n\t\tself.drawXZGrid\n\t\tself.drawYZGrid\n\tend",
"def show_grid=(value)\n old = @show_grid\n @show_grid = value\n if old != @show_grid\n @array.each do |tile|\n if @show_grid\n if !tile.sprites[999]\n tile.sprites[999] = Sprite.new($visuals.viewport, {special: true})\n tile.sprites[999].set_bitmap(GRIDBITMAP)\n tile.sprites[999].x = tile.sprites[0].x\n tile.sprites[999].y = tile.sprites[0].y\n tile.sprites[999].z = 999\n end\n else\n if tile.sprites[999]\n tile.sprites[999].dispose\n tile.sprites.delete(999)\n end\n end\n end\n end\n end",
"def drawYZGrid\n\t\tif !@gridOn then return end\n\t\tglDisable(GL_LIGHTING)\n\t\tglBegin(GL_LINES)\n\t\tglColor(@gridColorYZ)\n\t\tfor i in (-@gridLines..@gridLines)\n\t\t\t# Draw two lines for each iteration\n\t\t\tglVertex( 0.0, i*@gridSpacing, -(@gridLines*@gridSpacing))\n\t\t\tglVertex( 0.0, i*@gridSpacing, (@gridLines*@gridSpacing))\n\t\t\tglVertex( 0.0, -(@gridLines*@gridSpacing), i*@gridSpacing)\n\t\t\tglVertex( 0.0, (@gridLines*@gridSpacing), i*@gridSpacing)\n\t\tend\n\t\tglEnd\n\t\tglEnable(GL_LIGHTING)\n\tend",
"def grids\n @grids ||= {}\n end",
"def initialize(grid=empty_grid)\n @grid = grid\n end",
"def set_grid\n @grid = Grid.find(params[:id])\n end",
"def set_grid\n @grid = Grid.find(params[:id])\n end",
"def set_grid\n @grid = Grid.find(params[:id])\n end",
"def setup_grid\n empty_rows\n [:white, :light_yellow].each do |color|\n back_rows(color)\n pawn_rows(color)\n end\n end",
"def build_grid\n x = 0\n 10.times do\n row = []\n y = 0\n 10.times do\n row.push({display: \"~~\", ship: false, coord: [x, y]})\n y += 1\n end\n self.grid << row\n x += 1\n end\n p self.grid\n end",
"def set_grid\n @grid = Grid.find(params[:id])\n end",
"def make_grid\n @grid = Array.new(4){Array.new(4)}\n end",
"def cell_flagger(row_num, col_num)\n\t\t@grid[row_num][col_num].flagger\n\tend",
"def grid *name_and_or_opts, &proc\n return unless configurable?\n name, opts = nil, Hash.new\n name_and_or_opts.each { |a| a.is_a?(Hash) ? opts.update(a) : name = a }\n id = Digest::MD5.hexdigest(name.to_s + proc.to_s)\n name ||= id\n if proc\n @grid, @grid_columns = name, 0\n self.instance_exec &proc\n @grid = nil\n end\n columns = opts.delete(:columns) || @grid_columns || 2\n grids[name] = Struct.new(:id, :name, :columns, :opts).new(id, name, columns, opts)\n end",
"def gridAltered\n if helpDisplayed?\n @textUI.updateLabel \"\"\n @helpCR[1]\n # Make the concerned cells normal\n @helpCR[1].each{ |cell|\n cellUi= @gridUi.cells[cell.row][cell.column]\n cellUi.normal\n }\n helpDisplayed=false\n end\n end",
"def setGridOnClick\n end",
"def build_pack_groups_grid(data_set,can_edit)\n\n\tcolumn_configs = Array.new\n\t require File.dirname(__FILE__) + \"/../../../app/helpers/production/run_setup_plugin.rb\"\n\n\tcolumn_configs[0] = {:field_type => 'text',:field_name => 'pack_group_number',:column_caption => 'group_num',:col_width => 85}\n\tcolumn_configs[1] = {:field_type => 'text',:field_name => 'production_run_number',:column_caption => 'run_num',:col_width => 85}\n\tcolumn_configs[2] = {:field_type => 'text',:field_name => 'production_schedule_name',:col_width => 233}\n\tcolumn_configs[3] = {:field_type => 'text',:field_name => 'commodity_code',:col_width => 65}\n\tcolumn_configs[4] = {:field_type => 'text',:field_name => 'marketing_variety_code',:col_width => 85,:column_caption => 'variety'}\n\tcolumn_configs[5] = {:field_type => 'text',:field_name => 'color_sort_percentage',:col_width => 60,:column_caption => '% color'}\n\tcolumn_configs[6] = {:field_type => 'text',:field_name => 'grade_code',:col_width => 65}\n\n#\t----------------------\n#\tdefine action columns\n#\t----------------------\n\tif can_edit\n\t\tcolumn_configs[column_configs.length()] = {:field_type => 'action',:field_name => 'edit drops', :col_width => 112,\n\t\t\t:settings =>\n\t\t\t\t {:link_text => 'set_drops_to_counts',\n\t\t\t\t:target_action => 'set_drops_to_counts',\n\t\t\t\t:id_column => 'id'}}\n\n\telse\n\t column_configs[column_configs.length()] = {:field_type => 'action',:field_name => 'edit drops', :col_width => 112,\n\t\t\t:settings =>\n\t\t\t\t {:link_text => 'view drops allocation',\n\t\t\t\t:target_action => 'view_drops_to_counts',\n\t\t\t\t:id_column => 'id'}}\n\n\tend\n\n return get_data_grid(data_set,column_configs,RunSetupPlugins::PackGroupGridPlugin.new)\n\nend",
"def render_gridlines_if_needed args\n if args.state.show_gridlines && args.static_lines.length == 0\n args.static_lines << 65.times.map do |i|\n [\n [CENTER_OFFSET + i * TINY_SCALE + 1, 0,\n CENTER_OFFSET + i * TINY_SCALE + 1, 720, 128, 128, 128],\n [CENTER_OFFSET + i * TINY_SCALE, 0,\n CENTER_OFFSET + i * TINY_SCALE, 720, 128, 128, 128],\n [CENTER_OFFSET, 0 + i * TINY_SCALE,\n CENTER_OFFSET + 720, 0 + i * TINY_SCALE, 128, 128, 128],\n [CENTER_OFFSET, 1 + i * TINY_SCALE,\n CENTER_OFFSET + 720, 1 + i * TINY_SCALE, 128, 128, 128]\n ]\n end\n elsif !args.state.show_gridlines\n args.static_lines.clear\n end\nend",
"def grid_role(grid: grid_role?)\n grid ? 'grid' : 'table'\n end",
"def store_print_gridlines #:nodoc:\n record = 0x002b # Record identifier\n length = 0x0002 # Bytes to follow\n\n fPrintGrid = @print_gridlines # Boolean flag\n\n header = [record, length].pack(\"vv\")\n data = [fPrintGrid].pack(\"v\")\n\n prepend(header, data)\n end",
"def render_grid_lines\n outputs.lines << (0..grid.width).map { |x| vertical_line(x) }\n outputs.lines << (0..grid.height).map { |y| horizontal_line(y) }\n end",
"def mapGridPosition _args\n \"mapGridPosition _args;\" \n end",
"def start_grid\n Array.new(@lines) { Array.new(@columns) { Cell.new } }\n end",
"def grid\n @grid ||=\n {\n rows: lines_to_ranges(lines[:horizontal]),\n columns: lines_to_ranges(lines[:vertical])\n }\n end",
"def grid3d(*)\n super\n end",
"def index\n set_product_risk_plans_grid\n end",
"def print_grid\n rows = @grid.map do |row|\n row.join(\" \")\n end\n print rows.join(\"\\n\")\n end",
"def build_cartons_grid(data_set, is_multi_select = nil)\n\n column_configs = Array.new\n\n\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'carton_number', :col_width => 120}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'pallet_number', :col_width => 150}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'rw_receipt_unit'} if is_multi_select\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'production_run_code', :col_width => 158}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'fg_product_code', :col_width => 294}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'fg_mark_code', :col_width => 170}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => \"attributes['farm_code']\", :column_caption => \"farm_code\", :col_width => 76}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'puc', :col_width => 76}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'fg_code_old', :col_width => 161}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'organization_code', :col_width => 40}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'grade_code', :col_width => 40}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'inventory_code', :col_width => 140}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'target_market_code', :col_width => 130}\n\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'extended_fg_code', :col_width => 516}\n\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => \"attributes['line_code']\", :column_caption => \"line_code\", :col_width => 47}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'order_number', :col_width => 150}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'pack_date_time', :col_width => 162}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'pick_reference', :col_width => 56}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'is_inspection_carton', :col_width => 45}\n\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'carton_fruit_nett_mass', :col_width => 60,:column_caption => 'mass'}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'id'}\n column_configs[column_configs.length()] = {:field_type => 'text', :field_name => 'bin_id'}\n\n if !@multi_select\n column_configs[column_configs.length()] = {:field_type => 'action', :field_name => 'carton',\n :settings =>\n {:link_text => 'view_carton',\n :target_action => 'view_carton',\n :id_column => 'id'}}\n end\n\n\n key_based_access = true\n key_based_access = @key_based_access if @key_based_access\n\n\n return get_data_grid(data_set, column_configs, nil, key_based_access)\n\n end",
"def test_that_grid_generation_is_accurate\n end",
"def render_grid\n\t\t@grid_w.times.with_index do |x|\n\t\t\t@grid_h.times.with_index do |y|\n\t\t\t\tif !@has_enviroment_rendered\n \t \t\trender_wall x, y if @grid[x][y]==1\n\t\t\t\tend\n\t\t \trender_player x, y if @grid[x][y]==2\n \tend\n end\n #each_cell do |x, y, v|\n # render_wall x, y if !@has_environment_rendered && v == 1 \n # render_player x, y if v == 2\n #end\n\t\t@has_enviroment_rendered = true\n\tend",
"def grid_header_rows\n 1\n end",
"def grid_page_size\n GRID_PAGE_SIZE\n end",
"def initialize(grid = Board.default_grid)\n @grid = grid\n end",
"def gridhelper ()\n $helper = \"\"\n $g = 0\n items = MEASURES\n $LEN = items.length\n $parsed = 0\n\n until $g == $LEN\n $TYPE = items[$g]['TYPE']\n if $g == 0\n $NAME = \"default\"\n else\n $NAME = \"$bp-\" + items[$g]['NAME']\n end\n $FROM = items[$g]['FROM']\n $COLS = items[$g]['COLS']\n $FLUID = items[$g]['FLUID']\n $RATIOPREGOLDEN = items[$g]['RATIOPREGOLDEN']\n $GOLDEN = items[$g]['GOLDEN']\n $RATIO = $RATIOPREGOLDEN * $GOLDEN\n $COLW = items[$g]['COLW']\n $GUTW = items[$g]['GUTW']\n $MAXW = items[$g]['MAXW']\n $COLBG = items[$g]['COLBG']\n\n \n if $TYPE == \"grid_bp\"\n $helper += \"\\n/* %s GRID */\" % [$NAME]\n $helper += \"\\n@media (min-width: #$FROM){\"\n if $FLUID == \"f\" || $FLUID == \"F\"\n $HALW = \"cal(-#$MAXW/2)\"\n $GUTW = \"cal(100%/(#$COLS+(#$COLS*#$RATIO)))\"\n $MRGW = \"cal(50%/(#$COLS+(#$COLS*#$RATIO)))\"\n $COLW = \"cal(100%*#$RATIO/(#$COLS+(#$COLS*#$RATIO)))\" \n\n else \n $HALW = \"cal(-#$COLS/2*(#$COLW+#$GUTW))\"\n $MAXW = \"cal(#$COLS*(#$COLW+#$GUTW))\"\n $MRGW = \"cal(#$GUTW/2)\"\n end\n $helper += \"\n #grid {\n margin-left: #$HALW;\n max-width: #$MAXW; \n }\n #grid div.vert {\n background: #$COLBG;\n width: #$COLW;\n margin: 0 #$MRGW;\n }\n #grid div.vert.first-line {\n margin-left: #$MRGW;\n }\n #grid div.vert.cols#$COLS { /* this grid uses #$COLS cols */\n margin-right: 0;\n }\n \"\n if $parsed > 0\n $target = $parsed - 1\n $PREVCOLS = getPreviousGridCols ( $target )\n\n $helper += \"\n #grid div.vert.cols#$PREVCOLS { /* reset previous #$PREVCOLS cols grid */\n margin-right: #$MRGW;\n }\n \"\n end\n $helper += \"\\n}\"\n\n $parsed += 1\n else\n if $FLUID == \"f\" || $FLUID == \"F\"\n $HALW = \"cal(-#$MAXW/2)\"\n\n else\n $HALW = \"cal(-#$COLS/2*(#$COLW+#$GUTW))\"\n $MAXW = \"cal(#$COLS*(#$COLW+#$GUTW))\"\n end\n $helper += \"\n /* extra breakpoint */\n @media (min-width: #$FROM){\n #grid {\n margin-left: #$HALW;\n max-width: #$MAXW; \n }\n #grid div.vert {\n background: #$COLBG;\n }\n }\n \"\n end\n $g += 1\n end\n\nreturn $helper\nend",
"def cheat\n Board.print_grid(@grid)\n end",
"def grid\n handle_date\n @pool = Pool.find(params[:pool_id])\n end",
"def render_grid_lines\n outputs.lines << (0..grid.width).map { |x| vertical_line(x) }\n outputs.lines << (0..grid.width).map { |x| shifted_vertical_line(x) }\n outputs.lines << (0..grid.height).map { |y| horizontal_line(y) }\n outputs.lines << (0..grid.height).map { |y| shifted_horizontal_line(y) }\n end",
"def grid_params\n params.require(:grid).permit(:difficulty, :nationality, :user_id)\n end",
"def grid\n\t\t@gridTitle = \"Subscriber Listings\"\n\t\t@searchPlaceholder = \"Search for Subscribers\"\n\t\tslim :grid, :layout => false\n\tend",
"def default_grid\n Array.new(7) { Array.new(6) { Cell.new } }\n end",
"def index\n set_risk_plan_operations_grid\n end",
"def p11\n\tgrid = Matrix[\n\t\t[8,\t2, 22,97,38,15,0, 40,0, 75,4, 5, 7, 78,52,12,50,77,91,8],\n\t\t[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,4, 56,62,0],\n\t\t[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,3, 49,13,36,65],\n\t\t[52,70,95,23,4, 60,11,42,69,24,68,56,1, 32,56,71,37,2, 36,91],\n\t\t[22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80],\n\t\t[24,47,32,60,99,3, 45,2, 44,75,33,53,78,36,84,20,35,17,12,50],\n\t\t[32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70],\n\t\t[67,26,20,68,2, 62,12,20,95,63,94,39,63,8, 40,91,66,49,94,21],\n\t\t[24,55,58,5, 66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72],\n\t\t[21,36,23,9, 75,0, 76,44,20,45,35,14,0, 61,33,97,34,31,33,95],\n\t\t[78,17,53,28,22,75,31,67,15,94,3, 80,4, 62,16,14,9, 53,56,92],\n\t\t[16,39,5, 42,96,35,31,47,55,58,88,24,0, 17,54,24,36,29,85,57],\n\t\t[86,56,0, 48,35,71,89,7, 5, 44,44,37,44,60,21,58,51,54,17,58],\n\t\t[19,80,81,68,5, 94,47,69,28,73,92,13,86,52,17,77,4, 89,55,40],\n\t\t[4,\t52,8, 83,97,35,99,16,7, 97,57,32,16,26,26,79,33,27,98,66],\n\t\t[88,36,68,87,57,62,20,72,3, 46,33,67,46,55,12,32,63,93,53,69],\n\t\t[4,\t42,16,73,38,25,39,11,24,94,72,18,8, 46,29,32,40,62,76,36],\n\t\t[20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,4, 36,16],\n\t\t[20,73,35,29,78,31,90,1, 74,31,49,71,48,86,81,16,23,57,5, 54],\n\t\t[1,\t70,54,71,83,51,54,69,16,92,33,48,61,43,52,1, 89,19,67,48]\n\t]\n\tproducts = []\n\t(0...grid.row_count).each do |row|\n\t\t(0...grid.column_count).each do |col|\n\t\t\tright = col + 3 < grid.row_count\n\t\t\tdown = row + 3 < grid.column_count\n\t\t\tleft = col - 3 >= 0\n\t\t\tif right\n\t\t\t\tset = grid.minor(row..row,col..col+3)\n\t\t\t\tproducts << set.reduce(:*)\n\t\t\tend\n\t\t\tif down and right\n\t\t\t\tdiagonal = []\n\t\t\t\t(0..3).each do |x|\n\t\t\t\t\tdiagonal << grid.minor(row+x..row+x,col+x..col+x).component(0,0)\n\t\t\t\tend\n\t\t\t\tproducts << diagonal.reduce(:*)\n\t\t\tend\n\t\t\tif down\n\t\t\t\tset = grid.minor(row..row+3,col..col)\n\t\t\t\tproducts << set.reduce(:*)\n\t\t\tend\n\t\t\tif down and left\n\t\t\t\tdiagonal = []\n\t\t\t\t(0..3).each do |x|\n\t\t\t\t\tdiagonal << grid.minor(row+x..row+x,col-x..col-x).component(0,0)\n\t\t\t\tend\n\t\t\t\tproducts << diagonal.reduce(:*)\n\t\t\tend\n\t\tend\n\tend\n\tproducts.max\nend",
"def free_form_grid(rows, cols, grid_pov=nil)\n # Make sure we are attached to a cube\n check_attached\n get_dimensions unless @dimensions\n\n # Update the POV if one is specified\n if grid_pov\n self.pov = grid_pov\n end\n\n grid = Grid.define(@dimensions, pov, rows, cols)\n\n @logger.info \"Retrieving free-form grid\"\n @req.ProcessFreeFormGrid do |xml|\n xml.sID @session_id\n @preferences.inject_xml xml, @provider_type\n xml.backgroundpov do |xml|\n pov.each do |dim,mbr|\n xml.dim :name => dim, :pov => mbr\n end\n end\n grid.to_xml(xml, false)\n grid.dims_to_xml(xml)\n end\n doc = invoke\n grid = Grid.from_xml(doc)\n\n # The grid returned does not contain data, so perform a refresh\n refresh(grid)\n end",
"def show\n @treinos_grid = initialize_grid(@aluno.treinos)\n end",
"def prepare_grid\n\t\tArray.new(rows) do |row|\n\t\t\tArray.new(columns) do |col|\n\t\t\t\tCell.new(row, col)\n\t\t\tend\n\t\tend\n\tend",
"def grid_obj?\n return (@node_type == :lasgn and [email protected] {|s| s.node_type == :call and !s.sons.select {|ss| ss.node_type == :const and ss.name == \"GObj\"}.empty? }.empty?)\n end",
"def enabled_all?; end",
"def set_board_pin_mode\n\n @axis_x.set_pin_mode()\n @axis_y.set_pin_mode()\n @axis_z.set_pin_mode()\n\n end",
"def default_grid\n Array.new(3) { Array.new(3) {Cell.new} }\n end",
"def initialize\n\t\t@grid = Array.new(10){Array.new(10)}\n\tend",
"def grid_css_class\n \"#{grid_row_model_type}-grid\"\n end",
"def create_grid\n grid = Array.new(6, Array.new(7, BLANK))\n end",
"def index\n \t @company_import_log_grid = initialize_grid(CompanyImportLog, \n order:'id', \n order_direction: 'desc')\n end",
"def create_grid\n @grid = {\"1a\" => \" \", \"1b\" => \" \", \"1c\" => \" \", \"1d\" => \" \", \"1e\" => \" \",\n \"2a\" => \" \", \"2b\" => \" \", \"2c\" => \" \", \"2d\" => \" \", \"2e\" => \" \",\n \"3a\" => \" \", \"3b\" => \" \", \"3c\" => \" \", \"3d\" => \" \", \"3e\" => \" \",\n \"4a\" => \" \", \"4b\" => \" \", \"4c\" => \" \", \"4d\" => \" \", \"4e\" => \" \",\n \"5a\" => \" \", \"5b\" => \" \", \"5c\" => \" \", \"5d\" => \" \", \"5e\" => \" \"}\n end",
"def mouse_over_grid?\n inputs.mouse.point.inside_rect?(scale_up(grid.rect))\n end",
"def jq_grid(grid)\n output = jqgrid_html(grid)\n output << jqgrid_js(grid)\n if grid.detached_javascript.present?\n output << javascript_tag{ \"jQuery(document).ready(function(){ #{grid.detached_javascript.join(\"\\n\")}});\".html_safe }\n end\n output.html_safe\n end",
"def PrintGrid\n\t\t(0..9).each do |i| #vertical parent grid\n\t\t\t(0..19).each do |j| #horizontal nested array\n\t\t\t\tprint @user_grid[i][j]\n\t\t\tend\n\t\tputs\n\t\tend\n\t\treturn @user_grid\n\tend",
"def initialize_grid_from_node(node)\n boxes_zone = node.boxes_zone\n goals_zone = node.goals_zone\n pusher_zone = node.pusher_zone\n level = node.level\n\n @rows = level.rows\n @cols = level.cols\n @name = level.name\n @copyright = level.copyright\n\n pos = 0\n pusher_flag = false\n @grid = level.grid.collect do |cell|\n # Only keep empty spaces\n if ['@', '$', '*', '+'].include? cell\n new_cell = 's'\n else\n new_cell = cell\n end\n\n if @inside_cells.include? new_cell\n # Place goals from zone\n if goals_zone.bit_1?(pos)\n new_cell = '.'\n end\n\n # Place boxes from zone\n if boxes_zone.bit_1?(pos)\n new_cell = new_cell == '.' ? '*' : '$'\n # Place pusher from zone\n elsif !pusher_flag && pusher_zone.bit_1?(pos)\n new_cell = new_cell == '.' ? '+' : '@'\n pusher_flag = true\n end\n\n pos += 1\n end\n\n new_cell\n end\n end",
"def populate_grid_data\n logger.debug \"populate_grid_data ->\"\n @insurance_eobs_saved ||= @check_information.insurance_payment_eobs.exists? if !@orbograph_correspondence_condition\n @patient_pay_eobs_saved ||= @check_information.patient_pay_eobs.exists?\n if @insurance_eobs_saved.blank? and @patient_pay_eobs_saved.blank?\n if @job.split_parent_job_id.blank?\n @check_information.index_file_check_amount = @check_information.check_amount\n @check_information.save\n end\n end\n @hide_adj_line = @insurance_pay\n if @hide_adj_line || @mpi_service_line.blank?\n svc_lines = []\n svc_lines << ServicePaymentEob.new\n @service_line = svc_lines\n end\n\n @micr_line_information = @check_information.micr_line_information unless\n @facility.details[:micr_line_info].blank?\n @amount_so_far = InsurancePaymentEob.amount_so_far(@check_information, @facility)\n @facility_name = @facility.name\n if(@facility_name == 'METROHEALTH SYSTEM' || @facility_name == 'AVITA HEALTH SYSTEMS')\n @faciltiy_lockbox = FacilityLockboxMapping.find_by_lockbox_number_and_facility_id(@batch.lockbox,@facility.id)\n @facility_lock_box_npi = @faciltiy_lockbox.npi unless @faciltiy_lockbox.nil?\n @facility_lock_box_tin = @faciltiy_lockbox.tin unless @faciltiy_lockbox.nil?\n end\n if @check_information.payer\n @payer = @check_information.payer\n elsif @micr_line_information && @micr_line_information.payer\n @payer = @micr_line_information.payer\n end\n\n if [email protected]?\n @payer_name = @payer.payer\n @payer_type = @payer.payer_type\n @payer_address_one = @payer.pay_address_one\n @payer_address_two = @payer.pay_address_two\n @payer_city = @payer.payer_city\n @payer_state = @payer.payer_state\n @payer_zip = @payer.payer_zip\n @payer_id = @payer.id\n @payid = @payer.supply_payid\n @rc_set_name_id = @payer.reason_code_set_name_id\n @payer_indicator_hash, @default_payer_indicator = applicable_payer_indicator(@payid)\n else\n @payer_indicator_hash = {\"ALL\" => \"ALL\"}\n end\n if @facility.details[:payer_tin]\n if @payer && [email protected]_tin.blank?\n @payer_tin = @payer.payer_tin\n elsif [email protected]_tin.blank?\n @payer_tin = @job.payer_tin\n elsif @patient_pay\n @payer_tin = @facility.default_patpay_payer_tin unless @facility.default_patpay_payer_tin.blank?\n else\n @payer_tin = @facility.default_insurance_payer_tin unless @facility.default_insurance_payer_tin.blank?\n end\n end\n if @patient_837_information\n @organization = (@client_name.upcase.strip == 'UPMC' || @client_name.upcase.strip == 'UNIVERSITY OF PITTSBURGH MEDICAL CENTER') ? (@check_information.payee_name.blank? ? @patient_837_information.payee_name : @check_information.payee_name ) : (@patient_837_information.payee_name || @facility.name)\n else\n if (@check_information.insurance_payment_eobs.exists? && (@client_name.upcase.strip == 'UPMC' || @client_name.upcase.strip == 'UNIVERSITY OF PITTSBURGH MEDICAL CENTER'))\n @organization = @check_information.insurance_payment_eobs.first.provider_organisation\n else\n @organization = @facility.name unless (@client_name.upcase.strip == 'UPMC' || @client_name.upcase.strip == 'UNIVERSITY OF PITTSBURGH MEDICAL CENTER')\n end\n end\n if not @insurance_pay\n @claim_type_hash = {\"--\" => \"Primary\", \"Primary\" => \"Primary\", \"Secondary\" => \"Secondary\", \"Tertiary\" => \"Tertiary\" }\n else\n @claim_type_hash = {\"--\" => \"--\", \"Primary\" => \"Primary\", \"Secondary\" => \"Secondary\", \"Tertiary\" => \"Tertiary\",\n \"Denial\" => \"Denial\", \"RPP\" => \"Reversal of Prior payment\",\n \"PPO - No Payment\" => \"Predetermination Pricing Only - No Payment\",\n \"FAP\" => \"Processed as Primary - FAP\" }\n end\n @payment_type_items = ['', 'Money Order', 'Check']\n # HLSC Requirement\n # @payment_type_items = ['']\n # Exclude CHK from the dropdown box if the check type is correspondence\n # @payment_type_items << 'CHK' unless @check_information.correspondence?\n # @payment_type_items.concat(['EOB', 'HIP', 'PAY'])\n\n @job_payment_so_far = @check_information.total_payment_amount.to_f\n @transaction_type_hash = {\"Complete EOB\" => \"Complete EOB\",\n \"Missing Check\" => \"Missing Check\", \"Check Only\" => \"Check Only\", \"Correspondence\" => \"Correspondence\"}\n # The '@transaction_type_selection_value' holds the default seletion value of 'transaction_type'\n @transaction_type_selection_value = \"Complete EOB\"\n # The '@job_payment_so_far' holds the the total payment for this check\n if @job_payment_so_far.zero?\n @transaction_type_possible_value = \"Complete EOB\"\n else\n @transaction_type_possible_value = \"Missing Check\"\n end\n @hash_for_payee_type_format = {'' => nil, 'A' => 'A', 'B' => 'B', 'C' => 'C'}\n @hash_for_patpay_statement_fields = {'' => nil, 'Yes' => true, 'No' => false}\n @hash_for_statement_receiver = {'' => nil, 'Hospital' => 'Hospital', 'Physician' => 'Physician'}\n @show_patpay_statement_fields = (@facility.details[:patpay_statement_fields] &&\n @patient_pay)\n @twice_keying_fields = TwiceKeyingField.get_all_twice_keying_fields(@batch.client_id, @batch.facility_id, current_user.id, @rc_set_name_id)\n @allow_special_characters = @facility.details[:patient_account_number_hyphen_format]\n logger.debug \"<- populate_grid_data\"\n\n end",
"def in_grid?(col, row)\n col.between?(0, COLUMNS - 1) && row.between?(0, ROWS - 1)\n end",
"def grid_mode?(items)\n # more than one question is needed for grid mode\n false unless items.size > 1\n\n items.all? do |i|\n i.is_a?(Questioning) &&\n i.qtype_name == 'select_one' &&\n i.option_set == items[0].option_set &&\n !i.multi_level?\n end\n end",
"def print_grid\n @grid.each do |arr|\n puts arr.join(\" \")\n end\n end",
"def grid(options = {}, &block)\n Grid.new({ parent: self }.merge!(options), &block)\n end",
"def init_white_panel!\n grid.cells[grid.pos] = 1\n end",
"def default_grid\n Array.new(7) { Array.new(6) { CellNode.new }}\n end",
"def print_grid\n self.print_head\n puts $line_break\n i = 0\n grid.each do |row|\n printable_row = []\n row.each do |cell|\n printable_row << cell[:display]\n end\n row_string = printable_row.join(\" | \")\n puts \"## #{$abc[i].upcase} #{row_string} ##\"\n # puts \"## #{row_string} ##\"\n puts \"##\" + \"------\" + \"+----\" * 9 + \"##\"\n i += 1\n end\n bottom_row = []\n l = 0\n 10.times do\n bottom_row << \" #{l} \"\n l += 1\n end\n print_row = bottom_row.join(\"|\")\n puts \"## #{print_row}##\"\n puts $line_break\n end",
"def jqgrid_properties\n vals = {}\n \n # data and request options\n vals['url'] = url if url\n vals['restful'] = true if restful\n vals['postData'] = { :grid => name } #identify which grid making the request\n # vals['colNames'] = column_names if columns.present?\n vals['colModel'] = column_model if columns.present?\n vals['datatype'] = data_type if data_type\n if data_format.present?\n if data_type == :xml\n vals['xmlReader'] = data_format\n elsif data_type == :json\n vals['jsonReader'] = data_format\n end\n end\n \n vals['loadonce'] = load_once if load_once\n\n vals['sortname'] = sort_by if sort_by\n vals['sortorder'] = sort_order if sort_order && sort_by\n vals['rowNum'] = rows_per_page if rows_per_page\n vals['page'] = current_page if current_page\n\n # grid options\n vals['height'] = height if height\n vals['gridview'] = true # faster views, NOTE theres cases when this needs to be disabled\n \n case width_fit\n when :fitted\n #vals[:autowidth] = false #default\n #vals[:shrinkToFit] = true #default\n vals['forceFit'] = true\n vals['width'] = width if width\n \n when :scroll\n #vals[:autowidth] = false #default\n vals['shrinkToFit'] = false\n #vals['forceFit'] = #ignored by jqGrid\n vals['width'] = width if width\n \n else #when :fluid\n vals['autowidth'] = true\n #vals['shrinkToFit'] = true #default\n vals['forceFit'] = true\n #vals['width'] = is ignored\n vals['resizeStop'] = 'javascript: gridify_fluid_recalc_width'\n end\n \n vals['sortable'] = true if arranger_type.include?(:sortable)\n \n # header layer\n vals['caption'] = title if title\n vals['hidegrid'] = false unless collapsible\n vals['hiddengrid'] = true if collapsed\n \n # row formatting\n vals['altrows'] = true if alt_rows\n vals['altclass'] = alt_rows if alt_rows.is_a?(String)\n \n vals['rowNumbers'] = true if row_numbers\n vals['rownumWidth'] = row_numbers if row_numbers.is_a?(Numeric)\n \n if select_rows.present?\n vals['scrollrows'] = true\n #handler...\n else\n vals['hoverrows'] = false\n vals['beforeSelectRow'] = \"javascript: function(){ false; }\"\n end\n \n # pager layer\n if pager\n vals['pager'] = \"##{pager}\" \n vals['viewrecords'] = true # display total records in the query (eg \"1 - 10 of 25\")\n vals['rowList'] = paging_choices\n if paging_controls.is_a?(Hash)\n # allow override of jqGrid pager options\n vals.merge!(paging_controls)\n elsif !paging_controls\n vals['rowList'] = []\n vals['pgbuttons'] = false\n vals['pginput'] = false\n vals['recordtext'] = \"{2} records\"\n end\n end\n \n # allow override of native jqGrid options\n vals.merge(jqgrid_options)\n end",
"def populateGrid\n\n\t\[email protected]_with_index do | row, i |\n\n\t\t\trow.each_with_index do | col, j |\n\n\t\t\t\[email protected][i][j] = Cell.new(i, j, false)\n\t\t\tend\n\t\tend\n\tend",
"def grids\n [grid].compact\n end",
"def set_question_grid\n @question_grid = QuestionGrid.find(params[:id])\n end",
"def jqgrid\n\n\tend",
"def mouse_inside_grid?\n inputs.mouse.point.inside_rect?(scale_up(grid.rect))\n end",
"def gp_flags; end",
"def quick_gridlayout(how, what)\n QuickGridLayout.new(self, how, what, parent_widget, window_id, :gridlayout)\n end",
"def store_gridset #:nodoc:\n record = 0x0082 # Record identifier\n length = 0x0002 # Bytes to follow\n\n fGridSet = @print_gridlines == 0 ? 1 : 0 # Boolean flag\n\n header = [record, length].pack(\"vv\")\n data = [fGridSet].pack(\"v\")\n\n prepend(header, data)\n end",
"def print_grid\n @grid.each do |row|\n row.each do |cell|\n if cell == 'X'\n print(cell.red)\n else\n print(cell)\n end\n end\n print(\"\\n\")\n end\n end",
"def test_solve_hard_grid\n log \"running hard grid\"\n grid = Grid::load(\"grids/hard_grid.txt\")\n grid.solve\n log \"solved grid:\"\n log grid.to_s\n end",
"def grid_count\r\n Api.proj_coordoperation_get_grid_used_count(self.context, self)\r\n end"
] | [
"0.8502784",
"0.62757754",
"0.62229645",
"0.6183486",
"0.611126",
"0.60810155",
"0.6035749",
"0.6026787",
"0.6025474",
"0.6016687",
"0.6016687",
"0.59253377",
"0.5913974",
"0.5795546",
"0.57123667",
"0.5711879",
"0.56795454",
"0.565231",
"0.5647841",
"0.5630417",
"0.5624477",
"0.5588298",
"0.5587236",
"0.5558881",
"0.5548243",
"0.55222315",
"0.55210644",
"0.5505336",
"0.5502989",
"0.5491247",
"0.5491247",
"0.5487014",
"0.5468692",
"0.5463561",
"0.5462415",
"0.54251117",
"0.54249704",
"0.5424381",
"0.5414823",
"0.54070145",
"0.5398198",
"0.53971595",
"0.53647804",
"0.5355787",
"0.5336206",
"0.5330435",
"0.5323605",
"0.5311834",
"0.52983665",
"0.5297409",
"0.5253665",
"0.5250844",
"0.5250733",
"0.5238499",
"0.5230439",
"0.5220063",
"0.5219531",
"0.5215339",
"0.5210241",
"0.5195706",
"0.5189611",
"0.5181522",
"0.51807094",
"0.5174019",
"0.5173566",
"0.51545805",
"0.5154374",
"0.51524806",
"0.5149661",
"0.5135778",
"0.51345885",
"0.5130768",
"0.5130365",
"0.51226056",
"0.5116907",
"0.51085687",
"0.5105078",
"0.50994045",
"0.50965065",
"0.50957626",
"0.50766647",
"0.50725466",
"0.50540257",
"0.50445616",
"0.5043597",
"0.5042989",
"0.5042411",
"0.5037882",
"0.503596",
"0.5035273",
"0.5031055",
"0.5031049",
"0.5029406",
"0.5027765",
"0.5023671",
"0.502226",
"0.50213623",
"0.500757",
"0.5001258",
"0.49945322",
"0.49894792"
] | 0.0 | -1 |
returns first id of record with a field equal to value | def id field, value
# can't bind field name, oh well
@db.get_first_value "select id from #{@name} where #{field} = ?", value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(value)\n key = \\\n if value.to_s =~ /^[0-9\\.]*$/\n default_search_param + \"id\"\n else\n default_search_param\n end\n\n where(key => value).first\n end",
"def get_id(*value)\n return nil if value.blank?\n return nil unless attribute_names.include?('id')\n\n value = value.first if value.count == 1\n\n return value.map{|v| get_id(v)} if value.is_a?(::Array)\n\n return value.id if value.class == self\n return value if value.is_a?(::Integer)\n return value.to_i if value.to_s =~ /\\A\\d+\\z/\n\n result = search_for(value).order(:id).pluck(:id).to_a\n\n return nil if result.blank?\n return result.first if result.count == 1\n\n result\n end",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find_one(params, field = :_id)\n return nil if params.nil? #to avoid mistakes \n return self.find(params).first if params.is_a? Hash\n\n find_one((field.to_s) => params)\n end",
"def id_from_record(record)\n f907 = record.find {|f| f.tag == \"907\"}\n f907.subfields.find {|s| s.code == \"a\"}.value\nend",
"def find_id(val, obj)\n if val.is_a?(obj)\n val.id\n elsif val.is_a?(String)\n obj.find(val).id\n else\n val\n end\n end",
"def with_value(value)\n where(:value => value).first\n end",
"def get(field)\n # Get the first/only row as a Hash.\n result = CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id = #{@id}\").first\n\n # Return only the value for the key of the field we're seeking.\n return result[field]\n end",
"def find_one(id)\n if id.is_a?(Integer) && id > 0\n row = connection.get_first_row <<-SQL\n SELECT #{columns.join \",\"} FROM #{table}\n WHERE id = #{id};\n SQL\n\n # converts a row into an object\n init_object_from_row(row)\n else\n puts \"Id must be a number greater than 0, Try again\"\n end\n end",
"def value_to_ident(value)\n return nil if value.nil?\n if value.nil?\n return nil\n elsif value.kind_of?(Fixnum)\n the_id = value\n elsif value.respond_to?(:id)\n the_id = value.id\n else\n Kernel.raise \"Cannot search for invalid value #{value.inspect}\"\n end\n return index(the_id)\n end",
"def get_value_or_id(field)\n field = item_type.find_field(field) unless field.is_a? Field\n field.value_or_id_for_item(self)\n end",
"def fetch_first_field(sql)\n fetch_first_row(sql)&.values&.first\n end",
"def GetValueId(db, valueTable, idColumn, valueColumn, value)\n\tquery = db.execute(\"SELECT \" + idColumn + \" FROM \" + valueTable + \" WHERE \" + valueColumn + \" = ?;\",[value])\n\t\n\tif (query.length == 1)\n\t\treturn query\n\telse\n\t\tdb.execute(\"INSERT INTO \" + valueTable + \"(\" + valueColumn + \") VALUES (?);\", [value])\n\t\treturn db.execute(\"SELECT \" + idColumn + \" FROM \" + valueTable + \" WHERE \" + valueColumn + \" = ?;\",[value])\n\tend\nend",
"def find(id)\r\n find_one do |record|\r\n record.id == id\r\n end\r\n end",
"def id ; @record.id if @record ; end",
"def find_with_alternative_id(field_name, value, current_user)\n return if value.blank?\n\n unless current_user.is_a?(User) || current_user == :no_user\n raise FphsException, 'find_with_alternative_id requires a current_user'\n end\n\n current_user = nil if current_user == :no_user\n\n field_name = field_name.to_sym\n\n unless alternative_id?(field_name, access_by: current_user)\n raise FphsException, \"Can not match on this field (#{field_name}). \" \\\n 'It is not an accepted alterative ID field for this user.'\n end\n\n # Start by attempting to match on a field in the master record\n return where(field_name => value).first if crosswalk_attr?(field_name)\n\n # No crosswalk field was found. Try an external ID instead\n unless external_id?(field_name, access_by: current_user)\n raise FphsException, 'The field specified is not valid for external identifier matching'\n end\n\n ei = ExternalIdentifier.class_for(field_name).find_by_external_id(value)\n ei&.master\n end",
"def field_by_id(id = nil)\n @fields.find { |h| h[:id] == id.to_s }\n end",
"def id\n value[0]\n end",
"def getIdDoc(value)\n doc_array = @docs.find_one({:docname => value}).to_a\n return doc_array[@ID_INDEX][@ID_VALUE]\n end",
"def find_field(field_id)\n fields.find_by(field_id.starts_with?('_') ? :uuid : :slug => field_id)\n end",
"def lookup_id_for(attribute, value)\n return value if attribute == 'id'\n project_list = get(\"/rest/api/2/project\")\n project_list.each do |project|\n return project['id'] if project[attribute] == value\n end\n end",
"def extract_single_value(row, field)\n values = extract_values(row, field)\n return nil unless values.count.positive?\n\n values.first\n end",
"def find_record(relation = nil)\n if locate_id.nil? || (locate_id.is_a?(::Numeric) && locate_id == 0) || (locate_id.to_s == '')\n return -1\n end\n\n dataset = load_records(relation, false)\n return -1 if dataset.blank?\n\n first_item = dataset.first\n klass = first_item.class\n\n id_field = klass.respond_to?('primary_key') ? klass.primary_key : nil\n id_field ||= first_item.respond_to?('id') ? 'id' : nil\n\n return -1 unless id_field\n if locate_id.is_a?(::Numeric)\n dataset.index{|item| item.send(id_field) == locate_id} || -1\n else\n loc_id = locate_id.to_s.downcase\n dataset.index{|item| item.send(id_field).to_s.downcase == loc_id} || -1\n end\n\n end",
"def field_id(lookup = nil)\n field = field(lookup)\n field[:id].to_i if field\n end",
"def id\n get_val(:id)\n end",
"def find(id)\n first(\"Id = '#{id}'\")\n end",
"def find_record(table, id)\n result = DB[table].where(id: id).first\n result ? Hashie::Mash.new(result) : nil\nend",
"def assert_single_result(id, field, value)\n res = select_by_field(results, field, value)\n expect(res.length).to eq 1\n expect(res.first['id']).to eq [id]\n end",
"def assert_single_result(id, field, value)\n res = select_by_field(results, field, value)\n expect(res.length).to eq 1\n expect(res.first['id']).to eq [id]\n end",
"def minimum_id(id_key: nil)\n record_class.minimum(id_key || id_column)&.to_i\n end",
"def id(index)\n i = get_field_index_by_external_id(index,@fields[:id])\n fields(index, i).to_i unless i.nil?\n end",
"def id(index)\n i = get_field_index_by_external_id(index,@fields[:id])\n fields(index, i).to_i unless i.nil?\n end",
"def find_first(*args)\n id = get_range(:count => 1, *args).first\n id && find_one(id, *args)\n end",
"def get(field)\n result = CONNECTION.execute(\"SELECT * FROM '#{tablename}' WHERE id = ?;\", @id).first\n result[field]\n end",
"def find hash\n field, value = hash.first\n if index(field).unique\n if id = redis.get(colon(name, field, value))\n new id\n end\n else\n raise \"no unique index on #{field}\"\n end\n end",
"def find_by_id(id)\n find_by_attributes(:id => id).first\n end",
"def get_field_from_solr id, field\n result = Blacklight.solr.get \"select\", :params => {:q => 'id:\"'+id+'\"', :qt => 'document', :fl => field, :rows => 1 }\n result[\"response\"][\"docs\"].empty? ? nil : result[\"response\"][\"docs\"].first[field]\n end",
"def id\n key = self.key\n key.first if key.size == 1\n end",
"def id(num)\n find :id => num\n end",
"def insert_and_id field, value\n id = -1\n sql = \"INSERT INTO #{table_name(field)}(value) VALUES \" +\n \"(?)\"\n @db.connect do\n st = @db.prepared_stmt sql\n st.execute(value)\n sql = \"select last_insert_id()\"\n id = @db.query(sql).fetch_row[0].to_i\n end\n return id\n end",
"def select_value(sql, name = nil)\n if result = select_one(sql, name)\n result.values.first\n end\n end",
"def get_first_value( sql, *bind_vars )\n execute( sql, *bind_vars ) { |row| return row[0] }\n nil\n end",
"def select_first!\n limit(1).select!.first\n end",
"def find_by_key(val)\n find(:first, :conditions => {:key => prepare_key(val)})\n end",
"def lookup_field_id_string(field_identifier, options={})\n if options[:find_by] == :code\n return model.map_field_codes_to_id_strings[field_identifier]\n elsif options[:find_by]\n field = model.fields.where(options[:find_by] => field_identifier).select(:id).first\n return field.id.to_s unless field.nil?\n else\n return field_identifier.to_s\n end\n end",
"def find(id)\n where({'id' => \"#{id}\"}).first\n end",
"def find_by(attribute, value)\n row = connection.get_first_row <<-SQL\n SELECT #{columns.join \",\"} FROM #{table}\n WHERE #{attribute} = #{BlocRecord::Utility.sql_strings(value)};\n SQL\n\n # converts a row into an object\n init_object_from_row(row)\n end",
"def find_by_id(id)\n id = id.to_i\n\n @id_hash[id]\n end",
"def fetch(id)\n search(id: id)[:records].first\n end",
"def id\n fields['id']\n end",
"def id(name, league_id)\n database do |db|\n # return id\n return db.get_first_value 'SELECT PlayerID FROM Player\n WHERE DisplayName = :name\n AND LeagueID = :league_id\n COLLATE NOCASE',\n name, league_id\n end\nend",
"def find_by(values)\n all.where(values).limit(1).query_as(:n).pluck(:n).first\n end",
"def primary_key\n select(&:primary_key?)\n end",
"def id\n @values[:id]\n end",
"def distinct_value\n id\n end",
"def find_by_id(input, value)\n hash = nil\n input.each do |input|\n if input[:id] == value\n hash = input\n end\n end\n hash\nend",
"def find_by(field, value)\n @base.send('find_by_' + field, value)\n end",
"def find_user_id (db, user)\n user_values = db.execute(\"SELECT id FROM user WHERE name = ?\", [user])\n user_values[0][0]\nend",
"def primary_key_lookup(pk)\n if sql = @fast_pk_lookup_sql\n sql = sql.dup\n ds = dataset\n ds.literal_append(sql, pk)\n ds.fetch_rows(sql){|r| return ds.row_proc.call(r)}\n nil\n else\n dataset.first(primary_key_hash(pk))\n end\n end",
"def find_id(id)\n @candidates.find {|candidate| candidate if candidate[:id] == id}\nend",
"def find_id_from_database(id, email)\n id_for_github_id(id) || id_for_github_email(email)\n end",
"def find(id)\n self.detect{|x| x.id == id.to_i}\n end",
"def [](x)\n case x\n when self\n x\n when Hash\n find_by_hash(:first, x)\n when nil, Symbol\n find(:first, :conditions => [ 'code = ?', (x || '_').to_s ])\n when String\n find(:first, :conditions => [ 'uuid = ? OR code = ?', (x || '').to_s, (x || '_').to_s ])\n when Integer\n find(:first, :conditions => [ 'id = ?', x ])\n end\n end",
"def find_field(name_or_id)\n self.fields.detect { |field| field.matches?(name_or_id) }\n end",
"def find(id)\n @records.find { |record| record.id == id }\n end",
"def check_id\n unless self.id\n maximo= self.class.maximum(:id)\n id = 1 unless maximo\n id ||= maximo.to_i + 1\n self.id = id\n end\n end",
"def pk_field(klass)\n pk = klass.primary_key\n return klass.ann(pk, :field) || pk\n end",
"def list_id_from_column(column)\n Field.where(name: column).first.settings[:list_id]\n end",
"def sql_select_one(sql)\n result = sql_select_first_row(sql)\n return nil unless result\n result.first[1] # Value des Key/Value-Tupels des ersten Elememtes im Hash\n end",
"def return_value(db, table, id, key)\r\n\tvalue_array = db.execute(\"SELECT #{key} FROM #{table} WHERE id=#{id}\")\r\n\r\n\t# If not defined, return nil\r\n\tif value_array.empty?\r\n\t\treturn nil\r\n\tend\r\n\tif value_array.length > 1\r\n\t\tputs \"ERROR! Multiple matches for id #{id}!\"\r\n\t\treturn nil\r\n\tend\r\n\t# If id is found, return value associated with key\r\n\treturn value_array[0][key]\r\nend",
"def id_string(record)\n record && record['001'] && record['001'].value.to_s\n end",
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && !results['id'].blank? && new(results) || nil\n end",
"def on(field)\n self[field].to_a.first\n end",
"def on(field)\n self[field].to_a.first\n end",
"def find_id_by_title title\n element = select_one_by_title title\n element[\"@#{kind}_id\".to_sym] if element\n end",
"def find_by_value(value)\n by_value[value]\n end",
"def find_by_value(value)\n by_value[value]\n end",
"def find_one(&block)\r\n copy_and_return(@records.find(&block))\r\n end",
"def record_id(object)\n #eval \"object.#{object.class.primary_key}\"\n object.id\n end",
"def query_return_first_value(sql, *binds)\n mysql.fetch(sql, *binds).single_value\n end",
"def address_id(residential_complex_id:, street:, street_number:)\n filtered_result = where(\n :residential_complex_id => residential_complex_id,\n :street => street,\n :street_number => street_number)\n unless filtered_result.empty?\n filtered_result.first.id\n end\n end",
"def alternative_id_value(field_name)\n field_name = field_name.to_sym\n @alternative_id_value ||= {}\n return @alternative_id_value[field_name] if @alternative_id_value.key? field_name\n\n # Start by attempting to match on a field in the master record\n unless self.class.alternative_id?(field_name, access_by: current_user)\n Rails.logger.warn \"Can not match on this field. It is not an accepted alterative ID field. #{field_name}\"\n Rails.logger.warn \"Failed user: #{current_user}\"\n Rails.logger.warn \"Can access: #{self.class.alternative_id_fields(access_by: current_user)}\"\n\n raise FphsException, \"Can not match on this field. It is not an accepted alterative ID field. #{field_name}\"\n end\n\n @alternative_id_value[field_name] = attributes[field_name.to_s]\n return @alternative_id_value[field_name] if self.class.crosswalk_attr?(field_name, access_by: current_user)\n\n ext_id = self.class.external_id_definition(field_name, access_by: current_user)\n unless ext_id\n raise(FphsException,\n \"External ID definition is not active for #{field_name}. Key: #{self.class.access_by_key(current_user)}\")\n end\n\n @alternative_id_value[field_name] = self.class.external_id?(field_name, access_by: current_user)\n return unless @alternative_id_value[field_name]\n\n assoc_name = ext_id.model_association_name\n # Ensure the first item is used, since adding new IDs could lead to spurious results\n # Also check that the master has this association defined, as there are unusual situations where\n # this can cause unexpected errors\n m = send(assoc_name).reorder('').order(id: :asc).first if respond_to?(assoc_name)\n\n @alternative_id_value[field_name] = m&.external_id\n end",
"def id_value(item, **opt)\n if valid_id?(item)\n item.to_s\n elsif valid_id?((item = get_value(item, (opt[:id_key] || id_column))))\n item.to_s\n end\n end",
"def find_acct_id(label, field)\n account = find_and_choose(label, field)\n\n account['id'] unless account.nil?\n end",
"def personen_id(db,name,vorname)\n t = db.execute(\"SELECT id FROM personen WHERE name='\"+name+\n \"' AND vorname='\"+vorname+\"';\")\n if t==[] then\n return nil\n else\n return t[0][0]\n end\nend",
"def find(record_id)\n result = DATABASE.execute(\"SELECT * FROM #{table} WHERE id = #{record_id}\").first\n\n self.new(result)\n end",
"def find_value(value)\n return find() do |item| # find is an enumerable that takes a block - passes each entry in enum to block\n item.data == value # and returns the first for which block is NOT false. So here we say return what we\n end # the first item of which the data matches the value\n end",
"def by_id(base_id)\n self.where(:id => base_id).limit(1)\n end",
"def find_first(value,start,stop)\n return start if time_at(start) > value\n find(:first,value,start,stop)\n end",
"def index_value fields,record\n @index_value ||= get_index_values\n fields.each do |f,i|\n ## fast comparison due to use of Symbol and not string\n next unless @index_fields.include? f\n if id = @index_value[record[i]]\n record[i] = id\n else\n ## we insert and then put the id\n id = insert_and_id f,record[i]\n @index_value[record[i]] = id\n record[i] = id\n end\n end\n end",
"def get(id)\n klass.find(:first, params: { klass.primary_key => wrap_key(id) })\n end",
"def find_by_id(id)\n unless id.class == BSON::ObjectId\n if BSON::ObjectId.legal? id\n id = BSON::ObjectId.from_string(id)\n else\n nil\n end\n end\n\n find('_id' => id).first\n end",
"def id\n @values[:id]\n end",
"def id\n @values[:id]\n end",
"def pid\n @fields.first\n end",
"def find(id=nil)\n record = self.connection.exec_params('SELECT * FROM contacts '\\\n 'WHERE id = $1::int', [id]) if id.is_a?(Integer)\n \n record.nil? || record.num_tuples.zero? ? nil : new(record[0].values[1], record[0].values[2], record[0].values[0])\n end",
"def primary_key_value(obj)\n obj.pk\n end",
"def lookup_field_code(field_identifier, options={})\n if options[:find_by]\n field = model.fields.where(options[:find_by] => field_identifier).select(:code,:id).first\n return field.to_param unless field.nil?\n else\n return field_identifier.to_s\n end\n end",
"def find_by_id(id)\n find_by(:id, id)\n end"
] | [
"0.69565594",
"0.6676421",
"0.6634789",
"0.6634789",
"0.66263705",
"0.6493472",
"0.64218557",
"0.63811576",
"0.6373809",
"0.6348592",
"0.63105625",
"0.6292532",
"0.6277508",
"0.6275408",
"0.61603403",
"0.61383283",
"0.60730416",
"0.6067499",
"0.6064629",
"0.6058045",
"0.6051453",
"0.60387814",
"0.60334134",
"0.5978501",
"0.5968968",
"0.59642637",
"0.5951597",
"0.59304774",
"0.59221673",
"0.59221673",
"0.5904992",
"0.59042525",
"0.59042525",
"0.5895034",
"0.58839786",
"0.5880449",
"0.58618605",
"0.58296657",
"0.5813574",
"0.57846427",
"0.5772542",
"0.57641256",
"0.57626224",
"0.5756016",
"0.5751208",
"0.5746365",
"0.57384104",
"0.5732236",
"0.57308584",
"0.57268894",
"0.57257086",
"0.5725392",
"0.57135856",
"0.5679724",
"0.56743145",
"0.5650093",
"0.5639958",
"0.56386656",
"0.56385136",
"0.5637527",
"0.5629943",
"0.56296134",
"0.56196725",
"0.5617876",
"0.5614183",
"0.56082165",
"0.5601575",
"0.56006634",
"0.5597521",
"0.55962795",
"0.5593781",
"0.5584807",
"0.5577474",
"0.5576018",
"0.5576018",
"0.557341",
"0.55671084",
"0.55671084",
"0.555824",
"0.5554343",
"0.5552511",
"0.5542517",
"0.55371225",
"0.5528658",
"0.5516656",
"0.55139655",
"0.5506265",
"0.5501559",
"0.5494326",
"0.54906195",
"0.5478414",
"0.54776233",
"0.54766",
"0.5471329",
"0.5471329",
"0.54658747",
"0.54619116",
"0.5448447",
"0.5442035",
"0.5440333"
] | 0.8031731 | 0 |
Update/add specific metadata key (works with GET) | def run(request, data)
node = Razor::Data::Node[:name => data['node']]
operation = { 'update' => { data['key'] => data['value'] } }
operation['no_replace'] = data['no_replace']
begin
node.modify_metadata(operation)
rescue Razor::Data::NoReplaceMetadataError
request.error 409, :error => _('no_replace supplied and key is present')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_metadata(key, **metadata); end",
"def update_metadata(key, **metadata)\n end",
"def set(key, value)\n @metadata[key] = value\n end",
"def update_metadata(params)\n @client.put(metadata_path, nil, params, \"Content-Type\" => \"application/json\")\n end",
"def set_metadata(key, value)\n params = java.util.HashMap.new()\n params.put(key.to_s, value)\n @stamp.setMoreInfo(params)\n end",
"def update_metadata_field(field_name, value)\n @client.put(\"#{metadata_path}/#{field_name}\", nil, { value: value }, \"Content-Type\" => \"application/json\")\n end",
"def update(uuid, key, value)\n put(uri: \"/files/#{uuid}/metadata/#{key}/\", content: value.to_json)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @metadata = args[:metadata] if args.key?(:metadata)\n @params = args[:params] if args.key?(:params)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @metadata = args[:metadata] if args.key?(:metadata)\n @value = args[:value] if args.key?(:value)\n end",
"def put_vapp_metadata_item_metadata(vm_id, metadata_key, metadata_value)\n body=\"\n <MetadataValue xmlns=\\\"http://www.vmware.com/vcloud/v1.5\\\">\n <Value>#{metadata_value}</Value>\n </MetadataValue>\"\n\n request(\n :body => body,\n :expects => 202,\n :headers => {'Content-Type' => \"application/vnd.vmware.vcloud.metadata.value+xml\"},\n :method => 'PUT',\n :parser => Fog::ToHashDocument.new,\n :path => \"vApp/#{vm_id}/metadata/#{URI.escape(metadata_key)}\"\n )\n end",
"def []=(key, value)\n @metadata[key.to_s] = value\n end",
"def []=(key, value)\n @metadata[key.to_s] = value\n end",
"def put(key, organization_metadata)\n HttpClient::Preconditions.assert_class('key', key, String)\n HttpClient::Preconditions.assert_class('organization_metadata', organization_metadata, Apidoc::Models::OrganizationMetadata)\n @client.request(\"/organizations/#{CGI.escape(key)}/metadata\").with_json(organization_metadata.to_json).put { |hash| Apidoc::Models::OrganizationMetadata.new(hash) }\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @metadata = args[:metadata] if args.key?(:metadata)\n @namespace = args[:namespace] if args.key?(:namespace)\n @value = args[:value] if args.key?(:value)\n end",
"def add_key_data(key_data_); end",
"def update_metadata(dataset, metadata = {})\n metadata = get_metadata(metadata)\n metadata.each { |k, v| dataset.metadata[k] = v }\n dataset.save\n end",
"def []=(key, value)\n if argument_key?(key)\n super\n else\n @metadata[key] = value\n end\n end",
"def put(key, value)\n \n end",
"def update_metadata(direction, metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\n end",
"def update!(**args)\n @generic_metadata = args[:generic_metadata] if args.key?(:generic_metadata)\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 put(key, value); end",
"def set_account_meta_key(account_meta_key)\n @logger.info \"Setting account meta key for tenant #{@fog_options[:hp_tenant_id]}...\"\n response = @connection.request({\n :method => 'POST',\n :headers => { \n 'X-Account-Meta-Temp-URL-Key' => account_meta_key\n }\n })\n \n # Confirm meta data changes\n response = @connection.request({\n :method => 'HEAD'\n })\n \n @logger.info \"Done setting account meta key.\"\n end",
"def addMetadata(filename, metadatatype, metadatavalue)\n begin\n \n if @fileMetadata.has_key?(filename)\n @fileMetadata[filename] = @fileMetadata[filename].to_s + \"&&&\" + metadatatype.downcase + \":\" + metadatavalue.downcase\n else\n @fileMetadata[filename] = metadatatype.downcase + \":\" + metadatavalue.downcase\n end\n \n rescue Exception => e\n puts \"Error: #{e.to_s}\"\n puts \" -- line: #{e.backtrace[0].to_s}\"\n raise Exception.new(\"Could not add metadata to a new file!\")\n end\n end",
"def overwrite_metadata(metadata, section, key, value)\n return unless key.is_a?(String) || key.is_a?(Symbol)\n\n metadata[section] ||= {}\n metadata[section][key] = value\n end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @signature = args[:signature] if args.key?(:signature)\n end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @signature = args[:signature] if args.key?(:signature)\n end",
"def alter_metadata(identifier, metadata_record)\n dspace_id = translate_handle_to_dspace_id(identifier)\n tempfile = Tempfile.new('alter-md')\n tempfile.write(JSON.generate(metadata_record))\n tempfile.close\n cmd = `curl -X PUT -H \"Content-Type: application/json\" -H \"Accept: application/json\" -H \"rest-dspace-token: #{@token}\" #{ENV[\"FDA_REST_ENDPOINT\"]}/items/#{dspace_id}/metadata --data @#{tempfile.path} --insecure -s`\n tempfile.unlink\n return cmd\n end",
"def put(namespace, key, entry); end",
"def hmset(key, *attrs); end",
"def hmset(key, *attrs); end",
"def update_meta_tag(key, value)\n set_meta_tags({key => value})\n end",
"def []=( key, value )\n _meta_data[key.to_s] = value\n end",
"def update_metadata(metric, options= {})\n @metadata_svc.update(metric, options)\n end",
"def update!(**args)\n @description = args[:description] if args.key?(:description)\n @key = args[:key] if args.key?(:key)\n end",
"def update!(**args)\n @expiration_time = args[:expiration_time] if args.key?(:expiration_time)\n @fingerprint = args[:fingerprint] if args.key?(:fingerprint)\n @key = args[:key] if args.key?(:key)\n @metadata = args[:metadata] if args.key?(:metadata)\n end",
"def update!(**args)\n @metadata = args[:metadata] if args.key?(:metadata)\n end",
"def add_metadata(metadata, section, key_or_data, value = NOT_PROVIDED)\n case value\n when NOT_PROVIDED\n merge_metadata(metadata, section, key_or_data)\n when nil\n clear_metadata(metadata, section, key_or_data)\n else\n overwrite_metadata(metadata, section, key_or_data, value)\n end\n end",
"def update_api_key(key, object, validity = 0, max_queries_per_IP_per_hour = 0, max_hits_per_query = 0, request_options = {})\n if object.instance_of?(Array)\n params = { :acl => object }\n else\n params = object\n end\n\n params['validity'] = validity.to_i if validity != 0\n params['maxHitsPerQuery'] = max_hits_per_query.to_i if max_hits_per_query != 0\n params['maxQueriesPerIPPerHour'] = max_queries_per_IP_per_hour.to_i if max_queries_per_IP_per_hour != 0\n\n client.put(Protocol.index_key_uri(name, key), params.to_json, :write, request_options)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n end",
"def put_collection_key(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}\"\n\tputs do_the_put_call( url: api_url, user: @user, json: args[:json] )\nend",
"def update!(**args)\n @request_metadata = args[:request_metadata] if args.key?(:request_metadata)\n end",
"def update!(**args)\n @request_metadata = args[:request_metadata] if args.key?(:request_metadata)\n end",
"def update!(**args)\n @request_metadata = args[:request_metadata] if args.key?(:request_metadata)\n end",
"def update!(**args)\n @request_metadata = args[:request_metadata] if args.key?(:request_metadata)\n end",
"def set(key, value)\n filename = filename_from_url(key)\n mkpath(filename)\n\n # Save metadata in a parallel file\n if value.respond_to?(:meta)\n filename_meta = \"#{filename}.meta\"\n meta = value.meta\n meta[:status] = value.status if value.respond_to?(:status)\n meta[:content_type] = value.content_type if value.respond_to?(:content_type)\n meta[:base_uri] = value.base_uri if value.respond_to?(:base_uri)\n File.open(filename_meta, 'wb') {|f| YAML::dump(meta, f)}\n end\n\n # Save file contents\n File.open(filename, 'wb'){|f| f.write value.read }\n value.rewind\n value\n end",
"def update!(**args)\n @external_key_uri = args[:external_key_uri] if args.key?(:external_key_uri)\n end",
"def set_meta(key, value)\n metas.where(key: key).update_or_create({value: fix_meta_value(value)})\n cama_set_cache(\"meta_#{key}\", value)\n end",
"def add_metadata(section, key_or_data, *args)\n configuration.add_metadata(section, key_or_data, *args)\n end",
"def hset(key, *attrs); end",
"def add_metadata_to_manifest(manifest, key, value)\n element = manifest.elements[\"//manifest/application/meta-data[@android:name=\\\"#{key}\\\"]\"]\n if element.nil?\n application = manifest.elements[\"//manifest/application\"]\n application.add_element \"meta-data\", \"android:name\" => key, \"android:value\" => value\n else\n element.attributes[\"android:value\"] = value\n end\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @value_type = args[:value_type] if args.key?(:value_type)\n @description = args[:description] if args.key?(:description)\n end",
"def update\n if @key.update(key_params)\n render json: @key\n else\n render json: @key.errors, status: :unprocessable_entity\n end\n end",
"def put_metadata(doi, metadata)\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"doi=#{doi}\",\n \"metadata=#{metadata}\",\n \"\" ], bold_puts: debug_verbose_puts if debug_verbose\n doi = prefix if doi.blank?\n response = mds_connection.put(\"metadata/#{doi}\", metadata, { 'Content-Type': 'application/xml;charset=UTF-8' })\n raise Error.new(\"Failed creating metadata for DOI '#{doi}'\", response) unless response.status == 201\n\n /^OK \\((?<found_or_created_doi>.*)\\)$/ =~ response.body\n found_or_created_doi\n end",
"def update!(**args)\n @metadata_location = args[:metadata_location] if args.key?(:metadata_location)\n end",
"def update!(**args)\n @delete_metadata = args[:delete_metadata] if args.key?(:delete_metadata)\n @edit_metadata = args[:edit_metadata] if args.key?(:edit_metadata)\n @hangout_video_metadata = args[:hangout_video_metadata] if args.key?(:hangout_video_metadata)\n end",
"def update_initial_metadata(metadata)\n end",
"def should_change_metadata(key, value, new_value = nil, _expected_status = 200, *tags)\n it \"#{key} = #{value} returns #{_expected_status}\", *tags do\n\n cookbook = new_cookbook(cookbook_name, cookbook_version)\n\n put_payload = cookbook.dup\n put_metadata = put_payload[\"metadata\"]\n if (value == :delete)\n put_metadata.delete(key)\n else\n put_metadata[key] = value\n end\n put_payload[\"metadata\"] = put_metadata\n\n put(api_url(\"/#{cookbook_url_base}/#{cookbook_name}/#{cookbook_version}\"), admin_user,\n :payload => put_payload) do |response|\n # The PUT response returns the payload exactly as it was sent\n response.should look_like({:status => _expected_status, :body_exact => put_payload})\n end\n\n # Verified change (or creation) happened\n get(api_url(\"/#{cookbook_url_base}/#{cookbook_name}/#{cookbook_version}\"), admin_user,\n ) do |response|\n get_response = cookbook.dup\n if (new_value)\n get_metadata = get_response[\"metadata\"]\n get_metadata[key] = new_value\n get_response[\"metadata\"] = get_metadata\n end\n\n response.should look_like({:status => 200, :body => get_response})\n end\n\n end\n end",
"def update!(**args)\n @key_type = args[:key_type] if args.key?(:key_type)\n @key_value = args[:key_value] if args.key?(:key_value)\n end"
] | [
"0.81631094",
"0.7936334",
"0.69122374",
"0.689169",
"0.6829413",
"0.6807875",
"0.6783698",
"0.6702113",
"0.67008746",
"0.66036904",
"0.65782917",
"0.65782917",
"0.65527576",
"0.6550364",
"0.65428597",
"0.6534862",
"0.64902127",
"0.63708603",
"0.63569903",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.63527167",
"0.6345376",
"0.6335452",
"0.6315746",
"0.63020885",
"0.6284787",
"0.625269",
"0.625269",
"0.62326276",
"0.6198443",
"0.6177696",
"0.6177696",
"0.6157007",
"0.6140545",
"0.61337376",
"0.61290324",
"0.6118021",
"0.6109961",
"0.6107222",
"0.609682",
"0.60952723",
"0.60952723",
"0.6076727",
"0.6073688",
"0.6073688",
"0.6073688",
"0.6073688",
"0.6063188",
"0.60257554",
"0.60178995",
"0.6015949",
"0.60101855",
"0.60048115",
"0.59981924",
"0.597886",
"0.59747314",
"0.59518784",
"0.59309405",
"0.59233475",
"0.59180045",
"0.5917527"
] | 0.5924304 | 97 |
Use callbacks to share common setup or constraints between actions. | def set_newsletter
@newsletter = Newsletter.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def 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 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 action\n end",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\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 before_action \n end",
"def action\n end",
"def setup\n # override this if needed\n end",
"def matt_custom_action_begin(label); 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 setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def lookup_action; 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 around_hooks; end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def action_target()\n \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 setup(&blk)\n @setup_block = blk\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 callback_phase\n super\n end",
"def advice\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def _handle_action_missing(*args); end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def call\n setup_context\n super\n end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end"
] | [
"0.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516",
"0.5311442",
"0.52963835",
"0.52955836",
"0.5295297",
"0.5258503",
"0.52442217",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5234908",
"0.5230927",
"0.52263695",
"0.5222485",
"0.5216462",
"0.52128595",
"0.52070963",
"0.520529",
"0.517586",
"0.5174021",
"0.5172379",
"0.5165636",
"0.5161574",
"0.51556087",
"0.5153217",
"0.5152898",
"0.5151238",
"0.5144674",
"0.51387095",
"0.51342636",
"0.5113545",
"0.51131564",
"0.51131564",
"0.5107665",
"0.5107052",
"0.50908124",
"0.5089785",
"0.50814754",
"0.50807786",
"0.5064482",
"0.5053022",
"0.50526255",
"0.5050246",
"0.5050246",
"0.50329554",
"0.5023997",
"0.5021236",
"0.5014815",
"0.5014393",
"0.4999298",
"0.49990913",
"0.4997733",
"0.49884573",
"0.49884573",
"0.49840933",
"0.49786162",
"0.49784446",
"0.49782816",
"0.49659815",
"0.49655175",
"0.4956222",
"0.49543875",
"0.49536037",
"0.495265",
"0.4951427",
"0.49438462",
"0.49436793",
"0.49335384",
"0.49321616",
"0.49264926",
"0.49247074",
"0.49246994",
"0.49226475",
"0.49194494",
"0.49152806",
"0.49149707",
"0.49149227",
"0.49144953",
"0.49141943"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def newsletter_params
params.require(:newsletter).permit(:released_at, :title, :description, :asset)
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 |
checks whether supplier user owns a clan or is a member of a clan | def can_create_or_join_clan(user)
raise "must supply a block" unless block_given?
unless user.clans.blank? && user.member_of_clan.blank?
render :partial => 'clans/cannot_create_or_join', :layout => true
else
yield
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owner?(user_asking)\n user_asking.in? company.owners\n end",
"def owned_by?(u)\n self.user == u\n end",
"def is_owned_by?(member = nil)\n return false if member.blank?\n if self.designer == member or self.client == member\n true\n else\n member.is_super_user? ? true : false\n end\n rescue\n false\n end",
"def owned_by? a_user\n a_user == user\n end",
"def is_owned_by_user?(user)\n self.user == user\n end",
"def is_owned_by?(user_id)\n self.user_id == user_id\n end",
"def owned?(user_to_check = current_user)\n user_to_check ? self.creator == user_to_check : false\n end",
"def staff_owned_gate?\n record.check_points.where(registrar: user).map(&:gate?).reduce(:|)\n end",
"def owned?\n user.present?\n end",
"def owned_by? a_user\n a_user == program.moderator\n end",
"def chargeable? listing\n listing.seller?(@user) && listing.new? \n end",
"def owned_by?(user)\n if (access_restricted?)\n return self.acl.owner?(user)\n end\n return false\n end",
"def owned_by?(current_user)\n current_user && user_id == current_user.id\n end",
"def is_not_global_and_is_owned_by?(user)\n !self.is_global? && self.user_id == user.id\n end",
"def owned_by?(user_id)\n user_id = user_id.id if user_id.is_a?(User)\n has_role(user_id, :creator)\n end",
"def is_owned\n !!(\n @training &&\n @training.id &&\n (\n @is_admin_logged_in || (@current_user && (@training.user_id == @current_user.id))\n )\n )\n end",
"def collaborate?\n record.private? && (record.user_id == user.id || user.admin?)\n end",
"def managed_by? a_user\n owned_by? a_user || program.moderator == a_user\n end",
"def user_can_see?(user)\n !self.private || self.is_owner?(user)\n end",
"def owned_by?(user)\n return false unless user.is_a? User\n \n # allow admins and project owners to edit\n user.admin? or self.owner == user\n end",
"def owned_by?(user)\n return false unless user.is_a? User\n \n # allow admins and project owners to edit\n user.admin? or self.owner == user\n end",
"def owner?(c_utor)\n contribution.owner?(c_utor)\n end",
"def is_global_or_owned_by?(user)\n self.is_global? || self.user_id == user.id\n end",
"def managed_by? a_user\n program.owned_by? a_user\n end",
"def manageable?(user)\n self == user || user&.admin?\n end",
"def is_owner? (opportunity)\n \topportunity.user_id == self.id\n end",
"def is_owner?(person)\n return person !=nil && person.team_id == self.id && person.role == \"captain\"\n end",
"def has_owner(user)\n return self.user.id==user.id\n end",
"def is_member_of_household?\n self.household.present?\nend",
"def owner?(c_utor)\n #contributor_id.to_i == c_utor.id.to_i and contributor_type.to_s == c_utor.class.to_s\n \n case self.contributor_type.to_s\n when \"User\"\n return (self.contributor_id.to_i == c_utor.id.to_i and self.contributor_type.to_s == c_utor.class.to_s)\n when \"Network\"\n return self.contributor.owner?(c_utor.id) if self.contributor_type.to_s\n else\n return false\n end\n \n #return (self.contributor_id.to_i == c_utor.id.to_i and self.contributor_type.to_s == c_utor.class.to_s) if self.contributor_type.to_s == \"User\"\n #return self.contributor.owner?(c_utor.id) if self.contributor_type.to_s == \"Network\"\n \n #false\n end",
"def check_correct_owners\n if current_admin.nil?\n if @referral.referral_email != current_user.email && @referral.user != current_user\n redirect_to(new_user_session_path, notice: \"You cannot view this referral. Please login to the correct account.\")\n end\n else\n if @referral.job.admin != current_admin && @referral.admin_id != current_admin.id\n redirect_to(new_user_session_path, notice: \"You cannot view this referral. Please login to the correct account.\")\n end\n end\n end",
"def can_be_accessed_by?(user)\n if visibility == 'public'\n return true\n elsif visibility == 'buddies' && organization.battle_buddy_list.include?(user.organization_id)\n return true\n elsif visibility == 'shared' && buddy_list.split(',').include?(user.organization_id.to_s)\n return true\n elsif visibility == 'executive' && user.is_executive? && organization.users.include?(user)\n return true\n elsif ['private','buddies','shared'].include?(visibility) && organization.users.include?(user)\n return true\n else\n return false\n end\n end",
"def owner? usr\n user_id == usr.id\n end",
"def owned_by?(student)\n student.id == self.student_id\n end",
"def is_owner?(user)\n user.id == self.user_id\n end",
"def acceptable_by?(user)\n return false unless user.has_role?(:admin, user.unit)\n resource.pending?\n end",
"def owner?\n customer.owner_id == id\n end",
"def check_ownership_requestor_user(requestor,user)\n if requestor.nickname != user.nickname\n raise Error, \"Requestor #{requestor.nickname} and user requested #{user.nickname} do not match\"\n end\n end",
"def supporter?\n owner.plan_type != 'free'\n end",
"def show?\n @user.has_role?(:admin) || @record.course.user_id == @user.id || @record.course.bought(@user) == false\n end",
"def owns?(object); object.owners.include?(self) end",
"def is_owner?(user)\n !user.nil? && (self.user_id == user.id)\n end",
"def has_access(developer)\r\n current_user.id == developer.id\r\n end",
"def is_owner?(this_user)\n user == this_user\n end",
"def member_of?(context)\n context.users.include? self\n end",
"def course_owner?(course)\n tutor? && current_user?(course.tutor)\n end",
"def check_user(current_user, clearance_level)\n if current_user.nil?\n return false\n end\n if clearance_level == \"admin\"\n return current_user.role == \"admin\"\n end\n if clearance_level == \"chair\"\n (current_user.role == \"admin\" || current_user.role == \"chair\")\n end\n end",
"def member?(user)\n user.has_role?(:member, self) || owner.try('member?', user)\n end",
"def members?\n user.hoa == hoa\n end",
"def donors?(other_user)\n\t\tdonors.include?(other_user)\n\tend",
"def accepted?\n return true if exclusive?\n\n accepted_by?(host_lead_member) && accepted_by?(guest_lead_member)\n end",
"def check_owner_user\n @guild = Guild.find(@invite[:guild_id])\n if self.admin?\n return 1\n end\n return (@guild[:owner_id] == session[:user_id]) ? 1 : nil\n end",
"def owns?(what)\n if what.respond_to?(:user_ids)\n return what.user_ids.include?(self.id)\n elsif what.respond_to?(:user_id)\n return what.user_id == self.id\n end\n return self.is_cesia?\n end",
"def member_in_cooperative?(id)\n return false unless confidential?\n\n Space.find(space_id).member(id).present?\n end",
"def manager_or_owner?\n MANAGER_ROLES.include?(CourseUser.roles[role.to_sym])\n end",
"def check_ownership \t\n \taccess_denied(:redirect => @check_ownership_of) unless current_user_owns?(@check_ownership_of)\n end",
"def ifMember(group_id,user_id)\n GroupUser.where(:group_id => group_id, :user_id => user_id).exists? #change to current_user_id \n end",
"def user_meets_criteria?(user)\n user.credits > 0\n end",
"def creatable_by?(creator)\n creator.administrator? || !administrator\n end",
"def visible_to?(resource)\n if self.visible || self.user_id == resource.id #|| assuming they have an ID\n true\n else\n false\n end\n end",
"def editable_by?(user)\n \tuser && user == owner\n\tend",
"def is_member?\n determine_user_role\n end",
"def user_owner_entry?\n user_entry? && principle == \"OWNER\"\n end",
"def check_owner\n return if params[:id].blank? or @login_user.nil?\n\n begin\n owner_id = Location.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_LOCATION) and owner_id != @login_user.id\n Log.add_check(request, '[check_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end",
"def can_user_access?(user)\n if user.is_account_holder_or_administrator? || self.is_user_tagged_to_team?(user)\n true\n else\n false\n end\n end",
"def manage?\n super || (@user && @user.is_curator?)\n end",
"def metropolitan_club_admin?\n metropolitan_club.leaders.include?(self)\n end",
"def owned?\n !owner.nil?\n end",
"def destroyable_by?(user)\n return !!(user.is_admin? or self.creator == nil or self.creator == user or (self.roll and self.roll.creator == user))\n end",
"def show?\n user_is_owner_or_admin? || user_is_professional?\n end",
"def require_costume_ownership\n redirect_to root_path(message: 'Only can owner or assigned dancer can access') unless current_user.costumes.include?(@costume)\n end",
"def allow(owner)\n u = User.find(session[:user_id])\n if u.role == :admin\n return true\n else\n if u.id == owner.id\n return true\n else\n return false\n end\n end\n end",
"def owner?(c_utor)\n case self.contributor_type\n when \"User\"\n return (self.contributor_id == c_utor.id && self.contributor_type == c_utor.class.name)\n # TODO some new types of \"contributors\" may be added at some point - this is to cater for that in future\n # when \"Network\"\n # return self.contributor.owner?(c_utor.id) if self.contributor_type.to_s\n else\n # unknown type of contributor - definitely not the owner \n return false\n end\n end",
"def is_member?(user)\n return true if user.id == self.created_by.id\n self.users.any? { |u| u.id == user.id }\n end",
"def owner?(user)\n user == owner || owners.include?(user)\n end",
"def member?\n client.organization_member? org_id, user.login\n end",
"def is_owner_of?(thing)\n return false unless thing.user == self\n true\n end",
"def privacy_check(user_check)\n can_view = nil\n\n if self.public == false\n user = User.find_by_id(self.user_id)\n if user.company_id != user_check.company_id\n can_view = false\n else\n can_view = true\n end\n else\n can_view = true\n end\n\n return can_view\n\n end",
"def user_owns\n if [email protected]_owner(@user)\n redirect_to @user\n end\n end",
"def check_user_type\n if self.user_type.present?\n self.contractor = self.user_type.to_s.downcase.include? \"contractor\"\n else\n self.contractor = false\n end\n end",
"def check_user_for_cardgroup(cardgroup)\n cardgroup_owner_id = cardgroup.owner_id\n current_user_not_cardgroup_owner = (cardgroup_owner_id != session[:user_id])\n\n if (accountant? && ((cardgroup_owner_id != 0) || (session[:acc_callingcard_manage].to_i == 0))) ||\n (reseller? && (current_user_not_cardgroup_owner || (session[:res_calling_cards].to_i != 2))) ||\n (admin? && current_user_not_cardgroup_owner)\n dont_be_so_smart\n redirect_to(:root) && (return false)\n end\n\n true\n end",
"def has_own_providers?\n if is_reseller?\n common_use_provider_count > 0\n else\n raise \"User is not reseller, he cannot have providers\"\n end\n end",
"def has_owner? user\n self.account_users.where(user: user, is_owner: true).count > 0\n end",
"def senior_member?\n\t\tsenior != true\n\tend",
"def check_toy_owner\n return if params[:id].nil? or params[:id].empty? or @login_user.nil?\n\n begin\n owner_id = Toy.find(params[:id]).user_id\n rescue\n owner_id = -1\n end\n if !@login_user.admin?(User::AUTH_DESKTOP) and owner_id != @login_user.id\n Log.add_check(request, '[check_toy_owner]'+request.to_s)\n\n flash[:notice] = t('msg.need_to_be_owner')\n redirect_to(:controller => 'desktop', :action => 'show')\n end\n end",
"def access?(user, access)\n\n # check customer\n if user.permissions?('ticket.customer')\n\n # access ok if its own ticket\n return true if customer_id == user.id\n\n # check organization ticket access\n return false if organization_id.blank?\n return false if user.organization_id.blank?\n return false if organization_id != user.organization_id\n\n return organization.shared?\n end\n\n # check agent\n\n # access if requestor is owner\n return true if owner_id == user.id\n\n # access if requestor is in group\n user.group_access?(group.id, access)\n end",
"def show?\n user.try(:admin?) || record.has_member?(user) \n end",
"def readable_by?(user_id)\n user = user_id.is_a?(User) ? user_id : User.find(user_id)\n owner_orgs = self.owner_and_coowners.collect(&:org)\n \n # Super Admins can view plans read-only, Org Admins can view their Org's plans \n # otherwise the user must have the commenter role\n (user.can_super_admin? ||\n user.can_org_admin? && owner_orgs.include?(user.org) ||\n has_role(user.id, :commenter))\n end",
"def visible?(usr=nil)\n (usr || User.current).allowed_to?(:view_cm_ncs, self.project)\n end",
"def invitable_to?(user)\n return false unless pending?\n return false if authors.include?(user)\n end",
"def invite?\r\n admin? or (user.id != user_record.id and streamer?)\r\n end",
"def editable_by?(user)\n\t \t# user && user == owner\n\t user == user\n \tend",
"def registration_owned?\n if current_user\n current_user == Registration.find_by(id: params[:id]).user\n end\n end",
"def is_managed_by?(user)\n user&.person&.is_project_administrator_of_any_project? || user&.person&.is_programme_administrator_of_any_programme?\n end",
"def can_access_club? club_id\n current_user.clubs.find(club_id)\n end",
"def owner_and_coowners\n vals = Role.access_values_for(:creator).concat(Role.access_values_for(:administrator))\n User.joins(:roles).where(\"roles.plan_id = ? AND roles.access IN (?)\", self.id, vals)\n end",
"def share_cases?(account)\n if [AppConstants::PRIVILEGE[:super_user],AppConstants::PRIVILEGE[:admin],AppConstants::PRIVILEGE[:user_manager]].include?(portal_privilege) and account == company\n true\n else\n false\n end\n end",
"def visible_to?(user)\n return self.user==user || !self.visible_to || self.visible_to.include?(user._id)\n end",
"def created_by?(check_user)\n return false unless check_user.present?\n return true if check_user.cornerstone_admin?\n self.user && self.user == check_user\n end",
"def show?\n @current_user.permission('Donor', :guest)\n end"
] | [
"0.6850293",
"0.6849805",
"0.6837078",
"0.68338585",
"0.6779485",
"0.6776255",
"0.6721402",
"0.66866213",
"0.6574234",
"0.6566158",
"0.655444",
"0.6538602",
"0.6532752",
"0.65129113",
"0.6433698",
"0.6376648",
"0.6370196",
"0.6361917",
"0.6344178",
"0.6314224",
"0.6314224",
"0.6292685",
"0.6270158",
"0.6257784",
"0.6238216",
"0.623374",
"0.62159574",
"0.61995363",
"0.61582655",
"0.6155665",
"0.61534697",
"0.6137573",
"0.6127419",
"0.61262065",
"0.611595",
"0.6104794",
"0.6096067",
"0.6086088",
"0.6082543",
"0.60752064",
"0.60736454",
"0.6068996",
"0.6067106",
"0.6066876",
"0.60653585",
"0.60542333",
"0.60518277",
"0.60495025",
"0.6043598",
"0.6040937",
"0.6039071",
"0.60370487",
"0.6028499",
"0.6027485",
"0.6022955",
"0.6011245",
"0.59909284",
"0.59882545",
"0.5985956",
"0.5981274",
"0.5979677",
"0.5974585",
"0.5971515",
"0.59596586",
"0.5959375",
"0.5952963",
"0.594689",
"0.5943557",
"0.59391075",
"0.5938487",
"0.59357756",
"0.593485",
"0.59279907",
"0.59274346",
"0.592582",
"0.59193724",
"0.5917655",
"0.59094906",
"0.5908632",
"0.59053457",
"0.59051085",
"0.59007156",
"0.5898176",
"0.58971924",
"0.5896312",
"0.5891104",
"0.5890354",
"0.58894765",
"0.5888422",
"0.5883181",
"0.58790576",
"0.5873556",
"0.5863828",
"0.5862961",
"0.58612704",
"0.5859955",
"0.58592147",
"0.58580667",
"0.5857406",
"0.58493143"
] | 0.61404294 | 31 |
This method is autogenerated. Do not change directly. | def to_sdd_xml(meta, xml)
xml.send(meta[:xml_name]) do
self.class.xml_fields.each do |field|
if self[field[:db_field_name]]
if self[field[:db_field_name]].is_a? Array
logger.debug 'Translating to XML and the object is an Array'
self[field[:db_field_name]].each_with_index do |instance, index|
xml.send(:"#{field[:xml_field_name]}", instance, 'index' => index)
end
else
xml.send(:"#{field[:xml_field_name]}", self[field[:db_field_name]])
end
end
end
# go through children if they have something to add, call their methods
kids = self.class.children_models
unless kids.nil? || kids.empty?
kids.each do |k|
models = send(k[:model_name].pluralize)
models.each do |m|
m.to_sdd_xml(k, xml)
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def custom; end",
"def custom; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def refutal()\n end",
"def implementation; end",
"def implementation; end",
"def probers; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def overrides; end",
"def generated\n end",
"def set; end",
"def set; end",
"def definition\n super\n end",
"def definition\n super\n end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def verdi; end",
"def formation; end",
"def offences_by; end",
"def generated_by\n\t\t\n\tend",
"def ref; end",
"def suivre; end",
"def generated_on\n\t\t\n\tend",
"def value; end",
"def value; end",
"def value; end",
"def value; end",
"def value; end"
] | [
"0.7373633",
"0.65087914",
"0.65087914",
"0.645239",
"0.6378533",
"0.6378533",
"0.6378533",
"0.6378533",
"0.6254785",
"0.62208474",
"0.62208474",
"0.6191855",
"0.61281425",
"0.61281425",
"0.61281425",
"0.61281425",
"0.61281425",
"0.61281425",
"0.61281425",
"0.6120204",
"0.61173034",
"0.6063574",
"0.6063574",
"0.60588145",
"0.60588145",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.59989387",
"0.5986795",
"0.5971577",
"0.5963485",
"0.59293026",
"0.590278",
"0.589709",
"0.5891194",
"0.5877728",
"0.5877728",
"0.5877728",
"0.5877728",
"0.5877728"
] | 0.0 | -1 |
This method is autogenerated. Do not change directly. | def create_children_from_sdd_json(meta, h)
# Go through the children
self_model = meta[:model_name].camelcase(:upper).constantize
kids = self_model.children_models
unless kids.nil? || kids.empty?
kids.each do |k|
# check if the kids have a json object at this level
if h[k[:xml_name]]
logger.debug "XML child is #{k[:xml_name]}"
logger.debug "Model name is #{k[:model_name]}"
if h[k[:xml_name]].is_a? Array
logger.debug "#{k[:xml_name]} is an array, will add all the objects"
h[k[:xml_name]].each do |h_instance|
klass = k[:model_name].camelcase(:upper).constantize
if klass.respond_to? :from_sdd_json
model = klass.from_sdd_json(k, h_instance)
# Assign the foreign key on the object
model["#{meta[:model_name]}_id"] = id
model.save!
else
logger.warn "Class #{klass} does not have instance method 'from_sdd_json'"
end
end
elsif h[k[:xml_name]].is_a? Hash
logger.debug "#{k[:xml_name]} is a single object, will add only one"
klass = k[:model_name].camelcase(:upper).constantize
if klass.respond_to? :from_sdd_json
model = klass.from_sdd_json(k, h[k[:xml_name]])
# Assign the foreign key on the object
model["#{meta[:model_name]}_id"] = id
model.save!
else
logger.warn "Class #{klass} does not have instance method 'from_sdd_json'"
end
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def custom; end",
"def custom; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def refutal()\n end",
"def implementation; end",
"def implementation; end",
"def probers; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def overrides; end",
"def generated\n end",
"def set; end",
"def set; end",
"def definition\n super\n end",
"def definition\n super\n end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def verdi; end",
"def formation; end",
"def offences_by; end",
"def generated_by\n\t\t\n\tend",
"def ref; end",
"def suivre; end",
"def generated_on\n\t\t\n\tend",
"def transferred_properties; end",
"def transferred_properties; end",
"def value; end",
"def value; end",
"def value; end"
] | [
"0.73732734",
"0.6505777",
"0.6505777",
"0.6450235",
"0.6377401",
"0.6377401",
"0.6377401",
"0.6377401",
"0.6253046",
"0.6218102",
"0.6218102",
"0.6190521",
"0.6126704",
"0.6126704",
"0.6126704",
"0.6126704",
"0.6126704",
"0.6126704",
"0.6126704",
"0.61183673",
"0.6115741",
"0.6061867",
"0.6061867",
"0.6057763",
"0.6057763",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59974664",
"0.59845406",
"0.5969089",
"0.5962703",
"0.5926849",
"0.5902063",
"0.5894451",
"0.58892286",
"0.5877034",
"0.5877034",
"0.5876689",
"0.5876689",
"0.5876689"
] | 0.0 | -1 |
strip leading and trailing spaces from names, login and email | def strip_spaces
# these are conditionalized because it is called before the validation
# so the validation will make sure they are setup correctly
if self.first_name? then self.first_name.strip! end
if self.last_name? then self.last_name.strip! end
if self.login? then self.login.strip! end
if self.email? then self.email.strip! end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_login\n self.login.to_s.strip!\n end",
"def remove_whitespace\n self.first_name = self.first_name.strip\n self.last_name = self.last_name.strip\n self.biography = self.biography.strip\n end",
"def remove_whitespace\n self.name = self.name.strip\n self.phone = self.phone.strip\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 clean_space_in_email\n self.unconfirmed_email.gsub!(' ', '') if self.unconfirmed_email.present?\n self.email.gsub!(' ', '') if self.email.present?\n end",
"def clean_username(username)\n\n my_username = username\n #remove all non- alphanumeric character (expect dashes '-')\n my_username = my_username.gsub(/[^0-9a-z -]/i, '')\n\n #remplace dashes() for empty space because if the user add dash mean that it want separate the username\n my_username = my_username.gsub(/[-]/i, ' ')\n\n #remplace the empty space for one dash by word\n my_username.downcase!\n my_username.strip!\n username_split = my_username.split(' ').join('-')\n\n end",
"def name\n \"#{first_name.strip} #{last_name.strip}\".strip\n end",
"def trim_name_whitespace!\r\n self.name.strip!\r\n end",
"def full_name\n \"#{firstname} #{lastname}\".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 \"#{first_name} #{last_name}\".strip\n end",
"def sanitize_user\r\n self.first_name = Sanitize.clean(self.first_name).gsub('&','&').gsub('>', '>') unless self.first_name.blank?\r\n end",
"def full_name\n \"#{first_name.strip} #{last_name.strip}\"\n end",
"def remove_excess_whitespace_from_name\n self.name = name&.split&.join(' ')\n end",
"def full_name\n \"#{firstname} #{lastname}\".strip\n end",
"def full_name\n [first_name, last_name].join(' ').strip\n end",
"def name\n result = []\n result << self.first_name\n result << self.last_name\n if result.compact.empty?\n self.user.login if self.user\n else\n result.compact.map {|m| m.to_s.strip}.reject {|i| i.blank?}.join(' ')\n end\n end",
"def name_swap\n\tuser_name = first_last.split(' ')\n\nend",
"def full_name\n [ first_name, last_name].join(' ').squeeze(' ')\n end",
"def cleanse_name\n return if self.name.nil?\n self.name = self.name.strip\n self.name = nil if self.name.length == 0\n end",
"def name\n [first_name, last_name].join(' ').strip\n end",
"def strip_strings\n self.name = name.strip\n end",
"def strip_strings\n self.name = name.strip\n end",
"def show_name\n \tif first_name\n \t\t\"#{first_name}\".strip.squeeze(\" \")\n \telse\n \t\temail\n \tend\n end",
"def full_name\n \n if (not self.first_name.nil? and not self.first_name.eql? \"\") or (not self.last_name.nil? and not self.last_name.eql? \"\")\n \"#{self.title} #{self.first_name} #{self.last_name}\".strip\n elsif self.username\n self.username \n else\n # wrapped email only prefix\n\n parsed_email = self.email.split('@')\n parsed_email[0]\n end\n end",
"def strip_columns\n user_fields = %W(\n name\n email\n address\n )\n\n user_fields.each do |field|\n next if self[field].nil?\n self[field] = self[field].strip\n end\n end",
"def remove_whitespace(dirty_name)\n \n return dirty_name.split(' ').join(\" \") \n \n end",
"def format_email\n email.downcase!.strip!\n end",
"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 display_name\n return \"#{first_name} #{last_name}\".strip if first_name\n return email\n end",
"def ensure_username\n return unless username.blank?\n\n self.username = email.gsub(/@.*$/, '')\n end",
"def display_name\n email.gsub(/@.*/, \"\")\n end",
"def scrub\n self.gsub(/[^a-zA-Z\\s0-9\\.]/, '').gsub(/\\t/, ' ').gsub(/\\r/, ' ').gsub(/\\s\\s/, '').lstrip.rstrip\n end",
"def get_user_name\n if first_name.blank?\n return email.split('@').first.capitalize unless email.blank? \n else\n return first_name.capitalize + \" \" + last_name.capitalize\n end \n return ''\n end",
"def login_user_name\n user_name.tr('.', '')\n end",
"def normalize_email(email)\n raise \"E-mail address is blank\" if email.blank?\n raise \"Invalid e-mail address\" unless Authentication.email_regex =~ email\n email.strip\n end",
"def format_name(first, last)\n if first == \"\" || last == \"\"\n \tnil\n else \n \tfirst.gsub!(/[^A-Za-z]/, '')\n \tlast.gsub!(/[^A-Za-z]/, '')\n \tfirst = first.strip\n\tlast = last.split.join(\"\").strip\n\tuser_name = first[0] + last\n\tuser_name = user_name.downcase \n end\n user_name\nend",
"def full_name\n if first_name? && last_name?\n name_words = first_name.split(\" \") + last_name.split(\" \")\n return name_words.map{ |w| w.capitalize }.join(\" \")\n else\n return email\n end\n end",
"def safe_user_name\n user_name\n .gsub(\"'\", '')\n .gsub(/[^-_A-Za-z0-9]+/, '-')\n .delete_prefix('-')\n .delete_suffix('-')\n end",
"def format_username\n \t_email_base = self.email[/[^@]+/]\n \tself.username ||= _email_base.camelize.underscore.gsub(/\\./,\"_\") unless _email_base.nil?\n\n end",
"def show_name\n return_string = \"\"\n if first_name.present? || last_name.present?\n return_string = \"#{first_name} #{last_name}\".strip\n end\n if login.present?\n return_string = return_string.blank? ? login : \"#{return_string} (#{login})\".strip\n end\n if return_string.blank?\n return_string = email\n end\n return_string\n end",
"def normalize_fields\n self.email.downcase!\n end",
"def strip(*fields)\n sanitize(*fields) { |value| value.strip }\n end",
"def full_name\n \"#{first_name} #{last_name}\".strip.squeeze(' ').titleize\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 normalize_fields\n\t\tself.email.downcase!\n\tend",
"def format_name(first, last)\n if last == '' || first == ''\n word = nil\n else\n user_name = ''\n user_name += first.gsub(' ', '').gsub(/[^0-9A-Za-z]/, '')[0]\n user_name += (last.gsub(' ','').gsub(/[^0-9A-Za-z]/, ''))\n user_name.gsub(/\\d/, '').downcase\n end\nend",
"def full_name\n \treturn \"#{first_name} #{last_name}\".strip if(first_name || last_name) \n \t\"Anonymous\"\n end",
"def name\n if first_name.present? || last_name.present?\n [first_name, last_name].join(\" \").strip\n else\n username\n end\n end",
"def username_format\n return if self.username.nil?\n self.username.gsub!(/[^0-9a-z\\- ]/i, '_')\n self.username.gsub!(/\\s+/, '-')\n self.username = self.username.downcase\n self.username = self.username.byteslice(0, 24) #substring 24\n end",
"def normalize_attributes\n self.first_name = self.first_name.downcase.titleize\n self.last_name = self.last_name.downcase.titleize\n self.email.downcase!\n end",
"def strip_name\n if self.name.present?\n self.name.strip!\n end\n end",
"def normalize_fields\n self.email.downcase!\n end",
"def normalize_fields\n self.email.downcase!\n end",
"def normalize_fields\n self.email.downcase!\n end",
"def normalize_fields\n self.email.downcase!\n end",
"def normalize_fields\n self.email.downcase!\n end",
"def normalize_fields\n self.email.downcase!\n end",
"def format_name(first, last)\n\tuser_name = \"\"\n\tif !first.empty? && !last.empty?\n\t \tuser_name = first.strip[0].downcase + last.strip.split.join('')\n\telse\n\t\treturn nil\n\tend\n\tuser_name.downcase\nend",
"def format_name(first, last)\n\n if first.length == 0\n p nil\n elsif last.length == 0\n p nil\n else\n # this will remove all empty spaces\n first_name = first.gsub(/[^A-Za-z]/,\"\")\n last_name = last.gsub(/[^A-Za-z]/, \"\")\n # this will get the first letter in first name\n first_inlast = first_name[0]\n # this will return the first letter of the name + the last name\n full_name = first_inlast + last_name\n # this will return the full name lowercased along with deleting white spaces\n lowercase_name = full_name.downcase\n # remove_allcharacters = full_name.gsub(/[^a-zA-Z0-9\\-]/,\"\")\n p lowercase_name\n end\nend",
"def trimmed_names \n trimmed_names = []\n raw_names.each do |name|\n article_trim_strings.each do |trim| #Remove all trim words from name\n name = !name.index(trim).nil? ? name.sub(trim, \"\") : name\n end\n name = name.strip\n if(name.length > 5)\n\ttrimmed_names << name #Add trimmed name to the list\n end\n end\n trimmed_names\n end",
"def formatAuthName(auth)\n str = \"\"\n fname, lname = auth.text_at(\"./fname\"), auth.text_at(\"./lname\")\n if lname && fname\n str = \"#{lname}, #{fname}\"\n mname, suffix = auth.text_at(\"./mname\"), auth.text_at(\"./suffix\")\n mname and str += \" #{mname}\"\n suffix and str += \", #{suffix}\"\n elsif fname\n str = fname\n elsif lname\n str = lname\n elsif auth.text_at(\"./email\") # special case\n str = auth.text_at(\"./email\")\n else\n str = auth.text.strip\n str.empty? and return nil # ignore all-empty author\n puts \"Warning: can't figure out author #{auth}\"\n end\n return str\nend",
"def sanitise_email(email)\n return nil if email.blank?\n #remove all non-word chars\n email.collect{ |e| e.gsub(/[^\\w]-/,'')}\n return email\n end",
"def full_name\n [self.first_name, self.last_name].compact.join(\" \").strip\n end",
"def smart_name\n return '' if short_name.blank? && long_name.blank?\n\n (short_name.blank? ? long_name.strip : short_name.strip)\n end",
"def extract_name(email)\n\t\t# Uses regular expressions to remove everything after the \"@ as well as any digits\"\n\t\temail.gsub(/@.*$/,'').gsub(/[0-9]+/,'')\n\tend",
"def display_name\n \"#{given_name} #{surname}\".strip\n end",
"def formatAuthName(auth)\n str = \"\"\n if auth.at(\"lname\") && auth.at(\"fname\")\n str = auth.at(\"lname\").text.strip + \", \" + auth.at(\"fname\").text.strip\n auth.at(\"mname\") and str += \" \" + auth.at(\"mname\").text.strip\n auth.at(\"suffix\") and str += \", \" + auth.at(\"suffix\").text.strip\n elsif auth.at(\"fname\")\n str = auth.at(\"fname\").text\n elsif auth.at(\"lname\")\n str = auth.at(\"lname\").text\n else\n puts \"Warning: can't figure out author #{auth}\"\n str = auth.text\n end\n return str\nend",
"def full_name\n \t([first_name, last_name].compact-['']).join(' ')\n end",
"def get_first_and_last_name\n if first_name && last_name && !first_name.empty? && !last_name.empty?\n [first_name, last_name]\n elsif description.present?\n [\n description.split(' ')[0],\n description.split(' ')[1]\n ]\n else\n [name[0..4], ''] # Return just the first 5 char from the username, just to increase the chances\n end\n end",
"def strip_blanks\n self.title = self.title.strip\n self.code = self.code.strip\n self.complement_title = self.complement_title.strip\n end",
"def name_clean\n self.name.gsub(/_/, \" \")\n end",
"def full_name\n\n return \"#{first_name} #{last_name}\".strip if (first_name || last_name)\n \"Anonymouse\"\n end",
"def determine_name_parts(name)\n @first_name = name[0..name.index(\" \")].strip.downcase\n @last_name = name[name.index(\" \")..name.length].strip.downcase\n end",
"def full_user_name\n formatedName=first_name[0].upcase+first_name[1,first_name.size].downcase+\" \"+last_name[0].upcase+last_name[1,last_name.size].downcase\n return formatedName.strip if (first_name || last_name)\n return \"Anonymous\"\n end",
"def whole_name\n [given_name, family_name].compact.join(' ')\n end",
"def strip_naked\n return self if blank?\n self.downcase.strip.gsub(/([\\s]{2,})/, ' ')\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 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 safe_name\n name.to_s.gsub(/[^a-zA-Z0-9 _\\-:\\.]/, '').gsub(/:/, ' - ').gsub(/ +/, ' ')\n end",
"def clean!\n reject! { |name| name.blank? }\n map! { |name| name.strip }\n map! { |name| name.downcase } if force_lowercase\n map! { |name| name.parameterize } if force_parameterize\n map! { |name| name.gsub('_','-') }\n uniq!\n end",
"def full_name\n # clean_name\n \"#{@first_name} #{@middle_name} #{@last_name}\"\n [first_name, middle_name, last_name].compact.join(' ')\n end",
"def name(use_email = true)\n if (firstname.blank? && surname.blank?) || use_email then\n return email\n else\n name = \"#{firstname} #{surname}\"\n return name.strip\n end\n end",
"def clean_name(name)\n if name.present?\n name.gsub(/(\\s|-|\\.|,)/,'')\n end\n end",
"def name\n [first_name, initial, last_name].select {|x| not x.nil?}.map {|x| x.strip}.join(\" \").titleize\n end",
"def full_name\n\t name = \"\"\n\t name = name + \"#{first_name}\" if !first_name.nil? || !first_name.empty?\n\t name = name + \" #{last_name}\" if !last_name.nil? || !last_name.empty?\n\t\tname.gsub(/^ /,'')\n\tend",
"def full_name\n\t name = \"\"\n\t name = name + \"#{first_name}\" if !first_name.nil? || !first_name.empty?\n\t name = name + \" #{last_name}\" if !last_name.nil? || !last_name.empty?\n\t\tname.gsub(/^ /,'')\n\tend",
"def username\n email.match(/[^@]+/).to_s\n end",
"def scrub_email_address\n self.email_address.downcase\n end",
"def full_name\n if (forename != '' && surname != '')\n forename+' '+surname\n elsif (forename != '')\n forename\n elsif (email != '')\n email\n end\n end",
"def remove_whitespace\n self.time = self.time.strip\n self.description = self.description.strip\n self.venue = self.venue.strip.downcase\n self.location = self.location.strip.downcase\n end",
"def name(use_email = true)\n if (firstname.blank? && surname.blank?) || use_email\n email\n else\n name = \"#{firstname} #{surname}\"\n name.strip\n end\n end",
"def authority_name\n [surname, given_name].reject(&:blank?).join(', ')\n end",
"def prepare_email\n self.email = email.downcase.strip if email\n end",
"def split_name\n\t\t@full_name.split('')\n\tend",
"def format_attributes\n self.email = self.email.downcase\n self.first_name = self.first_name.titleize\n self.last_name = self.last_name.titleize\n self.full_name = \"#{self.first_name} #{self.last_name}\"\n end"
] | [
"0.7560539",
"0.7235534",
"0.70129585",
"0.69557816",
"0.68847084",
"0.6797453",
"0.6666385",
"0.666385",
"0.66604817",
"0.660489",
"0.660489",
"0.660489",
"0.660489",
"0.6599209",
"0.6575654",
"0.6553751",
"0.6549051",
"0.65147996",
"0.6501655",
"0.64907503",
"0.64902186",
"0.647946",
"0.6438535",
"0.64355767",
"0.64355767",
"0.6433616",
"0.6432865",
"0.6420437",
"0.64162356",
"0.6410445",
"0.6408169",
"0.6408169",
"0.6408169",
"0.6394492",
"0.6387022",
"0.6379892",
"0.6379873",
"0.6350302",
"0.63477415",
"0.63449126",
"0.6341887",
"0.6333198",
"0.63273793",
"0.63143414",
"0.63127166",
"0.6304791",
"0.6297143",
"0.6295218",
"0.62894386",
"0.627257",
"0.62351716",
"0.6231517",
"0.62134236",
"0.6184296",
"0.61712945",
"0.6166419",
"0.61527765",
"0.61527765",
"0.61527765",
"0.61527765",
"0.61527765",
"0.61527765",
"0.61469233",
"0.6144479",
"0.6139451",
"0.6138614",
"0.6134982",
"0.6126038",
"0.6115958",
"0.6092302",
"0.60910714",
"0.6090441",
"0.6088227",
"0.60720193",
"0.60468304",
"0.6039687",
"0.60365915",
"0.6026029",
"0.6025766",
"0.60225403",
"0.6012959",
"0.59987676",
"0.59955555",
"0.5989665",
"0.59837115",
"0.5979991",
"0.5977273",
"0.59658587",
"0.59580934",
"0.59572136",
"0.59572136",
"0.59565955",
"0.5951242",
"0.59499866",
"0.5943191",
"0.59228224",
"0.59210336",
"0.5915529",
"0.5912184",
"0.5911917"
] | 0.7366326 | 1 |
is this user the anonymous user? | def anonymous?
id == 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anonymous?\n user.nil?\n end",
"def anonymous?\n user.nil? || as_anonymous?\n end",
"def is_anonymous\n @user_id == Gss::Provider::IDENTITY_ANONYMOUS\n end",
"def anonymous_user?\n\t\t\tunless logged_in?\n\t\t\t\tredirect_to root_path\n\t\t\tend\n\t\tend",
"def is_anonymous_user?\n users.first.is_a?(AnonymousUser)\n end",
"def anonymous?\n private? || guest? || user.protected?\n end",
"def authenticated?\n !anonymous?\n end",
"def user_authenticated?\n !session[:user_id].nil?\n end",
"def user_is_authenticated\r\n !!current_user\r\n end",
"def anonymous?\n email == ANONYMOUS_EMAIL\n end",
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def current_user\n !session[:uid].nil?\n end",
"def if_anonymous\n !is_bot? && !view_context.user_signed_in? && current_group.enable_anonymous\n end",
"def current_user?\n return session[:user_id] != nil\n end",
"def logged_in\n current_user != nil\n end",
"def logged_in?\n current_user != :false \n end",
"def logged_in?\r\n current_user != :false\r\n end",
"def user_logged?\n !session[:user_id].nil?\n end",
"def user?\n get_mode == :user\n end",
"def user_is_logged_in?\n !!session[:user_id]\n end",
"def logged_in?\n current_user != :false\n end",
"def logged_in?\n current_user != :false\n end",
"def logged_in\n logged_in_user != nil\n end",
"def logged_in?\n !!logged_user\n end",
"def logged_in?\n !session[:user_id].nil? #&& User.find(session[:user_id]).owns(@current_site)\n end",
"def user_is_logged_in?\n !!session[:user_id]\n end",
"def is_user?\n user ? true : false\n end",
"def logged_in?\n !!logged_in_user \n end",
"def current_user?(user)\r\n user == current_user\r\n end",
"def current_user?(user)\n \tuser == current_user\n \tend",
"def current_user?(user)\n \tuser == current_user\n \tend",
"def logged_in?\n current_user != :false\n end",
"def user_login?\n\t !!current_user\n\tend",
"def current_user?(user)\n \t\tuser == current_user\n \tend",
"def anonymous?\n false\n end",
"def user_logged_in?\n !current_user.nil?\n end",
"def user_logged_in?\n !current_user.nil?\n end",
"def user_logged_in?\n !current_user.nil?\n end",
"def user_logged_in?\n !current_user.nil?\n end",
"def user_logged_in?\n !current_user.nil?\n end",
"def user_logged_in?\n !current_user.nil?\n end",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def user_logged_in?\n current_user.present?\n end",
"def user_logged_in?\n current_user.present?\n end",
"def current_user?(user)\n \t\tuser == current_user\n \tend",
"def logged_in?\n session[:uid] != nil\n end",
"def logged_in?\n session[:uid] != nil\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def logged_in?\n !!current_ma_user\n end",
"def to_user_not_authenticated?\n return if user_not_authenticated?\n end",
"def authenticated?\n !!session[:user]\n end",
"def logged_in?\n !current_user.blank?\n end",
"def logged_in?\n current_user_id.to_i > 0\n end",
"def is_this_user\n\t\[email protected] == current_user.id\n\tend",
"def anyone_signed_in?\n !current_user.nil?\n end",
"def is_logged_in?\n !session[:user_id].nil?\n end",
"def anonymous?\n !!self[:anonymous]\n end",
"def anonymous?\n !!self[:anonymous]\n end",
"def anonymous?\n !!self[:anonymous]\n end",
"def current_user?(user)\n\t\tcurrent_user == user\n\tend",
"def logged_in?\r\n !!current_user\r\n end",
"def logged_in?\n\t\t\tcurrent_user.is_a? User\n\t\tend",
"def current_user?(user)\n user == current_user\n end",
"def logged_in_normal_user?\n normal_user.present?\n end",
"def current_user?(user)\n logged_in? and user == current_user\n end",
"def accessible_for?(user)\n user_id == user.id && !user.anonimous?\n end",
"def logged_in?\n\t\t !!current_user\n end",
"def logged_in?\n (current_user ? login_access : false).is_a?(User)\n end",
"def logged_in?\n \t\tcurrent_user.is_a? User\n \tend",
"def user_logged_in?\n session[:user_id].present?\n end",
"def person_logged_in?\n !session[:person_id].nil?\n end",
"def public_user?\n \tcurrent_user.username.eql? \"public_user\"\n end",
"def is_logged_in?\n !session[:user_email].nil?\n end",
"def current_user?(user)\n\t\tuser==current_user\n\tend",
"def logged_in?\n\t\t!!current_user\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n\t !!current_user\n\tend",
"def user_logged_in?\n session[:user]\n end",
"def signed_in?\n !current_account.is_anonymous?\n end",
"def logged_in_user?\n !current_user.nil?\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end"
] | [
"0.88499546",
"0.8657433",
"0.8383578",
"0.8324707",
"0.82785976",
"0.8135039",
"0.7969194",
"0.78817886",
"0.78217703",
"0.7734905",
"0.76812845",
"0.7604624",
"0.7599052",
"0.7525505",
"0.75085247",
"0.75039715",
"0.7489127",
"0.74887115",
"0.7482023",
"0.74815583",
"0.7422581",
"0.7422581",
"0.7419682",
"0.7415854",
"0.7398282",
"0.7390484",
"0.7380825",
"0.736073",
"0.7356459",
"0.73323095",
"0.73323095",
"0.73236513",
"0.7315008",
"0.7312852",
"0.73072296",
"0.729791",
"0.729791",
"0.729791",
"0.729791",
"0.729791",
"0.729791",
"0.7295129",
"0.7294463",
"0.7294463",
"0.7294463",
"0.7294463",
"0.7294463",
"0.7294463",
"0.7294463",
"0.7294463",
"0.7294463",
"0.7294463",
"0.7293152",
"0.7293152",
"0.72926676",
"0.72897977",
"0.72897977",
"0.7288389",
"0.7288389",
"0.7288389",
"0.7288389",
"0.7288389",
"0.7288389",
"0.7288389",
"0.7285265",
"0.7283287",
"0.7278368",
"0.72776926",
"0.72772145",
"0.7267424",
"0.7266918",
"0.72582775",
"0.7248794",
"0.7248794",
"0.7248794",
"0.7248095",
"0.7239443",
"0.72381955",
"0.7230129",
"0.72295266",
"0.72282887",
"0.7228169",
"0.7227109",
"0.72243696",
"0.721971",
"0.7217423",
"0.72159046",
"0.72153944",
"0.72149444",
"0.7213553",
"0.7210193",
"0.720996",
"0.720996",
"0.720996",
"0.720996",
"0.7208136",
"0.7205715",
"0.71974677",
"0.7197169",
"0.7196895",
"0.7196895"
] | 0.0 | -1 |
Encrypts the password with the user salt | def salted_sha_encrypt(password)
self.class.local_encrypt(password, salt)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt_password\n self.salt = make_salt unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end",
"def encrypt_password\n self.salt = make_salt unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end",
"def encrypt_password\n if self.password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.password = BCrypt::Engine.hash_secret(password, self.salt)\n end\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(password + salt)\n end",
"def encrypt_password\n\t unless @password.blank?\n self.password_salt = salt\n self.encrypted_password = encrypt(@password, salt)\n\t end\n\tend",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt_password()\n if password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.encrypted_password = BCrypt::Engine.hash_secret(password, self.salt)\n end\n end",
"def encrypt(password, salt=nil)\n salt ||= self.salt\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt_password\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end",
"def encrypt_password(password)\n self.class.secure_digest([password, password_salt])\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.encrypted_password = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.encrypted_password= BCrypt::Engine.hash_secret(password, salt)\n end\n end",
"def encrypt(password)\n User.password_digest(password, salt)\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt(password)\n self.class.encrypt(password) #, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end",
"def encrypt(password)\n self.class.encrypt(password, salt)\n end"
] | [
"0.8456656",
"0.83809954",
"0.837295",
"0.83666867",
"0.8361271",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83539045",
"0.8353123",
"0.83147633",
"0.8314556",
"0.83011955",
"0.82853645",
"0.8279242",
"0.8253498",
"0.82321554",
"0.82296264",
"0.82296264",
"0.82296264",
"0.82296264",
"0.82296264",
"0.82236284",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076",
"0.82061076"
] | 0.0 | -1 |
Encrypts just using MD5 hash | def md5_encrypt(password)
self.class.remote_encrypt(password)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_md5(pass)\r\n return Digest::MD5.hexdigest(pass)\r\nend",
"def encrypt(password) #, salt)\n Digest::MD5.hexdigest(password)\n end",
"def to_md5(pass)\n return Digest::MD5.hexdigest(pass)\nend",
"def to_md5(salt = \"\")\n hashsum(:md5, salt)\n end",
"def md5(string)\n\tDigest::MD5.hexdigest(string)\nend",
"def md5(value)\n merge(md5: value.to_s)\n end",
"def md5?; @md5; end",
"def md5_hash(data)\n md5 = Digest::MD5.new\n md5 << data\n md5.hexdigest\n end",
"def cram_md5_challenge; end",
"def encrypt_password\n \tself.password = Digest::MD5.hexdigest(self.password)\n end",
"def encrypt(string)\n Digest::SHA1.hexdigest(string)\n end",
"def encrypt(string)\n Digest::SHA1.hexdigest(string)\n end",
"def md5\n Base64.strict_encode64(@signature.md5)\n end",
"def encrypt_password\n self.password = Digest::MD5.hexdigest(self.password).encode('UTF-8')\n end",
"def md5_hash_hex(x)\n h = Digest::MD5.new\n h << x\n return h.to_s # to_s method gives the result in hex\nend",
"def md5 hash\n\t\treturn Digest::MD5.hexdigest(hash.to_s).to_s\n\tend",
"def encrypt(*tokens)\n digest = tokens.flatten.join(join_token)\n stretches.times { digest = Digest::MD5.digest(digest) }\n digest.unpack1(\"H*\")\n end",
"def md5sum\n Digest::MD5.hexdigest(self)\n end",
"def createMD5Hash(data)\n\t\treturn Digest::MD5.digest(data)\n\tend",
"def md5\n Digest::MD5.hexdigest(self)\n end",
"def md5\n\t\tDigest::MD5.hexdigest(self)\n\tend",
"def md5_sum(key)\n md5 = Digest::MD5.new\n buffer = ''\n with_input_io(key) do |io|\n while io.read(65536, buffer)\n md5 << buffer\n end\n end\n md5.base64digest\n end",
"def to_md5(length = 32)\n Digest::MD5.hexdigest(self)[0,length]\n end",
"def md5_hash_email(email)\n\t\tDigest::MD5.hexdigest(email.strip.downcase)\n\tend",
"def md5\n @md5 ||= digest(path, :md5)\n end",
"def encode(plain_pass)\n md5 salt + plain_pass + salt\n end",
"def md5sum\n @md5sum ||= Digest::MD5.hexdigest(self.to_checksum_string)\n end",
"def encrypt(val)\n #Usage self.encrypt(val)\n return Digest::SHA1.hexdigest(val.to_s) \n end",
"def md5\n @gapi[\"md5Hash\"]\n end",
"def make_md5(string = nil)\n # create a random string if one is not provided\n string ||= (0...32).map{ ('a'..'z').to_a[rand(26)] }.join\n # hash it\n (Digest::MD5.new << string).to_s\n end",
"def md5\n @attributes[:md5]\n end",
"def encrypt(data)\n Digest::SHA1.hexdigest(data + @salt)\n end",
"def _hash_digest(key)\n m = Digest::MD5.new\n m.update(key)\n\n # No need to ord each item since ordinary array access\n # of a string in Ruby converts to ordinal value\n return m.digest\n end",
"def encrypt; end",
"def challenge5(s, k)\n Utils::HexString.from_bytes(CryptUtil.xor(s.bytes, k))\n end",
"def mutate_md5(cell)\n cell ? Digest::MD5.base64digest(cell) : cell\n end",
"def md5_of_body\n data[:md5_of_body]\n end",
"def hash( *strs )\n return Digest::MD5.hexdigest( strs.join )\n end",
"def md5_authkey( key1, key2, transact,currency, amount = nil)\n amount = \"0000\" if amount.nil?\n Digest::MD5.hexdigest( key2 +\n Digest::MD5.hexdigest( key1 + \"transact=#{transact}&amount=#{amount}¤cy=#{currency}\")\n )\n end",
"def hash!\n\t\t@@email.downcase!\n\t\thash = Digest::MD5.hexdigest(@@email)\n\t\treturn hash\n\tend",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\") \n\tend",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def encrypt(plain_password)\n md5_password = Digest::MD5.digest(plain_password)\n base64_password = Base64.encode64(md5_password).chomp\n base64_password\n end",
"def encrypt(group, name, version)\n hex_digest(OpenSSL::PKCS5.pbkdf2_hmac(\n [secret, group, name, version].join,\n salt,\n iterations,\n hash_function.length,\n hash_function\n ))\n end",
"def encrypt(code)\n ::Digest::SHA1.hexdigest \"#{salt}--#{code}\"\n end",
"def md5_hash(ts, public_key)\n private_key = Rails.application.credentials.marvel[:private_key]\n Digest::MD5.hexdigest(ts + private_key + public_key)\n end",
"def md5\n return self.body_data.md5\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def encrypt_password(password, password_seed)\n\t\t\tpass_to_hash=password + \"Securasaurus\" + password_seed\n\t\t\t\n\t\t\tcase AUTHENTASAURUS[:hashing] \n when \"SHA2\"\n Digest::SHA2.hexdigest(pass_to_hash)\n when \"SHA1\"\n Digest::SHA1.hexdigest(pass_to_hash)\n when \"MD5\"\n Digest::MD5.hexdigest(pass_to_hash)\n else\n Digest::SHA2.hexdigest(pass_to_hash)\n end\n\t\t\t\n\t\tend",
"def hash_string(value)\n return case password_hash_type\n when 'md5' then Digest::MD5.hexdigest(value + self.password_salt)\n end\n end",
"def digest(subject)\n Digest::MD5.hexdigest subject.downcase\n end",
"def md5_checksum_ticket( key1, key2, merchant, orderid, currency, amount, ticket )\n Digest::MD5.hexdigest( key2 +\n Digest::MD5.hexdigest( key1 +\n \"merchant=#{merchant}&orderid=#{orderid}&ticket=#{ticket}¤cy=#{currency}&amount=#{amount}\"\n )\n )\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def encrypt(string)\n secure_hash(\"#{salt}--#{string}\")\n end",
"def hash_password\n self.password = Digest::MD5.hexdigest(self.password)\n end",
"def encrypt(password)\n Digest::SHA1.hexdigest(\"--#{self.salt}--#{password}--\")\n end",
"def sadd\n @redis.sadd md5_list, @md5_sum\n end",
"def process_line(password)\n md5 = Digest::MD5.hexdigest(password.chop!)\n if $encoded.include? md5 then $digest[md5] = password end\nend",
"def md5; Digest::MD5.file(fname).hexdigest; end",
"def md5_authkey_preauth( key1, key2, transact, currency )\n Digest::MD5.hexdigest( key2 +\n Digest::MD5.hexdigest( key1 + \"transact=#{transact}&preauth=true¤cy=#{currency}\")\n )\n end",
"def myers_md5_implementation\n return <<'JS'\n// Joseph Myers' implementation of MD5 in JS\n// http://www.myersdaily.org/joseph/javascript/md5-text.html\nfunction md5cycle(x, k) {\nvar a = x[0], b = x[1], c = x[2], d = x[3];\n\na = ff(a, b, c, d, k[0], 7, -680876936);\nd = ff(d, a, b, c, k[1], 12, -389564586);\nc = ff(c, d, a, b, k[2], 17, 606105819);\nb = ff(b, c, d, a, k[3], 22, -1044525330);\na = ff(a, b, c, d, k[4], 7, -176418897);\nd = ff(d, a, b, c, k[5], 12, 1200080426);\nc = ff(c, d, a, b, k[6], 17, -1473231341);\nb = ff(b, c, d, a, k[7], 22, -45705983);\na = ff(a, b, c, d, k[8], 7, 1770035416);\nd = ff(d, a, b, c, k[9], 12, -1958414417);\nc = ff(c, d, a, b, k[10], 17, -42063);\nb = ff(b, c, d, a, k[11], 22, -1990404162);\na = ff(a, b, c, d, k[12], 7, 1804603682);\nd = ff(d, a, b, c, k[13], 12, -40341101);\nc = ff(c, d, a, b, k[14], 17, -1502002290);\nb = ff(b, c, d, a, k[15], 22, 1236535329);\n\na = gg(a, b, c, d, k[1], 5, -165796510);\nd = gg(d, a, b, c, k[6], 9, -1069501632);\nc = gg(c, d, a, b, k[11], 14, 643717713);\nb = gg(b, c, d, a, k[0], 20, -373897302);\na = gg(a, b, c, d, k[5], 5, -701558691);\nd = gg(d, a, b, c, k[10], 9, 38016083);\nc = gg(c, d, a, b, k[15], 14, -660478335);\nb = gg(b, c, d, a, k[4], 20, -405537848);\na = gg(a, b, c, d, k[9], 5, 568446438);\nd = gg(d, a, b, c, k[14], 9, -1019803690);\nc = gg(c, d, a, b, k[3], 14, -187363961);\nb = gg(b, c, d, a, k[8], 20, 1163531501);\na = gg(a, b, c, d, k[13], 5, -1444681467);\nd = gg(d, a, b, c, k[2], 9, -51403784);\nc = gg(c, d, a, b, k[7], 14, 1735328473);\nb = gg(b, c, d, a, k[12], 20, -1926607734);\n\na = hh(a, b, c, d, k[5], 4, -378558);\nd = hh(d, a, b, c, k[8], 11, -2022574463);\nc = hh(c, d, a, b, k[11], 16, 1839030562);\nb = hh(b, c, d, a, k[14], 23, -35309556);\na = hh(a, b, c, d, k[1], 4, -1530992060);\nd = hh(d, a, b, c, k[4], 11, 1272893353);\nc = hh(c, d, a, b, k[7], 16, -155497632);\nb = hh(b, c, d, a, k[10], 23, -1094730640);\na = hh(a, b, c, d, k[13], 4, 681279174);\nd = hh(d, a, b, c, k[0], 11, -358537222);\nc = hh(c, d, a, b, k[3], 16, -722521979);\nb = hh(b, c, d, a, k[6], 23, 76029189);\na = hh(a, b, c, d, k[9], 4, -640364487);\nd = hh(d, a, b, c, k[12], 11, -421815835);\nc = hh(c, d, a, b, k[15], 16, 530742520);\nb = hh(b, c, d, a, k[2], 23, -995338651);\n\na = ii(a, b, c, d, k[0], 6, -198630844);\nd = ii(d, a, b, c, k[7], 10, 1126891415);\nc = ii(c, d, a, b, k[14], 15, -1416354905);\nb = ii(b, c, d, a, k[5], 21, -57434055);\na = ii(a, b, c, d, k[12], 6, 1700485571);\nd = ii(d, a, b, c, k[3], 10, -1894986606);\nc = ii(c, d, a, b, k[10], 15, -1051523);\nb = ii(b, c, d, a, k[1], 21, -2054922799);\na = ii(a, b, c, d, k[8], 6, 1873313359);\nd = ii(d, a, b, c, k[15], 10, -30611744);\nc = ii(c, d, a, b, k[6], 15, -1560198380);\nb = ii(b, c, d, a, k[13], 21, 1309151649);\na = ii(a, b, c, d, k[4], 6, -145523070);\nd = ii(d, a, b, c, k[11], 10, -1120210379);\nc = ii(c, d, a, b, k[2], 15, 718787259);\nb = ii(b, c, d, a, k[9], 21, -343485551);\n\nx[0] = add32(a, x[0]);\nx[1] = add32(b, x[1]);\nx[2] = add32(c, x[2]);\nx[3] = add32(d, x[3]);\n}\n\nfunction cmn(q, a, b, x, s, t) {\na = add32(add32(a, q), add32(x, t));\nreturn add32((a << s) | (a >>> (32 - s)), b);\n}\n\nfunction ff(a, b, c, d, x, s, t) {\nreturn cmn((b & c) | ((~b) & d), a, b, x, s, t);\n}\n\nfunction gg(a, b, c, d, x, s, t) {\nreturn cmn((b & d) | (c & (~d)), a, b, x, s, t);\n}\n\nfunction hh(a, b, c, d, x, s, t) {\nreturn cmn(b ^ c ^ d, a, b, x, s, t);\n}\n\nfunction ii(a, b, c, d, x, s, t) {\nreturn cmn(c ^ (b | (~d)), a, b, x, s, t);\n}\n\nfunction md51(s) {\ntxt = '';\nvar n = s.length,\nstate = [1732584193, -271733879, -1732584194, 271733878], i;\nfor (i=64; i<=s.length; i+=64) {\nmd5cycle(state, md5blk(s.substring(i-64, i)));\n}\ns = s.substring(i-64);\nvar tail = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];\nfor (i=0; i<s.length; i++)\ntail[i>>2] |= s.charCodeAt(i) << ((i%4) << 3);\ntail[i>>2] |= 0x80 << ((i%4) << 3);\nif (i > 55) {\nmd5cycle(state, tail);\nfor (i=0; i<16; i++) tail[i] = 0;\n}\ntail[14] = n*8;\nmd5cycle(state, tail);\nreturn state;\n}\n\n/* there needs to be support for Unicode here,\n * unless we pretend that we can redefine the MD-5\n * algorithm for multi-byte characters (perhaps\n * by adding every four 16-bit characters and\n * shortening the sum to 32 bits). Otherwise\n * I suggest performing MD-5 as if every character\n * was two bytes--e.g., 0040 0025 = @%--but then\n * how will an ordinary MD-5 sum be matched?\n * There is no way to standardize text to something\n * like UTF-8 before transformation; speed cost is\n * utterly prohibitive. The JavaScript standard\n * itself needs to look at this: it should start\n * providing access to strings as preformed UTF-8\n * 8-bit unsigned value arrays.\n */\nfunction md5blk(s) { /* I figured global was faster. */\nvar md5blks = [], i; /* Andy King said do it this way. */\nfor (i=0; i<64; i+=4) {\nmd5blks[i>>2] = s.charCodeAt(i)\n+ (s.charCodeAt(i+1) << 8)\n+ (s.charCodeAt(i+2) << 16)\n+ (s.charCodeAt(i+3) << 24);\n}\nreturn md5blks;\n}\n\nvar hex_chr = '0123456789abcdef'.split('');\n\nfunction rhex(n)\n{\nvar s='', j=0;\nfor(; j<4; j++)\ns += hex_chr[(n >> (j * 8 + 4)) & 0x0F]\n+ hex_chr[(n >> (j * 8)) & 0x0F];\nreturn s;\n}\n\nfunction hex(x) {\nfor (var i=0; i<x.length; i++)\nx[i] = rhex(x[i]);\nreturn x.join('');\n}\n\nfunction md5(s) {\nreturn hex(md51(s));\n}\n\n/* this function is much faster,\nso if possible we use it. Some IEs\nare the only ones I know of that\nneed the idiotic second function,\ngenerated by an if clause. */\n\nfunction add32(a, b) {\nreturn (a + b) & 0xFFFFFFFF;\n}\n\nif (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {\nfunction add32(x, y) {\nvar lsw = (x & 0xFFFF) + (y & 0xFFFF),\nmsw = (x >> 16) + (y >> 16) + (lsw >> 16);\nreturn (msw << 16) | (lsw & 0xFFFF);\n}\n}\nJS\nend",
"def hash_password(username, plaintext)\n OpenSSL::Digest::MD5.hexdigest(\"#{username}:mongo:#{plaintext}\")\n end",
"def md5(handle, offset, length, quick_hash)\n send_request(FXP_EXTENDED, :string, \"md5-hash-handle\", :int64, offset, :int64, length, :string, quick_hash)\n end",
"def _md5(str)\n js_context.call('newrank_md5', str, bare: true)\n end",
"def encrypt(string)\n CRYPTO.encrypt_string(string).to_64\nend",
"def encode(string: String)\n\n salt = SecureRandom.random_bytes(8)\n\n cipher = OpenSSL::Cipher.new('AES-256-CBC')\n cipher.encrypt\n cipher.pkcs5_keyivgen(@password, salt, 1, \"MD5\")\n data = \"Salted__\" + salt + cipher.update(string) + cipher.final\n\n Base64.encode64(data)\n end",
"def needs_md5sums\n false\n end",
"def generate_md5(hash, keys)\n data = keys.map{|key|\n extract_key(hash, key)\n }\n Digest::MD5.hexdigest( keys_flat data )\n end",
"def md5_fingerprint\n Digest::MD5.hexdigest(ssh_public_key_conversion).gsub(/(.{2})(?=.)/, '\\1:\\2')\n end",
"def to_param\n (value = read_value) ? Digest::MD5.hexdigest(value) : nil\n end",
"def digest_encrypt_password\n if password_changed? || username_changed?\n self.password = encrypt_password(username, DIGEST_REALM, password)\n end\n end",
"def encrypt string\n string\n end",
"def sha512; end",
"def password_hash(str)\n fifty_fifty(Digest::MD5.hexdigest(str)) { str }\nend",
"def md5\n Digest::MD5.file(@path).to_s\n end",
"def encrypt(value)\n Base64.encode64 escape_and_execute_sql(\n [\"SELECT AES_ENCRYPT(?, ?)\", value, key]).first\n end",
"def encrypt(pass)\n \t\tDigest::SHA2.hexdigest(\"#{self.salt}--#{pass}\")\n \tend",
"def encrypt(pass)\n \t\tDigest::SHA2.hexdigest(\"#{self.salt}--#{pass}\")\n \tend",
"def encrypt(pass)\n \t\tDigest::SHA2.hexdigest(\"#{self.salt}--#{pass}\")\n \tend",
"def encrypt(pass)\n \t\tDigest::SHA2.hexdigest(\"#{self.salt}--#{pass}\")\n \tend",
"def encrypt(pass)\n \t\tDigest::SHA2.hexdigest(\"#{self.salt}--#{pass}\")\n \tend",
"def encrypt(string)\n\t#store passwords with the timestamp first, then password (encrpyted)\n secure_hash(\"#{salt}--#{string}\")\n\t#Since weíre inside the User class, Ruby knows that salt refers to the userís salt attribute.\n end",
"def md5\n render :json => { :hash => Digest::MD5.hexdigest(md5_query.to_s) }\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(password + salt)\n end",
"def digest\n Digest::MD5.digest(blob)\n end",
"def md5sum(path)\n digest, buf = Digest::MD5.new, \"\"\n File.open(path) do |f|\n while f.read(4096, buf)\n digest.update(buf)\n end\n end\n digest.hexdigest\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def upstream_md5=( checksum )\n @digest = Crate::Digest.md5( checksum )\n end",
"def digest\n Digest::MD5.hexdigest(id.to_s+Interactiff::Application.config.secret_token).to_i(16).to_s[3,8]\n end",
"def encrypt(data)\n crypto_key.encrypt64(data)\n end",
"def encrypt_password(password)\n Digest::SHA512.hexdigest(password)\n end",
"def build_hash data\n digest = OpenSSL::Digest::Digest.new('md5')\n OpenSSL::HMAC.hexdigest(digest, @project_secret, data)\n end",
"def encrypt_key(password, salt)\n iterations, length = CRYPTERATIONS, HASH_BYTE_SIZE\n OpenSSL::PKCS5::pbkdf2_hmac_sha1(password, salt, iterations, length)\n end",
"def encrypt()\n cipher_type = \"aes-128-ecb\"\n data = password;\n key = master_password;\n \n self.encrypted_password = aes_encrypt(data,key,nil,cipher_type).to_s\n end",
"def audioMD5sum\n @audioMD5sum ||= MD5.hexdigest( audio )\n end",
"def encrypt(string)\r\n aes = cipher\r\n encrypted = aes.update(string) + aes.final\r\n Base64.encode64(encrypted)\r\n end",
"def ruby_md5\n Rip.md5 Rip.ruby\n end",
"def encrypt(*tokens)\n digest = tokens.flatten.join(join_token)\n stretches.times { digest = Digest::SHA512.hexdigest(digest) }\n digest\n end"
] | [
"0.75340575",
"0.74995816",
"0.7496476",
"0.741504",
"0.70201004",
"0.70020866",
"0.6996137",
"0.6984172",
"0.6983229",
"0.69254977",
"0.687628",
"0.687628",
"0.6864773",
"0.6862848",
"0.6856227",
"0.683133",
"0.6800406",
"0.6787133",
"0.6769178",
"0.6755509",
"0.6744237",
"0.665679",
"0.6632799",
"0.65962857",
"0.65532494",
"0.6531106",
"0.6521325",
"0.64803666",
"0.644172",
"0.6415003",
"0.64139444",
"0.6401076",
"0.63987607",
"0.6397706",
"0.63895357",
"0.6353516",
"0.63437337",
"0.6292899",
"0.6283569",
"0.6277336",
"0.6265132",
"0.6260065",
"0.6244459",
"0.6224674",
"0.622168",
"0.62124884",
"0.61902773",
"0.61849403",
"0.618228",
"0.6146621",
"0.6131071",
"0.612442",
"0.6107292",
"0.61048144",
"0.61048144",
"0.61048144",
"0.6089079",
"0.607898",
"0.6078513",
"0.6064702",
"0.6064589",
"0.606209",
"0.60528576",
"0.60433847",
"0.6039395",
"0.59993625",
"0.5985533",
"0.5968866",
"0.5954163",
"0.5941621",
"0.593761",
"0.5935712",
"0.5922009",
"0.59096754",
"0.59081525",
"0.59032756",
"0.5891508",
"0.58848655",
"0.58834964",
"0.58834964",
"0.58834964",
"0.58834964",
"0.58834964",
"0.58754325",
"0.58726585",
"0.5863626",
"0.5849516",
"0.58443904",
"0.58393943",
"0.5832507",
"0.57955134",
"0.57927173",
"0.57876986",
"0.57766664",
"0.577167",
"0.57661647",
"0.5765892",
"0.57629085",
"0.57603747",
"0.5757633"
] | 0.7686864 | 0 |
Encrypts the password with the user salt | def encrypt(password)
self.class.encrypt(password, salt)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt_password\n self.salt = make_salt unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end",
"def encrypt_password\n self.salt = make_salt unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end",
"def encrypt_password\n if self.password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.password = BCrypt::Engine.hash_secret(password, self.salt)\n end\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(password + salt)\n end",
"def encrypt_password\n\t unless @password.blank?\n self.password_salt = salt\n self.encrypted_password = encrypt(@password, salt)\n\t end\n\tend",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt(password, salt)\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt_password()\n if password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.encrypted_password = BCrypt::Engine.hash_secret(password, self.salt)\n end\n end",
"def encrypt(password, salt=nil)\n salt ||= self.salt\n Digest::SHA1.hexdigest(\"--#{salt}--#{password}--\")\n end",
"def encrypt_password\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end",
"def encrypt_password(password)\n self.class.secure_digest([password, password_salt])\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.encrypted_password = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.salt = BCrypt::Engine.generate_salt\n self.encrypted_password= BCrypt::Engine.hash_secret(password, salt)\n end\n end",
"def encrypt(password)\n User.password_digest(password, salt)\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt_password\n if password.present?\n self.password_salt = BCrypt::Engine.generate_salt\n self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)\n end\n end",
"def encrypt(password)\n self.class.encrypt(password) #, salt)\n end"
] | [
"0.8456656",
"0.83809954",
"0.837295",
"0.83666867",
"0.8361271",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83539045",
"0.8353123",
"0.83147633",
"0.8314556",
"0.83011955",
"0.82853645",
"0.8279242",
"0.8253498",
"0.82321554",
"0.82296264",
"0.82296264",
"0.82296264",
"0.82296264",
"0.82296264",
"0.82236284"
] | 0.82061076 | 100 |
These create and unset the fields required for remembering users between browser closes | def remember_me
remember_me_for 2.weeks
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forgets\n update_attribute(:remember_digest, nil)\n end",
"def after_save\n cookies['global_properties_for_user'] = nil\n end",
"def forget\n \tupdate_attribute(:remember_digest, nil)\n end",
"def forget\n \tupdate_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n \n end",
"def forget\n\t\tupdate_attribute(:remember_digest,nil)\n\tend",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def forget\n\t\tupdate_attribute(:remember_digest, nil)\n\tend",
"def forget\n\t\tupdate_attribute(:remember_digest, nil)\n\tend",
"def forget\n\t\tupdate_attribute(:remember_digest, nil)\n\tend",
"def forget\n update_attribute :remember_digest, nil\n end",
"def forget\n update_attribute :remember_digest, nil\n end",
"def forget\n update_attribute(:remember_digest, nil)\n end",
"def clear_user_and_mark_purged\n random_suffix = (('0'..'9').to_a + ('a'..'z').to_a).sample(8).join\n\n self.studio_person_id = nil\n self.name = nil\n self.username = \"#{SYSTEM_DELETED_USERNAME}_#{random_suffix}\"\n self.current_sign_in_ip = nil\n self.last_sign_in_ip = nil\n self.email = ''\n self.hashed_email = ''\n self.parent_email = nil\n self.encrypted_password = nil\n self.uid = nil\n self.reset_password_token = nil\n self.full_address = nil\n self.properties = {}\n\n self.purged_at = Time.zone.now\n\n save!\n end",
"def clear_fields\n self.password=nil\n self.username=nil\n self.role=nil\n end",
"def forget_me\n self.remember_token_expires_at = nil\n self.remember_token = nil\n save(:validate => false) \n end",
"def clear_login_data\r\n session[:edit_mode] = 0\r\n session[:user_id] = nil\r\n session[:user_name] = nil\r\n session[:user_roles] = nil\r\n cookies.delete :remember_me\r\nend",
"def after_remembered; end",
"def after_remembered\n end",
"def forget_me\r\n self.remember_token_expires_at = nil\r\n self.remember_token = nil\r\n save(:validate => false)\r\n end",
"def forget_me\n self.remember_token_expires_at = nil\n self.remember_token = nil\n save(:validate => false)\n end",
"def reset!\n self.user_values = {}\n\n # @inputs have to be nil, not an empty hash. otherwise\n # the memoized inputs will not pick up the changes.\n @inputs = nil\n end",
"def userinfo_unset\n userinfo_set nil\n end",
"def forget(user)\n user.update_attribute(:remember_digest, nil)\n cookies.delete(:student_id) if student?\n cookies.delete(:tutor_id) if tutor?\n cookies.delete(:remember_token)\n end",
"def after_create\n @password = nil\n @confirm_password = nil\n end",
"def forget\n update_attribute(:remember_token, nil)\n end",
"def remember_values\n logger.debug {\"Generating remember values\"}\n {}\n end",
"def clean_up_passwords\n self.dob = nil\n super\n end",
"def reset_session_variables\n session[:login] = ''\n session[:register_id] = ''\n session[:register_name] = ''\n session[:folio_id] = ''\n session[:folio_image] = ''\n session[:first_folio_id] = ''\n session[:last_folio_id] = ''\n session[:browse_id] = ''\n session[:browse_image] = ''\n end",
"def clean_up\n Capybara.current_session.execute_script \"window.localStorage.removeItem('pushEnabled');window.localStorage.removeItem('clark-user-journey');\"\n end",
"def forget_me\n self.remember_token_expires_at = nil\n self.remember_token = nil\n save(false)\n end",
"def forget_me\n self.remember_token_expires_at = nil\n self.remember_token = nil\n save(false)\n end",
"def forget\n update_attribute(:remember_digest, nil)\n # We don't need the below line because if we update remember_digest to nil, then\n # you cannot use the old remember_token anyway, so it is unnecessary\n # self.remember_token = nil\n end",
"def teardown\n @user_admin = nil\n @user_admin_details = nil\n\n @user_normal = nil\n @user_normal_details = nil\n\n session[:user_id] = nil\n end",
"def forget\n self.remember_token = nil\n update_attribute(:remember_digest, nil)\n end",
"def forget\n self.remember_token = nil\n update_attribute(:remember_digest, nil)\n end",
"def force_forget_me!\n config = sorcery_config\n sorcery_adapter.update_attributes(config.remember_me_token_attribute_name => nil,\n config.remember_me_token_expires_at_attribute_name => nil)\n end",
"def clear_new_flight_variables\n session[:new_flight] = Hash.new\n end",
"def after_create\n @password = nil\n end",
"def after_create\n @password = nil\n end",
"def set_logged_out\n @id = nil\n @nonce = nil\n @ip = nil\n end",
"def sign_out\n @username = nil\n @current_user = nil\n\n @modhash = nil\n @cookie = nil\n end",
"def forget\n self.remember_token = nil\n self.update_attribute(:remember_digest, nil)\n end",
"def sign_out\n #Setting current user's remember_token to a\n #new hash that is in valid\n #The idea is to make every record in the\n #table to look identical in an attempt to\n #thwart evil\n current_user.update_attribute(:remember_token, User.hash(User.new_remember_token))\n #Deletes current user's remember_token from hash\n cookies.delete(:remember_token)\n #sets current use to empty\n self.current_user = nil\n end",
"def remember_me=(_arg0); end",
"def check_for_removal\n if @value && @unused && @unused[\"unused\"]\n @res.cookies << create_cookie(\"unused\", false, 'flash_unused')\n elsif @value\n @value = nil\n @res.cookies << create_cookie(\"unused\", nil, 'flash_unused')\n @res.cookies << create_cookie(\"message\", nil)\n end\n end",
"def discard_saved_state\n end",
"def set_defaults\n self.state ||= 'NEW'\n self.user_id ||= Gizmo::Util::Uuid.generate\n end",
"def forget_me!\n sorcery_config.remember_me_token_persist_globally || force_forget_me!\n end",
"def destruir\n session[:email]=nil\n session[:nombre]=nil\n session[:apellido]=nil\n $email=''\n $nombre=''\n end",
"def clean_up\n @minefield = nil\n end",
"def logout\n session[:email] = nil\n session[:firstname] = nil\n session[:lastname] = nil \n render :adduser \n end",
"def reset_fields\n self.outpost_queued = false\n # outpost_prevent is set and reset at end of previous turn\n # pirate_coins persists turn after turn\n self.gained_last_turn = []\n self.bought_victory = false\n self.played_treasure = false\n self.played_crossroads = false\n self.played_fools_gold = false\n save!\n end",
"def session_reset(db_user) # User record\n # Clear session hash just to be sure nothing is left (but copy over some fields)\n winh = session[:winH]\n winw = session[:winW]\n session.clear\n session[:winH] = winh\n session[:winW] = winw\n\n session[:userid] = db_user.userid\n\n # Set the current userid in the User class for this thread for models to use\n User.current_userid = session[:userid]\n\n session[:username] = db_user.name\n\n # set group and role ids\n session[:group] = db_user.miq_group.id # Set the user's group id\n session[:group_description] = db_user.miq_group.description # and description\n role = db_user.miq_group.miq_user_role\n session[:role] = role.id # Set the group's role id\n\n # Build pre-sprint 69 role name if this is an EvmRole read_only role\n session[:userrole] = role.read_only? ? role.name.split(\"-\").last : \"\"\n\n # Save an array of groups this user is eligible for, if more than 1\n eg = db_user.eligible_miq_groups.sort{|a,b| a.description.downcase <=> b.description.downcase}\n session[:eligible_groups] = db_user.nil? || eg.length < 2 ?\n [] :\n eg.collect{|g| [g.description, g.id]}\n\n # Clear instance vars that end up in the session\n @sb = @edit = @view = @settings = @lastaction = @perf_options = @assign =\n @current_page = @search_text = @detail_sortcol = @detail_sortdir =\n @exp_key = @server_options = @tl_options =\n @pp_choices = @panels = @breadcrumbs = nil\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 forget\n self.remember_token = nil\n update_attribute(:remember_token_digest, nil)\n end",
"def resets; end",
"def forget(tok)\n update_attributes! remember_hash: remember_hash.delete_if { |_k, v| Encrypt::Password.validatePassword tok, v } unless tok.nil?\n end",
"def clear_back_office_data\n @flbt_type = nil\n @version = nil\n @submitted_date = nil\n @effective_date = nil\n @filing_date = nil\n @ads_included = nil\n @ads_amount = nil\n @number_of_buyers = nil\n end",
"def reset_cleared_default_fields\n @cleared_default_fields = {}\n end",
"def clear_cookie\n create_accesses_cookie\n end",
"def remember_me; end",
"def fortune_cookie; end",
"def set_new_form_vars\n @edit = {}\n @edit[:key] = \"sm_edit__new\"\n @edit[:new] = {}\n @edit[:current] = {}\n\n @edit[:new][:name] = nil\n @edit[:sm_types] = StorageManager.storage_manager_types\n @edit[:new][:hostname] = nil\n @edit[:new][:ipaddress] = nil\n @edit[:new][:port] = nil\n @edit[:new][:sm_type] = nil\n # @edit[:new][:agent_type] = nil\n @edit[:new][:zone] = \"default\"\n @edit[:server_zones] = []\n zones = Zone.all\n zones.each do |zone|\n @edit[:server_zones].push(zone.name)\n end\n\n @edit[:new][:userid] = nil\n @edit[:new][:password] = nil\n @edit[:new][:verify] = nil\n\n session[:verify_sm_status] = nil\n set_verify_status\n\n @edit[:current] = @edit[:new].dup\n session[:edit] = @edit\n end",
"def reset!\n defaults = Settler.config[self.key]\n self.label = defaults['label']\n self.value = defaults['value']\n self.editable = defaults['editable']\n self.deletable = defaults['deletable']\n self.deleted = false\n save(:validate => false)\n end",
"def valid_upto\n GlobalConstant::Cookie.password_auth_expiry\n end",
"def forget_me!\n return unless persisted?\n self.remember_token = nil if respond_to?(:remember_token)\n self.remember_created_at = nil if self.class.expire_all_remember_me_on_sign_out\n save(validate: false)\n end",
"def reset_current_useritem\n session[:useritem_id] = nil\n session[:useritem_type] = nil\n end",
"def set_defaults\n self.state ||= 'NEW'\n self.account_id ||= Gizmo::Util::Uuid.generate\n self.account_name ||= self.subdomain\n end",
"def reset_guest!\n original_locale = session[:locale]\n original_scores = session[:show_scores]\n\n sign_out(:user) if user_signed_in?\n reset_session\n\n session[:locale] = original_locale\n session[:show_scores] = original_scores\n\n cookies.delete :guest\n @_guest = nil\n end",
"def reset_to_defaults!\n @allowlist_regexp = nil\n @custom_http_auth_scheme = UnsetString.new(\"custom_http_auth_scheme\")\n @env_var_to_hold_api_client_primary_key = NonNullString.new(\"env_var_to_hold_api_client_primary_key\",\"STITCHES_API_CLIENT_ID\")\n @env_var_to_hold_api_client= NonNullString.new(\"env_var_to_hold_api_client\",\"STITCHES_API_CLIENT\")\n @max_cache_ttl = NonNullInteger.new(\"max_cache_ttl\", 0)\n @max_cache_size = NonNullInteger.new(\"max_cache_size\", 0)\n @disabled_key_leniency_in_seconds = ActiveSupport::Duration.days(3)\n @disabled_key_leniency_error_log_threshold_in_seconds = ActiveSupport::Duration.days(2)\n end",
"def create_user_information # for new users. runs last according to rails.\n self.dj_name = name\n self.roles = Role.where(:title => 'noob')\n self.active = true\n set_password\n end",
"def clean_up_passwords; end",
"def reset\n session[:emirate_id] = nil\n session[:emirate_name] = nil\n session[:neighborhood_id] = nil\n session[:neighborhood_name] = nil\n session[:project_id] = nil\n session[:project_name] = nil\n session[:building_id] = nil\n session[:building_name] = nil\n flash[:notice] = \"Selected value for Emirate has been reseted.\"\n redirect_to(request.env['HTTP_REFERR'] || emirates_url)\n end",
"def refresh_expiration \n \t self.needs_new_cookie=true \n \tend",
"def remember_me\n self.remember_token_expires_at = 2.weeks.from_now.utc\n self.remember_token = encrypt(\"#{remember_token_expires_at}\")\n # save(:validate => false)\n end",
"def forget\n \tputs \"%USER-I-TRACE, forget called.\"\n\t\tupdate_attribute(:remember_digest, nil)\n\tend",
"def abandon!\n @user = nil\n session.clear\n end",
"def reset_user\n return unless exists?(:previous_user)\n set :user, fetch(:previous_user)\n unset :previous_user\n clear_sessions\n end",
"def cleared_required\n if current_user\n if current_user.cleared\n return\n end\n raise 'Du är ännu inte godkänd för att tippa.'\n end\n redirect_to \"/login\", notice: 'Logga in för att tippa.'\n end",
"def reset!\n reset_secret\n refresh_expiry\n reset_confirmation\n save!\n end",
"def forget_form_data(type)\n session.delete(type)\n end",
"def remember_me() return true; end"
] | [
"0.655833",
"0.64576274",
"0.6433039",
"0.6433039",
"0.63186485",
"0.6318346",
"0.62982345",
"0.62982345",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6252695",
"0.6252695",
"0.6252695",
"0.62494266",
"0.62494266",
"0.6221605",
"0.62047994",
"0.61707467",
"0.6157821",
"0.6139168",
"0.6128803",
"0.60424393",
"0.60367966",
"0.59947336",
"0.5886899",
"0.58703595",
"0.5850127",
"0.5849959",
"0.58350986",
"0.5799766",
"0.5749178",
"0.5726777",
"0.5696514",
"0.56919754",
"0.56919754",
"0.567833",
"0.566733",
"0.56405693",
"0.56405693",
"0.5634449",
"0.5626462",
"0.558413",
"0.558413",
"0.556913",
"0.5564659",
"0.5563434",
"0.55582345",
"0.55325294",
"0.55272514",
"0.55179334",
"0.5517242",
"0.5510993",
"0.54968077",
"0.5490115",
"0.5482928",
"0.5475412",
"0.54741484",
"0.5471919",
"0.546449",
"0.543982",
"0.54385984",
"0.5434804",
"0.54124016",
"0.54083997",
"0.5403811",
"0.5401727",
"0.53954965",
"0.53888035",
"0.53721374",
"0.53679377",
"0.53436095",
"0.53367555",
"0.53323185",
"0.53320724",
"0.532623",
"0.53255653",
"0.53242767",
"0.5322038",
"0.5310463",
"0.5305345",
"0.5303277",
"0.5302871",
"0.5295144",
"0.52868015",
"0.52844334",
"0.5281007"
] | 0.0 | -1 |
:name, :title, :salary, :boss, | def initialize(name,title,salary,boss)
super #(name,title,salary,boss)
# @name = name
# @title = title
# @salary = salary
# @boss = boss
@employees = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boss_params\n params.require(:boss).permit(:name, :weakness, :resistance, :immunity, :parryable, :optional)\n end",
"def name\n name_business\n end",
"def name; nutrdesc; end",
"def hire_employee(employee_name, employee_salary)\n Employee.new(employee_name, employee_salary, self.name)\nend",
"def attributes *args\n data = super\n data[:hospital_id] = object.id\n data[:Name] = object.Name\n data[:Address] = object.Address\n data[:Beds] = object.Beds\n data\n end",
"def initialize(person_id, name, last_name, title, salary)\n super(person_id, name, last_name)\n @title = title\n @salary = salary\n end",
"def salary_head_params\n params.require(:salary_head).permit(:salaryname, :earnings, :deduction)\n end",
"def initialize(name = \"Anonymous\", salary = 0.00)\n self.name = name\n self.salary = salary\n end",
"def hall_params\n params.require(:hall).permit(:name, :description, :chairs, :capacity)\n end",
"def boss\n @boss\n end",
"def name\n self[:first_name] + \" \" + self[:last_name]\n end",
"def health_benefit; end",
"def saler_params\n params.require(:saler).permit(:name)\n end",
"def name\n @name\n end",
"def name\n 'occupant'\n end",
"def initialize(details)\n @name = details[:name]\n @specialty = details[:specialty]\n @education = details[:education]\n @salary = details[:salary]\n end",
"def investor_params\n params.require(:investor).permit(:firstname, :lastname, :description)\n end",
"def herb_params\n params.require(:herb).permit(:name, :soil, :space, :hardinessZone, :sunShine, :start, :special, :companions, :foes)\n end",
"def investigated_params\n params.require(:investigated).permit(:name, :lastname1)\n end",
"def name\n\t\t\"#{lastName}, #{firstName}\"\n\tend",
"def display_employees\n\t\t@@name_and_salary.each do |x|\n\t\t\tputs \"Name: #{x[:name]}, Salary: $#{x[:salary]}\"\n\t\tend\n\tend",
"def name\n title\n end",
"def name\n title\n end",
"def name\n title\n end",
"def name\n title\n end",
"def salutation_params\n params.require(:salutation).permit(:name)\n end",
"def salesperson_params\n params.require(:salesperson).permit(:name, :gender, :age, :height, :weight)\n end",
"def name \n @name\n end",
"def name \n @name\n end",
"def pioneer\n{:name =>'Grace Hopper'}\nend",
"def name\n person_name\n end",
"def name\n @name\nend",
"def add_students(name, cohort, country, height, hobbie)\n\t@students << {name: name, cohort: cohort.to_sym, country: country.to_sym, height: height.to_sym, hobbie: hobbie.to_sym }\nend",
"def employment_params\n params.require(:employment).permit(:first_name, :second_name, :third_name, :photo, :birth_date, :decription, :phone, :is_confirmed, :specialty_id)\n end",
"def name\n @name \n end",
"def hire_employee(name,salary)\n Employee.new(name, self, salary)\n end",
"def salons\n FindSalon::Salon.all.map do |salon|\n salon.id.to_s + ' ' + salon.name + ' | ' + 'Rating: ' + salon.rating.to_s + ' | ' + 'Address: ' + salon.vicinity\n end\n end",
"def initialize(name, sex, age, height, weight)\n self.name = name\n self.sex = sex\n self.age = age\n self.height = height\n self.weight = weight\n end",
"def my_boice_params\n params.require(:my_boice).permit(:name, :description)\n end",
"def hall_params\n params.require(:hall).permit(:name, :description, :scale, :items_url, :shop_id, :map)\n end",
"def bill_params\n params.require(:bill).permit(:name, :income)\n end",
"def employee_params\n params.require(:employee).permit(:name,:bio, :headshot)\nend",
"def name\n\t\t\"#{firstname} #{lastname}\"\n\tend",
"def name \r\n\t @name\r\n end",
"def name; title end",
"def name\n @name = self.firstname + \" \" + self.lastname \n end",
"def first_name_women; end",
"def name\n nome\n end",
"def employee_params\n params.require(:employee).permit(:first_name, :middle_name, :last_name, :chair_id, :post_id, :degree_id, :academic_title_id, :head)\n end",
"def job_params\n params.require(:job).permit(:description, :third, :salary, :branch_id)\n end",
"def hobby_params\n params.require(:hobby).permit(:name)\n end",
"def hobby_params\n params.require(:hobby).permit(:name)\n end",
"def name\n self[:first_name] + \" \" + self[:last_name]\n end",
"def name\n description\n end",
"def name\n description\n end",
"def employee_params\n params.require(:employee).permit(:first_name, :surname)\n end",
"def name\n \n end",
"def name\n \"Town Hall\"\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end",
"def name\n @name\n end"
] | [
"0.63197845",
"0.5958281",
"0.59469897",
"0.5849107",
"0.58132035",
"0.5800984",
"0.5753704",
"0.5748102",
"0.5724427",
"0.5712752",
"0.57117563",
"0.5686457",
"0.56847274",
"0.5670774",
"0.56623596",
"0.5651402",
"0.56296873",
"0.56107277",
"0.5609868",
"0.560186",
"0.5591911",
"0.5587794",
"0.5587794",
"0.5587794",
"0.5587794",
"0.5586711",
"0.55865866",
"0.5577985",
"0.5577985",
"0.55756027",
"0.5567119",
"0.5562857",
"0.5561312",
"0.5559945",
"0.55582505",
"0.55551165",
"0.55513966",
"0.55392325",
"0.5528036",
"0.5526641",
"0.5525825",
"0.55157864",
"0.55100995",
"0.5505185",
"0.5494986",
"0.5493356",
"0.5489202",
"0.54867995",
"0.54855895",
"0.54849833",
"0.54791796",
"0.54791796",
"0.5473291",
"0.5471835",
"0.5471835",
"0.5468867",
"0.54633176",
"0.5461766",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104",
"0.5460104"
] | 0.64796734 | 0 |
Get the database provided in the URI. | def database
@database ||= match[9]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def database\n @database ||= opts.fetch(:database, parsed_uri.path[1..-1])\n end",
"def db_name\n @uri.path.split('/').last\n end",
"def get_db(dbname)\n Database.new(dbname, @socket, self)\n end",
"def find_db\n db = nil\n if !database.nil?\n db = rds.db_instances[database]\n elsif !environment.nil?\n db = find_db_by_environment(environment)\n end\n db\n end",
"def name\n db_name = URI.parse(uri(self)).path.to_s.sub(\"/\", \"\")\n db_name.blank? ? database : db_name\n end",
"def database! url\n parsed = parse url\n cr = CouchRest.new(parsed[:host])\n cr.database!(parsed[:database])\n end",
"def db_info\n @conn.query({url_path: \"#{database}\", method: :get})\n end",
"def db_uri\n unless @db_uri # get the config from command line\n @db_uri = self.conf['db_url']\n end\n @db_uri\n end",
"def db\n return @args[:db]\n end",
"def get_database(db_name)\n Monga::Database.new(@client, db_name)\n end",
"def database\n database_name ? connection.db(database_name) : nil\n end",
"def database(options = {})\n throw ArgumentError.new('Required arguments :database_id missing') if options[:database_id].nil?\n get(\"databases/#{options[:database_id]}\")\n end",
"def database\n @database ||= determine_database\n end",
"def database\n @database ||= match[9]\n end",
"def get_database(key)\n return nil unless @databases.has_key?(key)\n\n # Get the database entry.\n # If it is a 'Proc' then execute the proc and use the value that is returned.\n db = @databases[key]\n db = db.call if db.kind_of?(Proc)\n # Connect to the database, if required and return.\n db.connect_and_migrate\n db\n end",
"def current_database\n query('select current_database()')[0][0]\n end",
"def get_couch_db(url)\n if !url.end_with?('/')\n url = url + '/'\n end\n url = url + 'mydb'\n\n puts 'Using URL: ' + url\n #This will create the DB if it does not exist, however it will fail if you do not have permissions\n CouchRest.database!(url)\n end",
"def determine_database\n self.class.database \n end",
"def database! name\n create_db(name) rescue nil\n database name\n end",
"def database\n @database ||= begin\n uid_split = uid.split(':')\n uid_split.length > 1 ? uid_split[0] : nil\n end\n end",
"def database\n \"--db='#{ name }'\" if name\n end",
"def database\n \"--db='#{ name }'\"\n end",
"def get_database(name)\n response = @glue_client.get_database(name: name)\n response.database\nrescue Aws::Glue::Errors::GlueException => e\n @logger.error(\"Glue could not get database #{name}: \\n#{e.message}\")\n raise\n end",
"def getDB\n @db\n end",
"def sqlite3_db_name\n @database_url.scan(/sqlite3:\\/\\/localhost\\/(.+)/)[0][0]\n end",
"def database database_id\n ensure_service!\n grpc = service.get_database instance_id, database_id\n Database.from_grpc grpc, service\n rescue Google::Cloud::NotFoundError\n nil\n end",
"def database! url\n parsed = parse url\n cr = Sova.new(parsed[:host])\n cr.database!(parsed[:database])\n end",
"def db\n @db ||= find_or_create_database\n end",
"def database\n @database\n end",
"def database\n @database\n end",
"def databases\n get '_all_dbs'\n end",
"def database(name)\n Database.new(connection.db(name))\n end",
"def parse_db_uri(db_uri)\n uri = URI.parse(db_uri)\n \n db_config = {\n :adapter => uri.scheme,\n :database => uri.path[1..-1],\n :host => uri.host\n }\n \n if uri.user\n db_config[:username] = uri.user\n db_config[:password] = uri.password if uri.password\n end\n db_config[:port] = uri.port if uri.port\n \n db_config\n end",
"def database\n config[\"database\"]\n end",
"def current_database #:nodoc:\n select_one(\"select sys_context('userenv','db_name') db from dual\")[\"db\"]\n end",
"def database\n @@db\n end",
"def select_db(name)\n #This is a stub, used for indexing\n end",
"def database name\n CouchRest::Database.new(self, name)\n end",
"def database\n @database || self.class.database\n end",
"def get(database_id:)\n path = '/databases/{databaseId}'\n .gsub('{databaseId}', database_id)\n\n if database_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"databaseId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::Database\n )\n end",
"def parse_database_url(url)\n parsed = URI(url)\n {}.tap do |db|\n # Store this for use later in #set_state, and maybe future use by\n # Django in some magic world where operability happens.\n db[:URL] = url\n db[:ENGINE] = resolve_engine(parsed.scheme)\n # Strip the leading /.\n path = parsed.path ? parsed.path[1..-1] : parsed.path\n # If we are using SQLite, make it an absolute path.\n path = ::File.expand_path(path, self.path) if db[:ENGINE].include?('sqlite')\n db[:NAME] = path if path && !path.empty?\n db[:USER] = parsed.user if parsed.user && !parsed.user.empty?\n db[:PASSWORD] = parsed.password if parsed.password && !parsed.password.empty?\n db[:HOST] = parsed.host if parsed.host && !parsed.host.empty?\n db[:PORT] = parsed.port if parsed.port && !parsed.port.empty?\n end\n end",
"def databases\n CouchRest.get \"#{@uri}/_all_dbs\"\n end",
"def select_db(db)\n query \"use #{db}\"\n self\n end",
"def database\n @database ||= self.class.database\n end",
"def database; datastore['DATABASE']; end",
"def get_db_uri\n \"#{URI.encode ZohoReports.configuration.login_email}/#{URI.encode ZohoReports.configuration.zoho_database_name}\"\n end",
"def database(dbname=nil, &block)\n dbname ||= database_name\n if dbname then\n repository dbname, &block\n else\n yield\n end\n end",
"def database\n @database || self.class.database\n end",
"def database instance_id, database_id\n ensure_service!\n grpc = service.get_database instance_id, database_id\n Database.from_grpc grpc, service\n rescue Google::Cloud::NotFoundError\n nil\n end",
"def get_db\n # we want to check a couple levels 2011-09-28 \n unless @db\n unless File.exists? @file\n 3.times do |i|\n @file = \"../#{@file}\"\n break if File.exists? @file\n end\n end\n end\n @db ||= DB.new @file\n end",
"def database_name\n __evaluate__(storage_options[:database])\n end",
"def database\n self.class.database\n end",
"def database_info(dbname, options = {})\n version = options.fetch(:t, '-')\n get db_url(dbname, version) + \"/\", :Accept => 'application/edn'\n end",
"def db_path\n @db\n end",
"def database\n if database_name.nil?\n MongoMapper.database\n else\n connection.db(database_name)\n end\n end",
"def database_name\n @opts[:database]\n end",
"def db\n @db ||= finder_result.connection\n end",
"def database(name)\n Database.new(self, name)\n end",
"def db name = nil, &block\n repository = name || scopes.size < 1 ? repositories[name ||= :default] : scopes.last\n repository or raise \"Unknown db '#{name}', did you forget to #setup ?\"\n\n if block_given?\n begin\n scopes.push(repository)\n block.call(repository)\n ensure\n scopes.pop\n end\n end\n repository\n end",
"def database\n @database ||= begin\n if ENV['DATABASE_URL']\n Sequel.connect(ENV['DATABASE_URL'])\n elsif RUBY_PLATFORM == 'java'\n Sequel.connect(jdbc_settings)\n else\n Sequel.connect(database_settings)\n end\n end\n end",
"def db\n self.config[:db]\n end",
"def database\n Jrodb::Database[:default]\n end",
"def [](dbname)\n self.db[dbname]\n end",
"def uri(db = database)\n \"#{db.root}/#{self['_id']}\"\n end",
"def database_name\n @database_name\n end",
"def db\n @db ||= Database.new\n end",
"def database\n default = begin\n YAML.load_file(\"config/database.yml\")['production']['adapter'].strip\n rescue\n nil\n end\n menu_with_default \"Select a database for production:\", [\"postgres\", \"mysql\", \"sqlite3\"], default\n end",
"def databases\n JSON.parse(RestClient.get(File.join(self.uri, \"_all_dbs\"))).collect do |database_name|\n Database.new(:name => database_name)\n end\n end",
"def database\n @database ? @database : Database::ADMIN\n end",
"def default_database; ENV['APP_DB'] end",
"def get_db_connection\n config = read_database_config\n if config.dig(:adapter) == 'postgresql'\n config[:user] = config.delete(:username) if config[:username]\n config[:dbname] = config.delete(:database) if config[:database]\n config.delete(:adapter)\n valid_param_keys = PG::Connection.conndefaults_hash.keys + [:requiressl]\n config.slice!(*valid_param_keys)\n @db ||= PG::Connection.new(config)\n elsif config.dig(:adapter) == 'mysql2'\n @db ||= Mysql2::Client.new(config)\n else\n @db ||= SQLite3::Database.open(\"spectacles-#{Rails.env}.db\")\n end\n end",
"def get_db\n if @db==nil\n @db = Mongo::Connection.new(@db_host, @db_port).db(@db_name)\n QME::MongoHelpers.initialize_javascript_frameworks(@db)\n end\n @db\n end",
"def get_db\n if @db==nil\n @db = Mongo::Connection.new(@db_host, @db_port).db(@db_name)\n QME::MongoHelpers.initialize_javascript_frameworks(@db)\n end\n @db\n end",
"def db\n return self.class.db\n end",
"def db\n self.class.db\n end",
"def get_remote_database(print_to_stdout)\n cleardb = api.get_config_vars(app).body[\"CLEARDB_DATABASE_URL\"]\n jawsdb = api.get_config_vars(app).body[\"JAWSDB_URL\"]\n\n if @@db == 'cleardb'\n puts \"Using ClearDB\" if print_to_stdout\n return cleardb\n elsif @@db == 'jawsdb'\n puts \"Using JawsDB\" if print_to_stdout\n return jawsdb\n elsif jawsdb && cleardb\n puts \"Error. Both CLEARDB_DATABASE_URL and JAWSDB_URL config vars are found. Please indicate which database to use with the --db parameter (values accepted: cleardb or jawsdb)\"\n return nil\n elsif cleardb\n puts \"Using ClearDB\" if print_to_stdout\n return cleardb\n elsif jawsdb\n puts \"Using JawsDB\" if print_to_stdout\n return jawsdb\n end\n\n return nil\n end",
"def db\n @db ||= new_connection\n end",
"def uri\n database.uri + '/_design/' + name\n end",
"def find_db\n log_debug\n file_name = 'com.plexapp.plugins.library.db'\n # for dev it looks in current directory first\n # can add locations as we find them. only the first match is used\n paths = [ '.',\n '/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases',\n \"#{ENV['HOME']}/Library/Application Support/Plex Media Server/Plug-in Support/Databases\"\n ]\n db = ''\n \n paths.each do |path|\n if File.directory? path\n if File.exists? \"#{path}/#{file_name}\"\n # first match is used\n if db == ''\n db = \"#{path}/#{file_name}\"\n end\n end\n end\n end\n \n if db !~ /\\w/\n puts \"error : could not find db file \\\"#{file_name}\\\" \"\n exit 2\n end\n \n log_debug \"find_db using \\\"#{db}\\\"\"\n return db\n end",
"def [](db_name)\n DB.new(db_name, self, :logger => @logger)\n end",
"def db_name\n data[:db_name]\n end",
"def database\n self.class_database || CouchRest::Model.default_database\n end",
"def _db\n @_db ||= Sequel::DATABASES.first || Sequel.sqlite\n end",
"def db\n @db == true ? TABLE : @db.try(:parameterize, separator: \"_\")\n end",
"def current_database\n select_value('select current_database()', 'SCHEMA')\n end",
"def getDatabaseInfo(dbName)\n printDebugMessage('getDatabaseInfo', 'Begin', 11)\n dbInfo = nil\n dbInfoList = getDatabaseInfoList()\n dbInfoList.each{ |tmpDbInfo|\n if tmpDbInfo.elements['name'].text == dbName\n dbInfo = tmpDbInfo\n else\n tmpDbInfo.each_element('aliasList/alias') { |value|\n if value.text == dbName\n dbInfo = tmpDbInfo\n end\n }\n end\n }\n printDebugMessage('getDatabaseInfo', 'End', 11)\n return dbInfo\n end",
"def uri\n \"#{database.uri}/#{ensure_id}\"\n end",
"def uri\n uri = URI::Generic.new(\n self.class.adapter_scheme.to_s,\n nil,\n @opts[:host],\n @opts[:port],\n nil,\n \"/#{@opts[:database]}\",\n nil,\n nil,\n nil\n )\n uri.user = @opts[:user]\n uri.password = @opts[:password] if uri.user\n uri.to_s\n end",
"def uri\n uri = URI::Generic.new(\n self.class.adapter_scheme.to_s,\n nil,\n @opts[:host],\n @opts[:port],\n nil,\n \"/#{@opts[:database]}\",\n nil,\n nil,\n nil\n )\n uri.user = @opts[:user]\n uri.password = @opts[:password] if uri.user\n uri.to_s\n end",
"def database_name\n data[:database_name]\n end",
"def database_name\n @dbi.db_name\n end",
"def database_name\n @dbi.db_name\n end",
"def database_id\n service.database\n end",
"def database_id\n @grpc.database.split(\"/\")[5]\n end",
"def database_name\n database&.name\n end",
"def db\n unless @db # not connected\n @db = Sequel.connect(self.db_uri, :logger => self.log)\n end\n @db\n end",
"def use(args)\n @dbh.select_db(args[:db_name])\n end",
"def get_db\n manif = Project.miga_online_manif\n @downloadable = manif[:databases].map do |name, i|\n local = Project.find_by(path: name)\n local_v = (local.miga.metadata[:release] || 'unknown') if local && local.miga\n latest = i[:versions][i[:latest].to_sym]\n file = File.join(Settings.miga_projects, latest[:path])\n downloading = File.size(file) * 100 / latest[:size] if File.exist?(file)\n i.merge(name: name, local: local_v, downloading: downloading)\n end\n end",
"def db\n unless @db\n @db = ::Sequel.connect(uri)\n @db.logger = @options[:sequel_logger]\n end\n @db\n end",
"def database(opts = nil)\n if opts\n @database ||= Sequel.connect(opts)\n find_or_create_sequence_number\n end\n @database\n end"
] | [
"0.8474478",
"0.7361203",
"0.72507834",
"0.7188314",
"0.71707356",
"0.7165774",
"0.7125147",
"0.711822",
"0.7115814",
"0.7093209",
"0.70868504",
"0.70248395",
"0.692902",
"0.68376786",
"0.68043804",
"0.67975646",
"0.6763022",
"0.67322564",
"0.6731406",
"0.67264473",
"0.6717443",
"0.6700483",
"0.66987395",
"0.66872907",
"0.6667432",
"0.6653525",
"0.66431034",
"0.661083",
"0.66088015",
"0.66088015",
"0.66033006",
"0.65761393",
"0.65749896",
"0.65701425",
"0.6543342",
"0.6527649",
"0.651036",
"0.64919406",
"0.64910626",
"0.6484157",
"0.6478905",
"0.647181",
"0.6451062",
"0.64451766",
"0.6444445",
"0.64381295",
"0.64154327",
"0.64112175",
"0.6385412",
"0.63679165",
"0.63497156",
"0.6329765",
"0.6290457",
"0.62784654",
"0.6275218",
"0.62622076",
"0.6256303",
"0.623333",
"0.6202586",
"0.6192434",
"0.6191002",
"0.61864394",
"0.61828053",
"0.616841",
"0.6149421",
"0.6147219",
"0.6146634",
"0.61388135",
"0.6133127",
"0.6125909",
"0.61163175",
"0.61142325",
"0.61142325",
"0.6089585",
"0.607704",
"0.6073719",
"0.60724545",
"0.6066591",
"0.60599756",
"0.6058988",
"0.60534805",
"0.6046549",
"0.60280746",
"0.60276204",
"0.60225326",
"0.6016976",
"0.6005058",
"0.6003545",
"0.6003545",
"0.6002501",
"0.59952146",
"0.59952146",
"0.5987495",
"0.596368",
"0.5963372",
"0.5960331",
"0.5959783",
"0.59376276",
"0.5921273",
"0.59209955"
] | 0.6784345 | 16 |
Get the hosts provided in the URI. | def hosts
@hosts ||= match[5].split(",")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_uri_hosts(tweet)\n list = []\n #tweet.uris.each { |uri| list << uri.expanded_uri.host.downcase } if tweet.uris?\n\n # Remove subdomains (e.g.: www.example.org => example.org)\n regex = '[[:word:]]{1,}\\.[[:word:]]{1,}\\z'\n tweet.uris.each do |uri|\n m = /#{regex}/.match(uri.expanded_uri.host.downcase)\n list << m[0]\n end\n\n list\n end",
"def hosts\n @hosts ||= Array(Hansolo.target).map { |target| URI.parse(target) }\n end",
"def hosts\n @hosts ||= match[5].split(\",\")\n end",
"def hosts\n @hosts.values\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 hosts\n @hosts ||= []\n end",
"def hosts\n h = []\n r = ('a'..'z')\n r.each do |i|\n r.each do |j|\n r.each do |k|\n h << i.to_s + j + k + \".com\"\n end\n end\n end\n h\n end",
"def hosts\n\t\tHost.find(:all)\n\tend",
"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 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 hosts(args = nil)\n if args and args[:server]\n args[:server].split(';').collect { |server| $hosts[server] ||\n Config.warn_fail(\"#{server} is not a known host\") }\n else\n $hosts.values\n end\nend",
"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 hosts; end",
"def hosts; end",
"def hosts; end",
"def get_all_hosts()\n results = @zabbix.host.get({\"output\" => [\"name\"], \"sortfield\" => \"name\",})\n host_names = []\n results.each { |result| host_names << result['name'] }\n return host_names\n end",
"def hosts\n # prevent original array from being changed\n @hosts.dup\n end",
"def available_hosts\n @available_hosts ||= []\n end",
"def get_puppetdb_hosts\n curl = setup_curl(\"#{@puppetdb_url}/v3/nodes\")\n curl.get\n servers_junk = JSON.parse(curl.body_str)\n servers_array = []\n servers_junk.each { |server| servers_array << server['name'] }\n @puppetdb_hosts = servers_array\n end",
"def hosts\n `#{cmk} --list-hosts`.split(/\\n/).sort\n end",
"def get_possible_hosts_paths(parts)\n case parts['host']\n when Resolv::IPv4::Regex\n ip = true\n when Resolv::IPv6::Regex\n ip = true\n else\n ip = false\n end\n\n # For the hostname, the client will try at most 5 different strings. They are:\n # - the exact hostname in the url\n # - up to 4 hostnames formed by starting with the last 5 components and successively removing the leading component.\n # The top-level domain can be skipped. These additional hostnames should not be checked if the host is an IP address.\n possible_hosts = []\n\n if(!ip)\n host = parts['host'].split('.')\n [host.length - 2, 4].min.times do |i|\n possible_hosts.push(host[host.length-2-i..-1].join('.'))\n end\n end\n possible_hosts.push(parts['host'])\n possible_hosts.reverse!\n\n # For the path, the client will also try at most 6 different strings. They are:\n # - the exact path of the url, including query parameters\n # - the exact path of the url, without query parameters\n # - the 4 paths formed by starting at the root (/) and successively appending path components, including a trailing slash.\n possible_paths = []\n\n if(parts['query'] != '')\n possible_paths.push(parts['path'] + parts['query'])\n end\n possible_paths.push(parts['path'])\n\n path = parts['path'].split('/')\n [path.length - 1, 5].min.times do |i|\n possible_path = path[0..i].join('/')\n if(possible_path == '' || i < path.length - 1)\n possible_path += '/'\n end\n\n possible_paths.push(possible_path)\n end\n\n return possible_hosts, possible_paths\n end",
"def api_v11_hosts_get(opts = {})\n api_v11_hosts_get_with_http_info(opts)\n return nil\n end",
"def hosts=(_arg0); end",
"def hosts=(_arg0); end",
"def all_server_hosts\n [server_host]\n end",
"def hosts\n (self.web_hosts.to_a + self.db_hosts.to_a + self.balance_hosts.to_a + self.app_hosts.to_a).uniq.sort\n end",
"def get_foreman_hosts(per_page = 10000)\n curl = setup_curl(\"#{@foreman_url}/api/hosts?per_page=#{per_page}\", true)\n curl.perform\n servers_junk = JSON.parse(curl.body_str)\n servers_array = []\n servers_junk.each { |server| servers_array << server['host']['name'] }\n @foreman_hosts = servers_array\n end",
"def host\n _, _, host, = URI.split url\n host\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 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 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 hosts(key)\n unless @@vendors[key].nil?\n @@vendors[key][:hosts].collect { |id| @@hosts[id] }\n else\n []\n end\n end",
"def doozer_hosts\n hosts = []\n walk('/ctl/node/*/addr') do |path, value, revision|\n hosts << value unless hosts.include? value\n end\n hosts\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 get_all(source=nil)\n extra_params = {}\n if source\n extra_params['source'] = source\n end\n\n request(Net::HTTP::Get, '/api/' + API_VERSION + '/tags/hosts', extra_params, nil, false)\n end",
"def lookup(request)\n\t\t\t\t# Trailing dot and port is ignored/normalized.\n\t\t\t\tif authority = request.authority&.sub(/(\\.)?(:\\d+)?$/, '')\n\t\t\t\t\treturn @hosts[authority]\n\t\t\t\tend\n\t\t\tend",
"def cmd_resolve_hosts argv\n setup argv\n name = @hash['name']\n response = @api.resolve_hosts(name)\n msg response\n return response\n end",
"def hosts(filter = {})\n paged_response(raw_hosts.index(filter).first)\n end",
"def get_vcenter_hosts(vcenter_id=nil, auth=nil, cert=nil)\n check_vcenter(vcenter_id)\n rest_get(\"#{@base_url}/compute/vcenters/#{vcenter_id}/hosts\", auth.nil? ? @auth_token : auth, cert.nil? ? @verify_cert : cert)\n end",
"def list_of_hosts\n super\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 getHost()\n return @uri.host\n end",
"def hosts\n @salticid.hosts.select do |host|\n host.roles.include? self\n end\n end",
"def host_ids\n array = Array.new\n\n self.each(\"HOSTS/ID\") do |id|\n array << id.text.to_i\n end\n\n return array\n end",
"def list_xpn_hosts request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_list_xpn_hosts_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::XpnHostList.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end",
"def list_hosts(domain, compact_list_optional)\n validate_list([[\"Domain\", domain, :domain_format]])\n options = {\"Domain\" => domain}\n optional_fields = [ [\"compact_list_optional\", compact_list_optional] ]\n options = set_optional_fields(optional_fields, options)\n\n connection = Connection.new\n connection.post(\"Domain/Host/List\", options)\n end",
"def index\n @hostnames = current_user.hostnames.all\n end",
"def list_hosts(folder = '')\n rows = JSON.parse(http_request(@uri + '/view.py', {\n wato_folder: folder,\n\tsearch: 'Search',\n\tfilled_in: 'filter',\n\thost_address_prefix: 'yes',\n\tview_name: 'searchhost',\n\toutput_format: 'json',\n\t}))\n rows.shift # skip the header\n rows.map { |r| r[1] }\n end",
"def extract_uris(uri, uri_content)\n # in our case, no new uri can be extracted from a web resource\n return Array.new()\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(wspace = workspace, only_up = false, addresses = nil)\n\t\tconditions = {}\n\t\tconditions[:state] = [Msf::HostState::Alive, Msf::HostState::Unknown] if only_up\n\t\tconditions[:address] = addresses if addresses\n\t\twspace.hosts.all(:conditions => conditions, :order => :address)\n\tend",
"def hosts_for(string)\n first = string[/^(\\w+)\\.\\w+/, 1]\n if role = @roles.find { |r| r.name == first }\n return role.hosts\n else\n raise \"Sorry, I didn't understand what hosts to run #{string.inspect} on.\"\n end\n end",
"def bad_hosts\n bad_hosts.collect {|r| r.host }\n end",
"def host\n URI.parse(@url).host\n end",
"def list_xpn_hosts request_pb, options:, &block\n uri = \"/compute/v1/projects/#{request_pb.project}/listXpnHosts\"\n body = request_pb.projects_list_xpn_hosts_request_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::XpnHostList.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n\n result\n end",
"def find(uri)\n _try_variations_of(uri) do |path|\n content= get path\n return [content] unless content.nil?\n end unless uri.nil?\n []\n end",
"def get_hostgroups()\n groups = @zabbix.hostgroup.get({\"output\" => \"extend\", \"sortfield\" => \"name\",})\n host_groups_names = []\n groups.each { |group| host_groups_names << group['name'] }\n return host_groups_names\n end",
"def host\n URI(self.uri).host\n end",
"def hosts(touchAndPrune=false)\n hosts=@vp_lock.synchronize{@hostname2vp.keys}\n if touchAndPrune\n check_up_hosts(hosts)\n else\n hosts\n end\n end",
"def urls\n @urls ||= extract_urls('url')\n end",
"def find_hosts!(host_spec)\n if self.groups[host_spec]\n return self.groups[host_spec].host_list.map { |m| self.hosts[m] }\n elsif self.hosts[host_spec]\n return [self.hosts[host_spec]]\n else\n say \"No inventory matching: '#{host_spec}' found. \"\n say ([\"Available hosts:\"] + self.hosts.keys).join(\"\\n\\t\")\n say ([\"Available groups:\"] + self.groups.keys).join(\"\\n\\t\")\n exit\n end\n end",
"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 hostnames(nodes)\n @referenced_nodes ||= ObjectList.new\n nodes = listify(nodes)\n nodes.each_node do |node|\n @referenced_nodes[node.name] ||= node\n end\n return nodes.values.collect {|node| node.domain.name}\n end",
"def get_hosts_by_group(name)\n begin\n groupid = get_group_by_name(name)[0][\"groupid\"].to_i\n hosts = @zbx.query( method: \"host.get\", params: {\"output\" => \"extend\", \"groupids\" => [groupid] } )\n rescue Exception => error\n return nil\n end\n end",
"def domains\n @_domains ||= mxers.map { |m| Host.new(m.first).domain_name }.sort.uniq\n end",
"def baculized_hosts\n hosts.in_bacula.pluck(:name)\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 list_hosts( zone_id)\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::Zerigo::DNS::ListHosts.new,\n :path => \"/api/1.1/zones/#{zone_id}/hosts.xml\"\n )\n end",
"def all_hosts_in(file)\n servers = []\n file.each do |line|\n if line.include?('Host ')\n servers << line.sub('Host ', '').strip\n end\n end\n servers\n end",
"def uri_host; end",
"def hosts(opts)\n ::ApplicationRecord.connection_pool.with_connection {\n # If we have the ID, there is no point in creating a complex query.\n if opts[:id] && !opts[:id].to_s.empty?\n return Array.wrap(Mdm::Host.find(opts[:id]))\n end\n\n wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework)\n\n conditions = {}\n conditions[:state] = [Msf::HostState::Alive, Msf::HostState::Unknown] if opts[:non_dead]\n conditions[:address] = opts[:address] if opts[:address] && !opts[:address].empty?\n\n if opts[:search_term] && !opts[:search_term].empty?\n column_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Mdm::Host, opts[:search_term])\n tag_conditions = Arel::Nodes::Regexp.new(Mdm::Tag.arel_table[:name], Arel::Nodes.build_quoted(\"(?mi)#{opts[:search_term]}\"))\n search_conditions = column_search_conditions.or(tag_conditions)\n wspace.hosts.where(conditions).where(search_conditions).includes(:tags).references(:tags).order(:address)\n else\n wspace.hosts.where(conditions).order(:address)\n end\n }\n end",
"def report_hosts(report_id)\r\n\t\tpost= { \"token\" => @token, \"report\" => report_id } \r\n\t\tdocxml=nessus_request('report/hosts', post)\r\n\t\tlist = Array.new\r\n\t\tdocxml.root.elements['contents'].elements['hostList'].each_element('//host') { |host| \r\n\t\t\tlist.push host.elements['hostname'].text\r\n\t\t}\r\n\t\treturn list\r\n\tend",
"def domains\n\tfetch(\"/Domain.List\")\nend",
"def read_hosts(file)\n hosts = Array.new\n File.open(file,'r') do |f|\n f.each_line do |line|\n if line[0] != \"#\" and line!=\"\"\n parts = line.split()\n if parts.size==4\n hosts << {:host => parts[0], :ps => parts[1].to_i, :user => parts[3]}\n end\n end\n end\n end\n hosts\n end",
"def get_hosts_from_hostgroup(host_group_name)\n raise \"host_group_name must be set\" if host_group_name.nil?\n\n results = @zabbix.hostgroup.get({\"filter\" => { \"name\" => host_group_name}, \"sortfield\" => \"name\", \"selectHosts\" => \"extend\"})\n return false unless results.any? == true\n host_names = []\n results.each { |result| result[\"hosts\"].each { |host| host_names << host[\"name\"] } }\n return host_names\n end",
"def urls\n each_url.to_set\n end",
"def hosts\n @job = Job.find(params[:id])\n host_array = []\n @job.nodes.each do |node|\n host_array << \"#{node.private_dns_name} #{node.private_dns_name.split('.')[0]}\"\n end\n send_data host_array.join(\"\\n\"), :type => 'text/html; charset=utf-8'\n end",
"def host\n @host ||= opts.fetch(:host, parsed_uri.host)\n end",
"def get_usage_hosts(start_hr, opts = {})\n data, _status_code, _headers = get_usage_hosts_with_http_info(start_hr, opts)\n data\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 turbo_hosts\n deep_values(\"turbo_hosts\")\n end",
"def grab_connections\n connections = []\n connections << @host\n end",
"def index_hosts\n load_service\n return if (@service.blank?)\n\n # Preload hosts\n @hosts = Host.where(:_id.in => @service.host_ids)\n\n respond_to do |format|\n format.html\n end\n end",
"def post_urls\n arr_hrefs = []\n collect_post_elements.each do |element|\n # there should only be one headline link per post\n if link = element.search( headline_element ).first \n uri = URI.parse link['href']\n uri.fragment = nil\n arr_hrefs << uri.to_s \n end\n end\n\n return arr_hrefs\n end",
"def host_set(host)\n rebuild_uri :host => host\n end",
"def get_host_by_hostname(hostname, collector)\n host = nil\n if collector\n hosts_json = rpc(\"getHosts\", {\"hostGroupId\" => 1})\n hosts_resp = JSON.parse(hosts_json)\n# p hosts_resp\n collector_resp = JSON.parse(rpc(\"getAgents\", {}))\n if hosts_resp[\"status\"] == 200\n hosts_resp[\"data\"][\"hosts\"].each do |h|\n if h[\"hostName\"].eql?(hostname)\n # puts(\"Found host with matching hostname: #{resource[:hostname]}\")\n # puts(\"Checking agent match\")\n if collector_resp[\"status\"] == 200\n collector_resp[\"data\"].each do |c|\n if c[\"description\"].eql?(collector)\n host = h\n end\n end\n else\n puts(\"Unable to retrieve collector list from server\")\n end\n end\n end\n else\n puts(\"Unable to retrieve host list from server\" )\n end\n end\n host\nend",
"def find_hosts( fqdn, zone_id = nil)\n if zone_id.nil?\n #look for matching host across all zones\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::Zerigo::DNS::FindHosts.new,\n :path => \"/api/1.1/hosts.xml?fqdn=#{fqdn}\"\n )\n else\n #look for hosts in a specific zone\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::Zerigo::DNS::FindHosts.new,\n :path => \"/api/1.1/zones/#{zone_id}/hosts.xml?fqdn=#{fqdn}\"\n )\n end\n end",
"def urls\n keys\n end",
"def preferred_hosts\n deep_values(\"preferred_hosts\")\n end",
"def visit_hosts\n @host_rules.accept\n end",
"def mongo_hosts\n @mongo_hosts\n end",
"def uri_info\n services.map do |s|\n uri = URI(s[:url])\n {\n host: uri.host,\n port: uri.port,\n scheme: uri.scheme\n }\n end\n end",
"def urls\n @sets.collect(&:keys).flatten\n end",
"def ssh_hostnames\n ssh_configs.map { |c| c.hostname }.compact.uniq.sort\n end",
"def get_a2a_hosts\n abs_initialize\n mom =\n { 'role': \"mom\",\n 'size': @mom_size,\n 'volume_size': @mom_volume_size }\n\n metrics =\n { 'role': \"metrics\",\n 'size': @metrics_size,\n 'volume_size': @metrics_volume_size }\n\n hosts = [mom, metrics]\n\n return hosts\n end",
"def uri_host(url)\n url = uri(url)\n url ? url.host : nil\n end",
"def get_host_from_url(url)\n return url[0...url.index(\"/\")]\nend",
"def parse_host_and_port_for_locale\n @parsed_host_and_port ||= begin\n parts = request.host_with_port.split('.')\n\n parts.shift if parts.first == 'www'\n\n lang = parts.shift if valid_locale?(parts.first)\n\n host, port = parts.join('.').split(':')\n [lang, host, port]\n end\n end",
"def domains\n []\n end",
"def host_aliases (host)\n\t\tputs \"Search aliases in the local hosts data repository for host: #{host}\" if @verbose\n\t\thost.strip!\n\t\traise \"Unknown method input: #{host} We expect a FQDN host-name string from you. \" unless is_fqdn?(host)\n\t\taliases=Array.new\n\t\tif @known_hosts.key?(host)\n\t\t\tip=local_host_2_ip(host)\n\t\t\t@known_hosts.keys.map do |key|\n\t\t\t\tmy_ip=local_host_2_ip(key)\n\t\t\t\tif ip == my_ip\n\t\t\t\t\taliases.push(key)\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\traise \"Unknown host-name in the local hosts data repository: #{host}\"\n\t\tend\n\t\treturn aliases-[host]\n\trescue Exception => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\t\treturn nil\n\tend"
] | [
"0.7350574",
"0.73418415",
"0.7292541",
"0.7212927",
"0.7190429",
"0.7047398",
"0.6989781",
"0.68751174",
"0.6825206",
"0.67855984",
"0.67705446",
"0.67204815",
"0.6502923",
"0.6502923",
"0.6502923",
"0.6431278",
"0.635271",
"0.63357264",
"0.6286228",
"0.6284372",
"0.6215691",
"0.6183216",
"0.6162001",
"0.6162001",
"0.6118607",
"0.61181813",
"0.604198",
"0.60323304",
"0.6031779",
"0.60272545",
"0.60169095",
"0.60102403",
"0.5999055",
"0.59907985",
"0.59631836",
"0.5942833",
"0.592745",
"0.5916536",
"0.58490527",
"0.5843941",
"0.5842504",
"0.5812509",
"0.5800854",
"0.5776408",
"0.577365",
"0.5763803",
"0.5755753",
"0.57387316",
"0.5690893",
"0.56824106",
"0.56717074",
"0.56451356",
"0.56286454",
"0.56260663",
"0.5625501",
"0.56217885",
"0.55951875",
"0.5584665",
"0.5582566",
"0.55765086",
"0.55627793",
"0.5562205",
"0.5543431",
"0.5527695",
"0.5520342",
"0.5516337",
"0.55091155",
"0.55090046",
"0.5500484",
"0.5493162",
"0.54909307",
"0.5476414",
"0.5472481",
"0.54462814",
"0.5444407",
"0.5440996",
"0.54162097",
"0.54116523",
"0.5409978",
"0.53693897",
"0.5369111",
"0.53626746",
"0.5350218",
"0.5348613",
"0.5346275",
"0.5346006",
"0.53436625",
"0.5330495",
"0.5326477",
"0.53167224",
"0.53147846",
"0.5281751",
"0.5271499",
"0.52654094",
"0.526531",
"0.526007",
"0.52574956",
"0.5255919",
"0.52494997",
"0.5249398"
] | 0.7346816 | 1 |
Create the new uri from the provided string. | def initialize(string)
@match = string.match(URI)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uri(string)\n return if string.blank?\n\n string = URI(string) unless string.is_a?(URI)\n\n # Rewrite host if necessary\n return string unless MetalArchives.config.endpoint\n\n endpoint = URI(MetalArchives.config.endpoint)\n\n string\n .tap { |u| u.host = endpoint.host }\n .tap { |u| u.scheme = endpoint.scheme }\n .tap { |u| u.port = endpoint.port }\n end",
"def build_uri(uri)\n return uri if @region.nil? && @edge.nil?\n\n parsed_url = URI(uri)\n pieces = parsed_url.host.split('.')\n product = pieces[0]\n domain = pieces[-2, 2]\n new_edge = @edge\n new_region = @region\n\n case pieces.length\n when 4\n new_region ||= pieces[1]\n when 5\n new_edge ||= pieces[1]\n new_region ||= pieces[2]\n end\n\n new_region = @@default_region if !new_edge.nil? && new_region.nil?\n\n parsed_url.host = [product, new_edge, new_region, domain].reject(&:nil?).join('.')\n parsed_url.to_s\n end",
"def create_uri\n end",
"def initialize(string)\n @match = string.match(URI)\n invalid_uri!(string) unless @match\n end",
"def uri( new_uri=nil )\n\t\tif new_uri\n\t\t\t@uri = URI( new_uri )\n\t\t\[email protected] ||= self.addresses.first.to_s\n\n\t\t\tself.app_protocol( @uri.scheme )\n\t\t\tself.port( @uri.port )\n\t\tend\n\n\t\treturn @uri.to_s\n\tend",
"def url_for(str)\n return str if str =~ /^[|[:alpha:]]+:\\/\\//\n File.join((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s), str)\n end",
"def construct_url(uri)\n \"#{uri.scheme}://#{uri.host}#{uri.path}\"\n end",
"def create_uri url\n uri = URI.parse url\n uri.user = @login\n uri.password = @password\n uri\n end",
"def build_request_uri(uri, params, container)\n newuri = uri.clone # don't modify uri template\n # We call uri.clone b/c we modify uri. \n uri.scan(/([:\\$])([a-z_]+)/i) do |inst|\n val = find_replacement_value(inst[1], params, container, base_uri)\n Stella.ld \"FOUND VAR: #{inst[0]}#{inst[1]} (value: #{val})\"\n re = Regexp.new \"\\\\#{inst[0]}#{inst[1]}\"\n newuri.gsub! re, val.to_s unless val.nil?\n end\n\n uri = URI.parse(newuri)\n \n if uri.host.nil? && base_uri.nil?\n Stella.abort!\n raise NoHostDefined, uri\n end\n \n uri.scheme = base_uri.scheme if uri.scheme.nil?\n uri.host = base_uri.host if uri.host.nil?\n uri.port = base_uri.port if uri.port.nil?\n uri.path ||= ''\n uri.path.gsub! /\\/$/, '' # Don't double up on the first slash\n \n uri\n end",
"def uri= new_uri\n @uri = self.class.build_uri new_uri\n end",
"def uri string = nil\n string ? @uri = string : @uri\n end",
"def build_uri\n # Validate the scheme.\n scheme = build_scheme.upcase\n raise UnresolvableResourceError, 'scheme must be http or https' if scheme!='HTTP' && scheme!='HTTPS'\n \n # Build and normalize the URI.\n URI.const_get(scheme).\n build2(host: build_host, port: build_port(scheme), userinfo: build_userinfo, path: build_path, query: build_query).\n normalize\n end",
"def ensure_url(str)\n if str.respond_to?(:scheme)\n str\n else\n str = str.to_s\n str.gsub! /\\s/, ''\n str.gsub! /(\\#|\\?).*/, ''\n Addressable::URI.parse str\n end\n end",
"def test_add\n uri_string = \"http://foobar.com/xyz/\"\n uri = N::URI.new(uri_string)\n assert_equal(N::URI.new(uri_string + \"add\"), uri + \"add\")\n assert_equal(N::URI.new(uri_string + \"add\"), uri + N::URI.new(\"add\"))\n end",
"def make_uri(namespaces, base_uri, value)\n if value.nil?\n return nil\n elsif value =~ /^\\[.*\\]$/\n return curie_to_uri(namespaces, value[1,value.length-2])\n else\n u = URI.parse(value)\n return (u.relative? and base_uri ) ? base_uri + u : u\n end\n end",
"def to_uri(uri, base_uri = nil)\n case base_uri\n when nil, ''\n Utils.normalize_uri(uri.to_s)\n else\n Utils.normalize_uri(base_uri) + Utils.normalize_uri(uri.to_s)\n end\n rescue URI::Error\n nil\n end",
"def create uri\n filename = uri_to_file(uri)\n @change_semaphore.synchronize do\n library.create_from_disk filename\n end\n end",
"def build_uri\n print \"building uri object...\"\n @uri = URI::HTTP.build({\n :host => \"lb.#{@datacenter}.reachlocal.com\",\n :path => \"\",\n :port => \"\",\n :scheme => \"http\",\n :fragment => \"\"\n })\n print \"done!\\n\"\n end",
"def build_uri(uri = nil)\n if uri.nil?\n \"#{@path}\"\n else\n [\"#{@path}\", uri].join(\"/\")\n end\n end",
"def create_uri(url, parms)\n uri = URI(url)\n uri.query = URI.encode_www_form(parms)\n uri\nend",
"def build_as_url\n URI(build_as_string)\n rescue Urb::InvalidUrl => e\n URI('/')\n end",
"def uri= uri_or_string\n if uri_or_string.respond_to?(:host)\n @uri = uri_or_string\n else\n string = uri_or_string =~ /^http/ ? uri_or_string : 'http://' + uri_or_string.to_s\n @uri = URI.parse(string)\n end\n @server = Net::HTTP.new(uri.host, uri.port)\n end",
"def to_uri\n uri_class = ::URI.const_get scheme.upcase\n uri_class.build host: host, path: path\n end",
"def initialize(params)\n @uri_string = params[:uri_string]\n end",
"def uri_path(str)\n str.gsub(%r{[^/]+}n) { uri_segment($&) }\n end",
"def normalize_uri(*strs)\n new_str = strs * '/'\n new_str = new_str.gsub!('//', '/') while new_str.index('//')\n new_str\n end",
"def build_uri(base_uri, url)\n uri = URI(url)\n unless uri.host\n uri = base_uri.merge(url)\n end\n uri\n rescue => ex\n nil\n end",
"def coerce_uri incoming_uri\n if incoming_uri.is_a? Hash\n Addressable::URI.new deep_hash_normalize(incoming_uri)\n elsif incoming_uri\n Addressable::URI.parse incoming_uri\n end\n end",
"def normalize_uri(*strs)\n new_str = strs * \"/\"\n\n new_str = new_str.gsub!(\"//\", \"/\") while new_str.index(\"//\")\n\n # Makes sure there's a starting slash\n unless new_str[0,1] == '/'\n new_str = '/' + new_str\n end\n\n new_str\n end",
"def initialize(uri)\n raise ArgumentError, \"No blank URI allowed here\" if(uri.to_s.blank?)\n @uri = N::URI.new(uri)\n end",
"def normalize_base_uri(str) #:nodoc:\n str =~ /^https?:\\/\\// ? str : \"http#{'s' if str.include?(':443')}://#{str}\"\n end",
"def build_uri(path)\n path = path.to_s\n unless path.match(/^\\//)\n path = \"/#{path}\"\n end\n base_uri + path\n end",
"def parse(uri)\n URI.for(*self.split(uri), self)\n end",
"def absolute_url_for(uri, str)\n # TODO: use URI.parse() for better handling?\n return str if str =~ /^[|[:alpha:]]+:\\/\\//\n File.join(((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s)), \n str)\n end",
"def uri\n URI.new :scheme => scheme,\n :host => host,\n :path => path,\n :query => query\n end",
"def initialize(uri_string, options = {})\n @options = options.clone\n setup_uri_state!(uri_string)\n setup_request_config!\n end",
"def uri_for(uri_or_path, params = nil)\n if uri_or_path.kind_of? URI\n u = uri_or_path.dup\n\n u.host = @uri.host\n u.port = @uri.port\n u.scheme = @uri.scheme\n else\n u = uri.dup\n u.path = File.join(uri.path, uri_or_path)\n end\n\n u.query = query_string_for(params) if params\n u.to_s\n end",
"def initialize(string, params = {})\n params ||= {}\n self.class.include Scheme\n\n @url = string\n @query = params[:query_params] || {}\n @encoding = params[:encoding] || 'utf-8'\n\n set_scheme params[:force_scheme]\n encode_url\n end",
"def build_uri(resource)\n URI(\"#{API_URL}/#{resource}\")\n end",
"def categorize_uri(str)\n regex = /\\.+/ # really simple host regex to thwart unwanted strings\n str = \"http://#{str}\" unless str.to_s =~ %r{\\Ahttps?://}\n uri = URI.parse(str.to_s)\n path = uri.path.chomp('/')\n return :unknown if (uri.host =~ regex).nil?\n\n path.empty? ? :host : :url\n rescue URI::InvalidURIError\n :unknown\n end",
"def uri (name,default=\"\")\n \n name=name.to_s\n #FIXME: bad urls (for example just www.example.com will produce an endless-loop\n if name.try(:include?, \"://\")\n return name[0..name.length-2] if name[-1,1]==\"/\"\n return name[0..name.length]\n else\n name +=\"/\" unless (name[name.length-1..name.length-1] == (\"/\" || \"#\")) || name.try(:include?, \":\")\n\n if name.index(\":\") \n t= @object_namespaces[name.split(\":\")[0].to_sym]\n t ||=\"\"\n t += \"/\" unless (t[t.length-1..t.length-1] == (\"/\" || \"#\") || t.blank?) || name.try(:include?, \":\")\n return uri( t+ normalize_local_name(name.split(\":\")[1])+\"/\")\n else \n t= default.blank? ? @base_uri : default\n t += \"/\" unless t[t.length-1..t.length-1]==\"/\"\n return uri( t + normalize_local_name(name))\n end\n end\n end",
"def initialize uri\n self.uri = uri\n end",
"def test_uri\n uri_string = \"http://foobar.com/xyz/\"\n uri = N::URI.new(uri_string)\n assert_equal(uri_string, uri.to_s)\n end",
"def initialize(uri, env)\n @root = env.root\n @env = env\n uri = uri.to_s\n if uri.include?(\"://\".freeze)\n @scheme, _, @path = uri.partition(\"://\".freeze)\n @scheme << \"://\".freeze\n else\n @scheme = \"\".freeze\n @path = uri\n end\n end",
"def raptor_new_string(str)\n ptr = V1.raptor_alloc_memory(str.bytesize + 1)\n ptr.put_string(0, str)\n ptr\n end",
"def cannonical_uri_string\n @cannonical_uri_string ||= if resource_collection_uri?\n \"#{@string}/#{UUID.generate}\"\n elsif resource_uri?\n @string\n else\n raise CloudKit::InvalidURIFormat\n end\n end",
"def make_url(string)\n puts \"not implemented\"\nend",
"def build_uri(base_uri, rest_path)\n if server.options[:single_org]\n # Strip off /organizations/chef if we are in single org mode\n if rest_path[0..1] != [ 'organizations', server.options[:single_org] ]\n raise \"Unexpected URL #{rest_path[0..1]} passed to build_uri in single org mode\"\n else\n \"#{base_uri}/#{rest_path[2..-1].join('/')}\"\n end\n else\n \"#{base_uri}/#{rest_path.join('/')}\"\n end\n end",
"def normalize_uri uri\n (uri =~ /^https?:/) ? uri : \"http://#{uri}\"\n end",
"def generate_new_location_uri\n candidate = nil\n loop do\n candidate = uri_prefix + pid_generator.next_pid\n break unless exists?(candidate)\n end\n candidate\n end",
"def set_uri(base, path)\n @uri = \"#{base}/#{path}/#{self.identifier}\"\n end",
"def to_uri\n URI.parse(to_s)\n end",
"def uri\n URI::Generic.build(host: addr, port: port)\n end",
"def uri\n URI::Generic.build(host: addr, port: port)\n end",
"def ensure_uri(uri)\n raise ArgumentError, \"ensure_uri: uri may not be nil\" if uri.nil?\n is_uri?(uri) ? uri : URI.parse(uri)\n end",
"def url(uri=nil)\n @uri = Addressable::Template.new(uri.gsub(/:(?![0-9])(\\w+)/) { \"{#{$1}}\" }) unless uri.nil?\n @uri\n end",
"def build_uri(command = '')\n uri_to_parse = @node +'/1.1/'+ @user_obj.encrypted_login\n uri_to_parse += \"/#{command}\" unless command == ''\n URI.parse(uri_to_parse)\n end",
"def parse(uri)\n scheme, userinfo, host, port,\n registry, path, opaque, query, fragment = self.split(uri)\n\n if scheme && URI.scheme_list.include?(scheme.upcase)\n URI.scheme_list[scheme.upcase].new(scheme, userinfo, host, port,\n registry, path, opaque, query,\n fragment, self)\n else\n Generic.new(scheme, userinfo, host, port,\n registry, path, opaque, query,\n fragment, self)\n end\n end",
"def uri_from_env(env_var, default)\n Addressable::URI.parse(ENV.fetch(env_var, default))\n end",
"def from(string)\n @str = string.dup\n self # Allow chaining\n end",
"def uri\n \"http://example.com#{base_path}#{anchor}\"\n end",
"def conform_uri(uri_string)\n uri_string.gsub(/^(?!\\/)(.*)/, '/\\1').gsub(/[\\/]+$/, '')\n end",
"def uri(*parts)\n # If an absolute URI already\n return parts.first if parts.first.is_a?(URI) && parts.first.host\n\n joined = [url, *parts].map(&:to_s).reject(&:empty?) * '/'\n\n URI.parse(joined)\n end",
"def initialize(uri)\r\n\t\t@uri = clean(uri)\r\n\t\t@uri_xml_encoded_only = REXML::Text.normalize(@uri)\r\n\t\t\r\n\t\t\r\n\t\t@follow_link = true\r\n\tend",
"def generate_new_location_uri\n raise NotImplementedError\n end",
"def url_for(string); end",
"def uri\n N::URI.new(self[:uri])\n end",
"def uri\n N::URI.new(self[:uri])\n end",
"def from_string(string, opts = {})\n encoding = opts.fetch(:encoding) { string.encoding }\n reader = Helpers.string_reader(string, encoding)\n from_inputstream_or_reader(reader, opts[:base_uri])\n end",
"def create_uri(fake_method, **kwargs)\n @uri_part += kwargs ? kwargs.map {|k, v| \"/#{k}/#{v}\"}.join : ''\n \"api/#{fake_method}#{@uri_part}/xml\"\n end",
"def initialize_from_string(string)\n raise NotImplementedError\n end",
"def uri_normalize(uri)\n \treturn 'http://' + uri unless uri =~ /http:\\/\\//\n \turi\n\tend",
"def uri_normalize(uri)\n \treturn 'http://' + uri unless uri =~ /http:\\/\\//\n \turi\n\tend",
"def make_request_uri(uri, opts)\n uri = uri.to_s\n\n uri = \"#{default_options.persistent}#{uri}\" if default_options.persistent? && uri !~ HTTP_OR_HTTPS_RE\n\n uri = HTTP::URI.parse uri\n\n uri.query_values = uri.query_values(Array).to_a.concat(opts.params.to_a) if opts.params && !opts.params.empty?\n\n # Some proxies (seen on WEBRick) fail if URL has\n # empty path (e.g. `http://example.com`) while it's RFC-complaint:\n # http://tools.ietf.org/html/rfc1738#section-3.1\n uri.path = \"/\" if uri.path.empty?\n\n uri\n end",
"def new_http(uri); end",
"def initialize(uri:)\n @uri = uri\n end",
"def build_url(path, params={})\n full_path = @uri.path + path\n full_url = \"#{@uri.scheme}://#{@uri.host}\"\n full_url += \":#{@uri.port}\" if @uri.port\n full_url += super(full_path, params, @uri.query)\n end",
"def to_uri\n URI.parse self\n end",
"def uri\n self + \"\"\n end",
"def uri\n self + \"\"\n end",
"def parse_url(url_str, name = 'URL')\n begin \n uri = URI.parse(url_str)\n rescue Exception => e\n raise URLError, \"couldn't parse #{name} '#{url_str}': #{e}\"\n end\n\n # check URI scheme\n unless uri.scheme == 'http'\n raise URLError, \"Unknown #{name} scheme: #{uri.scheme}\"\n end\n\n # return URI\n uri\n end",
"def to_uri\n build_uri\n end",
"def uri\n @uri ||= begin\n uri = Addressable::URI.parse(sanitize_link(@link_string))\n uri.normalize\n uri.query_values = nil\n uri\n end\n end",
"def uri!\n @uri = URI.parse \"#{@config.http_scheme}://#{@config.host}:#{@config.port}/api/#{@config.api_version}/\"\n end",
"def uri=(_arg0); end",
"def uri=(_arg0); end",
"def uri=(_arg0); end",
"def uri=(_arg0); end",
"def initialize(uri, parent)\n if uri.try(:node?)\n uri = RDF::URI(\"#identifier#{uri.to_s.gsub('_:', '')}\")\n elsif uri.start_with?(\"#\")\n uri = RDF::URI(uri)\n end\n super\n end",
"def initialize uri_or_string, username=nil, password=nil\n self.uri = uri_or_string\n @username = username || uri.user\n @password = password || uri.password\n @request_id = 0\n end",
"def make_relative_uri(hash={})\n @urigen.make_relative_uri(hash)\n end",
"def build_log_uri(base_uri, loc_file)\n scheme, userinfo, host, port, registry, path, opaque, query, fragment = URI.split(URI::DEFAULT_PARSER.escape(base_uri))\n\n # Convert encoded spaces back to spaces\n path.gsub!('%20', ' ')\n\n relpath = relative_path_for_upload(loc_file)\n new_path = File.join(\"/\", path, relpath)\n uri = URI::HTTP.new(scheme, userinfo, host, port, registry, new_path, opaque, query, fragment).to_s\n _log.info(\"New URI: [#{uri}] from base: [#{base_uri}], and relative path: [#{relpath}]\")\n uri\n end",
"def initialize(uri, parent)\n if uri.try(:node?)\n uri = RDF::URI(\"#funding#{uri.to_s.gsub('_:', '')}\")\n elsif uri.start_with?(\"#\")\n uri = RDF::URI(uri)\n end\n super\n end",
"def to_uri_fragment\n # remove HTML tags from the input\n buf = gsub(/<.*?>/, '')\n\n # The first or only character must be a letter.\n buf.insert(0, 'a') unless buf[0,1] =~ /[[:alpha:]]/\n\n # The remaining characters must be letters, digits, hyphens (-),\n # underscores (_), colons (:), or periods (.) or Unicode characters\n buf.unpack('U*').map! do |code|\n if code > 0xFF or code.chr =~ /[[:alnum:]\\-_:\\.]/\n code\n else\n 32 # ASCII character code for a single space\n end\n end.pack('U*').strip.gsub(/[[:space:]-]+/, '-')\n end",
"def hubssolib_promote_uri_to_ssl(uri_str, host = nil)\n uri = URI.parse(uri_str)\n uri.host = host if host\n uri.scheme = 'https'\n return uri.to_s\n end",
"def initialize(uri, factory)\n self.factory = factory\n self.uri = uri\n end",
"def _uri(uri, absolute = false, format = \"do\")\n return absolute ? \"#{uri}.#{format}\" : \"#{uri_prefix}#{uri ? uri : ''}.#{format}\"\n end",
"def normalize_uri(uri)\n (uri =~ /^(https?|ftp|file):/) ? uri : \"http://#{uri}\"\n end",
"def initialize(uri, parent)\n if uri.try(:node?)\n uri = RDF::URI(\"#person#{uri.to_s.gsub('_:', '')}\")\n elsif uri.start_with?(\"#\")\n uri = RDF::URI(uri)\n end\n super\n end",
"def URI(url); end"
] | [
"0.7402693",
"0.70300627",
"0.65971994",
"0.6473146",
"0.64545035",
"0.6445503",
"0.6440364",
"0.63728964",
"0.6298496",
"0.6262053",
"0.62530804",
"0.6208939",
"0.6127222",
"0.6126438",
"0.61233413",
"0.6106487",
"0.60913354",
"0.6088699",
"0.60630333",
"0.604967",
"0.6047005",
"0.6029982",
"0.6028465",
"0.60069877",
"0.6002648",
"0.59995717",
"0.59857357",
"0.59755534",
"0.59742564",
"0.59619623",
"0.59522194",
"0.5950424",
"0.5937416",
"0.59139806",
"0.5893575",
"0.5882076",
"0.5873984",
"0.5868812",
"0.5861439",
"0.5855179",
"0.58344066",
"0.5820305",
"0.58115506",
"0.57778823",
"0.575477",
"0.57502997",
"0.57448417",
"0.57274085",
"0.5683622",
"0.5676285",
"0.56742847",
"0.5649227",
"0.5641905",
"0.5641905",
"0.56406516",
"0.5619753",
"0.5591256",
"0.5582337",
"0.5563182",
"0.5546382",
"0.55239856",
"0.5522495",
"0.55054",
"0.5503972",
"0.5503503",
"0.5485466",
"0.54681355",
"0.54681355",
"0.54632723",
"0.5457638",
"0.54413974",
"0.5440474",
"0.5440474",
"0.54381245",
"0.54303724",
"0.5427823",
"0.5414003",
"0.54098654",
"0.54082394",
"0.54082394",
"0.54051006",
"0.54011184",
"0.54000676",
"0.5398455",
"0.5380801",
"0.5380801",
"0.5380801",
"0.5380801",
"0.5376656",
"0.537036",
"0.5357446",
"0.53548664",
"0.53544974",
"0.535353",
"0.5348802",
"0.53426224",
"0.5342581",
"0.5339799",
"0.53386027",
"0.5335931"
] | 0.5929767 | 33 |
Get the password provided in the URI. | def password
@password ||= match[4]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_password\n password = @uri.password\n password ? Wgit::Url.new(password) : nil\n end",
"def get_password(password)\n password\n end",
"def password\n connect\n password = self.class.query('CMD_API_VERIFY_PASSWORD',\n :user => resource[:username],\n :passwd => resource[:password]\n )\n if password[\"valid\"] == \"1\"\n return resource[:password]\n else\n return \"********\"\n end\n end",
"def getpassword()\r\n return getvalue(SVTags::PASSWORD)\r\n end",
"def password\n if !@password_insync && resource[:api_admin] == :true\n update_admin_pass_with_rake\n end\n return resource[:password] if @password_insync\n return nil\n end",
"def password\n Shellwords.shellescape(SabreDAVExport.password)\n end",
"def password\n credentials.last\n end",
"def password\n @password ||= opts.fetch(:password, parsed_opt('password'))\n end",
"def password\n return @password\n end",
"def fetch(password)\r\n end",
"def password\n open(@credentials_file, 'r').readlines.last.strip if valid_file?(@credentials_file)\n end",
"def getPassword()\n return @password\n\tend",
"def password\n return @password\n end",
"def password\n return nil unless @password\n @password.password\n end",
"def password\n @attributes[:password]\n end",
"def password\n @attributes[:password]\n end",
"def password\n conf['api']['password']\n end",
"def password\n @hash.to_s\n end",
"def password\n\t\tbegin\n\t\t\tr = curl '-s', '-u', \"#{@resource[:name]}:#{@resource[:password]}\",\n\t\t\t\t\"http://localhost:#{@resource[:mgmt_port]}/api/whoami\"\n\t\t\tdebug r\n\t\trescue\n\t\t\traise \"Management plugin not reachable at localhost:%s\" % @resource[:mgmt_port]\n\t\tend\n\t\trh = JSON.parse r\n\t\t\n\t\tif( rh.key?(:name) and rh[:name] == @property_hash[:name] )\n\t\t\treturn @resource[:password]\n\t\tend\n\t\t\n\t\tif ( rh['error'] == 'not_authorised' and rh['reason'] == 'Not management user' )\n\t\t\treturn @resource[:password]\n\t\telse\n\t\t\treturn ''\n\t\tend\n\tend",
"def password\n @password ||= match[4]\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def find_password\n @password || $config.fetch(:password) || prompt_password\n end",
"def password(password_name)\n pwd = Security::GenericPassword.find(l: password_name)\n pwd = Security::InternetPassword.find(l: password_name) if !pwd\n raise \"A password named '#{password_name}' does not exist in the default keychain\" if !pwd\n pwd.password\n end",
"def password\n @password || raise(Communicator::MissingCredentials.new(\"No Password specified for HTTP AUTH. Please configure using Communicator.password='xyz'\"))\n end",
"def password\n Password.find(password_id)\n end",
"def password_credential\n user.credentials.find { |c| c.is_a? Credentials::Password }\n end",
"def password\n password = Base64.decode64(@config.fetch(:password, nil))\n if password\n cipher.decrypt_string(password).gsub(\"\\0\", \"\")\n else\n password\n end\n end",
"def get_password\n\tpwd1 = Password.get(\"New Password: \")\n\tpwd2 = Password.get(\"Retype New Password: \")\n\n\tbegin\n\t\traise if pwd1 != pwd2\n\t\trescue\n\t\t\tprint \"ERROR: Password mismatch!\\n\"\n\t\t\texit\n\tend\n\n\tbegin\n\t\tpwd1.check # check password strength\n\t\trescue\n\t\t\tprint \"ERROR: Password strength check failed: \" + $! + \"\\n\"\n\t\t\texit\n\tend\n\n\tsalt = rand.to_s.gsub(/0\\./, '')\n\tpass = pwd1.to_s\n\thash = \"{SSHA}\"+Base64.encode64(Digest::SHA1.digest(\"#{pass}#{salt}\")+salt).chomp!\n\treturn hash\nend",
"def password\n @retain_user_connection_parameters.password\n end",
"def user_password\n @password\n end",
"def password(db_connection)\n sql = 'SELECT password FROM user_logins WHERE user_id=$1;'\n db_connection.exec_params(sql, [ id ]).first['password']\n end",
"def password\n @password\n end",
"def password\n @password ||= Password.new(password_digest)\n end",
"def password\n @password||=@options['password']\n end",
"def password\n 'password'.gsub('', '')\n end",
"def password\r\n @password\r\n end",
"def password_digest(password); end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n @password\n end",
"def password\n if password_digest\n @password ||= BCrypt::Password.new(password_digest)\n else\n nil\n end\n end",
"def account_password\n get_account_password\n end",
"def password\n raw_password = read_attribute(:password)\n raw_password.blank? ? nil : crypt.decrypt(raw_password)\n end",
"def password\n\t\t@password\n\tend",
"def password\n\t\t@password\n\tend",
"def hash_password(password)\n puts \"Password: #{password}\"\n stdout, result = Open3.capture2('openssl', 'passwd', '-apr1', password)\n puts stdout\n puts result\n if result.success?\n return stdout\n else\n raise ShellError\n end\n end",
"def standard_password_digest\n password_digest( standard_password )\n end",
"def password\n\t\tPassword.new( attribute_get(:password) )\n\tend",
"def password(id)\n profile_element = profile(id)\n if profile_element\n enc_passwd = profile_element['password']\n return decrypt(enc_passwd) if enc_passwd\n end\n end",
"def get_password_policy(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'GetPasswordPolicy'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tself.run(args)\n\tend",
"def password_credentials\n return @password_credentials\n end",
"def password_input\n if password_params != nil\n password = password_params[:password]\n shared = false\n get(password, shared) \n end\n end",
"def password\n first_element_text('password')\n end",
"def password\n\t@password\n\tend",
"def auth_password username, password\n user = User.find_by_username username\n return nil unless (user and user.password_digest)\n if user.password == password\n return user\n else\n return nil\n end\n end",
"def credentials_for uri, realm\n uri = URI uri unless URI === uri\n\n uri += '/'\n uri.user = nil\n uri.password = nil\n\n realms = @auth_accounts[uri]\n\n realms[realm] || realms[nil] || @default_auth\n end",
"def password(profile)\n profile_element = @repository_xml.root.elements[\"profile[@id='#{profile}']\"]\n if profile_element\n enc_passwd = profile_element.attributes['password']\n return decrypt(enc_passwd) if enc_passwd\n end\n end",
"def with_uri_credentials(uri)\n if uri.user and uri.password\n yield(Utils.unescape(uri.user), Utils.unescape(uri.password))\n end\n end",
"def extract_password(line) =\n line.match(PASSWORD_INFO)&.named_captures&.transform_keys(&:to_sym)",
"def password\n self.class.escape_dn(@cert_chain[0].subject.to_s)\n end",
"def standard_password\n \"!@Cd5678\"\n end",
"def guess_http_password(attempt)\n HTTParty.get(\n \"http://localhost:3001/bank/vault\",\n headers: {\n \"Authorization\" => \"Token token=#{attempt}\"\n }\n ).success?\n end",
"def password\n @password ||= ::BCrypt::Password.new(password_digest)\n end",
"def passwd\r\n @password = \"12345\"\r\n end",
"def password_node\n return password unless digest?\n\n token = nonce + timestamp + password\n Base64.encode64(Digest::SHA1.hexdigest(token)).chomp!\n end",
"def credentials_for(uri, realm); end",
"def authenticate_with_http_digest(realm = T.unsafe(nil), &password_procedure); end",
"def password\n @password ||= Password.new(password_hash)\n end",
"def password\n @password ||= Password.new(password_hash)\n end",
"def password\n @password ||= Password.new(password_hash)\n end",
"def password\n @password ||= Password.new(password_hash)\n end",
"def password\n @password ||= Password.new(password_hash)\n end",
"def password\n @password ||= Password.new(password_hash)\n end"
] | [
"0.7688032",
"0.7278035",
"0.71954423",
"0.6933452",
"0.6813961",
"0.67981833",
"0.67922705",
"0.6749623",
"0.6726572",
"0.66764104",
"0.66354936",
"0.6610255",
"0.65721804",
"0.65259826",
"0.6508754",
"0.6508754",
"0.65066034",
"0.64915466",
"0.648858",
"0.64885455",
"0.6460099",
"0.6460099",
"0.64578813",
"0.64578813",
"0.6434285",
"0.6425866",
"0.6419631",
"0.6411843",
"0.6382781",
"0.6356834",
"0.634738",
"0.63368183",
"0.63270813",
"0.6319995",
"0.63122565",
"0.6300208",
"0.6289729",
"0.6287426",
"0.6282461",
"0.62179023",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.6213294",
"0.620753",
"0.61711246",
"0.61703044",
"0.6151466",
"0.6151466",
"0.61503303",
"0.6123256",
"0.612275",
"0.6110951",
"0.60991526",
"0.6086376",
"0.6079281",
"0.60758156",
"0.60682344",
"0.606175",
"0.6053665",
"0.6053002",
"0.6044128",
"0.603119",
"0.60283786",
"0.6007047",
"0.5994346",
"0.59835696",
"0.5982311",
"0.59799296",
"0.59713864",
"0.5956962",
"0.5956165",
"0.5956165",
"0.5956165",
"0.5956165",
"0.5956165",
"0.5956165"
] | 0.6514339 | 14 |
Get the uri as a Mongoid friendly configuration hash. | def to_hash
config = { database: database, hosts: hosts }
if username && password
config.merge!(username: username, password: password)
end
config
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uri\n if @config.include?('uri')\n @config['uri']\n elsif credentials?\n \"mongodb://#{credentials}@#{@config['host']}:#{@config['port']}/#{@config['database']}\"\n else\n \"mongodb://#{@config['host']}:#{@config['port']}/#{@config['database']}\"\n end\n end",
"def configured_uri_for(uri)\n if /https?:/ =~ uri\n remote = URI(uri)\n config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]\n remote.userinfo ||= config_auth\n remote.to_s\n else\n uri\n end\n end",
"def configured_uri\n if /https?:/.match?(uri)\n remote = Bundler::URI(uri)\n config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]\n remote.userinfo ||= config_auth\n remote.to_s\n elsif File.exist?(uri)\n \"file://#{uri}\"\n else\n uri.to_s\n end\n end",
"def to_s\n uri\n end",
"def uri\n @uri.to_s\n end",
"def uri\n uri_for({}, nil)\n end",
"def uri_hash # :nodoc:\n normalized =\n if @repository =~ %r%^\\w+://(\\w+@)?% then\n uri = URI(@repository).normalize.to_s.sub %r%/$%,''\n uri.sub(/\\A(\\w+)/) { $1.downcase }\n else\n @repository\n end\n\n Digest::SHA1.hexdigest normalized\n end",
"def to_s\n uri.to_s\n end",
"def uri\n attributes.fetch(:uri)\n end",
"def uri\n attributes.fetch(:uri)\n end",
"def to_uri\n build_uri\n end",
"def uri\n uri_prefix + Digest::MD5.hexdigest(self.address)\n end",
"def uri_hash # :nodoc:\n require_relative '../openssl'\n\n normalized =\n if @repository =~ %r{^\\w+://(\\w+@)?}\n uri = URI(@repository).normalize.to_s.sub %r{/$},''\n uri.sub(/\\A(\\w+)/) { $1.downcase }\n else\n @repository\n end\n\n OpenSSL::Digest::SHA1.hexdigest normalized\n end",
"def to_s\n @uri.to_s\n end",
"def to_s\n @uri.to_s\n end",
"def to_s\n uri_string\n end",
"def uri\n \"#{@@config[:base_uri]}#{id}\"\n end",
"def to_s\n @uri\n end",
"def getURI()\n return @uri.to_s\n end",
"def uri\n read_attr :uri\n end",
"def to_s\n self.uri.to_s\n end",
"def url\n uri.to_s\n end",
"def uri\n opts[:uri]\n end",
"def uri\n conf['uri'] || git_source\n end",
"def mongo_uri\n [\"#{ host }:#{ port }#{ ('/' + name) if name }\",\n credential_options, ipv6_option].join(' ').strip\n end",
"def to_addressable_uri\n @uri\n end",
"def full_uri\n \"#{host_uri}#{uri}\"\n end",
"def uri\n return @uri\n end",
"def uri\n return @uri\n end",
"def get_uri\n unless self.uri == nil\n return self.uri\n else \n return repository.generate_uri(title)\n end\n end",
"def to_s\n @uri\n end",
"def url\n uri.to_s\n end",
"def uri\n @uri\n end",
"def uri\n @uri\n end",
"def configured_uri_for(uri)\n uri = uri.gsub(\"[email protected]:\", \"https://github.com/\")\n if /https?:/ =~ uri\n remote = URI(uri)\n config_auth =\n Bundler.settings[remote.to_s] || Bundler.settings[remote.host]\n remote.userinfo ||= config_auth\n remote.to_s\n else\n uri\n end\n end",
"def uri_endpoint\n URI( self.endpoint )\n end",
"def uri!\n @uri = URI.parse \"#{@config.http_scheme}://#{@config.host}:#{@config.port}/api/#{@config.api_version}/\"\n end",
"def base_uri(in_or_out = :in)\n Rails.my_config(\"base_uri_#{in_or_out}\".to_sym)\n end",
"def to_base\n return nil unless @uri.scheme && @uri.host\n\n base = \"#{@uri.scheme}://#{@uri.host}\"\n Wgit::Url.new(base)\n end",
"def to_endpoint\n endpoint = @uri.path\n endpoint = '/' + endpoint unless endpoint.start_with?('/')\n Wgit::Url.new(endpoint)\n end",
"def to_endpoint\n endpoint = @uri.path\n endpoint = '/' + endpoint unless endpoint.start_with?('/')\n Wgit::Url.new(endpoint)\n end",
"def uri\n N::URI.new(self[:uri])\n end",
"def uri\n N::URI.new(self[:uri])\n end",
"def to_s\n reconstruct_uri\n end",
"def uri\n\t\turi_parts = {\n\t\t\t:scheme => self.connect_type == :ssl ? 'ldaps' : 'ldap',\n\t\t\t:host => self.host,\n\t\t\t:port => self.port,\n\t\t\t:dn => '/' + self.base_dn\n\t\t}\n\n\t\treturn URI::LDAP.build( uri_parts )\n\tend",
"def uri_path\n __getobj__.uri.path\n end",
"def ssh_uri\n unless @uri.host\n raise(InvalidConfig,\"URI does not have a host: #{@uri}\",caller)\n end\n\n new_uri = @uri.host\n new_uri = \"#{@uri.user}@#{new_uri}\" if @uri.user\n\n return new_uri\n end",
"def to_base\n return nil if @uri.scheme.nil? || @uri.host.nil?\n\n base = \"#{@uri.scheme}://#{@uri.host}\"\n Wgit::Url.new(base)\n end",
"def uri\n @uri ||= URI(url)\n end",
"def uri\n @uri\n end",
"def uri\n @uri\n end",
"def uri\n URI.new :scheme => scheme,\n :host => host,\n :path => path,\n :query => query\n end",
"def db_uri\n unless @db_uri # get the config from command line\n @db_uri = self.conf['db_url']\n end\n @db_uri\n end",
"def base_uri\n attributes.fetch(:baseUri)\n end",
"def to_hash\n self.config.to_hash\n end",
"def build_uri(options = {})\n \"mongodb://\".tap do |base|\n base << \"#{username}:#{password}@\" if authenticating?\n base << \"#{options[\"host\"] || \"localhost\"}:#{options[\"port\"] || 27017}\"\n base << \"/#{self[\"database\"]}\" if authenticating?\n end\n end",
"def uri\n @uri ||= URI.parse @url if @url\n @uri\n end",
"def uri\n @uri ||= resource_template.uri_for(params, application.base)\n end",
"def hash\n [uri, parameters, username, password, verify_mode].hash\n end",
"def to_uri\n URI(normalize)\n end",
"def url\n uri\n end",
"def url\n uri\n end",
"def uri_host; end",
"def to_uri\n uri_class = ::URI.const_get scheme.upcase\n uri_class.build host: host, path: path\n end",
"def uri( new_uri=nil )\n\t\tif new_uri\n\t\t\t@uri = URI( new_uri )\n\t\t\[email protected] ||= self.addresses.first.to_s\n\n\t\t\tself.app_protocol( @uri.scheme )\n\t\t\tself.port( @uri.port )\n\t\tend\n\n\t\treturn @uri.to_s\n\tend",
"def root_uri\n attributes.fetch(:rootUri)\n end",
"def square_uri\n square_params\n uri\n end",
"def uri\n @uri ||= select { |type,value| type == :uri }.map do |(type,value)|\n URI.parse(value)\n end\n end",
"def uri\n \"#{database.uri}/#{ensure_id}\"\n end",
"def to_uri\n URI(normalise)\n end",
"def get_hash()\n\t\t\treturn @config.clone()\n\t\tend",
"def uri\n database.uri + '/' + ensure_id\n end",
"def uri\n\t\turi = self.directory.uri\n\t\turi.dn = self.dn\n\t\treturn uri\n\tend",
"def uri_base\n \"http#{'s' if @options[:ssl]}://#{@options[:host]}\"\n end",
"def normalise\n Wgit::Url.new(@uri.normalize.to_s)\n end",
"def root_uri_path\n @options[:root_uri_path]\n end",
"def to_hash\n configuration\n end",
"def uri\n URI::Generic.build(host: addr, port: port)\n end",
"def uri\n URI::Generic.build(host: addr, port: port)\n end",
"def uri(options = {})\n options[\"uri\"] || build_uri(options)\n end",
"def base_uri\n @options[:base_uri]\n end",
"def base_uri\n @options[:base_uri]\n end",
"def uri\n connection&.uri\n end",
"def uri\n @_uri ||= URI(@url)\n end",
"def uri\n @_uri ||= URI(@url)\n end",
"def object_key_from_uri(uri)\n uri.split('/')[3..-1].join('/')\n end",
"def openid_config_url\n \"https://login.windows.net/#{tenant}/.well-known/openid-configuration\"\n end",
"def get\n uri\n super()\n end",
"def get\n uri\n super()\n end",
"def get\n uri\n super()\n end",
"def to_host\n host = @uri.host\n host ? Wgit::Url.new(host) : nil\n end",
"def to_host\n host = @uri.host\n host ? Wgit::Url.new(host) : nil\n end",
"def uri\n @uri ||= URI.parse(url)\n end",
"def square_url\n square_uri.to_s\n end",
"def config_hash\n digest = Digest::MD5.hexdigest(\n \"#{@x}-#{@y}-#{@hires_factor}-#{@render_type}-#{@format}-#{CONVERTER_VERSION}\")\n digest\n end",
"def get_magic_link_config\n return @client.raw(\"get\", \"/helpers/magic-link-config\")\n end",
"def to_s\n @uri_string ||=\n begin\n uri_string = \"#{normalized_authority}:#{normalized_path}\"\n if uri_string.respond_to?(:force_encoding)\n uri_string.force_encoding(Encoding::UTF_8)\n end\n uri_string\n end\n end",
"def to_uri\n URI.parse self\n end",
"def to_path\n path = @uri.path\n return nil if path.nil? || path.empty?\n return Wgit::Url.new('/') if path == '/'\n\n Wgit::Url.new(path).omit_slashes\n end",
"def to_path\n path = @uri.path\n return nil if path.nil? || path.empty?\n return Wgit::Url.new('/') if path == '/'\n\n Wgit::Url.new(path).without_slashes\n end",
"def uri\n if host && !request_uri.host\n request_uri.dup.tap do |uri|\n uri.scheme = 'http'\n uri.host = host\n end\n else\n request_uri\n end\n end"
] | [
"0.7023173",
"0.6625796",
"0.6445636",
"0.64266497",
"0.6417377",
"0.6405865",
"0.6373918",
"0.63606936",
"0.63118374",
"0.63118374",
"0.6306402",
"0.6302526",
"0.6259779",
"0.6248994",
"0.6248994",
"0.6232",
"0.6230305",
"0.6230159",
"0.6207951",
"0.61928755",
"0.6176924",
"0.6152748",
"0.6142795",
"0.6142359",
"0.61037093",
"0.6092264",
"0.6081238",
"0.60516644",
"0.60516644",
"0.60504586",
"0.6038212",
"0.60348576",
"0.601794",
"0.601794",
"0.60157657",
"0.60121614",
"0.6011202",
"0.5995412",
"0.5991418",
"0.598617",
"0.598617",
"0.5976113",
"0.5976113",
"0.59645224",
"0.59626263",
"0.59540117",
"0.59494287",
"0.59484726",
"0.5923456",
"0.59194666",
"0.59194666",
"0.58947814",
"0.5875557",
"0.5875343",
"0.587397",
"0.5872401",
"0.58678395",
"0.5866459",
"0.5863678",
"0.5855791",
"0.5834156",
"0.5834156",
"0.582921",
"0.58008814",
"0.57964575",
"0.57928014",
"0.57782763",
"0.57735103",
"0.57704014",
"0.57657814",
"0.5755928",
"0.57515144",
"0.5748404",
"0.5735087",
"0.5723382",
"0.5721751",
"0.5718611",
"0.57141584",
"0.57141584",
"0.57114524",
"0.5709831",
"0.5709831",
"0.5695898",
"0.56929725",
"0.56929725",
"0.5689084",
"0.5679517",
"0.5662633",
"0.5662633",
"0.5662633",
"0.5656896",
"0.5656896",
"0.56520677",
"0.56409204",
"0.56273997",
"0.5626682",
"0.56121504",
"0.56078875",
"0.5605681",
"0.5585106",
"0.5563782"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.