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 |
---|---|---|---|---|---|---|
Use callbacks to share common setup or constraints between actions. | def set_product_claim
@product_claim = ProductClaim.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def product_claim_params
params.require(:product_claim).permit(:user_id, :supermarket, :category, :brand, :description, :abf, :organic, :grassfed, :never, :humane, :promo, :expiration_date, :image, :price)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
Part 1: Access multiple elements of a nested array Pseudocode Initial Solution Refactored Solution DRIVER TESTS GO BELOW THIS LINE Reflection Part 2: Write a method that takes a row number and returns all the elements in the row. Pseudocode DEFINE method get_row with two ARGUMENTS board, row RETURN ELEMENT row1 of board Initial Solution | def get_row(board,row)
board[row-1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_row(row,board)\n return board[row] \nend",
"def get_row(row,board) # row(x,*y)\n\tboard[row]\nend",
"def get_row(board, row)\n board[row]\nend",
"def get_row(board, row)\n board[row]\nend",
"def get_row(board, row)\n return board[row]\nend",
"def get_row_elements(row)\n @cells[row]\n end",
"def get_row(board, row)\n\tboard[row]\nend",
"def get_row(board, row)\n\treturn board[row]\nend",
"def get_row(board,row)\n\treturn board[row]\nend",
"def get_row(row)\n boggle_board =[[\"b\", \"r\", \"a\", \"e\"],\n [\"i\", \"o\", \"d\", \"t\"],\n [\"e\", \"c\", \"l\", \"r\"],\n [\"t\", \"a\", \"k\", \"e\"]]\n boggle_board[row]\nend",
"def get_row(row)\n boggle_board = [[\"b\", \"r\", \"a\", \"e\"],\n [\"i\", \"o\", \"d\", \"t\"],\n [\"e\", \"c\", \"l\", \"r\"],\n [\"t\", \"a\", \"k\", \"e\"]]\n boggle_board[row]\n # your code here\nend",
"def get_row(row)\n\tboggle_board = [[\"b\", \"r\", \"a\", \"e\"],\n [\"i\", \"o\", \"d\", \"t\"],\n [\"e\", \"c\", \"l\", \"r\"],\n [\"t\", \"a\", \"k\", \"e\"]]\n puts \"#{boggle_board[row]}\"\nend",
"def get_row(row)\n board = $boggle_board\n return board[row]\nend",
"def get_row(board, row_number)\n board[row_number-1]\nend",
"def get_row_cells row\n\t\treturn (row * 9...row * 9 + 9).to_a\n\tend",
"def get_row(game,row)\n return game[row]\nend",
"def get_row(game,row)\n return game[row]\nend",
"def board_row_values(board, row_number)\n start_value = row_number == 1 ? 0 : (row_number * BOARD_WIDTH) - BOARD_WIDTH\n board.values.slice(start_value, BOARD_WIDTH)\nend",
"def get_row(row)\n row = $boggle_board[row]\nend",
"def get_row(matrix, row)\n matrix[row].select { |n| !n.nil? }\nend",
"def get_row(row)\n\tboggle_board = [[\"b\", \"r\", \"a\", \"e\"],\n [\"i\", \"o\", \"d\", \"t\"],\n [\"e\", \"c\", \"l\", \"r\"],\n [\"t\", \"a\", \"k\", \"e\"]]\n\treturn boggle_board[row]\nend",
"def [](i, j)\n # @rows[i][j] # Maglev, fix ruby_bug \"#1518\", \"1.9.1.129\"\n elem = @rows[i]\n unless elem._equal?(nil)\n elem = elem[j]\n end\n elem\n end",
"def row_for(p, r)\n if p <= 1\n cell(0)\n elsif p.odd?\n if r == p - 1\n row(p)\n else\n row_for(p - 1, r)\n col(p, r)\n end\n else\n if r == 0\n row(p)\n else\n col(p, r)\n row_for(p - 1, r - 1)\n end\n end\n end",
"def nest_array(board)\n nested_board = []\n 9.times { nested_board << board.slice!(0..8)}\n return nested_board\nend",
"def [](i,j)\n return @rows[i][j]\n end",
"def get_row(row)\n $boggle_board[row]\nend",
"def get_array_by_row()\n\t\tprepare(@dim_i,@dim_j)\n\t\treturn @myTab\n\tend",
"def get_col(board, col)\n \n col_array = []\n board.each do |row|\n col_array << row[col]\n end\n col_array\nend",
"def get_row_contents(row)\n @board.slice(row*9,9)\n end",
"def get_row(row_num)\n @grid[row_num]\n end",
"def _get_board_rows()\n array_of_rows = []\n sudoku_board.each { |row| array_of_rows << row }\n end",
"def board\n board_arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n p board_arr[0]\n p board_arr[1]\n p board_arr[2]\nend",
"def get_row(row) # defines get_row\n @boggle_board.fetch(row) {|row| puts \"#{row}\"}.join(\"\") # fetches the elements of each row and joins it together as one string.\nend",
"def [] x, y\r\n @rows[y][x]\r\n end",
"def rows\n @array\n end",
"def row(p)\n x = p * (p - 1)\n y = x + p - 1\n x.upto(y) {|i| cell(p.odd? ? x - i + y : i) }\n end",
"def get_row(row)\n\t$boggle_board[row]\nend",
"def row_elems(x)\n return @grid[x] unless block_given?\n @grid[x].each do |g|\n yield g\n end\n end",
"def row(r)\n return matrix[r].map{|e| e.dup}\n end",
"def get_row(index)\n @board[index]\n end",
"def get_row(row)\n @boggle_board[row]\n end",
"def [](pos) #pos = [1,2]\n # x, y = pos\n x = pos[0]\n y = pos[1]\n @rows[x][y] \n end",
"def [](row, col)\n #convert row values by * by 9\n @grid[row * 9 + col]\n end",
"def get_row(row)\n validate_pos(row, 0)\n\n row_arr = @fm[row*@cols ... (row+1)*@cols]\n return FMatrix.new([row_arr])\n end",
"def [](row,col)\n case col\n when 0...81\n @row_column[row][col]\n when 81...162\n @row_number[row][col - 81]\n when 162...243\n @column_number[row][col - 162]\n when 243...324\n @box_number[row][col - 243]\n else\n nil\n end\n end",
"def print_out_row_v1(board, number)\n\n\t\trow_array = []\n\n\t\tl = number - 1\n\n\t\tchoosen_row = board[l]\n\t\tprint choosen_row\n\t\tputs\n\t\treturn choosen_row\n\tend",
"def spiral_access(arrays, iteration=0, &block)\n y_max = arrays.length - 1\n x_max = arrays.first.length - 1\n\n # base step\n return if y_max/2 < iteration || x_max/2 < iteration\n\n # top row\n # 1st Pass: 0.upto(4) do\n iteration.upto x_max-iteration do |x|\n # 1st Pass(1): arrays[0][0]\n # 1st Pass(2): arrays[0][1]\n # 1st Pass(3): arrays[0][2]\n # 1st Pass(4): arrays[0][3]\n # 1st Pass(5): arrays[0][4]\n block.call arrays[iteration][x]\n end\n\n # right column\n # 1st Pass: 1.upto(4) do\n (iteration + 1).upto y_max-iteration do |y|\n # 1st Pass(1): arrays[1][4]\n # 1st Pass(1): arrays[2][4]\n # 1st Pass(1): arrays[3][4]\n # 1st Pass(1): arrays[4][4]\n block.call arrays[y][x_max-iteration]\n end\n\n # bottom row\n # 1st Pass: 3.downto(0) do\n (x_max - 1 - iteration).downto iteration do |x|\n # 1st Pass(1): arrays[4][3]\n # 1st Pass(1): arrays[4][2]\n # 1st Pass(1): arrays[4][1]\n # 1st Pass(1): arrays[4][0]\n block.call arrays[y_max-iteration][x]\n end\n\n # left column\n # 1st Pass: 3.downto(1) do\n (y_max - 1 - iteration).downto iteration+1 do |y|\n # 1st Pass(1): arrays[3][0]\n # 1st Pass(1): arrays[2][0]\n # 1st Pass(1): arrays[1][0]\n block.call arrays[y][iteration]\n end\n\n # recursive step\n # 1st Pass: spiral_access arrays, 1\n spiral_access arrays, iteration+1, &block\n end",
"def create_row(r)\n row = Array.new\n self.board.each { |a|\n row << a[r]\n }\n row\n end",
"def square_arrays\n squares = []\n org_row = 0\n org_col = 0\n (0..8).each do |i|\n squares[i] = []\n (org_row..org_row+2).each do |k|\n (org_col..org_col+2).each do |j|\n squares[i].push(@board[k][j])\n end \n end\n if org_row == 6\n org_col += 3 \n org_row = 0\n else\n org_row += 3 \n end\n end \n squares\n end",
"def get_row(n)\n\t\tprepare(@dim_i,@dim_j)\n\t\treturn @myTab[n]\n\tend",
"def repeat_in_row(row)\n sub_sudoku = @sudoku[row*@width..(row+1)*@width-1].split(\"\").map{|element| element.to_i}\n result = []\n @width.times do |col|\n if sub_sudoku.count(col+1) > 1\n sub_sudoku.each_with_index do |element, index|\n result << row*@width + index if element == col+1\n end\n return result\n end\n end\n nil\n end",
"def by_row(arr)\n rows = (0..5).reduce([]) do |r, i| \n r.push(arr.map { |column| column[i] })\n r\n end\n rows.select { |row| row.size > 3}\n determine_winner(rows)\nend",
"def [](row, column)\n\t\treturn nil unless row.between?(0, @rows-1)\n\t\treturn nil unless column.between?(0, @columns-1)\n\t\t@grid[row][column]\n\tend",
"def [](row, col)\n @grid[row][col]\n end",
"def get_cells(rows, columns)\n cells = []\n rows.each do |r|\n columns.each do |c|\n cells << @fields[r][c]\n end\n end\n cells\n end",
"def get2d_many(rows, cols)\n case rows\n when Fixnum\n case cols\n when Fixnum\n RAtlas::get2d_one(@storage, rows, cols)\n when Array\n self.class.new RAtlas::get2d_many(\n @storage, [rows], cols)\n when Range\n self.class.new RAtlas::get2d_by_range(\n @storage, Range.new(rows, rows), cols)\n end\n when Range\n case cols\n when Range\n self.class.new RAtlas::get2d_by_range(\n @storage, rows, cols)\n when Array\n rows = range2arr(rows, size[0])\n self.class.new RAtlas::get2d_many(\n @storage, rows, cols)\n when Fixnum\n self.class.new RAtlas::get2d_by_range(\n @storage, rows, Range.new(cols, cols))\n end\n when Array\n case cols\n when Range\n cols = range2arr(cols, size[1])\n self.class.new RAtlas::get2d_many(\n @storage, rows, cols)\n when Array\n self.class.new RAtlas::get2d_many(\n @storage, rows, cols)\n when Fixnum\n self.class.new RAtlas::get2d_many(\n @storage, rows, [cols])\n end\n end\n\n end",
"def cell_rows\n cells = []\n\n # for each row\n 1.upto(3).each do |row|\n rows = []\n # for each column\n 1.upto(3).each do |column|\n rows << get_cell_value(row, column)\n end\n\n cells << rows\n end\n\n cells\n end",
"def other_way(matrix)\n result = []\n (0..2).each do |column_index|\n new_row = (0..2).map {|row_index| matrix[row_index][column_index]}\n result << new_row\n end\n result\nend",
"def row(i) # :yield: e\n if block_given?\n for e in @rows[i]\n yield e\n end\n else\n Vector.elements(@rows[i])\n end\n end",
"def get_element_at column, row\n raise OutOfRangeError if column >= @data.size || row >= @data.size\n @data[column] * @data[row]\n end",
"def traverse_grid(rows, cols, dead_zones, paths)\n paths ||= Array.new(rows) {Array.new(cols)}\n\n #recursive step\n return traverse_grid(rows-1, cols) || traverse_grid(rows, cols-1)\nend",
"def [](pos)\n x, y = pos\n @rows[x][y]\n end",
"def get_diagonal_elements(row, column)\n queried_diagonals = [1,-1].each_with_object([]) do |slope, diagonals|\n diagonal = get_points(column, row, slope).each_with_object([]) do |point, elements|\n elements << @cells[point[1]][point[0]]\n end\n\n diagonals << diagonal\n end\n\n queried_diagonals.reject {|diagonal| diagonal.size == 1 }\n end",
"def get_row(quilt_board, board_rows)\n\t\t# Get a list of which colors are used in each row\n\t\tcolumns, quilt_board = get_list_of_column_numbers(quilt_board)\n\t\t# Narrow down the options to only valid rows\n\t\tget_current_options(columns, quilt_board, board_rows)\n\t\t# Return false if there are no options left\n\t\treturn false, quilt_board, @current_options.length if @current_options.empty? \n\t\t# Return the potential row if it exists, trimming the row if a fraction of a square is needed\n\t\treturn @current_options.sample[0..(board_rows-1)], quilt_board, @current_options.length\n\tend",
"def spiral_access(arr, &block)\n #count how many rows = e.g. length of first\n if arr.length > 1\n rows = arr.length - 1\n columns = arr[0].length - 1\n #puts rows, columns\n #count how many columns, e.g. in the first array\n #create a placeholder\n var_arr = []\n #first go across the top\n var_arr= arr[0]\n var_arr.each {|nr| block.call(nr)}\n # then take the last element in each array\n (1..(columns-1)).each do |x|\n var_arr = arr[x]\n block.call(var_arr.delete_at(columns))\n end\n #then go reverse along the last array\n var_arr = arr.delete_at(-1).reverse\n var_arr.each {|nr| block.call(nr)}\n #puts var_arr.join(' ')\n #then take the first elements up till n2\n (columns-1).downto(1) do |x|\n var_arr = arr[x]\n #puts var_arr.join(' ')\n block.call(var_arr.delete_at(0))\n end\n arr.delete_at(0)\n #puts arr.join(' ')\n spiral_access(arr,&block)\n elsif arr.length == 1\n arr[0].any? ? block.call(arr[0][0]) : arr[0]\n else\n arr\n\n end\n\n #then call it again for the rest\nend",
"def getCell(row,col)\n the_row = @rows[row]\n the_cell = the_row.cells[col]\n return the_cell\n end",
"def rows\n shape[0]\n end",
"def get\n return [@row, @col]\n end",
"def row_cells\n rowdata = []\n print_layout.each do |section|\n rowdata += row_cell_items(section[:row_cells])\n end\n rowdata\n end",
"def get_col(board, col)\n board.map {|x| x[col]}\nend",
"def rows\n return @rows if @rows\n @item_table = [[]]\n @rows = [[[]]]\n filled_columns = 0\n filled_rows = 0\n row_items = 0\n\n skips = []\n items.each do |item|\n\n skips.delete_if do |row_span, skip_cols_at, skip_cols_length|\n next true if row_span == 1\n if skip_cols_length > 0 and filled_columns == skip_cols_at\n filled_columns += skip_cols_length\n skip_cols_length.times do\n @item_table[filled_rows] << nil\n @rows[filled_rows][row_items] << nil\n end\n if filled_columns >= columns and item != items.last\n filled_rows += 1\n filled_columns = 0\n row_items = 0\n @rows << [[]]\n @item_table << []\n skips.map! do |new_row_span, new_skip_cols_at, new_skip_cols_length|\n [new_row_span - 1, new_skip_cols_at, new_skip_cols_length]\n end\n end\n if filled_columns != 0 and item != items.last\n row_items += 1\n @rows[filled_rows] << []\n end\n next row_span - 1 == 1\n end\n end\n\n if item.is_a?(Text) || !([:check_box, :radio, :scale].include? item.type)\n if item.row_span > 1\n skips << [item.row_span, filled_columns, item.col_span]\n end\n\n @item_table[filled_rows] << item\n @rows[filled_rows][row_items] << item\n filled_columns += item.col_span\n\n if filled_columns >= columns and item != items.last\n filled_rows += 1\n filled_columns = 0\n row_items = 0\n @rows << [[]]\n @item_table << []\n end\n if filled_columns != 0 and item != items.last\n row_items += 1\n @rows[filled_rows] << []\n end\n\n else # is :check_box, :radio or :scale question\n if item.row_span > 1\n skips << [item.row_span, filled_columns, item.options.length]\n end\n\n @item_table[filled_rows] << item\n if item.options.length <= columns # multiple questions on one row\n item.options.each do |opt|\n @rows[filled_rows][row_items] << opt\n filled_columns += 1\n\n if filled_columns >= columns and item != items.last\n filled_rows += 1\n filled_columns = 0\n row_items = 0\n @rows << [[]]\n @item_table << []\n end\n end\n if filled_columns != 0 and item != items.last\n row_items += 1\n @rows[filled_rows] << []\n end\n else # one question's options split over multiple rows, ordered row wise\n opt_len = item.options.length\n col_len = (opt_len / columns.to_f).ceil\n (0...col_len).each do |j|\n (0...columns).each do |i|\n break if j + i * col_len >= opt_len\n @rows[filled_rows][row_items] << item.options[j + i * col_len]\n filled_columns += 1\n if filled_columns == columns\n filled_rows += 1\n filled_columns = 0\n @rows << [[]]\n @item_table << [item]\n end\n end\n end\n end\n end\n end\n @rows\n end",
"def rows\n rows_and_cols.first\n end",
"def getColumn arr, col\n arr2 = [] \n for row in arr do\n arr2.push row[col]\n end \n return arr2\nend",
"def get_col(col)\n\tcol_array = []\n\t$boggle_board.length.times do |row|\n\t\tcol_array << $boggle_board[row][col]\n\t\trow+=1\n\tend\n\tcol_array\nend",
"def [](row, column)\n puzzle[row][column]\n end",
"def find(num)\n $pre_grid.each_with_index do |row,row_i|\n row.each_with_index do |e,e_i|\n i = [ row_i, e_i ]\n # special case for finding second 1\n if e.to_i == num && i != $first1\n return i\n end\n end\n end\nend",
"def rows\n @rows ||= begin\n row_indexes.map do |e|\n e.map do |e|\n @input[e]\n end\n end\n end\n end",
"def [](pos)\n row, col = pos\n @rows[row][col]\n end",
"def getSumsByRow(tri, row)\n\t#for every element in current line\n\tfor i in 0..tri[row].length-1\n\t\t#add to the lagest of the child nodes\n\t\ttri[row][i] += [tri[row+1][i], tri[row+1][i+1]].max\n\tend\n\t#if the row only has one element\n\tif tri[row].length == 1\n\t\t#return it\n\t\treturn tri[row][0]\n\telse\n\t\t#or else recurse \n\t\treturn getSumsByRow(tri, row-1)\n\tend\nend",
"def solve(puzzle, row, column = 0)\n return puzzle.flatten if column == 4\n return nil if permissible_values(puzzle, row, column).empty?\n p \"puzzle: #{puzzle}\"\n p \"row: #{row}\"\n p \"column: #{column}\"\n blank_puzzle.each { |i_in_row|\n i_in_row.each { |i_in_column|\n permissible_values(puzzle, i_in_row, i_in_column).map do |value|\n solve(update_puzzle(puzzle.dup, value, row, column), row, column + 1)\n end\n }\n }\nend",
"def getArrayIndex(row, col)\n index = 0\n case row\n when '1'\n if col == 'A'\n index = 0\n elsif col == 'D'\n index = 1\n else index = 2\n end\n when '2'\n if col == 'B'\n index = 3\n elsif col == 'D'\n index = 4\n else index = 5\n end\n when '3'\n if col == 'C'\n index = 6\n elsif col == 'D'\n index = 7\n else index = 8\n end\n when '4'\n if col == 'A'\n index = 9\n elsif col == 'B'\n index = 10\n elsif col == 'C'\n index = 11\n elsif col == 'E'\n index = 12\n elsif col == 'F'\n index = 13\n else index = 14\n end\n when '5'\n if col == 'C'\n index = 15\n elsif col == 'D'\n index = 16\n else\n index = 17\n end\n when '6'\n if col == 'B'\n index = 18\n elsif col == 'D'\n index = 19\n else\n index = 20\n end\n when '7'\n if col == 'A'\n index = 21\n elsif col == 'D'\n index = 22\n else\n index = 23\n end\n end\n return index\n end",
"def triangle_recursive(row)\n if row == 0\n return [1]\n else\n previous_row = triangle_recursive(row-1)\n return compute_row(previous_row)\n end\nend",
"def getvalue(row, column)\n rows[row][column]\n end",
"def row(index)\n end",
"def find_row(temp)\n array_row = 0\n rows = [1, 3, 5, 7, 9, 11]\n rows.each do |row|\n unless @display[row][temp..(temp + 4)] != '37;49'\n array_row = row\n end\n end\n array_row\n end",
"def spiral_access(arrs, iteration = 0, &block)\n maxY = arrs.length - 1\n maxX = arrs.first.length - 1\n \n return if maxY/2 < iteration || maxX/2 < iteration\n \n # top row\n iteration.upto maxX-iteration do |x|\n block.call arrs[iteration][x]\n end\n\n # right column\n (iteration + 1).upto maxY-iteration do |y|\n block.call arrs[y][maxX-iteration]\n end\n\n # bottom row\n (maxX - 1 - iteration).downto iteration do |x|\n block.call arrays[maxY-iteration][x]\n end\n\n # left column\n (maxY - 1 - iteration).downto iteration+1 do |y|\n block.call arrays[y][iteration]\n end\n\n spiral_access arrs, iteration+1, &block\n \nend",
"def get_col(board,col)\n\tboard.map { |row| row[col] }\nend",
"def get_col(col)\n boggle_board = [\n\t \t\t\t\t[\"b\", \"r\", \"a\", \"e\"],\n\t [\"i\", \"o\", \"d\", \"t\"],\n\t [\"e\", \"c\", \"l\", \"r\"],\n\t [\"t\", \"a\", \"k\", \"e\"]\n\t \t\t\t\t\t\t\t]\ncol_arr = []\nrow_num = boggle_board.length\nrow_num.times do |row| \n\tcol_arr << boggle_board[row][col-1]\n\trow+=1\n end\ncol_arr\nend",
"def row; end",
"def display_board(board)\n #Do stuff fool \n puts build_row(board[0..2])\n print_separator\n puts build_row(board[3..5])\n print_separator\n puts build_row(board[6..8])\nend",
"def row_at(row_idx)\n @grid[row_idx]\n end",
"def validate_grid(array, element, row, column, array2)\n row = row - 1\n column = column - 1\n set_flag_row = validate_row(array, element, row)\n print \"\\n Row =>#{set_flag_row} \" #1 element found row\n set_flag_column = validate_column(array, element, column)\n print \"\\n Column => #{set_flag_column} \" #1 element found in column\n set_flag_grid = validate_matrix(array, element, row, column)\n print \"\\n Grid =>#{set_flag_grid} \"\n set_flag_state = validate_state(array, row, column, array2)\n print \"\\n state =>#{set_flag_state}\\n\"\nend",
"def grid_row_items\n # noinspection RubyMismatchedReturnType\n row_items\n end",
"def grid_row_items\n # noinspection RubyMismatchedReturnType\n row_items\n end",
"def matrix_find(row, column)\n self[row*9 + column]\n end",
"def find_answer(row , board, queens)\r\n open = board.check_open(row)\r\n\r\n if open.empty?\r\n #if there are no solutions here, so this doesn't work\r\n return []\r\n\r\n elsif row == 7 and queens.size() < 7\r\n #if we're at the last row, but don't have enough queens\r\n return []\r\n\r\n elsif row == 7 and queens.size() == 7 and open.size < 1\r\n # we're at the last row with no solution\r\n return []\r\n\r\n elsif row == 7 and queens.size() == 7 and open.size() == 1\r\n # we're at the last row, and we have a final solution\r\n\r\n # Creates a new board for us to use recursively\r\n new_board1 = Board.new\r\n queens.each do | coords |\r\n new_board1.set_closed(coords[0], coords[1])\r\n end\r\n new_board1.set_closed(open[0], row)\r\n new_board1.set_solution\r\n\r\n #creates the final array of coordinates the queens are at\r\n final = queens.push([open[0], row])\r\n\r\n $solutions_array.push(final)\r\n $solutions_boards.push(new_board1)\r\n\r\n return final\r\n\r\n else # we're not at last row, and we still have a solution to try from open\r\n\r\n open.each do | spot |\r\n new_board = Board.new\r\n\r\n queens.each do | coords |\r\n new_board.set_closed(coords[0], coords[1])\r\n end\r\n new_board.set_closed(spot, row)\r\n\r\n new_queens = Array.new\r\n new_queens.concat(queens)\r\n new_queens.push([spot, row])\r\n\r\n new_row = row + 1\r\n\r\n find_answer(new_row, new_board, new_queens)\r\n end\r\n end\r\nend",
"def [](pos)\n raise \"pos not on board\" unless on_board?(pos)\n i, j = pos\n @rows[i][j]\n end",
"def get_col(board, col)\n column = []\n board.each_with_index { |obj,i| column.push(board[i][col])}\n return column\nend",
"def board_2d\n # slice the array into groups of 4 to create 2d-array\n @board.enum_slice(4).to_a\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"
] | [
"0.71235335",
"0.7123354",
"0.71073055",
"0.71073055",
"0.7076405",
"0.6891618",
"0.68278486",
"0.67934525",
"0.67889214",
"0.67508507",
"0.67004585",
"0.64379793",
"0.6395111",
"0.6376297",
"0.6356874",
"0.6324448",
"0.6324448",
"0.6207936",
"0.6201748",
"0.6181573",
"0.61731",
"0.6136112",
"0.61257994",
"0.61244154",
"0.60813254",
"0.60725236",
"0.6054785",
"0.6051062",
"0.6047837",
"0.6030196",
"0.59842455",
"0.59661466",
"0.5942558",
"0.5917812",
"0.58955914",
"0.5878639",
"0.5872605",
"0.5871824",
"0.5862094",
"0.58588797",
"0.58469665",
"0.5825788",
"0.58227956",
"0.5807606",
"0.579601",
"0.5788597",
"0.576328",
"0.5752777",
"0.5738564",
"0.5730073",
"0.5729262",
"0.5726657",
"0.5726583",
"0.57071584",
"0.5665791",
"0.5655549",
"0.56491864",
"0.56485087",
"0.5630583",
"0.56268966",
"0.5621406",
"0.56163603",
"0.56151396",
"0.5609677",
"0.56088185",
"0.5594288",
"0.5582629",
"0.55774117",
"0.556828",
"0.556181",
"0.5553526",
"0.55515116",
"0.553837",
"0.5529261",
"0.5523873",
"0.55220586",
"0.5516065",
"0.5513642",
"0.551081",
"0.55049956",
"0.5500954",
"0.5497675",
"0.54843843",
"0.54826164",
"0.54799193",
"0.54775715",
"0.5476126",
"0.54701924",
"0.54639715",
"0.5462315",
"0.5457273",
"0.54572636",
"0.5449391",
"0.5449391",
"0.5446138",
"0.54461247",
"0.54415417",
"0.5439922",
"0.5439506",
"0.5437787"
] | 0.63405126 | 15 |
Use inside def initialize, to get object id | def init
super_init
@defaults = OSX::NSUserDefaults.standardUserDefaults
register_defaults_for_inbox('~/Movies/iTunes-inbox') # Note: The directory for the box
# will not be created until the program is actually run, so the user can change inbox location in the preferences.
register_defaults_for_processed( Pathstring.new(@defaults.objectForKey(:inbox)).parent / 'iTunes-processed' ) # This is the location
# of directories for files that has been processed, converted, failed, etc. Must be on the same volume!
return self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_id() end",
"def __id; @id || @obj.id; end",
"def id() end",
"def id\n object_id\n end",
"def id\n __id\n end",
"def id\n object.object_id\n end",
"def id\n object.id\n end",
"def id\n object.id\n end",
"def id()\n #This is a stub, used for indexing\n end",
"def object_id\n object.object_id\n end",
"def id=(_arg0); end",
"def id=(_arg0); end",
"def id=(_arg0); end",
"def get_object_id object\n object.respond_to?(:id) ? object.id : object\n end",
"def initialize(id) @id = id; end",
"def initialize(id) @id = id; end",
"def __id__() end",
"def getId()\n @obj.getId()\n end",
"def _id\n @id\n end",
"def id\n object.id.to_i\n end",
"def id; 1; end",
"def __object_unique_id__\n name\n end",
"def __object_unique_id__\n name\n end",
"def initialize(id)\n self.id = id\n end",
"def id\n object[\"id\"]\n end",
"def id\n object.to_param\n end",
"def oid\n id(get_oid())\n end",
"def get_id()\n @id\n end",
"def get_id()\n @id\n end",
"def objname\n id\n end",
"def id\n @obj['id']\n end",
"def get_id\n\t\treturn id\n\tend",
"def id\n object.id.to_s\n end",
"def initialize\n @id = {}\n end",
"def id; 1; end",
"def id\n return unless class_variable_defined? :@@id\n class_variable_get :@@id\n end",
"def get_id()\n return @id\n end",
"def initialize(id); end",
"def id\n _id rescue nil\n end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def initialize(obj)\n self.class_name = obj.class.to_s\n self.obj_id = obj.id.to_s\n end",
"def id\n `$q(this.__native__.id||nil)`\n end",
"def getId()\n\t\t\treturn @_id\n\t\tend",
"def id\n raise Errno::ENOENT, \"This object has been deleted.\" if self.deleted?\n raise \"No ID on object.\" if !@id\n return @id\n end",
"def initialize pid = nil\n @id = pid\n end",
"def get_id\n @id\n end",
"def get_id\n @id\n end",
"def get_id\n @id\n end",
"def get_id\n @id\n end",
"def real_id\n @id\n end",
"def real_id\n @id\n end",
"def __object_unique_id__\n return 0 if self.deleted?\n return self.id\n end",
"def get_id()\n return @id\n end",
"def initialize (id)\n @id = id\n end",
"def initialize(id)\n\t\t@id = id\n\tend",
"def id\n @id || self.class.name.underscore.split('/').last #gsub('/', '_')\n end",
"def as_id(object)\n object.kind_of?(PublicEarth::Db::Base) && object.id || object\n end",
"def initialize(id)\n @id = id\n end",
"def id ; @record.id if @record ; end",
"def id\n #NOOP\n end",
"def sobject_id\n sobject.id\n end",
"def id\n @id_number = 12345\n end",
"def id\n return @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def record_id(object)\n #eval \"object.#{object.class.primary_key}\"\n object.id\n end",
"def id\n @instance.id\n end",
"def get_id(obj)\n\t\t@objects.invert[obj]\n\tend",
"def objet_id\n @objet_id ||= begin\n if objet.nil?\n nil\n else\n objet_hash? ? objet[:id] : objet.id\n end\n end\n end",
"def initialize(id)\n self.id = id\n end",
"def identify(id)\n @id = id\n end",
"def get_object_id(object, object_id = nil)\n check_object(object)\n object_id ||= object[:objectID] || object['objectID']\n raise Algolia::AlgoliaError, \"Missing 'objectID'\" if object_id.nil?\n object_id\n end",
"def id\n object.external_id\n end",
"def __object_unique_id__\n return @args[:data][:Key_name]\n end",
"def id\n self[:identifier]\n end",
"def initialize(id: nil)\n super()\n @id = id\n end",
"def initialize_id\n if @id.blank?\n @id = \"\"\n else\n @id = @id.to_i\n end\n end",
"def id\n self[:id]\n end",
"def id\n self[:id]\n end",
"def id_number; end",
"def local_id; end",
"def id\n @id\n end",
"def initialize(params={})\n super params\n\n # self._id = self.properties[:uuid]\n\n end",
"def getId\n return @id\n end",
"def id\r\n @id\r\n end",
"def id\n @id ||= Time.now.utc.to_i\n end",
"def initialize tid = nil\n @id = tid\n end",
"def id_from_hash\n return @id_from_hash if defined?(@id_from_hash)\n @id_from_hash = __getobj__[:id] || __getobj__[\"id\"]\n end"
] | [
"0.81858164",
"0.80553377",
"0.7697184",
"0.7509359",
"0.7491644",
"0.7459179",
"0.742805",
"0.742805",
"0.74157655",
"0.7405285",
"0.74028724",
"0.74028724",
"0.74028724",
"0.73997164",
"0.7394876",
"0.7394876",
"0.73676115",
"0.7360355",
"0.73227686",
"0.73221153",
"0.7264175",
"0.7215534",
"0.7215534",
"0.71976817",
"0.71780944",
"0.7165527",
"0.71512395",
"0.7138413",
"0.7138413",
"0.7136056",
"0.71242094",
"0.7111987",
"0.71048844",
"0.7100054",
"0.70812446",
"0.70713574",
"0.7060154",
"0.70580244",
"0.7051768",
"0.70378333",
"0.70378333",
"0.70378333",
"0.70378333",
"0.70378333",
"0.70378333",
"0.70378333",
"0.70378333",
"0.70378333",
"0.70378333",
"0.70378333",
"0.70378333",
"0.70342344",
"0.7007404",
"0.70011234",
"0.69827914",
"0.6980243",
"0.69720984",
"0.69720984",
"0.69720984",
"0.69720984",
"0.69379723",
"0.69379723",
"0.692694",
"0.69252795",
"0.6907263",
"0.6902924",
"0.6897785",
"0.6897047",
"0.68943435",
"0.6880584",
"0.68648195",
"0.6857799",
"0.6856407",
"0.68313956",
"0.68304336",
"0.68304336",
"0.68304336",
"0.68304336",
"0.6825148",
"0.6825095",
"0.68156266",
"0.68140084",
"0.6809848",
"0.67989165",
"0.6795637",
"0.6779623",
"0.6778573",
"0.6777957",
"0.6777546",
"0.677194",
"0.6749447",
"0.6739194",
"0.673875",
"0.67377216",
"0.67374",
"0.6734011",
"0.6727651",
"0.6725502",
"0.6713692",
"0.67102665",
"0.6704056"
] | 0.0 | -1 |
Checks that inbox and processed directories are on the same volume (since we want to be able to move these big files, not copy them) Potential BUG: What happens if I want to move both to a diffent volume. Maybe there should be a method for moving both at the same time..? | def register_defaults_for_processed(target_dir)
if Pathstring.new(inbox).volume == Pathstring.new(target_dir).volume then
@defaults.registerDefaults(:processed => Pathstring.new(target_dir) )
else
raise "Both inbox and processed directories must be on same volume."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync!\n\n destfiles = begin \n FsShellProxy.new.ls(@dest, true) \n rescue NoSuchFile \n {}\n end\n results = HSync::compare(LocalFs.new.ls(@source, true), destfiles)\n push_files(results.files_missing_in_b)\n # push_files(results.files_newer_in_a) # todo\n end",
"def move_files\n source_dir = Item.new(Path.new(params[:source]))\n dest_dir = Item.new(Path.new(params[:dest]))\n type = params[:type]\n response = {}\n response[:source_dir] = source_dir\n response[:dest_dir] = dest_dir\n if source_dir.move_files_to(dest_dir, type)\n response[:msg] = \"Success\"\n render json: response, status: 200\n else\n response[:msg] = \"Fail\"\n render json: response, status: 402\n end\n end",
"def move_dirs\n \n end",
"def user_move(from, to)\n\t# If FROM peg is empty, there is no disk to move. Display error \n\t# message.\n\tif $pegs[from].count == 0\n\t\tputs \"That peg is empty, please choose a different peg!\"\n\t# If the disk the user is trying to move is larger than the disk on \n\t# the TO peg, don't allow the move. Display invalid move message.\n\telsif ($pegs[to].count != 0) && ($pegs[from].last > $pegs[to].last)\n\t\tputs \"That is an invalid move. Please try again.\"\n\t# If move is valid, pop FROM peg and push disk to the TO peg.\n\telse\n\t\t$pegs[to] << $pegs[from].pop\n\tend\nend",
"def move\n file = session[:user].x_files.get(params[:id])\n raise RequestError.new(:file_not_found, \"File not found\") unless file\n raise RequestError.new(:bad_param, \"File not uploaded\") if !file.folder && !file.uploaded\n raise RequestError.new(:bad_param, \"Can not move the root folder\") if file.id == session[:user].root_folder.id\n source = WFolder.get(params[:source])\n raise RequestError.new(:file_not_found, \"Source not found\") unless source\n raise RequestError.new(:bad_param, \"Source is not a folder\") unless source.folder\n raise RequestError.new(:bad_access, \"No access to the source folder\") unless source.users.include? session[:user] \n raise RequestError.new(:bad_param, \"Source does not contain the file\") if source.files.include? file == false && !file.folder\n raise RequestError.new(:bad_param, \"Source does not contain the folder\") if source.childrens.include? file && file.folder\n destination = WFolder.get(params[:destination])\n raise RequestError.new(:file_not_found, \"Destination not found\") unless destination\n raise RequestError.new(:bad_param, \"Destination is not a folder\") unless destination.folder\n raise RequestError.new(:bad_access, \"No access to the destination folder\") unless destination.users.include? session[:user] \n raise RequestError.new(:bad_param, \"Destination and Source are identical\") if source.id == destination.id\n raise RequestError.new(:bad_param, \"Destination and File are identical\") if file.id == destination.id\n raise RequestError.new(:bad_param, \"File and Source are identical\") if source.id == file.id\n\n WFile.move(file, source, destination) unless file.folder\n WFolder.move(file, source, destination) if file.folder\n\n @result = { success: true }\n end",
"def move_dirs\n :both\n end",
"def move_to_trash\n source_dir = Item.new(Path.new(params[:source_dir]))\n dest_dir_path = Pathname.new(source_dir.path.dirname.to_s + \"/RESTARTED/RESTARTED_\" + source_dir.path.basename.to_s)\n\n dest_dir_string = dest_dir_path.to_s\n dir_found = false\n i = 1\n while(!dir_found)\n dest_dir = Item.new(Path.new(dest_dir_string))\n if dest_dir.exist?\n dest_dir_string = dest_dir_path.to_s + \"_#{i}\"\n i += 1\n else\n dir_found = true\n end\n end\n\n response = {}\n if !source_dir.exist?\n response[:msg] = \"No folder at location, nothing to do\"\n render json: response, status: 200\n elsif source_dir.move_to(dest_dir)\n response[:msg] = \"Success\"\n render json: response, status: 200\n else\n response[:msg] = \"Fail\"\n render json: response, status: 422\n end\n end",
"def compare_folders(a, b)\n\n puts \"* Comparing contents...\".light_yellow\n puts if OPTIONS.verbose\n \n common_a, unique_to_a = a.compare_to(b)\n common_b, unique_to_b = b.compare_to(a, common_a)\n common = common_a | common_b\n\n puts\n [unique_to_a, common, unique_to_b]\nend",
"def check_directories\n if File.exist?(source_dir)\n @source_dir = source_dir\n else\n raise DirectoryNotExist, \"Directory not exist\" \n end\n if File.exist?(destination_dir)\n @destination_dir = destination_dir\n else\n raise DirectoryNotExist, \"Directory not exist\" \n end \n end",
"def register_defaults_for_inbox(inboxpath)\n if processed then # If there is a default set for processed...\n if not Pathstring.new(inboxpath).volume == Pathstring.new(processed).volume then # ...and it's not on the same volume as inboxpath\n raise \"Both inbox and processed directories must be on same volume.\"\n end\n end\n @defaults.registerDefaults(:inbox => File.expand_path(inboxpath))\n end",
"def move_file\n source_file = Item.new(Path.new(params[:source_file]))\n dest_file = Item.new(Path.new(params[:dest_file]))\n\n response = {}\n if source_file.path.to_s == dest_file.path.to_s\n response[:msg] = \"Same file\"\n render json: response, status: 200\n return\n end\n\n response[:source_file] = source_file\n response[:dest_file] = dest_file\n if source_file.move_to(dest_file)\n response[:msg] = \"Success\"\n render json: response, status: 200\n else\n response[:msg] = \"Fail\"\n render json: response, status: 402\n end\n end",
"def move_folder\n source_dir = Item.new(Path.new(params[:source_dir]))\n dest_dir = Item.new(Path.new(params[:dest_dir]))\n\n response = {}\n response[:source_dir] = source_dir\n response[:dest_dir] = dest_dir\n if source_dir.move_to(dest_dir)\n response[:msg] = \"Success\"\n render json: response, status: 200\n else\n response[:msg] = \"Fail\"\n render json: response, status: 402\n end\n end",
"def move_files(from_path, to_path)\n # move into the new dir - and mv files to the in_process_dir\n pwd = FileUtils.pwd\n begin\n FileUtils.mkdir_p(to_path) if not Dir.exists? to_path\n Dir.chdir(from_path)\n FileUtils.mv Dir.glob(\"*\"), to_path, :force => true\n Dir.chdir(to_path)\n begin\n #remove from_path as files are now \"in process\"\n FileUtils.rm_r(from_path)\n rescue\n logger.warn \"failed to rm #{from_path}\"\n end\n ensure\n if FileUtils.pwd() != pwd\n if Dir.exists? pwd\n FileUtils.chdir(pwd)\n else\n FileUtils.chdir( student_work_dir() )\n end\n end\n end\n end",
"def move_opt_chef(src, dest)\n converge_by(\"moving all files under #{src} to #{dest}\") do\n FileUtils.rm_rf dest\n raise \"rm_rf of #{dest} failed\" if ::File.exist?(dest) # detect mountpoints that were not deleted\n FileUtils.mv src, dest\n end\nrescue => e\n # this handles mountpoints\n converge_by(\"caught #{e}, falling back to copying and removing from #{src} to #{dest}\") do\n begin\n FileUtils.rm_rf dest\n rescue\n nil\n end # mountpoints can throw EBUSY\n begin\n FileUtils.mkdir dest\n rescue\n nil\n end # mountpoints can throw EBUSY\n FileUtils.cp_r Dir.glob(\"#{src}/*\"), dest\n FileUtils.rm_rf Dir.glob(\"#{src}/*\")\n end\nend",
"def move_multimedia_files_to_trash\n if self.multimedia_path\n\n FileUtils.mkdir_p(dir_for_deleted)\n FileUtils.mv(Dir.glob(File.join(class_multimedia_path, self.multimedia_path, \"*.*\")), dir_for_deleted)\n\n logger.info \"Moviendo #{File.join(class_multimedia_path, self.multimedia_path, \"*.*\")} a #{dir_for_deleted}\"\n\n FileUtils.rm_rf(File.join(class_multimedia_path, self.multimedia_path))\n\n # Los videos de la webtv dejarán de funcionar porque están en el mismo directorio\n self.webtv_videos.update_all(\"published_at=NULL, document_id=NULL\") if self.respond_to?('webtv_videos')\n self.gallery_photos.update_all(\"document_id=NULL\") if self.respond_to?('gallery_photos')\n self.album.update_attributes(:document_id => nil, :draft => true) if self.respond_to?('album') && self.album\n end\n return true\n end",
"def compareDirs( relative = \"\" )\n # Combine the base path with the relative path\n original = File.expand_path( File.join( $original, relative ) )\n backup = File.expand_path( File.join( $backup, relative ) )\n\n # Return if this directory has been excluded\n if $options[:ignore].include?( original ) or $options[:ignore].include?( backup )\n $skippedCount += 1\n STDOUT.puts \"SKIP: Skipping comparison of [#{original}] and [#{backup}]\"\n return\n end\n\n # Make sure both directories exist\n unless File.directory?( original ) and File.directory?( backup )\n STDOUT.puts \"DIR: [#{original}] not found in [#{backup}]\"\n $diffCount += 1\n $diffCount += countItems( original ) if $options[:count]\n return\n end\n\n # If both directories exist, we check their contents\n begin\n Dir.foreach( original ) do |item|\n next if item == \".\" or item == \"..\"\n $itemCount += 1\n\n origPath = File.join( original, item )\n backupPath = File.join( backup, item )\n\n if File.directory? origPath\n # Skip symlinks if told to do so...\n if File.symlink?( origPath ) and not $options[:follow]\n $skippedCount += 1\n STDOUT.puts \"SYMLINK: [#{origPath}] skipped.\"\n next\n end\n # Stay on one filesystem if told to do so...\n outerDev = File::Stat.new( original ).dev\n innerDev = File::Stat.new( origPath ).dev\n if outerDev != innerDev and $options[:one_filesystem]\n $skippedCount += 1\n STDOUT.puts \"DIFFFS: [#{origPath}] is on a different file system. Skipped.\"\n next\n end\n compareDirs( File.join( relative, item ) )\n else # It's a file\n unless sameFile( origPath, backupPath )\n $diffCount += 1\n STDOUT.puts \"FILE: [#{origPath}] not found at, or doesn't match [#{backupPath}]\"\n end\n end\n end # Dir.foreach\n rescue Errno::EACCES\n STDOUT.puts \"ERROR: Can't read directory [#{original}]\"\n $errorCount += 1\n end\nend",
"def move_folder\n\n destFolder = params[:dest]\n targetFolder = params[:folder_id]\n client = user_client\n mixpanel_tab_event(\"My Vault\", \"Move Folder - Drag & Drop\")\n\n # get folder\n folder = Rails.cache.fetch(\"/folder/#{session[:box_id]}/my_folder/#{params[:dest]}\", :expires_in => 10.minutes) do\n client.folder_from_id(params[:dest])\n end\n\n begin\n # get shared folder, then move file into shared folder\n client.move_folder(targetFolder, destFolder)\n flash[:notice] = \"Folder moved into \\\"#{folder.name}\\\"\"\n rescue\n flash[:error] = \"Error: Folder could not be moved\"\n end\n\n redirect_to dashboard_id_path(session[:current_folder])\n end",
"def push_files(local_path,remote_path)\n debug_p(\"push_files from #{local_path} to #{remote_path}\")\n local_dir = Dir.new(local_path)\n local_dir.each{ |path|\n unless File::ftype(local_path + \"/\" + path) == \"directory\"\n @sftp_session.upload!(local_path + \"/\" + path,remote_path + \"/\" + path)\n end\n }\n end",
"def needCopy(destItem,srcItem)\n oldfile = !FiRe::filesys.uptodate?(destItem,srcItem)\n missingfile = !FiRe::filesys.exist?(destItem) || smaller?(destItem,srcItem)\n\n if !(oldfile || missingfile)\n FiRe::log.debug \"item already there! [#{srcItem}]\"\n end\n \n oldfile || missingfile\n \n end",
"def reshare dir, host\n if File.exist? \"#{dir}/#{host}/.completed\"\n `share -F nfs -o ro=#{host},anon=0 #{dir}/#{host} > /dev/null 2>&1`\n end\nend",
"def move\n begin\n conversation = params['conversation']\n message = @frontapp_service.get_message(conversation)\n if(@frontapp_service.has_spam_tag?(conversation) && !@frontapp_service.in_spam_inbox?(conversation))\n # has spam tag and is moved to non-spam folder\n Rails.logger.info \"------ MARKING MESSAGE AS HAM\\n#{message[0..255]}\\n------\"\n @spam_service.mark_ham(message)\n @frontapp_service.mark_ham(conversation)\n @message_service.mark_ham(conversation['id'], message)\n elsif !@frontapp_service.has_spam_tag?(conversation)\n # does not have spam tag and is moved to spam folder\n Rails.logger.info \"------ MARKING MESSAGE AS SPAM\\n#{message[0..255]}\\n------\"\n @spam_service.mark_spam(message)\n @frontapp_service.mark_spam(conversation)\n @message_service.mark_spam(conversation['id'], message)\n end\n render json: { ok: true }\n rescue => e\n Rails.logger.error \"[move] #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n render json: { error: 'Oops, something did not go as planned' }, status: 500\n end\n end",
"def file_diff(package, from, to, file)\n ret = true\n Dir.mktmpdir {|tmpdir| \n files_found = system(\"cd #{tmpdir} && #{osc_cmd} co #{from} #{package} #{file} && mv #{file} #{file}.new && #{osc_cmd} co #{to} #{package} #{file} >/dev/null 2>&1\")\n unless files_found\n puts \"=== Cannot check out file #{file} from package #{package}\"\n ret = true\n else\n ret = ! system(\"cd #{tmpdir} && diff #{file} #{file}.new\")\n end\n }\n ret\nend",
"def remove_superfluous_destination_files\n # join mirror_file and dest_file and delete everything from dest_file which isn't in mirror_file\n # because mirror_file should represent the current state of the source mogile files\n Log.instance.info('Joining destination and mirror tables to determine files that have been deleted from source repo.')\n DestFile.where('mirror_file.dkey IS NULL').joins('LEFT OUTER JOIN mirror_file ON mirror_file.dkey = file.dkey').find_in_batches(batch_size: 1000) do |batch|\n batch.each do |file|\n # Quit if program exit has been requested.\n break if SignalHandler.instance.should_quit\n\n # Delete all files from our destination domain which no longer exist in the source domain.\n begin\n Log.instance.debug(\"key [ #{file.dkey} ] should not exist. Deleting.\")\n @dest_mogile.delete(file.dkey)\n @removed += 1\n @freed_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error deleting [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n end\n\n # Print a summary to the user.\n summarize\n\n # Quit if program exit has been requested.\n return true if SignalHandler.instance.should_quit\n end\n end",
"def share_folder(location, name, box)\n if location\n box.vm.share_folder(name, name, location, :nfs => true)\n end\nend",
"def batch_copy_missing_destination_files(files)\n dest_domain = DestDomain.find_by_namespace(@dest_mogile.domain)\n\n files.each do |file|\n # Quit if no results\n break if file.nil?\n\n # Quit if program exit has been requested.\n break if SignalHandler.instance.should_quit\n\n # Look up the source file's key in the destination domain\n destfile = DestFile.find_by_dkey_and_dmid(file.dkey, dest_domain.dmid)\n if destfile\n # File exists!\n # Check that the source and dest file sizes match\n if file.length != destfile.length\n # File exists but has been modified. Copy it over.\n begin\n Log.instance.debug(\"Key [ #{file.dkey} ] is out of date. Updating.\")\n stream_copy(file)\n @updated += 1\n @copied_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error updating [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n else\n Log.instance.debug(\"key [ #{file.dkey} ] is up to date.\")\n @uptodate += 1\n end\n else\n # File does not exist. Copy it over.\n begin\n Log.instance.debug(\"key [ #{file.dkey} ] does not exist... creating.\")\n stream_copy(file)\n @added += 1\n @copied_bytes += file.length\n rescue => e\n @failed += 1\n Log.instance.error(\"Error adding [ #{file.dkey} ]: #{e.message}\\n#{e.backtrace}\")\n end\n end\n end\n end",
"def move_from(from_path)\n res = false\n current_user_role_names.each do |role_name|\n # Cycle until we find a role that makes this directory writeable\n next unless Filesystem.test_dir role_name, container, :write\n\n # If a path is set, ensure we can make a directory for it if one doesn't exist\n unless path.blank? || Filesystem.test_dir(role_name, container, :mkdir,\n extra_path: container_path(no_filename: true), ok_if_exists: true)\n next\n end\n\n cleanpath = Filesystem.clean_path(path)\n if cleanpath\n is_trash_path = self.class.trash_path?(cleanpath)\n\n if !is_trash_path && (cleanpath.start_with?('.') || cleanpath.start_with?('/'))\n raise FsException::Action, \"Path to move to is bad: #{cleanpath}\"\n end\n end\n\n to_path = if is_trash_path\n cleanpath\n else\n container_path(no_filename: true)\n end\n\n res = Filesystem.move_file_to_final_location role_name, from_path, container, to_path, file_name\n break if res\n end\n\n unless res\n raise FsException::NoAccess, 'User does not have permission to store file with any of the current groups'\n end\n\n true\n end",
"def replicate_dir(f)\n out_original = f.sub($queue,$original)\n out_watermarked = f.sub($queue,$watermarked)\n if !File.exist?(out_original) && !File.exist?(out_watermarked)\n FileUtils.mkdir(out_original)\n FileUtils.mkdir(out_watermarked) \n end\nend",
"def move_files_if(src_files, dst_dir = nil)\n Dir[src_files].each do |srcfile|\n cp_action = 0\n dst_dir = File.dirname(src_files).gsub(TMPDIR, '').gsub(/^\\//, '') if dst_dir == nil\n dst_dir << \"/\" unless dst_dir =~ /\\/$/\n dstfile = \"#{dst_dir}#{File.basename(srcfile)}\"\n\n # check if exists similar one in hdl/ directory\n if !File.file? dstfile\n cp_action = 1\n # if exists but differs\n elsif !FileUtils.identical?(dstfile, srcfile) then\n \n puts \"-\" * 43 << \"existing one\" << \"-\" * 44 << '|' << \"-\" * 44 << \"generated\" << \"-\" * 43 << \"\\n\" \n puts %x{diff -y -W200 #{dstfile} #{srcfile} | less }\n puts \"-\" * 200\n print \"Use generated file #{File.basename(srcfile)}? [Y/N] \"\n if $stdin.gets =~ /y/i\n cp_action = 2\n end\n end\n if cp_action > 0\n FileUtils.mkdir_p(dst_dir) unless File.directory? dst_dir\n FileUtils.cp srcfile, dstfile\n if cp_action == 1\n printf(\"%5s %20s %s\\n\",\"\", \" new file added:\", dstfile)\n else\n printf(\"%20s %s\\n\",\" overwrited:\", dstfile)\n end\n end\n end\nend",
"def smaller?(destItem, srcItem)\n\n srcsize = FiRe::filesys.size?(srcItem) \n destsize = FiRe::filesys.size?(destItem)\n\n # handle strange behaviour with nil in return for zero-bytes sizes\n srcsize = 0 if srcsize.nil?\n destsize = 0 if destsize.nil?\n \n destsize < srcsize \n \n end",
"def execute\n\n copiedCounter = 0\n failedCounter = 0\n skippedCounter = 0\n \n # traverse all srcfiles\n FiRe::filesys.find(@source) { |srcItem|\n \n # give some feedback\n FiRe::log.info \"searching #{srcItem}...\" if FiRe::filesys.directory?(srcItem)\n \n # skip this subtree if it matches ignored-items\n FiRe::filesys.prune if ignore?(srcItem) \n \n # transform srcpath to destpath\n destItem = srcItem.gsub(@source, @destination)\n\n # do not copy if item already exists and looks OK\n if needCopy(destItem,srcItem)\n copyWentWell = copyItem(srcItem, destItem)\n copiedCounter += 1 if copyWentWell\n failedCounter += 1 if !copyWentWell\n else\n skippedCounter += 1 \n end\n \n }\n \n # give some feedback\n FiRe::log.info \"copied #{copiedCounter} items, while #{failedCounter} items failed. #{skippedCounter} items did not need to be copied today.\"\n\n end",
"def test_move_under_single_lock\n setup_hr\n\n lock = lock 'httplock/hr', :depth => RubyDav::INFINITY\n\n response = @request.move('httplock/hr/recruiting/resumes', 'httplock/hr/archives/resumes')\n assert_equal '423', response.status\n assert_exists 'httplock/hr/recruiting/resumes/'\n assert_does_not_exist 'httplock/hr/archives/resumes/'\n\n if_hdr = lock.token\n response = @request.move('httplock/hr/recruiting/resumes', 'httplock/hr/archives/resumes', false, :if => if_hdr)\n assert_equal '201', response.status\n assert_does_not_exist 'httplock/hr/recruiting/resumes/'\n assert_exists 'httplock/hr/archives/resumes/'\n\n # cleanup\n unlock('httplock/hr', lock.token)\n delete_coll('httplock')\n end",
"def sync_special_fat32_files\n Dir[File.join(@path_source, '**/*\\./')].sort.each do |source_dir|\n # Syncing files from source and dest\n dest_dir = get_dest_filepath(source_dir)\n\n puts \"Manually syncing files to #{File.basename(dest_dir)}\"\n rsync_dirs(source_dir, dest_dir, true)\n end\n end",
"def upload_mbox_tree(source)\n if File.file?(source)\n upload_mbox(source)\n else\n Dir.new(source).each do |f|\n next if f == '.' || f == '..'\n path = File.join(source, f)\n if File.file?(path)\n upload_mbox(path)\n elsif File.directory?(path)\n # Recurse.\n upload_mbox_tree(path)\n end\n end\n end\n end",
"def new_maildir(target, source, name)\n x = name.sub(/Messages$/, \"\").sub(/\\.mbox\\/?.*/, \"\")\n x = x.sub(Regexp.new(source), \"\").sub(/^\\//, \"\")\n d = \"\"\n x.split(\"/\").each do |comp|\n d << \"/\" + comp.delete(\" \")\n unless FileTest.directory?(target + \"/\" + d)\n FileUtils.mkdir(target + \"/\" + d)\n end\n end\n new_d = target + \"/\" + d\n FileUtils.mkdir(new_d + \"/cur\")\n FileUtils.mkdir(new_d + \"/new\")\n FileUtils.mkdir(new_d + \"/tmp\")\n new_d\nend",
"def verify_src_dest_dir_paths\n unless File.exists?(@era_root_dir_path) && File.directory?(@era_root_dir_path)\n STDERR.puts \"Source directory does not exist:\\n '#{@era_root_dir_path}'\"\n exit 2\n end\n if File.exists?(@era_root_dir_path_dest)\n STDERR.puts \"Destination directory or file already exists:\\n '#{@era_root_dir_path_dest}'\"\n exit 3\n end\n end",
"def compare_inventory_files(old_file, new_file)\n old_inventory = inventory_from(old_file)\n\n\n new_inventory = inventory_from(new_file)\n\n x = (new_inventory - old_inventory).length\n # Excercise: add number of added files\n puts \"The following #{x} file(s) have been added:\"\n puts new_inventory - old_inventory\n\n y = (old_inventory - new_inventory).length\n\n puts \"\"\n # Excercise: add number of deleted files\n puts \"The following #{y} file(s) have been deleted:\"\n puts old_inventory - new_inventory\n\n x = new_inventory.length - x\n\n y = old_inventory.length - y \n\n puts \"\"\n # Excercise: add number of unchanged files\n puts \"Unchanged files: #{x} \"\n puts \"Verification of unchanged files: #{y} \"\nend",
"def sync_dir dir\n # TODO: think of a better name scheme\n # maybe the title should include the relative path?\n calculated_photoset_name = \"[ruphy-backup] #{dir}\"\n Dir.chdir @root + '/' + dir\n\n if photoset_exist? calculated_photoset_name\n #sync\n flickr_list = get_file_list calculated_photoset_name\n local_list = Dir[\"*\"]\n remotely_missing = []\n locally_missing = []\n \n local_list.each do |f|\n remotely_missing << f unless flickr_list.include? f\n end\n# puts \"remotely missing files: \" + remotely_missing.join(',')\n \n remotely_missing.each do |f|\n upload f, calculated_photoset_name\n end\n \n \n flickr_list.each do |f|\n locally_missing << f unless local_list.include? f\n end\n puts \"we're locally missing: \" + locally_missing.join(', ')\n \n # TODO: really perform sync\n \n else\n # set not existing: just upload\n Dir[\"*\"].each do |f|\n upload f, calculated_photoset_name\n end\n end\n end",
"def mirror_missing_destination_files\n # Find the id of the domain we are mirroring\n source_domain = SourceDomain.find_by_namespace(@source_mogile.domain)\n\n # Get the max fid from the mirror db\n # This will only be nonzero if we are doing an incremental\n max_fid = MirrorFile.max_fid\n\n # Process source files in batches.\n Log.instance.info(\"Searching for files in domain [ #{source_domain.namespace} ] whose fid is larger than [ #{max_fid} ].\")\n SourceFile.where('dmid = ? AND fid > ?', source_domain.dmid, max_fid).includes(:domain, :fileclass).find_in_batches(batch_size: 1000) do |batch|\n # Create an array of MirrorFiles which represents files we have mirrored.\n remotefiles = batch.collect { |file| MirrorFile.new(fid: file.fid, dkey: file.dkey, length: file.length, classname: file.classname) }\n\n # Insert the mirror files in a batch format.\n Log.instance.debug('Bulk inserting mirror files.')\n MirrorFile.import remotefiles\n\n # Figure out which files need copied over\n # (either because they are missing or because they have been updated)\n batch_copy_missing_destination_files(remotefiles)\n\n # Show our progress so people know we are working\n summarize\n\n # Quit if program exit has been requested.\n return true if SignalHandler.instance.should_quit\n end\n end",
"def move_folder(from_source:, from_dir:, to_source:, to_dir:)\n response = HTTParty.get(\"#{@host}/move_folder\", query: {\n source_dir: \"#{from_source}:#{from_dir}\",\n dest_dir: \"#{to_source}:#{to_dir}\",\n api_key: @api_key\n })\n \n return response.success?\n end",
"def compareDirs( relative = \"\" )\n # Combine the base path with the relative path\n original = File.expand_path( File.join( $original, relative ) )\n backup = File.expand_path( File.join( $backup, relative ) )\n\n if $options[:verbose]\n STDOUT.puts \"DEBUG: Comparing [#{original}] to [#{backup}]\" \n end\n\n # Return if this directory has been excluded\n if $options[:ignore].include?( original ) or $options[:ignore].include?( backup )\n $skippedCount += 1\n STDOUT.puts \"SKIP: Skipping comparison of [#{original}] and [#{backup}]\"\n return\n end\n\n # Make sure both directories exist\n unless File.directory?( original ) and File.directory?( backup )\n STDOUT.puts \"DIR: [#{original}] not found in [#{backup}]\"\n # The directory not existing counts as one difference.\n $diffCount += 1 \n # Each item in the directory counts as yet another item processed and yet\n # another difference.\n item_count = countItems( original )\n $itemCount += item_count\n $diffCount += item_count\n return\n end\n\n # If both directories exist, we check their contents\n begin\n Dir.foreach( original ) do |item|\n next if item == \".\" or item == \"..\"\n $itemCount += 1\n origPath = File.join( original, item )\n backupPath = File.join( backup, item )\n\n # This check is independent of whether or not the path is a directory or\n # a file. If either is a symlink, make sure they are both symlinks, and\n # that they link to the same thing.\n if File.symlink?( origPath ) || File.symlink?( backupPath )\n if !(File.symlink?( origPath ) && File.symlink?( backupPath )) ||\n File.readlink( origPath ) != File.readlink( backupPath )\n\n STDOUT.puts \"SYMMIS: Symlink mismatch [#{origPath}] and [#{backupPath}]\"\n\n # Count the differing symlink.\n $diffCount += 1\n\n # FIXME: If follow symlinks is on, we want to count everything that\n # was under that missing symlink directory too.\n\n # We know these paths are different, so move on to the next one.\n next\n end\n end\n\n if File.directory? origPath\n # Skip symlinks if told to do so...\n if File.symlink?( origPath ) and not $options[:follow]\n $skippedCount += 1\n STDOUT.puts \"SYMLINK: [#{origPath}] skipped.\"\n next\n end\n # Stay on one filesystem if told to do so...\n outerDev = File::Stat.new( original ).dev\n innerDev = File::Stat.new( origPath ).dev\n if outerDev != innerDev and $options[:one_filesystem]\n $skippedCount += 1\n STDOUT.puts \"DIFFFS: [#{origPath}] is on a different file system. Skipped.\"\n next\n end\n compareDirs( File.join( relative, item ) )\n else # It's a file\n unless sameFile( origPath, backupPath )\n $diffCount += 1\n STDOUT.puts \"FILE: [#{origPath}] not found at, or doesn't match [#{backupPath}]\"\n end\n end\n end # Dir.foreach\n rescue Errno::EACCES\n STDOUT.puts \"ERROR: Can't read directory [#{original}]\"\n $errorCount += 1\n end\nend",
"def move_folder\n if ENV['RACK_ENV'] == 'production'\n if File.directory?(get_folder(name_change.last))\n error!('A folder with this name already exists.', 400)\n else\n FileUtils.mv get_folder(name_change.first), get_folder(name_change.last)\n end\n end\n end",
"def compare_folder_recursive(result, src_folder, dst_folder, current_path = '')\n Rails.logger.info \"Comparing folder #{src_folder} <=> #{dst_folder}\"\n if src_folder != dst_folder\n Dir.foreach(src_folder) do |item|\n next if (item == '.') || (item == '..')\n\n src_path = File.join(src_folder, item)\n dst_path = File.join(dst_folder, item)\n if File.exist?(dst_path) && File.file?(src_path) == File.file?(dst_path)\n if File.directory? dst_path\n # Recursive call\n compare_folder_recursive(result, src_path, dst_path, File.join(current_path, item))\n else\n # Compare file content\n unless FileUtils.compare_file(src_path, dst_path)\n filename = File.join(current_path, item)\n Rails.logger.error \"File differ: #{filename}\"\n result[:mismatch] << filename\n end\n end\n else\n filename = File.join(current_path, item)\n Rails.logger.error \"File not found: #{filename}\"\n result[:missing] << filename\n end\n end\n else\n Rails.logger.warn 'Same folder path, skip comparing'\n end\n end",
"def copy_files\n message \"Checking for existing #{@@app_name.capitalize} install in #{install_directory}\"\n files_yml = File.join(install_directory,'installer','files.yml')\n old_files = read_yml(files_yml) rescue Hash.new\n \n message \"Reading files from #{source_directory}\"\n new_files = sha1_hash_directory_tree(source_directory)\n new_files.delete('/config/database.yml') # Never copy this.\n \n # Next, we compare the original install hash to the current hash. For each\n # entry:\n #\n # - in new_file but not in old_files: copy\n # - in old files but not in new_files: delete\n # - in both, but hash different: copy\n # - in both, hash same: don't copy\n #\n # We really should add a third hash (existing_files) and compare against that\n # so we don't overwrite changed files.\n\n added, changed, deleted, same = hash_diff(old_files, new_files)\n \n if added.size > 0\n message \"Copying #{added.size} new files into #{install_directory}\"\n added.keys.sort.each do |file|\n message \" copying #{file}\"\n copy_one_file(file)\n end\n end\n \n if changed.size > 0\n message \"Updating #{changed.size} files in #{install_directory}\"\n changed.keys.sort.each do |file|\n message \" updating #{file}\"\n copy_one_file(file)\n end\n end\n \n if deleted.size > 0\n message \"Deleting #{deleted.size} files from #{install_directory}\"\n \n deleted.keys.sort.each do |file|\n message \" deleting #{file}\"\n rm(File.join(install_directory,file)) rescue nil\n end\n end\n \n write_yml(files_yml,new_files)\n end",
"def test_post_move_folder()\n\n src = 'folder6'\n dest = 'folder7/folder6'\n storage = 'First Storage'\n dest_storage = 'First Storage'\n request = PostMoveFolderRequest.new(src, dest, storage, dest_storage)\n\n result = @storage_api.post_move_folder(request)\n assert result.code == 200, 'Error while moving folder'\n\n end",
"def move_folders(orig,dest)\n \n puts \"Moving #{orig} -> #{dest}\" if @verbose\n FileUtils.mv orig,dest\n end",
"def ensure_not_in_dest\n dest_pathname = Pathname.new(dest)\n Pathname.new(source).ascend do |path|\n if path == dest_pathname\n raise Errors::FatalException,\n \"Destination directory cannot be or contain the Source directory.\"\n end\n end\n end",
"def preform_copy_directory\n @destination_directories.each do |destination|\n @sources.each do |source|\n write_mode = 'w'\n new_path = Pathname.new(destination.to_s).join(source.basename)\n # Check if the specified file is a directory\n if new_path.directory?\n return false if get_input(\"Destination path '\" + new_path.to_s + \"' is a directory. (S)kip the file or (C)ancel: \", ['s','c']) == 'c'\n next\n end\n # Copy the file\n return false unless copy_file(source, new_path)\n end\n end\n return true\n end",
"def find_files(src,dest,options)\r\n src_files = self.find_as_relative( src, options[:excludes] )\r\n dest_files = self.find_as_relative( dest, options[:excludes] )\r\n\r\n # output target files\r\n puts \" 元フォルダ:\" + src_files.size.to_s + \"件\" if self.debug?\r\n puts \"同期先フォルダ:\" + dest_files.size.to_s + \"件\" if self.debug?\r\n #pp src_files if self.debug?\r\n sleep 1 if self.debug?\r\n\r\n #両方にあるファイル名で中身が違うもので src の方が古いもの\r\n same_name_files = (dest_files & src_files)\r\n same_name_files.reject!{|e|\r\n #ファイルが同じモノは省く\r\n next unless File.exists?( File.expand_path(e,dest))\r\n puts \"compare file bin. #{e}\" if self.debug? || self.verbose?\r\n $stdout.flush if self.debug?\r\n FileUtils.cmp( File.expand_path(e,src) , File.expand_path(e,dest) ) \r\n } if options[:strict]\r\n same_name_files.reject!{|e|\r\n #ファイルサイズが同じモノを省く(全部比較する代替手段)\r\n next unless File.exists?( File.expand_path(e,dest))\r\n puts \"size/mtime compare #{e}\" if self.debug? || self.verbose?\r\n File.size(File.expand_path(e,src)) == File.size( File.expand_path(e,dest))\r\n #&& File.mtime(File.expand_path(e,src)) == File.mtime( File.expand_path(e,dest) )\r\n } unless options[:strict]\r\n if options[:update] then\r\n same_name_files= same_name_files.select{|e|\r\n puts \"mtime is newer #{e}\" if self.debug? || self.verbose?\r\n (File.mtime(File.expand_path(e,src)) > File.mtime( File.expand_path(e,dest)))\r\n }\r\n end\r\n if options[:overwrite] == false then\r\n same_name_files= same_name_files.reject{|e|\r\n puts \"can over write? #{e}\" if self.debug? || self.verbose?\r\n (File.exists?(File.expand_path(e,src)) && File.exists?( File.expand_path(e,dest)))\r\n }\r\n end\r\n $stdout.flush if self.debug?\r\n files_not_in_dest = (src_files - dest_files)\r\n #files\r\n files =[]\r\n files = (files_not_in_dest + same_name_files ).flatten\r\n files\r\n end",
"def compare\n\t\t\t\n\t\t\tDir.foreach(@folder1) do |item|\n\t\t\t\tbegin\n \t\t\t\tnext if item == '.' or item == '..'\n \t\t\t\tfullfilename = File.expand_path(@folder1, item)\n \t\t\t\tthe_hash = Digest::MD5.hexdigest(File.read(File.join(File.expand_path(@folder1), item)))\n \t\t\t\titem = item.downcase\n \t\t\t\tfiledata = FileHashResults.new(item, the_hash, nil)\n \t\t\t\t@filehash[item] = filedata\n \t\t\trescue\n \t\t\t #puts \"Skipped:#{item.inspect}\"\n \t\t\tend\n\t\t\tend\n\n\t\t\tDir.foreach(@folder2) do |item|\n\t\t\t begin\n \t\t\t\tnext if item == '.' or item == '..'\n \t\t\t\tthe_hash = Digest::MD5.hexdigest(File.read(File.join(@folder2, item)))\n \t\t\t\titem = item.downcase\n if(@filehash[item]==nil)\n \t\t\t\t\tfiledata = FileHashResults.new(item, nil, the_hash)\n \t\t\t\t\t@filehash[item] = filedata\n \t\t\t\t\tnext\n \t\t\t\tend\n \t\t\t\t@filehash[item.downcase].file_hash2 = the_hash\n \t\t\trescue\n #puts \"Skipped:#{item.inspect}\"\n end\t\n\t\t\tend\n\t\tend",
"def runDiffOperation(new_output, old_output, diff_folder)\n #Searching for New & updated files\n @files = Dir.glob(new_output+\"**/**\")\n for file in @files\n partName=file.split(new_output).last \n if (File.directory?(file))\n if !File.exist?(old_output+partName)\n if !File.exist?(diff_folder+partName)\n createFolder(diff_folder+partName)\n puts \"Dir Created -\" + partName\n else\n puts \"Target Dir Exists -\" + partName\n end\n end\n else\n #New file copy operation\n if !File.exist?(old_output+partName) \n folder= partName.split(partName.split(\"/\").last).first\n if folder==nil\n folder=\"\"\n end\n if !File.exist?(diff_folder+folder)\n createFolder(diff_folder+folder)\n puts \"Dir Created -\" + diff_folder+folder\n end\n File.copy(file,diff_folder+folder)\n puts \"New File Copied -\"+file +\" to \"+diff_folder+folder\n #Updated file copy operation\n elsif !(File.compare(file,old_output+partName))\n folder= partName.split(partName.split(\"/\").last).first\n if folder==nil \n folder=\"\"\n end\n if !File.exist?(diff_folder+folder)\n createFolder(diff_folder+folder)\n puts \"Dir Created -\" + diff_folder+folder\n end\n File.copy(file,diff_folder+folder)\n puts \"Updated File Copied -\"+file +\" to \"+diff_folder+folder\n end\n end\n end\n #Searching for Deleted files & creating the list\n deletedFileList=diff_folder+\"deletedFiles.list\"\n timestamp = Time.now.to_s()\n deletedFileName=\"\"\n deletedFilesCount=0;\n @files = Dir.glob(old_output+\"**/**\")\n for file in @files\n partName=file.split(old_output).last\n check=partName.include?'search/'\n if !File.exist?(new_output+partName) && !check\n if !(File.directory?(file))\n deletedFileName=partName.split(\"/\").last\n open(deletedFileList, 'a') { |f|\n f.puts deletedFileName\n }\n end\n# deletedFileName= timestamp +\"\\t\"+deletedFileName\n deletedFilesCount=deletedFilesCount+1 \n end\n end\n if Dir.glob(diff_folder+\"**/**\") .length==0\n if (File.directory?(diff_folder))\n Dir.rmdir(diff_folder)\n end\n if (File.directory?(@book_update_folder))\n Dir.rmdir(@book_update_folder)\n end \n puts \"No Changes made\"\n exit\n end\nend",
"def push_dir(local_path,remote_path)\n debug_p(\"push_dir from #{local_path} to #{remote_path}\")\n begin\n @sftp_session.upload!(local_path,remote_path)\n rescue\n @ssh.exec!(\"rm -rf #{remote_path}\")\n retry\n end\n end",
"def move_folder\n parent_folder = Folder.find_folder(params[:folder_id])\n parent_folder1 = Folder.find_folder(parent_folder.parent_id)\n portfolio_id_old = parent_folder.portfolio_id\n @portfolio_old = portfolio_id_old\n folder_id_old = params[:folder_id]\n @folder = parent_folder\n @portfolio = @folder.portfolio\n @parent_folder = parent_folder\n move_folder_id = Folder.find_folder(params[:move_folder_id])\n @moved_folder = move_folder_id\n @moved_portfolio_old = @moved_folder.portfolio_id\n params[:folder_id] = parent_folder.parent_id if !parent_folder.nil?\t\tand !params[:element_type].nil? and params[:element_type].blank?\n if params[:move_folder_id] and !params[:move_folder_id].blank?\n move_document(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] == \"document\" and params[:operation] and params[:operation] == \"move\"\n copy_document(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] == \"document\" and params[:operation] and params[:operation] == \"copy\"\n move_folders(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] != \"document\" and params[:operation] and params[:operation] == \"move\"\n copy_folder(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] != \"document\" and params[:operation] and params[:operation] == \"copy\"\n end\n display_collection_of_folders_docs_tasks\n end",
"def move_messages uids, destination, expunge = true\n return if uids.empty?\n log \"COPY [...#{uids.size} uids]\"\n\n begin\n imap.copy uids, destination\n rescue Net::IMAP::NoResponseError\n # ruby-lang bug #1713\n #raise unless e.response.data.code.name == 'TRYCREATE'\n create_mailbox destination\n imap.copy uids, destination\n end\n\n delete_messages uids, expunge\n end",
"def check_directories\n new_file_names = {}\n DirmonEntry.enabled.each do |entry|\n entry.each do |pathname|\n # BSON Keys cannot contain periods\n key = pathname.to_s.tr('.', '_')\n previous_size = previous_file_names[key]\n size = check_file(entry, pathname, previous_size)\n new_file_names[key] = size if size\n end\n end\n self.previous_file_names = new_file_names\n end",
"def move_file\n\n destFolder = params[:dest]\n targetFile = params[:file_id]\n client = user_client\n mixpanel_tab_event(\"My Vault\", \"Move File - Drag & Drop\")\n\n # get folder\n folder = Rails.cache.fetch(\"/folder/#{session[:box_id]}/my_folder/#{params[:dest]}\", :expires_in => 10.minutes) do\n client.folder_from_id(params[:dest])\n end\n\n begin\n # get shared folder, then move file into shared folder\n client.move_file(targetFile, destFolder)\n flash[:notice] = \"File moved into \\\"#{folder.name}\\\"\"\n rescue\n flash[:error] = \"Error: File could not be moved\"\n end\n\n redirect_to dashboard_id_path(session[:current_folder])\n end",
"def copy(dest, overwrite = false)\n# if(dest.path == path)\n# Conflict\n# elsif(stat.directory?)\n# dest.make_collection\n# FileUtils.cp_r(\"#{file_path}/.\", \"#{dest.send(:file_path)}/\")\n# OK\n# else\n# exists = File.exists?(file_path)\n# if(exists && !overwrite)\n# PreconditionFailed\n# else\n# open(file_path, \"rb\") do |file|\n# dest.write(file)\n# end\n# exists ? NoContent : Created\n# end\n# end\n\n # ディレクトリなら末尾に「/」をつける。\n # (dstにもともと「/」が付いているかどうか、クライアントに依存している)\n # CarotDAV : 「/」が付いていない\n # TeamFile : 「/」が付いている\n dest.collection! if collection?\n\n src = @bson['filename']\n dst = dest.file_path\n exists = nil\n\n @collection.find({:filename => /^#{Regexp.escape(src)}/}).each do |bson|\n src_name = bson['filename']\n dst_name = dst + src_name.slice(src.length, src_name.length)\n\n exists = @collection.find_one({:filename => dst_name}) rescue nil\n\n return PreconditionFailed if (exists && !overwrite && !collection?)\n\n @filesystem.open(src_name, \"r\") do |src|\n @filesystem.open(dst_name, \"w\") do |dst|\n dst.write(src) if src.file_length > 0\n end\n end\n\n @collection.remove(exists) if exists\n end\n\n collection? ? Created : (exists ? NoContent : Created)\n end",
"def copy files, host, dir\n dest = \"#{dir}/#{host}\"\n File.directory?(dest) || mkdir_p(dest)\n #puts \"Connecting to #{host}\"\n begin\n Net::SFTP.start(host, \"root\", :auth_methods => [\"publickey\"], :keys => [$key], :timeout => 1) do |sftp|\n files.each do |file|\n begin\n dir = File.dirname \"#{dest}/#{file}\"\n stats = sftp.stat! file\n if stats\n File.directory?(dir) || mkdir_p(dir)\n if stats.directory?\n sftp.download! file, \"#{dest}/#{file}\", :recursive => true\n chmod stats.permissions, \"#{dest}/#{file}\"\n else\n sftp.download! file, \"#{dest}/#{file}\"\n chmod stats.permissions, \"#{dest}/#{file}\"\n end\n touch \"#{dest}/.completed\" #at least one copied file. Too intensive?\n end\n rescue\n #puts \"Next for #{file}\"\n next #file does not exist\n end\n end\n end\n rescue Net::SFTP::Exception => e\n puts \"#{host} sftp exception: #{e}\"\n return false\n #rescue Net::SCP::Error => e\n # puts \"#{host} scp error: #{e}\"\n # return false\n rescue Timeout::Error => e\n puts \"#{host} timeout: #{e}\"\n return false\n rescue Errno::ECONNREFUSED => e\n puts \"#{host} refused: #{e}\"\n return false\n rescue SocketError => e\n puts \"#{host} resolve: #{e}\"\n return false\n rescue Net::SSH::AuthenticationFailed => e\n puts \"#{host} auth failed: #{e}\"\n return false\n rescue Net::SSH::Disconnect => e\n puts \"#{host} disconnected: #{e}\"\n return false #no access to host\n end\n return true\nend",
"def test_post_move_file\n\n src = 'folder1/FileTest.pdf'\n dest = 'folder3/folder1/FileTest.pdf'\n versionId = nil\n storage = 'First Storage'\n destStorage = 'First Storage'\n request = PostMoveFileRequest.new(src, dest, versionId, storage, destStorage)\n\n result = @storage_api.post_move_file(request)\n assert result.code == 200, 'Error while moving document'\n\n end",
"def copyMotionX(newFiles,baseFolderGPX, folderDownload)\n puts \"\\n6. (165). Copying MotionX gpx files\\n from #{folderDownload} to Massaged Folder and \\nadding to newFiles, the list of files to be processed.\"\n i = 0\n folderNew = \"167. folderDownload: #{folderDownload}\"\n today = Time.now.strftime(\"%Y%m%d\")\n puts \n Find.find(folderDownload) do |fx|\n # puts \"166. fx: #{fx}. File.file?(fx): #{File.file?(fx)}. \"\n next if !File.file?(fx) # the directory we're looking in is added to the fx list, so skip it. # Was Find.prune if … which didn't work\n Find.prune if File.extname(fx) != '.gpx' # get errors trying to process other files on card.\n puts \"\\n174. fx: #{fx}. \\nFile.basename(fx): \\n #{File.basename(fx)}\"\n # Establish file name\n # 2015.03.19 MotionX changed file naming and they don't come with date first anymore, so will have to extract date from file. \n # Read first <time> and set it to firstTime or \n \n # then extract and set dotTime to be added to beginning of filename while keeping the rest of the filenam\n \n dotDate = motionXdate(fx)\n puts \"#{lineNum}. dotDate: #{dotDate}\"\n #REDO THIS AS NEEDED\n yearFile = dotDate[0..3]\n # puts \"185. yearFile: #{yearFile}\"\n dateFile = dotDate.gsub(\".\",\"\")\n puts \"dateFile: #{dateFile}\"\n # puts \"188. folderNew:\"\n puts folderNew = \"#{baseFolderGPX}#{yearFile} Massaged\" # MIGHT MOVE THIS FROM THE TWO DEFS\n \n newBasename = \"#{dotDate} - #{File.basename(fx)}\" # \n # puts \"\\n\\n184. newBasename: #{newBasename}\"\n \n # if today==File.basename(fx, \".TEMP.gpx\")\n # puts \"\\n194. today: #{today}. dateFile: #{dateFile}\"\n if today==dateFile\n # puts \"193.. fx: #{fx}\"\n fileshortnew = newBasename + \".TEMP\" \n fnew = \"#{folderNew}/#{fileshortnew}.gpx\"\n puts \"201.. fnew: #{fnew}.\"\n else # all but today's file\n fnew = \"#{folderNew}/#{newBasename}.gpx\"\n # puts \"204. fnew: #{fnew}.\"\n end # today==. Add TEMP to today's files\n puts \"207.. fx: #{fx}. \"\n if !File.exists?(fnew)\n puts \"209.. fnew: #{fnew}. \"\n newFiles << fnew\n FileUtils.cp(fx, fnew) \n i =+ 1\n end # !File.exists?(fnew). add to newFiles \n \n \n end # Find.find(folderDownload) do |fx|. The basic grind\n puts \"\\n7. (#{lineNum}). Copying and renaming finished. #{i} gpx files copied to #{folderNew}.\\n\" \n # puts \"\\n160. newFiles: #{newFiles}.\\n Not exactly the same as newFiles below.\"\n return newFiles \nend",
"def move_files_to(dest_dir, type)\n\t\treturn false if !dir?\n\n\t\tfiles = @path.files(file_type: type)\n\t\tfiles.each do |source_file|\n\t\t\tdest_file = Item.new(Path.new(\"#{dest_dir.path}/#{source_file.path.basename}\"))\n\t\t\treturn false if !source_file.move_to(dest_file)\n\t\tend\n\n\t\treturn true\n\tend",
"def move_directory(directory,target)\n log_new(\"move directory -> #{File.basename(directory)}\")\n \n if File.exists? \"#{target}/#{File.basename(directory)}\"\n log(\"warning dst directory exists: \\'#{File.basename(directory)}\\'\")\n else \n # if the directory does not exist it is created\n FileUtils.mkdir_p(target,$options) if not File.directory? target\n FileUtils.mv(directory,target,$options) if ( (File.dirname directory) != target.gsub(/\\/$/,'')) \n symlink_on_move(directory,target)\n end\nend",
"def archive_differs_from_disk?(src, dest)\n modified = false\n archive = Archive::Reader.open_filename(src, nil, strip_components: new_resource.strip_components)\n Chef::Log.trace(\"Beginning the comparison of file mtime between contents of #{src} and #{dest}\")\n archive.each_entry do |e|\n pathname = ::File.expand_path(e.pathname, dest)\n if ::File.exist?(pathname)\n Chef::Log.trace(\"#{pathname} mtime is #{::File.mtime(pathname)} and archive is #{e.mtime}\")\n modified = true unless ::File.mtime(pathname) == e.mtime\n else\n Chef::Log.trace(\"#{pathname} doesn't exist on disk, but exists in the archive\")\n modified = true\n end\n end\n modified\n end",
"def move_to_target_directory!\n return if new_record? || !readable?\n\n src = diskfile\n self.disk_directory = target_directory\n dest = diskfile\n\n return if src == dest\n\n if !RedmicaS3::Connection.move_object(src, dest)\n Rails.logger.error \"Could not move attachment from #{src} to #{dest}\"\n return\n end\n\n update_column :disk_directory, disk_directory\n end",
"def sync(srcDir, dstDir)\n end",
"def go_single_transfer_in\r\n wait_for_transfer_file_come_up\r\n size = wait_for_the_data_to_all_get_here\r\n @copied_files += copy_files_from_dropbox_to_local_permanent_storage size\r\n create_done_copying_files_to_local_file\r\n wait_till_current_transfer_is_over\r\n\treturn recombinate_files_for_multiple_transfers_possibly\r\n end",
"def prepare_copy_folders\n return if config[:copy_folders].nil?\n\n info(\"Preparing to copy specified folders to #{sandbox_module_path}.\")\n kitchen_root_path = config[:kitchen_root]\n config[:copy_folders].each do |folder|\n debug(\"copying #{folder}\")\n folder_to_copy = File.join(kitchen_root_path, folder)\n copy_if_src_exists(folder_to_copy, sandbox_module_path)\n end\n end",
"def runDiffOperation(new_output, old_output, diff_folder)\n #Searching for New & updated files\n @files = Dir.glob(new_output+\"**/**\")\n for file in @files\n partName=file.split(new_output).last \n if (File.directory?(file))\n if !File.exist?(old_output+partName)\n if !File.exist?(diff_folder+partName)\n createFolder(diff_folder+partName)\n puts \"Dir Created -\" + partName\n else\n puts \"Target Dir Exists -\" + partName\n end\n end\n else\n #New file copy operation\n if !File.exist?(old_output+partName) \n folder= partName.split(partName.split(\"/\").last).first\n if !File.exist?(diff_folder+folder)\n createFolder(diff_folder+folder)\n puts \"Dir Created -\" + partName\n end\n File.copy(file,diff_folder+folder)\n puts \"New File Copied -\"+file\n #Updated file copy operation\n elsif !(File.compare(file,old_output+partName))\n folder= partName.split(partName.split(\"/\").last).first\n if folder==nil \n folder=\"\"\n end\n if !File.exist?(diff_folder+folder)\n createFolder(diff_folder+folder)\n puts \"Dir Created -\" + partName\n end\n File.copy(file,diff_folder+folder)\n puts \"Updated File Copied -\"+file\n end\n end\n end\n #Searching for Deleted files & creating the list\n deletedFileList=diff_folder+\"deletedList.list\"\n timestamp = Time.now.to_s()\n deletedFileName=\"\"\n deletedFilesCount=0;\n @files = Dir.glob(old_output+\"**/**\")\n for file in @files\n partName=file.split(old_output).last\n if !File.exist?(new_output+partName)\n if (File.directory?(file))\n deletedFileName=partName + \"/\"\n else\n deletedFileName=partName\n end\n# deletedFileName= timestamp +\"\\t\"+deletedFileName\n open(deletedFileList, 'a') { |f|\n f.puts deletedFileName\n }\n deletedFilesCount=deletedFilesCount+1 \n end\n end\n if Dir.glob(diff_folder+\"**/**\") .length==0\n if (File.directory?(@book_prod_final_update_folder))\n Dir.rmdir(@book_prod_final_update_folder)\n end\n if (File.directory?(diff_folder))\n Dir.rmdir(diff_folder)\n end\n if (File.directory?(@book_update_folder))\n Dir.rmdir(@book_update_folder)\n end \n puts \"No Changes made\"\n exit\n end\nend",
"def keep_dirs; end",
"def test_dirs(desc, dir1, dir2)\n\n test_missing_files(desc, dir1, dir2)\n\n dir_files(dir1).each do |file|\n file2 = file.sub(dir1, dir2)\n if File.exist?(file2)\n if diff = diff_file(file, file2)\n @failures << {\n desc: \"#{desc}\\nDiff of file: #{file.sub(dir1+'/', '')}\\n\",\n result: format_diff(diff)\n }\n pout 'F'.red\n else\n pout '.'.green\n end\n end\n end\nend",
"def moveFilesAfterProcessing(order_hash, status_hash)\n\t\tself.s3Connect(status_hash)\n\t\ts3_bucket = status_hash[:s3_process_bucket]\n\t\timage_array = Array.new\t\t \n\t\tstatus_hash[:s3_move_status] = 0\n\t\torder_number = order_hash[:order_number]\n\t\ttmp_path = File.join(File.dirname(__FILE__), 'orders', order_number)\n\t\ttmp_failure_path = File.join(File.dirname(__FILE__), 'orders/failure', order_number)\n\t\tzip = order_hash[:image_zip_file]\n\t\ttmp_zip_path = File.join(tmp_path, zip)\n\t\t\n\t\tif s3_bucket == 'is.happy.makr.orders'\n\t\t\tdelete_zip_path = zip\n\t\t\ts3_orig_path = zip\n\t\t\ts3_finish_path = ''\n\t\telse\n\t\t\tdelete_zip_path = File.join('orders/new/', zip)\n\t\t\ts3_orig_path = File.join('orders/new/', zip)\n\t\t\ts3_finish_path = 'orders/'\n\t\tend\t\t \n\t\t\n\t\t# moves files to approriate folder based on order_status\n\t\tif status_hash[:status] == 0 && File.exist?(tmp_zip_path) && status_hash[:s3_status] == 1\n\t\t\ts3_path = File.join(s3_finish_path, 'processed', order_number)\n\t\t\ts3_zip_path = File.join(s3_path, \"processed_#{order_number}.zip\")\n\t\t\torig_s3_zip_path = File.join(s3_path, zip)\n\t\t\t\n\t\t\tbegin\n\t\t\t\tAWS::S3::S3Object.store(s3_zip_path, open(tmp_zip_path), s3_bucket)\n\t\t\t\tif order_hash[:mode] == 'stress'\n\t\t\t\t\tAWS::S3::S3Object.copy(s3_orig_path, orig_s3_zip_path, s3_bucket)\n\t\t\t\telse\n\t\t\t\t\tAWS::S3::S3Object.rename(s3_orig_path, orig_s3_zip_path, s3_bucket)\n\t\t\t\tend\n\t\t\t\tstatus_hash[:s3_move_status] = 1\n\t\t\t\tstatus_hash[:msg] = 'files moved to s3 processed folder'\n\t\t\trescue AWS::S3::NoSuchKey\n\t\t\t\tstatus_hash[:status] = 1\n\t\t\t\tstatus_hash[:msg] = 'received order zip not found on s3'\n\t\t\tend\n\t\t\n\t\telsif status_hash[:status] == 3\n\t\t\ts3_path = File.join(s3_finish_path, 'failure', order_number)\n\t\t\ts3_zip_path = File.join(s3_path, zip)\n\t\t\tbegin\t\t\t\t\n\t\t\t\tif order_hash[:mode] == 'stress'\n\t\t\t\t\tAWS::S3::S3Object.copy(s3_orig_path, s3_zip_path, s3_bucket)\n\t\t\t\telse\n\t\t\t\t\tAWS::S3::S3Object.rename(s3_orig_path, s3_zip_path, s3_bucket)\n\t\t\t\tend\n\t\t\t\tstatus_hash[:s3_move_status] = 1\n\t\t\t\tstatus_hash[:msg] = 'files moved to s3 failure folder'\n\t\t\trescue\n\t\t\t\tstatus_hash[:status] = 1\n\t\t\t\tstatus_hash[:msg] = 'received order zip not found on s3'\n\t\t\tend\n\t\tend\n\t\t\n\t\tif status_hash[:status] == 0 && status_hash[:s3_move_status] == 1\n\t\t\tstatus_hash[:s3_move_msg] = 'processed order zip moved to processed folder'\n\t\telsif status_hash[:status] == 1 && status_hash[:s3_move_status] == 1\n\t\t\tstatus_hash[:s3_move_msg] = 'received order zip moved to failure folder'\n\t\telse\n\t\t\tstatus_hash[:s3_move_msg] = 'no s3 files were moved'\t\n\t\tend\n\n\t\tFileUtils.rm_rf(tmp_path)\n\tend",
"def push_dir(sftp_session, remote_path, local_path, delete, sync_data)\n\n @log.debug(\"Pushing dir #{local_path}\")\n \n # make sure the remote path exists\n begin\n\n sftp_session.dir.entries(remote_path)\n rescue\n\n # we block on the directory creation because we'll need it as\n # soon as this call returns\n sftp_session.mkdir!(remote_path)\n end\n\n # move our local file pointer to the local path\n FileUtils.cd(local_path)\n\n # get a list of our remote files\n remote_entries = sftp_session.dir.glob(remote_path, \"*\")\n\n # a list of items in this directory that we have handled\n handled_remote_entry_paths = Array.new\n\n # enumerate the local directory\n Dir.glob(\"*\").each do |local_entry|\n\n # don't sync the link to the local or parent directory\n if(local_entry != \".\" && local_entry != \"..\")\n\n # compute the local and remote paths\n local_entry_path = local_path + \"/\" + local_entry\n remote_entry_path = remote_path + \"/\" + local_entry\n\n if File.directory?(local_entry_path)\n\n push_dir(sftp_session, remote_entry_path, local_entry_path, delete,\n sync_data)\n else\n\n push_file(sftp_session, remote_entry_path, local_entry_path,\n sync_data)\n end\n\n # add the remote path to our list of handled paths\n handled_remote_entry_paths << remote_entry_path\n end\n end\n\n # handle the deletion of stale remote files and directories\n if delete\n\n # loop through the remote entries\n remote_entries.each do |remote_entry|\n\n # compute the remote path\n remote_entry_path = remote_path + \"/\" + remote_entry.name\n\n # check to see if we have handled this path\n if !handled_remote_entry_paths.include?(remote_entry_path)\n\n # this entry wasn't on the local side, delete it\n if remote_entry.directory?\n\n remove_dir(sftp_session, remote_entry_path, nil)\n else\n\n remove_file(sftp_session, remote_entry_path, nil)\n end\n end\n end\n end\n\n @log.debug(\"Pushed dir #{local_path}\")\n end",
"def store_backup\n ret = true\n base = Util.data_path(EMMConfig[\"DATA_BACK_DIR\"])\n $files.each do |f|\n # directory of the file \n # LSMSS10, LSMSS30 , etc\n dir = File.basename(File.expand_path(\"#{f}/..\"))\n back_path = base + \"/\" + dir + \"/\" + File.basename(f)\n cmd = \"mv #{f} #{back_path}\"\n unless system(cmd)\n $stderr.puts \"Move #{cmd} did not work ... Next\" if $opts[:v]\n ret = false\n next\n end\n\n # compress the file\n cmd = EMMConfig[\"COMPRESS\"] + \" #{back_path}\"\n unless system(cmd)\n $stderr.puts \"Compress #{cmd} did not work ... Next\" if $opts[:v]\n ret = false\n next\n end\n end \n ret\nend",
"def check_files\n updated = []\n files.each do |filename, mtime| \n begin\n current_mtime = File.stat(filename).mtime\n rescue Errno::ENOENT\n # file was not found and was probably deleted\n # remove the file from the file list \n files.delete(filename)\n next\n end\n if current_mtime != mtime \n updated << filename\n # update the mtime in file registry so we it's only send once\n files[filename] = current_mtime\n puts \"quick_serve: spotted change in #{filename}\"\n end\n end\n QuickServe::Rails::Snapshot.reset if updated != []\n false\n end",
"def scan_dir(path)\n old_files = dir_entries(@old_base, path)\n new_files = dir_entries(@new_base, path)\n old_files.each do |fname, type|\n unless new_files.has_key?(fname) && new_files[fname] == type\n delete_dir(path + fname + '/') if type == :directory && !@options[:shallow]\n @entries << [path + fname, type, :deleted]\n end\n end\n new_files.each do |fname, type|\n if old_files.has_key?(fname) && old_files[fname] == type\n if type == :directory\n scan_dir(path + fname + '/')\n else\n compare_file(path + fname, type)\n end\n else\n @entries << [path + fname, type, :added]\n add_dir(path + fname + '/') if type == :directory && !@options[:shallow]\n end\n end\n end",
"def upload_maildir(source_dir)\n Dir.new(source_dir).each do |f|\n next if f == '.' || f == '..'\n path = File.join(source_dir, f)\n if File.file?(path)\n upload_mail_file(path)\n elsif File.directory?(path) && !is_apple_mail?\n # Recurse. \n upload_maildir(path)\n end\n end\n end",
"def pre_sync\n #move\n end",
"def using_nfs?\n !!synced_folders(@machine)[:nfs]\n end",
"def test_move_between_locks_tagged\n setup_hr\n new_coll('httplock/hr/archives/resumes')\n\n resumes_locktoken = lock('httplock/hr/recruiting/resumes',\n :depth => RubyDav::INFINITY).token\n archives_locktoken = lock('httplock/hr/archives',\n :depth => RubyDav::INFINITY).token\n\n bad_if = {\n 'httplock/hr/recruiting/resumes/harry' => archives_locktoken,\n 'httplock/hr/archives/resumes' => resumes_locktoken\n }\n\n assert_hr_move_response '412', bad_if\n\n good_if = {\n 'httplock/hr/recruiting/resumes/harry' => resumes_locktoken,\n 'httplock/hr/archives/resumes' => archives_locktoken\n }\n\n assert_hr_move_response '201', good_if\n\n # cleanup\n unlock('httplock/hr/recruiting/resumes', resumes_locktoken)\n unlock('httplock/hr/archives', archives_locktoken)\n delete_coll 'httplock'\n end",
"def share_folders(folders)\n end",
"def copy_files\n source_dir = Item.new(Path.new(params[:source]))\n dest_dir = Item.new(Path.new(params[:dest]))\n type = params[:type]\n response = {}\n response[:source_dir] = source_dir\n response[:dest_dir] = dest_dir\n if source_dir.copy_files_to(dest_dir, type)\n response[:msg] = \"Success\"\n else\n response[:msg] = \"Fail\"\n end\n render json: response\n end",
"def update_dir\n was_changed = false\n\n # monitor existing and absent files\n @files.each_value do |file|\n file.monitor\n\n if file.state == FileStatEnum::NON_EXISTING\n was_changed = true\n rm_file(file)\n end\n end\n\n @dirs.each_value do |dir|\n dir.monitor\n\n if dir.state == FileStatEnum::NON_EXISTING\n was_changed = true\n rm_dir(dir)\n end\n end\n\n was_changed = was_changed || glob_me\n\n return was_changed\n end",
"def compare_file(a, b)\r\n return false unless File.size(a) == File.size(b)\r\n File.open(a, 'rb') {|fa|\r\n File.open(b, 'rb') {|fb|\r\n return compare_stream(fa, fb)\r\n }\r\n }\r\n end",
"def can_move?(*args)\n index,dir = process_move_args(*args)\n self[index].travels?(dir) && self[index + MOVE[dir]].empty?\n end",
"def ensure_not_in_dest; end",
"def test_move_file_in_subdirectory\n `touch ../harness/test/new/foo`\n nd = TestDirectory.new \"../harness/test/new\"\n assert(nd.files.find \"foo\")\n @td.move(:foo, :new, :unclassified)\n assert(File.exist?(\"../harness/test/unclassified/foo\"))\n assert(!File.exist?(\"../harness/test/new/foo\"))\n end",
"def check_directory(remote_dir, sftp)\r\n \tbegin\r\n \t\tsftp.stat(remote_dir)\r\n\trescue Net::SFTP::Operations::StatusException => e \r\n\t\traise unless e.code == 2\r\n\t\t# directory doesn't exist on remote, so create it\r\n\t\tputs \"Creating directory #{remote_dir}\"\r\n\t\tsftp.mkdir(remote_dir, :permissions => DIR_PERM)\r\n\tend \t\r\nend",
"def compare_to(other, skip=[])\n common = []\n unique = []\n #p [\"skip:\", skip.size]\n #p [\"first few:\", skip[0..10]]\n \n skip = Set.new(skip.map{|p| p.path})\n \n name_to_path.each do |name, path|\n size = path_to_size[path]\n\n opath_samesize = other.size_to_path[size]\n opath_samename = other.name_to_path[name] \n\n next if skip.include? opath_samename or skip.include? opath_samesize\n\n r = Result.new(root, path)\n\n if opath_samesize and opath_samename\n # same size, same name\n common << r\n\n elsif opath_samename\n # same name, different content\n osize = other.path_to_size[opath_samename]\n diff = (size - osize).abs\n r.message = \"#{diff} bytes #{size > osize ? \"<light_green>larger</light_green>\" : \"<light_red>smaller</light_red>\"}\"\n unique << r\n\n elsif opath_samesize\n # same size, different name\n if OPTIONS.verbose\n puts \"<yellow>* Size matches, comparing content:\\n <light_cyan>#{path}\\n <light_white>#{opath_samesize}\".colorize\n end\n\n if content_probably_matches?(path, opath_samesize)\n # same content (probably)\n oname = File.split(opath_samesize).last\n r.message = \"other name: #{oname}\"\n common << r\n else\n # different content\n unique << r\n end\n\n puts if OPTIONS.verbose\n \n else\n\n unique << r\n\n end\n end\n \n [common, unique]\n end",
"def sync_down\n existing = list_files\n new_objects = []\n self.objects.each do |obj|\n filename = filename_from_key(obj.key)\n existing.delete( filename )\n file = directory + filename\n if !File.exists?(file)\n puts \"Downloading file #{file} with key #{obj.key})\"\n new_objects << s3_client.get_object({ bucket: bucket, key: obj.key }, target: directory + filename_from_key(obj.key) )\n end\n end\n\n existing.each do |file|\n puts \"Deleting file #{file}\"\n File.delete( directory + file )\n end\n\n # Return true if the directory changed\n (new_objects.count > 0) || (existing.count > 0)\n end",
"def synced_folders(vm, host, global)\n if folders = get_config_parameter(host, global, 'synced_folders')\n folders.each do |folder|\n vm.synced_folder folder['src'], folder['dest'], folder['options']\n end\n end\nend",
"def share_folders(prefix, folders)\n folders.each do |type, local_path, remote_path|\n if type == :host\n env[:machine].config.vm.share_folder(\n \"v-#{prefix}-#{self.class.get_and_update_counter(:shared_folder)}\",\n remote_path, local_path, :nfs => config.nfs)\n end\n end\n end",
"def uploadDir(localDir, denyFilters = nil, allowFilters = nil)\n localDirWithSeparatorSuffix = File.expand_path(localDir) << File::SEPARATOR\n dirUtil = Embbox::DirUtil.new(@log)\n\n pids = []\n maxProcesses = 30\n\n ignoredFiles = dirUtil.walk(localDir, denyFilters, allowFilters) do |file|\n remotePath = file.gsub(localDirWithSeparatorSuffix, '')\n # @log.debug(@logPrefix) {\" Include : '#{remotePath}'\"} \n #uploadFile(file, remotePath)\n\n pid = uploadFileAsync(file, remotePath)\n pids.push(pid)\n puts \"PID LIST:\\n #{pids.join(\",\")}\"\n while (pids.length >= maxProcesses)\n waitedPid = Process.wait\n puts \"Waited for #{waitedPid}\"\n pids.delete(waitedPid)\n end\n end\n \n puts \"Waiting for remaining uploads to finish\"\n Process.waitall\n \n if (ignoredFiles.length > 0)\n ignoredFiles.each do |f|\n @log.info(@logPrefix) {\"* EXCLUDE *: '#{f.gsub(localDirWithSeparatorSuffix, '')}'\"} \n end\n end\n end",
"def shared?\n \t!self.shared_folders.empty?\n end",
"def main\n # check those arguments\n usage if ARGV[0].nil?\n target = ARGV[0].strip\n maildir = \"#{ENV['HOME']}/Library/Mail\"\n maildir = ARGV[1].strip unless ARGV[1].nil?\n puts \"Using source directory of '#{maildir}'...\"\n puts \"Using target directory of '#{target}'...\"\n deliveries = 0\n\n # make the target directory\n File.umask(077)\n FileUtils.mkdir(target)\n\n # for each dir in source dir matching /\\.mbox$/ (recursive)\n $stdout.sync = true\n traverse(maildir, /\\.mbox$/) do |dir|\n d = \"#{dir}/Messages\"\n next unless FileTest.directory?(d)\n new_d = new_maildir(target, maildir, d)\n\n # for each filename matching /\\.emlx$/\n msgs = 0\n Dir.entries(d).each do |file|\n next unless file =~ /\\.emlx$/\n msgs += 1\n\n # load all lines of source file into array\n lines = IO.readlines(\"#{d}/#{file}\")\n\n # remove first line from array\n lines.delete_at(0)\n\n # from the end of the array, look for \"</plist>\"; until we find\n # the matching \"<?xml...>\" line, we drop each line from the\n # array\n raise \"Invalid file format\" unless lines[-1] =~ /^<\\/plist>/\n last = \"\"\n flags = 0\n lines.reverse_each do |line|\n break if last =~ /^<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>/\n if line =~ /<key>flags<\\/key>/\n flags = last.sub(/<integer>/, \"\").sub( /<\\/integer>.*/, \"\").to_i\n end\n last = lines[-1].dup\n lines.delete_at(-1)\n end\n\n # open new Maildir-formatted filename in target dir ($TARGET)\n deliveries += 1\n n = maildirname(deliveries, flags)\n File.open(new_d + \"/\" + n, \"w+\") do |f|\n lines.each { |x| f.print x }\n end\n\n print sprintf(\"\\r%s %d\", \"Converting #{dir}...\", msgs)\n end\n puts unless msgs.zero?\n end\nend",
"def compare_file(a, b)\n return false unless File.size(a) == File.size(b)\n File.open(a, 'rb') {|fa|\n File.open(b, 'rb') {|fb|\n return compare_stream(fa, fb)\n }\n }\n end",
"def in_dest_dir(*paths); end",
"def send_files(type, server)\n raise \"No server given\" if !server\n FileUtils.mkdir_p \"./uploads/#{type}\"\n system \"rsync --progress -rue 'ssh -p #{ssh_port(server)}' uploads/#{type} #{server.user}@#{server.hostname}:#{shared_path}/uploads/\"\n end",
"def get_remote_files\n manager = @current_source.file_manager\n manager.start do \n @current_source.folders.each do |folder|\n @files[folder] = manager.find_files folder\n @files[folder] = @files[folder].take(@take) if @take\n Logger.<<(__FILE__,\"INFO\",\"Found #{@files[folder].size} files for #{@current_source.base_dir}/#{folder} at #{@current_source.host.address}\")\n SignalHandler.check\n end\n end\n end",
"def createFolders(path)\n #timeutc = @update_timestamp.utc\n update_ts=@update_timestamp.to_s()\n update_ts=update_ts.split(\" +\").first\n update_ts = update_ts.gsub(\":\",\"-\")\n update_ts = update_ts.gsub(\" \",\"_\")\n\n # Create root diff folder\n difFolder=path+\"diff_folder/\"\n if !(File.directory?(difFolder))\n Dir.mkdir(difFolder)\n end\n\n # Create book diff folder\n @book_diff_folder=difFolder+update_ts+\"/\"\n if File.directory?(@book_diff_folder)\n FileUtils.rm_rf(@book_diff_folder)\n #File.rename(@book_diff_folder, @book_diff_folder+\"-OLD_\"+current_ts)\n end\n Dir.mkdir(@book_diff_folder)\n \n # Create update root folder\n @updateFolder=path+@book_full_name+\"_update/\"\n if !(File.directory?(@updateFolder))\n Dir.mkdir(@updateFolder)\n end\n \n # Create update book folder\n @book_update_folder=@updateFolder+update_ts+\"/\"\n if File.directory?(@book_update_folder)\n #File.rename(@book_update_folder, @book_update_folder+\"-OLD_\"+current_ts)\n File.rename(@book_update_folder, @updateFolder+update_ts+\"-OLD\") \n FileUtils.rm_rf(@updateFolder+update_ts+\"-OLD\")\n end \n Dir.mkdir(@book_update_folder)\nend",
"def movePendingFiles(itemID)\n noSplashKey = calcNoSplashKey(itemID)\n\n pvwPfx = getEnv(\"S3_PREVIEW_PREFIX\")\n pvwLin = $s3Bucket.object(\"#{pvwPfx}/#{itemID}/#{itemID}_noSplash_#{noSplashKey}.pdf\")\n pvwSplash = $s3Bucket.object(\"#{pvwPfx}/#{itemID}/#{itemID}.pdf\")\n\n # If there's no preview file to move, we have nothing to do\n pvwLin.exists? or return\n\n # Move the preview splash file, if present\n contentPfx = getEnv(\"S3_CONTENT_PREFIX\")\n if pvwSplash.exists?\n newSplash = $s3Bucket.object(\"#{contentPfx}/#{itemID}/#{itemID}.pdf\")\n puts \" movePending: copying #{pvwSplash.key} to #{newSplash.key}\"\n copyContentFile(itemID, pvwSplash, newSplash)\n pvwSplash.delete\n end\n\n # Move the linearized file\n newLin = $s3Bucket.object(\"#{contentPfx}/#{itemID}/#{itemID}_noSplash_#{noSplashKey}.pdf\")\n puts \" movePending: copying #{pvwLin.key} to #{newLin.key}\"\n copyContentFile(itemID, pvwLin, newLin)\n pvwLin.delete\nend",
"def move_folder_ind\n create_process(process: \"MOVE_FOLDER\")\n end"
] | [
"0.6007712",
"0.5982647",
"0.5902136",
"0.58897376",
"0.58830637",
"0.5802409",
"0.5801397",
"0.5757566",
"0.5729186",
"0.5717225",
"0.570425",
"0.5701741",
"0.5680437",
"0.5655928",
"0.56456745",
"0.5637089",
"0.56067216",
"0.5591601",
"0.5558157",
"0.5543967",
"0.5532435",
"0.5520261",
"0.55144674",
"0.5473697",
"0.5471252",
"0.54625225",
"0.5460095",
"0.5432027",
"0.54300344",
"0.54098094",
"0.5395959",
"0.53927225",
"0.5392008",
"0.53843516",
"0.53700787",
"0.5350574",
"0.5342697",
"0.5342473",
"0.53420377",
"0.534056",
"0.5335966",
"0.5331155",
"0.5321645",
"0.53081816",
"0.5300002",
"0.52773786",
"0.5265766",
"0.52629966",
"0.52503645",
"0.523474",
"0.5190296",
"0.5189601",
"0.51822376",
"0.5171418",
"0.51613474",
"0.51555735",
"0.5151726",
"0.515081",
"0.51461595",
"0.51447207",
"0.5131513",
"0.51185846",
"0.5114562",
"0.51130545",
"0.51100934",
"0.5104554",
"0.51014626",
"0.50989187",
"0.50878394",
"0.5078668",
"0.5074382",
"0.5070467",
"0.5070064",
"0.50690275",
"0.50654703",
"0.5064461",
"0.50628555",
"0.50606024",
"0.50578517",
"0.5056236",
"0.50558126",
"0.5055085",
"0.50532556",
"0.50530815",
"0.5044227",
"0.5043615",
"0.50435996",
"0.5043148",
"0.5041281",
"0.503968",
"0.5035442",
"0.5031544",
"0.50255805",
"0.5023531",
"0.5022573",
"0.5020667",
"0.50129247",
"0.5012408",
"0.50120497",
"0.50069296"
] | 0.5997536 | 1 |
Checks that inbox and processed directories are on the same volume | def register_defaults_for_inbox(inboxpath)
if processed then # If there is a default set for processed...
if not Pathstring.new(inboxpath).volume == Pathstring.new(processed).volume then # ...and it's not on the same volume as inboxpath
raise "Both inbox and processed directories must be on same volume."
end
end
@defaults.registerDefaults(:inbox => File.expand_path(inboxpath))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_defaults_for_processed(target_dir)\n if Pathstring.new(inbox).volume == Pathstring.new(target_dir).volume then\n @defaults.registerDefaults(:processed => Pathstring.new(target_dir) )\n else\n raise \"Both inbox and processed directories must be on same volume.\"\n end\n end",
"def check_directories\n new_file_names = {}\n DirmonEntry.enabled.each do |entry|\n entry.each do |pathname|\n # BSON Keys cannot contain periods\n key = pathname.to_s.tr('.', '_')\n previous_size = previous_file_names[key]\n size = check_file(entry, pathname, previous_size)\n new_file_names[key] = size if size\n end\n end\n self.previous_file_names = new_file_names\n end",
"def check_directories\n if File.exist?(source_dir)\n @source_dir = source_dir\n else\n raise DirectoryNotExist, \"Directory not exist\" \n end\n if File.exist?(destination_dir)\n @destination_dir = destination_dir\n else\n raise DirectoryNotExist, \"Directory not exist\" \n end \n end",
"def check()\n # check if teh volume still exists\n begin\n volumes = $ec2.describe_volumes([self.id])\n rescue RightAws::AwsError\n if $!.errors[0][0] == \"InvalidVolume.NotFound\"\n puts \"WARN: Volume #{self.id} is not running\"\n delete()\n return\n else\n p $!.code\n end\n end\n\n # check that it is attached\n if volumes[0][:aws_attachment_status] == 'attached'\n if self.attached_instance != volumes[0][:aws_instance_id]\n self.attached_instance = volumes[0][:aws_instance_id]\n self.save()\n puts \"WARN: volume #{self.id} is now attached to #{self.attached_instance}\"\n end\n elsif self.attached_instance.nil?\n puts \"WARN: volume #{self.id} is no longer attached\"\n self.attached_instance = nil\n self.save()\n end\n end",
"def verify_mount_count\n @mounted_partitions.length\n end",
"def using_nfs?\n !!synced_folders(@machine)[:nfs]\n end",
"def shared?\n \t!self.shared_folders.empty?\n end",
"def reshare dir, host\n if File.exist? \"#{dir}/#{host}/.completed\"\n `share -F nfs -o ro=#{host},anon=0 #{dir}/#{host} > /dev/null 2>&1`\n end\nend",
"def check_folder_contents(query)\n if (system(\"[ -d #{query} ]\"))\n puts(\"Error in current directory: #{query} already exists.\")\n false\n else\n true\n end\n end",
"def folder_reachable?\n Dir.exists? folder_path\n end",
"def shared? \n \t!self.shared_folders.empty? \n\tend",
"def mountpoint?\n begin\n stat1 = self.lstat\n stat2 = self.parent.lstat\n stat1.dev == stat2.dev && stat1.ino == stat2.ino ||\n stat1.dev != stat2.dev\n rescue Errno::ENOENT\n false\n end\n end",
"def update_dir\n was_changed = false\n\n # monitor existing and absent files\n @files.each_value do |file|\n file.monitor\n\n if file.state == FileStatEnum::NON_EXISTING\n was_changed = true\n rm_file(file)\n end\n end\n\n @dirs.each_value do |dir|\n dir.monitor\n\n if dir.state == FileStatEnum::NON_EXISTING\n was_changed = true\n rm_dir(dir)\n end\n end\n\n was_changed = was_changed || glob_me\n\n return was_changed\n end",
"def verify_src_dest_dir_paths\n unless File.exists?(@era_root_dir_path) && File.directory?(@era_root_dir_path)\n STDERR.puts \"Source directory does not exist:\\n '#{@era_root_dir_path}'\"\n exit 2\n end\n if File.exists?(@era_root_dir_path_dest)\n STDERR.puts \"Destination directory or file already exists:\\n '#{@era_root_dir_path_dest}'\"\n exit 3\n end\n end",
"def guess_usb_volume( dirs_to_sync )\n volumes = Dir.entries(@usb_volumes_dir).reject do |f|\n f.match(/\\.\\.?/) \n end\n volumes.sort_by { |v|\n puts \"Checking volume #{v}\"\n dirs_to_sync.select{ |dts|\n File.directory?( File.join(@usb_volumes_dir, usb, dts))\n }.size\n }[0]\n end",
"def validate_directory_structure\n return false unless File.exists? @root\n Find.find(@root) do |path|\n stat = File::Stat.new path\n return false unless stat.uid == OWNER and stat.gid == GROUP\n if File.directory? path\n return false unless stat.mode == DIRMODE\n else\n return false unless stat.mode == FILEMODE\n end\n end\n true\n end",
"def check_files\n updated = []\n files.each do |filename, mtime| \n begin\n current_mtime = File.stat(filename).mtime\n rescue Errno::ENOENT\n # file was not found and was probably deleted\n # remove the file from the file list \n files.delete(filename)\n next\n end\n if current_mtime != mtime \n updated << filename\n # update the mtime in file registry so we it's only send once\n files[filename] = current_mtime\n puts \"quick_serve: spotted change in #{filename}\"\n end\n end\n QuickServe::Rails::Snapshot.reset if updated != []\n false\n end",
"def perform\n check_directories\n end",
"def outside_configured_directory?(dir); end",
"def mountpoint?\n begin\n stat1 = lstat\n stat2 = parent.lstat\n stat1.dev != stat2.dev or stat1.ino == stat2.ino\n rescue Errno::ENOENT\n false\n end\n end",
"def delete_empty_upstream_dirs\n path = ::File.expand_path(store_dir, root)\n Dir.delete(path) # fails if path not empty dir\n\n path = ::File.expand_path(base_store_dir, root)\n Dir.delete(path) # fails if path not empty dir\n rescue SystemCallError\n true # nothing, the dir is not empty\n end",
"def has_valid_owners_for_all_files?\n num_owned_by_wlmaster = num_files_owned_by_user('wlmaster')\n num_owned_by_wluser = num_files_owned_by_user('wluser')\n num_total = num_files_total\n # if all the files are owned by either 'wlmaster' or 'wluser', then\n # num_total must be equal to the sum of num_owned_by_wlmaster and num_owned_by_wluser.\n # If this condition is not matched, that means, there is at least one file\n # or directory, which is not owned by either of them.\n num_total == (num_owned_by_wlmaster + num_owned_by_wluser)\n end",
"def dir_forbidden?\n File.stat(run_dir).mode.to_s(8) == \"100000\" || File.stat(run_dir).mode.to_s(8) == \"40000\"\n end",
"def compareDirs( relative = \"\" )\n # Combine the base path with the relative path\n original = File.expand_path( File.join( $original, relative ) )\n backup = File.expand_path( File.join( $backup, relative ) )\n\n # Return if this directory has been excluded\n if $options[:ignore].include?( original ) or $options[:ignore].include?( backup )\n $skippedCount += 1\n STDOUT.puts \"SKIP: Skipping comparison of [#{original}] and [#{backup}]\"\n return\n end\n\n # Make sure both directories exist\n unless File.directory?( original ) and File.directory?( backup )\n STDOUT.puts \"DIR: [#{original}] not found in [#{backup}]\"\n $diffCount += 1\n $diffCount += countItems( original ) if $options[:count]\n return\n end\n\n # If both directories exist, we check their contents\n begin\n Dir.foreach( original ) do |item|\n next if item == \".\" or item == \"..\"\n $itemCount += 1\n\n origPath = File.join( original, item )\n backupPath = File.join( backup, item )\n\n if File.directory? origPath\n # Skip symlinks if told to do so...\n if File.symlink?( origPath ) and not $options[:follow]\n $skippedCount += 1\n STDOUT.puts \"SYMLINK: [#{origPath}] skipped.\"\n next\n end\n # Stay on one filesystem if told to do so...\n outerDev = File::Stat.new( original ).dev\n innerDev = File::Stat.new( origPath ).dev\n if outerDev != innerDev and $options[:one_filesystem]\n $skippedCount += 1\n STDOUT.puts \"DIFFFS: [#{origPath}] is on a different file system. Skipped.\"\n next\n end\n compareDirs( File.join( relative, item ) )\n else # It's a file\n unless sameFile( origPath, backupPath )\n $diffCount += 1\n STDOUT.puts \"FILE: [#{origPath}] not found at, or doesn't match [#{backupPath}]\"\n end\n end\n end # Dir.foreach\n rescue Errno::EACCES\n STDOUT.puts \"ERROR: Can't read directory [#{original}]\"\n $errorCount += 1\n end\nend",
"def mountpoint?\n begin\n stat1 = expand_tilde.lstat\n stat2 = expand_tilde.parent.lstat\n stat1.dev == stat2.dev && stat1.ino == stat2.ino ||\n stat1.dev != stat2.dev\n rescue Errno::ENOENT\n false\n end\n end",
"def check_snapshot_folder\n Dir.mkdir(snapshot_folder_path) unless Dir.exists?(snapshot_folder_path)\n end",
"def check_dvd_env\n [\"#{@dvd_src}/isolinux\",\"#{@dvd_src}/ks\"].each do |dir|\n File.directory?(dir) or raise \"Environment not suitable: Unable to find directory '#{dir}'\"\n end\n end",
"def sync_dir dir\n # TODO: think of a better name scheme\n # maybe the title should include the relative path?\n calculated_photoset_name = \"[ruphy-backup] #{dir}\"\n Dir.chdir @root + '/' + dir\n\n if photoset_exist? calculated_photoset_name\n #sync\n flickr_list = get_file_list calculated_photoset_name\n local_list = Dir[\"*\"]\n remotely_missing = []\n locally_missing = []\n \n local_list.each do |f|\n remotely_missing << f unless flickr_list.include? f\n end\n# puts \"remotely missing files: \" + remotely_missing.join(',')\n \n remotely_missing.each do |f|\n upload f, calculated_photoset_name\n end\n \n \n flickr_list.each do |f|\n locally_missing << f unless local_list.include? f\n end\n puts \"we're locally missing: \" + locally_missing.join(', ')\n \n # TODO: really perform sync\n \n else\n # set not existing: just upload\n Dir[\"*\"].each do |f|\n upload f, calculated_photoset_name\n end\n end\n end",
"def sync!\n\n destfiles = begin \n FsShellProxy.new.ls(@dest, true) \n rescue NoSuchFile \n {}\n end\n results = HSync::compare(LocalFs.new.ls(@source, true), destfiles)\n push_files(results.files_missing_in_b)\n # push_files(results.files_newer_in_a) # todo\n end",
"def analyze_dirs(dir_to_analyze, parent)\n\n\n # bootstrap case\n # don't create an entry for the root because there's nothing to link to yet, scan the subdirs\n if (dir_to_analyze == self.target_volume)\n # puts \"Dir to analyze is the target volume\"\n # run on all child dirs, not this dir\n Dir.entries(dir_to_analyze).reject {|d| d.start_with?('.')}.each do |name|\n # puts \"\\tentry: >#{file}<\"\n full_path = File.join(dir_to_analyze, name)\n if (Dir.exist?(full_path) && !File.symlink?(full_path))\n # puts \"Contender: >#{full_path}<\"\n analyze_dirs(full_path, self.dir_tree)\n end\n end\n return\n end\n\n # use \"P\" to help prevent following any symlinks\n cmd = \"du -sxkP \\\"#{dir_to_analyze}\\\"\"\n puts \"\\trunning #{cmd}\"\n output = `#{cmd}`.strip().split(\"\\t\")\n # puts \"Du output:\"\n # pp output\n size = output[0].to_i \n size_gb = \"#{'%.0f' % (size.to_f / 1024 / 1024)}\"\n # puts \"Size: #{size}\\nCapacity: #{self.diskhash['/']['capacity']}\"\n\n # Occupancy as a fraction of total space\n # occupancy = (size.to_f / self.capacity.to_f)\n\n # Occupancy as a fraction of USED space\n occupancy = (size.to_f / self.used.to_f)\n\n occupancy_pct = \"#{'%.0f' % (occupancy * 100)}\"\n capacity_gb = \"#{'%.0f' % (self.capacity.to_f / 1024 / 1024)}\"\n \n # if this dir contains more than 5% of disk space, add it to the tree\n\n if (dir_to_analyze == self.target_dir)\n # puts \"Dir to analyze is the target dir, space used outside this dir..\"\n # account for space used outside of target dir\n other_space = self.used - size\n other_space_gb = \"#{'%.0f' % (other_space / 1024 / 1024)}\"\n parent.children.push(DirNode.new(parent, self.target_volume, 'Other Space', other_space_gb))\n end\n \n \n if (occupancy > self.threshold_pct)\n # puts \"Dir contains more than 5% of disk space: #{dir_to_analyze} \\n\\tsize:\\t#{size_gb} / \\ncapacity:\\t#{capacity_gb} = #{occupancy_pct}%\"\n puts \"Dir contains more than 5% of used disk space: #{dir_to_analyze} \\n\\tsize:\\t\\t#{size_gb} / \\n\\toccupancy:\\t#{self.used_gb} = #{occupancy_pct}% of used space\"\n\n # puts \"Dir to analyze (#{dir_to_analyze}) is not the target dir (#{self.target_dir})\"\n dirs = dir_to_analyze.split('/')\n \n short_dir = dirs.pop().gsub(\"'\",\"\\\\\\\\'\")\n full_parent = dirs.join('/')\n if (dir_to_analyze == self.target_dir || full_parent == self.target_volume)\n # puts \"Either this dir is the target dir, or the parent is the target volume, make parent the full target volume\"\n short_parent = self.target_volume.gsub(\"'\",\"\\\\\\\\'\")\n else\n # puts \"Neither this dir or parent is the target dir, making parent short\"\n short_parent = dirs.pop().gsub(\"'\",\"\\\\\\\\'\")\n end\n \n\n this_node = DirNode.new(parent, dir_to_analyze, short_dir, size_gb)\n parent.children.push(this_node)\n\n # run on all child dirs\n Dir.entries(dir_to_analyze).reject {|d| d.start_with?('.')}.each do |name|\n full_path = File.join(dir_to_analyze, name)\n # don't follow any symlinks\n if (Dir.exist?(full_path) && !File.symlink?(full_path))\n # puts \"Contender: >#{full_path}<\"\n analyze_dirs(full_path, this_node)\n end\n end\n \n end # occupancy > threshold\n \n end",
"def is_managed_attaching_volume?(mapping)\n return 'attached' == mapping[:management_status] && 'attached' != mapping[:volume_status]\n end",
"def check\n stat = File.stat(directory) if File.exist?(directory)\n if stat\n if stat.directory?\n if !stat.readable?\n mark_message \"Directory '#{directory}' is not readable.\"\n mark_failure\n elsif writable && !stat.writable?\n mark_message \"Directory '#{directory}' is not writable.\"\n mark_failure\n elsif !writable && stat.writable?\n mark_message \"Directory '#{directory}' is writable (undesired).\"\n mark_failure\n else\n mark_message \"Directory '#{directory}' is #{writable ? nil : 'NOT '}writable (as expected).\"\n end\n else\n mark_message \"'#{directory}' is not a directory.\"\n mark_failure\n end\n else\n mark_message \"Directory '#{directory}' does not exist.\"\n mark_failure\n end\n end",
"def watchable_dirs; end",
"def volume_count\n return unless exists?\n Dir.glob(folder_pathname.join(\"**\")).count do |file|\n File.directory?(file)\n end\n end",
"def verify_mounted(partition)\n\treturn `grep partition /proc/mounts | wc -l`.chomp\nend",
"def has_share_access?(folder) \n \n if(!folder) \n return true\n end \n #has share access if the folder is one of one of his own \n return true if self.folders.include?(folder) \n \n #has share access if the folder is one of the shared_folders_by_others \n return true if self.shared_folders_by_others.include?(folder) \n \n #for checking sub folders under one of the being_shared_folders \n return_value = false\n \n folder.ancestors.each do |ancestor_folder| \n \n return_value = self.being_shared_folders.include?(ancestor_folder) \n if return_value #if it's true \n return true\n end\n end\n \n return false\nend",
"def detachvolume\n false\n end",
"def empty?( dir_path )\n connection.nlst( dir_path ).empty?\n end",
"def is_managed_attached_unassigned_volume?(mapping)\n return 'attached' == mapping[:volume_status] && 'attached' == mapping[:management_status]\n end",
"def find_path_validation\n\t\troot_storage_path = Rails.root.join 'public', 'musics', '000', '000'\n\t\tlatest_path = root_storage_path.children.sort.last\n\t\tif Dir.entries(latest_path).last == self.audio_file_name\n\t\t\ttrue\n\t\telse\n\t\t\tself.destroy\n\t\t\tfalse\n\t\tend\n\tend",
"def mounted?(name)\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n system(\"mount | grep #{mount_loc}\")\nend",
"def compareDirs( relative = \"\" )\n # Combine the base path with the relative path\n original = File.expand_path( File.join( $original, relative ) )\n backup = File.expand_path( File.join( $backup, relative ) )\n\n if $options[:verbose]\n STDOUT.puts \"DEBUG: Comparing [#{original}] to [#{backup}]\" \n end\n\n # Return if this directory has been excluded\n if $options[:ignore].include?( original ) or $options[:ignore].include?( backup )\n $skippedCount += 1\n STDOUT.puts \"SKIP: Skipping comparison of [#{original}] and [#{backup}]\"\n return\n end\n\n # Make sure both directories exist\n unless File.directory?( original ) and File.directory?( backup )\n STDOUT.puts \"DIR: [#{original}] not found in [#{backup}]\"\n # The directory not existing counts as one difference.\n $diffCount += 1 \n # Each item in the directory counts as yet another item processed and yet\n # another difference.\n item_count = countItems( original )\n $itemCount += item_count\n $diffCount += item_count\n return\n end\n\n # If both directories exist, we check their contents\n begin\n Dir.foreach( original ) do |item|\n next if item == \".\" or item == \"..\"\n $itemCount += 1\n origPath = File.join( original, item )\n backupPath = File.join( backup, item )\n\n # This check is independent of whether or not the path is a directory or\n # a file. If either is a symlink, make sure they are both symlinks, and\n # that they link to the same thing.\n if File.symlink?( origPath ) || File.symlink?( backupPath )\n if !(File.symlink?( origPath ) && File.symlink?( backupPath )) ||\n File.readlink( origPath ) != File.readlink( backupPath )\n\n STDOUT.puts \"SYMMIS: Symlink mismatch [#{origPath}] and [#{backupPath}]\"\n\n # Count the differing symlink.\n $diffCount += 1\n\n # FIXME: If follow symlinks is on, we want to count everything that\n # was under that missing symlink directory too.\n\n # We know these paths are different, so move on to the next one.\n next\n end\n end\n\n if File.directory? origPath\n # Skip symlinks if told to do so...\n if File.symlink?( origPath ) and not $options[:follow]\n $skippedCount += 1\n STDOUT.puts \"SYMLINK: [#{origPath}] skipped.\"\n next\n end\n # Stay on one filesystem if told to do so...\n outerDev = File::Stat.new( original ).dev\n innerDev = File::Stat.new( origPath ).dev\n if outerDev != innerDev and $options[:one_filesystem]\n $skippedCount += 1\n STDOUT.puts \"DIFFFS: [#{origPath}] is on a different file system. Skipped.\"\n next\n end\n compareDirs( File.join( relative, item ) )\n else # It's a file\n unless sameFile( origPath, backupPath )\n $diffCount += 1\n STDOUT.puts \"FILE: [#{origPath}] not found at, or doesn't match [#{backupPath}]\"\n end\n end\n end # Dir.foreach\n rescue Errno::EACCES\n STDOUT.puts \"ERROR: Can't read directory [#{original}]\"\n $errorCount += 1\n end\nend",
"def test_listedpath\n server = nil\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n\n # create a deep dir\n basedir = tempfile\n testdir = \"#{basedir}/with/some/sub/directories/for/testing\"\n oldfile = File.join(testdir, \"oldfile\")\n assert_nothing_raised {\n system(\"mkdir -p #{testdir}\")\n File.open(oldfile, \"w\") { |f|\n 3.times { f.puts rand(100) }\n }\n @@tmpfiles << basedir\n }\n\n # mounty mounty\n assert_nothing_raised {\n server.mount(basedir, \"localhost\")\n }\n\n list = nil\n # and then check a few dirs\n assert_nothing_raised {\n list = server.list(\"/localhost/with\", :manage, false, false)\n }\n\n assert(list !~ /with/)\n\n assert_nothing_raised {\n list = server.list(\"/localhost/with/some/sub\", :manage, true, false)\n }\n\n assert(list !~ /sub/)\n end",
"def compare_folders(a, b)\n\n puts \"* Comparing contents...\".light_yellow\n puts if OPTIONS.verbose\n \n common_a, unique_to_a = a.compare_to(b)\n common_b, unique_to_b = b.compare_to(a, common_a)\n common = common_a | common_b\n\n puts\n [unique_to_a, common, unique_to_b]\nend",
"def outside_configured_directory?(dir)\n collections_dir = site.config[\"collections_dir\"]\n !collections_dir.empty? && !dir.start_with?(\"/#{collections_dir}\")\n end",
"def check_directory(remote_dir, sftp)\r\n \tbegin\r\n \t\tsftp.stat(remote_dir)\r\n\trescue Net::SFTP::Operations::StatusException => e \r\n\t\traise unless e.code == 2\r\n\t\t# directory doesn't exist on remote, so create it\r\n\t\tputs \"Creating directory #{remote_dir}\"\r\n\t\tsftp.mkdir(remote_dir, :permissions => DIR_PERM)\r\n\tend \t\r\nend",
"def is_unmanageable_volume?(mapping)\n case mapping[:volume_status]\n when 'attached', 'attaching', 'detached', 'detaching'\n false\n else\n true\n end\n end",
"def file_content_match?\n @fixture.full_files.zip(@local.full_files).all? do |fixture_file, local_file|\n if File.directory?(fixture_file)\n File.directory?(local_file)\n else\n !File.directory?(local_file) && IO.read(fixture_file) == IO.read(local_file)\n end\n end\n end",
"def has_share_access?(folder) \n\n # doesn't have share access if folder is nil (i.e., file is top-level)\n return false if folder.nil?\n\n #has share access if the folder is one of one of his own \n return true if self.folders.include?(folder) \n \n #has share access if the folder is one of the shared_folders_by_others \n return true if self.shared_folders_by_others.include?(folder) \n \n #for checking sub folders under one of the being_shared_folders \n return_value = false \n \n folder.ancestors.each do |ancestor_folder| \n \n return_value = self.being_shared_folders.include?(ancestor_folder) \n if return_value #if it's true \n return true \n end \n end \n \n return false \nend",
"def file_exists?(path)\n result = transport.execute(\"ls -d #{path}\", :read_only => true)\n result.exitstatus == 0 && result.stdout != ''\n end",
"def validate_local_files\n expected_user_id = user.id\n uploaded_files.each do |file|\n if file.user_id != expected_user_id\n Rails.logger.error \"User #{user.user_key} attempted to ingest uploaded_file #{file.id}, but it belongs to a different user\"\n return false\n end\n end\n true\n end",
"def mount_files\n Dir.glob('proc/*', base: mountpoint)\n end",
"def take_snapshots\n snapped_volumes = []\n logger.debug \"Issuing sync command\"\n system 'sync'\n\n logger.debug \"Walking attached volumes\"\n attached_volumes.each do |vol|\n dir = device_to_directory device_name vol\n logger.debug \"Found #{vol.id} mounted on #{dir}\"\n unless should_snap vol\n logger.debug \"Skipping #{vol.id}\"\n next\n end\n\n fs_freeze dir if options[:fs_freeze]\n take_snapshot vol\n snapped_volumes.push vol\n fs_unfreeze dir if options[:fs_freeze]\n end\n snapped_volumes\n end",
"def eql?(fs)\n fs.host.eql?(@host) and fs.dir.eql?(@dir) and fs.files.eql?(self.files)\n end",
"def verify_all_remotes\n missing = []\n files = self.study_files.where(queued_for_deletion: false, human_data: false, :parse_status.ne => 'parsing', status: 'uploaded')\n directories = self.directory_listings.are_synced\n all_locations = files.map(&:bucket_location)\n all_locations += directories.map {|dir| dir.files.map {|file| file['name']}}.flatten\n remotes = ApplicationController.firecloud_client.execute_gcloud_method(:get_workspace_files, 0, self.bucket_id)\n if remotes.next?\n remotes = [] # don't use bucket list of files, instead verify each file individually\n end\n all_locations.each do |file_location|\n match = self.verify_remote_file(remotes: remotes, file_location: file_location)\n if match.nil?\n missing << {filename: file_location, study: self.name, owner: self.user.email, reason: \"File missing from bucket: #{self.bucket_id}\"}\n end\n end\n missing\n end",
"def scan_dir(path)\n old_files = dir_entries(@old_base, path)\n new_files = dir_entries(@new_base, path)\n old_files.each do |fname, type|\n unless new_files.has_key?(fname) && new_files[fname] == type\n delete_dir(path + fname + '/') if type == :directory && !@options[:shallow]\n @entries << [path + fname, type, :deleted]\n end\n end\n new_files.each do |fname, type|\n if old_files.has_key?(fname) && old_files[fname] == type\n if type == :directory\n scan_dir(path + fname + '/')\n else\n compare_file(path + fname, type)\n end\n else\n @entries << [path + fname, type, :added]\n add_dir(path + fname + '/') if type == :directory && !@options[:shallow]\n end\n end\n end",
"def eponymous_directory?\n if !path.end_with?(\"/#{@app.config[:index_file]}\") && destination_path.end_with?(\"/#{@app.config[:index_file]}\")\n return true\n end\n\n @app.files.by_type(:source).watchers.any? do |source|\n (source.directory + Pathname(eponymous_directory_path)).directory?\n end\n end",
"def check_required_disk_space\n old_data_dir_size = Du.du(old_data_dir)\n # new_data_dir might not exist at the point of making this check.\n # In that case check the first existing directory above it.\n new_dir = dir_or_existing_parent(new_data_dir)\n free_disk_space = Statfs.new(new_dir).free_space\n\n if old_data_dir_size < (free_disk_space * 0.90)\n Chef::Log.info(\"!!!!!!!!!!!!! Old data dir size: #{old_data_dir_size}\")\n Chef::Log.info(\"Free disk space: #{free_disk_space}\")\n Chef::Log.info('Free space is sufficient to start upgrade')\n true\n else\n Chef::Log.fatal('Insufficient free space on disk to complete upgrade.')\n Chef::Log.fatal(\"The current postgresql data directory contains #{old_data_dir_size} KB of data but only #{free_disk_space} KB is available on disk.\")\n Chef::Log.fatal(\"The upgrade process requires at least #{old_data_dir_size / 0.90} KB.\")\n raise 'Insufficient Disk Space to Upgrade'\n end\n end",
"def is_unmanaged_attached_volume?(mapping)\n case mapping[:volume_status]\n when 'attached', 'attaching'\n mapping[:management_status].nil?\n else\n false\n end\n end",
"def file_diff(package, from, to, file)\n ret = true\n Dir.mktmpdir {|tmpdir| \n files_found = system(\"cd #{tmpdir} && #{osc_cmd} co #{from} #{package} #{file} && mv #{file} #{file}.new && #{osc_cmd} co #{to} #{package} #{file} >/dev/null 2>&1\")\n unless files_found\n puts \"=== Cannot check out file #{file} from package #{package}\"\n ret = true\n else\n ret = ! system(\"cd #{tmpdir} && diff #{file} #{file}.new\")\n end\n }\n ret\nend",
"def directory?(path)\n\t\t@connection.directory?(path)\n\tend",
"def share_folder(location, name, box)\n if location\n box.vm.share_folder(name, name, location, :nfs => true)\n end\nend",
"def has_local_match?(files)\n files.each do |file|\n return true if self.drive_path == file.sub_path\n end\n false\n end",
"def nfs?\n false\n end",
"def exam_been_uploaded?\n self.split_pdf_logs.exists?\n end",
"def check_required_disk_space\n old_data_dir_size = Du.du(old_data_dir)\n # new_data_dir might not exist at the point of making this check.\n # In that case check the first existing directory above it.\n new_dir = dir_or_existing_parent(new_data_dir)\n free_disk_space = Statfs.new(new_dir).free_space\n\n if old_data_dir_size < (free_disk_space * 0.90)\n Chef::Log.debug(\"Old data dir size: #{old_data_dir_size}\")\n Chef::Log.debug(\" Free disk space: #{free_disk_space}\")\n Chef::Log.debug('Free space is sufficient to start upgrade')\n true\n else\n Chef::Log.fatal('Insufficient free space on disk to complete upgrade.')\n Chef::Log.fatal(\"The current postgresql data directory contains #{old_data_dir_size} KB of data but only #{free_disk_space} KB is available on disk.\")\n Chef::Log.fatal(\"The upgrade process requires at least #{old_data_dir_size / 0.90} KB.\")\n raise 'Insufficient Disk Space to Upgrade'\n end\n end",
"def compare\n\t\t\t\n\t\t\tDir.foreach(@folder1) do |item|\n\t\t\t\tbegin\n \t\t\t\tnext if item == '.' or item == '..'\n \t\t\t\tfullfilename = File.expand_path(@folder1, item)\n \t\t\t\tthe_hash = Digest::MD5.hexdigest(File.read(File.join(File.expand_path(@folder1), item)))\n \t\t\t\titem = item.downcase\n \t\t\t\tfiledata = FileHashResults.new(item, the_hash, nil)\n \t\t\t\t@filehash[item] = filedata\n \t\t\trescue\n \t\t\t #puts \"Skipped:#{item.inspect}\"\n \t\t\tend\n\t\t\tend\n\n\t\t\tDir.foreach(@folder2) do |item|\n\t\t\t begin\n \t\t\t\tnext if item == '.' or item == '..'\n \t\t\t\tthe_hash = Digest::MD5.hexdigest(File.read(File.join(@folder2, item)))\n \t\t\t\titem = item.downcase\n if(@filehash[item]==nil)\n \t\t\t\t\tfiledata = FileHashResults.new(item, nil, the_hash)\n \t\t\t\t\t@filehash[item] = filedata\n \t\t\t\t\tnext\n \t\t\t\tend\n \t\t\t\t@filehash[item.downcase].file_hash2 = the_hash\n \t\t\trescue\n #puts \"Skipped:#{item.inspect}\"\n end\t\n\t\t\tend\n\t\tend",
"def files_differ?(backup_path, restore_path, io)\n !@symlinked && (@backup_directory || @restore_directory || io.read(backup_path) != io.read(restore_path))\n end",
"def should_process? \n #return false if it has been set to skip processing \n return false if self.persistence_checksum.eql?(\"skip\")\n\n #return true if there are different number of craft files than records of craft that are not marked as deleted\n craft_files = campaigns_instance.identify_craft_in(self.name)\n craft = self.craft.where(:deleted => false) #if craft.nil?\n return true if craft_files.map{|k,v| v}.flatten.size != craft.count\n\n #return true if the stored checksum for persistent.sfs does not match the one generated for the current persistent.sfs\n Dir.chdir(self.path)\n return true unless File.exists?(\"persistent.sfs\")\n checksum = Digest::SHA256.file(\"persistent.sfs\").hexdigest\n not checksum.eql?(self.persistence_checksum)\n end",
"def share_folders(prefix, folders)\n folders.each do |type, local_path, remote_path|\n if type == :host\n env[:machine].config.vm.share_folder(\n \"v-#{prefix}-#{self.class.get_and_update_counter(:shared_folder)}\",\n remote_path, local_path, :nfs => config.nfs)\n end\n end\n end",
"def folder_exists?\n empty_name?\n\n if File.exists?(\"#{LOCAL_PATH}/#{@name}\") || File.exists?(\"#{REMOTE_PATH}/#{@name}.git\")\n if File.exists?(\"#{LOCAL_PATH}/#{@name}\")\n print \"Directory `#{@name}` exists in #{LOCAL_PATH}. Pass a new name: \"\n elsif File.exists?(\"#{REMOTE_PATH}/#{@name}.git\")\n print \"Directory `#{@name}.git` exists in #{REMOTE_PATH}. Pass a new name: \"\n end\n\n @name = gets.chomp\n folder_exists?\n end\n\n false\n end",
"def test_mountroot\n server = nil\n assert_nothing_raised {\n\n server = Puppet::Network::Handler.fileserver.new(\n\n :Local => true,\n\n :Config => false\n )\n }\n\n assert_nothing_raised {\n server.mount(\"/\", \"root\")\n }\n\n testdir, pattern, tmpfile = mktestdir\n\n list = nil\n assert_nothing_raised {\n list = server.list(\"/root/#{testdir}\", :manage, true, false)\n }\n\n assert(list =~ pattern)\n assert_nothing_raised {\n list = server.list(\"/root#{testdir}\", :manage, true, false)\n }\n\n assert(list =~ pattern)\n end",
"def run\n local_only_uids = serializer.uids - folder.uids\n return if local_only_uids.empty?\n\n serializer.filter do |message|\n !local_only_uids.include?(message.uid)\n end\n end",
"def local_reqsRW_remote_contended\n obj_ptr_re = /\\[\\d{1},(.*)\\]/\n reqsRW_re = /reqsRW:\\<(.*)\\>/\n contended_re = /contended\\:(.?)\\,/\n count = 0\n $arr_local_store.each do |local_file|\n local_file.each do |line|\n unless line.chomp.empty?\n obj_ptr = line.match(obj_ptr_re)\n reqsRW = line.match(reqsRW_re)\n reqs_arr = reqsRW[1].split(/,/)\n reqs_arr.size.times do |i|\n found = false\n $arr_remote_store[reqs_arr[i].to_i].each do |r_line|\n if r_line.include? obj_ptr[1]\n found = true\n contended = r_line.match(contended_re)\n if contended[1].to_i == 0\n p \"OMG! #{count} has received a request, for object #{obj_ptr[1]} from #{reqs_arr[i].to_i}, but its not conteneded there\"\n end\n end\n end\n if !found and !count.eql?reqs_arr[i].to_i\n p \"OMG! #{count} has received a request, for object #{obj_ptr[1]} from #{reqs_arr[i].to_i}, but remote dir at this host doesn't know\"\n end\n end\n end\n end\n count = count + 1\n end\nend",
"def stubstub(subject)\n if subject.is_a?(Peep::GoproFolder)\n expect(Dir).to receive(:glob).with('/Volumes/*').and_return([\"/Volumes/#{subject.name}\"])\n expect(File).to receive(:directory?).with(\"/Volumes/#{subject.name}\").and_return(true)\n expect(File).to receive(:exist?).with(\"/Volumes/#{subject.name}/DCIM/100GOPRO\").and_return(true)\n expect(File).to receive(:exist?).with(\"/Volumes/#{subject.name}/MISC\").and_return(true) # this just surpresses the logger warning of a missing MISC folder\n end\nend",
"def get_remote_files\n manager = @current_source.file_manager\n manager.start do \n @current_source.folders.each do |folder|\n @files[folder] = manager.find_files folder\n @files[folder] = @files[folder].take(@take) if @take\n Logger.<<(__FILE__,\"INFO\",\"Found #{@files[folder].size} files for #{@current_source.base_dir}/#{folder} at #{@current_source.host.address}\")\n SignalHandler.check\n end\n end\n end",
"def check_OLD\n # Check if we are configured to skip all backup checks\n if @backup_skip_all\n incstatus(\"OK\")\n @short=@backup_skip_all\n return\n end\n\n ## Not skipped, we check backups\n @objects=readObjects(\"backup\")\n\n # Create logdir if it doesn't exist\n FileUtils.mkdir_p @log_dir unless File.directory? @log_dir\n\n ## Initialize to OK since we may skip everything\n incstatus(\"OK\")\n\n ## CHECK CODE \n entries=Hash.new\n # Add mount entries\n entries=get_mounts_to_backup(entries) unless @backup_skip_mounts\n entries=get_lvs_to_backup(entries) unless @backup_skip_lvscan\n puts YAML.dump(entries) if @debug\n entries.values.each do |entry|\n check_entry(entry)\n end\n\n # Set Messages if OK and empty messages\n if status == \"OK\" and @short == \"\"\n @short=\"Everything OK\"\n end\n end",
"def directory_exists_on(host, dir_path)\n if host[:platform].include?('windows')\n dir_path = \"#{dir_path}\\\\\" unless (dir_path[-1].chr == '\\\\')\n\n command = Command.new(%{IF exist \"#{dir_path}\" ( exit 0 ) ELSE ( exit 1 )}, [], { :cmdexe => true })\n else\n command = Command.new(%(test -d \"#{dir_path}\"), [])\n end\n\n return on(host, command, { :accept_all_exit_codes => true }).exit_code.zero?\n end",
"def directory?() end",
"def keep_dirs; end",
"def check_data\n if MissouriDatum.last.new_file\n @downloads.each_with_index do |download, index|\n obj = s3.bucket('missouridata').object(\"new/#{file_names[index]}\")\n @file_status = \"new\"\n puts \"new file\"\n upload(obj, download)\n end\n else \n downloads.each_with_index do |download, index|\n obj = s3.bucket('missouridata').object(\"same/#{file_names[index]}\")\n @file_status = \"same\"\n puts \"same file\"\n upload(obj, download)\n end\n end \n end",
"def share_folders(folders)\n end",
"def folder_exists_in_audio?(folder_name)\n `ls audio/ | grep #{folder_name}`.chomp.length > 0\n end",
"def file_exists?(path)\n result = transport.execute(\"ls -d #{path}\")\n result.exitstatus == 0 && result.stdout != ''\n end",
"def check_for_changes\n\t\t\t# Check on disk changes\n\t\t\tunless @disks[0][:changes] == false\n\t\t\t\t\t$log.info \"Cachefile changed by user. Honoring changes.\"\n\t\t\t\t\t@disks[0][:changes] = false\n\t\t\t\t\twrite_disk_cache\n\t\t\t\t\treturn true\n\t\t\tend\n\t\t\treturn false\n\t\tend",
"def poll_changed_directories\n until stopped\n sleep(latency)\n report_changes\n end\n end",
"def update_limit_check() \n book_size=getFolderSize(@book_prod_folder)\n updates_size=getFolderSize(@updateFolder)\n accepted_size=(book_size*@max_update_limit.to_i())/100\n if(updates_size>accepted_size)\n diff_size=updates_size-accepted_size\n deleteUpdateFolderContents(diff_size)\n end\nend",
"def verify(state)\n transport.connection(state) do |conn|\n\n conn.execute(busser.cleanup_cmd)\n\n busser.sync_files.each do |file|\n conn.upload!(file[:local], file[:remote])\n end\n\n conn.execute(busser.sync_cmd)\n conn.execute(busser.run_cmd)\n\n conn.execute(busser.cleanup_cmd)\n end\n end",
"def ensure_root\n if self.root? and self.root_cfs_directory.blank?\n self.root_cfs_directory = self\n self.save!\n end\n true\n end",
"def is_mounted?(device)\n system(\"grep -q '#{device}' /proc/mounts\")\nend",
"def test_dirs(desc, dir1, dir2)\n\n test_missing_files(desc, dir1, dir2)\n\n dir_files(dir1).each do |file|\n file2 = file.sub(dir1, dir2)\n if File.exist?(file2)\n if diff = diff_file(file, file2)\n @failures << {\n desc: \"#{desc}\\nDiff of file: #{file.sub(dir1+'/', '')}\\n\",\n result: format_diff(diff)\n }\n pout 'F'.red\n else\n pout '.'.green\n end\n end\n end\nend",
"def is_detached_volume?(mapping)\n # detached by volume status unless we have successfully requested attachment\n # and volume status does not yet reflect this change. an unmanaged volume\n # can also be detached.\n return 'detached' == mapping[:volume_status] && 'attached' != mapping[:management_status]\n end",
"def validate_host_volume_paths\n return unless allowed = ENV['KUBERNETES_ALLOWED_VOLUME_HOST_PATHS'].presence\n allowed = allowed.split(\",\").map { |d| File.join(d, '') }\n used = map_attributes([:spec, :volumes, :hostPath, :path], elements: templates).\n flatten(1).compact.map { |d| File.join(d, '') }\n bad = used.select { |u| allowed.none? { |a| u.start_with?(a) } }\n @errors << \"Only volume host paths #{allowed.join(\", \")} are allowed, not #{bad.join(\", \")}.\" if bad.any?\n end",
"def check_files\n @files.delete_if do |file|\n if File.exist? file then\n if File.readable? file then\n false\n else\n warn \"file '#{file}' not readable\"\n\n true\n end\n else\n warn \"file '#{file}' not found\"\n\n true\n end\n end\n end",
"def is_directory?\n files.count > 1\n end",
"def validate_file_entries_absent(key_info, backend_hiera, host)\n errors = []\n key_info.each do |app_id, key_struct|\n root_path = file_root_path_for_app_id(app_id, backend_hiera)\n key_struct.each do |key_type, keys|\n key_root_path = (key_type == 'global') ? \"#{root_path}/globals\" : \"#{root_path}/environments/production\"\n keys.each do |key, key_data|\n key_path = \"#{key_root_path}/#{key}\"\n result = on(host, \"ls -l #{key_path}\", :accept_all_exit_codes => true)\n if result.exit_code == 0\n errors << \"Validation of #{key_path} absence failed: #{result.stdout}\"\n end\n end\n end\n end\n\n if errors.size == 0\n true\n else\n warn('Validation Failures:')\n errors.each do |error|\n warn(\" #{error}\")\n end\n\n false\n end\nend",
"def has_share_access?(folder) \n \t#has share access if the folder is one of one of his own \n \treturn true if self.folders.include?(folder) \n \n \t#has share access if the folder is one of the shared_folders_by_others \n \treturn true if self.shared_folders_by_others.include?(folder) \n \n \t#for checking sub folders under one of the being_shared_folders \n \treturn_value = false\n print folder\n \tfolder.ancestors.each do |ancestor_folder| \n \n \t\treturn_value = self.shared_folders_by_others.include?(ancestor_folder) \n \t\tp ancestor_folder \n if return_value #if it's true \n \t\treturn true\n \t\tend\n \tend\n \n \treturn false\n\tend",
"def send_in_progress?\n !MediaObject.where(locked: true).empty?\n end",
"def check_and_assign_shared_ids_to_shared_folders\n shared_folders = SharedFolder.find_all_by_shared_email(self.email)\n if ! shared_folders.empty?\n shared_folders.each do |shared_folder|\n shared_folder.shared_user_id = self.id\n shared_folder.save\n end\n # if the account has shared folders they were invited, so they\n # don't need administrative activation.\n logger.info \"ACTIVATING ACCOUNT: #{email} has shared folders\"\n self.account_active = 1\n self.save!\n end \n end",
"def mounted?\n !!( attached? && mount_point && File.exists?(mount_point) && current[:mount] == mount_point )\n end"
] | [
"0.6155193",
"0.5775255",
"0.56353587",
"0.5602444",
"0.5589934",
"0.5523069",
"0.55050296",
"0.5474742",
"0.54152274",
"0.5399029",
"0.5394972",
"0.53911865",
"0.53261644",
"0.5310736",
"0.5310015",
"0.5285441",
"0.5280536",
"0.52759796",
"0.52722025",
"0.5251967",
"0.52298254",
"0.5159843",
"0.51410824",
"0.51271516",
"0.51260656",
"0.51167095",
"0.5097123",
"0.5092411",
"0.5089159",
"0.5083805",
"0.50755227",
"0.50628847",
"0.5058666",
"0.505794",
"0.50508016",
"0.5042165",
"0.50239176",
"0.50216216",
"0.5017589",
"0.50172246",
"0.49950752",
"0.49895197",
"0.49876064",
"0.49820134",
"0.49780858",
"0.49674383",
"0.49608657",
"0.49564263",
"0.4954641",
"0.49526772",
"0.49476826",
"0.4933665",
"0.49287874",
"0.49211842",
"0.491568",
"0.49154952",
"0.49134085",
"0.49123383",
"0.49044555",
"0.4903344",
"0.4896295",
"0.48850697",
"0.4879779",
"0.48748842",
"0.48731297",
"0.48704904",
"0.48673242",
"0.4867303",
"0.48672992",
"0.4864281",
"0.48605207",
"0.48591593",
"0.48543268",
"0.48530182",
"0.4852538",
"0.4849506",
"0.48291075",
"0.48191383",
"0.48169515",
"0.4814321",
"0.48111975",
"0.48062354",
"0.48062342",
"0.48017246",
"0.47988424",
"0.47951162",
"0.47860682",
"0.47846422",
"0.47841483",
"0.4783325",
"0.47825924",
"0.47737446",
"0.47729594",
"0.47705913",
"0.47694018",
"0.47653675",
"0.47599825",
"0.47596496",
"0.4758479",
"0.47564307"
] | 0.6028424 | 1 |
def set_preferences end Note that this points to the actual inboxdirectory | def inbox
return @defaults.objectForKey(:inbox)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_config\n @me = current_user\n @profile = Profile.find_by user_id: current_user.id\n @preference = Preference.find_by user_id: current_user.id\n end",
"def set_preferences\n unless current_user.preference\n pref = Preference.create(user_id: current_user.id,theme: \"default-right\",bgcolor: \"white\",rows: 20, wallpaper: false)\n else\n pref = Preference.where(user_id: current_user.id).first\n end\n session[:theme] = pref.theme\n session[:bgcolor] = pref.bgcolor\n session[:rows] = pref.rows\n session[:wallpaper] = pref.wallpaper\n end",
"def update_email_preferences\n prefs = preference_params\n authorize User\n pref = current_user.pref\n # does user not have prefs?\n if pref.blank?\n pref = Pref.new\n pref.settings = {}\n pref.user = current_user\n end\n pref.settings['email'] = booleanize_hash(prefs['prefs'])\n pref.save\n\n # Include active tab in redirect path\n redirect_to \"#{edit_user_registration_path}#notification-preferences\",\n notice: success_message(pref, _('saved'))\n end",
"def po_dir=(dir); end",
"def set_favorite_folder\n self.favorite_folder_id = profile.favorite_folder.id if favorite_folder.nil?\n end",
"def set_user_preferences\n @user_preferences = UserPreferences.find_or_create_by!(:user => current_user)\n end",
"def set_preference\n @preference = @user.preferences.find(params[:id])\n end",
"def init\n super_init\n\n @defaults = OSX::NSUserDefaults.standardUserDefaults\n register_defaults_for_inbox('~/Movies/iTunes-inbox') # Note: The directory for the box\n # will not be created until the program is actually run, so the user can change inbox location in the preferences.\n register_defaults_for_processed( Pathstring.new(@defaults.objectForKey(:inbox)).parent / 'iTunes-processed' ) # This is the location\n # of directories for files that has been processed, converted, failed, etc. Must be on the same volume!\n\n return self\n end",
"def setFolder(folder)\r\n\t\t\t\t\t@folder = folder\r\n\t\t\t\tend",
"def update_prefs\n current_user.preferences = params[:preferences]\n render plain: \"1\"\n end",
"def setup_notification_preferences\n n = NotificationPreference.create!(user_id: id)\n self.notification_preference_id = n.id\n end",
"def preferences=(prefs)\n unless prefs.kind_of? Preferences\n raise InvalidPreference, \"Preference settings must be an instance of SmartView::Preferences\"\n end\n @preferences = prefs\n end",
"def set_right_preferences_path\n Mongoid::Preferences.configure do |config|\n # model preferences path to dummy model\n config.model_preferences_path = File.join(File.dirname(__FILE__), \"models_preferences\")\n end\nend",
"def set_preferences( opts={} )\n options.merge!( opts )\n end",
"def remember_preference settings\n self.preference = Preference.find_or_create_by user_id: self\n self.preference.update settings\n end",
"def register_defaults_for_inbox(inboxpath)\n if processed then # If there is a default set for processed...\n if not Pathstring.new(inboxpath).volume == Pathstring.new(processed).volume then # ...and it's not on the same volume as inboxpath\n raise \"Both inbox and processed directories must be on same volume.\"\n end\n end\n @defaults.registerDefaults(:inbox => File.expand_path(inboxpath))\n end",
"def set_pref\n @pref = Pref.find(params[:id])\n end",
"def set_storage_permissions(preferences: false, statistics: false)\n cookie_permissions.permission('necessary', true)\n cookie_permissions.permission('preferences', preferences)\n cookie_permissions.permission('statistics', statistics)\n manually_set_cookie(cookie_permissions.write, 1.year)\n\n # Also write to say they have seen the message, if not already set\n return if cookies[:'cookie-notification-acknowledged']\n\n cookies[:'cookie-notification-acknowledged'] = { value: Base64.strict_encode64('yes'), expires: 1.year }\n end",
"def set_mailbox\n imap.select(@mailbox.name) if logged_in?\n end",
"def set_folder\n @folder = Folder.find_by!(id: params[:id], user_id: current_user.id)\n end",
"def load_all\n parse_json(get(PREFERENCE_URL))['prefs'].each do |p|\n @@greader_preferences[p['id']] = p['value']\n end\n end",
"def email_notification_preferences=(prefs_attributes)\n prefs = self.email_notification_preferences # init the object if it wasn't there\n prefs_attributes.each{|key, val| prefs.send(\"#{key}=\", val==\"true\")}\n write_attribute(:email_notification_preferences, prefs)\n end",
"def set_wrong_preferences_path\n Mongoid::Preferences.configure do |config|\n # model preferences path to dummy model\n config.model_preferences_path = 'wrong/path/to/preferences/file'\n end\nend",
"def settings\n\t\tcheck_if_myself\n\t\t@user = current_user\n\tend",
"def set_inbox\n @inbox = Inbox.find(params[:id])\n @account_inbox = @inbox.account_inboxes.find_by_account_id(current_account.id)\n end",
"def initialize(config)\n super(config)\n @standard_folders[:Trash] = \"[Google Mail]/Trash\"\n @standard_folders[:Drafts] = \"[Google Mail]/Drafts\"\n @standard_folders[:Sent] = \"[Google Mail]/Sent Mail\"\n @max_folder_depth = 8\n # unselectable parent folders are removed automatically\n end",
"def set_email_preference\n @email_preference = EmailPreference.find(params[:id])\n end",
"def set_setting\n end",
"def install_prefs!\n return false unless File.exists?(prefs_bak)\n\n puts \" preferences: #{prefs_dest.inspect}\"\n FileUtils.cp(prefs_bak, prefs_dest)\n true\n end",
"def set_account_inbox\r\n @account_inbox = AccountInbox.find(params[:id])\r\n end",
"def set_mailbox\n config = Configuration.instance\n maildir_format = config.maildir_format\n mailbox_class = maildir_format.capitalize + \"Mailbox\"\n class_dir = File.expand_path('../../', __FILE__) + \"/mailbox\"\n mailbox_file = File.join class_dir, maildir_format + \"_mailbox\"\n require mailbox_file\n maildir_path = config.maildir\n @mailbox = self.class.const_get(mailbox_class).new maildir_path\n end",
"def default_email_preferences\n EmailPreference.default_set_for_user(self) if email_preferences.blank?\n end",
"def use_static_preferences!\n @preference_store = default_preferences\n end",
"def change_preference_list\n\t\tcheck_if_myself\n\t\tuser = current_user\n\t\tnew_preference_list = user_pref_list_params[:preference_list]\n\t\tif new_preference_list != user.preference_list\n\t\t\tuser.update_attributes(user_pref_list_params)\n\t\t\tuser.save\n\t\t\tRecomputeMeetingParticipationsJob.perform_later (0..6).to_a, user\n\t\tend\n\t\tredirect_to settings_page_path\n\tend",
"def user_setting_page\n\t\t@notification_settings = current_user.notification_setting\n\n\tend",
"def reset\n set(default_preferences)\n end",
"def set(preferences={})\n config = self.instance\n preferences.each do |key, value|\n config.set_preference(key, value)\n end\n config.save\n Rails.cache.delete(\"configuration_#{config.id}\".to_sym)\n end",
"def set_folder\n @folder = PulStore::Lae::Folder.find(params[:id])\n end",
"def set_preference\n begin\n @preference = Preference.find(params[:id])\n rescue\n flash[:danger] = \"You don't have permission for this action.\"\n redirect_to preferences_path\n end\n end",
"def defined_preferences\n super - [:server]\n end",
"def set_preference\n @preference = Preference.find(params[:id])\n end",
"def store(prefs)\n prefs.each do |key, value|\n self[key] = value\n end if prefs.respond_to?(:each)\n end",
"def set_preference\n preference = Preference.find(params[:id])\n end",
"def set_inbox\n @inbox = Inbox.find(params[:id])\n end",
"def set_inbox\n @inbox = Inbox.find(params[:id])\n end",
"def app_library_preferences_dir\n base_dir = app_library_dir\n if base_dir.nil?\n nil\n else\n File.join(base_dir, 'Preferences')\n end\n end",
"def set_user_preference\n @user_preference = UserPreference.find(params[:id])\n end",
"def setting; end",
"def activate_inbox\r\n flash[:success] = !@content.archived? ? \"Folder is already active\".t : (\"Activated folder '%s'\" / [@content.title_long])\r\n @content.update_attribute(:archived, false)\r\n redirect_to content_url(@content)\r\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_inbox\n @inbox = current_user.inboxes.find(params[:id])\n end",
"def select_data_dir(oConfig)\n #try to get rid of these globals, tweak call-backs on 'other' side\n oConfig.data_dir = Tk::chooseDirectory\n #p \"Data folder set to #{oConfig.data_dir}\"\n oConfig.data_dir\nend",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def settheme\n ct = Theme.find_by_filename(params[:preference][:theme])\n unless ct.wallpaper\n session[:wallpaper] = false\n current_user.preference.wallpaper = false\n end\n \n respond_to do |format|\n if current_user.preference.update_attributes(params[:preference])\n set_session\n format.html {redirect_to :back}\n format.js {render \"reminder_save\"}\n else\n format.js {render \"shared/save_failed\"}\n end\n end\n end",
"def markMail(imap, folder)\n pp \"MARKED #{folder}..\"\n message_ids = imap.uid_search(\"ALL\")\n imap.uid_store(message_ids, \"+FLAGS\", [:Seen])\n imap.expunge\nend",
"def set_m_pref\n @m_pref = MPref.find(params[:id])\n end",
"def load_defaults\n @main[:link_file] = File.expand_path \"~/Pictures/single\"\n @main[:directory] = File.expand_path \"~/Pictures\"\n @main[:mask] = \"**/*\"\n @main[:cache_dir] = File.expand_path \"~/.cache/\"\n @main[:cache_file] = File.expand_path \"~/.cache/next_background/cache.yaml\"\n @main[:timeout] = 10\n self.save\n end",
"def save(mailbox)\n\n if mailbox[0,1]=='=' and @maildir != nil then\n if @folderstyle == Maildir and mailbox !~ /^=\\./ then\n mailbox[\"=\"]=@maildir+\"/.\"\n else\n mailbox[\"=\"]=@maildir+\"/\"\n end\n end\n\n if mailbox[0,1] != '/' then\n log(\"Cannot save to relative filenames! Saving to spool file\");\n mailbox=spoolfile\n end\n\n begin\n [MBox,Maildir,MH].each do |mod|\n if mod::check_mailbox(mailbox) then\n extend mod\n raise MailboxFound\n end\n end\n\n # Huh, nothing could find anything. Oh well,\n # let's default to whatever's in @folderstyle. (I\n # guess we'll be making a new mailbox, eh?)\n\n if Module === @folderstyle then\n #\n # Careful we don't get the wrong instance variable \n folderstyle=@folderstyle \n\n extend folderstyle\n else\n # No hints from the user either. Let's guess!\n # I'll use the same heuristic that Postfix uses--if the\n # mailbox name ends with a /, then make it a Maildir,\n # otherwise make it a mail file\n if mailbox =~ /\\/$/ then\n extend Maildir\n else\n extend MBox\n end\n end\n \n rescue MailboxFound\n # Don't need to do anything--we only have to worry\n # about it if there wasn't a mailbox there.\n nil\n end\n\n begin\n deliver_message(mailbox)\n rescue SystemCallError\n self.log \"Gack! Something went wrong: \" + $!.to_s\n raise\n # exit 75\n end\n end",
"def set_profile\n end",
"def load_config\n @preferences = \"/Library/Preferences/com.apple.RemoteManagement.plist\"\n config = NSMutableDictionary.dictionaryWithContentsOfFile(@preferences)\n end",
"def pref\n raw_config = File.open(\"#{Rails.root}/config/prefs.yml\")\n config = YAML.load(raw_config)\n #$prefs=config.symbolize_keys[:pref]\n config\n end",
"def add_preference(name, value)\n @options[:prefs][name] = value\n end",
"def settings; end",
"def settings; end",
"def ask_pref(preference, prompt)\n prefs[preference] = ask_wizard(prompt)\nend",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def preferences_holder\n nil\n end",
"def load_master\n @master_preferences[@master_label] = @master_path\n @master_preferences\n end",
"def propagate_update\n self.preferences = self.group.preferences if self.group\n raise \"Couldn't save\" unless self.save\n assure_created_zip\n end",
"def stub_spree_preferences(preferences)\n preferences.each do |name, value|\n if Spree::Config.method(:[]).owner >= Spree::Config.class\n allow(Spree::Config).to receive(:[]).and_call_original\n end\n allow(Spree::Config).to receive(:[]).with(name) { value }\n allow(Spree::Config).to receive(name) { value }\n end\n end",
"def register_defaults_for_processed(target_dir)\n if Pathstring.new(inbox).volume == Pathstring.new(target_dir).volume then\n @defaults.registerDefaults(:processed => Pathstring.new(target_dir) )\n else\n raise \"Both inbox and processed directories must be on same volume.\"\n end\n end",
"def install_prefs\n return false if File.exists?(prefs_dest)\n install_prefs!\n end",
"def update_settings\n end",
"def preferences\n @user = current_user\n @mode = \"general\"\n\n respond_to do |format|\n format.html\n end\n end",
"def store_dir\n @dir = Dir.pwd\n end",
"def set_home\n end",
"def set_pref(key, value)\n prefs unless @prefs_fetched # update cache first\n success = _set_pref(key, value)\n @prefs_cache[key] = value if success\n success\n end",
"def set_params params\n raise \"No Params\" if params.nil?\n params.each do |key, value|\n raise \"key nil\" if key.nil?\n raise \"value nil\" if value.nil?\n self.preferences[key.to_sym] = value if valid_key?(key)\n end\n raise \"save failed: #{errors}\" unless self.save\n assure_created_zip\n end",
"def defender_additional_guarded_folders=(value)\n @defender_additional_guarded_folders = value\n end",
"def set_sharedfolder\n @sharedfolder = Sharedfolder.find(params[:id])\n end",
"def reset_default\n \n w=WinReg.new(@file)\n w.debug=@debug\n FOLDER_DEFAULTS.each do |key|\n w.write_key(FOLDERS_BASE+'\\\\'+key[:name],PROFILE_BASE+'\\\\'+key[:dir])\n end\n end",
"def select_data_dir(oDM)\n #try to get rid of these globals, tweak call-backs on 'other' side\n oDM.config.data_dir.value = Tk::chooseDirectory\n p \"Data folder set to #{oDM.config.data_dir.value}\"\n oDM.config.data_dir.value\nend",
"def write_preferences(dict, path)\n dict.writeToFile_atomically(path, true)\n end",
"def define_path\n raise GetMeSubsError.new(\"Settings for this OS aren't supported.\") if @os != :windows\n @path = (\n case @os\n when :windows\n ENV['APPDATA'] + \"/GetMeSubs/settings.yaml\"\n end\n )\n FileUtils.mkdir_p(File.dirname(@path))\n end",
"def setTasklist(tasklist)\r\n\t\t\t\t\t@tasklist = tasklist\r\n\t\t\t\tend",
"def save\n # Nothing in base class. This should be used to persist settings in\n # subclasses that use files.\n end",
"def set_mandarin_preference\n @mandarin_preference = MandarinPreference.find(params[:id])\n end",
"def set_defaults\n self.notification_id ||= Thrive::Util::Uuid.generate\n self.state = 'new' unless state\n end",
"def set_file_folder\n @file_folder = FileFolder.find(params[:id])\n end",
"def settings\n end",
"def set_notifications\n @notifications = current_user.my_notifications\n end",
"def set_favorite\n end",
"def set_up_assignment_review\n set_up_defaults\n @assignment.directory_path = nil if @assignment.directory_path.empty?\n end",
"def add_preference(name, value); end",
"def add_preference(name, value); end",
"def read_config\n @config = {}\n begin\n @config = Psych.load_file('config/prefs.yml')\n puts 'preferences loaded'\n rescue => e\n puts e\n puts e.backtrace\n puts 'An error occured while loading the preference file'\n puts 'User will be asked what to do'\n recreate_default_config\n read_config\n end\nend"
] | [
"0.5875382",
"0.58229256",
"0.5787761",
"0.5693339",
"0.564578",
"0.55750924",
"0.55706257",
"0.5545923",
"0.5536221",
"0.55259997",
"0.55197316",
"0.55189574",
"0.54969394",
"0.54817104",
"0.54778826",
"0.5451697",
"0.53765494",
"0.53627497",
"0.53580713",
"0.5355904",
"0.53333265",
"0.5333016",
"0.5312185",
"0.52986896",
"0.5280624",
"0.52786213",
"0.5271444",
"0.5270488",
"0.5234243",
"0.5224872",
"0.52189136",
"0.5212061",
"0.52092505",
"0.520472",
"0.52003336",
"0.517765",
"0.51679057",
"0.5154188",
"0.51381993",
"0.5135966",
"0.51316583",
"0.5114833",
"0.5059887",
"0.50520456",
"0.50520456",
"0.50445586",
"0.5025658",
"0.5012918",
"0.49958363",
"0.49812406",
"0.49812406",
"0.49812406",
"0.49812406",
"0.49812406",
"0.4974986",
"0.49677008",
"0.49301207",
"0.49240303",
"0.49156877",
"0.49146613",
"0.49073285",
"0.49017438",
"0.48804474",
"0.48674133",
"0.48634112",
"0.48584345",
"0.48564145",
"0.48564145",
"0.48322862",
"0.48288965",
"0.48288965",
"0.48262742",
"0.48245153",
"0.48192334",
"0.48136097",
"0.48085392",
"0.48019066",
"0.48002633",
"0.4786987",
"0.47833776",
"0.4769758",
"0.4760107",
"0.4755958",
"0.47523472",
"0.47477138",
"0.4747412",
"0.47433716",
"0.4736341",
"0.47273684",
"0.47123235",
"0.470975",
"0.47094294",
"0.47084206",
"0.4701004",
"0.46974802",
"0.4694082",
"0.46940583",
"0.46927524",
"0.4687554",
"0.4687554",
"0.46863335"
] | 0.0 | -1 |
But this points to a directory that will contain a set of different directories for processed files | def processed
return @defaults.objectForKey(:processed)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def for(file_or_dir); end",
"def directory(dir); end",
"def directories; end",
"def directories; end",
"def target_files_in_dir(base_dir = T.unsafe(nil)); end",
"def configure_directories\n processing_dir = @config['processing_dir']\n if @config['directory_formats']\n @spec['origdir'] = @config['origdir'] || parse_directory_format(@config['directory_formats']['origdir']) || File.join(processing_dir, @spec['subid'] + '_orig')\n @spec['procdir'] = @config['procdir'] || parse_directory_format(@config['directory_formats']['procdir']) || File.join(processing_dir, @spec['subid'] + '_proc')\n @spec['statsdir'] = @config['statsdir'] || parse_directory_format(@config['directory_formats']['statsdir']) || File.join(processing_dir, @spec['subid'] + '_stats')\n else\n @spec['origdir'] = @config['origdir'] || File.join(processing_dir, @spec['subid'] + '_orig')\n @spec['procdir'] = @config['procdir'] || File.join(processing_dir, @spec['subid'] + '_proc')\n @spec['statsdir'] = @config['statsdir'] || File.join(processing_dir, @spec['subid'] + '_stats')\n end\n end",
"def directory!\n @file_list = @file_list.select{ |f| File.directory?(f) }\n end",
"def parent_dirs(file); end",
"def glob_to_directory(glob); end",
"def directory; end",
"def directory; end",
"def process()\n scan_dir('.', '.')\n end",
"def dirs; end",
"def dirs; end",
"def directory_entries\n entries.select{ |f| File.directory?(File.join(path,f)) }\n #dirs = ::Dir.glob(\"#{path}/\")\n #dirs.collect{ |f| f.chomp('/') }\n end",
"def collection_dir(*files); end",
"def process\n # here is a starting directory\n main_dir = '/home/john/code/ruby/files'\n # let's go to the directory we want\n Dir.chdir(main_dir)\n #print the present working directory (pwd)\n puts Dir.pwd\n # glob is stolen from Perl - list all the \n # matches for the wildcard pattern \"*\"\n listing = Dir.glob(\"*\")\n # put out the list\n puts listing.inspect\n\n\n #let's process the subdirectories and discard other files\n listing.each do |f|\n if File.directory? f\n processDirectory f\n else\n puts \"ignoring file: \" + f\n end\n end\n\n puts @power.inspect\nend",
"def gen_sub_directories\n @outputdir.mkpath\n end",
"def relative_directory; end",
"def process_directory(path)\n Find.find(path) do |a_path| \n Find.prune if EXCLUDES_DIRECTORIES.include?(File.basename(a_path))\n if (ACCEPTED_FILES_PATTERN.each { | pattern| File.basename(pattern)} and\n !File.directory?(a_path))\n @files_processed += 1\n document = moddify_document(a_path)\n modify_file(a_path,document)\n end\n end\nend",
"def gen_sub_directories\n\t\t@outputdir.mkpath\n\tend",
"def gen_sub_directories\n\t\t@outputdir.mkpath\n\tend",
"def retrieve_dirs(_base, dir, dot_dirs); end",
"def process_directory(src, dest, ext = nil)\n src_path = '%s/*.%s' % [File.expand_path(src), ext || '*']\n dest_path = File.expand_path dest\n Dir.glob(src_path) do |file|\n dest_file = File.join(dest_path,File.basename(file))\n process_file(file, dest_file)\n end\n end",
"def directories\n directory.directoires\n end",
"def find(dirs); end",
"def destination(base_directory); end",
"def prepare_tmpdirs(data)\n data[:files].each do |file|\n targetdir = File.join(@workingdir, File.dirname(File.expand_path(file)).gsub(@package.target_path, \"\"))\n FileUtils.mkdir_p(targetdir) unless File.directory? targetdir\n FileUtils.cp_r(file, targetdir)\n end\n end",
"def new_dirs; end",
"def directory(args)\n args.map! do |file|\n File.expand_path(file)\n end\n\n args.select! do |file|\n File.exist?(file)\n end\n args[0]\n end",
"def base_dir_for_path_parameters; end",
"def scan_dir (dirname)\n log \"*** Inspect: \" + dirname\n Dir.foreach(dirname) do |filename|\n path_cand = File.join(dirname , filename)\n if File.directory?(path_cand)\n #exams directories\n if (filename != \".\" && filename != \"..\")\n unless @filter_dir.index(filename)\n #directory not filtered\n @explore_dir.push(path_cand)\n @dir_list << path_cand\n end\n end\n else\n # file to be listed\n unless file_is_filtered?(path_cand)\n # file is not filtered\n @result_list.push(path_cand)\n end\n end #file.directory?\n end\n next_dir = @explore_dir.pop\n scan_dir(next_dir) if next_dir \n end",
"def findPaths (conf)\n puts aktTime()+' collecting files...'\n STDOUT.flush #write out immediately\n\tconf[:saveDirs].each do |d|\n\t\tif File.directory?(d)\n\t\t\tDir.chdir(d)\n\t\t\tgetFiles(conf)\n\t\telse\n\t\t\tputs \"\\nWarning: Directory: \\n\"+d+\" **not** found !\"\n\t\tend\n\tend\nend",
"def directory\n @directory ||= File.expand_path(File.dirname(file))\n end",
"def directory_paths\n pages.map { |p| File.dirname(p.path).split(\"/\")[0] }.uniq\n end",
"def in_each_dir\n dirs.each do |dir|\n Dir.chdir(dir) do\n yield(dir)\n end\n end\n end",
"def filter_directories(modified_files); end",
"def fix_exam_directory(dirname, processed_dir)\n puts \"Importing exams from #{dirname}...\"\n puts \"Processed exams will go into #{processed_dir}\"\n if not File.exist?(processed_dir)\n puts \"Could not find #{processed_dir}. Creating now.\"\n FileUtils.mkdir(processed_dir)\n end\n\n # Call importExam for each file in directory.\n Dir[File.join(dirname, '*')].each do |file_path|\n if File.file?(file_path)\n new_name, result = fix_exam(file_path)\n new_dir = File.join(processed_dir, result)\n FileUtils.mkdir_p(new_dir)\n new_path = File.join(new_dir, new_name)\n puts \"#{new_name}\\t-\\t#{result}\"\n if new_path != file_path\n FileUtils.cp(file_path, new_path)\n end\n end\n end\n\n puts \"Done. Processed exams have been copied to #{processed_dir}.\"\n puts \"Run import_exam.rb to import successfully processed exams.\"\nend",
"def file_dir\n @parent_generator.file_dir\n end",
"def directories\n directory_entries.map{ |f| FileObject[path, f] }\n end",
"def generate_file_path(dir, files_to_load)\n Dir.foreach(dir) do |fname|\n unless fname == '.' || fname == '..'\n files_to_load << \"./#{dir}/#{fname}\"\n end\n end\nend",
"def copy_folders\r\n %w{_includes _layouts _posts _sass assets}.each do |dir|\r\n directory dir\r\n end\r\n end",
"def run_through_directory\n@file_array = []\n Dir.foreach('text_files') do |item|\n next if item == '.' or item == '..'\n @file_array << item\n end\nend",
"def search_paths\n # NOTE: Do not cache this list, specific generators\n # will modify it with their own lookups\n create_search_paths.select { |path| File.directory?(path) }\n end",
"def all_directories dir\n Dir[\"#{dir}**/\"]\nend",
"def ingest_paths\n path = Pathname.new(Figgy.config[\"ingest_folder_path\"]).join(ingest_directory)\n return [] unless path.exist?\n path.children.select(&:directory?)\n end",
"def keep_dirs; end",
"def ingest(base_directory)\n Dir[\"#{base_directory}/*\"].sort.each do |entry|\n next unless File.directory?(entry)\n\n bib_id = File.basename(entry)\n\n ingest_directory(directory: entry, property_value: bib_id)\n end\n end",
"def scan_dir (dirname)\n log \"*** Inspect: \" + dirname\n Dir.foreach(dirname) do |filename|\n path_cand = File.join(dirname , filename)\n if File.directory?(path_cand)\n #exams directories\n if (filename != \".\" && filename != \"..\")\n unless @filter_dir.index(filename)\n #directory not filtered\n @explore_dir.push(path_cand)\n @dir_list << path_cand\n end\n end\n else\n # file to be listed\n unless file_is_filtered?(path_cand)\n # file is not filtered\n #p path_cand\n if file_has_admitted_extension?(path_cand)\n @result_list.push(path_cand)\n end\n end\n end #file.directory?\n end\n next_dir = @explore_dir.pop\n scan_dir(next_dir) if next_dir \n end",
"def processDir( dirPath )\n return if not File.directory?( dirPath )\n\n puts File.basename( dirPath ) + \"/\"\n\n Dir.foreach( dirPath ) do | content |\n next if content == \".\" or content == \"..\"\n\n contentPath = dirPath + \"/\" + content\n next if File.symlink?( contentPath )\n\n if File.directory?( contentPath )\n processDir contentPath\n elsif File.file?( contentPath )\n fork do\n flacFile = FlacFile.new contentPath\n flacFile.normalize\n end\n end\n end\n\n Process.waitall\nend",
"def initialize root_dir\n find_files root_dir\n end",
"def processed_file\n last_dir_in_path = Pathname(@origional_path).each_filename.to_a.last\n file_wo_path = @origional_file.sub('.'+process_tag, '').sub(@origional_path, '')\n File.join($config[\"processed_loc\"], last_dir_in_path, file_wo_path)\n end",
"def process_directory\n Dir.foreach(@source) do |f|\n next unless f.match(/[a-z]{2}[0-9]{3}[a-z]{2}[0-9]{4}\\.xml/)\n druid = get_druid_from_filename(f)\n mods_file = MODSFile.new(Nokogiri::XML(File.open(File.join(@source, f))), @template_xml, @namespace)\n process_mods_file(mods_file, druid)\n end\n write_output if @analysis_only == false\n report_data_loss\n end",
"def replaced_files\n new_dirs.select { |dir| File.file?(dir) }.to_set\n end",
"def find_files\n find_files_recursive(@build_result_dir, '')\n end",
"def in_dest_dir(*paths); end",
"def containing_directory\n path.dirname\n end",
"def target_files_in_dir(base_dir = Dir.pwd)\n # Support Windows: Backslashes from command-line -> forward slashes\n base_dir = base_dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR\n all_files = find_files(base_dir, File::FNM_DOTMATCH)\n # use file.include? for performance optimization\n hidden_files = all_files.select { |file| file.include?(HIDDEN_PATH_SUBSTRING) }\n base_dir_config = @config_store.for(base_dir)\n\n target_files = all_files.select do |file|\n to_inspect?(file, hidden_files, base_dir_config)\n end\n\n target_files.sort_by!(&order)\n end",
"def dir\n self.a_dir.join '/'\n end",
"def directory\r\n \t@directory.path\r\n end",
"def file_dir\n 'files'\n end",
"def dir\n calc_dir(@basename)\n end",
"def root_dir\n existing_paths = root_paths.select { |path| File.exist?(path) }\n if existing_paths.size > 0\n MultiplexedDir.new(existing_paths.map do |path|\n dir = FileSystemEntry.new(name, parent, path)\n dir.write_pretty_json = !!write_pretty_json\n dir\n end)\n end\n end",
"def find_paths(dir=\"\")\n base = File.join(@source, dir)\n entries = Dir.chdir(base) { filter_entries(Dir[\"*\"]) }\n paths = []\n\n entries.each do |entry|\n absolute_path = File.join(base, entry)\n relative_path = File.join(dir, entry)\n\n if File.directory?(absolute_path)\n paths.concat find_paths(relative_path)\n else\n paths << absolute_path\n end\n end\n paths\n end",
"def process_directory(dir, files, rec)\n dir.children(true).each do |f|\n # ignore sub-directories\n if f.directory?\n if rec == false\n next\n else\n process_directory(f.expand_path, files, rec)\n end\n end\n process_file(f.expand_path, files)\n end\n end",
"def enclosed_directory\n \".\"\nend",
"def coerce_directories!\n @config.tap do |c|\n c.agency[:pid_directory] = path_from_env('SMITH_PID_DIRECTORY', c.agency[:pid_directory])\n c.agency[:cache_directory] = path_from_env('SMITH_CACHE_DIRECTORY', c.agency[:cache_directory])\n c.agency[:acl_directories] = paths_from_env('SMITH_ACL_DIRECTORIES', c.agency[:acl_directories])\n c.agency[:agent_directories] = paths_from_env('SMITH_AGENT_DIRECTORIES', c.agency[:agent_directories])\n end\n\n check_directories\n @config.agency[:acl_directories] = @config.agency[:acl_directories] + [smith_acl_directory]\n end",
"def get_directories(src)\n directories = Array.new\n #return directories\n Find.find(src) do |path|\n # not too sure what this was intended to do but its getting in the way\n # and can not be matched correctly.\n #next if File.dirname(path) != src \n next if path == src\n next if not File.directory? path\n directories.push path\n end\n directories.reverse\nend",
"def relative_directory\n @relative_directory ||= \"_#{label}\"\n end",
"def collection_dir(*files)\n return directory if files.empty?\n\n site.in_source_dir(container, relative_directory, *files)\n end",
"def read_directories(dir = \"\")\n base = site.in_source_dir(dir)\n\n return unless File.directory?(base)\n\n entries_dirs = []\n entries_pages = []\n entries_static_files = []\n\n entries = Dir.chdir(base) { filter_entries(Dir.entries(\".\"), base) }\n entries.each do |entry|\n file_path = @site.in_source_dir(base, entry)\n if File.directory?(file_path)\n entries_dirs << entry\n elsif Utils.has_yaml_header?(file_path) || Utils.has_rbfm_header?(file_path)\n entries_pages << entry\n else\n entries_static_files << entry\n end\n end\n\n retrieve_dirs(dir, entries_dirs)\n retrieve_pages(dir, entries_pages)\n retrieve_static_files(dir, entries_static_files)\n end",
"def retrieve_dirs(_base, dir, dot_dirs)\n dot_dirs.each do |file|\n dir_path = site.in_source_dir(dir, file)\n rel_path = PathManager.join(dir, file)\n @site.reader.read_directories(rel_path) unless @site.dest.chomp(\"/\") == dir_path\n end\n end",
"def process_result_dirs(parent_dir)\n # get all the result dirs in the parent dir\n results_dirs = Dir.glob(\"#{parent_dir}/*/\").sort\n puts \"processing #{results_dirs.length} results directories...\"\n\n # process each result dir\n results_dirs.each do |dir|\n dirname = File.basename(dir)\n puts \"processing results dir: #{dirname}\"\n\n csv_path = \"#{dir}#{dirname}.csv\"\n puts \"csv_path: #{csv_path}\"\n\n # create a summary csv with the headings and last 2 rows\n heading = \"<h1>#{dirname}</h1>\"\n table = extract_table_from_results_csv(csv_path)\n @tables += heading + table unless table.nil?\n end\nend",
"def read_directories(dir = \"\")\n base = site.in_source_dir(dir)\n\n return unless File.directory?(base)\n\n dot_dirs = []\n dot_pages = []\n dot_static_files = []\n\n dot = Dir.chdir(base) { filter_entries(Dir.entries(\".\"), base) }\n dot.each do |entry|\n file_path = @site.in_source_dir(base, entry)\n if File.directory?(file_path)\n dot_dirs << entry\n elsif Utils.has_yaml_header?(file_path)\n dot_pages << entry\n else\n dot_static_files << entry\n end\n end\n\n retrieve_posts(dir)\n retrieve_dirs(base, dir, dot_dirs)\n retrieve_pages(dir, dot_pages)\n retrieve_static_files(dir, dot_static_files)\n end",
"def parse_files (path = '.', parent_id = 0)\n\n full_path = root_path().join(path)\n\n Dir.foreach(full_path) {|file_name|\n\n if file_name == '.' || file_name == '..'\n next\n end\n\n program_file = program_files.build()\n program_file.name = file_name\n program_file.path = Pathname.new(path).join(file_name).to_s\n program_file.parent_id = parent_id\n\n if File.ftype(full_path.join(file_name)) == 'directory'\n program_file.file_type = :dir\n program_file.save\n parse_files Pathname.new(path).join(file_name), program_file.id\n else\n program_file.file_type = :file\n program_file.save\n end\n }\n end",
"def scan_sub_dirs_in_path(path)\n puts 'Scanning destination directories'\n Dir.chdir(path)\n sub_dirs = Dir['*'].select { |o| File.directory?(o) }\n Dir.chdir(root_dir)\n sub_dirs\nend",
"def work\n '/' + File.dirname(file)\n end",
"def dir_list\n path_from_env || default_path\n end",
"def new_dirs\n @new_dirs ||= new_files.flat_map { |file| parent_dirs(file) }.to_set\n end",
"def upload_paths\n @paths ||= begin\n (images + files + renders).map do |name|\n file_path = @directory.join(name)\n\n next unless File.readable?(file_path)\n\n file_path\n end.compact\n end\n end",
"def processFile dir\n\tdir.each do |file|\n\t\tif File.directory?(file) then next;\n\t\t\telse \n\t\t\t\th = {File.basename(file) => getHash(file)}\n\t\t\t\t@hash.merge!(h)\n\t\tend\n\tend\n\t@hash\nend",
"def prepare_dirs\n [@reports_dir, @cache_dir, @gems_dir].each do |dir|\n Dir.mkdir(dir) unless File.directory?(dir)\n end\n end",
"def find_as_relative(dir_name,excludes=[])\r\n files =[]\r\n excludes = [] unless excludes\r\n #todo write this two line . exculude initialize test\r\n excludes = excludes.split(\",\") if excludes.class == String\r\n excludes = [excludes] unless excludes.class == Array\r\n \r\n Dir.chdir(dir_name){ \r\n files = Dir.glob \"./**/*\", File::FNM_DOTMATCH\r\n exclude_files =[]\r\n exclude_files = excludes.map{|g| Dir.glob \"./**/#{g}\",File::FNM_DOTMATCH } \r\n files = files.reject{|e| File.directory?(e) }\r\n files = files - exclude_files.flatten\r\n }\r\n files = files.reject{|e| [\".\",\"..\"].any?{|s| s== File::basename(e) }}\r\n end",
"def spec_dirs; end",
"def dirs\n @dirs.each { |_, dir| apply_defaults_to_dir(dir) }\n end",
"def directories\n [root_path, deploys_path, shared_path,\n log_path, checkout_path, scripts_path]\n end",
"def scan_dirs\n @scan_files = Array.new\n Dir.entries(@scan_dir).each do |scan|\n next if File.directory?(@scan_dir + '/' + scan)\n @scan_files << @scan_dir + '/' + scan\n end\n end",
"def files(rootDir)\n Dir.foreach(rootDir) do |dir|\n if dir != \".\" && dir != \"..\"\n puts \"Processing \" + dir\n Dir.foreach(rootDir + \"/\" + dir) do |file|\n if file != \".\" && file != \"..\"\n open(rootDir + \"/\" + dir + \"/\" + file) do |f|\n yield(f)\n end\n end\n end\n end\n end\nend",
"def find_in(dir); end",
"def process_globs globs\n result = globs.flat_map do |glob|\n Dir[File.join directory, glob]\n .map{ |f| f.gsub(/\\\\/, '/') }\n .select { |f| File.file?(f) }\n end\n result\n end",
"def parse_params_from_directory dir = ENV['PWD']\n self.directory_parse_strategy(dir)\n end",
"def push_used_dirs d=Dir.pwd\n $used_dirs.index(d) || $used_dirs.push(d)\nend",
"def push_used_dirs d=Dir.pwd\n $used_dirs.index(d) || $used_dirs.push(d)\nend",
"def push_used_dirs d=Dir.pwd\n $used_dirs.index(d) || $used_dirs.push(d)\nend",
"def find_files(recusive,sort)\n ext_list = $config[\"series\"][\"media_extentions\"].gsub(/,/,\"|\")\n files = [] \n if File.directory? sort\n Find.find(sort) do |path|\n next if File.dirname(path) != sort and not recusive\n next if File.directory? path\n next if File.basename(path) =~ /^\\./\n next if path !~ /#{ext_list}$/\n files << path\n end\n else\n log(\"error: source directory of \\\"#{sort}\\\" does not exist!\")\n exit 2\n end\n files\nend",
"def process_dir(manifest, directory, options = {})\n manifest.directory(directory)\n \n files = relative_dir_files(directory)\n \n process_files(manifest, files, options)\n end",
"def getfolder(file)\n # Directory to return after analysing the target\n current_dir = Dir.pwd\n # when the target is a directory cd into inmediatly\n if File.directory? file\n Dir.chdir file\n # Get the folder that is going to be replaced with ./\n directory = Dir.pwd + '/'\n else\n # When the target is a file we need to get it's location\n splited_file_path = File.expand_path(file).split('/')\n # this limit reference the last folder before the filename\n limit = splited_file_path.length - 1\n # Get into the same folder of the target file\n Dir.chdir splited_file_path[0...limit].join('/')\n # Get the folder that is going to be replaced with ./\n directory = Dir.pwd + '/'\n end\n # Return to the original working directory\n Dir.chdir current_dir\n # return the founded directory that is going to be repalced in the target's path with './'\n directory\nend",
"def process_other_source_files\n files = @options[:include_source_files].flatten\n files.each do |f|\n FileUtils.cp Dir[f], @working_dir\n end\n end",
"def sort_out_output_directories \n FileUtils.mkdir_p(output_directory)\n FileUtils.mkdir_p(xml_directory)\n FileUtils.mkdir_p(intermediate_directory) unless run_in_memory\n end",
"def group_directories_first\n return if @group_directories == :none\n\n files = @files\n dirs = files.select { |f| File.directory?(f) }\n # earlier I had File? which removed links, esp dead ones\n fi = files.reject { |f| File.directory?(f) }\n @files = if @group_directories == :first\n dirs + fi\n else\n fi + dirs\n end\nend",
"def get_folder_list\n\n ################################\n # \n # prep: list\n #\n ################################\n #ref __FILE__ http://stackoverflow.com/questions/37101151/what-does-file-program-name-mean-in-ruby\n path = Pathname.new(__FILE__)\n# path = Pathname.new('.')\n \n #ref https://ruby-doc.org/stdlib-2.1.0/libdoc/pathname/rdoc/Pathname.html\n p \"path.dirname => #{path.dirname}\"\n \n dpath = path.dirname\n# dpath = \"c:/works_2\"\n \n #ref http://stackoverflow.com/questions/1899072/getting-a-list-of-folders-in-a-directory\n Dir.chdir(dpath)\n# Dir.chdir(\"c:/works_2\")\n# Dir.chdir(path.dirname)\n# Dir.chdir('/destination_directory')\n# list = Dir.glob('*').select\n# list = Dir.glob('*').select {|f| File.directory? f}\n files = Dir.glob('*').select {|f| File.file? f}\n dirs = Dir.glob('*').select {|f| File.directory? f}\n \n puts\n puts \"[#{__LINE__}] directory => #{dpath}\" \n \n puts\n puts \"[#{__LINE__}] folders ....\"\n p dirs\n \n puts\n puts \"[#{__LINE__}] files ....\"\n p files.sort\n# p files\n \n# p files.methods.sort\n \n# p __FILE__\n \n# target_directory = \n# \n# Dir.chdir('/destination_directory')\n## Dir.chdir('/destination_directory')\n# \n# list = Dir.glob('*').select {|f| File.directory? f}\n# \n# p list\n \n ################################\n # \n # file: write data\n #\n ################################\n time_label = get_time_label(\"serial\")\n \n fname = \"directory_list.#{time_label}.txt\"\n \n f = File.new(fname, \"w\")\n \n # header\n f.write(\"program file path = #{FILE_PATH}\")\n f.write(\"\\n\")\n f.write(\"version = #{VERSION}\")\n f.write(\"\\n\")\n \n f.write(\"list file created at = #{time_label}\")\n f.write(\"\\n\")\n \n f.write(\"dir path = #{dpath}\")\n f.write(\"\\n\")\n f.write(\"dirs = #{dirs.size}\")\n f.write(\"\\n\")\n f.write(\"files = #{files.size}\")\n f.write(\"\\n\")\n f.write(\"\\n\")\n \n # data: dirs\n f.write \"<directories> #{dirs.size}\"\n f.write \"\\n\"\n \n dirs.each do |elem|\n \n f.write(elem)\n f.write(\"\\n\")\n \n end\n \n f.write(\"\\n\")\n f.write(\"\\n\")\n \n # data: files\n f.write \"<files> #{files.size}\"\n f.write \"\\n\"\n\n files.each do |elem|\n \n f.write(elem)\n f.write(\"\\n\")\n \n end\n \n f.close\n \n puts \"[#{__LINE__}] file written => #{fname}\"\n \nend"
] | [
"0.6881335",
"0.68804115",
"0.6790909",
"0.6790909",
"0.6760648",
"0.6584804",
"0.6532048",
"0.64980865",
"0.6406091",
"0.6361338",
"0.6361338",
"0.6322287",
"0.6317839",
"0.6317839",
"0.6274138",
"0.62534",
"0.6249712",
"0.6246378",
"0.62385124",
"0.6224984",
"0.6205412",
"0.6205412",
"0.62040836",
"0.6189532",
"0.61856264",
"0.61711293",
"0.6168879",
"0.6151284",
"0.6139715",
"0.6138337",
"0.6124819",
"0.6104227",
"0.6096764",
"0.60872763",
"0.60822827",
"0.6076658",
"0.6075013",
"0.60732305",
"0.6071042",
"0.6047908",
"0.60418946",
"0.6037601",
"0.6037257",
"0.60305625",
"0.602174",
"0.6020843",
"0.60166246",
"0.60164595",
"0.6015153",
"0.60053426",
"0.6001572",
"0.59958535",
"0.59776",
"0.59676504",
"0.5964295",
"0.5963208",
"0.59620804",
"0.5961301",
"0.5961022",
"0.5947953",
"0.5946167",
"0.59430224",
"0.5937849",
"0.5933025",
"0.59309596",
"0.5916265",
"0.5915273",
"0.5914767",
"0.59081435",
"0.5902554",
"0.5894482",
"0.5888743",
"0.5885606",
"0.58852637",
"0.5866221",
"0.5865159",
"0.5861311",
"0.58600914",
"0.58570886",
"0.5849149",
"0.58486176",
"0.58466595",
"0.58385706",
"0.58374226",
"0.5836722",
"0.583469",
"0.5818421",
"0.5816555",
"0.5816345",
"0.58161336",
"0.5808155",
"0.58069015",
"0.58069015",
"0.58069015",
"0.5800509",
"0.5798303",
"0.5794923",
"0.5792076",
"0.5790577",
"0.57896554",
"0.5785754"
] | 0.0 | -1 |
GET /threats/1 GET /threats/1.xml | def show
@threat = Threat.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @threat }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @threds = Thred.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @threds }\n end\n end",
"def index\n @click_to_talks = ClickToTalk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @click_to_talks }\n end\n end",
"def show\n @chirp = Chirp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chirp }\n end\n end",
"def index\n authenticate\n @user = current_user\n @users = User.find_everyone(@user)\n @chats = @user.chats\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @chats }\n end\n end",
"def index\n @traffics = Traffic.find(:all, :order => \"created_at\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @traffics }\n end\n end",
"def index\n @meats = Meat.all\n end",
"def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def index\n @topics = Topic.where(:appear => 1).order(\"updated_at DESC, id DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def tournaments\n get('sports/en/tournaments.xml')\n end",
"def index\n @coatings = do_index(Coating, params)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @coatings }\n end\n end",
"def index\n #@feats = Feat.find(:all)\n @feats = @character.feats.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feats }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @coating }\n end\n end",
"def show\n @toilet = Toilet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @toilet }\n end\n end",
"def show\n @click_to_talk = ClickToTalk.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @click_to_talk }\n end\n end",
"def index\n @scotty_dog_sayings = ScottyDogSaying.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @scotty_dog_sayings }\n end\n end",
"def index\n @counter = 0\n @seats = Seat.all(:order =>'id')\n\n @messages = Message.where(\"user_id_to IS NULL AND created_at > ?\", Time.now.strftime(\"%Y-%m-%d\")) \n\n @messages.each do |m|\n @gconversation = \"#{@gconversation}\\n\"+ (m.user_id_from ? User.find(m.user_id_from).username : 'guest') + \": #{m.message}\"\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @seats }\n end\n end",
"def index\n @friend_requests = FriendRequest.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @friend_requests }\n end\n end",
"def index\n @friend_requests = FriendRequest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @friend_requests }\n end\n end",
"def show\n @sleep_log = SleepLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sleep_log }\n end\n end",
"def show\n @scotty_dog_saying = ScottyDogSaying.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @scotty_dog_saying }\n end\n end",
"def show\n @traffic = Traffic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @traffic }\n end\n end",
"def show\n @tstat = Tstat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tstat }\n end\n end",
"def index\n @brothers = Brother.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @brothers }\n end\n end",
"def show\n @arc = Arc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @arc.to_xml(:except => [ :created_at, :updated_at ], :include => :tahs) }\n end\n end",
"def show\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tso.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end",
"def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @boat }\n end\n end",
"def index\n @chat_rooms = ChatRoom.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @chat_rooms }\n end\n end",
"def show\n @haiku = Haiku.find(params[:id])\n\n respond_to { |format|\n format.html # show.rhtml\n format.xml {\n\trender :xml => @haiku.to_xml\n }\n }\n end",
"def friends(id)\n friends_data(request(\"users/friends/#{id}.xml\", :auth => true))\n end",
"def feats\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @character }\n end\n end",
"def index\n @topic_attributes = TopicAttribute.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topic_attributes }\n end\n end",
"def show\n @old_twit = OldTwit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @old_twit }\n end\n end",
"def index\n @topics = Topic.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def show\n @yacht = Yacht.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @yacht }\n end\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 @stats = Stat.where(:match_id => params[:match_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stats }\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 show\n @feat = @person.feats.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feat }\n end\n end",
"def show\n \n@clicker = Clicker.find(params[:id])\n\n \nrespond_to do |format|\n \nformat.html # show.html.erb\n \nformat.xml { render :xml => @clicker+\"yyyyy\" }\n \n end\n \nend",
"def index\n @tournaments = @resource_finder.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tournaments }\n end\n end",
"def show\n @tpago = Tpago.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tpago }\n end\n end",
"def show\n @thoughts = @topic.thoughts if @topic\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @topic.to_xml( :include => :thoughts ) }\n end\n end",
"def index\n @kontakties = Kontakty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @kontakties }\n end\n end",
"def index\n @reasons = Reason.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reasons }\n end\n end",
"def index\n respond_to do |format|\n format.html { redirect_to forum_path(params[:forum_id]) }\n format.xml do\n @topics = Topic.find_all_by_forum_id(params[:forum_id], :order => 'sticky desc, replied_at desc', :limit => 25)\n render :xml => @topics.to_xml\n end\n end\n end",
"def show\n @aircraft_history = AircraftHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @aircraft_history }\n end\n end",
"def show\n @seat = Seat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @seat }\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 index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def show\n @chat_room = ChatRoom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chat_room }\n end\n end",
"def index\n @wish_lists = WishList.find(:all, :order => 'created_at DESC').paginate :per_page => 20, :page => params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @wish_lists }\n end\n end",
"def index\n @timecards = Timecard.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @timecards }\n end\n end",
"def show\n @privacy_friend = PrivacyFriend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @privacy_friend }\n end\n end",
"def index\n @relationships = @character.relationships.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @relationships }\n end\n end",
"def index\n @countdowns = Countdown.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @countdowns }\n end\n end",
"def show\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friend }\n end\n end",
"def show\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @friend }\n end\n end",
"def index\n @relationships = Relationship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @relationships }\n end\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 @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 \t@clickers = Clicker.all\t\t\t\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clickers }\n end\n end",
"def show\n @action_log = ActionLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @action_log }\n end\n end",
"def index\n @friends = Friend.all(:conditions=>{:created_by=>current_user.id})\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @friends }\n end\n end",
"def show\n @stat = Stat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def show\n @stat = Stat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def show\n @talk = Talk.find(params[:id])\n @title=\"Hovor\"\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @talk }\n end\n end",
"def show\n @cattle_id = CattleId.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cattle_id }\n end\n end",
"def index\n @chats = Chat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chats }\n end\n end",
"def show\n @shout = Shout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shout }\n end\n end",
"def show\n @shout = Shout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @shout }\n end\n end",
"def index\n @attendances = Attendance.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @attendances }\n end\n end",
"def show\n @concert = Concert.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @concert }\n end\n end",
"def show\n @brothers = Brother.all\n @brother = Brother.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @brother }\n end\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 show\n @bookfair = Bookfair.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bookfair }\n end\n end",
"def show\n \n begin\n @topic_activity_summaries = \n TopicActivitySummary.find_all_by_student_id_and_grade(params[:id], params[:grade])\n rescue Exception => e \n respond_to do |format|\n format.xml { render :xml => errorRsp( e.message) }\n end\n return\n end\n\t \n respond_to do |format|\n format.xml { render :xml => @topic_activity_summaries.to_xml(:dasherize => false) }\n end\n end",
"def index\n @topics = Topic.all\n\n respond_to do |wants|\n wants.html # index.html.erb\n wants.xml { render :xml => @topics }\n end\n end",
"def show\n @clicker = Clicker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @clicker }\n end\n end",
"def show\n @cat = Cat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cat }\n end\n end",
"def index\n @replies = @topic.replies.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @replies }\n end\n end",
"def index\n @list_cats = ListCat.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_cats }\n end\n end",
"def show\n @http_receive = HttpReceive.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @http_receive }\n end\n end",
"def show\n @retailer_category = RetailerCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @retailer_category }\n end\n end",
"def index\n @friendsofusers = Friendsofuser.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @friendsofusers }\n end\n end",
"def show\n @trip_story = TripStory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @trip_story }\n end\n end",
"def index\n @stories = Story.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @stories }\n end\n end",
"def chats(*args)\n @client.get \"#{@path}/chats\", Hash[*args]\n end",
"def atom\n sup_id = Configuration.for('app').sup_id\n response['Content-Type'] = 'application/atom+xml'\n response['Cache-Control'] = 'max-age=900, public'\n response['Expires'] = (Time.now + 900).utc.rfc2822\n response['X-SUP-ID'] = \"http://friendfeed.com/api/public-sup.json##{sup_id}\"\n respond Tamanegi::to_atom.to_xml\n end",
"def show\n @contrato = Contrato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @contrato }\n end\n end",
"def show\n @matter = Matter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @matter }\n end\n end",
"def index\n @conversations = Conversation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @conversations }\n end\n end",
"def show\n @sleep = Sleep.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sleep }\n end\n end",
"def show\n @log_pelea_guilty = LogPeleaGuilty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @log_pelea_guilty }\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 show\n @kontakty = Kontakty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @kontakty }\n end\n end",
"def index\n @seats = Seat.all\n end",
"def index\n @seats = Seat.all\n end",
"def show\n @talk_record = TalkRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @talk_record }\n end\n end",
"def show\n @hour_entry = HourEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hour_entry }\n end\n end",
"def index\n @patients = Patient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @patients }\n end\n end"
] | [
"0.62674224",
"0.59927523",
"0.5965758",
"0.595783",
"0.59393615",
"0.59247285",
"0.5884636",
"0.5866884",
"0.5851609",
"0.58483505",
"0.5834604",
"0.5823494",
"0.5764516",
"0.57596314",
"0.5746658",
"0.57162845",
"0.5711153",
"0.5710144",
"0.5689824",
"0.5683754",
"0.5645016",
"0.5631984",
"0.5630365",
"0.56296825",
"0.5621128",
"0.5598249",
"0.5594257",
"0.5582647",
"0.55768514",
"0.557636",
"0.5574652",
"0.55744326",
"0.5565596",
"0.55608535",
"0.55472296",
"0.5542895",
"0.5542441",
"0.5540573",
"0.55339503",
"0.5529656",
"0.55259204",
"0.552419",
"0.55161625",
"0.55160916",
"0.5515152",
"0.55128634",
"0.5512816",
"0.5512015",
"0.5507683",
"0.5507313",
"0.5504786",
"0.549387",
"0.54854023",
"0.54852545",
"0.5482851",
"0.5479026",
"0.5479026",
"0.54695797",
"0.546746",
"0.54593337",
"0.5453441",
"0.5452188",
"0.5448896",
"0.54476064",
"0.54476064",
"0.5445794",
"0.54455304",
"0.5439722",
"0.54390705",
"0.54390705",
"0.5437489",
"0.54374754",
"0.54372346",
"0.5436605",
"0.5431838",
"0.5429767",
"0.5425861",
"0.54227257",
"0.5415481",
"0.5410787",
"0.5408448",
"0.5406224",
"0.5404276",
"0.5403977",
"0.5403133",
"0.5402994",
"0.5402524",
"0.5398911",
"0.539716",
"0.53964734",
"0.5396239",
"0.5395753",
"0.53929216",
"0.53923357",
"0.53910595",
"0.538836",
"0.538836",
"0.5384308",
"0.53830504",
"0.5381543"
] | 0.6149487 | 1 |
GET /threats/new GET /threats/new.xml | def new
@threat = Threat.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @threat }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @coating }\n end\n end",
"def new\n @thred = Thred.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thred }\n end\n end",
"def new\n @feat = @person.feats.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @feat }\n end\n end",
"def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @monkey }\n end\n end",
"def new\n @click_to_talk = ClickToTalk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @click_to_talk }\n end\n end",
"def new\n @chat = Chat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chat}\n end\n end",
"def new\n @seat = Seat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @seat }\n end\n end",
"def new\n @old_twit = OldTwit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_twit }\n end\n end",
"def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cat }\n end\n end",
"def new\n @chirp = Chirp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chirp }\n end\n end",
"def new\n @friend = Friend.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @friend }\n end\n end",
"def new\n @tpago = Tpago.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tpago }\n end\n end",
"def new\n @tstat = Tstat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tstat }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end",
"def new\n @relationship = Relationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relationship }\n end\n end",
"def new\n @tweet = Tweet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tweet }\n end\n end",
"def new\n @patron = Patron.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patron }\n end\n end",
"def new\n @patrimonio = Patrimonio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patrimonio }\n end\n end",
"def new\n @crew = Crew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @crew }\n end\n end",
"def new\n @matter = Matter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @matter }\n end\n end",
"def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @contrato = Contrato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contrato }\n end\n end",
"def new\n @good = Good.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @good }\n end\n end",
"def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end",
"def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end",
"def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end",
"def new\n @rssnew = Rssnews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rssnew }\n end\n end",
"def new\n @scotty_dog_saying = ScottyDogSaying.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scotty_dog_saying }\n end\n end",
"def new \n @how_to = HowTo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @how_to }\n end\n end",
"def new\n @brother = Brother.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @brother }\n end\n end",
"def new\n @twitterfeed = Twitterfeed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @twitterfeed }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @classroom }\n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\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 @story = Story.new\n @categories = Category.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story }\n end\n end",
"def new\n @loan = Loan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @loan }\n end\n end",
"def new\n @catena = Catena.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @catena }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n @my = My.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @my }\n end\n end",
"def new\n @friendship = Friendship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @friendship }\n end\n end",
"def new\n @news = News.new\n @title = \"New news\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end",
"def new\n @gift = Gift.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gift }\n end\n end",
"def new\n @topic = Topic.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end",
"def new\n @sleep_log = SleepLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sleep_log }\n end\n end",
"def new\n @atom = Atom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @atom }\n end\n end",
"def new\n @howto = Howto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @howto }\n end\n end",
"def new\n logger.debug 'new_some interesting information'\n @comdty = Comdty.new\n setvariables\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comdty }\n end\n end",
"def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end",
"def new\n @page = Page.new(:status => params[:from])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @borrow = Borrow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @borrow }\n end\n end",
"def new\n @people = People.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @people }\n end\n end",
"def new\n @traffic = Traffic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @traffic }\n end\n end",
"def new\n @regiment = Regiment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @regiment }\n end\n end",
"def new\n @activity = Activity.new\n @attcategories = Attcategory.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @activity }\n end\n end",
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n @today_activity = TodayActivity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @today_activity }\n end\n end",
"def new\n @addition = Addition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @addition }\n end\n end",
"def new\n @talk_record = TalkRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @talk_record }\n end\n end",
"def new\n @screw = Screw.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @screw }\n end\n end",
"def new\n \n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end",
"def new\n @t1 = T1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @t1 }\n end\n end",
"def new\n @pneighbour = Pneighbour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pneighbour }\n end\n end",
"def new\n @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 @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end",
"def new\n @bookfair = Bookfair.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bookfair }\n end\n end",
"def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end",
"def new\n @been2other = Been2other.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @been2other }\n end\n end",
"def new\n @buddy = Buddy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @buddy }\n end\n end",
"def new\n\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end",
"def new\n @meal = Meal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @meal }\n end\n end",
"def new\n @writ = Writ.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @writ }\n end\n end",
"def new\n @creation = Creation.new\n @topics = Topic.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @creation }\n end\n end",
"def new\n @rink = Rink.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rink }\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 respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chronopay_link }\n end\n end",
"def new\n @story = Story.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story }\n end\n end",
"def new\n @story = Story.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story }\n end\n end",
"def new\n @story = Story.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @story }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ciclo }\n end\n end",
"def new\n @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\n @wish_list = WishList.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @wish_list }\n end\n end",
"def new\n @favourites = Favourites.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @favourites }\n end\n end",
"def new\n @aircraft_history = AircraftHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aircraft_history }\n end\n end",
"def new\n @rant = Rant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rant }\n end\n end",
"def new\n @person = Person.new\n @title = \"people\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person }\n end\n end"
] | [
"0.6994002",
"0.68314433",
"0.6741578",
"0.6691571",
"0.66637546",
"0.6607414",
"0.658991",
"0.6585377",
"0.654986",
"0.6499361",
"0.6494669",
"0.64876175",
"0.6478503",
"0.6467655",
"0.6467655",
"0.6436838",
"0.641355",
"0.6393848",
"0.6389567",
"0.6387195",
"0.63831675",
"0.6379843",
"0.6369101",
"0.6366004",
"0.6363009",
"0.6357736",
"0.6357736",
"0.6357736",
"0.63506484",
"0.6342687",
"0.63421005",
"0.63394",
"0.6334417",
"0.6332531",
"0.6320369",
"0.6320369",
"0.6320369",
"0.6320369",
"0.6320369",
"0.6319598",
"0.63141686",
"0.6314085",
"0.6311608",
"0.63072824",
"0.63052684",
"0.6303616",
"0.6302264",
"0.62926847",
"0.6290805",
"0.6288197",
"0.62873876",
"0.6285521",
"0.6282764",
"0.6281266",
"0.62723744",
"0.6272229",
"0.62696195",
"0.6262709",
"0.6260548",
"0.6260196",
"0.6259345",
"0.6259091",
"0.62478137",
"0.6246018",
"0.62443113",
"0.6243702",
"0.62416506",
"0.62413245",
"0.62399095",
"0.62398094",
"0.62398094",
"0.62398094",
"0.62398094",
"0.62398094",
"0.62398094",
"0.62398094",
"0.62398094",
"0.62398094",
"0.62398094",
"0.62286824",
"0.6226904",
"0.6226019",
"0.6216626",
"0.6215491",
"0.6215457",
"0.62148017",
"0.62142724",
"0.62103015",
"0.6205213",
"0.6203032",
"0.6202536",
"0.6202536",
"0.6202536",
"0.6201976",
"0.62012315",
"0.61989987",
"0.61943555",
"0.6193702",
"0.61911166",
"0.61901295"
] | 0.691455 | 1 |
POST /threats POST /threats.xml | def create
@threat = Threat.new(params[:threat])
respond_to do |format|
if @threat.save
format.html { redirect_to(@threat, :notice => 'Threat was successfully created.') }
format.xml { render :xml => @threat, :status => :created, :location => @threat }
else
format.html { render :action => "new" }
format.xml { render :xml => @threat.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threats_answer_params\n params.require(:threats_answer).permit(:text, :threat_id)\n end",
"def create\n @threats_answer = ThreatsAnswer.new(threats_answer_params)\n @threat = Threat.find(@threats_answer.threat)\n @plano = current_user.plano\n @threats = @plano.threats\n respond_to do |format|\n if @threats_answer.save\n format.html { redirect_to @threats_answer, notice: 'Threats answer was successfully created.' }\n format.json { render :show, status: :created, location: @threats_answer }\n format.js\n else\n format.html { render :new }\n format.json { render json: @threats_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @art = Art.new(params[:art])\n\n respond_to do |format|\n if @art.save\n @art.chats = params[:i]\n flash[:notice] = 'Art was successfully created.'\n format.html { redirect_to(@art) }\n format.xml { render :xml => @art, :status => :created, :location => @art }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @art.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @meat = Meat.new(meat_params)\n\n respond_to do |format|\n if @meat.save\n format.html { redirect_to @meat, notice: 'Meat was successfully created.' }\n format.json { render :show, status: :created, location: @meat }\n else\n format.html { render :new }\n format.json { render json: @meat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @thermostat_history = ThermostatHistory.new(thermostat_history_params)\n\n respond_to do |format|\n if @thermostat_history.save\n format.html { redirect_to @thermostat_history.thermostat, notice: 'Thermostat history was successfully created.' }\n format.json { render action: 'show', status: :created, location: @thermostat_history }\n else\n @thermostats = Thermostat.all\n format.html { render action: 'new' }\n format.json { render json: @thermostat_history.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @action = params[:action_military_retreat_army_action]\n \n army = Military::Army.find(@action[:army_id])\n \n raise NotFoundError.new('army not found') if army.nil?\n raise BadRequestError.new('not owner of army') unless army.owner == current_character\n\n army.battle_retreat = @action[:retreat]\n raise BadRequestError.new('not owner of army') unless army.save \n\n respond_to do |format|\n format.html { redirect_to action_path, notice: 'Retreat army action was successfully executed.' }\n format.json { render json: {}, status: :created }\n end\n end",
"def destroy\n @threat = Threat.find(params[:id])\n @threat.destroy\n\n respond_to do |format|\n format.html { redirect_to(threats_url) }\n format.xml { head :ok }\n end\n end",
"def create\n @thuctap = Thuctap.new(thuctap_params)\n respond_to do |format|\n if @thuctap.save\n format.html { redirect_to @thuctap, notice: 'Thuctap was successfully created.' }\n format.json { render :show, status: :created, location: @thuctap }\n else\n format.html { render :new }\n format.json { render json: @thuctap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kontakty = Kontakty.new(params[:kontakty])\n\n respond_to do |format|\n if @kontakty.save\n flash[:notice] = 'Kontakty was successfully created.'\n format.html { redirect_to(@kontakty) }\n format.xml { render :xml => @kontakty, :status => :created, :location => @kontakty }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @kontakty.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @chat = Chat.new(params[:chat])\n @chat.nome = \"#{@chat.nome} - #{Time.now.strftime(\"%d/%m/%Y - %H:%M\")}\"\n @chat.user_id = current_user.id\n respond_to do |format|\n if @chat.save\n flash[:notice] = 'BATE PAPO INICIADO.'\n @chat.users.each do |c|\n ChamadoMailer.deliver_chat(c,@chat)\n end\n format.html { redirect_to(@chat) }\n format.xml { render :xml => @chat, :status => :created, :location => @chat}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @chat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @seat = Seat.new(params[:seat])\n\n respond_to do |format|\n if @seat.save\n format.html { redirect_to(@seat, :notice => 'Seat was successfully created.') }\n format.xml { render :xml => @seat, :status => :created, :location => @seat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @seat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @goat = Goat.new(params[:goat])\n\n respond_to do |format|\n if @goat.save\n format.html { redirect_to @goat, notice: 'Goat was successfully created.' }\n format.json { render json: @goat, status: :created, location: @goat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @goat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sendclaim\n require 'net/http'\n require 'uri'\n\n @visit = Visit.find(params[:id])\n @patient = Patient.find(@visit.patient_id)\n @patient.fname = @patient.full_sex unless @patient.fname.present?\n @doctor = Doctor.find(@visit.doc_id)\n @xml = render_to_string \"show.xml\"\n\n uri = URI.parse(CABMDURL)\n http= Net::HTTP.new(uri.host,uri.port)\n http.use_ssl = true\n \n req = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' => 'application/xml'})\n req.body = @xml\n\n res = http.request(req)\n @xmlhash = JSON.parse(res.body)\n# {\"success\"=>true, \"errors\"=>[], \"messages\"=>[], \"reference_id\"=>\"332933\", \"accounting_number\"=>\"0004MZ4Z\"}\n \n if @xmlhash['success'] \n\t acc_num = @xmlhash['accounting_number']\n flash[:info] = \"Claim #{acc_num} sent to cab.md \" \n @visit.update_attribute(:status, BILLED)\n @visit.update_attribute(:billing_ref, acc_num)\n else\n\t errors = @xmlhash['errors']\n\t messages = @xmlhash['messages']\n\t flash[:danger] = \"Error sending claim : #{@xmlhash}\"\n @visit.update_attribute(:status, READY)\n\t @visit.update_attribute(:billing_ref, errors.join(',')) if errors.present?\n end\n\n respond_to(:html)\n redirect_to patient_visit_path\n end",
"def create\n @feat = @person.feats.new(params[:feat])\n\n respond_to do |format|\n if @feat.save\n format.html { redirect_to([@person, @feat], :notice => 'Feat was successfully created.') }\n format.xml { render :xml => @feat, :status => :created, :location => @feat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @therapy = Therapy.new(therapy_params)\n category = TherapyCategory.create(name: @therapy.name)\n category.therapies << @therapy\n\n respond_to do |format|\n if @therapy.save\n format.html { redirect_to @therapy }\n format.json { render :show, status: :created, location: @therapy }\n else\n format.html { render :new }\n format.json { render json: @therapy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @thred = Thred.new(params[:thred])\n @thred.user_id = current_user\n @thred.topic_id = session[:topic_id]\n \n respond_to do |format|\n if @thred.save\n format.html { redirect_to(topic_path(@thred.topic_id)) }\n\tflash[:notice] = 'Thread was successfully created.'\n format.xml { render :xml => @thred, :status => :created, :location => @thred }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @thred.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n #ClickATell posts this\n #Parameters:\n #\"api_id\"=>\"3306957\"\n #\"from\"=>\"886975395038\"\n #\"to\"=>\"41798070085\"\n #\"timestamp\"=>\"2011-09-19 13:02:52\"\n #\"text\"=>\"Test of SMS 2\"\n #\"charset\"=>\"ISO-8859-1\"\n #\"udh\"=>\"\"\n #\"moMsgId\"=>\"3e644dd7c1df98671fe41d26dfd73672\"\n\n @momsg = Momsg.new(:from => params[:from], :text => params[:text])\n \n @momsg.save\n\n respond_to do |format|\n format.html { redirect_to @momsg }\n end\n end",
"def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end",
"def create_request\n Friendship.request(@user, @friend)\n flash[:notice] = \"Friend request sent.\"\n redirect_to :back\n end",
"def sendChatAction to, act\n self.query(\"sendChatAction\", {:chat_id=>to, :action=>act})\n end",
"def set_threats_answer\n @threats_answer = ThreatsAnswer.find(params[:id])\n end",
"def create\r\n @chat = Hangout.new(chat_params)\r\n @chat.save\r\n\r\n respond_to do |format|\r\n if @chat.save\r\n format.html { redirect_to chat_path(@chat), notice: 'Chat was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: @chat }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @chat.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @kontak = Kontak.new(params[:kontak])\n\n respond_to do |format|\n if @kontak.save\n flash[:peringatan] = 'Kontak was successfully created.'\n format.html { redirect_to :action => \"index\"}\n format.xml { render :xml => @kontak, :status => :created, :location => @kontak }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @kontak.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @shout = Shout.new(params[:shout])\n\n sendPush (@shout.name + ' just shouted ' + @shout.shout_message)\n \n respond_to do |format|\n if @shout.save\n format.html { redirect_to(@shout, :notice => 'Shout was successfully created.') }\n format.xml { render :xml => @shout, :status => :created, :location => @shout }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shout.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @attend = Attend.new(params[:attend])\n\n respond_to do |format|\n if @attend.save\n AtndNotifier.received(@attend).deliver\n format.html { redirect_to @attend, notice: '参加登録に成功しました!' }\n format.json { render json: @attend, status: :created, location: @attend }\n\n p \"call format\"\n else\n format.html { render action: \"new\" }\n format.json { render json: @attend.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_action(service, action, param)\r\n param_str = \"\"\r\n param.each do |key, value|\r\n param_str << '<%{key}>%{value}</%{key}>'.%(key: key, value: value)\r\n end\r\n xmldata = ActionXML.%(type: service.type, action: action, arguments: param_str)\r\n req = Net::HTTP::Post.new(uri = URI(@igd_location + service.control_url))\r\n req.content_type = 'text/xml; charset=\"utf-8\"'\r\n req['SOAPAction'] = '\"%{type}#%{action}\"'.%(type: service.type, action: action)\r\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\r\n http.request(req, xmldata)\r\n end\r\n #res = Net::HTTP.request(req, xmldata)\r\n xml = REXML::Document.new(res.body).root\r\n if(res.is_a?(Net::HTTPSuccess))\r\n xml.each_element('s:Body/u:*') do |element|\r\n return {is_error: false, has_xml: true, xml: element}\r\n end\r\n else\r\n return {is_error: true, \r\n faultcode: xml.get_text('s:Body/s:Fault/faultcode').to_s,\r\n faultstring: xml.get_text('s:Body/s:Fault/faultstring').to_s,\r\n code: xml.get_text('s:Body/s:Fault/detail/UPnPError/errorCode').to_s.to_i,\r\n descr: xml.get_text('s:Body/s:Fault/detail/UPnPError/errorDescription').to_s\r\n }\r\n end\r\n return {is_error: false, has_xml: false}\r\n end",
"def create\r\n @customerchat = Customerchat.new(customerchat_params)\r\n\r\n respond_to do |format|\r\n if @customerchat.save\r\n format.html { redirect_to @customerchat, notice: 'Customerchat was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: @customerchat }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @customerchat.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n count = Apply.where(\"applies.user_id = #{current_user.id} and applies.friend_id = #{params[:friend_id]}\")\n if (count != nil && count.as_json.length >= 1) || (current_user.id == params[:friend_id])\n flash[:error] = \"发送好友申请失败\"\n redirect_to chats_path\n else\n @apply = current_user.applies.build(:friend_id => params[:friend_id])\n if @apply.save\n flash[:info] = \"发送好友申请成功\"\n redirect_to chats_path\n else\n flash[:error] = \"发送好友申请失败\"\n redirect_to chats_path\n end\n end\n end",
"def create\n @thre = Thre.new(thre_params)\n\n respond_to do |format|\n if @thre.save\n format.html { redirect_to @thre, notice: 'Thre was successfully created.' }\n format.json { render :show, status: :created, location: @thre }\n else\n format.html { render :new }\n format.json { render json: @thre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @chats = Chat.all\n render json: {\n messages: \"Request Successfull!\",\n is_success: true,\n data: { chats: @chats }\n }\n end",
"def create\n @talk = Talk.new(params[:talk])\n\n respond_to do |format|\n if @talk.save\n flash[:notice] = 'Talk was successfully created.'\n format.html { redirect_to(@talk) }\n format.xml { render :xml => @talk, :status => :created, :location => @talk }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @talk.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n respond_to do |format|\n if @coating.save\n format.html { redirect_to(@coating, :notice => t(\"screens.notice.successfully_created\")) }\n format.xml { render :xml => @coating, :status => :created, :location => @coating }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @coating.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_to_action_cable\n\t\t\tdata = {message: to_html,action:\"new_post\"}\n\t\t\tself.user.friend_ids.each do |friend_id|\n\t\t\t\t#\"posts_#{friend_id}\" hace el broacating a todos los amigos del usuarios\n\t\t\t\t#quien realiza la publicacion\n\t\t\t\tActionCable.server.broadcast \"posts_#{friend_id}\", data\n\t\t\tend\n\n\t\t\tself.user.user_ids.each do |friend_id|\n\t\t\t\tActionCable.server.broadcast \"posts_#{friend_id}\", data\n\t\t\tend\n\t\t\t\n\t\tend",
"def create\n @thng = Thng.new(params[:thng])\n @thng.usr= Usr.find_by_opndd(session[:opndd]) unless session[:opndd].nil?\n respond_to do |format|\n if @thng.save\n flash[:notice] = 'Thng was successfully created.'\n format.html { redirect_to(@thng) }\n format.xml { render :xml => @thng, :status => :created, :location => @thng }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @thng.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_stomp(msg,headers)\n \n response_header = {\"Content-type\" => \"text/xml\"}\n response_header.merge headers\n ht =Net::HTTP.start(self.host,self.port)\n url = self.url # + \"/\" + self.topic\n puts \"posting to: #{self.host}: #{self.port} #{url} message: #{msg.to_xml}\"\n r=ht.post(url,msg.to_xml,response_header)\n \n puts \"result: #{r.to_s}\"\n r\n end",
"def new\n @threat = Threat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @threat }\n end\n end",
"def create\n @hikiyama = Hikiyama.new(params[:hikiyama])\n\n respond_to do |format|\n if @omatsuri.hikiyamas << @hikiyama\n flash[:notice] = 'Hikiyama was successfully created.'\n format.html { redirect_to(@omatsuri) }\n format.xml { render :xml => @hikiyama, :status => :created, :location => @omatsuri }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @hikiyama.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @threats_answers = ThreatsAnswer.all\n end",
"def post(action, **args); end",
"def create\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id])\n @friendship.status = \"SENT\"\n if @friendship.save\n flash[:notice] = \"Added friend.\"\n redirect_to root_url\n else\n flash[:error] = \"Unable to add friend.\"\n redirect_to root_url\n end\n end",
"def create\n @tack = Tack.new(tack_params)\n\n if @tack.save\n render json: @tack, status: :created, location: @tack\n else\n render json: @tack.errors, status: :unprocessable_entity\n end\n end",
"def create\n @twenty = Twenty.new(twenty_params)\n\n respond_to do |format|\n if @twenty.save\n format.html { redirect_to @twenty, notice: 'Twenty was successfully created.' }\n format.json { render action: 'show', status: :created, location: @twenty }\n else\n format.html { render action: 'new' }\n format.json { render json: @twenty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attend = Attend.new(params[:attend])\n\n respond_to do |format|\n if @attend.save\n format.html { redirect_to :back }\n format.xml { render :xml => @attend, :status => :created, :location => @attend }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @attend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tFriendship::request(@user, @friend)\n\t\tUserMailer::friend_request(\n\t\t\t:user => @user,\n\t\t\t:friend => @friend,\n\t\t\t:user_url => profile_for(@user),\n\t\t\t:accept_url => url_for(:action => \"accept\", :id => @user.screen_name),\n\t\t\t:decline_url => url_for(:action => \"decline\", :id => @user.screen_name)\n\t\t).deliver_now\n\t\tflash[:notice] = \"Friend request sent.\"\n\t\tredirect_to profile_for(@friend)\n\tend",
"def create\n @chatiw = Chatiw.new(params[:chatiw])\n\n respond_to do |format|\n if @chatiw.save\n format.html { redirect_to @chatiw, notice: 'Chatiw was successfully created.' }\n format.json { render json: @chatiw, status: :created, location: @chatiw }\n else\n format.html { render action: \"new\" }\n format.json { render json: @chatiw.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @chat = match.chats.build( params[:chat] )\n\n @chat.text.gsub!( '<', '<' ).gsub!( '>', '>' ) rescue nil\n @chat.player_id = current_player.id\n\n @chat.save!\n render :action => :show\n end",
"def index\n @counter = 0\n @seats = Seat.all(:order =>'id')\n\n @messages = Message.where(\"user_id_to IS NULL AND created_at > ?\", Time.now.strftime(\"%Y-%m-%d\")) \n\n @messages.each do |m|\n @gconversation = \"#{@gconversation}\\n\"+ (m.user_id_from ? User.find(m.user_id_from).username : 'guest') + \": #{m.message}\"\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @seats }\n end\n end",
"def create\n @helocagree = Helocagree.new(params[:helocagree])\n\n respond_to do |format|\n if @helocagree.save\n #flash[:notice] = 'Helocagree was successfully created.'\n format.html { redirect_to(new_helocapp_path) }\n format.xml { render :xml => @helocagree, :status => :created, :location => @helocagree }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @helocagree.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @friendship = Friendship.new\n @friendship.friend1_id = params[:id]\n @friendship.friend2_id = session[:user_text_id]\n @friendship.begin_date = Time.now\n destroy_friendship_sent_request()\n respond_to do |format|\n if @friendship.save\n @friendship_copy = Friendship.new\n @friendship_copy.friend2_id = params[:id]\n @friendship_copy.friend1_id = session[:user_text_id]\n @friendship_copy.begin_date = Time.now\n @friendship_copy.save\n format.html { redirect_to(:back, :alert => \"#{params[:id]} is your friend now.\") }\n format.xml { render :xml => @friendship, :status => :created, :location => @friendship }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @friendship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n Rails.logger.debug \"=========================================================\"\n Rails.logger.debug \"#{params}\"\n Rails.logger.debug \"=========================================================\"\n @feedback = Feedback.new(feedback_params)\n Announcement.where(\"id = ?\",params[:feedback][:annuncio_id]).limit(1).update_all(\"etichetta = 2\") # => 1\n Booking.where(\"id = ?\",params[:feedback][:booking_id]).limit(1).destroy_all\n respond_to do |format|\n if @feedback.save\n format.html { redirect_to \"/feedbacks?utente=#{params[:feedback][:proprietario_id]}\", notice: 'Il feedback è stato lasciato correttamente!' }\n format.json { render :index, status: :created, location: @feedback }\n else\n format.html { render :new }\n format.json { render json: @feedback.errors, status: :unprocessable_entity }\n end\n end\n end",
"def thuctap_params\n params.require(:thuctap).permit(:partner_info_id, :title, :content, :address, :tag, :endtime)\n end",
"def create\n @attending = Attending.new(attending_params)\n\n respond_to do |format|\n if @attending.save\n format.html { redirect_to @attending, notice: 'Attending was successfully created.' }\n format.json { render :show, status: :created, location: @attending }\n else\n format.html { render :new }\n format.json { render json: @attending.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @chat = Chat.new(chat_params)\n\n respond_to do |format|\n if @chat.save\n format.html { redirect_to @chat, notice: 'Chat was successfully created.' }\n format.json { render :show, status: :created, location: @chat }\n else\n format.html { render :new }\n format.json { render json: @chat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @myth = Myth.new(myth_params)\n\n\n respond_to do |format|\n if @myth.save\n @myth.mythsUsers << MythsUser.create(user: current_user, access_level: 2)\n format.html { redirect_to @myth, notice: 'Myth was successfully created.' }\n format.json { render :show, status: :created, location: @myth }\n else\n format.html { render :new }\n format.json { render json: @myth.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sleep_log = SleepLog.new(params[:sleep_log])\n\n respond_to do |format|\n if @sleep_log.save\n flash[:notice] = 'SleepLog was successfully created.'\n format.html { redirect_to(@sleep_log) }\n format.xml { render :xml => @sleep_log, :status => :created, :location => @sleep_log }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sleep_log.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @monkey = Monkey.new(params[:monkey])\n\n respond_to do |format|\n if @monkey.save\n format.html { redirect_to(@monkey, :notice => 'Monkey was successfully created.') }\n format.xml { render :xml => @monkey, :status => :created, :location => @monkey }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @monkey.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @chat = Chat.new(params[:chat])\n\n respond_to do |format|\n if @chat.save\n format.html { redirect_to @chat, notice: 'Chat was successfully created.' }\n format.json { render json: @chat, status: :created, location: @chat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @chat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dailystat = Dailystat.new(dailystat_params)\n\n respond_to do |format|\n if @dailystat.save\n format.html { redirect_to @dailystat, notice: 'Dailystat was successfully created.' }\n format.json { render :show, status: :created, location: @dailystat }\n else\n format.html { render :new }\n format.json { render json: @dailystat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @meats = Meat.all\n end",
"def new\n @thred = Thred.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thred }\n end\n end",
"def create\n @payments_ach = PaymentsAch.new(params[:payments_ach])\n\n respond_to do |format|\n if @payments_ach.save\n flash[:notice] = 'PaymentsAch was successfully created.'\n format.html { redirect_to(@payments_ach) }\n format.xml { render :xml => @payments_ach, :status => :created, :location => @payments_ach }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @payments_ach.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @game = Game.find(params[:game_id])\n @game.authorships.create_from_names(params[:authorship])\n respond_to do |format|\n flash[:notice] = 'Les autheurs sont enregistres'\n format.html { redirect_to game_path(@game) }\n format.xml { head :created, :location => authorship_url(@authorship) }\n end\n end",
"def create\n @boat = @harbour.boats.build(boat_params)\n @boat.save\n redirect_to harbour_boats_path(@harbour)\n # respond_to do |format|\n # if @boat.save\n # format.html { redirect_to harbour_boats_path, notice: 'Boat was successfully created.' }\n # format.json { render :show, status: :created, location: @boat }\n # else\n # format.html { render :new }\n # format.json { render json: @boat.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @twin = Twin.new(params[:twin])\n\n respond_to do |format|\n if @twin.save\n flash[:notice] = 'Twin was successfully created.'\n format.html { redirect_to(edit_twin_path(@twin)) }\n format.xml { render :xml => @twin, :status => :created, :location => @twin }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @twin.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @fan = Fan.new(params[:fan])\n\n respond_to do |format|\n if @fan.save\n format.html { render :action => 'thanks' }\n format.xml { render :xml => @fan, :status => :created, :location => @fan }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @fan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ourmail = Ourmail.new(ourmail_params)\n\n respond_to do |format|\n if @ourmail.save\n format.html { render action: 'thankyou'}\n\t#redirect_to @ourmail.thankyou, notice: 'Mail was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ourmail }\n else\n format.html { render action: 'new' }\n format.json { render json: @ourmail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @click_to_talks = ClickToTalk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @click_to_talks }\n end\n end",
"def create\n @brother = Brother.new(params[:brother])\n\n respond_to do |format|\n if @brother.save\n flash[:notice] = 'Brother was successfully created.'\n format.html { render :back }\n format.xml { render :xml => @brother, :status => :created, :location => @brother }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @brother.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def poteti_post(action, parameters = nil, session = nil, flash = nil)\n process_action(action, parameters, session, flash, 'POST')\n end",
"def post(action, params={}, options={})\n request(:post, action, params, options)\n end",
"def create\n \n begin\n @topic = Topic.new(params[ \"topic\" ]) \n rescue Exception => e \n respond_to do |format|\n format.xml { render :xml => errorRsp( e.message) }\n end\n return\n end\n \n \n logger.info log_hash \"Topic\", @topic.attributes\n \n # noting fatal happened with the 'new'\n respond_to do |format|\n begin \n if @topic.save\n format.xml { render :xml => successRsp }\n else\n format.xml { render :xml => errorRsp( @topic.errors.to_xml ) }\n end\n rescue Exception => e \n format.xml { render :xml => errorRsp( \"xx-\" + e.message ) }\n end\n end\n end",
"def create\n @groups_happening = GroupsHappening.new(params[:groups_happening])\n\n respond_to do |format|\n if @groups_happening.save\n flash[:notice] = 'GroupsHappening was successfully created.'\n format.html { redirect_to(groups_happenings_path) }\n format.xml { render :xml => @groups_happening, :status => :created, :location => @groups_happening }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @groups_happening.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @mattch = Mattch.new(mattch_params)\n\n respond_to do |format|\n if @mattch.save\n format.html { redirect_to @mattch, notice: 'Mattch was successfully created.' }\n format.json { render :show, status: :created, location: @mattch }\n else\n format.html { render :new }\n format.json { render json: @mattch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @seat.save\n format.html { redirect_to flights_path(@flight), notice: 'Seat was successfully created.' }\n format.json { render :show, status: :created, location: @seat }\n else\n format.html { render :new }\n format.json { render json: @seat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @myssion = Myssion.new(myssion_params)\n\n respond_to do |format|\n if @myssion.save\n format.html { redirect_to @myssion, notice: 'Myssion was successfully created.' }\n format.json { render :show, status: :created, location: @myssion }\n else\n format.html { render :new }\n format.json { render json: @myssion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mydebt = Mydebt.new(params[:mydebt])\n\n respond_to do |format|\n if @mydebt.save\n format.html { redirect_to @mydebt, notice: 'Mydebt was successfully created.' }\n format.json { render json: @mydebt, status: :created, location: @mydebt }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mydebt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @postit = Postit.new(postit_params)\n @postit.user = current_user\n\n respond_to do |format|\n if @postit.save\n broadcast_notification @postit\n broadcast_actioncable \"retrospective\", \"createPostit\", @postit.to_json(include: [:user,comments: {include: :actor }])\n format.html { redirect_to @postit, notice: 'Postit was successfully created.' }\n format.json { render json: @postit.to_json(include: :user) }\n else\n format.html { render :new }\n format.json { render json: @postit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @feedback = Feedback.new(params[:feedback])\n\n respond_to do |format|\n if @feedback.save\n flash[:feed_key] = @feedback.editable_key\n flash[:notice] = 'Your Feedback was successfully created.Thank you! We really appreciate you participation.'\n format.html { redirect_to feedback_url(@feedback) }\n format.xml { head :created, :location => feedback_url(@feedback) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feedback.errors.to_xml }\n end\n end\n end",
"def index\n @threds = Thred.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @threds }\n end\n end",
"def create\n @chat_room = ChatRoom.new(params[:chat_room])\n\n respond_to do |format|\n if @chat_room.save\n flash[:notice] = 'ChatRoom was successfully created.'\n format.html { redirect_to(:action => 'show', :id => @chat_room) }\n format.xml { render :xml => @chat_room, :status => :created, :location => @chat_room }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @chat_room.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @my = My.new(params[:my])\n\n respond_to do |format|\n if @my.save\n format.html { redirect_to(@my, :notice => 'My was successfully created.') }\n format.xml { render :xml => @my, :status => :created, :location => @my }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @my.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def give_gift_friends\t\n @gift_template = GiftTemplate.find(params[:gift_template_id])\n @organization = @gift_template.organization\n @related_trinkons = @gift_template.similar_trinkons\n if (@organization.display_type == \"unbranded\")\n\t @postTitle = @gift_template.title\n else\n\t @postTitle = @organization.display_name + \" \" + @gift_template.title\n end\n\t @app_id = APP_ID\n\t @link = FACEBOOK_URL\n\n @gift_state = create_gift_state\n @redirect_uri = GIVE_CALLBACK\n\t\t\n\t current_user = IndividualUser.find(session[:individual_user_id])\n\t\t\n\t friend_list = []\n\t\n\t current_user.friends_from_api(session[:access_token]).each do |friend| \n\t friend_list << Hash[\"label\" => friend[\"name\"], \n \"value\" => friend[\"name\"], \"id\" => friend[\"id\"].to_i]\n\t end\n\t @friend_list_json = friend_list.to_json\n\t\n\t # assures the gift can be sent (see gift_template.rb, can_be_sent), and that its quantity is > 0. Provides proper error message if not. -TS April 27, 2012\n\t unless (@gift_template.can_be_sent(current_user.facebook_id) && \n @gift_template.quantity_available > 0)\n\t\t redirect_to(:action => \"show_organization\", \n :organization_id => @gift_template.organization_id)\n\t\t if @gift_template.status == \"admin_visible\"\n\t\t flash[:notice] = \"Sorry, that gift can only be sent by authorized senders.\"\n\t\t else\n\t\t flash[:notice] = \"Sorry, that gift can't be sent right now.\"\n\t end\n\t end\n end",
"def create(name=\"Default name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Post.new(@url)\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n response.body\n end",
"def create\n @tattoo = Tattoo.new(params[:tattoo])\n\n respond_to do |format|\n if @tattoo.save\n format.html { redirect_to @tattoo, notice: 'Tattoo was successfully created.' }\n format.json { render json: @tattoo, status: :created, location: @tattoo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tattoo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @datashows = Datashow.new(params[:datashow])\n\n respond_to do |format|\n if @datashows.save\n flash[:notice] = 'RESERVA REALIZADA COM SUCESSO'\n format.html { redirect_to(@datashows) }\n format.xml { render :xml => @datashows, :status => :created, :location => @datashow }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @datashows.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n #@feat = Feat.new(params[:feat])\n @feat = @character.feats.build(params[:feat])\n\n respond_to do |format|\n if @feat.save\n flash[:notice] = 'Feat was successfully created.'\n format.html { redirect_to(edit_character_path(@character)) }\n format.xml { render :xml => @feat, :status => :created, :location => @feat }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @feat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tpago = Tpago.new(params[:tpago])\n\n respond_to do |format|\n if @tpago.save\n format.html { redirect_to(@tpago, :notice => 'Tpago was successfully created.') }\n format.xml { render :xml => @tpago, :status => :created, :location => @tpago }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tpago.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @rat = Rat.new(rat_params)\n\n respond_to do |format|\n if @rat.save\n format.html { redirect_to @rat, notice: 'Rat was successfully created.' }\n format.json { render :show, status: :created, location: @rat }\n else\n format.html { render :new }\n format.json { render json: @rat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @patrimonio = Patrimonio.new(params[:patrimonio])\n\n respond_to do |format|\n if @patrimonio.save\n flash[:notice] = 'Patrimonio criado com sucesso.'\n format.html { redirect_to(@patrimonio) }\n format.xml { render :xml => @patrimonio, :status => :created, :location => @patrimonio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @patrimonio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @chats = Chat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chats }\n end\n end",
"def create\n @adjunto = Adjunto.new(params[:adjunto])\n\n respond_to do |format|\n if @adjunto.save\n format.html { redirect_to(@adjunto, :notice => 'Adjunto was successfully created.') }\n format.xml { render :xml => @adjunto, :status => :created, :location => @adjunto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @adjunto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @twet = Twet.new(twet_params)\n\n respond_to do |format|\n if @twet.save\n format.html { redirect_to @twet, notice: \"Twet was successfully created.\" }\n format.json { render :show, status: :created, location: @twet }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @twet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @friend = Friend.new(params[:friend])\n @friend.save\n respond_with(@friend)\n end",
"def create\n @chimpaction = Chimpaction.new(params[:chimpaction])\n\n respond_to do |format|\n if @chimpaction.save\n format.html { redirect_to(chimpactions_url, :notice => 'Chimpaction was successfully created.') }\n format.xml { render :xml => @chimpaction, :status => :created, :location => @chimpaction }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @chimpaction.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ipc_seat = IpcSeat.new(ipc_seat_params)\n\n respond_to do |format|\n if @ipc_seat.save\n format.html { redirect_to @ipc_seat, notice: 'Ipc seat was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ipc_seat }\n else\n format.html { render action: 'new' }\n format.json { render json: @ipc_seat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @feed = Feed.new(feed_params)\n\n respond_to do |format|\n if @feed.save\n format.html { redirect_to :root, notice: \"#{@feed.name} Спасибо за ваше сообщение. В самые ближайшие сроки администраор его прочитает и ответит вам \"}\n else\n format.html { render 'welcome/feedback' }\n format.json { render json: @feed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @prospect = Prospect.new(params[:prospect])\n\n respond_to do |format|\n if @prospect.save\n ReservationMailer.deliver_sent(@prospect, @prospect.house)\n flash[:notice] = \"Votre demande d'informations a été pris en compte.\"\n format.html { redirect_to(house_path(@prospect.house)) }\n format.xml { render :xml => @prospect, :status => :created, :location => @prospect }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @prospect.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post\n response = HTTParty.post(servlet_url,\n :body => to_xml,\n :headers => { 'Content-Type' => 'application/xml' }\n ).response\n\n return Dhl::Shipment::Response.new(response.body)\n rescue Exception => e\n request_xml = if @to_xml.to_s.size>0\n @to_xml\n else\n '<not generated at time of error>'\n end\n\n response_body = if (response && response.body && response.body.to_s.size > 0)\n response.body\n else\n '<not received at time of error>'\n end\n\n log_level = if e.respond_to?(:log_level)\n e.log_level\n else\n :critical\n end\n\n log_request_and_response_xml(log_level, e, request_xml, response_body )\n raise e\n end",
"def create\n @relationship = @character.relationships.new(params[:relationship])\n \n respond_to do |format|\n if @relationship.save\n format.html { redirect_to([@character,@relationship], :notice => 'Relationship was successfully created.') }\n format.xml { render :xml => @relationship, :status => :created, :location => @relationship }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @relationship.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tl_sach = TlSach.new(tl_sach_params)\n\n respond_to do |format|\n if @tl_sach.save\n format.html { redirect_to @tl_sach, notice: \"Tl sach was successfully created.\" }\n format.json { render :show, status: :created, location: @tl_sach }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @tl_sach.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.534782",
"0.53325224",
"0.5322265",
"0.5281594",
"0.5169899",
"0.51271677",
"0.51141894",
"0.5107345",
"0.50853515",
"0.50703764",
"0.5069859",
"0.5030495",
"0.5006207",
"0.5004209",
"0.5003594",
"0.50027865",
"0.49882177",
"0.49855292",
"0.49725974",
"0.49716353",
"0.49418795",
"0.49393243",
"0.49382663",
"0.49291143",
"0.4927943",
"0.49249858",
"0.49212828",
"0.49211478",
"0.4919546",
"0.49173912",
"0.4914334",
"0.49074543",
"0.4901618",
"0.4895346",
"0.48923326",
"0.48903772",
"0.48857206",
"0.48728868",
"0.48673663",
"0.4861288",
"0.48582438",
"0.4824775",
"0.48246604",
"0.4821618",
"0.48214808",
"0.48196578",
"0.48132575",
"0.48064312",
"0.47933504",
"0.4789619",
"0.4782336",
"0.4779747",
"0.4778152",
"0.47762802",
"0.47740787",
"0.47702283",
"0.47698626",
"0.47648683",
"0.47615904",
"0.47588214",
"0.47561142",
"0.47557527",
"0.47546163",
"0.47533438",
"0.47517422",
"0.47492352",
"0.47481972",
"0.47473943",
"0.4746794",
"0.4746756",
"0.47426516",
"0.47407606",
"0.47393018",
"0.47389868",
"0.47317576",
"0.47277924",
"0.47276384",
"0.47262377",
"0.4713717",
"0.47095928",
"0.47088507",
"0.4706454",
"0.47038448",
"0.47002077",
"0.46998417",
"0.46988574",
"0.46985045",
"0.4695144",
"0.46936876",
"0.4693339",
"0.46923634",
"0.46893713",
"0.46893382",
"0.4688907",
"0.4688571",
"0.46869507",
"0.4686106",
"0.46856794",
"0.46837935",
"0.4682004"
] | 0.5544318 | 0 |
PUT /threats/1 PUT /threats/1.xml | def update
@threat = Threat.find(params[:id])
respond_to do |format|
if @threat.update_attributes(params[:threat])
format.html { redirect_to(@threat, :notice => 'Threat was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @threat.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 update\n @seat = Seat.find(params[:id])\n\n respond_to do |format|\n if @seat.update_attributes(params[:seat])\n format.html { redirect_to(@seat, :notice => 'Seat was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @seat.errors, :status => :unprocessable_entity }\n end\n end\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(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 @chat = Chat.find(params[:id])\n\n respond_to do |format|\n if @chat.update_attributes(params[:chat])\n flash[:notice] = 'BATE PAPO ATUALIZADO.'\n format.html { redirect_to(@chat) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @chat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @coating.update_attributes(params[:coating])\n format.html { redirect_to(@coating, :notice => t(\"screens.notice.successfully_updated\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @coating.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @chirp = Chirp.find(params[:id])\n\n respond_to do |format|\n if @chirp.update_attributes(params[:chirp])\n flash[:notice] = 'Chirp was successfully updated.'\n format.html { redirect_to(@chirp) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @chirp.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @goat = Goat.find(params[:id])\n\n respond_to do |format|\n if @goat.update_attributes(params[:goat])\n format.html { redirect_to @goat, notice: 'Goat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @goat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @eat = Eat.find(params[:id])\n\n respond_to do |format|\n if @eat.update_attributes(params[:eat])\n flash[:notice] = 'Eat was successfully updated.'\n format.html { redirect_to installation_eat_path(@installation, @eat) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @eat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @t1 = T1.find(params[:id])\n\n respond_to do |format|\n if @t1.update_attributes(params[:t1])\n flash[:notice] = 'T1 was successfully updated.'\n format.html { redirect_to(@t1) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @t1.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n if @boat.update_attributes(params[:boat])\n format.html { redirect_to(@boat, :notice => 'Boat was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @boat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @atom = Atom.find(params[:id])\n\n respond_to do |format|\n if @atom.update_attributes(params[:atom])\n flash[:notice] = 'Atom was successfully updated.'\n format.html { redirect_to(@atom) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @atom.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @seat = Seat.find(params[:id])\n\n respond_to do |format|\n if @seat.update_attributes(params[:seat])\n format.html { redirect_to @seat, notice: 'Seat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @seat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cattle_id = CattleId.find(params[:id])\n\n respond_to do |format|\n if @cattle_id.update_attributes(params[:cattle_id])\n format.html { redirect_to(@cattle_id, :notice => 'Cattle was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cattle_id.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end",
"def update\n respond_to do |format|\n if @meat.update(meat_params)\n format.html { redirect_to @meat, notice: 'Meat was successfully updated.' }\n format.json { render :show, status: :ok, location: @meat }\n else\n format.html { render :edit }\n format.json { render json: @meat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kontakty = Kontakty.find(params[:id])\n\n respond_to do |format|\n if @kontakty.update_attributes(params[:kontakty])\n flash[:notice] = 'Kontakty was successfully updated.'\n format.html { redirect_to(@kontakty) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @kontakty.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @scotty_dog_saying = ScottyDogSaying.find(params[:id])\n\n respond_to do |format|\n if @scotty_dog_saying.update_attributes(params[:scotty_dog_saying])\n flash[:notice] = 'Thanks for giving me something better to say. Scotty Dog Saying was successfully updated.'\n format.html { redirect_to(scotty_dog_sayings_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @scotty_dog_saying.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n if @tso.update_attributes(params[:tso])\n flash[:notice] = 'Tso was successfully updated.'\n format.html { redirect_to(@tso) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tso.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def 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\n @click_to_talk = ClickToTalk.find(params[:id])\n\n respond_to do |format|\n if @click_to_talk.update_attributes(params[:click_to_talk])\n flash[:notice] = 'ClickToTalk was successfully updated.'\n format.html { redirect_to(@click_to_talk) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @click_to_talk.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n if @friend.update_attributes(params[:friend])\n flash[:notice] = 'Friend was successfully updated.'\n format.html { redirect_to(@friend) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ocat = Ocat.find(params[:id])\n\n respond_to do |format|\n if @ocat.update_attributes(params[:ocat])\n format.html { redirect_to @ocat, notice: 'Ocat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ocat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thred = Thred.find(params[:id])\n\n respond_to do |format|\n if @thred.update_attributes(params[:thred])\n format.html { redirect_to(@thred, :notice => 'Thread was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @thred.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @bottle = Bottle.find(params[:id])\n\n respond_to do |format|\n if @bottle.update_attributes(params[:bottle])\n format.html { redirect_to(@bottle, :notice => 'Bottle was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bottle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tservicio = Tservicio.find(params[:id])\n\n respond_to do |format|\n if @tservicio.update_attributes(params[:tservicio])\n format.html { redirect_to(@tservicio, :notice => 'Tservicio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tservicio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @friend = Friend.find(params[:id])\n\n respond_to do |format|\n if @friend.update_attributes(params[:friend])\n format.html { redirect_to(@friend, :notice => 'Friend was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @shout = Shout.find(params[:id])\n\n respond_to do |format|\n if @shout.update_attributes(params[:shout])\n format.html { redirect_to(@shout, :notice => 'Shout was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shout.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @shout = Shout.find(params[:id])\n\n respond_to do |format|\n if @shout.update_attributes(params[:shout])\n format.html { redirect_to(@shout, :notice => 'Shout was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shout.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @story = Story.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n flash[:notice] = 'Story was successfully updated.'\n format.html { redirect_to(@story) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @story.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @story = Story.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n flash[:notice] = 'Story was successfully updated.'\n format.html { redirect_to(@story) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @story.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @history_thermostat.update(history_thermostat_params)\n format.html { redirect_to @history_thermostat, notice: 'History thermostat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @history_thermostat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @monkey = Monkey.find(params[:id])\n\n respond_to do |format|\n if @monkey.update_attributes(params[:monkey])\n format.html { redirect_to(@monkey, :notice => 'Monkey was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @monkey.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @friend = Friend.find(params[:id])\n @friend.update_attributes(params[:friend])\n respond_with(@friend)\n end",
"def update\n @story = Story.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to(@story, :notice => 'Story was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @story.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @habitat = Habitat.find(params[:id])\n\n respond_to do |format|\n if @habitat.update_attributes(params[:habitat])\n flash[:notice] = 'Habitat was successfully updated.'\n format.html { redirect_to habitat_url(@habitat) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @habitat.errors.to_xml }\n end\n end\n end",
"def update\n @trip_story = TripStory.find(params[:id])\n\n respond_to do |format|\n if @trip_story.update_attributes(params[:trip_story])\n flash[:notice] = 'TripStory was successfully updated.'\n format.html { redirect_to(@trip_story) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trip_story.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @heartbeat = Heartbeat.find(params[:id])\n\n respond_to do |format|\n if @heartbeat.update_attributes(params[:heartbeat])\n format.html { redirect_to @heartbeat, notice: 'Heartbeat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heartbeat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gift = Gift.find(params[:id])\n\n respond_to do |format|\n if @gift.update_attributes(params[:gift])\n flash[:notice] = 'Gift was successfully updated.'\n format.html { redirect_to(@gift) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @gift.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @setting = Setting.find(params[:id])\n @setting.notice_at = Time.local(2011, 10, 31, @setting.notice_at.hour, @setting.notice_at.min)\n @setting.update_attributes(params[:setting])\n respond_to do |format|\n format.html { redirect_to(setting_url(@setting))}\n format.xml { head :ok }\n end\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 #@feat = Feat.find(params[:id])\n @feat = @character.feats.find(params[:id])\n\n respond_to do |format|\n if @feat.update_attributes(params[:feat])\n flash[:notice] = 'Feat was successfully updated.'\n format.html { redirect_to(edit_character_path(@character)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @feat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @kontak = Kontak.find(params[:id])\n\n respond_to do |format|\n if @kontak.update_attributes(params[:kontak])\n flash[:notice] = 'Kontak was successfully updated.'\n format.html { redirect_to(@kontak) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @kontak.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @sti = Sti.find(params[:id])\n\n respond_to do |format|\n if @sti.update_attributes(params[:sti])\n flash[:notice] = 'Sti was successfully updated.'\n format.html { redirect_to(@sti) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sti.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @strelki = Strelki.find(params[:id])\n\n respond_to do |format|\n if @strelki.update_attributes(params[:strelki])\n flash[:notice] = 'Strelki was successfully updated.'\n format.html { redirect_to(@strelki) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @strelki.errors, :status => :unprocessable_entity }\n end\n end\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 update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to(@topic, :notice => 'Topic was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tpago = Tpago.find(params[:id])\n\n respond_to do |format|\n if @tpago.update_attributes(params[:tpago])\n format.html { redirect_to(@tpago, :notice => 'Tpago was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tpago.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @threat = Threat.find(params[:id])\n @threat.destroy\n\n respond_to do |format|\n format.html { redirect_to(threats_url) }\n format.xml { head :ok }\n end\n end",
"def update\n @housing = Housing.find(params[:id])\n\n respond_to do |format|\n if @housing.update_attributes(params[:housing])\n flash[:notice] = 'Housing was successfully updated.'\n format.html { redirect_to(@housing) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @housing.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n expire_front \n\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tattoo = Tattoo.find(params[:id])\n\n respond_to do |format|\n if @tattoo.update_attributes(params[:tattoo])\n format.html { redirect_to @tattoo, notice: 'Tattoo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tattoo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:success] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @sticky = Sticky.find(params[:id])\n\n respond_to do |format|\n if @sticky.update_attributes(params[:sticky])\n format.html { redirect_to @sticky, notice: 'Sticky was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sticky.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @patrimonio = Patrimonio.find(params[:id])\n\n respond_to do |format|\n if @patrimonio.update_attributes(params[:patrimonio])\n flash[:notice] = 'Patrimonio salvo com sucesso.'\n format.html { redirect_to(@patrimonio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @patrimonio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @story = Story.find(params[:id])\n @story.update_attributes(params[:story])\n respond_with @story\n end",
"def update\n @first1 = First1.find(params[:id])\n\n respond_to do |format|\n if @first1.update_attributes(params[:first1])\n flash[:notice] = 'First1 was successfully updated.'\n format.html { redirect_to(@first1) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @first1.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @hcontrato = Hcontrato.find(params[:id])\n\n respond_to do |format|\n if @hcontrato.update_attributes(params[:hcontrato])\n format.html { redirect_to(@hcontrato, :notice => 'Hcontrato was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @hcontrato.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @xaction = Xaction.find(params[:id])\n\n respond_to do |format|\n if @xaction.update_attributes(params[:xaction])\n format.html { redirect_to @xaction, notice: 'Xaction was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @xaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bookfair = Bookfair.find(params[:id])\n\n respond_to do |format|\n if @bookfair.update_attributes(params[:bookfair])\n format.html { redirect_to(@bookfair, :notice => 'Bookfair was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookfair.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @seat.update(seat_params)\n format.html { redirect_to @seat, notice: 'Seat was successfully updated.' }\n format.json { render :show, status: :ok, location: @seat }\n else\n format.html { render :edit }\n format.json { render json: @seat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @seat.update(seat_params)\n format.html { redirect_to @seat, notice: 'Seat was successfully updated.' }\n format.json { render :show, status: :ok, location: @seat }\n else\n format.html { render :edit }\n format.json { render json: @seat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @seat.update(seat_params)\n format.html { redirect_to @seat, notice: 'Seat was successfully updated.' }\n format.json { render :show, status: :ok, location: @seat }\n else\n format.html { render :edit }\n format.json { render json: @seat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def update\n @my = My.find(params[:id])\n\n respond_to do |format|\n if @my.update_attributes(params[:my])\n format.html { redirect_to(@my, :notice => 'My was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @my.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @contrato = Contrato.find(params[:id])\n\n respond_to do |format|\n if @contrato.update_attributes(params[:contrato])\n format.html { redirect_to(@contrato, :notice => 'Contrato was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contrato.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @story = Story.find(params[:id])\n #@story = Story.friendly.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to @story, notice: 'Story was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @neighborhood_topic = NeighborhoodTopic.find(params[:id])\n\n respond_to do |format|\n if @neighborhood_topic.update_attributes(params[:neighborhood_topic])\n format.html { redirect_to @neighborhood_topic, notice: 'Neighborhood topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @neighborhood_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @habitat_type = HabitatType.find(params[:id])\n\n respond_to do |format|\n if @habitat_type.update_attributes(params[:habitat_type])\n flash[:notice] = 'HabitatType was successfully updated.'\n format.html { redirect_to habitat_type_url(@habitat_type) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @habitat_type.errors.to_xml }\n end\n end\n end",
"def update\n @offlearn = Offlearn.find(params[:id])\n\n respond_to do |format|\n if @offlearn.update_attributes(params[:offlearn])\n flash[:notice] = 'Offlearn was successfully updated.'\n format.html { redirect_to(@offlearn) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @offlearn.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @atom.update_attributes(params[:atom])\n format.html { redirect_to @atom, notice: 'Atom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @atom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @buddy = Buddy.find(params[:id])\n\n respond_to do |format|\n if @buddy.update_attributes(params[:buddy])\n flash[:notice] = 'Buddy was successfully updated.'\n format.html { redirect_to(@buddy) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @buddy.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = \"Topic was successfully updated.\"\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n if @nossos_servico.update_attributes(params[:nossos_servico])\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket_action = TicketAction.find(params[:id])\n\n respond_to do |format|\n if @ticket_action.update_attributes(params[:ticket_action])\n flash[:notice] = 'TicketAction was successfully updated.'\n format.html { redirect_to(@ticket_action) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticket_action.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @friend_request = FriendRequest.find(params[:id])\n respond_to do |format|\n if @friend_request.update_attributes(params[:friend_request])\n format.html { redirect_to(@friend_request, :notice => 'Friend request was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend_request.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |wants|\n if @ticket.update_attributes(params[:ticket])\n flash[:notice] = 'Ticket was successfully updated.'\n wants.html { redirect_to(@ticket) }\n wants.xml { head :ok }\n wants.json { head :ok }\n else\n wants.html { render :action => \"edit\" }\n wants.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n wants.json { render :json => @ticket.errors.full_messages, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tatoo.update(tatoo_params)\n format.html { redirect_to tatoos_path, notice: 'Tatoo was successfully updated.' }\n format.json { render :show, status: :ok, location: @tatoo }\n else\n format.html { render :edit }\n format.json { render json: @tatoo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tiposcontrato = Tiposcontrato.find(params[:id])\n\n respond_to do |format|\n if @tiposcontrato.update_attributes(params[:tiposcontrato])\n flash[:notice] = 'Tiposcontrato was successfully updated.'\n format.html { redirect_to(@tiposcontrato) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tiposcontrato.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @catastrosdato = Catastrosdato.find(params[:id])\n\n respond_to do |format|\n if @catastrosdato.update_attributes(params[:catastrosdato])\n format.html { redirect_to(@catastrosdato, :notice => 'Catastrosdato was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @catastrosdato.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @matter = Matter.find(params[:id])\n\n respond_to do |format|\n if @matter.update_attributes(params[:matter])\n format.html { redirect_to(@matter, :notice => 'Matter was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @matter.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @beat = Beat.find(params[:id])\n\n respond_to do |format|\n if @beat.update_attributes(params[:beat])\n format.html { redirect_to @beat, notice: 'Beat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @beat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @friend_request = FriendRequest.find(params[:id])\n\n respond_to do |format|\n if @friend_request.update_attributes(params[:friend_request])\n flash[:notice] = 'FriendRequest was successfully updated.'\n format.html { redirect_to(@friend_request) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @friend_request.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @omatsuri = Omatsuri.find(params[:id])\n\n respond_to do |format|\n if @omatsuri.update_attributes(params[:omatsuri])\n flash[:notice] = 'Omatsuri was successfully updated.'\n format.html { redirect_to(@omatsuri) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @omatsuri.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @saying = Saying.find(params[:id])\n\n respond_to do |format|\n if @saying.update_attributes(params[:saying])\n format.html { redirect_to @saying}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @saying.errors, status: :unprocessable_entity }\n end\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 @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n flash[:notice] = 'Ticket was successfully updated.'\n format.html { redirect_to(@ticket) }\n format.xml { head :ok }\n else\n format.html { render :edit }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n if @socio.update_attributes(params[:socio])\n format.html { redirect_to @socio, :notice => 'Socio atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @socio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @cat = Cat.find(params[:id])\n\n respond_to do |format|\n if @cat.update_attributes(params[:cat])\n _update_topics \n format.html { redirect_to action: \"edit\", notice: 'Cat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @senhas = Senha.find(params[:id])\n\n respond_to do |format|\n if @senhas.update_attributes(params[:senha])\n flash[:notice] = 'SENHA SALVA COM SUCESSO.'\n format.html { redirect_to(senhas_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @senhas.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @reqinfo = Reqinfo.find(params[:id])\n\n respond_to do |format|\n if @reqinfo.update_attributes(params[:reqinfo])\n flash[:notice] = 'Reqinfo was successfully updated.'\n format.html { redirect_to(@reqinfo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @reqinfo.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.62588763",
"0.5713151",
"0.56344104",
"0.5630028",
"0.55805975",
"0.55342805",
"0.5496455",
"0.5488505",
"0.54764646",
"0.5466151",
"0.5464442",
"0.53870195",
"0.5366518",
"0.5353993",
"0.5341912",
"0.53367",
"0.5331451",
"0.53199977",
"0.5311789",
"0.5303575",
"0.52901584",
"0.528654",
"0.5267319",
"0.5256099",
"0.52527016",
"0.52448744",
"0.52438515",
"0.5230656",
"0.52274144",
"0.52274144",
"0.52191865",
"0.52191865",
"0.52065545",
"0.5204415",
"0.5198834",
"0.519292",
"0.51879907",
"0.5184904",
"0.5177651",
"0.5177054",
"0.5171813",
"0.5164283",
"0.5161184",
"0.5159777",
"0.5144152",
"0.5129144",
"0.51236457",
"0.5122245",
"0.51212996",
"0.51205397",
"0.5116442",
"0.5112794",
"0.5112794",
"0.5112794",
"0.5112794",
"0.5112794",
"0.5108489",
"0.51081365",
"0.51042974",
"0.5103391",
"0.50913084",
"0.5090062",
"0.5088283",
"0.5086347",
"0.50817764",
"0.5080672",
"0.50767785",
"0.507561",
"0.507561",
"0.507561",
"0.50753736",
"0.50737214",
"0.5069838",
"0.5069499",
"0.50633675",
"0.5061294",
"0.5060984",
"0.50579077",
"0.505646",
"0.50533915",
"0.50516534",
"0.5044866",
"0.5039914",
"0.5039405",
"0.5035686",
"0.50352967",
"0.50322944",
"0.5027149",
"0.50256866",
"0.502539",
"0.50222516",
"0.50187725",
"0.50172955",
"0.50172114",
"0.50166094",
"0.50156015",
"0.50153285",
"0.5014476",
"0.5013339",
"0.5010714"
] | 0.5673207 | 2 |
DELETE /threats/1 DELETE /threats/1.xml | def destroy
@threat = Threat.find(params[:id])
@threat.destroy
respond_to do |format|
format.html { redirect_to(threats_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @boat = Boat.find(params[:id])\n @boat.destroy\n\n respond_to do |format|\n format.html { redirect_to(boats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @t1 = T1.find(params[:id])\n @t1.destroy\n\n respond_to do |format|\n format.html { redirect_to(t1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @cat1 = Cat1.find(params[:id])\r\n @cat1.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(cat1s_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @seat = Seat.find(params[:id])\n @seat.destroy\n\n respond_to do |format|\n format.html { redirect_to(seats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @feat = @person.feats.find(params[:id])\n @feat.destroy\n\n respond_to do |format|\n format.html { redirect_to(person_feats_url(@person)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hcontrato = Hcontrato.find(params[:id])\n @hcontrato.destroy\n\n respond_to do |format|\n format.html { redirect_to(hcontratos_url) }\n format.xml { head :ok }\n end\n end",
"def delete_by_id id, opts = {}\n update opts.merge(:data => xml.delete_by_id(id))\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n @contrato = Contrato.find(params[:id])\n @contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to(contratos_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @cattle_id = CattleId.find(params[:id])\n @cattle_id.destroy\n\n respond_to do |format|\n format.html { redirect_to(cattle_ids_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @chat = Chat.find(params[:id])\n @chat.destroy\n\n respond_to do |format|\n format.html { redirect_to(chats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @helocagree = Helocagree.find(params[:id])\n @helocagree.destroy\n\n respond_to do |format|\n format.html { redirect_to(helocagrees_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"/\") }\n format.xml { head :ok }\n end\n end",
"def destroy\n @chirp = Chirp.find(params[:id])\n @chirp.destroy\n\n respond_to do |format|\n format.html { redirect_to(chirps_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @monkey = Monkey.find(params[:id])\n @monkey.destroy\n\n respond_to do |format|\n format.html { redirect_to(monkeys_url) }\n format.xml { head :ok }\n end\n end",
"def destroy1\n @todo = Todo.find(params[:id])\n @todo.destroy\n\n respond_to do |format|\n format.html { redirect_to(todos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hikiyama = Hikiyama.find(params[:id])\n @hikiyama.destroy\n\n respond_to do |format|\n format.html { redirect_to(@omatsuri) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sleep_log = SleepLog.find(params[:id])\n @sleep_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(sleep_logs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @achat.destroy\n respond_to do |format|\n format.html { redirect_to achats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @first1 = First1.find(params[:id])\n @first1.destroy\n\n respond_to do |format|\n format.html { redirect_to(first1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @my = My.find(params[:id])\n @my.destroy\n\n respond_to do |format|\n format.html { redirect_to(mies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @catena = Catena.find(params[:id])\n @catena.destroy\n\n respond_to do |format|\n format.html { redirect_to(catenas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @kontak = Kontak.find(params[:id])\n @kontak.destroy\n\n respond_to do |format|\n format.html { redirect_to(kontaks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @thermostat.destroy\n respond_to do |format|\n format.html { redirect_to thermostats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @goat = Goat.find(params[:id])\n @goat.destroy\n\n respond_to do |format|\n format.html { redirect_to goats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @click_to_talk = ClickToTalk.find(params[:id])\n @click_to_talk.destroy\n\n respond_to do |format|\n format.html { redirect_to(click_to_talks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @kontakty = Kontakty.find(params[:id])\n @kontakty.destroy\n\n respond_to do |format|\n format.html { redirect_to(kontakties_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @action_log = ActionLog.find(params[:id])\n @action_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(action_logs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(dossiers_url) }\n format.xml { head :ok }\n end\n end",
"def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end",
"def destroy\r\n @razdel1 = Razdel1.find(params[:id])\r\n @razdel1.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(razdel1s_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n #@feat = Feat.find(params[:id])\n @feat = @character.feats.find(params[:id])\n @feat.destroy\n\n respond_to do |format|\n format.html { redirect_to(edit_character_path(@character)) }\n format.xml { head :ok }\n end\n end",
"def delete() #DELETE film1.delete (removes 1 film)\n sql = \"DELETE FROM films WHERE id = $1;\"\n values = [@id]\n SqlRunner.run(sql, values)\n end",
"def destroy\n @been2other = Been2other.find(params[:id])\n @been2other.destroy\n\n respond_to do |format|\n format.html { redirect_to(been2others_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @catastrosdato = Catastrosdato.find(params[:id])\n @catastrosdato.destroy\n\n respond_to do |format|\n format.html { redirect_to(catastrosdatos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cat = Cat.find(params[:id])\n @cat.destroy\n\n respond_to do |format|\n format.html { redirect_to(cats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to(datos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to(datos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @history_thermostat.destroy\n respond_to do |format|\n format.html { redirect_to history_thermostats_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @forum_cat_l1 = ForumCatL1.find(params[:id])\n @forum_cat_l1.destroy\n\n respond_to do |format|\n format.html { redirect_to(forum_cat_l1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @datashows = Datashow.find(params[:id])\n @datashows.destroy\n\n respond_to do |format|\n format.html { redirect_to(datashows_url) }\n format.xml { head :ok }\n end\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def destroy\n @tiposcontrato = Tiposcontrato.find(params[:id])\n @tiposcontrato.destroy\n\n respond_to do |format|\n format.html { redirect_to(tiposcontratos_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def destroy\n @ganho = Ganho.find(params[:id])\n @ganho.destroy\n\n respond_to do |format|\n format.html { redirect_to(ganhos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @chimpaction = Chimpaction.find(params[:id])\n @chimpaction.destroy\n\n respond_to do |format|\n format.html { redirect_to(chimpactions_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end",
"def destroy\n @chamados = Chamado.find(params[:id])\n @chamados.destroy\n respond_to do |format|\n format.html { redirect_to(chamados_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tstat = Tstat.find(params[:id])\n @tstat.destroy\n\n respond_to do |format|\n format.html { redirect_to(tstats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @brother = Brother.find(params[:id])\n @brother.destroy\n\n respond_to do |format|\n format.html { redirect_to(brothers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relationship = Relationship.find(params[:id])\n @relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to(relationships_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @thred = Thred.find(params[:id])\n\tif @thred.user_id == current_user.id\n @thred.destroy\nend\n\n respond_to do |format|\n format.html { redirect_to(:controller => \"topics\", :action => \"topicsList\") }\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 destroy\n @tx = Tx.find(params[:id])\n @tx.destroy\n\n respond_to do |format|\n format.html { redirect_to(txes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aisle = Aisle.find(params[:id])\n @aisle.destroy\n\n respond_to do |format|\n format.html { redirect_to(aisles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @senhas = Senha.find(params[:id])\n @senhas.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @traffic = Traffic.find(params[:id])\n @traffic.destroy\n\n respond_to do |format|\n format.html { redirect_to(traffics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bottle = Bottle.find(params[:id])\n @bottle.destroy\n\n respond_to do |format|\n format.html { redirect_to(bottles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @log = @client.logs.find(params[:id])\n @log.destroy\n\n respond_to do |format|\n format.html { redirect_to(client_url(@client)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @attend = Attend.find(params[:id])\n @attend.destroy\n\n respond_to do |format|\n format.html { redirect_to(attends_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @beat = Beat.find(params [:id])\n @beat.destroy\n\n respond_to do |format|\n format.html { redirect_to post_comment_url(@lesson) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relatestagiario = Relatestagiario.find(params[:id])\n @relatestagiario.destroy\n\n respond_to do |format|\n format.html { redirect_to(relatestagiarios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stat = Stat.find(params[:id])\n @stat.destroy\n\n respond_to do |format|\n format.html { redirect_to(stats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stat = Stat.find(params[:id])\n @stat.destroy\n\n respond_to do |format|\n format.html { redirect_to(stats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @patrimonio = Patrimonio.find(params[:id])\n @patrimonio.destroy\n\n respond_to do |format|\n format.html { redirect_to(patrimonios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipos_contratos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @nom = Nom.find(params[:id])\n @nom.destroy\n\n respond_to do |format|\n format.html { redirect_to(noms_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tcliente = Tcliente.find(params[:id])\n @tcliente.destroy\n\n respond_to do |format|\n format.html { redirect_to(tclientes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @scotty_dog_saying = ScottyDogSaying.find(params[:id])\n @scotty_dog_saying.destroy\n\n respond_to do |format|\n format.html { redirect_to(scotty_dog_sayings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @certidao = Certidao.find(params[:id])\n @certidao.destroy\n\n respond_to do |format|\n format.html { redirect_to(certidaos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tuple = Tuple.find(params[:id])\n @tuple.destroy\n\n respond_to do |format|\n format.html { redirect_to(tuples_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @patron = Patron.find(params[:id])\n @patron.destroy\n\n respond_to do |format|\n format.html { redirect_to(patrons_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @battalion = Battalion.find(params[:id])\n @battalion.destroy\n\n respond_to do |format|\n format.html { redirect_to(battalions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @matter = Matter.find(params[:id])\n @matter.destroy\n\n respond_to do |format|\n format.html { redirect_to(matters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @uitgelicht = Uitgelicht.find(params[:id])\n @uitgelicht.destroy\n\n respond_to do |format|\n format.html { redirect_to(uitgelichts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @withdrawal = Withdrawal.find(params[:id])\n @withdrawal.destroy\n\n respond_to do |format|\n format.html { redirect_to(withdrawals_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n # @thng = Thng.find(params[:id])\n # @thng = Usr.find_by_opndd(session[:opndd]).thngs.find(params[:id])\n # @thng.destroy unless @thng.nil?\n flash[:notice] = \"In this site, a Thing cannot be removed.\"\n\n respond_to do |format|\n format.html { redirect_to(thngs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @daicho = Daicho.find(params[:id])\n @daicho.destroy\n\n respond_to do |format|\n format.html { redirect_to(daichos_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 @talk = Talk.find(params[:id])\n @talk.destroy\n\n respond_to do |format|\n format.html { redirect_to(talks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @installation = Installation.find(params[:installation_id]) \n @eat = Eat.find(params[:id])\n @eat.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relatorio = Relatorio.find(params[:id])\n @relatorio.destroy\n\n respond_to do |format|\n format.html { redirect_to(home_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n @chamado = Chamado.find(params[:id])\n @chamado.destroy\n\n #Deleta o historico\n @audits = Audit.find_all_by_idchamado(params[:id])\n\n @audits.each do |a|\n a.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to chamados_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flat_happening = FlatHappening.find(params[:id])\n @flat_happening.destroy\n\n head :no_content\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 destroy\n @logentry.destroy\n respond_to do |format|\n format.html { redirect_to logentries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cheque = Cheque.find(params[:id])\n @cheque.destroy\n\n respond_to do |format|\n format.html { redirect_to(cheques_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ficha_tematica = FichaTematica.find(params[:id])\n @ficha_tematica.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_ficha_tematicas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @gift = Gift.find(params[:id])\n @gift.destroy\n\n respond_to do |format|\n format.html { redirect_to(:action => :index) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @acre = Acre.find(params[:id])\n @acre.destroy\n\n respond_to do |format|\n format.html { redirect_to(acres_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child = Child.find(params[:id])\n @child.destroy\n\n respond_to do |format|\n format.html { redirect_to(children_url) }\n format.xml { 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"
] | [
"0.6373573",
"0.6353274",
"0.63419706",
"0.6317276",
"0.6268632",
"0.6224476",
"0.6220366",
"0.62074035",
"0.62050295",
"0.62013686",
"0.6196077",
"0.6192619",
"0.6187081",
"0.61792195",
"0.6176768",
"0.61679584",
"0.61482346",
"0.61328286",
"0.6114421",
"0.60976565",
"0.6097346",
"0.60723823",
"0.60707766",
"0.6067551",
"0.6067398",
"0.60565895",
"0.6052573",
"0.6049492",
"0.60369366",
"0.6034458",
"0.60318077",
"0.6016896",
"0.60163325",
"0.6016229",
"0.6014515",
"0.60137",
"0.6010009",
"0.6001051",
"0.5990553",
"0.5988119",
"0.5988119",
"0.59877384",
"0.5986658",
"0.59827906",
"0.59817547",
"0.59745014",
"0.59694594",
"0.59537387",
"0.5944851",
"0.59404606",
"0.5935505",
"0.5932588",
"0.5927278",
"0.5926983",
"0.5926059",
"0.59226936",
"0.59170467",
"0.5916038",
"0.59110945",
"0.59057",
"0.59036803",
"0.5900449",
"0.58997065",
"0.5897437",
"0.5893975",
"0.5893083",
"0.5888613",
"0.58787334",
"0.58762693",
"0.58762693",
"0.5869402",
"0.58686215",
"0.58667773",
"0.58665127",
"0.5865355",
"0.5864094",
"0.5860927",
"0.5860741",
"0.58589065",
"0.5858497",
"0.58541954",
"0.5851145",
"0.5851007",
"0.58492565",
"0.58479077",
"0.58479077",
"0.5844401",
"0.58412606",
"0.5840722",
"0.5840601",
"0.58385545",
"0.58380914",
"0.58361",
"0.5835436",
"0.5833619",
"0.58311003",
"0.5829935",
"0.5829734",
"0.58286715",
"0.5826299"
] | 0.70137775 | 0 |
This ConnectTacToeplay method is given for free and does not need to be modified It is used to make your game playable. | def play
until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)
@board.print
self.play_turn
p "--------------------"
end
self.switch_players!
@board.print
p @current_player.token + " has won!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect4(boardClass)\n \tboard = boardClass.new\n players = Player.create\n players.\n \trefresh\n \tboard.testboard\n \t#board.game_mode #decide on PVP or AI and enter char names\n \trefresh\n \tboard.printCoords #outputs sample of game box to show how coords work\n \trefresh\n \tboard.printboard #print board by outputting parts of @board separated with | and ---\n active = board.current_player #active player variable set by current_player class method \n board.prompt_move(active) #request column number from active player \n while board.valid_move == false do puts \"Please choose another column which is NOT filled up and ON the board\" #checks whether the column input is a valid move\n board.prompt_move(active) #asks for another number if it is not\n end \n board.drop_piece #@row now contains the row number of that the piece was dropped into \n refresh\n board.printboard\n return false if board.win #check winning conditions\n board.row = 0\n next_player #change current_player indice to be set for next player.\n end",
"def play_game\n print \"Welcome to Tic Tac Toe, a two player game where each player marks \nwith a X or O in a 3x3 board until one player achieves a line of 3 marks. Each \nplayer should type the row letter + column number eg. a1 \\n\"\n print_board\n while @turns<9 && self.three_o? == false && self.three_x? == false\n if @turn_type == \"x\"\n self.x_player_turn\n @turn_type = \"o\"\n @turns += 1\n self.print_board\n else\n self.o_player_turn\n @turn_type = \"x\"\n @turns += 1\n self.print_board\n end\n end\n if self.three_x?\n puts \"Player X Wins\" \n elsif self.three_o?\n puts \"Player O Wins\"\n else\n puts \"Tough luck it's a draw\"\n end\n end",
"def ticTacToe\n puts \"TIC TAC TOE\"\n players = [1,2]\n game = Game.new\n game.displayBoard\n puts \"Player 1 = X, Player 2 = O\"\n puts \"To place your mark, input \\'(x,y)\\' on your turn\"\n until game.endGame do\n players.each do |playerNum|\n game.playerMove(playerNum)\n break if game.endGame\n end\nend\n\nend",
"def play_tictac()\ntic = Board.new\n puts 'Welcome to Tic Tac Toe, enter move as 1-9'\n tic.print_board\n until (tic.won? || tic.drawn?)\n tic.move\n end\n puts \"Cat's Game\" if tic.drawn?\n tic.who_won if tic.won?\n\nend",
"def play\n outcome = ''\n [1, 2].each {|ix| _select_players(ix)}\n c_player, o_player = _init_players\n o_player.set_other!(c_player) if o_player.is_IA_S?\n c_player.set_other!(o_player) if c_player.is_IA_S?\n #\n move_already_played = []\n #\n loop do\n STDOUT.print(\"#{@board.to_s}\\n#==> #{c_player.name}/#{c_player.type}'s TURN:\\n\")\n loop do\n m, sym = _get_move_from(c_player, move_already_played) # current player do his move\n v = @board.set_cell(m, sym.to_s)\n if m == -1 || v == sym # if sym not valid symbol, set_cell(m, sym != sym\n move_already_played << m.to_i\n break\n end\n STDERR.print \"! cell[#{m}] already set, try something else - v was: #{v.inspect} // #{v.class}\\n\"\n end\n move_already_played.sort!\n outcome = @board.game_over?\n break if outcome == :draw || outcome == :winner\n c_player, o_player = _switch_players(c_player, o_player)\n end\n _conclusion(outcome, c_player)\n end",
"def start\n puts \"Welcome! Let's play Tic-Tac-Toe\"\n print_board\n play\n end",
"def play\n board_setup\n gameplay_setup\n end",
"def play\n # To start, the method takes two arguments, the players and board array. \n while @board.winner == false\n # Then I set up a while loop that will keep going until there is no winner.\n @board.display_board\n # I started by calling the display_board method (from the Board Class) to show \n # the array in the traditional Tic-Tac-Toe formatting. \n cell_prompt\n # I Prompt the Player to make their selection. \n get_move\n # Here is where the Player imputs their selection. \n @board.update_cell\n # Update_cell (from the Board Class) will take the Player's input and update the value of the object at the \n # corresponding Board[index]. \n if @board.winner == true \n puts @board.winner\n break\n # This ends the loop if there has been a winner.\n elsif @board.draw == true\n break\n # This ends the loop if the match is a draw. \n end\n end\n # Otherwise, the loop keeps going. \n end",
"def play\n #self.set_players # Only uncomment one of these two lines.\n self.set_computer_players # Uncomment this line to have two computer players\n until @board.winner?\n self.turn\n self.change_current_player\n end\n winner = (@current_player == @player1) ? @player2 : @player1\n puts \" #{winner.color.to_s.upcase} is the winner!!!!\"\n puts \"Thanks for playing.\"\n end",
"def turn\n victory = false\n while victory == false do\n player_place\n @board.show_board\n end\n end",
"def play\n rematch = true\n while rematch == true do\n @plateau = Board.new\n tour = 1\n puts \"-----------------------------------------------------------------------------------\"\n puts \"| Welcome to the game Tic-tac-toe !!! |\"\n puts \"-----------------------------------------------------------------------------------\"\n puts \"Veuillez entrer le nom du Joueur X:\"\n a = gets.chomp # On demande le nom du premier joueur\n puts \"Veuillez entrer le nom du Joueur O:\"\n b = gets.chomp # On demande le nom du second joueur\n\n @gamer1.name = a # On enregistre le nom du premier joueur\n @gamer2.name = b # On enregistre le nom du second joueur\n \n while tour != 10 do\n @plateau.view_board # On affiche le plateau de jeux\n puts \"\\n\"\n if tour % 2 == 0 # Quand c'est le tour du deuxieme joueur\n puts \"Au tour du joueur O (#{@gamer2.name.capitalize})\"\n p = gets.chomp # On l'invite a saisir une position\n\n # Tant que la case n'existe pas, on demande au joueur O de resaisir une position existante\n while !@positions[p.upcase.to_sym] do \n puts \"Cette position n'existe pas #{@gamer2.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # Tant que la case n'est pas vide on l'invite a choisir une autre case\n while @plateau.verify_case(@positions[p.upcase.to_sym]) != \" \" do\n puts \"Cette position est deja prise #{@gamer2.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # On attribue la case au joueur O\n @plateau.set_position(@positions[p.upcase.to_sym], \"O\")\n\n # On verifie si le joueur O gagne\n if @plateau.game_over(\"O\") # Si oui, on arrete le jeux et le joueur O gagne\n tour = 10\n @gamer2.victory = true\n else\n tour += 1 # Sinon, on passe au tour suivant\n end\n else\n puts \"Au tour du joueur X (#{@gamer1.name.capitalize})\"# Quand c'est le tour du premier joueur\n p = gets.chomp # On l'invite a saisir une position\n\n # Tant que la case n'existe pas, on demande au joueur X de resaisir une position existante\n while !@positions[p.upcase.to_sym] do \n puts \"Cette position n'existe pas #{@gamer1.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # Tant que la case n'est pas vide on l'invite a choisir une autre case\n while @plateau.verify_case(@positions[p.upcase.to_sym]) != \" \" do\n puts \"Cette position est deja prise #{@gamer1.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # On attribue la case au joueur O\n @plateau.set_position(@positions[p.upcase.to_sym], \"X\")\n\n # On verifie si le joueur X gagne\n if @plateau.game_over(\"X\")# Si oui, on arrete le jeux et le joueur X gagne\n tour = 10\n @gamer1.victory = true\n else\n tour += 1 # Sinon, on passe au tour suivant\n end\n end\n end\n \n # On affiche le resultat du plateau de jeu final\n @plateau.view_board\n \n # On check ce qui a gagne ou si c'etait un match nul\n if @gamer1.victory == true\n puts \"Bravo #{@gamer1.name.upcase}! T'as gagné !!!!\"\n elsif @gamer2.victory == true\n puts \"Bravo #{@gamer2.name.upcase}! T'as gagné !!!!\"\n elseclass Board_case\n attr_accessor :status\n def initialize(status=\" \")\n @status = status\n end\n else\n puts \"Match nul!!!!!\"\n end\n\n # On invite les joueurs a faire une autre partie\n puts \"\\n\\nFaire une revenche?\\n-Tappe 1 si Oui\\n-Tappe 2 si Non\"\n v = gets.chomp\n quit = false\n while quit != true do\n if v == \"1\"\n quit = true\n elsif v == \"2\"\n quit = true\n rematch = false\n puts \"thanks for playing with Tic Tac Toe! :)\"\n else\n quit = false\n puts \"\\n\\nTapez:\\n1- Pour recommencer\\n2- Pour quitter\"\n v = gets.chomp\n end\n end\n end\nend",
"def play\n while true\n current_player.en_passant = false\n board.formatted_grid\n if check_for_check\n if check_for_checkmate\n puts \"Checkmate!\"\n else\n puts \"Check!\"\n end\n end\n x, y = prompt_selection\n puts \"\"\n puts ask_move\n x_end, y_end = get_move\n if x_end == \"back\"\n board.clear_board\n play\n end\n while board.valid_place?(x_end, y_end) == false\n puts \"Invalid option! Try again:\"\n x_end, y_end = get_move\n board.valid_place?(x_end, y_end)\n end\n #check for en passant\n if board.get_cell_piece(x, y).type == \"pawn\" && y_end - y == 2\n current_player.en_passant = true\n elsif board.get_cell_piece(x, y).type == \"pawn\" && y - y_end == 2\n current_player.en_passant = true\n end\n\n #check for promotion\n if board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"white\" && y_end == 0\n promote(x, y)\n elsif board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"black\" && y_end == 7\n promote(x, y)\n end\n\n #check for castling\n if board.get_cell_piece(x, y).type == \"king\" && x_end - x == 2\n board.piece_move(x + 3, y, x + 1, y)\n board.set_cell_color(x + 2, y, \"red\")\n elsif board.get_cell_piece(x, y).type == \"king\" && x - x_end == 2\n board.piece_move(x - 4, y, x - 1, y)\n board.set_cell_color(x - 2, y, \"red\")\n end\n #check if taking an opponent's piece\n if is_taking_piece?(x_end, y_end) \n hash_value = other_player.pieces_left.key([x_end, y_end])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n other_player.pieces_left.delete(hash_value)\n\n board.piece_move(x, y, x_end, y_end)\n else\n hash_value = current_player.pieces_left.key([x, y])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n board.piece_move(x, y, x_end, y_end)\n end\n #if board.game_over\n #puts game_over_message\n #board.formatted_grid\n #return\n #else\n switch_players\n #end\n end\n end",
"def play\n\t\tboard = Board.new # cree une instance de la class board\n\t\tfor i in 1..9 # fait une boucle qui vas de 1 a 9, quand on arrive a 9 ca veut dire que toutes les cases du tableau on ete remplis. \n\t\t\tboard.display_stat(@player_one.return_name, @player_two.return_name, @player_one.return_number_of_win, @player_two.return_number_of_win, @player_two.return_number_of_egality) # on appel la methode display stats qui vas servire a affichier les statistiques, nombre de parties, nom des joueurs, leur nombre de victoires...\n\t\t\tif @who_play == 1 # on cree une condition qui vas servire a afficher le nom du joueur qui doit jouer ce tours.\n\t\t\t\tputs \"A toi de jouer #{@player_one.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\telse\n\t\t\t\tputs \"A toi de jouer #{@player_two.return_name.colorize(:green)} !\\n\\n\\n\"\n\t\t\tend\n\t\t\tboard.display_board(@board_case) # on affiche le plateau du jeux\n\t\t\tselect_board_case # on appel la methode qui demande a l'utilisateur de choisire la case sur laquel il vas jouer\n\t\t\tif is_win == true # on fait une condition qui appel la methode is_win, cette methode verifi si il y a un cas de victoire\n\t\t\t\tboard.display_board(@board_case) # on affiche le plateau une derniere fois pour montrer la derniere modification\n\t\t\t\tif @who_play == 1 # on fait une condition qui verifie qui a gagner\n\t\t\t\t\tputs \"le joueur #{@player_one.return_name} a gagner cette partie!\" # si c'est le joueur 1 qui a gagner on dit qu'il a gagner, on affiche son nom\n\t\t\t\t\t@player_one.increments_number_of_win\t# on incremente du nombre de victoire \n\t\t\t\telse\n\t\t\t\t\tputs \"le joueur #{@player_two.return_name} a gagner cette partie!\"\n\t\t\t\t\t@player_two.increments_number_of_win\n\t\t\t\tend\n\t\t\t\tbreak # On quitte la boucle car il y a eu une victoire\n\t\t\tend\n\t\t\t@who_play == 1 ? @who_play = 2 : @who_play = 1 # cette ligne sert a faire que c'est a l'autre joueur de jouer (c'est une condition de type ternaire)\n\t\tend\n\t\tif is_win == false # si on sort de la boucle et qu'il n'y a aucune victoire alor c'est un match nul\n\t\t\t@player_one.increments_number_of_egality # on incremente la variable qui compte le nombres de matchs nuls\n\t\t\t@player_two.increments_number_of_egality\n\t\t\tputs \"MATCH NULLLLLLL\".colorize(:red) # on affiche que c'est un match nul\n\t\tend\n\tend",
"def play\r\n self.display_board\r\n while !self.over? do\r\n self.turn\r\n end\r\n if self.draw? \r\n puts \"Cat's Game!\"\r\n else\r\n puts \"Congratulations #{self.winner}!\"\r\n end\r\n end",
"def play\n\t\t@board.print_grid\n\t\tdo_break = false\n\t\twhile !((@board.checkWin('X', @p1.name)) || (@board.checkWin('O', @p2.name)))\n\t\t\tplayer_turn\n\t\t\tif @@turn == 9\n\t\t\t\tdo_break = true\n\t\t\tend\n\t\t\tbreak if do_break\n\t\tend\n\t\tfinish\n\tend",
"def play_turn\n board.render\n pos = get_pos\n decision = get_decision\n if decision == \"r\"\n board.reveal(pos)\n elsif decision == \"f\"\n board.flag(pos)\n else\n @saved_board = board.to_yaml\n end\n end",
"def play\n rematch = true\n while rematch == true do\n @plateau = Board.new\n tour = 1\n puts \"###################################################################################\"\n puts \"# Bienvenu dans le jeu Tic-tac-toe!!! #\"\n puts \"###################################################################################\"\n puts \"Veuillez entrer le nom du Joueur X:\"\n a = gets.chomp # On demande le nom du premier joueur\n puts \"Veuillez entrer le nom du Joueur O:\"\n b = gets.chomp # On demande le nom du second joueur\n \n @j1.name = a # On enregistre le nom du premier joueur\n @j2.name = b # On enregistre le nom du second joueur\n \n while tour != 10 do\n @plateau.view_board # On affiche le plateau de jeux\n puts \"\\n\"\n if tour % 2 == 0 # Quand c'est le tour du deuxieme joueur\n puts \"Au tour du joueur O (#{@j2.name.capitalize})\"\n p = gets.chomp # On l'invite a saisir une position\n\n # Tant que la case n'existe pas, on demande au joueur O de resaisir une position existante\n while !@positions[p.upcase.to_sym] do \n puts \"Cette position n'existe pas #{@j2.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # Tant que la case n'est pas vide on l'invite a choisir une autre case\n while @plateau.verify_case(@positions[p.upcase.to_sym]) != \" \" do\n puts \"Cette position est deja prise #{@j2.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # On attribue la case au joueur O\n @plateau.set_position(@positions[p.upcase.to_sym], \"O\")\n\n # On verifie si le joueur O gagne\n if @plateau.game_over(\"O\") # Si oui, on arrete le jeux et le joueur O gagne\n tour = 10\n @j2.victory = true\n else\n tour += 1 # Sinon, on passe au tour suivant\n end\n else\n puts \"Au tour du joueur X (#{@j1.name.capitalize})\"# Quand c'est le tour du premier joueur\n p = gets.chomp # On l'invite a saisir une position\n\n # Tant que la case n'existe pas, on demande au joueur X de resaisir une position existante\n while !@positions[p.upcase.to_sym] do \n puts \"Cette position n'existe pas #{@j1.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # Tant que la case n'est pas vide on l'invite a choisir une autre case\n while @plateau.verify_case(@positions[p.upcase.to_sym]) != \" \" do\n puts \"Cette position est deja prise #{@j1.name.capitalize}, veuillez resaisir:\" \n p = gets.chomp\n end\n\n # On attribue la case au joueur O\n @plateau.set_position(@positions[p.upcase.to_sym], \"X\")\n\n # On verifie si le joueur X gagne\n if @plateau.game_over(\"X\")# Si oui, on arrete le jeux et le joueur X gagne\n tour = 10\n @j1.victory = true\n else\n tour += 1 # Sinon, on passe au tour suivant\n end\n end\n end\n \n # On affiche le resultat du plateau de jeu final\n @plateau.view_board\n \n # On check ce qui a gagne ou si c'etait un match nul\n if @j1.victory == true\n puts \"Bravo #{@j1.name.upcase}! T'as gagné !!!!\"\n elsif @j2.victory == true\n puts \"Bravo #{@j2.name.upcase}! T'as gagné !!!!\"\n else\n puts \"Match nul!!!!!\"\n end\n\n # On invite les joueurs a faire une autre partie\n puts \"\\n\\nFaire une revenche?\\n1- Oui\\n2- Non\"\n v = gets.chomp\n quit = false\n while quit != true do\n if v == \"1\"\n quit = true\n elsif v == \"2\"\n quit = true\n rematch = false\n puts \"Merci d'etre passe !!! :)\"\n else\n quit = false\n puts \"\\n\\nTapez:\\n1- Pour recommencer\\n2- Pour quitter\"\n v = gets.chomp\n end\n end\n end\n end",
"def game()\n\n system \"cls\"\n puts \"Enter the size of the tic-tac-toe board: \"\n size = gets.chomp.to_i\n if (size > 2) then\n init(:size => size)\n else\n puts(\"Invalid input\")\n sleep(1)\n game()\n end\n \n @taken = 0\n\n while true do\n\n if (@taken >= (@@size**2)-2) then\n system \"cls\"\n puts (\"<=============PLAYER #{@player}=============>\")\n puts ()\n show\n puts ()\n return 0\n end\n\n # player 1 is assumed to take X and player 2 assumed to take Y\n # this setting can be changed in the turn() method\n @player = 1\n if turn(@player) then\n system \"cls\"\n puts (\"<=============PLAYER #{@player}=============>\")\n puts ()\n show\n puts ()\n return 1\n end\n\n @player = 2\n if turn(@player) then\n system \"cls\"\n puts (\"<=============PLAYER #{@player}=============>\")\n puts ()\n show\n puts ()\n return 2\n end\n\n end\n end",
"def play\n\t\t# This will return the move that the player will take. This will come\n\t\t# from a move generator for the AI\n\t\t# The ai player will require the ai_type to be passed through\n\t\t# TODO: To be changed possibly based off of the main gameplay code. Look\n\t\t# \t\tinto the player_lobby code\n\n\t\tai_type = Settings.instance.game_mode\n\t\tif ai_type == :Connect4\n\t\t\t@ai_object = AI_Connect4.new(@game, 2, @current_chip)\n\t\telsif ai_type == :TOOT\n\t\t\t# make it that otto object\n\t\t\t@ai_object = AI_OTTO.new(@game, 1, @current_chip)\n\t\t\t@ai_object.player_goal = @goal\n\t\tend\n\n\t\t#pre\n\t\tassert game.is_a?(Game)\n\n\t\t# AI will get the next position, will be determined based on the difficulty setting\n\t\t@current_column = @ai_object.getBestScore()\n\t\tif @ai_object.is_a?(AI_OTTO)\n\t\t\t# random value\n\t\t\ttemp_num = rand(2)\n\t\t\tif temp_num == 0\n\t\t\t\tup()\n\t\t\tend\n\t\tend\n\t\tdrop()\n\t\tfinished()\n\n\t\t#post\n\t\tassert @current_column.is_a?(Numeric)\n\tend",
"def play\n\t @players.each { |player| player.score = 0 }\n\t \n\t loop do\n\t @board.clear\n\t\t@cur_player = @players[0]\n\t\t@rounds += 1\n\t\t\n\t\tprint \"\\n******************* Tic-Tac-Toe ********************\"\n\t puts \"\\n#{@players[0].name} will play with #{@players[0].mark}; #{@players[1].name} will play with #{@players[1].mark}\\n\\n\"\n\t\t@board.print_board \n\t \n\t\tloop do\n position = prompt_movement\n\t @board.set_mark(position, @cur_player.mark)\n\t\t @board.print_board \n\t\t \n\t\t result = \n\t\t if @board.is_winner?(@cur_player.mark)\n\t\t @cur_player.score += 1\n\t\t puts \"\\n#{@cur_player.name} wins!!\"\n\t\t\t true\n\t\t elsif @board.is_full?\n\t\t puts \"\\nThe game ended in a tie!\"\n\t\t\t true\n\t\t\tend\n\t\t \n\t\t break if result\n\t\t swap_players\n\t\tend\n\t\t\n\t\tbreak if prompt_quit\n\t end\n\t \n\t print_final_score\n\tend",
"def start_game\r\n # Read the file that contains game instructions and display on the console\r\n File.open(File.join(File.dirname(__FILE__),\"instructions.txt\")).each do |line|\r\n puts line\r\n end\r\n # Select player 1 and 2 as human or computer. If human provide a name for identification\r\n player_1 = ask(\"Player 1 option? \",Integer){|q| q.in = 1..3}\r\n if player_1 == 2\r\n player_1_name = ask(\"Name? \") { |q| q.validate = /\\w+\\Z/ }\r\n player_1_obj = Player.new(player_1_name)\r\n else\r\n player_1_obj = Player.new()\r\n end\r\n\r\n player_2 = ask(\"Player 2 option? \",Integer){|q| q.in = 1..3}\r\n if player_2 == 2\r\n player_2_name = ask(\"Name? \") { |q| q.validate = /\\w+\\Z/ }\r\n player_2_obj = Player.new(player_2_name)\r\n else\r\n player_2_obj = Player.new()\r\n end\r\n # Create an array with two player objects. Each player gets a token which is same as his index in the array\r\n players = Array.new(2){Player.new}\r\n players[0] = player_1_obj\r\n players[1] = player_2_obj\r\n # Create a new game board\r\n new_board = Board.new()\r\n puts \" To start, please select a column between 1-7\"\r\n turn = 1 # used to keep track of maximum number of turns in the game which is 7*6\r\n game_over_flag = 0 # set to 1 if game is over either by a win or a tie\r\n while(turn <= 42)\r\n players.each_with_index do |player,player_token|\r\n puts \"Player #{player.name} turn\"\r\n if player.name.eql?(\"Computer\")\r\n # currently the computer takes a random move. This can be replaced with the calculate_winning_move() method\r\n # by implementing an algorithm to calculate the best move\r\n player_selection = rand(7)\r\n else\r\n # Take human player's column selection. reduce it by 1 because array indices start with 0\r\n player_selection = ask(\"Column? \", Integer) { |q| q.in = 1..7 }\r\n end\r\n player_column = player_selection-1\r\n # call make_move which makes a move on behalf of player and checks if the move has made the player win\r\n win_flag = new_board.make_move(player_token,player_column)\r\n turn += 1\r\n if win_flag\r\n puts \"Game over : Player #{player.name} won\"\r\n game_over_flag = 1\r\n end\r\n if turn == 42\r\n puts \"Game over : Its a tie!!\"\r\n game_over_flag = 1\r\n end\r\n # if the game over flag is set, check if the players want to restart with a new game or end the game\r\n if game_over_flag == 1\r\n new_game = ask(\"Do you want to start new game ?(yes/no)\"){|q| q.validate = /(yes|no)\\Z/}\r\n if new_game.eql?('yes')\r\n start_game()\r\n else\r\n puts \"See you.Have a good day!!\"\r\n end\r\n return\r\n end\r\n end\r\nend\r\nend",
"def helper\n puts \"Welcome to Tic Tac Toe!\"\n puts display_board([1, 2, 3, 4, 5, 6, 7, 8, 9])\n play([\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"])\nend",
"def turn(tictactoe)\n moves_avail = @tictactoe.open_squares(p1_moves(@tictactoe),p2_moves(@tictactoe))\n\n return \"Player 1\" if moves_avail.length.odd? && tictactoe.players[0].first_to_act == \"true\"\n return \"Player 2\" if moves_avail.length.even? && tictactoe.players[0].first_to_act == \"true\"\n return \"Player 2\" if moves_avail.length.odd? && tictactoe.players[0].first_to_act == \"false\"\n return \"Player 1\" if moves_avail.length.even? && tictactoe.players[0].first_to_act == \"false\"\n end",
"def start\n\t\tputs \"Welcome to Tic Tac Toe\"\n puts \"How many players for this game: 0, 1, 2?\"\n players = gets.strip.to_i\n\n if players == 0\n board = Board.new\n game = Game.new(player_1=Player::Computer.new(\"X\"), player_2=Player::Computer.new(\"O\"), board=Board.new)\n game.play\n\n elsif players == 1\n puts \"Do you want to go first? (Y/N)\"\n go_first = gets.strip.upcase\n if go_first == \"Y\"\n game = Game.new(player_1=Player::Human.new(\"X\"), player_2=Player::Computer.new(\"O\"), board=Board.new)\n game.play\n else\n game = Game.new(player_1=Player::Computer.new(\"X\"), player_2=Player::Human.new(\"O\"), board=Board.new)\n game.play\n end\n\n elsif players == 2\n puts \"First player is X\"\n game = Game.new(player_1=Player::Human.new(\"X\"), player_2=Player::Human.new(\"O\"), board=Board.new)\n game.play\n end\n \n puts \"Do you want to play another game? (Y/N)?\"\n play_again = gets.strip.upcase\n if play_again == \"Y\"\n start\n else\n puts \"Thanks for playing!\"\n end\n end",
"def initialize # Starting the game with good looking emojis\n puts \"\\n | | | | | | \"\n puts \" 🔵 | ❌ | ❌ 🔵 | 🔵 | ❌ ❌ | ❌ | ❌ \"\n puts \"______|______|______ ______|______|______ ______|______|______ \"\n puts \" | | | | | | \"\n puts \" 🔵 | 🔵 | ❌ ❌ | 🔵 | ❌ 🔵 | 🔵 | ❌ \"\n puts \"______|______|______ ______|______|______ ______|______|______ \"\n puts \" | | | | | | \"\n puts \" ❌ | | 🔵 ❌ | ❌ | ❌ ❌ | 🔵 | 🔵 \"\n puts \" | | | | | | \"\n puts \"\\n\\n\\t\\t🎮⚙️ Welcome to Tic Tac Toe ⚙️ 🎮\"\n @p_one = Player.new\n @p_one.infos\n @p_two = Player.new\n @p_two.infos\n @board_game = Board.new\n end",
"def play\n p_arr = randomize_players(@player_1, @player_2)\n current_player = p_arr[0]\n next_player = p_arr[1]\n current_player.piece = 'X'\n next_player.piece = 'O'\n puts \"Player #{current_player.id.to_s} goes first!\"\n\n end_message = \"\"\n loop do\n set_cell(current_player.move(self))\n if check_win?\n end_message = current_player.win_message\n break\n elsif check_draw?\n end_message = \"It's a draw.\"\n break\n end\n current_player, next_player = next_player, current_player\n end\n\n display_board\n end_message\n end",
"def win(boord)\n if board[0] == 'X' && board[0] == 'X'\n end\n\n\n def display_board\n puts\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]}\"\n puts \"-\" * 11\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]}\"\n puts \"-\" * 11\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]}\"\n puts\n end\n\n def one_player_game\n turn = rand(1)\n available_turns = 9\n while available_turns > 0\n display_board\n if turn % 2 == 1\n puts \"Player 1, please pick a square from 1 to 9\"\n p1 = gets.chomp.to_i\n if @board[p1-1] == \" \"\n @board[p1-1] = \"X\"\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n else\n p2 = rand(9)\n if @board[p2-1] == \" \"\n @board.delete_at(p2-1)\n @board.insert(p2-1, \"O\")\n puts \"Computer player chooses square #{p2}\"\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n end\n end\n end_game\n end\n\n def two_player_game\n turn = rand(1)\n available_turns = 9\n while available_turns > 0 && win == \"no\"\n display_board\n if turn % 2 == 1\n puts \"Player 1, please pick a square from 1 to 9\"\n p1 = gets.chomp.to_i\n if @board[p1-1] == \" \"\n @board.delete_at(p1-1)\n @board.insert(p1 - 1, \"X\")\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n else\n puts \"Player 2, please pick a square from 1 to 9\"\n p2 = gets.chomp.to_i\n if @board[p2-1] == \" \"\n @board.delete_at(p2-1)\n @board.insert(p2-1, \"O\")\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n end\n end\n end_game\n end\n\n def start_game\n available_turns = 9\n while available_turns == 9\n puts\n puts \"*\" * 36\n puts \"Are you ready for some Tic-Tac-Toe?!\"\n puts \"*\" * 36\n puts\n input = gets.chomp.downcase\n if input == \"yes\"\n puts\n puts \"*\" * 36\n puts \"One player or two?\"\n puts \"*\" * 36\n puts\n player_num = gets.chomp.downcase\n if player_num == \"one\"\n one_player_game\n else\n two_player_game\n end\n else\n puts \"Your loss, buddy!\"\n exit!\n end\n end\n end\nend",
"def play_turn\n @board.place_mark(@current_player.get_move, @current_player.mark)\n switch_players!\n end",
"def play_move(from, to)\n #create duplicate of board, to correct pass by reference error\n #add top disk on from tower to the top of to tower\n to_dup = @board[to].dup\n to_dup.unshift(@board[from][0]) \n @board[to] = to_dup\n @board[from].shift\n \n if won?\n render\n puts \"congratulations you won!\\n\\n\"\n else\n get_move\n end\n end",
"def play_turn(board,joueur_actuel)\n # cette variable permet de verifier les disponibilité des cases .\n input_ko = true\n # [0] ... [ 8] ça défini les emplacement \n while input_ko\n print \"#{joueur_actuel.joueur_nom}, ton symbol est le '#{joueur_actuel.joueur_symbol}', quelle case souhaites-tu jouer ? \"\n case_to_play = gets.chomp.upcase\n\n case case_to_play\n when \"A1\"\n if board.list_boardcase[0].symbol == '.'\n board.list_boardcase[0].symbol = joueur_actuel.joueur_symbol\n input_ko = false\n else\n puts \"Case déjà occupée. Réessayes avec la bonne case !\"\n end\n when \"A2\"\n if board.list_boardcase[1].symbol == '.'\n board.list_boardcase[1].symbol = joueur_actuel.joueur_symbol\n input_ko = false\n else\n puts \"Case déjà occupée. Réessayes avec la bonne case !\"\n end\n when \"A3\"\n if board.list_boardcase[2].symbol == '.'\n board.list_boardcase[2].symbol = joueur_actuel.joueur_symbol\n input_ko = false\n else\n puts \"Case déjà occupée. Réessayes avec la bonne case !\"\n end\n when \"B1\"\n if board.list_boardcase[3].symbol == '.'\n board.list_boardcase[3].symbol = joueur_actuel.joueur_symbol\n input_ko = false\n else\n puts \"Case déjà occupée. Réessayes avec la bonne case !\"\n end\n when \"B2\"\n if board.list_boardcase[4].symbol == '.'\n board.list_boardcase[4].symbol = joueur_actuel.joueur_symbol\n input_ko = false\n else\n puts \"Case déjà occupée. Réessayes avec la bonne case !\"\n end\n when \"B3\"\n if board.list_boardcase[5].symbol == '.'\n board.list_boardcase[5].symbol = joueur_actuel.joueur_symbol\n input_ko = false\n else\n puts \"Case déjà occupée. Réessayes avec la bonne case !\"\n end\n when \"C1\" \n if board.list_boardcase[6].symbol == '.'\n board.list_boardcase[6].symbol = joueur_actuel.joueur_symbol\n input_ko = false\n else\n puts \"Case déjà occupée. Réessayes avec la bonne case !\"\n end\n when \"C2\"\n if board.list_boardcase[7].symbol == '.'\n board.list_boardcase[7].symbol = joueur_actuel.joueur_symbol\n input_ko = false\n else\n puts \"Case déjà occupée. Réessayes avec la bonne case !\"\n end\n when \"C3\"\n if board.list_boardcase[8].symbol =='.'\n board.list_boardcase[8].symbol = joueur_actuel.joueur_symbol\n input_ko = false\n else\n puts \"Case déjà occupée. Réessayes avec la bonne case !\"\n end\n else \n puts \"erreur de case\"\n end\n end\n\tend",
"def play_turn\n move = @current_player.get_move\n switch_players!\n @board.place_mark(move, :X)\n end",
"def turn\n puts \"#{@player_1.name}'s turn.\"\n puts \"Choose your case:\"\n print \">\"\n check_if_empty(@player_1)\n if win\n @board.print_board\n return true\n end\n @board.print_board\n puts \"#{@player_2.name}'s turn.\"\n puts \"Choose your case:\"\n print \">\"\n check_if_empty(@player_2)\n if win\n @board.print_board\n return true\n end\n @board.print_board\n end",
"def first_player_plays \n\t@choice_player1 = first_player.ask_play \n\tunless first_player.verification_coordonnees == true \n\t first_player.error \n\t \t @choice_player1 = first_player.ask_play\n\tend\n\n #pour chacun des elements du array stockant les cases\n #si le nom de la case = au choix du joueur et si la case et vide\n #changer la valeur de la case avec une petite croix\n #lance un message de succes (voir classe Player) qui dit que la case est bonne\n #si le nom de la case = au choix du joueur mais la case n'est pas vide\n #on lance la fonction error qui affiche un message d'erreur\n #on relance ask_play pour demander au joueur une autre coordonnee\n\t@array.map do |x| \n\t if x.value == @choice_player1 && x.check_if_empty\n\t x.fill_up_case(\"x\")\n\t first_player.success_case\n\t elsif x.value == @choice_player1 && !x.check_if_empty\n\t\t first_player.error\n\t\t @choice_player1 = first_player.ask_play\n\t end\n end\n\n #on lance la fonction ci-dessous pour modifier le board selon le choix du joueur\t\n\tupdate_board\n #on verifie si le joueur a gagne avec la fonction ci-dessous\n\tcheck_if_victory\n\n #si le joueur a gagne\n #on appelle la fonction winner (classer Player) qui affiche un message de victoire !\n #on lance la fonction ci-dessous qui demande a lancer un nouveau jeu\n\t if @victory == true\n\t first_player.winner \n\t another_game \n\t end\n end",
"def play\n until @tic.win?[0] || @tic.win?[1] || @turn_count == @tic.x*@tic.y\n @tic.show_board\n puts ' '\n location_selected = get_player_input\n if check_space?(location_selected)\n place_piece(location_selected)\n else \n \tputs \"That location has already been played, or is outside of the game board. Please choose another location.\"\n end\n end\n\n @tic.show_board\n puts ' '\n\n if @tic.win?[0]\n puts \"#{@player1.name} Wins!\"\n elsif @tic.win?[1]\n puts \"#{@player2.name} Wins!\"\n else\n puts \"Tie - Game Over\"\n end\n end",
"def turn(player)\n puts \" C'est le tour de #{player.nom}\"\n\n#affichage du plateau\n @plateau.visuel\n\n#demande au joueur ce qu'il joue\n puts \"Ou veux tu placer ton pion?\"\n puts \"Info : Tapes de 1 à 9\"\n @choix = gets.chomp.to_i\n puts \"Tu as choisi la case #{@choix}\"\n\n#appel de la methode de modification de la valeur de la case\n @plateau.play(@choix, player, player.token)\n\n#affichage du tableau avec les modifications\n @plateau.visuel\n\n#verification de la victoire ou non \n @plateau.victory(player.win, player.token)\n puts player.win\n if player.win == false\n go\n elsif\n puts \"Le jeu est fini ! #{player.nom} à gagner\"\n end\n\n end",
"def start_game(user_hash)\n\t\tflag = 0\n\t\tputs \"Welcome, lets play Tic Tac Toe:\"\n\t\tputs \"This is put board...\"\n\t\tdisplay_board(user_hash)\n\t\t\tuntil (flag == 1)\n\t\t\t\tprint \"Player 1 : \"\n\t\t\t\tplayer_1_move = gets.chomp.to_i\n\t\t\t\tchange_board(user_hash,player_1_move,1)\n\t\t\t\tif did_anyone_win?(player_1_array(user_hash)) == true and draw_condition(user_hash) == false\n\t\t\t\t\tputs \"Player 1 win!\"\n\t\t\t\t\tflag = 1\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tif draw_condition(user_hash) \n\t\t\t\t\tputs \"DRAW!\"\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tprint \"Player 2 : \"\n\t\t\t\tplayer_2_move = gets.chomp.to_i\n\t\t\t\tchange_board(user_hash,player_2_move,2)\n\t\t\t\tif did_anyone_win?(player_2_array(user_hash)) == true and draw_condition(user_hash) == false\n\t\t\t\t\tputs \"Player 2 win!\"\n\t\t\t\t\tflag = 1\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\t\tif draw_condition(user_hash) \n\t\t\t\t\tputs \"DRAW!\"\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tplay_more?\n\tend",
"def connect_game\n @connect_game = ConnectGame.new(@titles[@mode], game_state, @game_mode[@mode]) if @connect_game.nil?\n @connect_game\n end",
"def comp_turn\n index = computer_index\n if valid_move?(index)\n move(index, current_player)\n display_board\n else\n comp_turn\n end\n end",
"def insert_play_on_board(player, turno)\n row_pos = 0\n #Verifica si el primer caracter del turno es letra, si si se obtiene su equivalente en numero siendo a = 0 y z = 26\n if turno[0].to_i == 0\n (\"a\"..\"z\").each_with_index do |letra, i|\n if turno[0] == letra\n row_pos = i\n end\n end\n else #Si el primer caracter no fue letra significa que es numero y se procede a obtener el equivalente de la letra\n (\"a\"..\"z\").each_with_index do |letra, i|\n if turno[1] == letra\n row_pos = i\n end\n end\n end\n col_pos = (turno[0].to_i != 0 ? turno[0].to_i : turno[1].to_i) - 1\n #Se pregunta que amenos que el espacio donde se piensa colocar la ficha sea un lugar vacio se inserta si no se descarta\n unless @tablero.component(row_pos, col_pos) != \" \"\n @tablero.send(:[]=, row_pos, col_pos, player.ficha)\n return true\n else\n puts \"Lo siento ese lugar esta ocupado krnal\"\n return false\n end\n end",
"def go_play\n puts \"Let's start a new game\"\n @grid.print_board # prints the initial blank layout of the board\n puts @player1.name + \" \" + \"your turn first!\" # player 1 always goes first\n end",
"def play_turn\n move_info = FileReader.get_move(\"#{@turn}#{@player_to_move}\", @data) \n @cur_board.move_piece(move_info)\n end",
"def play\n\n until self.over?\n self.turn\n end\n\n if self.won?\n self.board.display\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n self.board.display\n puts \"Cat's Game!\"\n end\n end",
"def start\n \t\tself.board.display_instruction\n \t\tcurrent_player = select_first_player\n \t\t(self.board.size).times do \n \t\t\tplay(current_player)\n \t\t\tcurrent_player = next_of current_player \n end\n display_winner(nil, true)\n \tend",
"def start\n puts \"Welcome to Tic Tac Toe!\"\n puts \"\"\n define_players\n play\n end",
"def command_two_player_LAN\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Reset frame count for measuring play time\n Graphics.frame_count = 0\n # Switch to game screen\n $scene = Scene_Connect.new\n end",
"def tictactoe()\r\n\tcur = {row1: [\" \",\" \",\" | \",\" \",\" | \",\" \",\" \"], space1: [\"-----------\"], row2: [\" \",\" \",\" | \",\" \",\" | \",\" \",\" \"], space: [\"-----------\"], row3: [\" \",\" \",\" | \",\" \",\" | \",\" \",\" \"]}\r\n\t$columns = [nil,1,3,5]\r\n\t$x_o = true\r\n\t$foundWin = false\r\n\tplayernumber = 2.to_s\r\n\tcounter = 0\r\n\tprint \"Instructions: Input a column and row when prompted seperated by a single comma. ('2 2')\\n\"\r\n\twhile $foundWin == false and counter < 9 do #while no one has won, do turns\r\n\t\tprintBoard(cur)\r\n\t\tprint \"Player 1's (X) turn. Input: \" #start player 1's turn\r\n\t\tplayer1Input = gets.chomp.split(' ')\r\n\t\twhile player1Input[0] == nil or player1Input[1] == nil\r\n\t\t\tprint \"Move was not valid. Please try again: \"\r\n\t\t\tplayer1Input = gets.chomp.split(' ')\r\n\t\t\tplayer1C = player1Input[0].to_i\r\n\t\t\tplayer1R = player1Input[1].to_i\r\n\t\tend\r\n\t\tplayer1C = player1Input[0].to_i\r\n\t\tplayer1R = player1Input[1].to_i\r\n\t\tif moveValid?(cur,player1C,player1R,$x_o) == false\r\n\t\t\twhile moveValid?(cur,player1C,player1R,$x_o) == false\r\n\t\t\t\tprint \"Move was not valid. Please try again: \"\r\n\t\t\t\tplayer1Input = gets.chomp.split(' ')\r\n\t\t\t\tplayer1C = player1Input[0].to_i\r\n\t\t\t\tplayer1R = player1Input[1].to_i\r\n\t\t\tend\r\n\t\tend #all above this end is making sure input is valid from user, next is placing the x and determining if it is a win\r\n\t\tplaceXO(cur,player1C,player1R,$x_o)\r\n\t\tcounter += 1\r\n\t\tif counter > 8 and $fondWin == false\r\n\t\t\t$tie = true\r\n\t\t\tbreak\r\n\t\tend\r\n\t\tdidWin(cur,player1C,player1R,$x_o)\r\n\t\tif $foundWin == true #check if move was winning move, if so, break while loop\r\n\t\t\tbreak\r\n\t\tend\r\n\t\tswitchTurn() #starting player 2's turn, do everything I did for player 1 except for player 2\r\n\t\t#next turn\r\n\t\tprintBoard(cur)\r\n\t\tprint \"Player 2's (O) turn. Input: \"\r\n\t\tplayer2Input = gets.chomp.split(' ')\r\n\t\twhile player2Input[0] == nil or player2Input[1] == nil\r\n\t\t\tprint \"Move was not valid. Please try again: \"\r\n\t\t\tplayer2Input = gets.chomp.split(' ')\r\n\t\t\tplayer2C = player2Input[0].to_i\r\n\t\t\tplayer2R = player2Input[1].to_i\r\n\t\tend\r\n\t\tplayer2C = player2Input[0].to_i\r\n\t\tplayer2R = player2Input[1].to_i\r\n\t\tif moveValid?(cur,player2C,player2R,$x_o) == false\r\n\t\t\twhile moveValid?(cur,player2C,player2R,$x_o) == false\r\n\t\t\t\tprint \"Move was not valid. Please try again: \"\r\n\t\t\t\tplayer2Input = gets.chomp.split(' ')\r\n\t\t\t\tplayer2C = player2Input[0].to_i\r\n\t\t\t\tplayer2R = player2Input[1].to_i\r\n\t\t\tend\r\n\t\tend\r\n\t\tplaceXO(cur,player2C,player2R,$x_o)\r\n\t\tcounter += 1\r\n\t\tdidWin(cur,player2C,player2R,$x_o)\r\n\t\tswitchTurn()\r\n\t\t#no need to check if won, while loop will automatically do that for us at the loop\r\n\tend\r\n\tprint \"\\n\"\r\n\tprint \"\r\n\t╔═══╗─────────────╔╗───╔╗───╔╗\r\n\t║╔═╗║────────────╔╝╚╗──║║──╔╝╚╗\r\n\t║║─╚╬══╦═╗╔══╦═╦═╩╗╔╬╗╔╣║╔═╩╗╔╬╦══╦═╗╔══╗\r\n\t║║─╔╣╔╗║╔╗╣╔╗║╔╣╔╗║║║║║║║║╔╗║║╠╣╔╗║╔╗╣══╣\r\n\t║╚═╝║╚╝║║║║╚╝║║║╔╗║╚╣╚╝║╚╣╔╗║╚╣║╚╝║║║╠══║\r\n\t╚═══╩══╩╝╚╩═╗╠╝╚╝╚╩═╩══╩═╩╝╚╩═╩╩══╩╝╚╩══╝\r\n\t──────────╔═╝║\r\n\t──────────╚══╝\\n\" #print the awesome congrats ASCII code (I got it off the internet, just sayin)\r\n\tprintBoard(cur)\r\nend",
"def create_board\n\t@a1 = Cases.new(\"a1\", \" \") \n\t@a2 = Cases.new(\"a2\", \" \")\n\t@a3 = Cases.new(\"a3\", \" \")\n\t@b1 = Cases.new(\"b1\", \" \")\n\t@b2 = Cases.new(\"b2\", \" \")\n\t@b3 = Cases.new(\"b3\", \" \")\n\t@c1 = Cases.new(\"c1\", \" \")\n\t@c2 = Cases.new(\"c2\", \" \")\n\t@c3 = Cases.new(\"c3\", \" \")\n\n puts \" ________________________________________________________________________________________________________ \"\n puts \" | __ ___ __ ________ __ ________ ________ ___ ___ ________ | \"\n puts \" | l l l l l l l ______l l l l _____l l __ l l l l l l ______l | \"\n puts \" | l l l _ l l l l l__ l l l l l l l l l l l l l l__ | \"\n puts \" | l l_l l l l_l l l __l l l l l l l l l l l_l l_l l_l l l ___l | \"\n puts \" | l l l l l l_____ l l_____ l l_____ l l__l l l l l l l l l l_____ | \"\n puts \" | l___l l___l l________l l________l l________l l________l l__l l___l l__l l________l | \"\n puts \" |____________________________________________ TO ______________________________________________| \"\n puts \" | TIC TAC TOE | \"\n puts \" |_________________________________________________________________________________________________________| \"\n\n #On cree un Board et on definit ses 9 variables (voir Classe Board) comme etant la valeur de nos 9 cases, soit \" \"\n #on affiche un Board, qui sera vide\n #on cree un array avec toutes nos cases, qui sert a garder a jour les valeurs des cases au fur et a mesure de l'avancee du jeu\n\t@the_board = Board.new(@a1.position, @a2.position, @a3.position, @b1.position, @b2.position, @b3.position, @c1.position, @c2.position, @c3.position) \n\t@the_board.display \n\t@array = [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3] \n end",
"def opening\r\n clear_screen\r\n if $x_score + $o_score == 0\r\n border(31)\r\n tab(10, \"Tic Tac Toe\", \"-\" * 31, \"\\n\")\r\n else\r\n header\r\n scorekeeping($x_score, $o_score)\r\n end\r\n tab(11, \" | | X\")\r\n tab(11, \"-\" * 9)\r\n tab(11, \"O | O | X\")\r\n tab(11, \"-\" * 9)\r\n tab(11, \"X | |\", \"\\n\", \"-\" * 31)\r\n tab(8, \"Player Selection\", \"-\" * 31)\r\n tab(11, \"1 = human\")\r\n tab(11, \"2 = perfect\")\r\n tab(11, \"3 = random\")\r\n tab(11, \"4 = sequential\", \"-\" * 31)\r\n end",
"def turn\n marker = @turn_count.even? ? marker = \"X\" : marker = \"O\"\n move\n print \"Current board: \"\n show_board\n @player +=1\n end",
"def play_game\n @board.print_board\n until @quit || @restart || gameover?\n cell = take_turn(@current_player)\n if !cell.nil?\n coordinates = get_coordinates(cell)\n change_board(coordinates) if valid_cell?(coordinates)\n end\n @current_player = switch_player(@current_player)\n @board.print_board unless @restart || @quit\n end\n reset_board if @restart\n ending_screen if gameover?\n\n end",
"def play\n until over?\n @board.display\n turn\n end\n @board.display\n puts draw? ? \"Cat's Game!\" : \"Congratulations #{winner}!\"\n end",
"def do_player_turn\n eval_popup_queue\n start_player_turn if !@player_turn_init\n tbs_unit_selection \n \n map = $game_map\n show_unit_hud(map.events[map.tbu_id_xy($game_player.x,$game_player.y)])\n update_all_sh_acts_win\n update_hl_follow if TM.selecting_target?\n hide_skill_disp_win\n preview_effect_tb\n end",
"def play\n # letters to array [ [row, column, letter, points], [... ]\n letters = []\n params[:laid_letters].split('_').each_slice(4) do |ll|\n letters << [ll[0].to_i, ll[1].to_i, ll[2], ll[3].to_i]\n end\n logger.info '@@@@@@@@@@ ctrl letters: ' + letters.to_s\n\n # Check laying of letters\n @error = @turn.laid_oke(letters)\n if @error.blank?\n\n # Check the words\n @error = @turn.words_nok(letters)\n if @error.empty?\n\n # Update game and set next turn\n # @turn.started = Time.at( params[:js_start_time].to_i / 1000.0 )\n @turn.ended = Time.at(params[:js_time].to_i / 1000.0)\n # logger.info 'turn_ctrl - js_start_time: ' + @turn.started.to_s\n logger.info 'turn_ctrl - js_time: ' + @turn.ended.to_s\n @turn.update_turn(letters)\n @game.letters_to_board(letters)\n @turn = @game.goto_next(@turn) # @turn gets next_turn\n\n # to all players\n broadcast(letters)\n\n # Wrong words\n else\n render :play_error\n end\n\n # Laying not oke\n else\n render :play_error\n end\n # stop\n end",
"def start\n puts \"Welcome to Tic Tac Toe.\"\n play_again = \"yes\"\n while play_again.downcase == \"y\" || play_again.downcase == \"yes\"\n valid_options_1 = [\"0\", \"1\", \"2\"]\n question_1 = puts \"What type of game do you want to play? (0, 1, or 2 players)\"\n input_1 = gets.strip\n until valid_options_1.include? input_1\n puts \"That's not a valid option, please enter 0, 1, or 2.\"\n question_1\n input_1 = gets.strip\n end\n\n if input_1.to_i == 0\n player_1 = Players::Computer.new(\"X\")\n player_2 = Players::Computer.new(\"O\")\n Game.new(player_1, player_2).play\n elsif input_1.to_i == 1\n puts \"Would you like to go first and be X?\"\n answer = gets.strip\n if answer.downcase == \"yes\" || answer.downcase == \"y\"\n player_1 = Players::Human.new(\"X\")\n player_2 = Players::Computer.new(\"O\")\n Game.new(player_1, player_2).play\n else\n player_1 = Players::Computer.new(\"X\")\n player_2 = Players::Human.new(\"O\")\n Game.new(player_1, player_2).play\n end\n elsif input_1.to_i == 2\n player_1 = Players::Human.new(\"X\")\n player_2 = Players::Human.new(\"O\")\n Game.new(player_1, player_2).play\n end\n puts \"Would you like to play again?(Yes or No)\"\n play_again = gets.strip\n if play_again.downcase == \"no\" || play_again.downcase == \"n\"\n puts \"Goodbye, play again soon!\"\n end\n end\n end",
"def play\n while !over?\n turn\n board.display\n end\n if won?\n puts \"Congratulations #{winner}!\" \n elsif draw?\n puts \"Cats Game!\" \n end\n end",
"def start\n puts \"Welcome to Tic Tac Toe!\"\n puts \"Select the type of game you'd like to play:\"\n puts \"0 - Computer vs Computer\"\n puts \"1 - Human vs Computer\"\n puts \"2 - Human vs Human\"\n\n input = gets.strip\n\n if input == \"0\"\n this_game = Game.new(player_1 = Players::Computer.new(\"X\"),\n player_2 = Players::Computer.new(\"O\"), board = Board.new)\n this_game.play\n\n elsif input == \"1\"\n puts \"The first player will be 'X', the human player\"\n this_game = Game.new(player_1 = Players::Human.new(\"X\"),\n player_2 = Players::Computer.new(\"O\"), board = Board.new)\n this_game.play\n\n\n elsif input == \"2\"\n puts \"Human player 1 will be 'X', player 2 will be 'O'\"\n this_game = Game.new(player_1 = Players::Human.new(\"X\"),\n player_2 = Players::Human.new(\"O\"), board = Board.new)\n this_game.play\n\n end\n end",
"def play\n start = Time.now\n until @board.won?\n @player ? round_player : round_ai\n @attempts += 1\n sleep(2)\n system(\"cls\")\n @board.render\n end\n finish = Time.now\n time_to_finish = finish - start\n declare_win(time_to_finish)\n end",
"def play\n @play_mode = true\n session[:cards] = @tarot.cards.map(&:id).shuffle\n @tname = @tarot.name\n @tauthor = @tarot.author\n @draw_path = draw_one_tarot_cards_path(@tarot)\n @shuffle_path = play_tarot_cards_path(@tarot)\n # シャッフルでは画面リドローした方がいいので描画しなおす\n # respond_to do |format|\n # format.html\n # format.js\n # end\n end",
"def play_game2\r\n\r\n player = \"O\" #Make Player O the default player for each\r\n #new game\r\n \r\n noOfMoves = 0 #Reset the value of the variable used to\r\n #keep track of the total number of moves\r\n #made in a game\r\n\r\n #Clear out the game board to get it ready for a new game\r\n clear_game_board\r\n\r\n loop do #Loop forever\r\n\r\n Console_Screen.cls #Clear the display area\r\n \r\n #Call on the method that displays the game board and\r\n #collects player moves\r\n square = display_game_board(player)\r\n \r\n #Assign the selected game board square to the player\r\n #that selected it\r\n $A1 = player if square == \"A1\" \r\n $A2 = player if square == \"A2\" \r\n $A3 = player if square == \"A3\" \r\n $B1 = player if square == \"B1\" \r\n $B2 = player if square == \"B2\" \r\n $B3 = player if square == \"B3\" \r\n $C1 = player if square == \"C1\" \r\n $C2 = player if square == \"C2\" \r\n $C3 = player if square == \"C3\" \r\n\r\n #Keep count of the total number of moves that have\r\n #been made\r\n noOfMoves += 1\r\n\r\n #Call on the method that is responsible for \r\n #determining if the game has been won\r\n winner = check_results(player)\r\n \r\n #See is player X has won\r\n if winner == \"X\" then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Player X Wins!\")\r\n #Keep count of the total number of wins that $xWins has\r\n $xWins += 1\r\n break #Terminate the execution of the loop\r\n end\r\n \r\n #See if player O has won\r\n if winner == \"O\" then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Player O Wins!\")\r\n #Keep count of the total number of wins that $oWins has\r\n $oWins += 1\r\n break #Terminate the execution of the loop\r\n end \r\n \r\n #See if the game has ended in a tie\r\n if noOfMoves == 9 then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Tie\")\r\n break #Terminate the execution of the loop\r\n end\r\n \r\n #If the game has not ended, switch player turns and\r\n #keep playing\r\n if player == \"X\" then\r\n player = \"O\"\r\n else\r\n player = \"X\"\r\n end\r\n \r\n end\r\n \r\n end",
"def play_round\n loop do\n self.board.display_board\n self.player1.turn_action\n if self.player1.winner? || self.board.board_full?\n break\n end\n self.player2.turn_action\n if self.player2.winner? || self.board.board_full?\n break\n end\n end\n self.board.display_board\n end",
"def test_taking_turns\r\n pl1 = ConnectNGame::Player.new(\"A\", \"OK\", :silicon)\r\n pl2 = ConnectNGame::Player.new(\"B\", \"GOOD\", :carbon)\r\n\r\n game = ConnectNGame::Game.new(pl1, pl2).game_initialize\r\n\r\n assert_equal(4, game.rack.order)\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(1, game.turn)\r\n\r\n assert_equal(pl2, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(2, game.turn)\r\n\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(3, game.turn)\r\n\r\n assert_equal(pl2, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(4, game.turn)\r\n\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(5, game.turn)\r\n\r\n assert_equal(pl2, game.current_player)\r\n assert_equal(:continue, game.next_move)\r\n assert_equal(6, game.turn)\r\n\r\n assert_equal(pl1, game.current_player)\r\n assert_equal(:victory, game.next_move)\r\n assert_equal(7, game.turn)\r\n end",
"def display_game_board(player)\r\n \r\n move = \"\" #Assign a default value\r\n \r\n loop do #Loop forever\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Display the game board\r\n puts \"\\t\\t\\tWelcome to the Ruby Tic-Tac-Toe Game! \" +\r\n \"\\n\\n\\n\\n\"\r\n puts \"\\t\\t\\t 1 2 3\\n\" \r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t A #{$A1} | #{$A2} | #{$A3}\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t ---------------------\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t B #{$B1} | #{$B2} | #{$B3}\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t ---------------------\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t C #{$C1} | #{$C2} | #{$C3}\"\r\n puts \"\\t\\t\\t | |\"\r\n \r\n #Prompt the player to enter a move\r\n print \"\\n\\n\\n\\n\\nPlayer \" + player + \"'s turn. \" +\r\n \"Please enter your move: \"\r\n \r\n move = STDIN.gets #Collect the player's move\r\n move.chop! #Remove the end of line marker\r\n move = move.upcase #Convert to uppercase\r\n\r\n #user enters \"H\" as hidden cheat to display statistics\r\n if move == \"H\"\r\n puts display_statistics\r\n end\r\n\r\n #user enters \"M\" to load wikipedia instructions page\r\n if move == \"M\"\r\n puts display_wikipedia\r\n end\r\n\r\n #Terminate the loop if a valid move was entered\r\n if move.length == 2 then #Must be at 2 character long\r\n if move =~ /[A-C][1-3]/i #Must be A1, A2, A3, B1, \r\n #B2, B3, C1, C2, or C3\r\n #Call method responsible for determining if the \r\n #board square was available \r\n validMove = validate_player_move(move) \r\n if validMove == true #The move was valid \r\n break #Terminate the execution of the loop\r\n else\r\n #display_error method\r\n display_error\r\n end\r\n else\r\n #display_error method\r\n display_error\r\n end\r\n else\r\n #display_error method\r\n display_error\r\n end\r\n\r\n end\r\n \r\n return move #Return the player's move back to the\r\n #calling statement\r\n \r\n end",
"def play\n take_turn until @master.game_over?\n @master.show_board\n @robot.speak\n end",
"def pick_player\n \n puts \"Let's play Tic Tac Toe!\"\n puts \"But first, let's get acquainted. I am your computer #{Socket.gethostname}\"\n puts \"What's your name?\n \"\n\n # if you don't pick a name we'll pick a greeting for you\n @player = gets.chomp\n if @player == ''\n @player = 'Human friend'\n end\n \n # getting cracking already\n clr \n puts \"A pleaure to see you, #{@player}.\"\n puts \"Please choose if you want to play as X or O\"\n puts \"by pressing the corresponding key on your keyboard.\n \"\n input = ''\n until input == \"x\" || input ==\"o\" do\n input = gets.chomp.upcase\n if input == \"X\" || input == \"O\"\n @marker = input\n puts \"Thanks #{@player}, you picked #{@marker}, what's your move?\\n\"\n new_board\n make_move\n else\n puts \"that's not an X or an O. Try again\"\n end\n end\n end",
"def play\n init_player()\n init_board()\n puts \"Test game play\"\n end",
"def play\n until game_over\n start_new_turn\n show_board\n make_move @current_player\n end\n show_board\n puts \"#{game_over} wins!\"\n end",
"def start_game_human_to_computer(player_1 = Players::Human.new(\"X\"), player_2 = Players::Computer.new(\"O\"),board = Board.new)\n game = Game.new(player_1, player_2, board)\n game.play\n end",
"def opponent_turn\n #set variables\n game = Game.find(self.game_id)\n player = Player.find(game.players.last)\n draw_card = Card.where(player_id: -2).first\n opponent_cards = Card.where(player_id: self.id)\n possible_plays = []\n colors = [\"blue\", \"green\", \"red\", \"yellow\"]\n\n #determine eligible cards in hand.\n opponent_cards.each do |card|\n if card.color == draw_card.color || card.number == draw_card.number || (card.card_action != nil && card.card_action == draw_card.card_action)\n possible_plays.push(card)\n end\n end\n #starts decision logic for card to play, otherwise draws a card and looks for possible plays\n if possible_plays.any?\n #discard current draw pile card\n draw_card.player_id = -1\n draw_card.save\n\n #determines card to be played, sets card to be the new draw pile card\n selected_card = possible_plays.sample\n selected_card.player_id = -2\n selected_card.save\n\n #determines if card has special action, and executes action if it does.\n if selected_card.card_action != nil\n\n if selected_card.card_action === \"skip\" || selected_card.card_action === \"reverse\"\n self.opponent_turn\n elsif selected_card.card_action === \"draw\"\n draw_two = Card.where(player_id: 0).sample(2)\n draw_two.each do |card|\n card.player_id = game.players.first.id\n card.save\n end\n self.opponent_turn\n elsif selected_card.card_action === \"draw_four\"\n draw_four = Card.where(player_id: 0).sample(4)\n draw_four.each do |card|\n card.player_id = player.id\n card.save\n end\n self.opponent_turn\n elsif selected_card.card_action === \"wild_color\"\n selected_card.color = colors.sample\n selected_card.save\n end\n\n else\n #switches current turn once card has been selected and played\n if game.current_turn = self.id\n game.current_turn = player.id\n game.save\n else\n game.current_turn = self.id\n game.save\n end\n\n end\n\n else\n #draws a card from the draw pile and repeats opponent_turn process.\n drawn_card = Card.where(player_id: 0).sample\n drawn_card.player_id = self.id\n drawn_card.save\n self.opponent_turn\n end\n end",
"def onalg_have_to_play(player,command_decl_avail)\r\n decl_str = \"\"\r\n #p command_decl_avail\r\n if player == @player_on_gui[:player]\r\n @log.debug(\"player #{player.name} have to play\")\r\n free_all_btcmd()\r\n command_decl_avail.each do |cmd| \r\n if cmd[:name] == :change_brisc\r\n # change briscola command\r\n decl_str += \"possibile scambio briscola\"\r\n # create command button to change the briscola\r\n create_bt_cmd(\"Cambia bri\", \r\n [ player, cmd[:change_briscola][:briscola], cmd[:change_briscola][:on_hand] ], \r\n :onBtPlayerChangeBriscola)\r\n else\r\n # mariazza declaration command\r\n decl_str += \"#{nome_mariazza(cmd[:name])}, punti: #{cmd[:points]} \"\r\n # create a button with the declaration of this mariazza\r\n create_bt_cmd(cmd[:name], [player, cmd[:name]], :onBtPlayerDeclare)\r\n end\r\n end\r\n end\r\n # mark player that have to play\r\n player_sym = player.name.to_sym\r\n @turn_playermarker_gfx[player_sym].visible = true\r\n \r\n log \"Tocca a: #{player.name}.\\n\"\r\n if player == @player_on_gui[:player]\r\n @player_on_gui[:can_play] = true\r\n log \"#{player.name} comandi: #{decl_str}\\n\" if command_decl_avail.size > 0\r\n else\r\n @player_on_gui[:can_play] = false\r\n end\r\n if @option_gfx[:autoplayer_gfx]\r\n # store parameters into a stack\r\n @alg_auto_stack.push(command_decl_avail)\r\n @alg_auto_stack.push(player)\r\n # trigger autoplay\r\n @app_owner.registerTimeout(@option_gfx[:timout_autoplay], :onTimeoutHaveToPLay)\r\n # suspend core event process untill timeout\r\n @core_game.suspend_proc_gevents\r\n end\r\n \r\n # refresh the display\r\n @app_owner.update_dsp\r\n end",
"def start\n puts \"Connect Four! Try to get four pieces in a row before the other player.\"\n board.print_grid\n until over?\n board.place_piece( light_turn ? LIGHT : DARK, choose_column )\n board.print_grid\n @light_turn = !@light_turn\n end\n end",
"def main\n # Creation partie\n my_game = Game.new\n my_game.initialize_game\n\n # Creation du board\n my_board = Board.new\n\n # Creation des cases du jeu (vide)\n 1.upto(9) { |id| my_board.add_case(BoardCase.new(id)) }\n\n # Creation des joueurs\n print 'Nom du joueur 1 : '\n player1 = Player.new(gets.chomp.to_s, 1)\n print 'Nom du joueur 2 : '\n player2 = Player.new(gets.chomp.to_s, 2)\n my_board.display_board\n # Boucle du jeu\n game_turn(my_game, player1, player2, my_board)\nend",
"def play_turn\n @players.each do |p|\n dice = @dice.roll\n move_player p, dice\n @board.landed_by p\n end\n end",
"def show_board\n # Show empty board at initialization and get variable at each player turn\n puts \" 1 2 3\"\n puts \" a #{@A1.content} | #{@A2.content} | #{@A3.content}\"\n puts \" ---------\"\n puts \" b #{@B1.content} | #{@B2.content} | #{@B3.content}\"\n puts \" ---------\"\n puts \" c #{@C1.content} | #{@C2.content} | #{@C3.content}\"\n\n end",
"def play\n until @board.winner?(:X) || @board.winner?(:O)\n p \"#{@current_player.mark}'s turn\"\n @board.print\n self.play_turn\n end\n\n @board.print\n self.switch_players!\n p \"#{@current_player.mark} has won!\"\n end",
"def turn\n array = [\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"]\n firstshow = Show.new\n firstshow.show(array)\n puts \"What do you want to play ? \" #ask the player what he choose to play\n end",
"def play\n @board.print_board\n 9.times do |turns|\n if turn\n break\n end\n end\n end",
"def control(player_choice) \n if @game_over == false\n @game.make_move(@game.current_player, player_choice) \n if @game.win? \n @game.print_grid\n puts print_name(@game.win?) + \" gets \" + pink(\"cake\") + \", the loser will not be \" + pink(\"reformated into cake ingredients.\")\n @game_over = true\n elsif @game.tie? \n @game.print_grid\n puts \"It seems that you are both \" + pink(\"equally dumb\") + \". And probably \" + pink(\"equally flamable.\")\n @game_over = true\n else \n if @game_mark == \"player\" \n assign_player\n start_turn\n elsif @game_mark == \"AI\" \n \n if @game.current_player == \"O\" \n assign_player \n @AI.make_move \n elsif @game.current_player == \"X\" \n assign_player \n start_turn \n end\n else \n raise \"Game mark Error\".inspect\n end\n end\n end\n end",
"def turn()\n puts \"Coins: #{@current_player.get_coin_count}\"\n @current_player.show_active_cards\n puts Action.show_all_actions.join \"\\n\"\n\n # If a player ahs more than 10 coins he must stage a coup\n if (@current_player.get_coin_count > 10)\n action_id = \"2\"\n else\n puts \"#{@current_player} what is your action\"\n action_id = gets.strip\n end\n\n current_action = Action.new(action_id)\n if current_action.requires_target\n target_player = nil\n while target_player == nil || target_player == @current_player\n puts \"Select a target\"\n target_id = gets.strip\n target_player = get_player_by_id(target_id)\n end\n current_action.set_target(target_player)\n end\n\n turn_over = false\n action_failed = false\n\n @@turn += 1\n\n puts \"#{@current_player} moves: #{current_action}\"\n\n if (current_action.can_be_challenged?)\n puts \"Enter Y to challenge\"\n challenge = gets.strip\n if challenge == 'Y'\n puts \"Challenger enter your id\"\n player_challenging_id = gets.strip\n\n if (challenge && player_challenging_id)\n if @current_player.has_claimed_action_character?(current_action)\n @player_challenging = get_player_by_id(player_challenging_id)\n @player_challenging.loses_influence\n @current_player.swap_influence(current_action, @deck)\n else\n @current_player.loses_influence\n action_failed = true\n end\n end\n end\n turn_over = true\n end\n\n if (!turn_over && current_action.can_be_countered?)\n puts \"Enter Y to counteract\"\n counteraction = gets.strip\n\n if counteraction == 'Y'\n puts \"Counteractor enter your id\"\n counteracting_player_id = gets.strip\n if counteracting_player_id\n @counteracting_player = get_player_by_id(counteracting_player_id)\n puts \"Current player enter Y to challenge this counteraction\"\n challenge_counteraction = gets.strip\n if challenge_counteraction\n if @counteracting_player.has_claimed_counteraction_character?(current_action)\n @current_player.loses_influence\n @counteracting_player.swap_influence(current_action, @deck)\n else\n @counteracting_player.loses_influence\n end\n turn_over = true\n else\n turn_over = true\n action_failed = true\n end\n end\n end\n end\n\n if !action_failed\n current_action.succeed(@current_player, current_action, @deck)\n end\n\n next_player()\n\n if is_game_over()\n puts \"game over\"\n puts \"#{get_winner} wins\"\n else\n turn()\n end\n\n end",
"def turn\n input = current_player.move(board)\n\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n turn\n end\n end",
"def play_some_moves(game)\n first_player = game.active_player\n second_player = game.inactive_player\n size = game.board_size\n moves = [size + 1, 2*size - 2, 3*size + 1, 4*size - 2]\n\n i = 0\n 2.times do\n [first_player, second_player].each do |player|\n game.new_move(moves[i], player)\n i += 1\n end\n end\nend",
"def play_turn(player)\n puts \"Tour #{@count_turn}\"\n puts \"C'est au tour de #{player.name} (#{player.symbol})\"\n puts \"Quelle case souhaitez-vous jouer ?\"\n print \"> \"\n boardcase_selected = gets.chomp.to_s\n # Check if boardcase_selected exists\n if @boardcases.count { |b_case| b_case.case_id.include?(boardcase_selected) } == 1\n @boardcases.each do |b_case|\n # Check if boardcase selected exists and its value has not been modified yet\n if b_case.case_id == boardcase_selected && b_case.case_value == \" \"\n b_case.case_value = player.symbol\n end\n end\n else\n puts \"La case sélectionnée n'est pas valide\"\n end\n Show.new.show_board(self)\n @count_turn += 1\n end",
"def initialize # calls the class Show with a new board\n\t\tShow.new\n\t\tcreate_player1\n\t\tcreate_player2\n\t\t@partie = Game.new(@player1, @player2) #class Game\n\t\t@partie.each_turn\n\tend",
"def play\n @players.each { |player| player.score = 0 }\n\t \n\tloop do\n\t @board.clear\n @cur_player = @players[0]\n\t @rounds += 1\n\t\t\n\t print \"\\n******************* Connect Four ********************\"\n\t puts \"\\n#{@players[0].name} will play with #{@players[0].color}; #{@players[1].name} will play with #{@players[1].color}\\n\\n\"\n\t @board.print_board \n\t \n\t loop do\n position = prompt_movement\n\t @board.set_disk(position, @cur_player.color)\n\t\t@board.print_board \n\t\t \n\t\tresult = \n\t\t if @board.is_winner?(@cur_player.color)\n\t\t @cur_player.score += 1\n\t\t puts \"\\n#{@cur_player.name} wins!!\"\n\t\t\ttrue\n\t\t elsif @board.is_full?\n\t\t puts \"\\nThe game ended in a tie!\"\n\t\t\ttrue\n\t end\n\t\t \n\t\tbreak if result\n\t\tswap_players\n end\n\t\t\n\t break if prompt_quit\n\tend\n\t \n\tprint_final_score\n end",
"def play_game\n loop do\n puts \"\\n\\n\"\n display_board\n player_turn\n check_game_status\n end\n end",
"def play\n\n @board.render(clear=true)\n until @board.won? \n\n # should call reveal two time\n guess_1 = @board.reveal # gonna get position guess from the user and return the value\n @board.render(clear=true)\n guess_2 = @board.reveal # gonna get position guess from the user and return the value\n @board.render(clear=true)\n \n if guess_1 == guess_2\n puts \"It's a match!\" \n else\n # reset the board - set all card to face_up == false\n puts \"Try Again!\"\n @board.reset \n end\n sleep 3\n \n @board.render(clear=true)\n end\n end",
"def play\n until over? == true\n turn\n end\n if self.winner == nil\n puts \"Cats Game!\"\n else\n puts \"Congratulations #{self.winner}!\"\n #Congradulate the winner of the game, using the person with the most X or O combinations\n #Code in a play again option, so players don't have to re enter name\n board.display\n end\n end",
"def play_game\r\n\r\n player = \"X\" #Make Player X the default player for each\r\n #new game\r\n \r\n noOfMoves = 0 #Reset the value of the variable used to\r\n #keep track of the total number of moves\r\n #made in a game\r\n\r\n #Clear out the game board to get it ready for a new game\r\n clear_game_board\r\n\r\n loop do #Loop forever\r\n\r\n Console_Screen.cls #Clear the display area\r\n \r\n #Call on the method that displays the game board and\r\n #collects player moves\r\n square = display_game_board(player)\r\n \r\n #Assign the selected game board square to the player\r\n #that selected it\r\n $A1 = player if square == \"A1\" \r\n $A2 = player if square == \"A2\" \r\n $A3 = player if square == \"A3\" \r\n $B1 = player if square == \"B1\" \r\n $B2 = player if square == \"B2\" \r\n $B3 = player if square == \"B3\" \r\n $C1 = player if square == \"C1\" \r\n $C2 = player if square == \"C2\" \r\n $C3 = player if square == \"C3\" \r\n\r\n #Keep count of the total number of moves that have\r\n #been made\r\n noOfMoves += 1\r\n\r\n #Call on the method that is responsible for \r\n #determining if the game has been won\r\n winner = check_results(player)\r\n \r\n #See is player X has won\r\n if winner == \"X\" then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Player X Wins!\")\r\n #Keep count of the total number of wins that $xWins has\r\n $xWins += 1\r\n break #Terminate the execution of the loop\r\n end\r\n \r\n #See if player O has won\r\n if winner == \"O\" then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Player O Wins!\")\r\n #Keep count of the total number of wins that $oWins has\r\n $oWins += 1\r\n break #Terminate the execution of the loop\r\n end \r\n \r\n #See if the game has ended in a tie\r\n if noOfMoves == 9 then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Tie\")\r\n break #Terminate the execution of the loop\r\n end\r\n \r\n #If the game has not ended, switch player turns and\r\n #keep playing\r\n if player == \"X\" then\r\n player = \"O\"\r\n else\r\n player = \"X\"\r\n end\r\n \r\n end\r\n \r\n end",
"def turn\n input = current_player.move(board)\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n board.display\n turn\n end\n end",
"def turn(row, column)\n place_piece(row, column)\n puts display_board\n check_for_win() \n end",
"def game_turns\n @turn_obj.play_turn(solution, mode, @computer_solve_obj) until @turn_obj.game_over(@turn_obj.results,mode)\n end",
"def playerTurn(a)\n \ninitMatrix (a)\npaintMatrix (a)\nplayer = 1\nstop = false\ncounterTie = 0\n\t\n\twhile (!stop)\n\t\t\tcounterTie = counterTie + 1\n\t\t\tinsertNumber(a,player)\n\t\t\tpaintMatrix(a)\n\n\t\t\tif(player == 1)\n\t\t\t\tif(checker(a, player))\n\t\t\t\tputs \"Player #{player} wins\".yellow\n\t\t\t\tputs\"\"\n\t\t\t\tstop = true\n\t\t\t\tend\n\t\t\t\tplayer = player + 1\n\t\t\telse\n\t\t\t\tif(checker(a, player))\n\t\t\t\tputs \"Player #{player} wins\".yellow\n\t\t\t\tputs\"\"\n\t\t\t\tstop = true\n\t\t\t\tend\n\t\t\t\tplayer = player - 1\n\t\t\tend\n\t\t\t\tif(counterTie == a.length**2)\n\t\t\t\tstop = true\n\t\t\t\tputs \"TIE\".yellow\n\t\t\t\tputs\"\"\n\t\t\t\tend\n\tend \nend",
"def play(move, peice = @current_player.peice)\n @board[move] = peice\n change_turns\n end",
"def play_game\n puts \"Welcome to Tic Tac Toe (#{@dim} x #{@dim})!\"\n catch :game_end do\n while(moves)\n print_board\n @players.each do |player|\n # p moves\n square_number = player.move(moves)\n set_move(player, square_number)\n # Checks if player just won with their last move\n if(won?(player, square_number))\n print_board\n display_win_message(player)\n throw :game_end\n end\n end\n end\n puts \"Amazing, a tie game!\"\n throw :game_end\n end\n\n print \"Do you want to play again? [y/n] \"\n answer = gets.chomp\n if(answer[0] == \"y\" || answer[0] == \"Y\")\n clear_board\n print_board\n play_game\n else\n puts \"Bye!\"\n end\n end",
"def play(board)\nwhile !over?(board)\nturn(board)\nend\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play\n puts \"#{current_player.name} has randomly been selected as the first player\"\n while true\n board.display\n puts \"\"\n array = to_coordinate(select_case)\n x, y = array[0], array[1]\n board.set_cell(x, y, current_player.color)\n result = board.game_over\n if result == :winner\n board.display\n puts \"Congratulation #{current_player.name} you won!\"\n return\n elsif result == :draw\n puts \"No winners. Draw.\"\n return\n else\n switch_players\n end\n end\n end",
"def make_move(left,top)\n # get destination selected\n dest = get_clicked_box(left,top)\n # try to make the move on the board; @game.user_move returns false if move is not allowed\n if @game.user_move(@selected_piece, dest)\n # move the piece on the GUI boars\n move_piece(@selected_piece,dest)\n de_highlight(@selected_piece)\n deselect_piece\n # switch player turn after the move\n @game.switch_turn\n else\n # if move not allowed deselect and de highlight the piece\n de_highlight(@selected_piece)\n deselect_piece\n end\nend",
"def board_visualization\n puts @player_1.join\n puts @player_2.join\n end",
"def start\n\t\twhile @playing\n\t\t\tletter, x_coordinate, y_coordinate = @player.make_decision\n\t\t\tuntil @board.draw(letter, x_coordinate, y_coordinate)\n\t\t\t\tletter, x_coordinate, y_coordinate = @player.make_decision\n\t\t\tend\n\t\t\t@board.print_board\n\t\t\tvictory_check?\n\t\t\tif @playing\n\t\t\t\tletter, x_coordinate, y_coordinate = @computer.make_decision(@board.available_spaces)\n\t\t\t\t@board.draw(letter, x_coordinate, y_coordinate)\n\t\t\t\t@board.print_board\n\t\t\t\tvictory_check?\n\t\t\tend\n\t\tend\n\n\t\tputs \"Would you like to play again?(y/n)\"\n\t\tchoice = gets.chomp.downcase\n\t\tif choice == \"y\"\n\t\t\t@board.clear_board\n\t\t\t@playing = true\n\t\t\tstart\n\t\telse\n\t\t\tputs \"Goodbye!\"\n\t\tend\n\tend",
"def turn\n puts \"Turn #{@board.count_turn + 1}, player #{get_current_player.name} choose:\"\n @board.play_turn\n end",
"def turn \n puts \"Make a move compadre\"\n input = gets.strip\n location = input_to_index(input)\n if valid_move?(location)\n tictac = current_player\n move(location, tictac)\n display_board\n else\n turn\n end\n end",
"def play_full_game\n Display.clear_screen\n Display.draw_board(@cur_board, @player_white, @player_black)\n Display.game_start_ui\n fast_forward(@data[\"moves\"].keys[-1], true)\n Display.draw_board(@cur_board, @player_white, @player_black)\n Display.game_end_ui(determine_winner)\n end"
] | [
"0.64582855",
"0.6390269",
"0.61833715",
"0.61699545",
"0.6158984",
"0.61464894",
"0.61271465",
"0.6112989",
"0.6077604",
"0.60116607",
"0.6010722",
"0.60003346",
"0.59994644",
"0.597408",
"0.5971174",
"0.59674484",
"0.5945435",
"0.59450364",
"0.59306693",
"0.5925532",
"0.58904296",
"0.58902365",
"0.5889475",
"0.58718866",
"0.5860585",
"0.58519346",
"0.5847605",
"0.5841628",
"0.5835981",
"0.5831917",
"0.5819629",
"0.5808859",
"0.57835096",
"0.5765652",
"0.5761294",
"0.5746673",
"0.57433397",
"0.5737791",
"0.5736385",
"0.57068205",
"0.56953025",
"0.5690784",
"0.56720465",
"0.5666372",
"0.56625026",
"0.5654282",
"0.5647512",
"0.564624",
"0.56445074",
"0.5629603",
"0.5625253",
"0.5621855",
"0.56216735",
"0.561876",
"0.559761",
"0.55870336",
"0.5578784",
"0.5578202",
"0.55764604",
"0.5565981",
"0.55546755",
"0.5533355",
"0.5506215",
"0.5505567",
"0.55032307",
"0.5488917",
"0.5479106",
"0.5477686",
"0.54746586",
"0.54728425",
"0.5465073",
"0.54562515",
"0.54547733",
"0.54490113",
"0.5444819",
"0.54438055",
"0.544338",
"0.54388225",
"0.54270214",
"0.5423165",
"0.5413788",
"0.54134756",
"0.5402695",
"0.54020405",
"0.54008126",
"0.53996336",
"0.539884",
"0.5398161",
"0.5398081",
"0.53966933",
"0.5396405",
"0.5395413",
"0.53881246",
"0.53876436",
"0.5378821",
"0.5375538",
"0.53657144",
"0.53652096",
"0.5361612",
"0.53588164",
"0.5354241"
] | 0.0 | -1 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash)
if name_hash.empty?
return nil
else
min_v = name_hash.first[1]
min_k = name_hash.first[0]
name_hash.each do
|k,v|
if v < min_v
min_v = v
min_k = k
end
end
min_k
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |k, v|\n if v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n smallest_value = nil\n smallest_key = nil\n hash.each do |name, num|\n if smallest_value == nil || num < smallest_value\n smallest_value = num\n smallest_key = name\n end\n end\n smallest_key\nend",
"def key_for_min_value(hash)\n min_val = Float::INFINITY\n min_key = nil\n hash.each do |key, value|\n if value < min_val\n min_val = value\n min_key = key\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n \n min_val = Float::INFINITY\n min_key = nil\n hash.each do |k, v|\n if min_val > v\n min_val = v\n min_key = k\n end\n end\n return min_key\nend",
"def key_for_min_value(hash)\n smallest_key = nil\n tiny_value = nil\n hash.each do |key, value|\n if tiny_value == nil || value < tiny_value\n tiny_value = value\n smallest_key = key\n end\n end\n smallest_key\nend",
"def key_for_min_value(hash)\n smallest = nil\n key = nil\n hash.collect do |name, val|\n if smallest == nil || val < smallest\n smallest = val\n key = name\n end\n end\n key\nend",
"def key_for_min_value(hash)\n int_hash = hash.select { |key, val| val.class == Fixnum }\n smallest = int_hash[int_hash.keys.sample]\n # debugger\n int_hash.each do |key, val|\n if val < smallest\n smallest = val \n end\n end\n int_hash.key(smallest)\nend",
"def key_for_min_value(hash)\r\n smallest_key = nil\r\n tiniest_value = nil\r\n hash.each do |key, value|\r\n if tiniest_value == nil || value < tiniest_value\r\n tiniest_value = value\r\n smallest_key = key\r\n end\r\n end\r\n smallest_key\r\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = 0\n\n\n hash.each do |key,value|\n if lowest_value == 0 || value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n min = nil\n hash.each_pair do |key, value|\n min ||= value\n min = value if value < min\n end\n hash.key(min)\nend",
"def key_for_min_value(hash)\n smallest = nil\n hash.each do |key, value|\n if smallest == nil\n smallest = key\n end\n if hash[key] < hash[smallest]\n smallest = key\n end\n end\n smallest\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k, v|\n if lowest_value == nil || v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k, v|\n if lowest_value == nil || v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n smallest_key = nil\n tiniest_value = nil\n hash.each do |key, value|\n if tiniest_value == nil || value < tiniest_value\n \n # this way, the smallest value in the hash so far always overwrites the existing tiniest value\n \n tiniest_value = value\n smallest_key = key\n end\n end\n smallest_key\nend",
"def key_for_min_value(hash)\n hash_key = nil\n hash_value = nil\n hash.each do |key, value|\n if hash_value == nil || value < hash_value\n hash_value = value\n hash_key = key\n end\n end\n hash_key\nend",
"def key_for_min_value(hash)\n min_key = nil\n hash.each do |key, value|\n if min_key.nil?\n min_key = key\n elsif value < hash[min_key]\n min_key = key\n else\n next\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n min_key = nil\n hash.each do |key, value|\n if min_key.nil?\n min_key = key\n elsif value < hash[min_key]\n min_key = key\n else\n next\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n min = 99999999\n min_key = nil\n hash.select do |key, value|\n if value < min\n min = value\n min_key = key\n end\n end\n min_key\nend",
"def key_for_min_value(hash)\n if hash.empty?\n return nil\n end\n ans = [hash.first[0],hash.first[1]]\n hash.each do |k,v|\n if v < ans[1]\n ans[1] = v\n ans[0] = k\n end\n end\n return ans[0]\nend",
"def key_for_min_value(hash)\n key = nil\n lowest_value = nil\n hash.each do |name, value|\n if lowest_value == nil || value < lowest_value\n lowest_value = value\n key = name\n end\nend\nkey\nend",
"def key_for_min_value(hash)\n hash_key = nil\n hash_value = nil\n hash.each do |a, b|\n if hash_value == nil || b < hash_value\n hash_value = b\n hash_key = a\n end\n end\n hash_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil \n hash.each do |key, value|\n if lowest_value == nil || value < lowest_value \n lowest_value = value \n lowest_key = key \n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n lowestnum = 1000\n name_hash.each_value do |hashvalue|\n if hashvalue < lowestnum\n lowestnum = hashvalue\n end\n end\n name_hash.index(lowestnum)\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_number = nil\n name_hash.each do |name, number|\n if lowest_number == nil || number < lowest_number\n lowest_number = number\n lowest_key = name\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k,v|\n # first iteration\n ## this creates a starting point for comparison\n if lowest_value == nil || lowest_value > v\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n low = Float::INFINITY\n name_hash.each do |k,v|\n if v < low\n low = v\n end\n end\n name_hash.key(low)\nend",
"def key_for_min_value(hash)\n small_key = nil\n small_value = nil\n \n hash.each do |key, value|\n if small_value == nil || value < small_value\n small_value = value\n small_key = key\n end\nend\nsmall_key\nend",
"def key_for_min_value(hash)\n low_min = 1000\n min_key = nil\n hash.each do |key, value|\n if(low_min > value)\n low_min = value\n min_key = key\n end\nend\n min_key\nend",
"def key_for_min_value(name_hash)\n lowest = nil\n key = nil\n if name_hash.length == 0\n return \n end\n \n name_hash.each do |name, number|\n if lowest == nil\n lowest = number\n end\n if key == nil\n key = name\n end\n if number < lowest\n lowest = number\n key = name\n end\n end\n key\nend",
"def key_for_min_value(hash)\n least_value = nil \n least_key = nil\n hash.each do |a, b|\n if least_value == nil || b < least_value\n least_value = b\n least_key = a\n end\n end\n least_key\nend",
"def key_for_min_value(name_hash)\n\tif name_hash == {}\n\t\tnil\n\tend\n\n\tsmallest_key = nil\n\tsmallest_value = nil\n\tname_hash.each do |key, value|\n\t\tif !smallest_value || value < smallest_value\n\t\t\tsmallest_key = key\n\t\t\tsmallest_value = value\n\t\tend\n\tend\n\tsmallest_key\nend",
"def key_for_min_value(hash)\n i = 0\n lowest1 = :key\n lowest = 0\n if hash.empty? == true \n return nil\n end\n hash.each do |name, value|\n if i == 0\n lowest1 = name\n lowest = value\n i =+ 1\n end\n if value < lowest\n lowest1 = name\n lowest = value\n end\n if hash.empty? == true \n lowest1 = nil\n end\n end\n lowest1\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n name_hash.each do |name, amount|\n if amount < lowest_value\n lowest_value = amount\n lowest_key = name\n end\n end\n lowest_key\n end",
"def key_for_min_value(hash)\n lo_key = nil \n lo_value = nil \n hash.each do |k,v| \n if lo_key == nil || v < lo_value\n lo_key = k \n lo_value = v \n end \n end \n lo_key\n end",
"def key_for_min_value(hash)\n\n lowest_key = nil \n lowest_value = nil \n \n hash.each do |key,value|\n if lowest_value == nil || lowest_value > value\n\n lowest_key = key\n lowest_value = value \n end \n \n end \n lowest_key\nend",
"def key_for_min_value(name_hash)\n small_num = Float::INFINITY\n smallest_key = \"\"\n if name_hash.length == 0\n return nil\n end\n name_hash.each do |key, value|\n if value < small_num\n small_num = value\n smallest_key = key\n end\n end\nsmallest_key\nend",
"def key_for_min_value(hash)\n value_only_array = []\n hash.each_pair do |key, value|\n value_only_array << value\n end\n value_only_array.sort!\n hash.key(value_only_array[0])\nend",
"def key_for_min_value(hash)\n return nil if hash.empty?\n arr = hash.collect {|key, value| value}.sort\n hash.each {|key, value| return key if value == arr[0]}\nend",
"def key_for_min_value(hash)\n array = []\n hash.each do |key, value|\n array << value\n end\n array.sort!\n hash.key(array[0])\nend",
"def key_for_min_value(name_hash)\n lowest_key=nil\n lowest_value=Float::INFINITY\n name_hash.each{|key, value| \n if value<lowest_value\n lowest_value=value\n lowest_key=key\n end\n }\n lowest_key\nend",
"def key_for_min_value(name_hash)\n empty_hash = nil\n lowest_value = 10000000000000000000000\n name_hash.collect do |name, value|\n if value < lowest_value\n lowest_value = value\n empty_hash = name\n end\n end\n empty_hash\nend",
"def key_for_min_value(name_hash)\n lowest = \"\"\n lowest = nil if name_hash.empty?\n high_num = 100000000000000000\n name_hash.each do | key, value |\n lowest = key if value < high_num\n high_num = value if value < high_num\n end\n lowest\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = nil\n name_hash.each do |name, num|\n if lowest_key == nil || num < lowest_value\n lowest_key = name\n lowest_value = num\n elsif name_hash == nil\n nil\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n num = nil\n name_hash.collect do |key, value|\n if value < num\n num = value\n end\n end \n name_hash.key(num)\nend",
"def key_for_min_value(name_hash)\n smallest_val = 0\n smallest_key = nil\n name_hash.each do|key, val|\n if smallest_val == 0 || val < smallest_val\n smallest_val = val\n smallest_key = key\n end\n end\n smallest_key\n\nend",
"def key_for_min_value(name_hash)\n smallest_hash_key = nil\n name_hash.each do |key, val|\n if smallest_hash_key == nil\n smallest_hash_key = key\n next\n elsif val < name_hash[smallest_hash_key]\n smallest_hash_key = key\n end\n end\n smallest_hash_key\nend",
"def key_for_min_value(hash)\n if hash.count < 2\n return hash[0]\n else \n num = 42\n hash.each do |key, value|\n if value <= num\n num = value\n end\n end\n hash.invert[num] \n end\nend",
"def key_for_min_value(name_hash)\n return nil if name_hash.empty?\n lowest_number = name_hash.first[1];\n key_value = \"\"\n name_hash.each do |key, value|\n if value <= lowest_number\n lowest_number = value\n key_value = key\n end\n end\n key_value\nend",
"def key_for_min_value(name_hash)\n current = 0\n lowest = 0\n lowest_key = nil\n name_hash.collect do |key, value|\n current = value\n if current < lowest || lowest == 0\n lowest = current\n lowest_key = key\n end\n\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowestvalue = 1000\n name_hash.each do |name, value|\n if value < lowestvalue\n lowest_key = name\n lowestvalue = value\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n small_value = 10000000000\n small_key = nil\n name_hash.each do |k,v|\n if v < small_value\n small_value = v\n small_key = k\n end\n end\n small_key\nend",
"def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |k, v|\n if low_value == nil || v < low_value\n low_value = v\n low_key = k\n end\n end\n low_key\n end",
"def key_for_min_value(hash)\n lowest_value = nil\n lowest_key = nil\n\n hash.each do |key, value|\n if lowest_value == nil # tell me if this makes sense\n lowest_value = value\n lowest_key = key\n elsif lowest_value > value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key #you want to return the key for min\nend",
"def key_for_min_value(hash)\n \n if hash.empty?\n return nil\n end\n min_value=500\n min_key=:symbol\n \n hash.each do |key, value|\n if value<min_value\n min_value=value\n min_key=key\n end\n end\n return min_key\nend",
"def key_for_min_value(name_hash)\n lowestKey = nil\n lowestValue = Float::INFINITY\n name_hash.each do |k, v|\n if v < lowestValue\n lowestValue = v\n lowestKey = k\n end\n end\n lowestKey\n\nend",
"def key_for_min_value(name_hash)\n smallest_val = 0\n smallest_key = 0\n comp = nil\n name_hash.each do |key,val|\n comp = val\n if smallest_key == 0\n smallest_key = key\n smallest_val = val\n end \n if comp < smallest_val\n smallest_val = comp\n smallest_key = key\n end\n end\n if smallest_key == 0 \n return nil \n else\n return smallest_key\n end\nend",
"def key_for_min_value(name_hash)\n lowest_key=nil\n lowest_val=0\n name_hash.collect do |key,value|\n if value<lowest_val or lowest_val==0\n lowest_key=key\n lowest_val=value\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n smallest = nil\n this_num = 0\n previous_num = 1000000\n name_hash.collect { |item, qty|\n this_num = qty\n if this_num < previous_num\n smallest = item\n previous_num = this_num\n end\n }\n smallest\nend",
"def key_for_min_value(name_hash)\n rkey = nil\n rvalue = 10000000000000000\n name_hash.each do |key, value|\n if value < rvalue\n rkey = key\n rvalue = value\n end\n end\n rkey\nend",
"def key_for_min_value(name_hash)\n\tsmallest_value = nil\n\tassociated_key = nil \n\tname_hash.collect do |key, value|\n\t\tif smallest_value == nil || value < smallest_value\n\t\t\tsmallest_value = value \n\t\t\tassociated_key = key\n\t \tend\n\tend\n\tassociated_key\nend",
"def key_for_min_value(hash)\n # binding.pry\n lowest_key = nil\n lowest_value = 0\n # binding.pry\n hash.each do |key, value|\n if lowest_key == nil || value < lowest_value\n # binding.pry\n lowest_value = value\n lowest_key = key\n # binding.pry\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n hash.key(hash.values.min)\nend",
"def key_for_min_value(hash)\n hash.key(hash.values.min)\nend",
"def key_for_min_value(name_hash)\n smallest_value = 100\n name_hash.each do |key, value| \n if value < smallest_value\n smallest_value = value \n end \n end\n name_hash.key(smallest_value)\nend",
"def key_for_min_value(name_hash)\n lowest=\"\"\n lowest=nil if name_hash.empty?\n tracker=100000000\n name_hash.each do |key,value|\n lowest=key if value<tracker\n tracker=value if value<tracker\n # if value<tracker\n end\n lowest\nend",
"def key_for_min_value(name_hash)\n if name_hash.length == 0 \n nil\n else\n smallest_num = nil\n smallest_num_key = nil\n name_hash.collect do |key, value|\n if smallest_num == nil\n smallest_num = value\n smallest_num_key = key\n elsif smallest_num > value\n smallest_num = value\n smallest_num_key = key\n end\n end\n smallest_num_key\n end\n\nend",
"def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |n, s|\n if low_value == nil\n low_value = s\n low_key = n\n elsif low_value > s\n low_value = s\n low_key = n\n end\n end\n low_key\nend",
"def key_for_min_value(name_hash)\n return nil if name_hash == nil || name_hash == {}\n number_array = name_hash.collect do |name, number|\n number\n end\n number_array.sort!\n name_hash.key(number_array[0])\nend",
"def key_for_min_value(name_hash)\n lowestId = nil\n lowestNum = 0\n name_hash.each{ |id, val|\n if lowestNum == 0 \n lowestNum = val\n end\n if val <= lowestNum\n lowestNum = val\n lowestId = id\n end\n }\n return lowestId\nend",
"def key_for_min_value(name_hash)\n lowest_v = nil\n lowest_k = nil\n name_hash.each do |name, value|\n if lowest_v == nil\n lowest_v = value\n lowest_k = name\n elsif value < lowest_v\n lowest_v = value\n lowest_k = name\n end\n end\n lowest_k\n end",
"def key_for_min_value(name_hash)\n smallest_key = nil\n smallest_value = nil\n name_hash.each do |j, r|\n if smallest_value == nil || r < smallest_value\n smallest_value = r\n smallest_key = j\n end\n end\n smallest_key\nend",
"def key_for_min_value(name_hash)\nlowest = 1000000\n low_key = nil\n name_hash.each {|key, value|\n if value < lowest\n lowest = value\n low_key = key\n end\n }\n low_key\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n name_hash.each_key do |key|\n if lowest_key == nil\n lowest_key = key\n elsif name_hash[key] < name_hash[lowest_key]\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n\n if name_hash.empty?\n return nil\n end\n lowest = Float::INFINITY\n name_hash.each_pair do |k, v|\n if v < lowest\n lowest = v\n end\n end\n name_hash.each_pair do |k, v|\n if v == lowest\n return k\n end\n end\nend",
"def key_for_min_value(name_hash)\n output = 0\n smallest = nil\n name_hash.map do |key, value|\n if value < output || output == 0\n output = value\n smallest = key\n end\n end\n\n smallest\nend",
"def key_for_min_value(my_hash)\n #what is my value?\n lowest_value = 500\n lowest_key = nil\n\n my_hash.collect do |key, value|\n # what is my value?\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(name_hash)\n lowest_num = 1000000000\n lowest_num_key = \" \"\n if name_hash == {}\n return nil\n else\n name_hash.each do |name, num|\n if num < lowest_num\n lowest_num = num\n lowest_num_key = name\n end\n end\n return lowest_num_key\n end\nend",
"def key_for_min_value(name_hash)\n nums = name_hash.collect do |item, num|\n num\n end\n nums.sort!\n nums[0]\n \n min_key = nil\n name_hash.map do |item, num|\n if num == nums[0]\n min_key = item\n end\n end\n min_key\nend",
"def key_for_min_value(name_hash)\n vals = name_hash.collect { |key, value| value }\n keys = name_hash.collect { |key, value| key }\n low = vals[0]\n lowkey = keys[0]\n if name_hash.empty?\n nil\n else\n name_hash.collect do |key, value|\n if value < low\n low = value\n lowkey = key\n end\n end\n lowkey\n end\nend",
"def key_for_min_value(name_hash)\n value1 = 0\n lowestKey = nil\n name_hash.each do |key, value|\n if(value1 == 0)\n value1 = value\n lowestKey = key\n end\n if(value1 > value)\n value1 = value\n lowestKey = key\n elsif (value1 < value)\n lowestKey = lowestKey\n value1 = value1\n end\n end\n return lowestKey\nend",
"def key_for_min_value(hash)\n return nil if hash.empty?\n arr = hash.collect { |k, v| v }.sort\n hash.each { |k, v| return k if v == arr[0] }\nend",
"def key_for_min_value(name_hash)\n # saves the smaller value in memo, and takes the first elem of memo at the end (the key)\n smallest = name_hash.inject do|memo, (k, v)|\n memo = v < memo[1] ? [k,v] : memo\n end\n #handle the empty hash case...\n smallest ? smallest[0] : nil\nend",
"def key_for_min_value(name_hash)\n key = \"\"\n low_value = nil\n if name_hash.empty? == true\n return nil\n end\n name_hash.each do |name, number|\n if low_value == nil || number < low_value\n low_value = number\n key = name\n end\n end\n key\nend",
"def key_for_min_value(name_hash)\n answer = nil\n smallest = nil\n name_hash.each {|key, value|\n if smallest.nil?\n smallest = value\n end\n if value <= smallest\n smallest = value\n answer = key\n end\n }\n answer\nend",
"def smallest_key(q, hash)\n\t\ttemp = {}\n\t\tq.each do |v|\n\t\t\ttemp[v] = hash[v]\n\t\tend\n\t\treturn temp.key(temp.each_value.min)\n\tend",
"def key_for_min_value(name_hash)\n lowest_value = 0\n lowest_key = \"\"\n if name_hash.empty? == true\n nil\n else\n name_hash.each_with_index do |(key, value), i|\n if i == 0\n lowest_value = value\n lowest_key = key\n elsif value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\n end\nend",
"def key_for_min_value(name_hash)\n low=10000000000000000000\n return_key=nil\n name_hash.each do |key, value|\n if value<low\n low=value\n return_key=key\n end\n end\n return_key\nend",
"def key_for_min_value(hash)\n if hash.length == 0\n return nil\n else\n smallest = 1000\n printme = \"\"\n hash.each do |thing, number|\n if number < smallest\n smallest = number\n printme = thing\n end\n end\n printme\n end\nend",
"def key_for_min_value(name_hash)\n \n lowest_key = nil\n lowest_value = nil\n name_hash.each do |name_key, name_value|\n if lowest_value == nil || name_value < lowest_value\n lowest_value = name_value\n lowest_key = name_key\n end\n end\n lowest_key\n \n end",
"def key_for_min_value(name_hash)\n the_key = nil \n the_value = 1/0.0\n # Infinity...can also be expressed as FLOAT::Infinity\n name_hash.each do |id, num|\n if num <= the_value\n the_value = num\n the_key = id\n end\n end\n the_key\nend",
"def key_for_min_value(hash)\n array = []\n hash.each {|key,value| \n if array.empty? || value < array[1] \n array[0] = key \n array[1] = value \n end }\n if !array.empty? \n array.first \n else \n nil \n end\nend",
"def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n name_hash.each do |k,v|\n if v < lowest_value\n lowest_value = v\n lowest_key = k\n end \nend\nlowest_key\nend",
"def key_for_min_value(name_hash)\n return nil if name_hash == {}\n smallest_key = name_hash.first[0]\n smallest_val = name_hash.first[1]\n\n name_hash.each do |pair|\n if pair[1] < smallest_val\n smallest_key = pair[0]\n end\n end\n smallest_key\nend",
"def key_for_min_value(name_hash)\n key_of_smallest_value = \"\"\n smallest_value = 99999\n name_hash.each do |key, value|\n if smallest_value > value\n smallest_value = value\n key_of_smallest_value = key\n end\n end\n if name_hash.size == 0\n key_of_smallest_value = nil\n end\n key_of_smallest_value\nend",
"def key_for_min_value(name_hash)\n smallest_value = Float::INFINITY\n key_for_smallest_val = nil\n name_hash.each do |key, value|\n if smallest_value > value\n smallest_value = value\n key_for_smallest_val = key\n end \n end \n key_for_smallest_val\nend",
"def key_for_min_value(name_hash)\n minKey = nil\n minVal = 2 ** (64 - 2) - 1\n name_hash.each {|key, value|\n if value < minVal\n minVal = value\n minKey = key\n end}\n minKey\nend",
"def key_for_min_value(name_hash)\n if name_hash == {}\n return nil\n end\n lowest_number = nil\n name_hash.collect do |name, value|\n if lowest_number == nil\n lowest_number = value\n elsif lowest_number > value\n lowest_number = value\n end\n end\n \n name_hash.each do |name, value|\n if lowest_number == value\n return name\n end\n end\nend",
"def key_for_min_value(hash)\n min_value = hash.values.min\n keys = hash.collect do |key, num|\n \tkey if num == min_value\n end\n keys\nend",
"def key_for_min_value(name_hash)\n lowest_value = nil\n key_value = nil\n name_hash.collect do |name, number|\n if lowest_value == nil || number < lowest_value\n lowest_value = number\n key_value = name\n end\n end\n key_value\nend",
"def key_for_min_value(name_hash)\n smallest_value = 1/0.0\n key_of_smallest_value = nil\n name_hash.each do |key, value|\n if smallest_value > value\n key_of_smallest_value = key\n smallest_value = value\n end\n end\n return key_of_smallest_value\nend"
] | [
"0.8821222",
"0.8777674",
"0.87769854",
"0.8745862",
"0.8689437",
"0.86553806",
"0.865241",
"0.86165065",
"0.8587693",
"0.8572328",
"0.85674095",
"0.8550907",
"0.8529734",
"0.8529734",
"0.85182345",
"0.84936565",
"0.8475531",
"0.8475531",
"0.8466132",
"0.8449126",
"0.84490585",
"0.84359556",
"0.84328413",
"0.8430745",
"0.8428166",
"0.84090126",
"0.8388222",
"0.83684903",
"0.83568215",
"0.83524764",
"0.8345625",
"0.8343887",
"0.8328773",
"0.83284044",
"0.83269894",
"0.83253354",
"0.83201903",
"0.83164364",
"0.8312503",
"0.8312319",
"0.8304851",
"0.83014053",
"0.83008987",
"0.82917446",
"0.8288315",
"0.82870966",
"0.8274123",
"0.82674986",
"0.8267187",
"0.82527804",
"0.8250538",
"0.82443976",
"0.82439804",
"0.8243696",
"0.82416916",
"0.8240566",
"0.823854",
"0.82375354",
"0.82283455",
"0.82274485",
"0.82205135",
"0.82190055",
"0.82136935",
"0.82136935",
"0.82102376",
"0.82101446",
"0.82060164",
"0.8200657",
"0.81985617",
"0.81966525",
"0.81958514",
"0.81932545",
"0.81874573",
"0.8186549",
"0.8185174",
"0.8183619",
"0.8183068",
"0.8182941",
"0.8179895",
"0.8173536",
"0.81732464",
"0.8172825",
"0.81721044",
"0.8171692",
"0.81681263",
"0.8165602",
"0.81609225",
"0.8160289",
"0.81587887",
"0.815757",
"0.8154019",
"0.81534094",
"0.8152752",
"0.81524456",
"0.8151455",
"0.81511825",
"0.8151019",
"0.8146792",
"0.814368",
"0.8142542",
"0.81412685"
] | 0.0 | -1 |
Takes a range and yields pairs of [value, valid?] | def test_range(r)
yield [r.min-1, false]
yield [r.min, true]
yield [r.max, true]
yield [r.max+1, false]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?(range)\n range[0] < range[1]\nend",
"def check_range(rng)\n new(rng).results\n end",
"def valid_result_range\n self.result && self.result > -2 ? true : false\n end",
"def verify_range(value)\n a = (20...30) === value\n if a != true\n puts \"#{value} is not in range of 20 to 30\"\n else\n puts \"#{value} is in range of to 20 to 30\"\n end\nend",
"def validate_range(value)\n classname = value.class.to_s\n case classname\n when \"Range\" \n then value\n when \"Array\"\n then value\n else\n return (value..value)\n end\n end",
"def test_ranges\r\n assert_equal(@range.begin.to_f, @p2.to_f)\r\n assert(@range.cover?(@p5))\r\n assert(@range.end == @p8)\r\n assert(@range2.exclude_end?)\r\n assert_false(@range.exclude_end?)\r\n assert(@range.include?(@p3))\r\n assert(@range.max == @p8)\r\n assert(@range2.max == @p7)\r\n assert(@range.last(3) == [@p6, @p7, @p8])\r\n assert(@range.size == nil)\r\n end",
"def valid?(value)\n return value >= 0 && value <= 19\n end",
"def solve(range)\n valid_passwords = range.filter do |n|\n never_decrease?(n) && any_adj_group(n) { |grp| yield grp }\n end\n valid_passwords.count\nend",
"def valid_range?\n (0..@max_num).cover?(@number)\n end",
"def check_range(name, range, value, unit = '')\n grace = (-0.00001..0.00001)\n str = value.to_s\n value = value.value if value.is_a?(Sass::Script::Value::Number)\n return value if range.include?(value)\n return range.first if grace.include?(value - range.first)\n return range.last if grace.include?(value - range.last)\n raise ArgumentError.new(\n \"#{name} #{str} must be between #{range.first}#{unit} and #{range.last}#{unit}\")\n end",
"def validate_discount_range_values\n curr_val = curr_per = 0\n first = true\n discount_values.each do |val, per|\n if per > 100\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.invalid_range_percentage\"))\n break\n end\n unless first\n if val <= curr_val or per <= curr_per\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.invalid_range_secuence\"))\n break\n end\n end\n first = false\n curr_val, curr_per = val, per\n end\n end",
"def validate_range(address_arr)\n address_arr.all? do |number|\n number.to_i <= 255 && number.to_i >= 0\n end\nend",
"def validate_range(address_arr)\n address_arr.all? do |number|\n number.to_i <= 255 && number.to_i >= 0\n end\nend",
"def range\n unless value.is_a? Range\n errors.add(:value, :range)\n end\n end",
"def valid?\n return false if @range_start_index.nil?\n return false if @range_end_index.nil?\n true\n end",
"def parse_range\n val = super || return\n val.begin == val.end ? val.begin : val\n end",
"def only_evens range\n range.select do |value|\n value.even?\n end\nend",
"def only_evens range\n range.select do |value|\n value.even?\n end\nend",
"def run(lower, upper, validator)\n count = 0\n current_value = lower - 1\n\n # Each iteration, we skip to the next valid number in range and check whether\n # it satisfies the validator.\n while (current_value = step(current_value)) <= upper\n count += 1 if validator.call(current_value)\n end\n\n count\nend",
"def between(min, max, &block)\n return false unless (1..min).all? { try(&block) }\n (min..max).all? { try(&block) } # only using all?'s shortcut property\n true\n end",
"def in_range(a, b)\n return ((a >= 20 && a <= 30) || (b >= 20 && b <= 30));\t\nend",
"def match_range(range, match); end",
"def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end",
"def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end",
"def if_range(node); end",
"def in_range(lower, upper)\n Proc.new { |answer|\n answer.between?(lower, upper) ? range_answer = answer : range_answer = nil\n [range_answer, \"#{answer} must be between #{lower} and #{upper}.\"]\n }\nend",
"def should_ensure_value_in_range(attribute, range, opts = {})\n message, low_message, high_message = get_options!([opts],\n :message,\n :low_message,\n :high_message)\n matcher = ensure_inclusion_of(attribute).\n in_range(range).\n with_message(message).\n with_low_message(low_message).\n with_high_message(high_message)\n should matcher.description do\n assert_accepts matcher, subject\n end\n end",
"def is_a_3_dot_range?(range)\n a = range.first\n b = range.last\n range != (a..b)\nend",
"def restrict(value, range)\n [[value, range.first].max, range.last].min\n end",
"def prime_range(lower_bound, higher_bound)\n Prime.each(higher_bound).select {|prime| prime >= lower_bound}\nend",
"def included?(range, number)\n if range.exclude_end?\n number >= range.begin && number < range.end\n else\n number >= range.begin && number <= range.end\n end\nend",
"def ranges\n pairs.map { |b, e| (b...e) }\n end",
"def range(range)\n opts[:min] = range.begin\n opts[:max] = range.end\n end",
"def assert_within_range reclist, att, min, max\n values = get_values reclist, att\n values.delete_if{|x,y| y.nil?}\n if values.values.length == 0\n log_v \"All values nil for #{reclist[0].class.name}'s #{att} attribute\"\n return\n end\n outliers = values.reject{|k,v| (v >= min and v <= max) }\n sorted_values = values.values.sort\n if outliers.size > 0\n announce 'INVALID DATA:'\n announce \"#{outliers.size} invalid #{att}s.\"\n announce \"Outliers: #{outliers.collect{|x,y| x}*', '}\" if outliers.size < 10\n if sorted_values.first < min\n lowest = sorted_values.first\n temp = sorted_values.reject{|x| x > lowest}.count\n temp2 = sorted_values.reject{|x| x >= min}.count\n announce \"Smallest #{att} below min: #{lowest}. # records w/ this value: #{temp}\" \n announce \" # records below min : #{temp2}\" \n end\n if sorted_values.last > max \n highest = sorted_values.last\n temp = sorted_values.reject{|x| x < highest}.count\n temp2 = sorted_values.reject{|x| x <= max}.count\n announce \"Largest #{att} above max: #{highest}. # records w/ this value: #{temp}\" \n announce \" # records above max: #{temp2}\"\n end\n announce '------'\n else \n announce \"Valid data for #{att}!\\n ----- \"\n end\n end",
"def to_range\n min .. max\n end",
"def parse_allowed_value_range(state_variable)\n range = state_variable.at 'allowedValueRange'\n\n return nil unless range\n\n minimum = range.at 'minimum'\n maximum = range.at 'maximum'\n step = range.at 'step'\n\n range = [minimum, maximum]\n range << step if step\n\n range.map do |value|\n value = value.text\n value =~ /\\./ ? Float(value) : Integer(value)\n end\n end",
"def validate_range(key, value, enum_values)\n values = value.instance_of?(Array) ? value : [value]\n values.each do |v|\n add_templated_error(key, \"'#{v}' is not a valid setting for '#{template.name_for(key)}'\") unless enum_values.include?(v)\n end\n end",
"def breakable_range; end",
"def meets?(*args)\n other = coerce_range(*args)\n self.begin == other.end or other.begin == self.end\n end",
"def values_between? a, b\n is_ok = self.start_value.between?(a,b)\n \n if is_ok\n self.value_changes.each do |offset, setting|\n setting.value.between?(a,b)\n end\n end\n return is_ok\n end",
"def check_range(a,b)\n if (20..30).include?(a)\n puts \"a is in the range (20..30).\"\n else\n puts \"a is not in the range (20..30).\"\n end\n if (20..30).include?(b)\n puts \"b is in the range (20..30).\"\n else\n puts \"b is not in the range (20..30).\"\n end\nend",
"def is_a_3_dot_range?(range)\n\trange.exclude_end?\nend",
"def range(range)\n assert_range range\n schema do |s|\n s.type range.begin.is_a?(Integer) ? 'integer' : 'number'\n s.minimum range.begin\n s.maximum range.end, exclusive: range.exclude_end? unless range.end.nil?\n end\n end",
"def validate(spec)\n range = spec['range']\n match_delta(range, node.transform) ? true : false\n end",
"def test_bounds(val, min, max)\n val >= min && val <= max\n end",
"def test_Range_InstanceMethods_compare\n\t\tassert_equal(true, (1..3) == Range.new(1,3))\n\t\tassert_equal(false, (1..3) == (2..4))\n\tend",
"def range?(eloras, die)\n validity = true # default range, 0..*\n if die\n if die.range\n # divide and count eloras by parent groups\n parent_groups = Hash.new(0)\n eloras.each do |elora|\n case elora\n when REXML::Attribute\n parent_groups[elora.element] += 1\n when REXML::Element\n parent_groups[elora.parent] += 1\n end\n end\n parent_groups.each do |parent, tally|\n if not die.range === tally\n validity = false\n error = \"RANGE #{tally} ##{die.range}#\"\n @errors << [die.namespace, die.xpath, error]\n end\n end\n end\n end\n return validity\n end",
"def range\n min, max = span\n min..max\n end",
"def find_possible_passwords(range:)\n min = range.split('-')[0].to_i\n max = range.split('-')[1].to_i\n\n valid_passwords = (min..max).map do |possible_password|\n # eg 103_080 => [1, 0, 3, 0, 8, 0]\n digits_array = possible_password.to_s.split('').map(&:to_i)\n\n # Six-digit numbers only\n next if digits_array.length != 6\n\n # Must be in ascending order\n next if digits_array.sort != digits_array\n\n # Special filtering specific to each part of the puzzle\n next if !yield(digits_array)\n\n # Found one!\n possible_password\n end.compact\n\n valid_passwords\nend",
"def map_values\n @data.each do |code,value|\n fit = false\n @ranges.each do |r|\n if value.between?(r[:range][0],r[:range][1])\n self.paint_country(code,r[:color])\n fit = true\n break\n end\n end\n raise \"Unexpected error! Value #{value} doesn't fit in any range!\" unless fit\n end\n end",
"def range\n @from..@to\n end",
"def normalize_range_values(params, field_name, values)\n normalized = Array(values).map(&:presence).compact\n params[field_name] = (normalized.present? && values.length == 2) && (values.first...values.last) || nil\n end",
"def range(input); end",
"def range; end",
"def range; end",
"def range; end",
"def is_effective?(value)\n @range_lower <= value && value <= @range_upper\n end",
"def _reduce_518(val, _values, result)\n result = @builder.range_inclusive(val[0], val[1], val[2])\n \n result\nend",
"def value_in_range(range)\n case range.first\n when Integer then number_in_range(range)\n when Time then time_in_range(range)\n when Date then date_in_range(range)\n else range.to_a.rand\n end\n end",
"def in_range(a, b, c)\n return ((a >= 1 && a <= 10) || (b >= 1 && b <= 10) || (c >= 1 && c <= 10));\t\nend",
"def out_of_range?\n value < 1 || value > 12\n end",
"def query_user_for_date_range\n start_date, end_date = nil\n\n # untill we have both dates\n until start_date && end_date\n puts \"\\nFirst, we need a start date:\"\n start_date = query_user_for_date\n\n puts \"\\nNext, we need an end date:\"\n end_date = query_user_for_date\n\n if !date_range_valid?(start_date, end_date)\n puts \"Let's start again!\"\n start_date = end_date = nil\n end\n end\n return start_date, end_date # retunr both values as an array\nend",
"def is_a_3_dot_range?(range)\n range.exclude_end?\nend",
"def check_range(a)\n answer = case \n when (0 < a) && (a<= 50)\n \"Number is between 0 to 50\"\n when (51 < a) && (a <= 100)\n \"Number is between 51 to 100\"\n when (100 < a )\n \"Number is above 100\" \n else\n \"invalid\" \n end\n answer\nend",
"def validate_range(attribute_name, options = {})\n value = send(attribute_name)\n\n return unless value\n\n min = options.fetch(:min, nil)\n max = options.fetch(:max, nil)\n append_error(attribute_name, options.fetch(:min_message, nil) || :less_than_min) if min && value < min\n append_error(attribute_name, options.fetch(:max_message, nil) || :greater_than_max) if max && value > max\n end",
"def test_single_value\n x = IntegerRange.new(42)\n\n assert_equal(x.bottom, 42)\n assert_equal(x.top, 42)\n assert_equal(x.to_a, (42..42).to_a)\n\n a = each_to_a(x)\n\n assert_equal(a, (42..42).to_a)\n end",
"def get_range(range)\n r = []\n enum = range.to_enum\n begin\n while (x = enum.next) < @size\n r << get_single_key(x)\n end\n rescue StopIteration\n end\n r.empty? ? nil : r\n end",
"def in_range?(val, range)\n return true unless range\n\n if range.is_a?(Hash)\n result = true\n result &= ( val < range[:before] ) if range[:before]\n result &= ( val > range[:after] ) if range[:after]\n result &= ( val <= range[:max] ) if range[:max]\n result &= ( val >= range[:min] ) if range[:min]\n result &= ( val < range[:less_than] ) if range[:less_than]\n result &= ( val <= range[:less_than_or_equal_to] ) if range[:less_than_or_equal_to]\n result &= ( val > range[:greater_than] ) if range[:greater_than]\n result &= ( val >= range[:greater_than_or_equal_to] ) if range[:greater_than_or_equal_to]\n result\n else\n range = [range] unless range.respond_to?(:include?)\n range.include?(val)\n end\n end",
"def all_in_ranges?(nums, ranges)\n if nums.empty?\n return false\n end\n nums.each do |num|\n if !in_ranges?(num, ranges)\n return false\n end\n end\n true\nend",
"def search_range(array, range=nil, &block)\n lower = search_lower_boundary(array, range, &block)\n upper = search_upper_boundary(array, range, &block)\n return lower ... upper\n end",
"def maps_for_range(range)\n last = (range.exclude_end?) ? range.last : range.last + 1\n maps.select { |m| m.start_addr >= range.first and m.max < last }\n end",
"def odd_range(min, max)\n (min..max).select{|num| !(num.even?) }\nend",
"def within(range: 1.00..5000.00)\n between(from: range.min, to: range.max)\n end",
"def split_range(range)\n start, finish = range.begin, range.end\n start += length if start < 0\n finish += length if finish < 0\n \n [start, finish - start - (range.exclude_end? ? 1 : 0)]\n end",
"def between?(p0, p1) end",
"def expected_range( )\n expected = [ ]\n\n expected << \"above #{@above}\" unless @above.nil?\n expected << \"below #{@below}\" unless @below.nil?\n expected << \"included in #{@in.inspect}\" unless @in.nil?\n\n case expected.size\n when 0 then \"\"\n when 1 then expected.first\n when 2 then expected.join(\" and \")\n else expected[0..-2].join(\", \") + \", and #{expected.last}\"\n end\n end",
"def between?(x,y) end",
"def range(data)\n return (minimum(data)..maximum(data))\n end",
"def _reduce_528(val, _values, result)\n result = @builder.range_inclusive(val[0], val[1], val[2])\n\n result\nend",
"def in_range?\n return self.range.include?([@x, @y])\n end",
"def in_ranges?(num, ranges)\n result = false\n ranges.each do |range|\n if range.include?(num)\n result = true\n end\n end\n return result\nend",
"def attributes_are_range(attributes)\n raise \"Validation of time range must be defined by 2 attributes\" unless attributes.size == 2\n end",
"def bsearch_range(range = 0...length, &block)\n lower = bsearch_lower_boundary(range, &block)\n upper = bsearch_upper_boundary(range, &block)\n lower...upper\n end",
"def between?(min, max)\n #This is a stub, used for indexing\n end",
"def value_to_range(value)\n case value.to_s\n when /\\A(\\-?\\d+)\\z/\n Range.new($1.to_i, $1.to_i)\n when /\\A(-?\\d+?)(\\.\\.\\.?|-|,)(-?\\d+)\\z/\n Range.new($1.to_i, $3.to_i, $2 == '...')\n else\n if @slop.strict?\n raise InvalidArgumentError, \"#{value} could not be coerced into Range\"\n else\n value\n end\n end\n end",
"def size_range(range)\n return [1,1] if range.nil?\n from = range.from\n to = range.to\n x = from.nil? ? 1 : from\n y = to.nil? ? TheInfinity : to\n [x, y]\n end",
"def availability(room_number, end_date, start_date)\n\n @reservations.each do |reservation|\n\n # i am trying to look throught all the reservation instances and\n # see what dates are available to reserve a reservation.\n\n if room_number == reservation.room_number && reservation.does_overlap(end_date,start_date)\n\n # if reservation.start_date == start_date && reservation.end_date == end_date\n # return false\n # elsif reservation.start_date > start_date && reservation.start_date < end_date\n # next #true\n # elsif reservation.start_date < start_date && reservation.start_date < end_date\n # next #true\n # elsif reservation.start_date > start_date && reservation.start_date > end_date\n # next #false , i think i need only\n # else\n # end\n\n\n\n\n\n end\n\n end\nend",
"def range(c_begin, c_end, alphabet = DEFAULT_ALPHABET)\n any((c_begin..c_end).to_a, alphabet)\n end",
"def _reduce_516(val, _values, result)\n result = @builder.range_inclusive(val[0], val[1], val[2])\n \n result\nend",
"def check_range(x, y)\n !(x < 1 || y < 1 || x > width || y > height)\n end",
"def number_range2 (number)\n\t \tcase number\n\t\twhen 0..50\n\t\tputs \"your number is between 0 and 50\"\n\t\twhen 51..100\n\t\tputs \"your number is between 51 and 100\"\n\t\telse\n\t\t\tif number < 0\n\t\t\t\tputs \"can't enter a negative number\"\n\t\t\telsif number > 100\n\t\t\t\tputs \"over 100\"\n\t\t\tend\n\t\tend\n\tend",
"def test_Range_InstanceMethods_eql?\n\t\tassert_equal(true , (1..10).eql?(Range.new(1,10)))\n\t\tassert_equal(false, (1..10).eql?([1..10]))\n\tend",
"def valid_tickets\n @nearby_tickets.filter_map do |ticket|\n in_ranges = ticket.map do |val|\n merged_rules.map {|val_range| val_range.include?(val)}.include?(true)\n end\n ticket unless in_ranges.include?(false)\n end\n end",
"def test_raw_range_1\r\n r = GerbilCharts::Models::RawRange.new\r\n\r\n \t[10,20,10,0,0,1001,19920,882991.22].each do |v|\r\n\t\tr.update v\r\n\tend\r\n\r\n\tr.min_max do |mn,mx|\r\n \tassert mn==0\r\n\t\tassert mx==882991.22\r\n\tend\r\n end",
"def acceptable_years_in_school\n Array(min_year_in_school..max_year_in_school)\n end",
"def range(start_num, end_num)\n # one line version\n # (start_num...end_num).to_a\n\n # version 2\n exclusive_range = []\n (start_num...end_num).each do |num|\n exclusive_range << num\n end\n exclusive_range\nend",
"def bsearch_range (range = 0 ... self.length, &block)\r\n lower = bsearch_lower_boundary(range, &block)\r\n upper = bsearch_upper_boundary(range, &block)\r\n return lower ... upper\r\n end",
"def _reduce_523(val, _values, result)\n result = @builder.range_inclusive(nil, val[0], val[1])\n \n result\nend",
"def valid_intervals\n VALID[:interval]\n end",
"def check_bounds(value)\n return value >= self.bound.lower_bound && value <= self.bound.upper_bound\n end"
] | [
"0.7365275",
"0.6794344",
"0.67521155",
"0.6719763",
"0.66497636",
"0.6432021",
"0.64070433",
"0.6315455",
"0.6294037",
"0.6239495",
"0.61764205",
"0.6081809",
"0.6081809",
"0.6062867",
"0.6060753",
"0.6056744",
"0.60563254",
"0.60561895",
"0.60397905",
"0.60256296",
"0.60225934",
"0.6021621",
"0.60164577",
"0.60164577",
"0.5972782",
"0.59714764",
"0.5970186",
"0.59683466",
"0.59416884",
"0.5938821",
"0.5933623",
"0.5930172",
"0.59252816",
"0.59209263",
"0.59036785",
"0.58734494",
"0.58666205",
"0.5838547",
"0.58135134",
"0.58054805",
"0.579467",
"0.5779856",
"0.577789",
"0.5773664",
"0.57621044",
"0.57595605",
"0.57547593",
"0.5741574",
"0.57409775",
"0.5735944",
"0.57295996",
"0.5728965",
"0.5726489",
"0.5720774",
"0.5720774",
"0.5720774",
"0.57146275",
"0.5702109",
"0.5695797",
"0.56897455",
"0.56866366",
"0.5683652",
"0.5683011",
"0.5666819",
"0.56603426",
"0.5657015",
"0.56556123",
"0.56491375",
"0.5648385",
"0.5627311",
"0.562313",
"0.5618324",
"0.5617448",
"0.5614005",
"0.56086314",
"0.5603612",
"0.55964977",
"0.5593422",
"0.5582427",
"0.5576672",
"0.5564002",
"0.55596423",
"0.55584836",
"0.5557245",
"0.5557147",
"0.55548304",
"0.55455387",
"0.55438316",
"0.5539751",
"0.5536304",
"0.5527547",
"0.55216867",
"0.55155",
"0.5504543",
"0.5499889",
"0.5493014",
"0.54924685",
"0.5489461",
"0.54843354",
"0.5482606"
] | 0.7384472 | 0 |
Replace this with your real tests. | def setup
@task_submission = Factory.build(:task_submission)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testing\n # ...\n end",
"def __dummy_test__\n end",
"def tests; end",
"def tests; end",
"def spec; end",
"def spec; end",
"def self_test; end",
"def self_test; end",
"def test \n end",
"def test_0_dummy\n\t\tend",
"def test\n\n end",
"def test\n end",
"def test\n end",
"def test\n end",
"def private; 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 test_method\n end",
"def before_test(test); end",
"def before_test(test); end",
"def graffiti_test\n end",
"def test_truth\n end",
"def test_should_get_index \n get :index\n assert_response :success #making sure the request was successful\n assert_not_nil (:products) # ensuring that it assigns a valid products instance variable.\n end",
"def test_case; end",
"def test_cases; end",
"def running_test_case; end",
"def test_connection\n end",
"def testloop\n \n end",
"def should; super end",
"def test_nothing\n end",
"def default_test\r\n end",
"def my_tests\n end",
"def test_setup\r\n \r\n end",
"def test_intialize\r\n\tassert_equal 0, @test_prospector.current_gold\r\n\tassert_equal 0, @test_prospector.current_silver\r\n\tassert_equal 0, @test_prospector.total_gold\r\n\tassert_equal 0, @test_prospector.total_silver\r\n\tassert_equal 0, @test_prospector.move_count\r\n\tassert_nil @test_prospector.previous_location\r\n\tassert_equal 0, @test_prospector.num_days\r\n\tassert_equal 'Sutter Creek', @test_prospector.current_location\r\n end",
"def testing_end\n end",
"def test_next_song\n \n \n assert true\n end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def assertions; end",
"def assertions; end",
"def test_hack\n assert(true)\n end",
"def setup\n\n end",
"def setup\n\n end",
"def setup\n\n end",
"def test_attributes\n assert_equal \"Gallery 1\", @gallery.title\n assert @gallery.active?\n assert_equal \"f82dd0bd-4711-4578-ac47-4661257e69a6\", @gallery.guid\n end",
"def teardown; end",
"def teardown; end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def before_assert\n end",
"def test_fake_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.fake_rubies_found(7)\n\t\ttest_main.fake_rubies_found(7)\n\t\tassert test_main.num_fake_rubies, 14\n\tend",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def test_entry\n raise \"Implement this method in your test class\"\n end",
"def tests_song_not_found\n assert_equal =\n end\n\nend",
"def test_playlist\n end",
"def test_listchunk_attributes\n\t\t\n\tend",
"def love_test\nend",
"def test_entry_attrs\n raise \"Implement this method in your test class\"\n end",
"def test_truth\n assert true\n end",
"def stest_method_1(test); end",
"def teardown\r\n end",
"def default_test\n end",
"def test_037\n\n login\n\n #Create some PUs\n\n for i in 0..2\n create_pu('sample_pu'+i.to_s)\n end\n\n pus = Pu.find_all_by_name('sample_pu1')\n pu = pus.last\n pu.created_at =\"2009-05-08 11:30:50\"\n pu.save\n pus = Pu.find_all_by_name('sample_pu2')\n pu = pus.last\n pu.created_at =\"2008-05-08 14:30:50\"\n pu.save\n @@year = \"2009\"\n @@hour = \"14\"\n\n # Open PU management page\n open_pu_management_page_1\n\n # Arbitrary filtering is performed to PU name.\n assert_equal _(\"PU name\"), get_selected_label(\"find_box\")\n\n\n # you have no relevance\n filtering('3')\n assert !is_text_present('sample_pu1')\n assert !is_text_present('sample_pu2')\n assert is_text_present(_('A PU does not exist.'))\n sleep 2\n\n # Delete created data\n @@pu= Pu.find_by_name('sample_pu1')\n @@pu2= Pu.find_by_name('sample_pu2')\n @@pu.destroy\n @@pu2.destroy\n logout\n end",
"def run_fe_tests\n end",
"def after_test(_test); end",
"def after_test(_test); end",
"def after_test(_test); end",
"def setup; end",
"def tests=(_arg0); end",
"def tests=(_arg0); end",
"def test_truth\n april = riders(:rider_1)\n assert_equal \"April Jones\", april.name\n trigger = horses(:horse_1)\n assert_equal \"Trigger\", trigger.name\n event2 = events(:event_2)\n assert_equal \"5 Horse Scramble\", event2.name\n \n end",
"def test_BooksForAnAuthor\n loginRegisterBazzarVoice\n writeReview \n assert true \n end"
] | [
"0.7446459",
"0.6956364",
"0.69155836",
"0.69155836",
"0.6864151",
"0.6864151",
"0.66406286",
"0.66406286",
"0.66253287",
"0.6547665",
"0.6524571",
"0.6484549",
"0.6484549",
"0.6484549",
"0.6403847",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6389188",
"0.6385941",
"0.6354074",
"0.6354074",
"0.6350063",
"0.6317573",
"0.6271346",
"0.62341285",
"0.6210424",
"0.6183045",
"0.61626923",
"0.61574936",
"0.6137384",
"0.61362237",
"0.61194503",
"0.611745",
"0.61087",
"0.6098303",
"0.606717",
"0.6058555",
"0.6057699",
"0.6057699",
"0.6057699",
"0.6057699",
"0.6045397",
"0.6045397",
"0.6029009",
"0.60160005",
"0.60160005",
"0.60160005",
"0.6014079",
"0.5998994",
"0.5998994",
"0.5991374",
"0.5991374",
"0.5991374",
"0.5991374",
"0.5991374",
"0.5991374",
"0.5991374",
"0.5989936",
"0.59822077",
"0.59556234",
"0.59556234",
"0.59556234",
"0.59556234",
"0.59556234",
"0.59556234",
"0.5950605",
"0.59497803",
"0.5943133",
"0.59424186",
"0.5932352",
"0.59296894",
"0.5929659",
"0.5917424",
"0.59144044",
"0.5913393",
"0.5905494",
"0.5899468",
"0.58910733",
"0.58910733",
"0.58910733",
"0.5889112",
"0.5883961",
"0.5883961",
"0.5880121",
"0.5877717"
] | 0.0 | -1 |
check if student already applied this semester | def verify_unique_semester_application(current_applicant)
return true unless current_applicant.external_applied_for?(@settings.current_semester)
redirect_to students_apply_path, flash: { error: t('student_applications.create.resubmit') }
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isValidSemester?(semester)\n\t\tSEMESTERS.include? semester\n\tend",
"def student_team_already_existing\n return false if self.student.nil? || self.team.nil?\n if student_id_changed? || team_id_changed?\n assignment = StudentTeam.for_team(self.team).for_student(self.student)\n errors.add(:student_team,\"assignment already exists\") if !assignment.empty?\n end\n end",
"def verify_unique_semester_application(current_applicant)\n return true unless current_applicant.applied_for?(@settings.current_semester)\n redirect_to students_apply_path, flash: { error: t('student_applications.create.resubmit') }\n false\n end",
"def only_one_id_per_semester\n if current_step == 'id_and_semester' && !persisted? && semester\n if Prospect.joins(:enumerations).exists?(suppressed: false, directory_id: directory_id, enumerations: { id: semester.id })\n errors.add(:semester, \"Please note that this directory ID has already submitted an application. You are only allowed one application submission per semester. If you need to edit your submission please contact Lisa Warner at <a href='tel:3014059245'>301-405-9245</a> or <a href='mailto:lwarner@umd.edu'>lwarner@umd.edu</a> for assistance.\".html_safe)\n end\n end\n end",
"def coaches_student?(student)\n\t\tstudents.include?(student)\n\tend",
"def enrolled? (student)\n @students.include?(student) # returns true or false on array existence\n end",
"def check_for_students\n # TODO: set a message.\n # TODO: handle on a per section basis?\n if (!Student.exists?)\n # First we need students, so when the students table is empty\n # go to the import page.\n redirect_to students_path\n end\n end",
"def student?\n false\n end",
"def student_exist?(name)\t \n\t @directory_students.any? {|student| students_equal(student,name)}\n\tend",
"def this_semester?\n\t\topens = self.open_date\n\t\ttoday = Time.now\n\t\t\n\t\t# TODO: rewrite into a range so it's a bit cleaner\n\t\tif(opens.month > 7 && today.month > 7 && today.year == opens.year)\n\t\t\ttrue\n\t\telsif(opens.month <= 7 && today.month <= 7 && today.year == opens.year)\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def subscribing?(course)\n student? && current_user.subscribing?(course)\n end",
"def student?\n roles.where(name: Ability.student_group_name).exists?\n end",
"def has_students?\n !students.empty?\n end",
"def has_students?\n !students.empty?\n end",
"def this_semester?\n\t\topens = self.showtimes.first.timestamp\n\t\ttoday = Time.now\n\t\t\n\t\t# TODO: rewrite into a range so it's a bit cleaner\n\t\tif(opens.month > 7 && today.month > 7 && today.year == opens.year)\n\t\t\ttrue\n\t\telsif(opens.month <= 7 && today.month <= 7 && today.year == opens.year)\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def logged_in_as_student?\n !current_student.nil?\n end",
"def is_current?\r\n @is_current ||= self.semester.is_current?\r\n end",
"def student?\n return self.eduPersonAffiliation==\"student\"\n end",
"def student_team_requirements_met?\n # checks if the student has a team\n return false if @student.team.nil?\n # checks that the student's team has a topic\n return false if @student.team.topic.nil?\n\n # checks that the student has selected some topics\n @student.assignment.topics?\n end",
"def non_student?\n !self.has_role?('student')\n end",
"def tutor_check?(academic_session, student_id)\n \tcurrent_user.is_student_tutor?(academic_session, student_id)\n end",
"def student?\n @student = true if session[:role_name] == 'Student'\n end",
"def student?\n if self.role and self.role == 4 \n true\n end\n end",
"def student?\n student_id?\n end",
"def is_student?\n self.role==\"student\"\n end",
"def is_student?\n student.nil?\n end",
"def student_only?(sfuid)\n result = roles sfuid\n if result.join(\"\").eql? \"undergrad\"\n return true\n end\n false\n end",
"def enroll(student)\n if @students.count < @student_capacity\n students << student\n return true\n end\n return false\n end",
"def can_student_submit?(student)\n released_for_student?(student) && !deadline_passed_for?(student)\n end",
"def user_already_enrolled?\n if @course.multiple_roles_allowed?\n CoursesUsers.exists?(user_id: @user.id, course_id: @course.id, role: @role)\n else\n CoursesUsers.exists?(user_id: @user.id, course_id: @course.id)\n end\n end",
"def student_logged_in?\n !current_student.nil?\n end",
"def student?\n self.role == \"student\"\n end",
"def check_must_be_student_restriction\n if @offering.allow_students_only?\n @restriction = MustBeStudentRestriction.new(:offering_id => @offering.id)\n render :action => \"restricted\" and return unless @restriction.allows?(@user_application)\n end\n if !@user_application.person.is_a?(Student) && @offering.require_invitation_codes_from_non_students?\n redirect_to :action => \"enter_code\" and return if @user_application.offering_invitation_code.nil?\n end\n end",
"def periods_in_school\n if periods.map(&:school_id).any?{|id| id != school_id }\n errors.add(:periods, 'must be in the same school as the student')\n end\n end",
"def rollcall_student_required\n if current_user.is_rollcall_epi? || current_user.is_rollcall_health_officer? || current_user.is_rollcall_nurse? ||\n current_user.is_rollcall_admin?\n return true\n else\n redirect_to :action => \"unauthorized\", :controller => 'rollcall/rollcall_app'\n return false\n end\n end",
"def has_course?(course_id)\n semesters.collect do |semester|\n if semester.cis_courses.exists?(course_id)\n return true\n end \n end\n \n return course_bin.cis_courses.exists?(course_id)\n end",
"def student?\n return true if student\n\n student_email?(email)\n end",
"def schools_valid?\n valid = true\n self.schools.each do |school|\n unless school.qualifications_valid?\n self.errors.add(:school, \"'#{school.name}' does not have any qualifications\")\n valid = false\n end\n end\n valid\n end",
"def check_student\n if !current_student\n redirect_to :root, notice: \"You are not logged in as student\"\n end \n end",
"def enrolled_in?(course)\n\t self.courses.include?(course)\n end",
"def all_students?\n @options[:all_students].present?\n end",
"def senior?\n\t\tgrade == 12\n\tend",
"def transfer_student?\n return nil if admission_applications.empty?\n admission_applications.first.transfer_applicant?\n end",
"def can_create_course?\n ptainstructors = Ptainstructor.find_by_semester_id(self.id)\n teachers = Teacher.find_by_semester_id(self.id)\n if ((ptainstructors == nil) or (teachers == nil))\n return false\n end\n return true\n end",
"def coach?\n students.any?\n end",
"def semester\n time = time_from_enrollment\n @semester = time.div(1.year / 2) + 1\n @semester = 1 if @semester <= 0\n return @semester\n end",
"def is_authorized_for_student(student)\n return true if self.districtwide_access?\n\n return false if self.restricted_to_sped_students && !(student.program_assigned.in? ['Sp Ed', 'SEIP'])\n return false if self.restricted_to_english_language_learners && student.limited_english_proficiency == 'Fluent'\n return false if self.school.present? && self.school != student.school\n\n return true if self.schoolwide_access? || self.admin? # Schoolwide admin\n return true if self.has_access_to_grade_levels? && student.grade.in?(self.grade_level_access) # Grade level access\n return true if student.in?(self.students) # Homeroom level access\n false\n end",
"def is_relevant_for_educator?\n supported_schools.any? {|school| authorized_grade_levels(school.id).size > 0 }\n end",
"def add_students\n @course = Course.find(params[:id])\n to_add = params[:to_be_added]\n if to_add\n\t\t\tnot_added = []\n to_add.each do |stu_id, do_it|\n if do_it == \"yes\"\n student = Student.find(stu_id)\n\t\t\t\t\tif not @course.add_student(student)\n\t\t\t\t\t\t not_added << student.name\n\t\t\t\t\tend\n end\n end\n end\n\t\tif not not_added.empty?\n\t\t\tflash[:notice] = \"Students has already joined this course:\" + not_added.join(\",\")\n\t\tend\n\t\tredirect_to students_admin_course_path(@course)\n end",
"def seats_left?\n student_limit == students.count\n end",
"def isAdmissionApproved\n ad = Admission.where(student_id: student_id).first\n #ad = Admission.where(\"student_id = #{student_id}\").order(\"created_on DESC\").find(1)\n unless ad.step == \"Approved\" then\n errors.add(:student_id, \"- You must be approved in order to create a billing record.\")\n end\n end",
"def claimed_for_final_exam?\n claimed_final_application?\n end",
"def is_valid?\n instructor_approved || (non_rejected_student_memberships.size >= assignment.group_min)\n end",
"def check_student\n @@name_path = request.env['PATH_INFO']\n if current_user&.student? and (@@name_path != \"/my_projects\" and @@name_path != \"/\")\n begin\n redirect_to :back, alert: \"You do not have access to that page.\"\n rescue Exception\n redirect_to \"/\", alert: \"You do not have access to that page.\"\n end\n end\n end",
"def check_dups\n\t\t\tCampInstructor.all.each do |e|\n\t\t\t\tif (e.instructor.id == self.instructor_id && e.camp.id == self.camp_id)\n\t\t\t\t\terrors.add(:camp_id, \"camp instrctor obj already exists\")\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn true \n\t\tend",
"def must_be_student\n unless current_user.role.name.eql?('Student')\n flash[:error] = \"Access denied.\"\n redirect_to root_url\n end\n end",
"def can_access_student( student)\n # 2 ways to access all student: admin or access_all flag\n if (is_admin? || current_teacher.access_all_students)\n return true\n end\n\n # last gasp: check roster of accessible students\n find_student = RosterStudent.where( teacher_id: current_teacher.id, student_id: student.id)\n if ! find_student.blank?\n return true\n end\n\n false # nope - teacher cannot access this student's data\n end",
"def duplicate_ptainstructor(oldptainstructor)\n newptainstructor = oldptainstructor.dup\n newptainstructor.semester_id = self.id\n return false unless newptainstructor.save\n return true\n end",
"def current_user_is_student\n if !current_user || current_user.role != 'student'\n head(403)\n end\n end",
"def attended_exam_in? course\n exams.for_course(course).attended.present?\n end",
"def real_student?\n student? && !phantom\n end",
"def reviewed_school?(user)\n self.reviews.exists?(user: user)\n end",
"def same_graduate_course_required\n notfound = false\n gc = @current_user.graduate_courses.find(params[:id]) rescue notfound = true\n unless notfound\n if (!gc)\n flash[:error] = \"Non puoi modificare questo corso di laurea\"\n redirect_to timetables_url\n end\n else\n redirect_to :controller => 'timetables', :action => 'not_found'\n end\n end",
"def is_authorized_for_student?(student)\n begin\n return true if @educator.districtwide_access?\n\n return false if @educator.restricted_to_sped_students && !(student.program_assigned.in? ['Sp Ed', 'SEIP'])\n return false if @educator.restricted_to_english_language_learners && student.limited_english_proficiency == 'Fluent'\n return false if @educator.school_id.present? && student.school_id.present? && @educator.school_id != student.school_id\n\n return true if @educator.schoolwide_access? || @educator.admin? # Schoolwide admin\n return true if @educator.has_access_to_grade_levels? && student.grade.in?(@educator.grade_level_access) # Grade level access\n return true if student.in?(@educator.students) # Homeroom level access\n return true if student.in?(@educator.section_students) # Section level access\n rescue ActiveModel::MissingAttributeError => err\n # We can't do authorization checks on models with `#select` that are missing\n # fields. If this happens, it's probably because the developer is trying to\n # to optimize a query. The authorization layer could only recover by making more\n # queries, so instead we raise and force the developer to figure out how to resolve.\n #\n # See `Authorizer.student_fields_for_authorization` and `Authorizer.educator_field_for_authorization`\n # to see what fields are required on each model.\n raise err\n end\n false\n end",
"def require_current_students_request\n if current_user.student?\n unless current_user.id == @request.user_id\n flash[:danger] = \"You don't have access to that request!\"\n redirect_back(fallback_location: new_request_path)\n end\n end\n end",
"def student?\n return logged_in? && (current_user.class == Student)\n end",
"def check_on_track?\n result = 0\n \n self.accessible_students.each do |student|\n result = student.check_on_track?\n if result == 2\n # Not on-track\n break\n end\n end\n\n return result\n end",
"def passed?\n [\n semester.min_scholarship_index <= scholarship_index,\n community?,\n professional?\n ].count { |p| p == true} >= 2\n end",
"def has_course?(course)\n self.courses.include?(course)\n end",
"def has_course?(course)\n self.courses.include?(course)\n end",
"def is_solved_by_student(student_id)\n\t\treturn Solution.find_by(\n\t\t\t\t\tstudent_id: student_id,\n\t\t\t\t\tproblem_id: self.id,\n\t\t\t\t\tstatus: Solution::STATUS_ACCEPTED) != nil\n\tend",
"def ensure_valid_student_for_class_list!(student_id, workspace_id)\n # Check that the educator is authorized to see the grade and school for this student\n student = Student.find(student_id)\n raise Exceptions::EducatorNotAuthorized unless queries.is_authorized_for_grade_level_now?(student.school_id, student.grade)\n\n # Check that they gave a valid `workspace_id` and that it matches\n # the school and grade level for the student they're asking about.\n class_list = queries.read_authorized_class_list(workspace_id)\n raise Exceptions::EducatorNotAuthorized if class_list.nil?\n raise Exceptions::EducatorNotAuthorized if class_list.school_id != student.school_id\n raise Exceptions::EducatorNotAuthorized if class_list.grade_level_next_year != GradeLevels.new.next(student.grade)\n\n student\n end",
"def requisite_course_taken?(courses, department, level)\n courses.any? do |course|\n course.department == department && course.level.to_s == level\n end\n end",
"def enroll (student)\n if @students.length < @student_capacity\n @students << student # add the student to the array\n return true # the enrollment was successful\n else\n return false # the enrollment was not successful\n end\n end",
"def current_semester\n AcademicCalendar.current_semester()\n end",
"def enrolled_in?(course)\n course.all_enrollees.include?(self)\n end",
"def save_students\n\t\tif @students.blank? \n\t\t\t\t\n\t\telse\n\t\t\t@students.each do |student_id|\n\t\t\t\tHasStudent.create(student_id: student_id, course_id: self.id)\n\t\t\tend\n\t\tend\n\tend",
"def is_work?\n if @status==\"study\"\n puts \"he is a student.\"\n false\n else puts \"he is working\"\n true\n end\n end",
"def can_report?(reporting_user) \n return self.user.schools.detect{|s|\n reporting_user.schools.include?(s)\n }\n end",
"def check_student_limit\n\t\t@classroom = Classroom.where(id: self.classroom_id).first\n\t\tif Student.where(classroom_id: self.classroom_id).count >= @classroom.studentlimit\n\t\t\tself.errors.add(:base, \"Oppss!!! classroom is full\")\n\t\tend\n\tend",
"def is_taking_course?(course, term = nil)\n term ||= Utils::Term::now\n taking_courses.each do |c|\n if c.course == course and c.year == term.year and c.semester == term.semester\n return true\n end\n end\n false\n end",
"def duplicate_student(oldstudent, teachers_cloned)\n newstudent = oldstudent.dup\n newstudent.semester_id = self.id\n newstudent.teacher_id = teachers_cloned[oldstudent.id]\n return false unless newstudent.save\n return true\n end",
"def enrolled_in_which?(courses)\n courses.reject {|course| !self.enrolled_in?(course)}\n end",
"def organization_match\n return false if self.student.nil? || self.team.nil?\n student_org = self.student.organization\n team_org = self.team.organization\n if student_org != team_org\n errors.add(:team, \"organization does not match student's organization\")\n end\n end",
"def same_graduate_course_required\n ids = @current_user.graduate_course_ids\n graduate_course = GraduateCourse.find(:all, :include => {:curriculums => :teachings},\n :conditions => [\"graduate_courses.id IN (?) AND teachings.id = ?\", ids, params[:id]])\n unless graduate_course.size != 0\n flash[:error] = \"Questo insegnamento non appartiene a nessun tuo corso di laurea\"\n redirect_to timetables_url\n end\n end",
"def assigned_course_or_script?\n assigned_courses.any? || any_visible_assigned_scripts?\n end",
"def needs_season_personal_standard_recalculation?()\n need_recalculation = false\n season_personal_standard_collector = @row_collectors[ SeasonPersonalStandard.table_name ]\n if season_personal_standard_collector && season_personal_standard_collector.duplicate_rows.size > 0\n need_recalculation = true\n end\n need_recalculation\n end",
"def active_student_count\n if self.students.present?\n self.students.select { |s| s.sign_in_count > 0 }.size\n else\n 0\n end\n end",
"def student_logged_in?\n @student_logged_in ||= user_signed_in? and cur_student\n end",
"def graduation_required?\n applicant_type == 'grad_student' || applicant_type == 'undergrad_student' ||\n applicant_type == 'school_student'\n end",
"def is_tutoring?\n self.student_requests.where(status: \"active\").exists?\n end",
"def registered?(sport)\n\t\tself.sports.include? sport\n\tend",
"def uniqueness_for_school_and_subject\n school = School.find(school_id)\n school.courses.where(subject_id: subject_id).each do |course|\n if (course.call_number == call_number)\n errors.add(:course, 'course call number already exists')\n return\n elsif (course.friendly_name == friendly_name)\n errors.add(:course, 'course friendly name already exists')\n return\n end\n end\n end",
"def division_grade_consistency\n return false if self.student.nil? || self.team.nil?\n if self.student.junior? && self.team.junior?\n return true\n elsif !self.student.junior? && !self.team.junior? \n return true\n else \n errors.add(:student, \"'s grade is inappropriate for this team\")\n end\n end",
"def required_student\n require_user_type(:student)\n end",
"def set_semester_mark\n @semester_mark = SemesterMark.find(params[:id])\n if not @semester_mark.user_id==current_user.id\n redirect_to root_path\n end\n\n end",
"def save_education\n if self.schools_valid?\n self.current_stage = :employment_stage\n self.save validate: false\n return true\n end\n false\n end",
"def create\n @course = Course.new(course_params)\n @current_semester = Semester.find_by_active(1)\n\n respond_to do |format|\n if Course.where(:name => @course.name).blank?\n puts 'Course doest not exist'\n if @course.save && @current_semester.courses << @course\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 else\n puts @course.name\n puts 'Course exists'\n @existing_course = Course.find_by_name(@course.name)\n if @current_semester.courses << @existing_course\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\n end",
"def admin?\n\tif session[:student_id].nil?\n\t\treturn\n\telse\n signed_in? == true\n\t@current_student == Student.find_by_id(24)\n\tend\nend",
"def permitted_studies_exist\n unless self.study_list.count == self.accession_list.count\n missing = (self.accession_list - self.study_list.pluck(:accession)).join(', ')\n errors.add(:accession_list, \"contains missing studies: #{missing}\")\n end\n end"
] | [
"0.72673243",
"0.70935845",
"0.689772",
"0.6868563",
"0.6817627",
"0.664665",
"0.6544057",
"0.6486318",
"0.6434375",
"0.64167",
"0.6378888",
"0.63492984",
"0.6346527",
"0.6346527",
"0.63438004",
"0.63396454",
"0.6258459",
"0.6231072",
"0.62131965",
"0.6208256",
"0.6169102",
"0.6153555",
"0.6149017",
"0.6140459",
"0.6132308",
"0.61170185",
"0.61083937",
"0.6087886",
"0.60542804",
"0.60415447",
"0.60387516",
"0.6025212",
"0.6023698",
"0.60225034",
"0.60221803",
"0.60201687",
"0.6003014",
"0.59932804",
"0.5971222",
"0.59703046",
"0.5964592",
"0.5958594",
"0.59466916",
"0.59401834",
"0.590381",
"0.58973515",
"0.5893066",
"0.5887197",
"0.5866256",
"0.58648086",
"0.5860802",
"0.58588773",
"0.5858228",
"0.58393836",
"0.58240986",
"0.57989985",
"0.5789254",
"0.5781118",
"0.5769824",
"0.576848",
"0.5767058",
"0.57613564",
"0.57115114",
"0.5710167",
"0.57091004",
"0.57025456",
"0.56932163",
"0.56915385",
"0.56786835",
"0.56786835",
"0.5676607",
"0.5658996",
"0.5654681",
"0.5648127",
"0.56413305",
"0.5631324",
"0.5627298",
"0.56142145",
"0.5611054",
"0.5607881",
"0.56051517",
"0.5580867",
"0.5577881",
"0.55679095",
"0.55657476",
"0.55641526",
"0.55640507",
"0.55559814",
"0.5552937",
"0.55412114",
"0.55396056",
"0.5534988",
"0.5530734",
"0.5520284",
"0.55201894",
"0.55133474",
"0.55106",
"0.5500258",
"0.54962355",
"0.5495237"
] | 0.688842 | 3 |
Set the response status code and header | def redirect_to(url)
raise "already built response" if already_built_response?
@res.status = 302
@res["Location"] = url
@already_built_response = true
self.session.store_session(@res)
self.flash.store_flash(@res)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status(code)\n @response.status = code\n end",
"def send_headers response_code\n end",
"def status(code)\n response.status = code\n end",
"def set_status_code\n if self.status_code.nil?\n self.status_code = \"200\"\n end\n end",
"def response_status(kind)\n response.headers['status'] = kind.to_s\n end",
"def http_response_code(status = nil)\n if status\n @status = status\n else\n @status\n end\n end",
"def status code=nil\n @response.status = code if code\n @response.status\n end",
"def write_status(response)\n response.setStatus(@status.to_i)\n end",
"def respond_with(status_code)\n response.status = status_code\n response.write \"\"\n nil\n end",
"def set_http_code(h_c)\n if h_c.nil?\n @http_code = 200\n else\n @http_code = h_c.to_i\n end\n end",
"def respond_with(status_code)\n response.status = status_code\n response.write ''\n nil\n end",
"def set_status(status)\n if status.kind_of?(Symbol)\n status = Merb::ControllerExceptions::STATUS_CODES[status]\n status || raise(\"Can't find a response code with that name\")\n end\n @_status = status\n end",
"def set_response(response, body, status = 200)\n raise NotImplementedError\n end",
"def set_response(response, body, status = 200)\n raise NotImplementedError\n end",
"def status(value = nil)\n\t\t\tresponse.status ||= 200\n\t\t\tresponse.headers['X-Cascade'] = 'pass' if value == 404\n\t\t\tvalue ? response.status = value : response.status\n\t\tend",
"def send_by_code request, response, code, headers = {}\n\t\t\t\tbegin\n\t\t\t\t\tresponse.status = code\n\t\t\t\t\theaders.each {|k, v| response[k] = v}\n\t\t\t\t\treturn ErrorCtrl.new(request, response).index\n\t\t\t\trescue => e\n\t\t\t\t\tPlezi.error e\n\t\t\t\tend\n\t\t\t\tfalse\n\t\t\tend",
"def setup_status_and_body\n @status, @body = @response.status, @response.body # TODO: Need to status.to_i?\n end",
"def set_header name, value\n response_object.header name, value\n end",
"def headers\n { 'Status' => ActionController::Base::DEFAULT_RENDER_STATUS_CODE }\n end",
"def set_error(status)\n error_response = Rack::Response.new\n error_response.status = status\n @error_response = error_response.finish {yield}\n end",
"def report_response_status\n status = parsed_content.response_status\n request.update_attributes(status: status)\n end",
"def flex_error_handling\n response.headers['Status'] = interpret_status(200) if response.headers['Status'] == interpret_status(422)\n response.headers['Status'] = interpret_status(200) if response.headers['Status'] == interpret_status(201)\n end",
"def ok; @status = 200 end",
"def ok; @status = 200 end",
"def set_status(code)\n new(\n status: code\n )\n end",
"def status_code\n @response.status\n end",
"def response_headers! http_status_code = 200, http_with_version = 'HTTP 1.1', header_hash\n errors = header_hash.each_with_object [] do |(key, val), errors|\n key = key.to_s; val = val.to_s\n rv = Wrapper.msc_add_n_response_header txn_ptr, (strptr key), key.bytesize, (strptr val), val.bytesize\n rv == 1 or errors << \"msc_add_n_response_header failed adding #{[key,val].inspect}\"\n end\n\n raise Error, errors if errors.any?\n\n rv = Wrapper.msc_process_response_headers txn_ptr, (Integer http_status_code), (strptr http_with_version)\n rv == 1 or raise \"msc_process_response_headers failed\"\n\n intervention!\n end",
"def send_status( status )\n self.status = ::Rack::Utils.status_code( status )\n self.write ::Rack::Utils::HTTP_STATUS_CODES[ self.status ]\n end",
"def response code=nil, body=nil, headers=nil\n args = [code, body, headers].compact\n\n headers = {'Content-Type' => DEFAULT_CONTENT_TYPE}\n code = 200\n body = \"\"\n\n args.each do |arg|\n case arg\n when Hash then headers.merge!(arg)\n when String then body = arg\n when Integer then code = arg\n end\n end\n\n [code, headers, body]\n end",
"def give_X(response, status, mime_type, msg)\n\theaders = response.headers\n\tresponse.status =status\n\tresponse.body = [msg]\n\tresponse.headers[\"Content-Type\"] = mime_type\n\tresponse.headers[CONTENT_LENGTH] = response.body.join.length.to_s\n end",
"def downstream_resp=(status_headers_body)\n @status, @headers, @body = status_headers_body\n end",
"def headers=(new_headers)\n @_response ||= ActionDispatch::Response.new\n @_response.headers.replace(new_headers)\n end",
"def status(value=nil)\n response.status = value if value\n response.status\n end",
"def status(code, message)\n self.status = code\n self.body = message\n end",
"def status(code, message)\n self.status = code\n self.body = message\n end",
"def render_header\n response_header = \"#{@version} #{@status} #{@reason}#{CRLF}\"\n\n unless @headers.empty?\n response_header << @headers.map do |header, value|\n \"#{header}: #{value}\"\n end.join(CRLF) << CRLF\n end\n\n response_header << CRLF\n end",
"def status_code(val = nil)\n if val\n @j_del.setStatusCode(val)\n self\n else\n @j_del.getStatusCode\n end\n end",
"def status_code; end",
"def headers\n @headers.merge({ \"Status\" => @status })\n end",
"def status_code\n response_value(:code)\n end",
"def response_code; end",
"def response_code; end",
"def response_code; end",
"def response_code; end",
"def handle_status_code(req)\n case req.code\n when 200..204; return\n when 400; raise ResponseError.new req\n when 401; raise ResponseError.new req\n else raise StandardError\n end\n end",
"def fill_header(response); end",
"def parse_response_line\n if @headers.first =~ /\\AHTTP\\/1\\.[01] ([\\d]{3})/\n @status = $1.to_i\n else\n set_deferred_status :failed, {\n :status => 0 # crappy way of signifying an unrecognized response. TODO, find a better way to do this.\n }\n close_connection\n end\n end",
"def prepare_status_response( request, status_info )\n\t\tstatus_code, message = status_info.values_at( :status, :message )\n\t\tself.log.info \"Non-OK response: %d (%s)\" % [ status_code, message ]\n\n\t\trequest.notes[:status_info] = status_info\n\t\tresponse = request.response\n\t\tresponse.reset\n\t\tresponse.status = status_code\n\n\t\t# Some status codes allow explanatory text to be returned; some forbid it. Append the\n\t\t# message for those that allow one.\n\t\tunless request.verb == :HEAD || response.bodiless?\n\t\t\tself.log.debug \"Writing plain-text response body: %p\" % [ message ]\n\t\t\tresponse.content_type = 'text/plain'\n\t\t\tresponse.puts( message )\n\t\tend\n\n\t\t# Now assign any headers to the response that are part of the status\n\t\tif status_info.key?( :headers )\n\t\t\tstatus_info[:headers].each do |hdr, value|\n\t\t\t\tresponse.headers[ hdr ] = value\n\t\t\tend\n\t\tend\n\n\t\treturn response\n\tend",
"def set_status(status_code, fetch = false)\n case status_code\n when /1../\n @status = :running\n when \"200\"\n @status = :completed\n fetch_result if fetch\n when /4../\n @status = :error\n end\n end",
"def index\n head params[:response_status]\n end",
"def ok_status_code\n _undefined\n end",
"def set_redirect_error_status(status)\n end",
"def update!(**args)\n @response_status_code = args[:response_status_code] if args.key?(:response_status_code)\n end",
"def prepare_response(status, headers, body)\n status_reason_phrase = STATUS_REASON_PHRASES[status]\n header_lines = headers.map { |key, value| \"#{key}: #{value}\" }\n <<~EOF\n HTTP/1.1 #{status} #{status_reason_phrase}\n #{header_lines.join(\"\\n\")}\n\n #{body}\n EOF\n end",
"def error(code=500, body = nil)\n unless code.is_a?(Integer)\n body = code\n code = 500\n end\n\n response.status = code\n response.body = body if body\n halt\n end",
"def respond status:, headers: {}, body: ''\n @stream.respond status: status, headers: headers, body: body\n end",
"def status(stat)\n @headers << \"HTTP/1.1 #{stat}\\r\\n\"\n @accepted = true\n end",
"def add_response_header(key, value)\n new(\n response_headers: ConnSupport::Headers.add(\n response_headers, key, value\n )\n )\n end",
"def set_result\n raw.data.status_code = raw.statusCode\n raw.data.status_text = raw.statusText\n @result = raw.data\n end",
"def status_code\n wrapper.status_code.to_i\n end",
"def http_status\n self[:status_code]\n end",
"def set_response(response, result, status = 200)\n response.status = status\n unless result.is_a?(File)\n response.write result\n else\n response[\"Content-Length\"] = result.stat.size.to_s\n response.body = RackFile.new(result)\n end\n end",
"def page_status\n @status = \"OK\"\n @status = \"ERR\" if self.response_code > 399\n end",
"def initialize\n @headers = {}\n @trace = []\n self.code = 200\n self.redirect = false \n end",
"def update_response(processed)\n case processed\n when Integer then response.status = processed\n when String,NilClass then response.body << processed.to_s\n when Array\n response.status = processed[0].to_i\n if response.respond_to?(:headers=)\n response.headers = processed[1]\n else\n processed[1].each do |key, value|\n response[key] = value\n end\n end\n response.body = processed[2].respond_to?(:each) ? processed[2] : [processed[2]]\n when Hash\n response.status = processed[:status].to_i if processed.key?(:status)\n response.headers.update(processed[:headers]) if processed.key?(:headers)\n response.body = processed[:body].respond_to?(:each) ? processed[:body] : [processed[:body]] if processed.key?(:body)\n end\n end",
"def http_response(response)\n status_code, headers, body = response\n http_response = status_line(status_code)\n DefaultResponseHeaders.merge(headers).each do |k,v|\n http_response << \"#{k}: #{v}\\r\\n\"\n end\n http_response << \"\\r\\n\"\n body.each do |s|\n http_response << s\n end\n http_response\n end",
"def set_status( statuscode )\n\t\t\tself.log.warn \"Unknown status code %d\" unless CLOSING_STATUS_DESC.key?( statuscode )\n\t\t\tstatus_msg = \"%d %s\" % [ statuscode, CLOSING_STATUS_DESC[statuscode] ]\n\n\t\t\tself.payload.truncate( 0 )\n\t\t\tself.payload.puts( status_msg )\n\t\tend",
"def http_status_line(code = 200)\n \"#{HTTP_VERSION} #{code} #{Shelf::Utils::HTTP_STATUS_CODES[code]}\"\n end",
"def header_set(name, value)\n return dup_without_response.header_set(name, value) if response\n\n name = name.to_s\n if value.nil?\n @headers.delete name\n return self\n end\n\n @headers[name] = value.to_s\n self\n end",
"def http_status(hs=nil)\n @_http_status = hs unless hs.nil?\n @_http_status\n end",
"def status_code\n STATUS_CODE\n end",
"def header(str)\n # {{{\n if @output_started\n raise \"HTTP-Headers are already send. You can't change them after output has started!\"\n end\n unless @output_allowed\n raise \"You just can set headers inside of a Rweb::out-block\"\n end\n if str.is_a?Array\n str.each do | value |\n self.header(value)\n end\n\n elsif str.split(/\\n/).length > 1\n str.split(/\\n/).each do | value |\n self.header(value)\n end\n\n elsif str.is_a? String\n str.gsub!(/\\r/, \"\")\n\n if (str =~ /^HTTP\\/1\\.[01] [0-9]{3} ?.*$/) == 0\n pattern = /^HTTP\\/1.[01] ([0-9]{3}) ?(.*)$/\n\n result = pattern.match(str)\n self.setstatus(result[0], result[1])\n elsif (str =~ /^status: [0-9]{3} ?.*$/i) == 0\n pattern = /^status: ([0-9]{3}) ?(.*)$/i\n\n result = pattern.match(str)\n self.setstatus(result[0], result[1])\n else\n a = str.split(/: ?/, 2)\n\n @header[a[0].downcase] = a[1]\n end\n end\n # }}}\n end",
"def response\n [ @_status || DEFAULT_RESPONSE_CODE, headers, @_body || DEFAULT_RESPONSE_BODY.dup ]\n end",
"def response\n [ @_status || DEFAULT_RESPONSE_CODE, headers, @_body || DEFAULT_RESPONSE_BODY.dup ]\n end",
"def initialize(status_code, headers={}, body='')\n @status_code = status_code.to_i\n @headers = headers\n @body = body\n end",
"def status(value)\n phpcall :header, \"HTTP/1.1 #{frucnatra_http_statuses[value]}\"\n end",
"def initialize\n @headers = HeaderHash.new\n @trace = []\n self.code = 200\n self.redirect = false\n end",
"def get_http_response_code\n raise 'To be implemented in child classes'\n end",
"def set_http_response(response, skip_body=false)\n @data[:response][:instance] = HTTPResponse.new(\n response.code,\n skip_body ? nil : response.body,\n response.to_hash,\n response\n )\n nil\n end",
"def write_headers(response)\n @headers.each do |key, value|\n case key\n when /^Content-Type$/i\n response.setContentType(value.to_s)\n when /^Content-Length$/i\n length = value.to_i\n # setContentLength(int) ... addHeader must be used for large files (>2GB)\n response.setContentLength(length) if ! chunked? && length < 2_147_483_648\n else\n # servlet container auto handle chunking when response is flushed \n # (and Content-Length headers has not been set) :\n next if key == TRANSFER_ENCODING && skip_encoding_header?(value)\n # NOTE: effectively the same as `v.split(\"\\n\").each` which is what\n # rack handler does to guard against response splitting attacks !\n # https://github.com/jruby/jruby-rack/issues/81\n if value.respond_to?(:each_line)\n value.each_line { |val| response.addHeader(key.to_s, val.chomp(\"\\n\")) }\n elsif value.respond_to?(:each)\n value.each { |val| response.addHeader(key.to_s, val.chomp(\"\\n\")) }\n else\n case value\n when Numeric\n response.addIntHeader(key.to_s, value.to_i)\n when Time\n response.addDateHeader(key.to_s, value.to_i * 1000)\n else\n response.addHeader(key.to_s, value.to_s)\n end\n end\n end\n end\n end",
"def response_to_status(response)\n response ? :success : :error\n end",
"def json_error_response\n # status must be assigned, ||= will often return 200\n self.status = 401\n self.content_type = \"application/json\"\n # have to include format_json here because custom error app\n # doesn't seem to call render json: as normal\n # so pretty param is ignored\n self.response_body = format_json(\n { errors: [{ status: status, detail: i18n_message }] },\n {} # options hash normally handled by render block\n )\n end",
"def update_visit_response(status)\n if request.xhr?\n head :status => status\n else\n respond_to do |format|\n # send 'em back to where they came from\n format.html { redirect_to request.headers['HTTP_REFERER'] }\n end\n end\n end",
"def status\n @status ||= raw_response['responseHeader']['status']\n end",
"def put(_status, headers, env)\n check_precondition!(env)\n\n if exists?\n update(env['rack.input'], env['CONTENT_TYPE'])\n headers = update_headers(headers)\n [200, headers, self]\n else\n create(env['rack.input'], env['CONTENT_TYPE'])\n [201, update_headers(headers), self]\n end\n end",
"def getStatusCode\n @_statusCode\n end",
"def respond(status_code, body = nil, **headers)\n # Log response\n log = \"RESPONSE [#{ status_code }] #{ body }\"\n Yake.logger&.send(status_code.to_i >= 400 ? :error : :info, log)\n\n # Set headers\n content_length = (body&.bytesize || 0).to_s\n to_s_downcase = -> (key) { key.to_s.downcase }\n headers = {\n 'content-length' => content_length,\n **(@headers || {}),\n **headers,\n }.transform_keys(&to_s_downcase).compact\n\n # Send response\n { statusCode: status_code, headers: headers, body: body }.compact\n end",
"def processresponse(httpresponse)\n\n @responsecode = httpresponse.code\n case httpresponse.code\n when 201 # success condition\n @response = httpresponse.headers[:location]\n when 200 # success condition\n @response = httpresponse.headers[:location]\n\n end\n\n end",
"def set_error(error_code, msg, status_code=nil)\n return if @error\n @error = {:code => error_code, :message => msg} \n @status_code = status_code || 500\n end",
"def error!(status, message)\n response.status = status\n response[\"Content-Type\"] = \"application/json\"\n response.write({error: message}.to_json)\n request.halt\n end",
"def code\n @http_response.code.to_i\n end",
"def render_error( status_code )\n\n respond_to do |format|\n\n format.html { render( action: status_code, status: status_code )}\n format.all { head( status_code )}\n\n end\n\n @error_sent = true\n\n true # return something so we can chain things\n\n end",
"def status_code\n @parser.status_code\n end",
"def head(status, additional_headers = {})\n @response_status = status\n response_headers.merge!(additional_headers)\n response_headers.merge!({\"Access-Control-Allow-Origin\": ENV[\"ACCESS_CONTROL_ALLOW_ORIGIN\"]})\n end",
"def throw(code)\n status(*Http::Status.for_code(code))\n super :halt\n end",
"def hit_status(env)\n env&.response_headers&.fetch(@http_header, nil) ||\n env&.request_headers&.fetch(@http_header, nil)\n end",
"def status_error\n @status = 500\n end",
"def add_response_header(name, type, description)\n name = name.to_s\n check_duplicate(name, 'Response header')\n @response_headers[name] = SwaggerResponseHeader.new(name, type, description)\n end",
"def add_headers; end",
"def status\n head :ok\n end",
"def status\n head :ok\n end"
] | [
"0.794432",
"0.78250635",
"0.78158605",
"0.757165",
"0.74761254",
"0.73475385",
"0.7225574",
"0.7152764",
"0.71213555",
"0.70445",
"0.6923586",
"0.6883578",
"0.68797094",
"0.68797094",
"0.687684",
"0.68444437",
"0.678412",
"0.6782564",
"0.6771085",
"0.6747486",
"0.67410016",
"0.67410016",
"0.6716454",
"0.6716454",
"0.6714426",
"0.6536794",
"0.65323335",
"0.6526737",
"0.64911133",
"0.64798373",
"0.6477403",
"0.64520526",
"0.6445438",
"0.643101",
"0.643101",
"0.64280444",
"0.64021456",
"0.6384643",
"0.63749105",
"0.6373129",
"0.6361735",
"0.6361735",
"0.6361735",
"0.6361735",
"0.6349169",
"0.6305716",
"0.6297084",
"0.6288668",
"0.62847036",
"0.6283818",
"0.6281522",
"0.628102",
"0.6273195",
"0.6261495",
"0.6257526",
"0.6246483",
"0.62404644",
"0.62202144",
"0.6219443",
"0.6211866",
"0.6210467",
"0.6206887",
"0.6204738",
"0.6202401",
"0.6190686",
"0.6186212",
"0.6184355",
"0.61812913",
"0.61777604",
"0.61486214",
"0.6122018",
"0.6105089",
"0.6103174",
"0.6103174",
"0.6079447",
"0.60788506",
"0.60786307",
"0.60626024",
"0.60476136",
"0.6039038",
"0.6027417",
"0.60095006",
"0.6008609",
"0.5964368",
"0.59524024",
"0.5949451",
"0.59359485",
"0.5925512",
"0.5914793",
"0.5906869",
"0.59060925",
"0.58870137",
"0.58711183",
"0.58701426",
"0.586893",
"0.5866952",
"0.5866841",
"0.5854485",
"0.58520186",
"0.58388066",
"0.58388066"
] | 0.0 | -1 |
Populate the response with content. Set the response's content type to the given type. Raise an error if the developer tries to double render. | def render_content(content, type)
raise "already built response" if already_built_response?
self.session.store_session(@res)
self.flash.store_flash(@res)
@res.content_type = type
@res.body = content
@already_built_response = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_content(content, type)\n if already_built_response?\n raise\n else\n res.content_type = type\n res.body = content\n end\n @already_built_response = true\n @session.store_session(res) if @session\n @flash.store_flash(res) if @flash\n end",
"def render_content(content, type)\n raise Exception.new(\"Already Rendered Response\") if already_built_response?\n @response.body = content\n @response['Content-Type'] = type\n @session.store_session(@response) if @session\n @flash.store_flash(@response) if @flash\n @already_built_response = true\n end",
"def render_content(content, content_type)\n raise \"Already built response!\" if already_built_response?\n @res.body = content\n @res.content_type = content_type\n @already_built_response = true\n session.store_session(@res)\n flash.store_flash(@res)\n end",
"def render_content(content, content_type)\n raise if already_built_response?\n @res.content_type = content_type\n @res.body = content\n @already_built_response = true\n @session.store_session(@res)\n end",
"def render_content(content, content_type)\n raise DoubleRenderError if already_built_response?\n res['Content-Type'] = content_type\n res.body = [content]\n @already_built_response = true\n session.store_session(res)\n end",
"def render_content(content, content_type = 'text/html')\n if self.already_built_response?\n raise \"Double render error!\"\n else\n @res.write(content)\n @res['Content-Type'] = content_type\n @already_built_response = true\n nil\n end\n end",
"def render_content(content, content_type)\n unless already_built_response?\n @res.content_type = content_type\n @res.body = content\n @already_built_response = true\n else\n fail\n end\n session.store_session(res)\n end",
"def render_content(content, content_type)\n if already_built_response?\n raise \"double render\"\n else\n res['Content-Type'] = content_type\n res.write(content)\n store_flash_and_session(res)\n @already_built_response = true\n end\n end",
"def render_content( content, content_type )\n prepare_response do\n res.content_type = content_type\n res.write( content )\n end\n end",
"def render_content(content, type)\n #response = HTTPResponse.new(content_type: type, body: content)\n self.res.body, self.res.content_type = content, type\n session.store_session(self.res)\n\n if already_rendered?\n raise \"Can't render/redirect twice\"\n end\n\n #following might be wrong b/c of no setter\n @already_built_response = true\n nil\n #response\n end",
"def render_content(content, type)\n check_already_rendered\n session.store_session(response)\n response.content_type = type\n response.body = content\n @already_rendered = true\n end",
"def render_content(content, content_type)\n raise 'Already responded' if already_built_response?\n \n res['Content-Type'] = content_type\n res.write(content)\n @already_built_response = true\n session.store_session(res)\n end",
"def render_content(content, content_type)\n raise \"Already delivered response\" if self.already_built_response?\n res['Content-Type'] = content_type\n res.write(content)\n @already_built_response = true\n self.session.store_session(res)\n self.flash.store_flash(res)\n end",
"def render_content(body, content_type)\n @res.content_type = content_type\n @res.body = body\n @already_built_response = true\n session.store_session(@res)\n end",
"def render_content(content, content_type)\n raise \"double render error\" if constructed_response?\n\n @response.write(content)\n @response['Content-Type'] = content_type\n\n @constructed_response = true\n\n session.store_session(@response)\n\n nil\n end",
"def render_content(content, content_type)\n if !already_built_response?\n @res.body = content\n @res.content_type = content_type\n @already_built_response = true\n else\n raise \"exception\"\n end\n session.store_session(res)\n # storing the flash will fail the last spec\n flash.store_flash(res)\n end",
"def render_content(content, content_type)\n raise \"Double Render Error\" if already_built_response?\n\n # set content_type attribute in header equiv to set_header\n @res['Content-type'] = content_type\n\n # sets body\n @res.write(content)\n @already_built_response = true\n\n # sets cookie in response (as cookie for client to save)\n # just keep on adding stuff to the response (until res.finish is called in server)\n session.store_session(@res)\n end",
"def render(*args) #:nodoc:\n raise ::AbstractController::DoubleRenderError if self.response_body\n super\n self.content_type ||= rendered_format.to_s\n self.response_body\n end",
"def fixup_response_content_type( response )\n\n\t\t# Make the error for returning something other than a Response object a little\n\t\t# nicer.\n\t\tunless response.respond_to?( :content_type )\n\t\t\tself.log.error \"expected response (%p, a %p) to respond to #content_type\" %\n\t\t\t\t[ response, response.class ]\n\t\t\tfinish_with( HTTP::SERVER_ERROR, \"malformed response\" )\n\t\tend\n\n\t\trestype = response.content_type\n\n\t\tif !restype\n\t\t\tif (( default = self.class.default_type ))\n\t\t\t\tself.log.debug \"Setting content type of the response to the default: %p\" %\n\t\t\t\t\t[ default ]\n\t\t\t\tresponse.content_type = default\n\t\t\telse\n\t\t\t\tself.log.debug \"No default content type\"\n\t\t\tend\n\t\telse\n\t\t\tself.log.debug \"Content type already set: %p\" % [ restype ]\n\t\tend\n\tend",
"def render_content(content, content_type=\"text/html\")\n if already_built_response?\n raise \"DoubleRenderError\" \n else \n @res['Content-Type'] = content_type\n @res.write(content) \n session.store_session(res)\n @already_built_response = true \n \n end \n \n end",
"def render_content(content, content_type, cached=false)\n raise \"Already built response!\" if already_built_response?\n @res['Content-Type'] = content_type\n if cached\n @res['Cache-Control'] = \"public; max-age=31536000\"\n @res['Expires'] = (Time.now + 1.year).httpdate\n end\n @res.write(content)\n finalize_response(:render)\n end",
"def render_content(content, content_type)\n raise \"double render error\" if @already_built_response\n\n res.write(content)\n res['Content-Type'] = content_type\n\n @already_built_response = true\n\n @session.store_session(res)\n nil\n end",
"def content_type! type = nil, charset = nil\n __e__.explicit_charset = charset if charset\n charset ||= (content_type = response['Content-Type']) &&\n content_type.scan(%r[.*;\\s?charset=(.*)]i).flatten.first\n type && (Symbol === type) && (type = '.' << type.to_s)\n content_type = type ?\n (type =~ /\\A\\./ ? '' << mime_type(type) : type.split(';').first) : 'text/html'\n content_type << '; charset=' << charset if charset\n response['Content-Type'] = content_type\n end",
"def set_content_type(response, format)\n raise NotImplementedError\n end",
"def set_content_type(response, format)\n raise NotImplementedError\n end",
"def render_content(content, content_type)\n count = 0\n \n res = Rack::Response.new()\n\n @res.write(content)\n res[\"Content-Type\"] = content_type\n\n if @res.write \n count+= 1\n end\n\n if count > 1\n return @already_built_response = raise \"Double render error\"\n end\n\n end",
"def set_content_type\n response.headers[\"Content-Type\"] = \"text/html; charset=#{Comatose.config.content_type}\" unless Comatose.config.content_type.nil?\n end",
"def set_content_type\n response.headers[\"Content-Type\"] = \"text/html; charset=#{Comatose.config.content_type}\" unless Comatose.config.content_type.nil? or response.headers['Status'] == '404 Not Found'\n end",
"def default_render\n response.content_type.blank? ? respond_to(:html) : super \n end",
"def set_content_type raw_type\n response_object.mime_raw raw_type\n end",
"def content_type!(ext)\n case ext.downcase\n when 'haml'; t = 'text/html'\n when 'erb'; t = 'text/html'\n# I believe all the rest are determined accurately by the Rack::Mime.mime_type call in the else clause below.\n# when 'html'; t = 'text/html'\n# when 'js'; t = 'text/javascript'\n# when 'css'; t = 'text/css'\n# when 'png'; t = 'image/png'\n# when 'gif'; t = 'image/gif'\n# when 'jpg'; t = 'image/jpeg'\n# when 'jpeg'; t = 'image/jpeg'\n else t = Rack::Mime.mime_type('.' + ext, 'text/plain')\n end\n #puts(\"----#{ext}:\" + t.inspect) # dbg\n (self.response[:headers]['Content-Type'] = t) if t\n end",
"def render(*args, &block)\n options = _normalize_render(*args, &block)\n rendered_body = render_to_body(options)\n if options[:html]\n _set_html_content_type\n else\n _set_rendered_content_type rendered_format\n end\n _set_vary_header\n self.response_body = rendered_body\n end",
"def handle\n @response.response_code = response_code\n @response.content = view\n @response.layout = set_layout\n @response.output_format = @request.path_info.split(\".\").last\n end",
"def content_type=(ctype)\n @response_headers[\"Content-Type\"] = ctype\n end",
"def content_type\n self.class.response_content_type\n end",
"def set_content_type\n case params['format']\n when 'xml'\n response.headers['Content-Type'] = \"application/xml; charset=utf-8\"\n when 'json', 'csv'\n response.headers['Content-Type'] = \"application/json; charset=utf-8\"\n else\n raise \"Unexpected format!\"\n end\n end",
"def respond_to\n env['HTTP_ACCEPT'] ||= 'text/html'\n Rack::RespondTo.env = env\n\n super { |format|\n yield(format).tap do |response|\n type = Rack::RespondTo::Helpers.match(Rack::RespondTo.media_types, format).first\n content_type(type) if type\n end\n }\n end",
"def content_type\n @response['content-type'].nil? ? 'text/plain' : @response['content-type']\n end",
"def content_types(*content_types)\n Sinatra::RPC::Serializer.register self, content_types\n @response_content_type = content_types.compact.first\n end",
"def content_type\n @meta_content_type || response['content-type']\n end",
"def content_type\n @meta_content_type || response['content-type']\n end",
"def content_type\n @content_type ||= @response_impl.entity.content_type.value\n end",
"def respond_with_content_type(*args, &block)\n options = args.extract_options!\n options.merge!(:content_type => args.first)\n RespondWithMatcher.new(options, &block).spec(self)\n end",
"def render(*args, &block)\n options = args.last.is_a?(Hash) ? args.pop : {}\n @response.status = options.delete(:status) || 200\n layout = @layouts[options.delete(:layout) || :default]\n assigns = { :request => request, :response => response, :params => params, :session => session }\n @content = args.last.is_a?(String) ? args.last : Markaby::Builder.new(assigns, self, &(block || @views[args.last])).to_s\n @content = Markaby::Builder.new(assigns, self, &layout).to_s if layout\n @response.headers.merge!(options)\n @response.body = @content\n end",
"def content_type(type=nil, params={})\n return @_content_type unless type\n super(type, params)\n @_content_type = type\n end",
"def content_type=( type )\n\t\treturn self.headers.content_type = type\n\tend",
"def content_type=( type )\n\t\treturn self.headers.content_type = type\n\tend",
"def content_type(type)\n @headers << \"Content-Type: #{type}\\r\\n\"\n @content_type = true\n end",
"def render(*args, &block)\n\t options = _normalize_render(*args, &block)\n\t self.response_body = render_to_body(options)\n\t _process_format(rendered_format, options) if rendered_format\n\t self.response_body\n\t end",
"def content_type=(content_type); end",
"def parse_response(response)\n if response['content-type']\n [ response['content-type'].gsub(/\\s*;.*$/,''), response.body ]\n else\n raise _(\"No content type in http response; cannot parse\")\n end\n end",
"def content_type=( type )\n\t\treturn self.headers[ :content_type ] = type\n\tend",
"def content\n try(content_type)\n end",
"def content_type(type)\n @response.content_type == type\n end",
"def content_type=(type)\n @content_type = type\n end",
"def content_type_switch\n\t\t@old_content_type = params[:old_content_type]\n\t\t@content_type = params[:content_type];\n\t\tif @old_content_type != @content_type\n\t\t\t@content = render_to_string :partial=>'convert_content',\n\t\t\t\t:locals=>{:content=>params[:content],\n\t\t\t\t\t:from_type=>@old_content_type,\n\t\t\t\t\t:to_type=>@content_type}\n\t\telse\n\t\t\t@content = params[:content]\n\t\tend\n\t\t@page = Page.new(:content=>@content, :content_type=>@content_type)\n\t\t#render :layout=>false\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.js { render :layout=>false }\n\t\t\tformat.xml { render :xml=>@page.to_xml }\n\t\tend\n\tend",
"def parse_response(response)\n if response['content-type']\n [ response['content-type'].gsub(/\\s*;.*$/,''), uncompress_body(response) ]\n else\n raise _(\"No content type in http response; cannot parse\")\n end\n end",
"def call(request)\r\n response = super(request)\r\n \r\n if not response.nil? and response.headers['Content-Type']=='text/html'\r\n response.data = ERB.new(response.data +\r\n File.open(@template, \"rb\").readlines.join).result(binding)\r\n end\r\n \r\n response\r\n end",
"def content_type=(value)\n raise ArgumentError, \"content_type must be set to :data or :header, was: #{value.inspect}\" unless [:data, :header].include?(value)\n @content_type = value\n end",
"def response_content_type_with_charset(request, config)\n content_type_with_charset(\n response_content_type(request, config),\n config.default_charset || Action::DEFAULT_CHARSET\n )\n end",
"def set_content_type(content_type)\n set_header 'Content-Type', content_type\n end",
"def content_type(type=nil, params={})\n type.nil? ? @_content_type : super(type, params)\n end",
"def content_type(type=nil, params={})\n type.nil? ? @_content_type : super(type, params)\n end",
"def content_type\n return blank_type if @headers.nil?\n \n # if no content type is supplied return and empty string instead of nil\n Page.content_type_sanitize( @headers['content-type'] ) \n end",
"def render_content(content, content_type)\n super(content, content_type)\n @session.store_session(@res)\n end",
"def content_type\n response&.response&.content_type\n end",
"def content_type\n self[:content_type] == 'haml' ? 'text/html' : self[:content_type]\n end",
"def content_type=(type)\n\t\t\tif type.index(C_slash)\n\t\t\t\t@content_type = type\n\t\t\telse\n\t\t\t\t@content_type = MIME::Types.type_for(type).first || BINARY_TYPE\n\t\t\tend\n\t\tend",
"def set_content_type\n format = settings[:format] = params[:format].to_sym\n content_type content_types[format]\n end",
"def set_response_body(content)\n new(\n response_body: content.respond_to?(:each) ? content : [content]\n )\n end",
"def content_type=(value)\n @content_type = value\n end",
"def as(content_type)\n headers['Content-Type'] = content_type\n accepts(content_type)\n end",
"def respond(object, types)\n types << json\n types.each { |type|\n case type\n when json\n content_type :json, :charset => 'utf-8'\n halt object.to_json\n when yaml\n content_type :yaml, :charset => 'utf-8'\n halt object.to_yaml\n when text\n require 'pp'\n content_type :text, :charset => 'utf-8'\n halt object.pretty_inspect\n end\n }\n end",
"def render(*args, &block)\n super(*args, &block)\n opts = args.first\n if opts.has_key?(:text) && opts[:text].present?\n self.response_body = opts[:text]\n elsif opts.has_key?(:nothing) && opts[:nothing]\n self.response_body = \" \"\n else\n raise UnsupportedOperationError\n end\n end",
"def create_content_type(content_type)\n self.output_resource_op content_type\n\n response = self.post :content_types, content_type.to_params, nil, true\n\n self.apply_response(content_type, response)\n\n # status = self.response_to_status(response)\n\n self.output_resource_op_status content_type, :success\n rescue Exception => e\n self.output_resource_op_status content_type, :error, e.message\n end",
"def response_content_type\n @response_headers[\"Content-Type\"]\n end",
"def set_content_type(ctype)\n headers[\"Content-Type\"] = \"#{ctype};charset=#{Response.charset}\"\n end",
"def content_type\n response.content_type\n end",
"def content_type=(content_type); @message_impl.setContentType content_type; end",
"def content_type ctype=nil\n @content_type = ctype if ctype\n @content_type ||=\n \"#{self.class.media_type}/#{self.class.api_name}+#{@env['kiwi.format']}\"\n end",
"def content_type\n raise NotImplementedError\n end",
"def content_type=(identifier)\n @content_type = nil\n headers['Content-Type'] = MediaTypeIdentifier.load(identifier).to_s\n end",
"def content_type\n @response_headers[\"Content-Type\"]\n end",
"def as(content_type)\n @content_type = content_type\n @accepts = content_type\n self\n end",
"def content_type\n @content_type ||= request.content_type\n end",
"def format_response(response, args = { })\n supported_types = %w(application/json application/xml text/xml)\n case request.preferred_type(supported_types)\n when 'application/json'\n content_type :json\n _response = (response.is_a?(Hash) || response.is_a?(Array)) ? JSON.generate(response) : response\n #when 'application/xml', 'text/xml'\n # content_type :xml\n # _response = XmlSimple.xml_out(response, { :root_name => 'response' })\n else\n content_type :json\n _response = (response.is_a?(Hash) || response.is_a?(Array)) ? JSON.generate(response) : response\n end\n _response\n end",
"def render(options = {}, extra_options = {}, &block)\n if atom = options[:atom]\n response.content_type ||= Mime::ATOM\n render_for_text(atom.respond_to?(:to_atom) ? atom.to_atom.to_xml : atom.to_xml, options[:status])\n else\n super\n end\n end",
"def validate_content_type!(response)\n return unless media_type\n\n response_content_type = response.content_type\n expected_content_type = Praxis::MediaTypeIdentifier.load(media_type.identifier)\n\n unless expected_content_type.match(response_content_type)\n raise Exceptions::Validation.new(\n \"Bad Content-Type header. #{response_content_type}\" +\n \" is incompatible with #{expected_content_type} as described in response: #{self.name}\"\n )\n end\n end",
"def content_type\n ((response.headers.values_at('content-type', 'Content-Type').compact.first || '').split(';').first || '').strip\n end",
"def apply_response(content_type, response)\n return if content_type.nil? || response.nil?\n\n content_type._id = response['id']\n content_type.klass_name = response['klass_name']\n\n response['entries_custom_fields'].each do |remote_field|\n field = content_type.find_field(remote_field['name'])\n _id = remote_field['id']\n\n if field.nil?\n if self.force?\n content_type.fields << Locomotive::Mounter::Models::ContentField.new(_id: _id, _destroy: true)\n end\n else\n field._id = _id\n end\n end\n end",
"def finish(*args, &block)\n self['Content-Type'] ||= 'text/html;charset=utf-8'\n @block = block if block\n if [204, 205, 304].include?(status.to_i)\n header.delete \"Content-Type\"\n header.delete \"Content-Length\"\n close\n [status.to_i, header, []]\n else\n [status.to_i, header, body]\n end\n end",
"def render_response\n response.headers['Content-Type'] = 'charset=utf-8'\n @resp = server.encode_response(@resp)\n return render_xml_response if is_xml_request?\n case @resp.code\n when OpenID::Server::HTTP_OK\n render :text => @resp.body, :status => 200\n when OpenID::Server::HTTP_REDIRECT\n redirect_to @resp.redirect_url\n else\n render :text => @resp.body, :status => 400\n end \n end",
"def retrieve_response_from_mimes(mimes, &block)\n responder = ActionController::MimeResponds::Responder.new(self)\n mimes = collect_mimes_from_class_level if mimes.empty?\n mimes.each { |mime| responder.send(mime) }\n block.call(responder) if block_given?\n\n if format = responder.negotiate_mime\n self.response.template.template_format = format.to_sym\n self.response.content_type = format.to_s\n self.formats = [ format.to_sym ]\n responder.response_for(format) || proc { default_render }\n else\n head :not_acceptable\n nil\n end\n end",
"def content_type\n ::MIME::Types.type_for(name).first.try(:content_type) || 'text/html'\n end",
"def parse_response\n if @http_response.body && @http_response.respond_to?(:headers) && @http_response.headers['Content-Type']\n if @http_response.headers['Content-Type'].include?('xml')\n parse_xml_response\n elsif @http_response.headers['Content-Type'].include?('json')\n parse_json_response\n end\n else\n parse_unknown_response\n end\n end",
"def format_response\n status_code = @response['status_code'] ||= 500\n template = @response['template'] ||= 'upload'\n if @@request.media_type == 'application/json'\n headers = {'Content-Type' => 'application/json'}\n body = JSON.dump(@response)\n elsif @response['media_type'] == 'application/plain'\n headers = {'Content-Type' => 'text/html'}\n body = @response['message']\n else\n headers = {'Content-Type' => 'text/html'}\n body = File.read('./app/views/header.erb')\n body << File.read(\"./app/views/#{template}.erb\")\n body << File.read('./app/views/footer.erb')\n body = ERB.new(body).result(binding)\n end\n output = []\n if body\n output << body\n end\n if output.empty?\n output << 'There was no response.'\n end\n [status_code, headers, output]\n end",
"def formatted_response(content_type, fallback: :none, **options)\n body = build_payload(**options)\n\n # TODO: Maybe make a helper to register these types?\n to_format = content_type.to_sym == :jsonapi ? \"to_json\" : \"to_#{content_type.to_sym}\"\n\n if content_type && body.respond_to?(to_format)\n formatted_body = body.public_send(to_format)\n format = content_type\n else\n case fallback.to_sym\n when :json\n formatted_body = body.to_json\n # FIXME: This won't work without Rails\n format = fallback\n when :none\n return nil\n else\n raise ArgumentError, \"unknown fallback=#{fallback}\"\n end\n end\n\n [status_code, formatted_body, format]\n end",
"def content_type(type, params={})\n type = Rack::File::MIME_TYPES[type.to_s] if type.kind_of?(Symbol)\n fail \"Invalid or undefined media_type: #{type}\" if type.nil?\n if params.any?\n params = params.collect { |kv| \"%s=%s\" % kv }.join(', ')\n type = [ type, params ].join(\";\")\n end\n response.header['Content-Type'] = type\n end",
"def getContent (type='chuck norris')\n getHtmlResult(type)\n end",
"def render(*args) #:nodoc:\n raise ::AbstractController::DoubleRenderError if response_body\n super\n end"
] | [
"0.8146179",
"0.7987508",
"0.785869",
"0.77699715",
"0.7687297",
"0.76619387",
"0.7649412",
"0.7580971",
"0.75760704",
"0.7572346",
"0.7454495",
"0.74275774",
"0.7408022",
"0.740662",
"0.7404474",
"0.7379969",
"0.73241127",
"0.7267427",
"0.72407204",
"0.71585613",
"0.7132146",
"0.712012",
"0.7028308",
"0.70275176",
"0.70275176",
"0.6937888",
"0.6885516",
"0.686226",
"0.68374574",
"0.67883164",
"0.6645223",
"0.66035265",
"0.6565992",
"0.65433764",
"0.6482479",
"0.64070827",
"0.640595",
"0.63858014",
"0.6367805",
"0.6361079",
"0.6361079",
"0.6335312",
"0.6321586",
"0.6288278",
"0.6283652",
"0.6243493",
"0.6243493",
"0.6228837",
"0.6217684",
"0.61902136",
"0.61771876",
"0.6158945",
"0.61365205",
"0.61364424",
"0.61278397",
"0.61067486",
"0.6072115",
"0.6047155",
"0.5999357",
"0.59766483",
"0.59649444",
"0.59508264",
"0.59508264",
"0.5939833",
"0.59347653",
"0.5932004",
"0.59292746",
"0.59262407",
"0.59240705",
"0.5915284",
"0.59008735",
"0.58898854",
"0.5844303",
"0.58434606",
"0.5814398",
"0.5812512",
"0.5809911",
"0.5799032",
"0.57956755",
"0.5791905",
"0.5790788",
"0.5769235",
"0.57630527",
"0.57619333",
"0.5736284",
"0.5731892",
"0.5722708",
"0.5718506",
"0.56981975",
"0.5694179",
"0.56859595",
"0.5685302",
"0.5682508",
"0.5681506",
"0.5672783",
"0.56671995",
"0.56605864",
"0.56588775",
"0.56437397",
"0.5642679"
] | 0.76790184 | 5 |
use this with the router to call action_name (:index, :show, :create...) | def invoke_action(name)
self.send(name)
render(name) unless already_built_response?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoke_action(name)\n end",
"def invoke_action(name)\n end",
"def invoke_action(name)\n end",
"def index\r\n list\r\n render_action 'list'\r\n end",
"def route_index; end",
"def index\n list\n render_action 'list'\n end",
"def method_for_action(action_name); end",
"def action\n \"index\"\n end",
"def invoke_action(name)\n # used for self-reflection in views\n @action = name\n\n send(name)\n end",
"def invoke_action(name)\n check_authenticity_token unless req.request_method == 'GET'\n self.send(name)\n self.render(name.to_s) unless already_built_response?\n end",
"def action\n end",
"def execute(*args)\n\n # Verify if the controller answers to the @action_name value\n raise WebFlowError, \"The action step #{@action_name} is not defined in your controller.\" unless args[0].respond_to? lookup_method_to_call(@action_name)\n \n # The controller defines a method with the same name as @action_name.\n # Kewl! A 'someone else problem' !!!\n args[0].send( lookup_method_to_call( @action_name ) )\n \n end",
"def actions\n ['index', 'show', 'new', 'create', 'edit', 'update', 'destroy']\n end",
"def action\n end",
"def actions; end",
"def action_name\n name = self.request.route_obj.instance_variable_get('@named').to_s\n name.gsub!(/^#{controller_name}_?/, '')\n name = 'index' if name == ''\n name\n end",
"def invoke_action(name)\n self.send(name)\n render(name.to_s) unless already_built_response?\n end",
"def index\n render :action => 'view'\n end",
"def action_name; end",
"def route_for(name, *args); end",
"def action\n args.first\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def run(req, res)\n #@action = :index\n #@method = :get\n #@pattern = /^\\/users$/\n #@class = DummyController\n \n @params = req.path\n #route_params = @params\n ControllerBase.new(req, res, @params).invoke_action(@method, @pattern, @class, @action)\n end",
"def index\n list\n #render :action => 'list'\n\n end",
"def invoke_action(name)\n # debugger\n self.send(name)\n render(name.to_s) unless already_built_response?\n end",
"def action args = {}\n\t\tend",
"def invoke_action(name)\n self.send(name)\n render unless self.already_built_response?\n\n end",
"def invoke_action(name)\n self.send(name)\n #Rails Magic: Default calls render on appropriate method even if the programmer doesn't :\n render(name) unless already_rendered?\n end",
"def action_missing(name, *args)\n if name == action_name\n perform\n else\n raise AbstractController::ActionNotFound\n end\n end",
"def run(req, res)\n @params = req.params\n controller_class.send(action_name)\n end",
"def index\n list\n render :action => 'list'\n end",
"def index\n list\n render :action => 'list'\n end",
"def index\n list\n render :action => 'list'\n end",
"def index\n list\n render :action => 'list'\n end",
"def index\n list\n render :action => 'list'\n end",
"def index\n list\n render :action => 'list'\n end",
"def index\n list\n render :action => 'list'\n end",
"def action\n if action_name == 'advanced_search'\n :post\n else\n :get\n end\n end",
"def action\n action_name.to_sym\n end",
"def index\n list\n render :action => 'list'\n # show\n # render :action => 'show'\n # render('list')\n end",
"def index\n list #call the action\n render('list') #render the correct template not 'index'\n end",
"def perform(action)\n case action\n when :index, :new then get action\n when :show, :edit then get action, id: 1\n when :update then put :update, id: 1\n when :create then post :create\n when :destroy then delete :destroy, id: 1\n end\n end",
"def invoke_action(name)\n send(name)\n render(name) unless already_built_response?\n end",
"def action(name)\n nil\n end",
"def lookup_action; end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def invoke_action(name)\n send(name)\n render(name) unless already_built_response?\n end",
"def action(name)\n action_method = \"action_#{name}\"\n return Actions.send(action_method) if Actions.respond_to?(action_method)\n nil\n end",
"def dispatch_action(req)\n controller = ROUTE_TO_CONTROLLER[req.path_info]\n raise Heartcheck::Errors::RoutingError if controller.nil?\n\n Logger.info \"Start [#{controller}] from #{req.ip} at #{Time.now}\"\n\n controller.new.index.tap do |_|\n Logger.info \"End [#{controller}]\\n\"\n end\n end",
"def index\n @my_actions = MyAction.all\n end",
"def invoke_action(path)\n controller(path).send(action_name)\n end",
"def _dispatch\n case @options[:action]\n when :init\n _init\n when :add\n fail 'No url given (-u option)' if @options[:url].empty?\n fail 'No name given (-n option)' if @options[:name].empty?\n _add\n when :delete\n fail 'No id given (-i option)' if @options[:id].nil?\n _delete\n when :list\n _list\n else\n fail \"Unknown action #{@options[:action]}\"\n end\n end",
"def perform(action)\n @action_name = action\n begin\n self.send(@action_name)\n rescue\n Skates.logger.error {\n \"#{$!}:\\n#{$!.backtrace.join(\"\\n\")}\"\n }\n end\n self.render\n end",
"def index\n render action:\"new\"\n end",
"def index; redirect_to :action => 'list'; end",
"def index\n \n redirect_to ( :action => \"list\")\n end",
"def method_missing(method_name, *args)\n action_method_name = _resolve_action_method_name(method_name)\n if action_method_name.nil?\n super\n else\n send(action_method_name, *args)\n end\n end",
"def action(*args,&block)\n name, options = _parse_name_and_options(args)\n command.action({:name=>name}.merge(options),&block)\n end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def index; end",
"def run(req, res)\n controller = controller_class.new(req, res, route_params(req))\n controller.invoke_action(action_name)\n end",
"def route\n #TODO\n end"
] | [
"0.734207",
"0.734207",
"0.7341121",
"0.7079497",
"0.70227414",
"0.696795",
"0.6943637",
"0.6920887",
"0.69136906",
"0.6890334",
"0.68671626",
"0.6824139",
"0.6813997",
"0.6774912",
"0.67631173",
"0.6758284",
"0.67041564",
"0.6686834",
"0.6681827",
"0.6678034",
"0.665475",
"0.66500854",
"0.66500854",
"0.66500854",
"0.66500854",
"0.66500854",
"0.6641654",
"0.664045",
"0.66402036",
"0.663344",
"0.6619336",
"0.66144526",
"0.65956104",
"0.6594935",
"0.6571212",
"0.6571212",
"0.6571212",
"0.6571212",
"0.6571212",
"0.6571212",
"0.6571212",
"0.65439177",
"0.65363085",
"0.651634",
"0.6514689",
"0.6500492",
"0.64877355",
"0.64705765",
"0.6469784",
"0.64565706",
"0.64565706",
"0.64565706",
"0.6446989",
"0.6423583",
"0.6415081",
"0.6414786",
"0.64137095",
"0.6408895",
"0.6392654",
"0.63900316",
"0.6388664",
"0.6385173",
"0.6375508",
"0.6370885",
"0.6369523",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6368402",
"0.6362316",
"0.63608617"
] | 0.6560247 | 42 |
Create a reference resolver, options: :identifier_resolver: a proc which is called with an identifier and which should return the associated element in case the identifier is not uniq, the proc may return multiple values default: lookup element in internal map | def initialize(options={})
@identifier_resolver = options[:identifier_resolver]
@identifier_map = {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve_local(options={})\r\n resolver = RGen::Instantiator::ReferenceResolver.new\r\n index.each do |i|\r\n resolver.add_identifier(i[0], i[1])\r\n end\r\n @unresolved_refs = resolver.resolve(unresolved_refs, :use_target_type => options[:use_target_type])\r\n end",
"def resolve(unresolved_refs, options={})\r\n problems = options[:problems] || []\r\n still_unresolved_refs = []\r\n failed_resolutions = options[:failed_resolutions] || {}\r\n unresolved_refs.each do |ur|\r\n if @identifier_resolver\r\n target = @identifier_resolver.call(ur.proxy.targetIdentifier)\r\n else\r\n target = @identifier_map[ur.proxy.targetIdentifier]\r\n end\r\n target = [target].compact unless target.is_a?(Array)\r\n if options[:use_target_type] \r\n feature = ur.element.class.ecore.eAllReferences.find{|r| r.name == ur.feature_name}\r\n target = target.select{|e| e.is_a?(feature.eType.instanceClass)}\r\n end\r\n if target.size == 1\r\n status = ResolutionHelper.set_uref_target(ur, target[0])\r\n if status == :success\r\n options[:on_resolve] && options[:on_resolve].call(ur, target[0])\r\n elsif status == :type_error\r\n ur.target_type_error = true\r\n problems << type_error_message(target[0])\r\n still_unresolved_refs << ur\r\n failed_resolutions[ur] = target[0]\r\n end\r\n elsif target.size > 1\r\n problems << \"identifier #{ur.proxy.targetIdentifier} not uniq\"\r\n still_unresolved_refs << ur\r\n failed_resolutions[ur] = target\r\n else\r\n problems << \"identifier #{ur.proxy.targetIdentifier} not found\"\r\n still_unresolved_refs << ur\r\n end\r\n end\r\n still_unresolved_refs\r\n end",
"def resolve_reference; end",
"def resolve(identifier, required:true)\n return nil if identifier.blank? && !required\n #todo: be smart about existance of 'internal_name', for now assume not called unless exists\n result = by_uuid(identifier) || find_by_internal_name(identifier)\n raise \"#{self.name} not found for identifier: #{identifier}\" if required && !result\n result\n end",
"def resolve_external(external_index, options)\r\n fragment_provider = options[:fragment_provider]\r\n resolver = RGen::Instantiator::ReferenceResolver.new(\r\n :identifier_resolver => proc {|ident| external_index[ident] })\r\n if fragment_provider\r\n @resolved_refs = {} if @resolved_refs.nil? || @resolved_refs == :dirty\r\n on_resolve = proc { |ur, target|\r\n target_fragment = fragment_provider.call(target)\r\n target_fragment ||= :unknown\r\n raise \"can not resolve local reference in resolve_external, call resolve_local first\" \\\r\n if target_fragment == self\r\n @resolved_refs[target_fragment] ||= []\r\n @resolved_refs[target_fragment] << ResolvedReference.new(ur, target)\r\n } \r\n @unresolved_refs = resolver.resolve(unresolved_refs, :on_resolve => on_resolve, :use_target_type => options[:use_target_type])\r\n else\r\n @unresolved_refs = resolver.resolve(unresolved_refs, :use_target_type => options[:use_target_type])\r\n end\r\n end",
"def resolve_object_ref(id)\n end",
"def create_references(source_name, attribute_name, options)\n matcher = options[:matcher] || /#([0-9]+)/i\n finder = options[:finder] || :find_by_id\n class_name = options[:class_name] || source_name.to_s.classify\n class_name = class_name.constantize\n collection = options[:collection] || class_name\n\n collection = collection.call(self) if collection.is_a?(Proc)\n\n text = self.send(attribute_name)\n\n object_ids_setter = \"#{source_name.to_s.singularize}_ids=\"\n\n oids = []\n if text =~ matcher\n matches = text.scan(matcher)\n matches.each do |match|\n if object = collection.send(finder, match)\n oids.push(object.id)\n end\n end\n end\n self.send(object_ids_setter, oids)\n end",
"def resolver\n unless resolvers.empty?\n resolvers.first\n else\n nil\n end\n end",
"def lookup(oid_or_ref_name)\n rugged.rev_parse(oid_or_ref_name)\n end",
"def resolver\n @resolver = Dnsruby::Resolver.new if @resolver==nil\n @resolver\n end",
"def resolve(ref)\n self.class.resolve(ref, context)\n end",
"def link_resolver(maybe_ref)\n @link_resolver ||= Prismic::LinkResolver.new(maybe_ref) do |doc|\n case doc.link_type\n when \"homepage\"\n root_path(ref: maybe_ref)\n when \"article\" # This type is special: the URL is built depending on the document's prismic.io bookmark\n case doc.id\n when api.bookmark(\"tour\")\n tour_path(ref: maybe_ref)\n when api.bookmark(\"pricing\")\n pricing_path(ref: maybe_ref)\n when api.bookmark(\"about\")\n about_path(ref: maybe_ref)\n when api.bookmark(\"faq\")\n faq_path(ref: maybe_ref)\n else\n raise \"Article of id #{doc.id} doesn't have a known bookmark\"\n end\n when \"argument\"\n tour_path(ref: maybe_ref) + \"#\" + doc.id\n when \"pricing\"\n pricing_path(ref: maybe_ref) + \"#\" + doc.id\n when \"author\"\n about_path(ref: maybe_ref) + \"#\" + doc.id\n when \"faq\"\n faq_path(ref: maybe_ref) + \"#\" + doc.id\n when \"blog\"\n blogpost_path(doc.id, doc.slug, ref: maybe_ref)\n else\n raise \"link_resolver doesn't know how to write URLs for #{doc.link_type} type.\"\n end\n end\n end",
"def resolve(options = {})\n if options[:ui]\n raise 'The UI object must be of type Molinillo::UI' unless options[:ui].is_a?(Molinillo::UI)\n ui = options[:ui]\n else\n require 'puppetfile-resolver/ui/null_ui'\n ui = PuppetfileResolver::UI::NullUI.new\n end\n provider = ResolutionProvider.new(@puppetfile, @puppet_version, ui, options)\n\n resolver = Molinillo::Resolver.new(provider, ui)\n begin\n result = resolver.resolve(dependencies_to_resolve)\n rescue Molinillo::VersionConflict => e\n # Wrap the Molinillo error\n new_e = PuppetfileResolver::Puppetfile::DocumentVersionConflictError.new(e)\n raise new_e, new_e.message, e.backtrace\n rescue Molinillo::CircularDependencyError => e\n # Wrap the Molinillo error\n new_e = PuppetfileResolver::Puppetfile::DocumentCircularDependencyError.new(@puppetfile, e)\n raise new_e, new_e.message, e.backtrace\n end\n ResolutionResult.new(result, @puppetfile)\n end",
"def define_resolution(resolution_name, options = {}, &block)\n resolution_type = options.delete(:type) || :simple\n\n resolve = create_or_return_resolution(resolution_name, resolution_type)\n\n resolve.options(options) unless options.empty?\n resolve.evaluate(&block) if block\n\n resolve\n rescue StandardError => e\n log.log_exception(\"Unable to add resolve #{resolution_name.inspect} for fact #{@name}: #{e.message}\")\n nil\n end",
"def resolve(link, id)\n resolver = Plowshare::Resolver.new(link, id, self)\n @resolvers << resolver\n end",
"def resolver; end",
"def resolve options = { timeout: Bildchen.timeout }\n if path = _resolve(uri.path, options)\n dupe = uri.dup\n dupe.path = path\n dupe.to_s\n end\n end",
"def resolve\n return self.ref.resolve\n end",
"def resolve\n return self.ref.resolve\n end",
"def resolve\n # puts \"Resolve with #{self} and name=#{self.name} and ref=#{self.ref.class}\"\n # First resolve the sub reference if possible.\n if self.ref.is_a?(RefName) then\n obj = self.ref.resolve\n # puts \"obj=#{obj}\"\n # Look into the object for the name.\n return obj.get_by_name(self.name)\n else\n # Look in the parent hierachy for the name.\n parent = self.parent\n # puts \"parent=#{parent}\"\n while parent\n # puts \"parent=#{parent}\"\n if parent.respond_to?(:get_by_name) then\n # puts \"get_by_name\"\n found = parent.get_by_name(self.name)\n # puts \"found\" if found\n return found if found\n end\n parent = parent.parent\n end\n # Not found.\n puts \"Not found!\"\n return nil\n end\n end",
"def resolve_json_reference(options, object, _field, reference_def)\n keys = nil\n reference_json = nil\n if reference_def[:metadata]\n key = reference_def[:metadata].key.to_sym\n if reference_def[:metadata].polymorphic?\n clazz = reference_def[:metadata].inverse_class_name.constantize\n else\n clazz = reference_def[:metadata].class_name.constantize\n end\n relation_class = if Mongoid::Compatibility::Version.mongoid7_or_newer?\n Mongoid::Association::Referenced::HasAndBelongsToMany::Proxy\n else\n Mongoid::Relations::Referenced::ManyToMany\n end\n\n if reference_def[:metadata].relation == relation_class\n object_ids = object.send(key)\n if object_ids\n reference_json = object_ids.map do |id|\n materialize_keys, json = materialize_json(options, clazz: clazz, id: id)\n keys = keys ? keys.merge_set(materialize_keys) : materialize_keys\n json\n end.compact\n else\n object_ids = []\n end\n end\n end\n # If we get to this point and reference_json is still nil, there's no chance we can\n # load the JSON from cache so we go ahead and call as_json on the object.\n unless reference_json\n reference_def_definition = reference_def[:definition]\n reference = reference_def_definition.is_a?(Symbol) ? object.send(reference_def_definition) : reference_def_definition.call(object)\n reference_json = nil\n if reference\n if reference.respond_to?(:as_json_partial)\n reference_keys, reference_json = reference.as_json_partial(options)\n keys = keys ? keys.merge_set(reference_keys) : reference_keys\n else\n reference_json = reference.as_json(options)\n end\n end\n end\n [keys, reference_json]\n end",
"def locate_internal_refs1(refs, identifier, ident)\n #file, _filename = targetfile(filedesc, read: true)\n file, _filename = @files.targetfile_id(ident, read: true)\n xml = Nokogiri::XML(file) { |config| config.huge }\n t = xml.xpath(\"//*/@id\").each_with_object({}) { |i, x| x[i.text] = true }\n refs.each do |schema, ids|\n ids.keys.select { |id| t[id] }.each do |id|\n n = xml.at(\"//*[@id = '#{id}']\") and\n n.at(\"./ancestor-or-self::*[@type = '#{schema}']\") and\n refs[schema][id] = identifier\n end\n end\n end",
"def resolve_single_reference(reference)\n plugin_name = reference['_plugin']\n hook = get_hook(plugin_name, :resolve_reference)\n\n begin\n validate_proc = get_hook(plugin_name, :validate_resolve_reference)\n rescue PluginError\n validate_proc = proc { |*args| }\n end\n\n validate_proc.call(reference)\n\n begin\n # Evaluate the plugin and then recursively evaluate any plugin returned by it.\n hook.call(reference)\n rescue StandardError => e\n loc = \"resolve_reference in #{plugin_name}\"\n raise PluginError::ExecutionError.new(e.message, plugin_name, loc)\n end\n end",
"def resolver\n @resolver ||= Resolver.new @cache, @git_resolver\n end",
"def reg_resolve(key)\n return key unless Utils.ident?(key)\n\n spec = @registry_ref.value[key]\n\n if Utils.ident?(spec)\n deep_resolve(registry, spec)\n else\n spec\n end\n end",
"def add_resolver(single)\r\n @single_resolvers.push(single)\r\n end",
"def resolve_refs!\n name_of_last_ref = nil\n lookup_refs.each_with_index do |ref,z|\n @settings = two_layer_merge(@settings, ref.settings)\n @children.merge!(ref.children)\n name_of_last_ref = ref.name\n end\n if @settings[:path].nil? && !name_of_last_ref.nil?\n @settings[:path] = name_of_last_ref.to_s\n end\n @settings.delete :ref\n return self\n end",
"def resolved_ref\n \"resolved-#{ref}\"\n end",
"def resolve(key, identifier: false)\n if identifier\n key_identifier = find(Regexp.new(key.to_s)).map(&:name).last\n OpenStruct.new @contexts.values.detect{|hash| hash[:name].to_s == key_identifier.to_s}\n else\n OpenStruct.new @contexts.values.detect{|hash| hash[:name].to_s == key.to_s}\n end\n \n end",
"def reference\n [:item, identifier.to_s]\n end",
"def reference\n [:item, identifier.to_s]\n end",
"def resolve(key, &block)\n config.resolver.call(_container, key, &block)\n end",
"def auto_reference(value)\n if value.is_a?(Array)\n return value.map { |v| auto_reference(v) }\n end\n\n if value.is_a?(Entity)\n # If it's from another crate, need to add it to this one.\n crate.add_contextual_entity(value)\n\n return value.reference\n end\n\n value\n end",
"def resolve_name(lookup_name, lookup_types=[Dnsruby::Types::A, Dnsruby::Types::CNAME, Dnsruby::Types::PTR])\n resolve_names(lookup_name,lookup_types).first\n end",
"def create_ns_resolver( node_resolver )\n XPathNSResolver.new( node_resolver )\n end",
"def lookup\n @lock.with_read_lock do\n recalculate unless @options[:lookup]\n @lookup ||= @options[:lookup].map { |code| self.class.new(code) }.uniq\n end\n end",
"def reference\n [ type, identifier ]\n end",
"def lookup(options)\n raise 'todo'\n end",
"def resolve_name(lookup_name, lookup_types=[Dnsruby::Types::AAAA, Dnsruby::Types::A, Dnsruby::Types::CNAME, Dnsruby::Types::PTR])\n resolve_names(lookup_name,lookup_types).first\n end",
"def find_or_create_ref(opts)\n\t\tret = {}\n\t\tret[:ref] = get_ref(opts[:name])\n\t\treturn ret[:ref] if ret[:ref]\n\n\t\ttask = queue(Proc.new {\n\t\t\tref = Ref.find_or_initialize_by_name(opts[:name])\n\t\t\tif ref and ref.changed?\n\t\t\t\tref.save!\n\t\t\tend\n\t\t\tret[:ref] = ref\n\t\t})\n\t\treturn nil if task.wait() != :done\n\t\treturn ret[:ref]\n\tend",
"def resolve(id)\n case id\n when SHA, nil then id\n else rev_parse(id).first\n end\n end",
"def resolve_reference_string(ref)\n resolve_reference(Nidyx::Pointer.new(ref).path) if ref\n end",
"def lookup(arg)\n instance = lookup_without_default(arg)\n instance ||= build_default(arg)\n instance.value_serialized = property_serialized?(arg)\n\n owner = proxy_association.owner\n\n instance.send(\"#{association_class.owner_class_sym}=\", owner) if owner.new_record?\n instance\n end",
"def resolve(curie_or_uri)\n ns, short_name = split_curie curie_or_uri\n\n if ns && (namespaces.has_key? ns)\n namespaces[ns].expand(rel: short_name).to_s\n else\n curie_or_uri\n end\n end",
"def resolve\n api_call(\"resolve\")\n self\n end",
"def ref(id, options={})\n add Reference.new(resource, id, options)\n end",
"def resolve\n end",
"def resolve(parser)\n end",
"def find_resolver_from_model(model)\n @resolver_from_model[model]\n end",
"def resolve_id id\n lazy_load_strings\n @strings_xml[id]\n end",
"def get_lookup(name)\n @lookups = {} unless defined?(@lookups)\n @lookups[name] = spawn_lookup(name) unless @lookups.include?(name)\n @lookups[name]\n end",
"def new_reference(options={}, &block)\n save = options.delete(:save)\n\n if options[:cited_paper] && !options.has_key?(:uri) && options[:cited_paper].uri\n options[:uri] = options[:cited_paper].uri\n end\n\n if options[:number]\n options[:uri] = \"http://example.org/#{options[:number]}\" unless options.has_key?(:uri)\n options[:ref_id] = \"ref.#{options[:number]}\" unless options.has_key?(:ref_id)\n end\n\n if !options.has_key?(:cited_paper)\n uri = options[:uri]\n bib = options.delete(:bibliographic)\n options[:cited_paper] = Paper.new(uri:uri, bibliographic:bib)\n end\n\n result = Reference.new(options)\n\n if block_given?\n if block.arity==0\n result.instance_eval &block\n else\n yield self\n end\n end\n\n result.save! if save\n result\n end",
"def resolve( name )\n name = name.name if name.is_a?(Name)\n \n if @pattern_defs.member?(name) then\n return @pattern_defs[name]\n elsif @rule_defs.member?(name) then\n return @rule_defs[name]\n elsif @group_defs.member?(name) then\n return @group_defs[name]\n end\n \n return nil\n end",
"def resolve(param)\n return param unless param.is_a?(Symbol)\n return (@resolver || DEFAULT_RESOLVER).call(param)\n end",
"def resolve(link); end",
"def create_lookups( nodes )\n\t\t\treturn nodes.each_with_object( {} ) do |(identifier, node), hash|\n\t\t\t\tself.log.debug \"Creating lookup for node: %p\" % [ node ]\n\t\t\t\tname = node['name'] or next\n\t\t\t\trecord_type = node['record_type'] || 'A'\n\t\t\t\trecord_class = Resolv::DNS::Resource::IN.const_get( record_type ) or\n\t\t\t\t\traise \"Unsupported record type %p!\" % [ record_type ]\n\n\t\t\t\tself.log.debug \"Looking up %s record for %s (%s)\" % [ record_type, name, identifier ]\n\t\t\t\tthr = Thread.new do\n\t\t\t\t\tself.resolver.getresources( name, record_class )\n\t\t\t\tend\n\t\t\t\thash[ thr ] = identifier\n\t\t\tend\n\t\tend",
"def lookup\n InternalId.find_by(**scope, usage: usage_value)\n end",
"def resolution(name)\n return nil if name.nil?\n\n @resolves.find { |resolve| resolve.name == name }\n end",
"def new_reference(options={}, &block)\n save = options.delete(:save)\n\n if options[:number]\n options[:ref_id] = \"ref.#{options[:number]}\" unless options.has_key?(:ref_id)\n end\n\n if !options.has_key?(:cited_paper)\n uri = options.delete(:uri) || mk_random_uri\n bib = options.delete(:bibliographic)\n options[:cited_paper] = Paper.new(uri:uri, bibliographic:bib)\n end\n\n result = Reference.new(options)\n\n if block_given?\n if block.arity==0\n result.instance_eval &block\n else\n yield self\n end\n end\n\n result.save! if save\n result\n end",
"def resolve(resource, position:)\n case position\n when :subject\n return nil unless resource.literal?\n RDF::Literal(resource.as_number.floor)\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def get_config_var_resolver(variable_id)\n path = \"/d2l/api/lp/#{$lp_ver}/configVariables/#{variable_id}/resolver\"\n _get(path)\nend",
"def call\n reference_objects = if cache_reponse = @redis.hget(@collection_identifier, @collection_params)\n from_cache(cache_reponse)\n else\n from_query\n end\n\n ReferencesMap.new(@aggregator, reference_objects)\n end",
"def resolve\n @resolved_entity ||= @type.fetch_by_id(@id)\n @_version = @resolved_entity._version\n @resolved_entity\n end",
"def resolver(fqdn)\n dns = Resolv.new([Resolv::DNS.new( :nameserver => @resolvers, :search => [] )])\n\n # attempt to get address of fqdn\n x = dns.getaddresses(fqdn)\n rescue Resolv::ResolvError\n # move on\n rescue Errno::ENETUNREACH \n raise DomainError.new \"Host #{fqdn} unreachable\"\n else\n x\n end",
"def ror_or_fundref_to_identifier(scheme_name:, value:)\n return nil if org_id.present? && value.present? && scheme_name.present?\n\n scheme = IdentifierScheme.find_by(name: scheme_name)\n return nil if scheme.blank?\n\n Identifier.new(identifier_scheme: scheme, value: value)\n end",
"def resolve(locale, object, subject, options = T.unsafe(nil)); end",
"def resolve(resource, position:)\n case position\n when :subject\n return nil unless resource.literal?\n as_literal(Math.acosh(resource.as_number.object))\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def resolve\n Saml2::ArtifactResolver(source_id).resolve(self)\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n RDF::Literal(as_literal(resource.first).to_s, datatype: resource.last)\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def resolve_lexically(resolver, val, ctx)\n case val\n when Hash\n new = {}\n\n val.each do |k, v|\n new[k] = resolve_lexically(resolver, v, [val] + ctx)\n end\n\n new\n when Array\n val.collect do |v|\n resolve_lexically(resolver, v, ctx)\n end\n when String\n val.gsub(/\\$\\{([^\\}]+)\\}/) do\n resolve_symbol(resolver, $1, ctx)\n end\n else\n val\n end\n end",
"def lookup_lvalue(id)\n v = CompanyLookup.find_by_id(id)\n v.lvalue if v\n end",
"def lookup_id(arg)\n all_by_id[arg]\n end",
"def resolve\n self # simple Check never has references\n end",
"def resolve_uri(uri)\n rule = @rules.find { |r| r.match?(uri) }\n if rule\n rule.extract(uri)\n else\n raise Acoustic::UnresolvableUri.new(uri)\n end\n end",
"def lookup(mapping, type, reference)\n return reference unless String === reference\n data = mapping[reference]\n @errors << \"Reference to a missing #{type}: #{reference}\" unless data\n return data\n end",
"def resolve(object, arguments, context)\n @resolve_proc.call(object, arguments, context)\n end",
"def resolve(value); end",
"def resolve(dns_records, lookup_chain, domain)\n value = dns_records[domain]\n if(value == nil)\n puts \"Error: record not found for #{domain}\"\n exit\n\n elsif(value[:type] == \"A\")\n lookup_chain.push(value[:target])\n return lookup_chain\n\n elsif(value[:type] == \"CNAME\")\n lookup_chain.push(value[:target])\n return resolve(dns_records, lookup_chain, value[:target])\n \n end\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n RDF::Literal(as_literal(resource.first).to_s, language: resource.last.to_s.to_sym)\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def fetch_reference_by_id(id)\n Association::LazyEntityReference.new(id, self)\n end",
"def with_identifier(value)\n value = [value] if value.class == String\n t = Identifier.arel_table\n a = t[:cached].eq_any(value)\n self.joins(:identifiers).where(a.to_sql).references(:identifiers)\n end",
"def each_resolver(&blk) # :yields: anAID\n resolvers.each(&blk)\n end",
"def resolve link\n @agent.resolve link\n end",
"def lookup(field)\n id = field.to_s\n Server.new_instance self, collection.find_one(id)\n rescue BSON::InvalidObjectId\n Server.new_instance self, collection.first(:display_name => field) || collection.first(:link => field)\n end",
"def resolve_references(obj)\n case obj\n when PDF::Reader::Stream then\n obj.hash = resolve_references(obj.hash)\n obj\n when PDF::Reader::Reference then\n resolve_references(@xref.object(obj))\n when Hash then obj.each { |key,val| obj[key] = resolve_references(val) }\n when Array then obj.collect { |item| resolve_references(item) }\n else\n obj\n end\n end",
"def get_proxy(identifier); end",
"def get_proxy(identifier); end",
"def resolve\n @schema.resolve_check @ref\n end",
"def initialize( options=DEFAULT_OPTIONS )\n\t\t\toptions = DEFAULT_OPTIONS.merge( options || {} )\n\n\t\t\toptions.each do |name, value|\n\t\t\t\tself.public_send( \"#{name}=\", value )\n\t\t\tend\n\n\t\t\t@resolver = Resolv::DNS.new\n\t\tend",
"def resolve(context, path)\n factory = @parser.parse_string(path)\n v = resolve_any(factory.model.body, context, path)\n v.is_a?(Builder) ? v.resolve : v\n end",
"def resolution(name)\n return nil if name.nil?\n\n @resolves.find { |resolve| resolve.name == name }\n end",
"def resolve\n raise NotImplementedError, 'You must be implement \"resolve\" method.'\n end",
"def resolve(resource, position: :subject)\n case position\n when :subject\n return nil unless resource.literal? || resource.uri?\n begin\n repo = RDF::N3::Repository.new\n repo << RDF::Reader.open(resource, **@options.merge(list_terms: true, base_uri: resource, logger: false))\n content_hash = repo.statements.hash # used as name of resulting formula\n form = RDF::N3::Algebra::Formula.from_enumerable(repo, graph_name: RDF::Node.intern(content_hash))\n log_debug(NAME) {\"form hash (#{resource}): #{form.hash}\"}\n form\n rescue IOError, RDF::ReaderError => e\n log_error(NAME) {\"error loading #{resource}: #{e}\"}\n nil\n end\n when :object\n return nil unless resource.literal? || resource.variable?\n resource\n end\n end",
"def dependency_resolver_set # :nodoc:\n return Gem::Resolver::IndexSet.new self if 'file' == uri.scheme\n\n fetch_uri = if uri.host == \"rubygems.org\"\n index_uri = uri.dup\n index_uri.host = \"index.rubygems.org\"\n index_uri\n else\n uri\n end\n\n bundler_api_uri = enforce_trailing_slash(fetch_uri)\n\n begin\n fetcher = Gem::RemoteFetcher.fetcher\n response = fetcher.fetch_path bundler_api_uri, nil, true\n rescue Gem::RemoteFetcher::FetchError\n Gem::Resolver::IndexSet.new self\n else\n Gem::Resolver::APISet.new response.uri + \"./info/\"\n end\n end",
"def link_identifier(**options)\n value = options[:value].is_a?(Array) ? options[:value].first : options[:value]\n url = AcademicCommons.identifier_url(value)\n [link_to(url, url)]\n end",
"def reference(*args_or_name, block)\n # Check the args\n def_args = extract_definition_args(args_or_name)\n require_arg def_args, :name\n # puts \"reference #{def_args}\"\n name = def_args[:name]\n return unless version_wanted(def_args)\n\n raise \"polymorphic reference #{name} must specify :type and :for\" if def_args.key?(:for) ^ def_args.key?(:type)\n\n if def_args.key?(:for) && def_args.key?(:type)\n ref_type = def_args[:type]\n return unless ref_type.to_s == def_args[:for].to_s.camelize # Skip where the polymorph isn't us\n end\n\n # This reference is to be generated\n\n @put_stack.push(reference_record = new_h)\n block.call\n @put_stack.pop\n\n raise \"reference #{name} must yield a block returning hash\" unless reference_record.is_a?(Hash)\n raise \"reference #{name} must yield a hash with an :id\" unless reference_record.key?(:id)\n\n unless def_args[:link_id] == false\n ref_id = reference_record[:id]\n put_field \"#{name}_id\", ref_id\n end\n\n if def_args.key?(:type)\n put_field \"#{name}_type\", ref_type if def_args.key?(:generate_from_type) # TODO: doc\n ref_key = ref_type.to_s.underscore.pluralize\n else\n ref_key = name\n end\n\n (@references[ref_key] ||= Set.new) << reference_record\n end",
"def ref(reference)\n Ref.new(reference)\n end",
"def resolve(namespace, name, inheritance = T.unsafe(nil), proxy_fallback = T.unsafe(nil), type = T.unsafe(nil)); end",
"def lookup(field)\n id = BSON::ObjectId(field.to_s)\n Server.new_instance self, collection.find_one(id)\n rescue BSON::InvalidObjectId\n Server.new_instance self, collection.find_one({ :display_name=>field }) || collection.find_one({ :link=>field })\n end",
"def resolve(resource, position:)\n case resource\n when RDF::Query::Variable then resource\n when RDF::Literal\n case position\n when :subject\n as_literal(Math.sin(resource.as_number.object))\n when :object\n as_literal(Math.sinh(resource.as_number.object))\n end\n else\n nil\n end\n end"
] | [
"0.68053854",
"0.6335437",
"0.6183314",
"0.5975405",
"0.596767",
"0.5909224",
"0.5889479",
"0.5782354",
"0.5683273",
"0.56790835",
"0.5677379",
"0.5665979",
"0.5617914",
"0.5509146",
"0.5482542",
"0.5465393",
"0.5461956",
"0.54489076",
"0.54489076",
"0.5427035",
"0.53324634",
"0.5324214",
"0.5279859",
"0.5268268",
"0.5264883",
"0.52527976",
"0.5225288",
"0.5222607",
"0.52128553",
"0.51860946",
"0.51860946",
"0.518056",
"0.5169793",
"0.5143986",
"0.5107013",
"0.5103007",
"0.5102139",
"0.5083283",
"0.5044175",
"0.50396",
"0.5037496",
"0.5030031",
"0.5028312",
"0.5019947",
"0.5018192",
"0.5014234",
"0.5005012",
"0.50018907",
"0.49923763",
"0.4989007",
"0.49883243",
"0.498648",
"0.49730885",
"0.4957226",
"0.49564895",
"0.49406958",
"0.49350604",
"0.4930257",
"0.4922935",
"0.4899499",
"0.48961124",
"0.48946506",
"0.48941156",
"0.48870507",
"0.48827967",
"0.48807105",
"0.48805824",
"0.48762968",
"0.48741764",
"0.4869327",
"0.48643368",
"0.48608246",
"0.48584872",
"0.48561132",
"0.48550525",
"0.48340335",
"0.48298445",
"0.48260954",
"0.48246396",
"0.4823827",
"0.481822",
"0.4817508",
"0.4815694",
"0.48046502",
"0.47809643",
"0.4779231",
"0.4779231",
"0.4774445",
"0.4770819",
"0.47684154",
"0.4764283",
"0.47630307",
"0.4753698",
"0.47500536",
"0.47462904",
"0.47413126",
"0.47391275",
"0.47252795",
"0.4717257",
"0.4713081"
] | 0.5898166 | 6 |
Add an +identifer+ / +element+ pair which will be used for looking up unresolved identifers | def add_identifier(ident, element)
map_entry = @identifier_map[ident]
if map_entry
if map_entry.is_a?(Array)
map_entry << element
else
@identifier_map[ident] = [map_entry, element]
end
else
@identifier_map[ident] = element
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_identifier(val)\n return if val.nil?\n @identifiers.push(self.class.normalize_id(val)) unless @identifiers.index(self.class.normalize_id(val))\n end",
"def identify(sym, vals=nil)\n if vals.nil?\n identifiers_hash[sym]\n else\n identifiers_hash[sym] = vals\n end\n end",
"def identifier_map(id, name, id_map)\n if !id_map.include? id\n id_map[id] = name\n end \nend",
"def add_identifier(sym)\n raise Emittance::InvalidIdentifierError, 'Identifiers must respond to #to_sym' unless sym.respond_to?(:to_sym)\n\n lookup_strategy.register_identifier self, sym.to_sym\n end",
"def plus(elem)\n self.class.new(\"#{@name}[#{elem.name}]\", \"#{@id}:#{elem.options[:id] || elem.name}\")\n end",
"def insert_identifier(opts={})\n type = nil\n if !opts[:identifierType].nil?\n type = opts[:identifierType]\n end\n value = nil\n if !opts[:identifierValue].nil?\n value = opts[:identifierValue]\n end\n node = MedusaPremis::Datastream::RepresentationObjectDs.identifier_template(type, value)\n nodeset = self.find_by_terms(:identifier)\n\n unless nodeset.nil?\n if nodeset.empty?\n self.ng_xml.root.add_child(node)\n index = 0\n else\n nodeset.after(node)\n index = nodeset.length\n end\n # deprecated...\n # self.dirty = true\n end\n return node, index\n end",
"def add_info_on_tag_ids\n desc_hash = Notion.where(locale: @lecture.locale || I18n.default_locale)\n .pluck(:title, :tag_id, :aliased_tag_id)\n .map { |x| [x.first.downcase, x.second || x.third] }\n .select { |x| x.first.in?(@content_descriptions.map(&:downcase)) }\n .to_h\n @content.each do |c|\n c['tag_id'] = desc_hash[c['description'].downcase]\n end\n end",
"def insert_identifier(opts={})\n type = nil\n if !opts[:identifierType].nil?\n type = opts[:identifierType]\n end\n value = nil\n if !opts[:identifierValue].nil?\n value = opts[:identifierValue]\n end\n node = MedusaPremis::Datastream::AgentDs.identifier_template(type, value)\n nodeset = self.find_by_terms(:identifier)\n\n unless nodeset.nil?\n if nodeset.empty?\n self.ng_xml.root.add_child(node)\n index = 0\n else\n nodeset.after(node)\n index = nodeset.length\n end\n # deprecated... \n # self.dirty = true\n end\n return node, index\n end",
"def associate_by_identity(ast, comments); end",
"def associate_by_identity(ast, comments); end",
"def associate_by_identity(ast, comments); end",
"def id_elements(*element_names)\n options = element_names.extract_options!\n\n patterned_elements \"\\#%{element_name}\", *element_names, options.slice(:element_array)\n end",
"def insert_identifier(opts={})\n node = Medusa::Premis::Agent.identifier_template\n nodeset = self.find_by_terms(:agentIdentifier)\n \n unless nodeset.nil?\n if nodeset.empty?\n self.ng_xml.root.add_child(node)\n index = 0\n else\n nodeset.after(node)\n index = nodeset.length\n end\n self.dirty = true\n end\n \n return node, index\n end",
"def identifier(id)\n Registry.add(id.to_s, self)\n @id = id\n end",
"def register_identifier(klass:, identifier:)\n raise Emittance::InvalidIdentifierError unless valid_identifier? identifier\n raise Emittance::IdentifierCollisionError if identifier_reserved? identifier, klass\n\n identifier_to_klass_mappings[identifier] = klass\n\n klass_to_identifier_mappings[klass] ||= empty_collection\n klass_to_identifier_mappings[klass] << identifier\n\n klass\n end",
"def ident_key\n :ident\n end",
"def add_elem(elem)\n # (native code) \n end",
"def synonym(new_symbol, existing_symbol)\n element = self[existing_symbol]\n @unordered_elements[conform_to_symbol(new_symbol)] = element\n end",
"def add_rpx_identifier( rpx_id, rpx_provider_name )\n\t\t self.rpx_identifiers.build(:identifier => rpx_id, :provider_name => rpx_provider_name )\n end",
"def add_elem(elem)\n # (native code)\n end",
"def add_elem(elem)\n # (native code)\n end",
"def add_elem(elem)\n # (native code)\n end",
"def add_elem(elem)\n # (native code)\n end",
"def add_elem(elem)\n # (native code)\n end",
"def add_elem(elem)\n # (native code)\n end",
"def _insert_values\n identifier_hash(super)\n end",
"def identifiers(ident, prefix='')\n identify(ident).map{|sym| \"#{prefix}#{sym}\"}\n end",
"def element_id what\n \"#{object_type}_#{what}\"\n end",
"def element_add\r\n @env.issue.element_add @meta.element_add ElementAdd.new(@env).insert @is.element_add\r\n end",
"def insert(symbol, identifier,value)\n\t\tif !@symbols.has_key?(identifier)\n\t\t\t@symbols[identifier] = [symbol,value]\n\t\t\treturn false\n\t\telse\n\t\t\tputs \"Identificador: #{identifier}, declarado dos veces en un mismo alcance:\"\n\t\t\treturn true\n\t\tend\n\tend",
"def add_to_cache\n redis.hset 'identifiers', self.typed_id, item.typed_id\n redis.sadd 'identifier:' + item.typed_id, self.typed_id\n end",
"def id_check(el, id, base)\n if NC_REGEXP.match(id)\n # ID may only be specified once for the same URI\n if base\n uri = URIRef.intern(\"##{id}\", base, :normalize => false)\n if @id_mapping[id] && @id_mapping[id] == uri\n warn = \"ID addtribute '#{id}' may only be defined once for the same URI\"\n add_debug(el, warn)\n raise RdfContext::ParserException.new(warn) if @strict\n end\n \n @id_mapping[id] = uri\n # Returns URI, in this case\n else\n id\n end\n else\n warn = \"ID addtribute '#{id}' must be a NCName\"\n add_debug(el, \"ID addtribute '#{id}' must be a NCName\")\n add_debug(el, warn)\n raise RdfContext::ParserException.new(warn) if @strict\n nil\n end\n end",
"def insert_linking_identifier(opts={})\n node = Medusa::Premis::Agent.linking_identifier_template\n nodeset = self.find_by_terms(:linkingIdentifier)\n\n unless nodeset.nil?\n if nodeset.empty?\n self.ng_xml.root.add_child(node)\n index = 0\n else\n nodeset.after(node)\n index = nodeset.length\n end\n self.dirty = true\n end\n\n return node, index\n end",
"def add_identification_new_order(xml, options)\n requires!(options, :order_id)\n xml.Identification do\n xml.TransactionID options[:order_id]\n end\n end",
"def on_ident(name, ((line, column)))\n add_variable(name, line, column)\n end",
"def add_with_id item\n id = @id_gen.gen\n #here we automatically mix in the IdManaged protocol\n item.extend IdManaged\n item.id_manager = self\n item.pool_id =id\n @arr << item\n end",
"def unify(elt)\n unless self.class::UNIFICATIONS.any?{|name| __send__(name, elt)}\n @elements.add(elt)\n end\n end",
"def add_as_element(html,id,arr)\n html.elements.each(x_path(id)) do |tag|\n arr.push( tag[0].to_s )\n end\n end",
"def add_id name, value\n context.add_id name, value\n define_singleton_method(name) { value }\n end",
"def add_docidentifier\n @bib.docidentifier.each do |i|\n case i.type\n when \"isbn\" then @item.isbn = i.id\n when \"lccn\" then @item.lccn = i.id\n when \"issn\" then @item.issn = i.id\n end\n end\n end",
"def attach_identifiers(provenance:, affiliation:, result: {}, json: {})\n return affiliation unless affiliation.new_record?\n\n ror_prov = Provenance.where(name: 'ror').first\n\n # First use any identifiers returned by ROR\n if ror_prov.present? && result.present? && (result[:ror].present? || result[:fundref].present?)\n if result[:ror].present?\n affiliation.identifiers << ::Identifier.find_or_initialize_by(\n provenance: ror_prov, category: 'ror', descriptor: 'is_identified_by',\n value: \"https://ror.org/#{result[:ror]}\", identifiable_type: 'Affiliation'\n )\n end\n if result[:fundref].present?\n affiliation.identifiers << ::Identifier.find_or_initialize_by(\n provenance: ror_prov, category: 'fundref', descriptor: 'is_identified_by',\n value: \"https://api.crossref.org/funders/#{result[:fundref]}\",\n identifiable_type: 'Affiliation'\n )\n end\n end\n\n # Otherwise take any identifiers passed in the JSON\n id = json.fetch(:affiliation_id, json.fetch(:funder_id, {}))\n if id.present? && id[:identifier].present?\n identifier = Api::V0::Deserialization::Identifier.deserialize(\n provenance: provenance, identifiable: affiliation, json: id\n )\n affiliation.identifiers << identifier if identifier.present? && identifier.new_record?\n end\n affiliation\n end",
"def save_unresolved(obj,attrib,val)\n\t\t# Add it to a table storing unresolved objects\n\t\tbadone = UnresolvedId.new do |u|\n\t\t\tu.source = @source\n\t\t\tu.object_class = obj.class.name\n\t\t\tu.parameter = attrib\n\t\t\tu.val = val\n\t\tend\n\n\t\t# save it to a stack. We'll store it when the object gets an ID\n\t\t@unresolved_ids.push(badone)\n\n\t\tputs 'Added '+attrib+' to resolution list. Fail.' if Debug > 3\n\tend",
"def register_identifier(klass, identifier)\n Emittance::EventLookup::Registry.register_identifier klass: klass, identifier: identifier\n end",
"def register_for(id); end",
"def extract_multivalued_element(element_prefix, element_name)\n i = 0\n path = \"//foxml:datastream[@ID='RELS-EXT']/foxml:datastreamVersion\"\\\n \"[@ID='#{@current_rels_ext_version}']/foxml:xmlContent/rdf:RDF/\"\\\n \"rdf:Description/#{element_prefix}:#{element_name}/@rdf:resource\"\n @doc.xpath(path, @ns).each do |s|\n i += 1\n keyname = element_name.downcase\n keyname += i.to_s\n keyname = keyname.to_sym\n @key_metadata[keyname] = s.to_s\n end\n end",
"def add_new_element(lines_number, lines_content)\n\t\tnew_element_hash = {modify_nodes: [], add_nodes: [], remove_nodes: [], modify_edges: [], remove_edges: [], add_edges: []}\n\t\t\n\t\tlines_number.zip(lines_content).each do |number, content|\n\t\t\tnew_element_hash = merge_two_hashes(new_element_hash , insert_element(number, content))\n\t\tend\n\t\treturn uniqify_arrays_in_hash(new_element_hash, :id)\n\n\tend",
"def add_id\n @item.key = @bib.id\n end",
"def <<(element)\n if element.nil?\n pair = [0,NilClass]\n else\n if element.new?\n pair = [element,element.class]\n else\n pair = [element.rod_id,element.class]\n end\n end\n index = @size\n @map[index] = @added.size\n @added << pair\n #@commands << [:append, pair]\n @size += 1\n end",
"def add(element)\n @element_list << element\n end",
"def add(item)\n self[to_identifier(item)] = item\n end",
"def locate_internal_refs1(refs, identifier, ident)\n #file, _filename = targetfile(filedesc, read: true)\n file, _filename = @files.targetfile_id(ident, read: true)\n xml = Nokogiri::XML(file) { |config| config.huge }\n t = xml.xpath(\"//*/@id\").each_with_object({}) { |i, x| x[i.text] = true }\n refs.each do |schema, ids|\n ids.keys.select { |id| t[id] }.each do |id|\n n = xml.at(\"//*[@id = '#{id}']\") and\n n.at(\"./ancestor-or-self::*[@type = '#{schema}']\") and\n refs[schema][id] = identifier\n end\n end\n end",
"def append_identifier part, looping_identifier\n part.id.to_s + (looping_identifier.present? ? \"_#{looping_identifier}\" : \"_0\")\n end",
"def insert_agent_identifier(opts={})\n type = nil\n if !opts[:agent_identifierType].nil?\n type = opts[:agent_identifierType]\n end\n value = nil\n if !opts[:agent_identifierValue].nil?\n value = opts[:agent_identifierValue]\n end\n node = PremisAgentDatastream.agent_identifier_template(type, value)\n nodeset = self.find_by_terms(:agent_identifier)\n\n unless nodeset.nil?\n if nodeset.empty?\n self.ng_xml.root.add_child(node)\n index = 0\n else\n nodeset.after(node)\n index = nodeset.length\n end\n # deprecated... \n # self.dirty = true\n end\n \n return node, index\n end",
"def external_id_definition(attr_name, access_by: nil)\n attr_name = attr_name.to_sym\n\n results = if access_by\n external_id_definitions_access_by(access_by)\n else\n external_id_definitions\n end\n\n results[attr_name]\n end",
"def add_ids(code, id)\n code.freeze\n code = id + \" #{code} #{id}\"\n code\n end",
"def add_alternative_id_method(attr_name)\n define_method attr_name.to_sym do\n alternative_id_value attr_name\n end\n end",
"def attach_identifier(provenance:, contributor:, json: {})\n id = json.fetch(:contributor_id, json.fetch(:contact_id, {}))\n return contributor unless id[:identifier].present?\n\n identifier = Api::V0::Deserialization::Identifier.deserialize(\n provenance: provenance, identifiable: contributor, json: id\n )\n contributor.identifiers << identifier if identifier.present? && identifier.new_record?\n contributor\n end",
"def insert_id!(arr, insertable)\n arr << insertable\n insertable\nend",
"def known_identities; end",
"def identifier(identifier, part)\n id, location = identifier.split(\":\", 2)\n { id: id, location: location }[part]\n end",
"def add(element)\n @entries << element\n element.parent = self\n end",
"def associate klass, ident\n @associated_objects[klass].add?(ident) != nil\n end",
"def add_item(topic, id, name, description=nil, rarity=nil)\n @store[name] ||= []\n @store[name] << id\n end",
"def make_identifiable(symbol)\n if symbol.end_with?(\"%\")\n type = symbol.chomp(\"%\")\n quote(type + new_identifier_for(type).to_s)\n else\n symbol\n end\n end",
"def add(id)\n\t\traise unless id.is_a?(Fixnum)\n\t\t@extras << id\n\tend",
"def [] isin_id\n super || add(DOM.new isin_id)\n end",
"def add(elt)\n if elt.kind_of?(self.class)\n elt.elements.each {|e| unify(e) }\n else\n unify(elt)\n end\n end",
"def new_element(element_id)\n e = [element_id]\n DATA_ELEMENTS.times do\n e.push -999 # Ignore\n end\n return e\n end",
"def add(*args); elements.add(*args); end",
"def add(element)\n # set element id\n element.id = @next_id\n # push element into elements\n @elements << element\n # save changes\n save_csv\n # increment next_id\n @next_id += 1\n end",
"def update(symbol,identifier,value)\n\t\tif @symbols.has_key?(identifier)\n\t\t\t@symbols[identifier] = [symbol,value]\n\t\telse\n\t\t\tputs \"Identificador: #{identifier}, no se encuentra en ningun alcance\"\n\t\tend\n\tend",
"def add name:, location:\n @tags[name] ||= []\n @tags[name] << location\n end",
"def add(param, identifier)\n @messages[param] << identifier\n end",
"def add_rpx_identifier( rpx_id, rpx_provider_name )\n\t\t self.rpx_identifier = rpx_id\n\t\t #TODO: make rpx_provider_name a std param?\n end",
"def add_item(grcy_list, string, i=1)\n grcy_list[string] = i\nend",
"def insert_event_linkingAgentIdentifier(opts={})\n type = nil\n if !opts[:event_linkingAgentIdentifierType].nil?\n type = opts[:event_linkingAgentIdentifierType]\n end\n value = nil\n if !opts[:event_linkingAgentIdentifierValue].nil?\n value = opts[:event_linkingAgentIdentifierValue]\n end\n role = nil\n if !opts[:event_linkingAgentRole].nil?\n role = opts[:event_linkingAgentRole]\n end\n node = PremisEventDatastream.event_linkingAgentIdentifier_template(type, value, role)\n nodeset = self.find_by_terms(:event_linkingAgentIdentifier)\n\n unless nodeset.nil?\n if nodeset.empty?\n self.ng_xml.root.add_child(node)\n index = 0\n else\n nodeset.after(node)\n index = nodeset.length\n end\n # deprecated...\n # self.dirty = true\n end\n \n return node, index\n end",
"def add_item_ref_properties(element)\n item_ref = element.attribute('itemref')\n if item_ref\n item_ref.value.split(' ').each { |id| parse_elements(find_with_id(id)) }\n end\n end",
"def set_identifiers\n identifier.tap do |i|\n i.value = user.icn\n i.system = SYSTEM_ID\n i.type = identifier_type\n end\n end",
"def add_itemref_properties(element)\n itemref = element.attribute('itemref')\n if itemref\n itemref.value.split(' ').each {|id| parse_elements(find_with_id(id))}\n end\n end",
"def add_itemref_properties(element)\n itemref = element.attribute('itemref')\n if itemref\n itemref.value.split(' ').each {|id| parse_elements(find_with_id(id))}\n end\n end",
"def element_symbol; end",
"def add(elem)\n raise 'element name conflicts' if @rules[elem.name]\n @elements = nil\n @rules[elem.name] = elem\n elem\n end",
"def add_item(str,list)\n list[str]=1\n list\nend",
"def _addElement( key, value )\n @token.addElement( key, value )\n end",
"def set_Identifier(value)\n set_input(\"Identifier\", value)\n end",
"def identifiers; end",
"def identifier_value\n @value.map do |id|\n if /^https?\\:\\/\\//.match?(id)\n \"<a href='#{id}' alt='#{label}'>#{id}</a>\"\n else\n id\n end\n end\n end",
"def addMissingInteriorAddedInsulation(theElement)\n # locationStr contains \"HouseFile/House/Components/X/\", where X is \"Basement\",\n # \"Walkout\", \"Crawlspace\" or \"Slab\"\n # The Wall element is always four elements from the basement Configuration element\n theWallElement = theElement.next_element.next_element.next_element.next_element\n theWallConstElement = theWallElement[1] # First child element is always \"Construction\"\n theIntWallElement = theWallConstElement.add_element(\"InteriorAddedInsulation\", {\"nominalInsulation\"=>\"0\"})\n theIntWallElement.add_element(\"Description\")\n theIntWallCompElement = theIntWallElement.add_element(\"Composite\")\n theIntWallCompElement.add_element(\"Section\", {\"rank\"=>\"1\", \"percentage\"=>\"100\", \"rsi\"=>\"0\", \"nominalRsi\"=>\"0\"} )\nend",
"def add_item(list, string, integer=1)\n\tlist[string] = integer\n\treturn list\nend",
"def add_item(list, string, integer=1)\n\tlist[string] = integer\n\treturn list\nend",
"def register_id(object, type, remote_id, local_id)\n @keymap[type.to_s][remote_id] = local_id\n c = object.class\n while !['Object', 'ActiveRecord::Base'].include?(c.name)\n @keymap[c.name][remote_id] = local_id\n c = c.superclass\n end\n end",
"def identifier(value)\n end",
"def add(namespace:, name:, tags:)\n @registry[key(namespace, name)] = Set.new(tags)\n end",
"def insert_element(vector, elem, idx, name = \"\")\n error = element_error(vector, idx)\n\n error ||= if !elem.is_a?(LLVM::Value)\n \"elem: #{elem.inspect}\"\n end\n\n raise ArgumentError, \"Error building insert_element with #{error}\" if error\n\n ins = C.build_insert_element(self, vector, elem, idx, name)\n Instruction.from_ptr(ins)\n end",
"def add_identification_authorization(xml, authorization, options)\n xml.Identification do\n xml.ReferenceID authorization\n xml.TransactionID options[:order_id]\n end\n end",
"def <<(elem)\r\n self.add elem\r\n end",
"def add_oai_item_id\n\t\t#literal specifies that it should be in the form of...<oai:itemID>...</oai:itemID>\n \t\tself.add_relationship :oai_item_id, \"oai:hull.ac.uk:\" + self.pid, :literal => true\n\tend",
"def add(*citations)\n clashing = []\n hsh = to_hash\n citations.each do |cit|\n if hsh.key? cit.ident\n clashing << cit\n else\n @citations.push(cit)\n end\n end\n if clashing.size > 0\n clashing\n else\n nil\n end\n end",
"def consume_ident; end",
"def identify(ident=:default)\n self.class.identify(ident)\n end"
] | [
"0.6256824",
"0.6014995",
"0.6010768",
"0.59226495",
"0.5903451",
"0.58819604",
"0.5711026",
"0.5669221",
"0.56451416",
"0.56451416",
"0.56451416",
"0.56123066",
"0.55174124",
"0.54344827",
"0.5394895",
"0.53877884",
"0.5380361",
"0.5377576",
"0.536624",
"0.5353462",
"0.5353462",
"0.5353462",
"0.5353462",
"0.5353462",
"0.5353462",
"0.5348944",
"0.53485423",
"0.5331364",
"0.5322537",
"0.53175145",
"0.53162533",
"0.5296291",
"0.52905166",
"0.5279459",
"0.5257835",
"0.524346",
"0.52364755",
"0.5223603",
"0.5219249",
"0.52122116",
"0.5191533",
"0.5185129",
"0.51790524",
"0.51776403",
"0.5173437",
"0.5169914",
"0.51655275",
"0.5152026",
"0.51313937",
"0.51278245",
"0.5122586",
"0.5107707",
"0.5054051",
"0.5047924",
"0.5044252",
"0.5030467",
"0.50283533",
"0.50281745",
"0.5022946",
"0.5018481",
"0.50120246",
"0.5011309",
"0.5003289",
"0.49946594",
"0.4984906",
"0.49672338",
"0.4955457",
"0.4951783",
"0.49510208",
"0.49452043",
"0.49406147",
"0.4936429",
"0.4917685",
"0.49175835",
"0.49132815",
"0.49097058",
"0.49079117",
"0.490661",
"0.49038148",
"0.49038148",
"0.49036697",
"0.49009553",
"0.4899398",
"0.4897242",
"0.48901302",
"0.488761",
"0.48854837",
"0.48805913",
"0.4874241",
"0.4874241",
"0.48737857",
"0.48736525",
"0.48733664",
"0.48691446",
"0.48662627",
"0.48511487",
"0.48423293",
"0.4841388",
"0.48272637",
"0.48265505"
] | 0.81230694 | 0 |
Tries to resolve the given +unresolved_refs+. If resolution is successful, the proxy object will be removed, otherwise there will be an error description in the problems array. In case the resolved target element's type is not valid for the given feature, the +target_type_error+ flag will be set on the unresolved reference. Returns an array of the references which are still unresolved. Options: :problems an array to which problems will be appended :on_resolve a proc which will be called for every sucessful resolution, receives the unresolved reference as well as to new target element :use_target_type use the expected target type to narrow the set of possible targets (i.e. ignore targets with wrong type) :failed_resolutions a Hash which will receive an entry for each failed resolution for which at least one target element was found (wrong target type, or target not unique). hash key is the uref, hash value is the target element or the Array of target elements | def resolve(unresolved_refs, options={})
problems = options[:problems] || []
still_unresolved_refs = []
failed_resolutions = options[:failed_resolutions] || {}
unresolved_refs.each do |ur|
if @identifier_resolver
target = @identifier_resolver.call(ur.proxy.targetIdentifier)
else
target = @identifier_map[ur.proxy.targetIdentifier]
end
target = [target].compact unless target.is_a?(Array)
if options[:use_target_type]
feature = ur.element.class.ecore.eAllReferences.find{|r| r.name == ur.feature_name}
target = target.select{|e| e.is_a?(feature.eType.instanceClass)}
end
if target.size == 1
status = ResolutionHelper.set_uref_target(ur, target[0])
if status == :success
options[:on_resolve] && options[:on_resolve].call(ur, target[0])
elsif status == :type_error
ur.target_type_error = true
problems << type_error_message(target[0])
still_unresolved_refs << ur
failed_resolutions[ur] = target[0]
end
elsif target.size > 1
problems << "identifier #{ur.proxy.targetIdentifier} not uniq"
still_unresolved_refs << ur
failed_resolutions[ur] = target
else
problems << "identifier #{ur.proxy.targetIdentifier} not found"
still_unresolved_refs << ur
end
end
still_unresolved_refs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unresolve_refs(rrefs)\r\n # make sure any removed_urefs have been removed, \r\n # otherwise they will be removed later even if this method actually re-added them\r\n unresolved_refs\r\n rrefs.each do |rr|\r\n ur = rr.uref\r\n refs = ur.element.getGeneric(ur.feature_name)\r\n if refs.is_a?(Array)\r\n index = refs.index(rr.target)\r\n ur.element.removeGeneric(ur.feature_name, rr.target)\r\n ur.element.addGeneric(ur.feature_name, ur.proxy, index)\r\n else\r\n ur.element.setGeneric(ur.feature_name, ur.proxy)\r\n end\r\n @unresolved_refs << ur\r\n end\r\n end",
"def unresolved_refs\r\n @unresolved_refs ||= collect_unresolved_refs\r\n if @removed_urefs\r\n @unresolved_refs -= @removed_urefs\r\n @removed_urefs = nil\r\n end\r\n @unresolved_refs\r\n end",
"def unresolve_external\r\n return if @resolved_refs.nil?\r\n raise \"can not unresolve, missing fragment information\" if @resolved_refs == :dirty || @resolved_refs[:unknown]\r\n rrefs = @resolved_refs.values.flatten\r\n @resolved_refs = {}\r\n unresolve_refs(rrefs)\r\n end",
"def mark_resolved(uref, target_fragment, target)\r\n @resolved_refs = {} if @resolved_refs.nil? || @resolved_refs == :dirty\r\n target_fragment ||= :unknown\r\n if target_fragment != self\r\n @resolved_refs[target_fragment] ||= []\r\n @resolved_refs[target_fragment] << ResolvedReference.new(uref, target)\r\n end\r\n @removed_urefs ||= []\r\n @removed_urefs << uref\r\n end",
"def resolve_local(options={})\r\n resolver = RGen::Instantiator::ReferenceResolver.new\r\n index.each do |i|\r\n resolver.add_identifier(i[0], i[1])\r\n end\r\n @unresolved_refs = resolver.resolve(unresolved_refs, :use_target_type => options[:use_target_type])\r\n end",
"def resolve\n debug do\n <<~MSG\n Filtering out #{conflicts.size} conflicts from #{base_local_diffs.size + base_remote_diffs.size} diffs\n Remaining diffs #{unconflicted_diffs.size}\n MSG\n end\n\n conflicts.each_with_object(unconflicted_diffs) do |conflict, diffs|\n # TODO: this will result in diffs being out of order from their\n # original order. diffs should be flagged as conflicted and\n # this method should instead remove the conflicted flag.\n diffs.concat(@conflict_resolver.resolve(conflict))\n # TODO: if the conflict is resolved, it should be removed from the\n # @conflicts array.\n end\n end",
"def replace_references(refs)\n set = doc.xpath('.//references')\n\n if set\n inner_html = create_references_list_items(refs)\n replace_references_node(set, inner_html)\n end\n\n nil\n end",
"def info_fixups\n\t\t# Each reference should be an array consisting of two elements\n\t\trefs = module_info['References']\n\t\tif(refs and not refs.empty?)\n\t\t\trefs.each_index do |i|\n\t\t\t\tif !(refs[i].respond_to?('[]') and refs[i].length == 2)\n\t\t\t\t\trefs[i] = nil\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Purge invalid references\n\t\t\trefs.delete(nil)\n\t\tend\n\tend",
"def resolve_refs!\n name_of_last_ref = nil\n lookup_refs.each_with_index do |ref,z|\n @settings = two_layer_merge(@settings, ref.settings)\n @children.merge!(ref.children)\n name_of_last_ref = ref.name\n end\n if @settings[:path].nil? && !name_of_last_ref.nil?\n @settings[:path] = name_of_last_ref.to_s\n end\n @settings.delete :ref\n return self\n end",
"def resolve\n @schema.resolve_check @ref\n end",
"def resolve\n if !refs.nil? and refs.select { |ref| File.file? ref }.any?\n paths = refs.select { |ref| File.file? ref }.map { |path| File.expand_path(path) }\n elsif refs and refs.kind_of? Array\n paths, gems = GemsResolver.new(refs).call\n else\n paths = Dir.glob(File.join(\".\", \"lib/**/*.rb\")).map { |path| File.expand_path(path) }\n end\n\n { paths: paths, gems: gems || [] }\n end",
"def resolve_top_level_references(data)\n if data.is_a?(Array)\n data.flat_map { |elem| resolve_top_level_references(elem) }\n elsif reference?(data)\n partially_resolved = data.transform_values do |v|\n resolve_references(v)\n end\n fully_resolved = resolve_single_reference(partially_resolved)\n # The top-level reference may have returned more references, so repeat the process\n resolve_top_level_references(fully_resolved)\n else\n data\n end\n end",
"def resolve_dependencies!\n return unless Config.resolve? && targets.any?\n\n puts 'resolving dependencies...'\n each_threaded(targets) do |target|\n Depends.resolve(target, self)\n end\n end",
"def resolve(ref)\n self.class.resolve(ref, context)\n end",
"def resolve(options = {})\n if options[:ui]\n raise 'The UI object must be of type Molinillo::UI' unless options[:ui].is_a?(Molinillo::UI)\n ui = options[:ui]\n else\n require 'puppetfile-resolver/ui/null_ui'\n ui = PuppetfileResolver::UI::NullUI.new\n end\n provider = ResolutionProvider.new(@puppetfile, @puppet_version, ui, options)\n\n resolver = Molinillo::Resolver.new(provider, ui)\n begin\n result = resolver.resolve(dependencies_to_resolve)\n rescue Molinillo::VersionConflict => e\n # Wrap the Molinillo error\n new_e = PuppetfileResolver::Puppetfile::DocumentVersionConflictError.new(e)\n raise new_e, new_e.message, e.backtrace\n rescue Molinillo::CircularDependencyError => e\n # Wrap the Molinillo error\n new_e = PuppetfileResolver::Puppetfile::DocumentCircularDependencyError.new(@puppetfile, e)\n raise new_e, new_e.message, e.backtrace\n end\n ResolutionResult.new(result, @puppetfile)\n end",
"def resolve\n @resolved = []\n @unresolved = []\n @circular = []\n @outputs.each do |onode|\n rdep onode\n end\n [@resolved, @circular.empty? ? nil : @circular]\n end",
"def resolve_external(external_index, options)\r\n fragment_provider = options[:fragment_provider]\r\n resolver = RGen::Instantiator::ReferenceResolver.new(\r\n :identifier_resolver => proc {|ident| external_index[ident] })\r\n if fragment_provider\r\n @resolved_refs = {} if @resolved_refs.nil? || @resolved_refs == :dirty\r\n on_resolve = proc { |ur, target|\r\n target_fragment = fragment_provider.call(target)\r\n target_fragment ||= :unknown\r\n raise \"can not resolve local reference in resolve_external, call resolve_local first\" \\\r\n if target_fragment == self\r\n @resolved_refs[target_fragment] ||= []\r\n @resolved_refs[target_fragment] << ResolvedReference.new(ur, target)\r\n } \r\n @unresolved_refs = resolver.resolve(unresolved_refs, :on_resolve => on_resolve, :use_target_type => options[:use_target_type])\r\n else\r\n @unresolved_refs = resolver.resolve(unresolved_refs, :use_target_type => options[:use_target_type])\r\n end\r\n end",
"def resolve_references(data)\n Bolt::Util.postwalk_vals(data) do |value|\n reference?(value) ? resolve_references(resolve_single_reference(value)) : value\n end\n rescue SystemStackError\n raise Bolt::Error.new(\"Stack depth exceeded while recursively resolving references.\",\n \"bolt/recursive-reference-loop\")\n end",
"def resolve_inferred_selectors(resolved_specified_selectors, resolved_ignore_selectors, integrations, options)\n all_pacticipant_names = integrations.collect(&:pacticipant_names).flatten.uniq\n specified_names = resolved_specified_selectors.collect{ |s| s[:pacticipant_name] }\n inferred_pacticipant_names = all_pacticipant_names - specified_names\n unresolved_selectors = build_unresolved_selectors_for_inferred_pacticipants(inferred_pacticipant_names, options)\n resolve_versions_and_add_ids(unresolved_selectors, :inferred, SelectorIgnorer.new(resolved_ignore_selectors))\n end",
"def resolve_single_reference(reference)\n plugin_name = reference['_plugin']\n hook = get_hook(plugin_name, :resolve_reference)\n\n begin\n validate_proc = get_hook(plugin_name, :validate_resolve_reference)\n rescue PluginError\n validate_proc = proc { |*args| }\n end\n\n validate_proc.call(reference)\n\n begin\n # Evaluate the plugin and then recursively evaluate any plugin returned by it.\n hook.call(reference)\n rescue StandardError => e\n loc = \"resolve_reference in #{plugin_name}\"\n raise PluginError::ExecutionError.new(e.message, plugin_name, loc)\n end\n end",
"def unresolve_external_fragment(fragment)\r\n return if @resolved_refs.nil?\r\n raise \"can not unresolve, missing fragment information\" if @resolved_refs == :dirty || @resolved_refs[:unknown]\r\n rrefs = @resolved_refs[fragment]\r\n @resolved_refs.delete(fragment)\r\n unresolve_refs(rrefs) if rrefs\r\n end",
"def unify_references(ref1, ref2, ctx)\n return ctx.succeeded! if ref1.name == ref2.name\n\n if ref1.unbound?(ctx) || ref2.unbound?(ctx)\n ctx.fuse([ref1.name, ref2.name])\n ctx.succeeded!\n elsif ref1.floating?(ctx) && ref2.floating?(ctx)\n raise StandarrError if ctx.associations_for(ref1.name).size > 1\n val1 = ctx.associations_for(ref1.name)[0].value\n raise StandarrError if ctx.associations_for(ref2.name).size > 1 \n val2 = ctx.associations_for(ref2.name)[0].value\n unification(val1, val2, ctx)\n ctx.fuse([ref1.name, ref2.name]) if ctx.success?\n else\n raise NotImplementedError\n end\n # if both refs are fresh, fuse them\n # if one ref is fresh & the other one isn't then bind fresh one (occurs check)\n # More cases...\n\n ctx\n end",
"def resolve\n locking_dg = Molinillo::DependencyGraph.new\n Molinillo::Resolver.new(self, self).resolve(@needed.map {|d| DependencyRequest.new d, nil }, locking_dg).tsort.map(&:payload).compact\n rescue Molinillo::VersionConflict => e\n conflict = e.conflicts.values.first\n raise Gem::DependencyResolutionError, Conflict.new(conflict.requirement_trees.first.first, conflict.existing, conflict.requirement)\n ensure\n @output.close if defined?(@output) and !debug?\n end",
"def resolve\n return self.ref.resolve\n end",
"def resolve\n return self.ref.resolve\n end",
"def resolve_references(data, rel_path)\n # Walk through all array entries to find more references\n return data.map { |x| resolve_references(x, rel_path) } if data.is_a?(Array)\n\n # Return any data that we cannot step into to find more `include` calls\n return data unless data.is_a?(Hash)\n\n # Any call to `include` gets its data read, parsed, and merged back\n # into the current data structure\n if data.key?('include')\n data.delete('include').flatten\n .map { |x| File.expand_path(x, rel_path) }\n .map { |x| find_files(x) }.flatten\n .map { |path| parse_nginx(path) }\n .each { |conf| merge_config!(data, conf) }\n end\n\n # Walk through the remaining hash fields to find more references\n Hash[data.map { |k, v| [k, resolve_references(v, rel_path)] }]\n end",
"def resolve\n r = Gem::DependencyResolver.new(@dependencies)\n r.resolve\n end",
"def resolve_array_refs(obj)\n items = obj[ITEMS_KEY]\n\n case items\n when Array\n return resolve_items_array(items)\n when Hash\n # handle a nested any of key\n any_of = items[ANY_OF_KEY]\n return resolve_items_array(any_of) if any_of.is_a?(Array)\n\n resolve_reference_string(items[REF_KEY])\n return [class_name_from_ref(items[REF_KEY])].compact\n else\n return []\n end\n end",
"def resolve_references(obj)\n case obj\n when PDF::Reader::Stream then\n obj.hash = resolve_references(obj.hash)\n obj\n when PDF::Reader::Reference then\n resolve_references(@xref.object(obj))\n when Hash then obj.each { |key,val| obj[key] = resolve_references(val) }\n when Array then obj.collect { |item| resolve_references(item) }\n else\n obj\n end\n end",
"def resolve_dependencies(aMapping)\n @dependencies = []\n\n feature_files.each do |feature_file|\n feature = feature_file.feature\n its_id = feature.identifier\n dep_tags = feature.dependency_tags\n # Complain when self dependency detected\n if dep_tags.include?(its_id)\n msg = \"Feature with identifier #{its_id} depends on itself!\"\n raise StandardError, msg\n end\n\n # Complain when dependency tag refers to an unknown feature\n dependents = dep_tags.map do |a_tag|\n unless aMapping.include?(a_tag)\n msg_p1 = \"Feature with identifier '#{its_id}'\"\n msg_p2 = \" depends on unknown feature '#{a_tag}'\"\n raise StandardError, msg_p1 + msg_p2\n end\n aMapping[a_tag]\n end\n\n @dependencies << FeatureDependencies.new(feature_file, dependents)\n end\n\n return @dependencies\n end",
"def getMissingDeps(iDepsToResolve, iPossibleContextModifiers, ioAppliedContextModifiers)\n rMissingDeps = []\n\n # We might have some install environments to try\n iDepsToResolve.each do |iDepDesc|\n lDepID = iDepDesc.ID\n lCMListsToTry = iPossibleContextModifiers[lDepID]\n lDepResolved = false\n if (lCMListsToTry != nil)\n # We can try several ones. We want at least 1 of those sets to resolve the dependency.\n lCMListsToTry.each do |iCMSetToTry|\n # Try to add the locations to the context\n lAppliedCMs = []\n iCMSetToTry.each do |iContextModifierInfo|\n iName, iContent = iContextModifierInfo\n access_plugin('ContextModifiers', iName) do |ioPlugin|\n if (!ioPlugin.is_location_in_context?(iContent))\n # We try this one.\n ioPlugin.add_location_to_context(iContent)\n lAppliedCMs << iContextModifierInfo\n end\n end\n end\n # Now, test if this has resolved the dependency (don't try if nothing changed)\n if (!lAppliedCMs.empty?)\n lDepResolved = test_dependency(iDepDesc)\n # If we found it, it's ok\n if (lDepResolved)\n ioAppliedContextModifiers[iDepDesc.ID] = lAppliedCMs\n break\n else\n # Rollback those context modifications as they were useless\n lAppliedCMs.each do |iContextModifierInfo|\n iName, iContent = iContextModifierInfo\n access_plugin('ContextModifiers', iName) do |ioPlugin|\n ioPlugin.remove_location_from_context(iContent)\n end\n end\n end\n end\n end\n end\n # If none of them resolved the dependency, add the dependency to the missing ones\n if (!lDepResolved)\n rMissingDeps << iDepDesc\n end\n end\n\n return rMissingDeps\n end",
"def parse_references\n globbed_references = body.scan(/(.*?\\))/)\n\n globbed_references.each do |reference|\n url = reference.first.scan(/(?<=\\().*(?=\\))/).first\n next unless url\n\n if url.include?('users')\n # Do nothing for now when it's a mention of a user\n # FIXME - this is junk\n elsif url.include?('ideas') && idea = Idea.find_by_sha(url.gsub('/ideas/', ''))\n # When this is an idea we know about, make a hard link\n self.idea_references.build(:referenced_id => idea.id)\n else\n # Just leave it in the body without doing anything.\n end\n end\n end",
"def resolve(params)\n if @environment.in_dry_run_mode\n notify(:msg => \"[#{@name}] Would resolve issue #{params[:issue]}\",\n :tags => [:jira, :dryrun])\n nil\n else\n issue = disconnect(params)\n if issue\n resolution_name = params[:resolution] || 'Fixed'\n resolution = find_resolution(resolution_name)\n raise \"The resolution #{resolution_name} does not seem to be supported\" unless resolution\n\n action_name = params[:action] || 'Resolve Issue'\n resolution_field = Jira4R::V2::RemoteFieldValue.new\n resolution_field.id = \"resolution\"\n resolution_field.values = resolution.id\n perform_workflow_action_internal(issue, action_name, [resolution_field])\n notify(:msg => \"[#{@name}] Resolved issue #{issue.key}\",\n :tags => [:jira, :trace])\n else\n raise \"Could not find JIRA issue #{params[:issue]}\"\n end\n issue\n end\n end",
"def resolved_ref\n \"resolved-#{ref}\"\n end",
"def get_and_remove_done(collection)\n done_resolvers = collection.find_all(&:done?)\n collection.reject! do |resolver|\n done_resolvers.include?(resolver)\n end\n return done_resolvers\n end",
"def resolve\n self # simple Check never has references\n end",
"def resolve_reference; end",
"def resolve(target)\n modules.each do |m|\n res = m.resolve(target)\n return res unless res.nil?\n end\n nil\n end",
"def remove_invalid_reference_symbols_from(symbols)\n valid_referenced_symbols = []\n symbols.each do |s|\n if s\n valid_referenced_symbols << s\n else\n valid_referenced_symbols.pop\n valid_referenced_symbols << \"null\"\n end\n end\n valid_referenced_symbols\n end",
"def register_references_to(live_objects, options = Hash.new)\n orig_options = options # to exclude it from the graph\n options = Kernel.validate_options options,\n :roots => [Object], :excluded_classes => [], :excluded_objects => [],\n :include_class_relation => false\n roots_class, roots = options[:roots].partition { |obj| obj.kind_of?(Class) }\n excluded_classes = options[:excluded_classes]\n excluded_objects = options[:excluded_objects]\n include_class_relation = options[:include_class_relation]\n\n # Create a single ObjectRef per (interesting) live object, so that we\n # can use a BGL::Graph to represent the reference graph. This will be\n # what we are going to access later on. Use object IDs since we really\n # want to refer to objects and not use eql? comparisons\n desired_seeds = roots.map(&:object_id)\n excludes = [live_objects, self, graph, references, orig_options, options, roots, roots_class].to_value_set\n live_objects_total = live_objects.size\n live_objects.delete_if do |obj|\n if obj.kind_of?(DRbObject)\n true\n elsif excludes.include?(obj) || obj.respond_to?(:__ruby_object_graph_internal__)\n true\n else\n references[obj.object_id] ||= ObjectRef.new(obj)\n if roots_class.any? { |k| obj.kind_of?(k) }\n if !excluded_classes.any? { |k| obj.kind_of?(k) }\n if !excluded_objects.include?(obj)\n desired_seeds << obj.object_id\n end\n end\n end\n false\n end\n end\n\n desired_seeds.each do |obj_id|\n graph.insert(references[obj_id])\n end\n ignored_enumeration = Hash.new\n\n names = Hash[\n :array => \"Array\",\n :value_set => \"ValueSet[]\",\n :vertex => \"Vertex[]\",\n :edge => \"Edge[]\",\n :hash_key => \"Hash[key]\",\n :hash_value => \"Hash[value]\",\n :proc => \"Proc\",\n :ancestor => \"Ancestor\"]\n puts \"RubyObjectGraph: #{live_objects.size} objects found, #{desired_seeds.size} seeds and #{live_objects_total} total live objects\"\n loop do\n old_graph_size = graph.size\n live_objects.each do |obj|\n obj_ref = references[obj.object_id]\n\n if include_class_relation\n test_and_add_reference(obj_ref, obj.class, \"class\")\n end\n\n for var_name in obj.instance_variables\n var = obj.instance_variable_get(var_name)\n test_and_add_reference(obj_ref, var, var_name.to_s)\n end\n\n case obj\n when Array\n for var in obj\n test_and_add_reference(obj_ref, var, names[:array])\n end\n when ValueSet\n for var in obj\n test_and_add_reference(obj_ref, var, names[:value_set])\n end\n when BGL::Graph\n obj.each_vertex do\n test_and_add_reference(obj_ref, var, names[:vertex])\n end\n obj.each_edge do |_, _, info|\n test_and_add_reference(obj_ref, info, names[:edge])\n end\n when Hash\n for var in obj\n test_and_add_reference(obj_ref, var[0], names[:hash_key])\n test_and_add_reference(obj_ref, var[1], names[:hash_value])\n end\n when Proc\n if obj.respond_to?(:references)\n for var in obj.references\n begin\n test_and_add_reference(obj_ref, ObjectSpace._id2ref(var), names[:proc])\n rescue RangeError\n end\n end\n end\n when Class\n for ref in obj.ancestors\n test_and_add_reference(obj_ref, ref, names[:ancestor])\n end\n else\n if obj.respond_to?(:each)\n if obj.kind_of?(Module) || obj.kind_of?(Class)\n if !ignored_enumeration[obj]\n ignored_enumeration[obj] = true\n puts \"ignoring enumerator class/module #{obj}\"\n end\n else\n if !ignored_enumeration[obj.class]\n ignored_enumeration[obj.class] = true\n puts \"ignoring enumerator object of class #{obj.class}\"\n end\n end\n end\n end\n end\n if old_graph_size == graph.size\n break\n end\n end\n live_objects.clear # to avoid making it a central node in future calls\n return graph\n end",
"def unresolve\n change_state(:unresolve)\n end",
"def check_for_invalid_external_references(record, logical_urls)\n if record.respond_to?(:to_array)\n record.each {|e| check_for_invalid_external_references(e, logical_urls)}\n elsif record.respond_to?(:each)\n record.each do |k, v|\n if k == 'ref' && !logical_urls.has_key?(v)\n URIResolver.ensure_reference_is_valid(v, RequestContext.get(:repo_id))\n elsif k != '_resolved'\n check_for_invalid_external_references(v, logical_urls)\n end\n end\n end\n end",
"def resolved_ids\n return get_and_remove_done(@resolvers).map(&:id)\n end",
"def locate_internal_refs\n #require 'debug'; binding.b\n refs = gather_internal_refs\n #@files.keys.reject { |k| @files[k][:attachment] }.each do |identifier|\n @files.keys.reject { |k| @files.get(k,:attachment) }.each do |identifier|\n #id = @c.decode(@isodoc.docid_prefix(\"\", identifier.dup))\n #locate_internal_refs1(refs, identifier, @files[id])\n id = @isodoc.docid_prefix(\"\", identifier.dup)\n locate_internal_refs1(refs, identifier, id)\n end\n refs.each do |schema, ids|\n ids.each do |id, key|\n key == true and refs[schema][id] = \"Missing:#{schema}:#{id}\"\n end\n end\n refs\n end",
"def resolve\n @items.collect { |item| item.resolve }.freeze\n end",
"def resolve(plugins)\n @input = plugins.resolve_references(input)\n @config = Bolt::Util.deep_merge(defaults, filter(input))\n @resolved = true\n\n validate\n end",
"def clean_referenced_patterns\n refs = [:referenced_patterns]\n # refs << :referenced_subroutine_patterns if Origen.tester.v93k?\n refs.each do |ref|\n var = send(ref)\n var = var.uniq.map do |pat|\n pat = pat.sub(/\\..*/, '')\n pat unless pat =~ /_part\\d+$/\n end.uniq.compact\n singleton_class.class_variable_set(\"@@#{ref}\", var)\n end\n end",
"def references(collection)\n target.try(:references, collection) || []\n end",
"def reclaim(refs, options)\n a = []\n i = 0 # Pointer to references hash, which is already sorted with oldest first\n s = 0 # Largest contiguous size in the array of considered numbers\n p = 0 # Pointer to start of a suitable contiguous section in the array\n while s < options[:size] && i < refs.size\n a << refs.keys[i].to_i\n a.sort!\n s, p = largest_contiguous_section(a)\n i += 1\n end\n a[p]\n end",
"def fetch_refs(repo_user,repo_name)\n uri = URI(API_BASE_URL+ \"/repos/#{repo_user}/#{repo_name}/git/refs\")\n body = response_body(uri)\n \n if body.instance_of? Array\n body\n elsif body.key?('message') && body['message'].downcase == \"not found\"\n raise \"Unable to fetch #{uri}\" \n else\n puts \"WARNING unexpected body = #{body}\"\n [] \n end\n end",
"def existing_target_refs_to_link(tr_link_candidates, ndx_needs_sc)\n ret = []\n return ret if tr_link_candidates.empty?\n # See if nodes have target refs computed already; if so compute these\n # TODO: convert so that always case target refs computed already\n trs_that_need_processing = []\n tr_link_candidates.each do |node|\n trs = node[:target_refs_to_link] || []\n unless trs.empty?\n node_id = node[:id]\n ret += trs.map { |target_ref| ToLinkElement.new(node_id, target_ref) }\n else\n trs_that_need_processing << node\n end\n end\n\n return ret if trs_that_need_processing.empty?\n\n # TODO: after 'convert so that always case' can remove below\n ndx_node_template__node = trs_that_need_processing.inject({}) do |h, n|\n n[:node_template_id] ? h.merge!(n[:node_template_id] => n[:id]) : h\n end\n unless ndx_node_template__node.empty?\n sp_hash = {\n cols: [:id, :display_name, :type],\n filter: [:oneof, :id, ndx_node_template__node.keys]\n }\n Model.get_objs(@target.model_handle(:node), sp_hash).each do |nt|\n if nt.is_target_ref?()\n node_id = ndx_node_template__node[nt[:id]]\n ret << ToLinkElement.new(node_id, nt)\n ndx_needs_sc[node_id] = nil\n end\n end\n end\n ret\n end",
"def locate_internal_refs1(refs, identifier, ident)\n #file, _filename = targetfile(filedesc, read: true)\n file, _filename = @files.targetfile_id(ident, read: true)\n xml = Nokogiri::XML(file) { |config| config.huge }\n t = xml.xpath(\"//*/@id\").each_with_object({}) { |i, x| x[i.text] = true }\n refs.each do |schema, ids|\n ids.keys.select { |id| t[id] }.each do |id|\n n = xml.at(\"//*[@id = '#{id}']\") and\n n.at(\"./ancestor-or-self::*[@type = '#{schema}']\") and\n refs[schema][id] = identifier\n end\n end\n end",
"def resolveF\r\n if(@@bLastUsed == false)\r\n puts \"b was not used last. returning.\"\r\n elsif(@@forwardClasses.empty?)\r\n puts \"No more forward classes available. Please visit use command b to move back.\"\r\n else\r\n @@previousClasses.append(@@currClass.class.name)\r\n newClass = @@forwardClasses[@@forwardClasses.length - 1]\r\n newClassObj = Kernel.const_get(newClass).new\r\n @@currClass = newClassObj\r\n @@forwardClasses.pop\r\n defaultInfo\r\n puts 'List of forward classes: ' + @@forwardClasses.to_s\r\n end\r\n end",
"def resolve\n @check.resolve\n end",
"def resolve_specified_selectors(unresolved_specified_selectors, resolved_ignore_selectors)\n resolve_versions_and_add_ids(unresolved_specified_selectors, :specified, SelectorIgnorer.new(resolved_ignore_selectors))\n end",
"def references_to(type_name)\n rebuild_artifacts unless defined?(@type_reference_map)\n @type_reference_map.fetch(type_name, [])\n end",
"def get_unref_symbols\n unref = []\n @modules.each do |mod|\n mod.symbols.values.each do |s|\n unless s.referenced?\n unref << s.name\n end\n end\n end\n unref\n end",
"def resolve\n @pending = false\n @pending_add.each do |fn| resolve_add(fn) end\n @pending_add = []\n resolve_exclude\n self\n end",
"def resolve_reference_string(ref)\n resolve_reference(Nidyx::Pointer.new(ref).path) if ref\n end",
"def error_check(resolved_facts)\n status = 0\n if Options[:strict]\n missing_names = resolved_facts.select { |fact| fact.type == :nil }.map(&:user_query)\n\n if missing_names.count.positive?\n status = 1\n log_errors(missing_names)\n end\n end\n\n status\n end",
"def resolve_pull_request_dependencies(pull_requests)\n OverridesRetriever.new(client, pull_requests).resolve_dependencies\n end",
"def resolve!\n @relations.map(&:resolve!)\n end",
"def dereference(obj)\n if obj.is_a?(Hash)\n if obj.key?('$ref')\n uri, pointer = obj['$ref'].split('#')\n if uri == ''\n return obj if ALLOW_INTERNAL_REFS\n uri = INPUT\n end\n return dereference(resolve(uri, pointer))\n else\n return obj.transform_values do |value|\n dereference(value)\n end\n end\n elsif obj.is_a?(Array)\n return obj.map { |i| dereference(i) }\n else\n return obj\n end\nend",
"def resolve_tagged(tag)\n resolved = Array.new\n\n @definitions.each_value do |definition|\n if definition.tags and definition.tags.include? tag\n resolved.push definition.resolve\n end\n end\n\n resolved\n end",
"def references_to(type_name = nil)\n rebuild_artifacts unless defined?(@type_reference_map)\n if type_name\n @type_reference_map.fetch(type_name, [])\n else\n @type_reference_map\n end\n end",
"def resolve_dependency(_completed_operation)\n true\n end",
"def resolve(set=nil)\n r = Gem::DependencyResolver.new(@dependencies, set)\n @requests = r.resolve\n end",
"def resolve_dependencies\n _pt_resolve_dependencies\n\n puts \"plugin hook after resolve_dependencies\"\n\n pt_internal = PT_internal.instance\n\n\n specifications = analysis_result.specifications\n specs_to_modify = specifications.select do |s|\n pt_internal.l_names_using_binary.index(s.name)\n end\n\n specs_to_modify.map do |s|\n # :exclude_files has no getter\n exclude_files = [s.attributes_hash[\"exclude_files\"]]\n\n s.exclude_files = [exclude_files, PT::EXCLUDE_SOURCE_PATTERN].flatten\n\n s.subspecs.each do |subs|\n exclude_files = [subs.attributes_hash[\"exclude_files\"]]\n subs.exclude_files = [exclude_files, PT::EXCLUDE_SOURCE_PATTERN].flatten\n end\n\n end\n end",
"def unreferenced_elements\n model\n .elements\n .select { |el| el.references.none?(&ref_is_relationship_or_diagram) }\n end",
"def resolve\n # puts \"Resolve with #{self} and name=#{self.name} and ref=#{self.ref.class}\"\n # First resolve the sub reference if possible.\n if self.ref.is_a?(RefName) then\n obj = self.ref.resolve\n # puts \"obj=#{obj}\"\n # Look into the object for the name.\n return obj.get_by_name(self.name)\n else\n # Look in the parent hierachy for the name.\n parent = self.parent\n # puts \"parent=#{parent}\"\n while parent\n # puts \"parent=#{parent}\"\n if parent.respond_to?(:get_by_name) then\n # puts \"get_by_name\"\n found = parent.get_by_name(self.name)\n # puts \"found\" if found\n return found if found\n end\n parent = parent.parent\n end\n # Not found.\n puts \"Not found!\"\n return nil\n end\n end",
"def create_target_refs_and_links?\n tr_create = [] #node/node-groups that need target ref created\n tr_link = {} #node/node-groups that need to be linked to existing target refs\n tr_link_candidates = []\n\n # ndx_needs_sc is used to find nodes that need a state change object\n # meaning model is annoatted so these when a task is run will cause a node to be created\n # initiallly set ndx_needs_state_change to have all nodes and then in loop below remove ones\n # that are linked to existing nodes\n ndx_needs_sc = {}\n @nodes.each do |node|\n if node.is_node_group?() && !node[:target_refs_exist]\n tr_create << node\n else\n tr_link_candidates << node\n end\n # initiallly set ndx_needs_state_change to have all nodes\n ndx_needs_sc.merge!(node[:id] => node)\n end\n\n Input::BaseNodes.create_linked_target_refs?(@target, @assembly, tr_create)\n\n to_link_array = existing_target_refs_to_link(tr_link_candidates, ndx_needs_sc)\n link_to_target_refs(to_link_array)\n\n # needed target_ref state changes\n ndx_needs_sc.reject { |_node, needs_sc| !needs_sc }.values\n end",
"def all_resolved(e)\n if e.is_a?(Array)\n e.map { |t| all_resolved(t) }\n else\n e.is_a?(PTypeAliasType) ? all_resolved(e.resolved_type) : e\n end\n end",
"def _resolve_conflicts(versions)\r\n\t\tif @conflict_resolver and versions\r\n\t\t\treturn conflict_resolver(versions)\r\n\t\telse\r\n\t\t\treturn versions\r\n end\r\n end",
"def claim_existing_references(references)\n references.each do |ref_string|\n indirect_vm_ref = update_context.resolve_reference(ref_string, blame_reference).viewmodel_reference\n claim_existing_member(indirect_vm_ref, ref_string)\n end\n end",
"def resolve!\n @schemas.map(&:resolve!)\n end",
"def references(collection)\n target.manager_refs_by_association&.dig(collection, :ems_ref)&.to_a&.compact || []\n end",
"def look_for_references_to_undefined_symbols\n # for each rule ref, ask if there is a rule definition\n iter = @grammar.attr_rule_refs.iterator\n while iter.has_next\n ref_ast = iter.next_\n tok = ref_ast.attr_token\n rule_name = tok.get_text\n local_rule = @grammar.get_locally_defined_rule(rule_name)\n rule = @grammar.get_rule(rule_name)\n if ((local_rule).nil? && !(rule).nil?)\n # imported rule?\n @grammar.attr_delegated_rule_references.add(rule)\n rule.attr_imported = true\n end\n if ((rule).nil? && !(@grammar.get_token_type(rule_name)).equal?(Label::EOF))\n ErrorManager.grammar_error(ErrorManager::MSG_UNDEFINED_RULE_REF, @grammar, tok, rule_name)\n end\n end\n if ((@grammar.attr_type).equal?(Grammar::COMBINED))\n # if we're a combined grammar, we know which token IDs have no\n # associated lexer rule.\n iter_ = @grammar.attr_token_idrefs.iterator\n while iter_.has_next\n tok = iter_.next_\n token_id = tok.get_text\n if (!@grammar.attr_composite.attr_lexer_rules.contains(token_id) && !(@grammar.get_token_type(token_id)).equal?(Label::EOF))\n ErrorManager.grammar_warning(ErrorManager::MSG_NO_TOKEN_DEFINITION, @grammar, tok, token_id)\n end\n end\n end\n # check scopes and scoped rule refs\n it = @grammar.attr_scoped_rule_refs.iterator\n while it.has_next\n scope_ast = it.next_ # ^(DOT ID atom)\n scope_g = @grammar.attr_composite.get_grammar(scope_ast.get_text)\n ref_ast = scope_ast.get_child(1)\n rule_name = ref_ast.get_text\n if ((scope_g).nil?)\n ErrorManager.grammar_error(ErrorManager::MSG_NO_SUCH_GRAMMAR_SCOPE, @grammar, scope_ast.get_token, scope_ast.get_text, rule_name)\n else\n rule = @grammar.get_rule(scope_g.attr_name, rule_name)\n if ((rule).nil?)\n ErrorManager.grammar_error(ErrorManager::MSG_NO_SUCH_RULE_IN_SCOPE, @grammar, scope_ast.get_token, scope_ast.get_text, rule_name)\n end\n end\n end\n end",
"def resolved(usr, from=nil, till=nil)\n query_issues(jql_resolved usr, from, till)\n end",
"def unreleased_issues\n @unreleased_issues ||= JIRA.search(\n project: 'COOK',\n resolution: 'Fixed',\n status: 'Fix Committed',\n component: cookbook.name,\n )['issues']\n end",
"def references\n @references ||= ApiFactory.new 'GitData::References'\n end",
"def replaceAliases(iStr, iAliases, oDependencies = nil)\n rStr = iStr.clone\n\n lMatch = rStr.match(/^(.*)@\\{([^\\}]*)\\}(.*)$/)\n while (lMatch != nil)\n lAliasName = lMatch[2]\n if (lAliasName[0..3] == 'Ref[')\n # We have a reference to another deliverable\n lTargetTokens = lAliasName[4..-2].split('/')\n # Check if there is a property reference at the end\n lTargetMatch = lTargetTokens[-1].match(/^(.*)\\.([^\\.]*)$/)\n if (lTargetMatch == nil)\n # No property reference\n lDeps = getDeliverableTargets(lTargetTokens.join('/'))\n if (lDeps.size == 1)\n rStr = \"#{lMatch[1]}#{lDeps[0].RealDir}#{lMatch[3]}\"\n if (oDependencies != nil)\n oDependencies[lDeps[0]] = nil\n end\n else\n raise RuntimeError.new(\"Reference #{lAliasName} resolves to #{lDeps.size} deliverables.\")\n end\n else\n # There is a property reference\n lDeps = getDeliverableTargets((lTargetTokens[0..-2] + [ lTargetMatch[1] ]).join('/'))\n if (lDeps.size == 1)\n if (oDependencies == nil)\n # Read properties from this deliverable result\n lProperties = nil\n File.open(\"#{lDeps[0].RealDir}/metadata.conf.rb\", 'r') do |iFile|\n lProperties = eval(iFile.read)\n end\n lPropertyValue = lProperties[lTargetMatch[2].to_sym]\n if (lPropertyValue == nil)\n raise RuntimeError.new(\"No property named #{lTargetMatch[2]} could be found in deliverable #{lDeps[0].ID}. Unable to resolve #{lAliasName}.\")\n else\n rStr = \"#{lMatch[1]}#{replaceAliases(lPropertyValue, lDeps[0].Context.Aliases)}#{lMatch[3]}\"\n end\n else\n # Just remove this reference from the string\n rStr = \"#{lMatch[1]}#{lMatch[3]}\"\n oDependencies[lDeps[0]] = nil\n end\n else\n raise RuntimeError.new(\"Reference #{lAliasName} resolves to #{lDeps.size} deliverables.\")\n end\n end\n elsif (iAliases[lAliasName] == nil)\n raise RuntimeError.new(\"Unknown alias #{lAliasName} in string #{iStr}. Current aliases are: #{iAliases.inspect}.\")\n else\n rStr = \"#{lMatch[1]}#{iAliases[lAliasName]}#{lMatch[3]}\"\n end\n lMatch = rStr.match(/^(.*)@\\{([^\\}]*)\\}(.*)$/)\n end\n\n return rStr\n end",
"def replace_refs\n doc.xpath('.//ref').each_with_index.map do |node, index|\n text = node.inner_html\n\n ref_node = create_ref_node(node, index + 1)\n node.replace(ref_node)\n\n text\n end\n end",
"def RemoveObsoleteResolvables\n Builtins.y2milestone(\"--------- removing obsolete selections ---------\")\n\n # this removes only information about selections and applied patches\n # it doesn't remove any package\n Builtins.y2milestone(\n \"Removing all information about selections and patches in %1\",\n Installation.destdir\n )\n Pkg.TargetStoreRemove(Installation.destdir, :selection)\n\n # disabled by FATE #301990, bugzilla #238488\n # Pkg::TargetStoreRemove (Installation::destdir, `patch);\n\n Builtins.y2milestone(\"--------- removing obsolete selections ---------\")\n\n nil\n end",
"def build_references(refs = [], origin = nil, method = :all_refs)\n if respond_to?(method)\n send(method).each do |ref|\n raise SelfReference, \"#{origin} references itself at #{to_json}\" if origin && ref.to_s == origin\n raise NullReference, \"#{origin} contains null value reference at #{to_json}\" if origin && ref.nil?\n\n refs << ref\n end\n end\n\n ref_children.each do |elem|\n # Nulls are not permitted in Cloudformation templates.\n raise NullReference, \"#{origin} contains null value reference at #{to_json}\" if origin && elem.nil?\n\n elem.build_references(refs, origin, method) if elem.respond_to?(:build_references)\n end\n\n refs\n end",
"def fix(nonconflicts, conflicts, max_depth)\r\n\t\tmax_indices = []\r\n\t\tconflicts.each do |conflict|\r\n\t\t\tmax_indices << (conflict.similar_ingredients.length - 1)\r\n\t\tend\r\n\r\n\t\tsolution_queue = []\r\n\t\tsolution_queue << Array.new(conflicts.length, -1)\r\n\t\twhile !solution_queue.empty?\r\n\t\t\tprocessed_indices = solution_queue.shift\r\n\t\t\tcandidate = valid_solution(nonconflicts, conflicts, processed_indices)\r\n\t\t\tif !candidate.nil?\r\n\t\t\t\treturn candidate\r\n\t\t\tend\r\n\r\n\t\t\ti = 0\r\n\t\t\twhile i < processed_indices.length\r\n\t\t\t\tif processed_indices[i] != -1\r\n\t\t\t\t\ti = i + 1\r\n\t\t\t\t\tnext\r\n\t\t\t\tend\r\n\r\n\t\t\t\tmax_index = [max_depth, max_indices[i]].min\r\n\t\t\t\tfor new_index in 0..max_index\r\n\t\t\t\t\tnew_indices = Array.new(processed_indices)\r\n\t\t\t\t\tnew_indices[i] = new_index\r\n\t\t\t\t\tsolution_queue << new_indices\r\n\t\t\t\tend\r\n\t\t\t\ti = i + 1\r\n\t\t\tend\r\n\t\tend\r\n\t\treturn nil\r\n\tend",
"def refs\n @refs ||= load_refs\n end",
"def refs(ref=nil)\n prefix = ref ? \"#{path_prefix}/refs/#{ref}\" : \"#{path_prefix}/refs\"\n Ghee::API::Repos::Git::Refs::Proxy.new(connection, prefix)\n end",
"def plugin_refs(ref: nil, depth: 0)\n return [] if depth > 2\n\n introspector = LiquidTagFinder.new(content)\n plugin_names = introspector.plugin_names\n collector = plugin_names.empty? ? [] : [[plugin_names[0], ref]]\n introspector.partial_refs.each do |partial, child_ref|\n child_partial = LiquidPartial.where(title: partial).first\n next if child_partial.blank?\n\n collector += child_partial.plugin_refs(ref: child_ref, depth: depth + 1)\n end\n collector.uniq\n end",
"def unfold_references_helper(entity, array_of_refs, organization)\n ref = array_of_refs.shift\n field = entity[ref]\n\n # Unfold the id\n if array_of_refs.empty? && field\n return entity.delete(ref) if field.is_a?(String) # ~retro-compatibility to ease transition aroud Connec! idmaps rework. Should be removed eventually.\n\n id_hash = field.find { |id| id[:provider] == organization.oauth_provider && id[:realm] == organization.oauth_uid }\n if id_hash\n entity[ref] = id_hash['id']\n elsif field.find { |id| id[:provider] == 'connec' } # Should always be true as ids will always contain a connec id\n # We may enqueue a fetch on the endpoint of the missing association, followed by a re-fetch on this one.\n # However it's expected to be an edge case, so for now we rely on the fact that the webhooks should be relativly in order.\n # Worst case it'll be done on following sync\n entity.delete(ref)\n return nil\n end\n true\n\n # Follow embedment path\n else\n return true if field.blank?\n\n case field\n when Array\n bool = true\n field.each do |f|\n bool &= unfold_references_helper(f, array_of_refs.dup, organization)\n end\n bool\n when Hash\n unfold_references_helper(entity[ref], array_of_refs, organization)\n end\n end\n end",
"def handle_references_label(vals)\n @references_collection << vals.last\n @references = vals.last if matches_mdes_version(vals)\n end",
"def add_invalid_url(url, refs)\n @results[url] = 0\n\n refs.each do |ref|\n @errors[ref] ||= []\n @errors[ref] << url\n end\n end",
"def add_invalid_url(url, refs)\n @results[url] = 0\n\n refs.each do |ref|\n @errors[ref] ||= []\n @errors[ref] << url\n end\n end",
"def refer(code_array)\n if @resolved_addr\n code_array.push(@resolved_addr)\n else\n offset = code_array.size\n code_array.push(nil) # Dummy\n @unresolved_refs.push([code_array, offset])\n end\n end",
"def create_resource_ref_get_success(object, refs, inside_indent)\n # Generate network expectations for collected resourcerefs\n refs.map do |ref|\n # If the object being tested references itself (or another object of\n # the same kind) skip generation of dependencies to avoid colliding\n # with same ID objects\n next if ref.object == object\n\n ref_name = Google::StringUtils.underscore(ref.object.name)\n\n # Find the machine resource to safity the object's dependency. If an\n # object required by the object being tested in turn requires 1+ other\n # objects they were collected by the 'manifester.collect_refs' call\n # earlier.\n #\n # We now need to find the necessary dependencies and bind them to the\n # object being emitted.\n [\n create_expectation(\"expect_network_get_success_#{ref_name}\", true,\n ref.object, inside_indent, [],\n (ref.seed % MAX_ARRAY_SIZE) + 1)\n ]\n end.compact\n end",
"def resolve\n api_call(\"resolve\")\n self\n end",
"def resolve\n if @pending\n @pending = false\n @pending_add.each do |fn| resolve_add(fn) end\n @pending_add = []\n resolve_exclude\n end\n self\n end",
"def find_referenced_issue_by_id(id)\n return nil if id.blank?\n\n issue = Issue.find_by_id(id.to_i)\n if Setting.commit_cross_project_ref?\n # all issues can be referenced/fixed\n elsif issue\n # issue that belong to the repository project, a subproject or a parent project only\n unless issue.project &&\n (project == issue.project || project.is_ancestor_of?(issue.project) ||\n project.is_descendant_of?(issue.project))\n issue = nil\n end\n end\n issue\n end",
"def resolve\n if @pending\n @pending = false\n @pending_add.each do |fn| resolve_add(fn) end\n @pending_add = []\n resolve_exclude\n end\n self\n end",
"def link_to_target_refs(to_link_array)\n return if to_link_array.empty?\n create_ngrs_objs_hash = to_link_array.inject({}) do |h, to_link_el|\n h.merge(Input::BaseNodes.target_ref_link_hash(to_link_el.node_instance_id, to_link_el.target_ref.id))\n end\n create_objs_hash = { node_group_relation: create_ngrs_objs_hash }\n Model.input_hash_content_into_model(@target.id_handle(), create_objs_hash)\n end",
"def rest__resolve_pull_from_remote\n rest_ok_response resolve_pull_from_remote(:component_module)\n end"
] | [
"0.7077182",
"0.62200445",
"0.56936824",
"0.56459904",
"0.56038684",
"0.5388018",
"0.5291449",
"0.52605325",
"0.49676314",
"0.49657717",
"0.4962931",
"0.49530134",
"0.49332288",
"0.4918868",
"0.48872533",
"0.48753232",
"0.4821397",
"0.4804002",
"0.47497967",
"0.47372916",
"0.47072107",
"0.46790951",
"0.467172",
"0.4648915",
"0.4648915",
"0.4643711",
"0.46145156",
"0.46141657",
"0.45892012",
"0.45763937",
"0.45629326",
"0.45541745",
"0.4529862",
"0.45207003",
"0.45140696",
"0.45085534",
"0.45003587",
"0.44296506",
"0.44286183",
"0.44253498",
"0.43994042",
"0.4393216",
"0.43926427",
"0.4379433",
"0.4357975",
"0.4352805",
"0.4344353",
"0.43427533",
"0.42829043",
"0.42825788",
"0.4277631",
"0.42681563",
"0.42680195",
"0.42556256",
"0.42554203",
"0.42507592",
"0.42429402",
"0.42334554",
"0.42329964",
"0.42269337",
"0.421158",
"0.42000532",
"0.41963226",
"0.41928098",
"0.41864085",
"0.4162678",
"0.41621268",
"0.4160894",
"0.41608548",
"0.41430172",
"0.41396457",
"0.4138864",
"0.41228575",
"0.4117211",
"0.41135728",
"0.41121006",
"0.410941",
"0.4107916",
"0.41037327",
"0.409393",
"0.40928295",
"0.40899774",
"0.40886298",
"0.4081577",
"0.40782708",
"0.40780294",
"0.40766954",
"0.40763864",
"0.40760666",
"0.40743157",
"0.40726817",
"0.40726817",
"0.40688115",
"0.40560424",
"0.40413004",
"0.40350065",
"0.40340412",
"0.40268767",
"0.40243924",
"0.40075913"
] | 0.8583581 | 0 |
TODO: remove this method when we're on a version of devise_invitable which no longer expects it to exist (v1.2.1 onwards) | def build_resource
self.resource = resource_class.new(resource_params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invite_resource\n ## skip sending emails on invite\n # super do |u|\n # u.skip_invitation = true\n # end\n end",
"def fetchable_fields\n super - [:password, :password_confirmation]\n # if (context[:current_user].guest)\n # super - [:email]\n # else\n # super\n # end\n end",
"def devise_modules_hook!; end",
"def available_invites\n self.user_admin? ? 1 : self[:available_invites]\n end",
"def update\n invitation_token = Devise.token_generator.digest(User, :invitation_token, params[:invitation_token])\n user = User.find_by(invitation_token: invitation_token)\n if user.present? && user.encrypted_password.present?\n user.accept_invitation\n inviter = User.find(user.invited_by_id)\n user.firm_id = inviter.firm_id\n user.role = user.invitation_role\n user.invitation_role = nil\n user.save!\n\n redirect_to root_path, notice: 'Invitation accepted.'\n else\n super\n # resource.name = resource.first_name + \" \" + resource.last_name\n # resource.save\n end\n # super\n\n\n # class_string_name = User::USER_ROLES[current_user.role].humanize\n # puts \"CONTACT TYPE ------> \" + class_string_name\n # create_contact(class_string_name, current_user, current_user.firm)\n end",
"def permit_invite_code\n devise_parameter_sanitizer.for(:sign_up) << :invite_code\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:invite, keys: [:email, :role])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:invite, keys: [:email, :role])\n end",
"def email_changed?\n being_invited? ? false : super\n end",
"def authenticate_inviter!\n if cannot?( :invite, User )\n raise CanCan::AccessDenied\n else\n current_user\n end\n end",
"def devise_scope(scope); end",
"def devise_controller?; end",
"def devise_mappings; end",
"def configure_invite_params\n devise_parameter_sanitizer.permit(:invite, keys: [:email, :name, :username])\n end",
"def configure_accept_invitation_params \n devise_parameter_sanitizer.permit(:accept_invitation, keys: [:name, :username, :image, :password, :password_confirmation, :invitation_token])\n end",
"def authenticate_inviter!\n can?(:invite, :users) ? current_user : raise(CanCan::AccessDenied)\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:invite, keys: [:email, :role, :grade])\n end",
"def resource_name\n devise_mapping.name\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:invite, keys: [:role])\n end",
"def current_user\n #super the main class of devise current_user\n super || guest_user\n end",
"def after_successful_sign_in\n invite = current_account.claim_invitation\n if invite\n invitable = invite.invitable\n invitable_name = invitable.class.name.downcase\n anchor = '/%s/%d' % [invitable_name.pluralize, invitable.id]\n\n flash[:success] = _('%s invited you to collaborate on %s %s.') % [\n invite.user.nicename, invitable.title, invitable_name ]\n\n redirect_to root_path(:anchor => anchor)\n else\n super\n end\n end",
"def current_inviter\n if user_signed_in?\n super\n else\n @current_inviter ||= User.new(params[:user])\n end\n end",
"def invite_resource\n resource_class.invite!(invite_params, current_inviter) do |invitable|\n invitable.company_id = current_user.company_id\n invitable.is_admin = true\n invitable.require_email = true\n invitable.save\n end\n end",
"def fetch_invite_admin\n fail \"undefined method fetch_invite_admin in parent class\"\n end",
"def after_invite_new_user(invite)\n end",
"def confirmation_instructions(record)\n devise_mail(record, :confirmation_instructions)\n end",
"def authenticate_current_user_as_invited_user\n\t unless current_user == @invitation.invited_user\n\t redirect_to :back, alert: 'This invitation is not for you!'\n\t end\n\t end",
"def update\n inviter_mail = resource_params.delete \"invitermail\"\n \n accepted_inviter = resource_class.to_adapter.find_first(email: inviter_mail)\n \n # before inviting person gets credit for the new user: check if he is\n # really allowed to claim. Only certain vip users are allowed...\n if accepted_inviter && accepted_inviter.ability.can?(:invite, resource_class)\n self.resource = resource_class.accept_invitation!(resource_params) \n resource.invited_by = accepted_inviter\n else\n ## No discussion. User didn't have the right to invite, so show...\n flash[:error] = I18n.t(\"devise.invitations.no_authorized_inviter\")\n raise CanCan::AccessDenied\n end\n\n if resource.errors.empty?\n flash_message = resource.active_for_authentication? ? :updated : :updated_not_active \n set_flash_message :notice, flash_message\n sign_in(resource_name, resource)\n respond_with resource, :location => after_accept_path_for(resource)\n else\n respond_with_navigational(resource){ render :edit }\n end\n end",
"def invitation_instructions(resource, token, opts={})\n invited_by = resource.invited_by\n invited_by_email = invited_by.email\n invited_to_account = Account.joins(:memberships).where(memberships: {user_id: resource.id, created_by_id: invited_by.id}).limit(1).first.try(:name)\n opts[:subject] = \"#{invited_to_account} Invitation from #{invited_by_email}\"\n super\n end",
"def url_after_invite(invite)\n invite.invitable\n end",
"def devise_parameter_sanitizer; end",
"def resource_class\n devise_mapping.to\n end",
"def notification_devise_resource\n resolve_value(_notification_devise_resource)\n end",
"def invited_by_wus_user\n user = self.organization.users.where(self.invited_by_id).first\n user.full_name.present? ? user.full_name : user.email\n end",
"def after_invite_existing_user(invite)\n # Add the user to the invitable resource/organization\n invite.invitable.add_invited_user(invite.recipient)\n end",
"def authorize_invitation!\n authorize!(:manage_users, current_course)\n end",
"def authorize_invitation!\n authorize!(:manage_users, current_course)\n end",
"def authorize_invitation!\n authorize!(:manage_users, current_course)\n end",
"def existing_user_invite\n InviteMailer.existing_user_invite(Invite.last)\n end",
"def url_after_invite(invite)\n invite.invitable\n end",
"def get_unissued_invites()\n User.find(session[:user_id]).unissued_invites\n end",
"def edit\n @connected_providers = current_user.identities.collect{ |identitiy| identitiy.provider }\n super\n end",
"def fetch_details_from_devise\n self.username = 'devise_user'\n self.save\n end",
"def invite!\n #logger.debug 'invite called'\n self.confirm!\n super\n #self.confirmed_at = Time.now\n #self.save\n end",
"def showInvite\n @user = current_user\n end",
"def deliver_invite_to_resident(resident, user)\n return\n end",
"def invite_resource\n ## skip sending emails on invite\n u = resource_class.invite!(invite_params, current_inviter) do |u|\n u.skip_invitation = true\n u.invitation_sent_at = DateTime.now\n end\n flash[:link] = accept_user_invitation_url(:invitation_token => u.raw_invitation_token)\n u\n end",
"def set_invitation_flags\n self.invitation_required = false\n true\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def devise_mapping\n @devise_mapping ||= Devise.mappings[:user]\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:invite).concat [:involvement_ministry_id, :involvement_level, :first_name, :last_name]\n devise_parameter_sanitizer.for(:accept_invitation).concat [:profile_image]\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation, :first_name, :last_name) }\n # devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, :password, :password_confirmation, :first_name, :last_name) }\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:email, :password, :password_confirmation, :current_password, :first_name, :last_name, :profile_image) }\n end",
"def after_sign_in_path_for(resource)\n session[:sign_in_up_email] = nil\n if !session[:invite_id].blank?\n i = Invite.find(session[:invite_id])\n if current_user.email == i.email\n return accept_invite_path(:id => i.code)\n else\n session[:invite_id] = nil\n flash[:alert] = \"The invite you tried to use is for #{i.email} - please sign in with that account if you want to accept it.\"\n return root_path\n end\n else\n if session[:redirect_to].present?\n tmp = session[:redirect_to]\n session[:redirect_to] = nil\n return tmp\n else\n super(resource)\n end\n end\n end",
"def available_email_login?\n true\nend",
"def user_for_vestal_versions; end",
"def current_user\n # if a user is logged in we just use devise's implementation.\n super || guest_user\n end",
"def block_from_invitation?\n false\n end",
"def sign_in\n trait\n end",
"def after_invite_path_for(resource)\n users_path\n end",
"def after_invite_path_for(resource)\n users_path\n end",
"def invitable_users\n @title = \"Invitar usuario\"\n @invitable_users = GetInvitableUsers.call(@previa_group)\n end",
"def instruct_user!\n end",
"def inbound_email; end",
"def inbound_email; end",
"def inactive_message\n # this method actually is not implemented by devise_token_auth\n # instead, use devise_token_auth locales file or override #render_create_error_not_confirmed in controller\n # still not sure why it uses not_confirmed anyway, but at least I'm not the only one. See below\n #\n # This incomplete PR corrects it:\n # https://github.com/lynndylanhurley/devise_token_auth/pull/533\n # https://github.com/lynndylanhurley/devise_token_auth/pull/533/files\n end",
"def send_devise_notification(notification, *args); end",
"def invitee_string\n\t\n\tend",
"def accept_invitation\n \n end",
"def invited_by\n invite = BetaInvite.where(:invitee_id => self.id).first\n invite ? invite.sender : nil\n end",
"def can_invite\r\n unless @resource.can_be_invited_by?(current_user)\r\n flash[:error] = 'You can\\'t invite!'\r\n redirect_to (@resource_type == 'Argument') ? argument_path(@resource) : debate_path(@resource) \r\n end\r\n end",
"def after_password_reset\n accept_invitation! if invitation_token.present?\n end",
"def check_invitation \n if user_signed_in? && !pending_invitation.nil?\n if current_user.email == pending_invitation.email && pending_invitation.pending?\n proceed_to_invitation pending_invitation\n end\n session[:pending_invitation] = nil\n end\n end",
"def devise_i18n_options(options)\n options[:scope] = \"devise.registrations\"\n options\n end",
"def user_provider; end",
"def skip_pundit?\n devise_controller?\n end",
"def after_sign_up_path_for(resource)\n # binding.irb\n super\n # super(resource) do\n edit_user_registration_path\n # end\n # binding.irb\n # if resource[:role] == 'guest'\n # new_guest_path\n # else\n # new_host_path\n # end\n end",
"def additional_users_for_edit\n []\n end",
"def activate_if_invited\n invited_user = Invite.find_by_invited_user_email(self.email)\n if ! invited_user.nil?\n invited_user.update_attribute(:invited_user_id, self.id)\n self.account_active = 1\n self.save!\n end\n end",
"def current_survey_invitation\n @current_survey_invitation ||= (login_from_survey_invitation || false)\n end",
"def user_verification; end",
"def show\n # @has_password = current_user.has_password?\n # @has_email = current_user.authentications.emails.active.any?\n end",
"def show\n # @has_password = current_user.has_password?\n # @has_email = current_user.authentications.emails.active.any?\n end",
"def invitation_instructions(record, token, opts={})\n super\n end",
"def send_reset_password_instructions\r\n super if invitation_token.nil?\r\n end",
"def update\n respond_to do |format|\n format.js do\n invitation_token = Devise.token_generator.digest(\n resource_class, :invitation_token, update_resource_params[:invitation_token]\n )\n self.resource = resource_class.where(invitation_token: invitation_token).first\n resource.skip_password = true\n resource.update_attributes update_resource_params.except(:invitation_token)\n end\n format.html do\n super\n end\n end\n end",
"def user_key\n send(Devise.authentication_keys.first)\n end",
"def user_key\n send(Devise.authentication_keys.first)\n end",
"def get_activate_email\n end",
"def primary_invite\n self.primary_invite_id ? Invitation.find(self.primary_invite_id) : self.invitations.find(:first)\n end",
"def devise_mapping\n @devise_mapping ||= request.env[\"devise.mapping\"]\n end",
"def accept_invitation(invite)\n self.invitation= invite\n self.validation_level = invite.validation_level\n self.invitation_code = invite.code\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:accept_invitation) do |u|\n u.permit(:username,:validate_username, :password,:password_confirmation, :invitation_token)\n end\n devise_parameter_sanitizer.for(:invite) do |u|\n u.permit(:name,:comments)\n end\n\n devise_parameter_sanitizer.for(:sign_up) do |u|\n u.permit(:email, :password, :password_confirmation,:current_route,:first_visit, :demographic_attributes=>[:male, :nickname,:last_institute], :criterion_attributes=>[:male], :attendances_attributes=>[:user_id, :institution_id])\n end\n devise_parameter_sanitizer.for(:sign_in) do |u|\n u.permit(:username,:email,:password,:password_confirmation ,:current_route,:first_visit, :phone, :validate_username, :avatar_cache, :remove_avatar, :current_password,:remember_me)\n end\n\n devise_parameter_sanitizer.for(:account_update) do |u|\n u.permit(:username,:email,:password,:password_confirmation,:phone, :validate_username,:avatar, :avatar_cache, :remove_avatar, :current_password,:demographic_attributes=>[:male, :name,:nickname,:dob,:smoking,:drinking,:country,:city,:religion], :criterion_attributes=>[:male,:minage,:maxage,:smoking,:drinking], :attendances_attributes=>[:user_id, :institution_id])\n end\n end",
"def invited_user\n get_or_make_reference('User', @data, 'invited_user_id')\n end",
"def invite\n Notifications.invite\n end",
"def inviter?(user)\n return user.id == inviter_user_id\n end",
"def invitation_token\n invitation.token if invitation\n end",
"def user_action_on_resource_authorized\n end",
"def invitation_token\n \tinvitation.token if invitation\n end",
"def authenticate_inviter!\n send(:\"authenticate_#{resource_name}!\")\n end",
"def authenticated_with_devise?(current_resource)\n devise_resource = notification_devise_resource\n unless current_resource.blank? or current_resource.is_a? devise_resource.class\n raise TypeError,\n \"Different type of current resource #{current_resource.class} \"\\\n \"with devise resource #{devise_resource.class} has been passed to #{self.class}##{__method__}. \"\\\n \"You have to override #{self.class}##{__method__} method or set devise_resource in acts_as_target.\"\n end\n current_resource.present? && current_resource == devise_resource\n end",
"def devise(*modules)\n # hack to get around Neo4j's requirement to index before uniqueness validation\n index :email, :type => :exact if modules.include?(:validatable)\n super\n end"
] | [
"0.62042296",
"0.6148035",
"0.6088427",
"0.60879844",
"0.60226566",
"0.5949831",
"0.5934966",
"0.5934966",
"0.5880972",
"0.58695066",
"0.5849885",
"0.58398026",
"0.5837345",
"0.5821982",
"0.58006555",
"0.57847524",
"0.57737744",
"0.5766662",
"0.5740797",
"0.5715828",
"0.57071173",
"0.5700277",
"0.5692431",
"0.5680812",
"0.56579787",
"0.5654073",
"0.5637651",
"0.5602727",
"0.5598963",
"0.5598836",
"0.5597508",
"0.55946964",
"0.55944353",
"0.5590232",
"0.55887526",
"0.55820984",
"0.55820984",
"0.55820984",
"0.55771834",
"0.55748844",
"0.5565423",
"0.55621517",
"0.5557423",
"0.55560285",
"0.55517554",
"0.5550729",
"0.55465084",
"0.55286497",
"0.5525525",
"0.5525525",
"0.5525525",
"0.5477081",
"0.5474959",
"0.5461639",
"0.5445701",
"0.5444167",
"0.54343086",
"0.54122967",
"0.54064626",
"0.54064626",
"0.54021084",
"0.53925544",
"0.53760064",
"0.53760064",
"0.5366835",
"0.53634465",
"0.5361004",
"0.5360945",
"0.5359489",
"0.5358448",
"0.53477293",
"0.5342754",
"0.5340771",
"0.5338563",
"0.53360623",
"0.53216934",
"0.5306707",
"0.53043824",
"0.53020316",
"0.530006",
"0.5296786",
"0.5296786",
"0.5291743",
"0.52883065",
"0.5285825",
"0.52838063",
"0.52838063",
"0.5276218",
"0.5263826",
"0.5259787",
"0.52579826",
"0.5254829",
"0.5249663",
"0.5247588",
"0.5244459",
"0.52426976",
"0.52426153",
"0.5228387",
"0.5224494",
"0.5224247",
"0.52219266"
] | 0.0 | -1 |
TODO: once we've upgraded Devise and DeviseInvitable, `resource_params` hopefully won't be being called for actions like `new` anymore and we can change the following `params.fetch(:user)` to `params.require(:user)`. See and for details :) | def unsanitised_user_params
params.require(:user).permit(
:name,
:email,
:organisation_id,
:invitation_token,
:password,
:password_confirmation,
:require_2sv,
:role,
supported_permission_ids: [],
).to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_params\n strong_params = params.require(resource_name.to_sym).permit(*permit_attributes)\n strong_params.merge(user_id: current_user.id) if user_signed_in?\n end",
"def resource_params\n @resource_params ||= current_model_service.permit params\n end",
"def resource_params\n @resource_params ||= parse_resource_params(\n (params[:resource] && params.require(:resource).permit!) || {}\n )\n end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def resource_params\n user_params = params[:user] || {}\n user_params.merge!(uv_login: params[:uv_login]) if params[:uv_login].present?\n user_params\n end",
"def resource_params\n # TODO DANGER!\n params.require(@resource_class.name.underscore.to_sym).permit!\n end",
"def user_resource_params\n params.require(:user).permit(:email, :password)\n end",
"def resource_params\n @resource_params ||= self.send(\"#{resource_name}_params\")\n end",
"def resource_params\n params.require($resource.downcase.to_sym).permit(input_fields($new_resource).map{|pi| pi.to_sym})\n # MAY WORK WITHOUT \".to_sym\" METHOD\n end",
"def resource_params\n @resource_params ||= build_resource_params\n end",
"def user_params\n params.require(:user)\n end",
"def resource_params\n params.require(resource_name).permit(*permitted_params)\n end",
"def resource_params\n @resource[:resource_params]\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def user_params\n params.require(:user)\n end",
"def catalogs_user_resource_params\n params.require(:catalogs_user_resource).permit(:admin_user_id, :resource_id, :administrator)\n end",
"def object_params\n params.require(resource.name.underscore.to_sym)\n .permit(resource_params)\n end",
"def user_params\n params.require(:user).permit(:name, :avatar_url, user_resources_attributes: [:id, :resource_name, :resource_url, :resource_size, :_destroy])\n end",
"def resource_attributes\n request.format.html? ? params[user_resource_class.to_s.downcase] : params\n end",
"def build_resource_params\n parameters = respond_to?(:permitted_params, true) ? permitted_params : params\n rparams = [parameters[resource_request_name] || parameters[resource_instance_name] || {}]\n if without_protection_given?\n rparams << without_protection\n else\n rparams << as_role if role_given?\n end\n\n rparams\n end",
"def user_params\n\t\tparams.fetch(:user, {})\n\tend",
"def resource_params\n params.require(model_name.underscore.intern).permit(*@model.column_names.map(&:intern))\n end",
"def resource_params\n params.permit(devise_parameter_sanitizer.for(:sign_in))\n end",
"def user_params\r\n params.fetch(:user, {})\r\n end",
"def resource_params\n raise NotImplementedError\n end",
"def resource_params\n params.require(resource_handler.namespaced_resource_name).permit!\n end",
"def resource_params\n params.require(resource_handler.namespaced_resource_name).permit!\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def resource_params\n deserialized_params.permit!\n end",
"def permitted_params\n { user: user_params }\n end",
"def get_resource_params\n \traise NotImplementedError\n end",
"def permitted_params\n policy(resource || resource_class.new).send(\"permitted_#{action_name}_attributes\")\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params.fetch(:user, {})\n end",
"def user_params\n params[:user]\n end",
"def user_params\n params[:user]\n end",
"def user_param\n params.require(:user_id)\n end",
"def user_params\n params.require(:user).permit(:username, :email, :age, :political_affiliation, :password)\n # this is saying go into params look for a key of what is in the require() method and look inside that object for the keys included in permit()\n end",
"def resource_params\n {}\n end",
"def resource_params\n {}\n end",
"def user_params\n params[:user]\n end",
"def user_params\r\n params[:user]\r\n end",
"def user_params\n params.fetch(:user, {}).permit(:username, :email, :password, :password_confirmation, :privilege)\n end",
"def permit_attributes\n params.require(resource_as_param_key).permit(*permitted_attributes)\n end",
"def user_params\n params[:user]\n end",
"def user_params\n params[:user]\n end",
"def user_params\n params[:user]\n end",
"def user_params\n params[:user]\n end",
"def user_params\n params[:user]\n end",
"def user_params\n params[:user]\n end",
"def user_params\n params[:user]\n end",
"def build_resource_params\n parameters = permitted_params || params\n rparams = [parameters[resource_request_name] || parameters[resource_instance_name] || {}]\n if without_protection_given?\n rparams << without_protection\n else\n rparams << as_role if role_given?\n end\n\n rparams\n end",
"def user_params\n params.require(:user).permit(current_ability.permitted_attributes(:manage, @user))\n end",
"def user_params\n end",
"def resource_params\n registry_patient_params\n end",
"def user_params\n # params is a hashtable. It should have in it a key of :user.\n # The value for the :user key is another hash.\n # If params does not contain the key :user, an exception is raised. \n # Only the \"user\" hash is returned and only with the permitted key(s).\n # So we get back { :name => someName, :email => someEmail}\n params.require(:user).permit(:name, :email)\n end",
"def user_params\n params.fetch(:user, {}).permit(:approved, :id, :source, :has_contributed, :password, :password_confirmation, :email, :institution, :country, :fname, :lname, :research, :is_admin, :super_admin)\n end",
"def supported_user_params\n params.fetch(:supported_user, {})\n end",
"def users_params\n\t\tparams.require(:user).permit(User::PERMIT_ATTRIBUTES)\n\tend",
"def user_params\n params.require(:user).\n permit(:name, :password, :password_confirmation, :email, :role, :active, service_ids: [])\n end",
"def user_params\n params.\n require(:user).\n permit :name, :password, :password_confirmation, :password_digest, :import, :import_type_id, :import_contents\n end",
"def user_params\n # Rails 4+ requires you to whitelist attributes in the controller.\n params.fetch(:user, {}).permit(:username, :email, :password, :password_confirmation, :privilege, :status)\n end",
"def permitted_params\n \t@permitted_params ||= PermittedParams.new(params, current_user)\n end",
"def user_params\r\n end",
"def user_params\n\n \tif password_blank?\n \t\tparams.require(:user).permit(:name, :cpf, :role, :registry_id, :email).except(:password, :password_confirmation)\n \telse\n \t\tparams.require(:user).permit(:name, :cpf, :role, :registry_id, :email, :password, :password_confirmation)\n \tend\n\n end",
"def user_user_params\n params.fetch(:user_user, {})\n end",
"def user_params\n if current_user.is_admin?\n params.require(:user).permit(:name, :role, :email, :password)\n else\n params.require(:user).permit(:name, :email)\n end\n end",
"def user_params\n params.require(:user).permit(*policy(@user || User).permitted_attributes)\n end",
"def user_params\n params.fetch(:user, {}).permit(:name, :email, :password, :password_confirmation, :position, :role, :vac_days_left, :has_extended_access)\n # params.require(:user).permit(:first_name, :last_name, :email, :password_digest)\n end",
"def user_params\n params.require(:user).permit(policy(@user || User).permitted_attributes)\n end",
"def user_params\n params.require(:user).permit(policy(@user || User).permitted_attributes)\n end",
"def params_for_user\n {}\n end",
"def params_for_user\n {}\n end",
"def user_params\n if (params[:action] == \"update\")\n params.require(:user).permit(:email, :level, :name, :gravatar_email, :lang, :change_password)\n elsif (params[:action] == \"save_preferences\")\n # Password update\n if (params[:mode] == \"password\")\n params.require(:user).permit(:password, :password_confirmation, :current_password)\n else # General preferences update\n params.require(:user).permit(:email, :name, :gravatar_email, :lang, :current_password)\n end\n else\n params.require(:user).permit(:email, :level, :name, :gravatar_email, :lang)\n end\n end",
"def user_params\n # params that get passed in must contain a key 'user', permit optional keys\n params.require(:user).permit(:username, :password, :password_confirmation)\n end",
"def clean_params_for_save!\n if params[resource_param_name].present?\n params[resource_param_name].delete(:id)\n params[resource_param_name].delete(:user_id)\n end\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n\t\t\t\t\tparams.require(RicAuth.user_model.model_name.param_key).permit(\n\t\t\t\t\t\t:current_password, \n\t\t\t\t\t\t:password, \n\t\t\t\t\t\t:password_confirmation\n\t\t\t\t\t)\n\t\t\t\tend",
"def resource_params\n params.require(:resource).permit(\n :title, :content, :user_id, :project_id\n ).merge(\n :project_id => @project.id,\n :user_id => current_user.id\n )\n end",
"def resource_params\n params.require(:resource).permit(:oid, :retrievalURL, :activeFrom, :activeTo, :objectType, :eventType, :description, :lang, :license, :length, :mimeType, :contributorName, :contributorEmail, :useConstraints)\n end",
"def devise_parameter_sanitizer\n if resource_class == User\n User::ParameterSanitizer.new(User, :user, params)\n else\n super\n end\n end",
"def devise_parameter_sanitizer\n if resource_class == User\n User::ParameterSanitizer.new(User, :user, params)\n else\n super\n end\n end",
"def resource_params\n params.require(:resource).permit(:name, :description, :resource_type, :establishment_id, :is_active)\n end",
"def user_params\n params.require(:choice)\n end",
"def user_params\n current_class = @user.class.name.underscore.to_sym if @user\n if @current_account.present? and (@current_account.is_admin? or @current_account.is_boss?)\n params.require(current_class || :user).permit(:phone, :default_address, :name,\n :email_address, :vip_no, :vip_level_id, :pay_password, :recharge_amount)\n else\n params.require(current_class || :user).permit(:phone, :default_address, :name, :email_address)\n end\n end"
] | [
"0.7556684",
"0.7339725",
"0.73241115",
"0.72351956",
"0.7197823",
"0.71927255",
"0.7071349",
"0.7027629",
"0.6970772",
"0.69608736",
"0.6958336",
"0.689695",
"0.6889622",
"0.68828034",
"0.6852137",
"0.6761511",
"0.67408776",
"0.6690889",
"0.66635764",
"0.66462874",
"0.662812",
"0.6609681",
"0.66035724",
"0.66023475",
"0.660081",
"0.65796447",
"0.65796447",
"0.6573775",
"0.6573775",
"0.6573775",
"0.656381",
"0.65313596",
"0.65253997",
"0.6469966",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64456356",
"0.64210975",
"0.6405035",
"0.6405035",
"0.6404784",
"0.6394004",
"0.63828593",
"0.63716334",
"0.63683134",
"0.6350231",
"0.634844",
"0.6345084",
"0.63227403",
"0.63227403",
"0.63227403",
"0.63227403",
"0.63227403",
"0.63227403",
"0.63227403",
"0.6283375",
"0.6266475",
"0.6253278",
"0.6238212",
"0.62351316",
"0.62346566",
"0.6234554",
"0.62303853",
"0.6228918",
"0.6209683",
"0.61948055",
"0.61642313",
"0.6144359",
"0.61409277",
"0.61344934",
"0.61332434",
"0.6129791",
"0.6121808",
"0.6085919",
"0.6085919",
"0.6081087",
"0.6081087",
"0.6080963",
"0.607677",
"0.60628384",
"0.60472906",
"0.60468626",
"0.6027152",
"0.60225403",
"0.6016909",
"0.6016909",
"0.60112494",
"0.60044956",
"0.600371"
] | 0.0 | -1 |
NOTE: `current_user` doesn't exist for `edit` and `update` actions as implemented in our current (outofdate) versions of Devise ( and DeviseInvitable ( With the old attr_accessible approach, this would fall back to the default whitelist (i.e. equivalent to the `:normal` role) and this this preserves that behaviour. In fact, a user accepting an invitation only needs to modify `password` and `password_confirmation` so we could only permit those two params for the `edit` and `update` actions. | def current_user_role
current_user.try(:role).try(:to_sym) || :normal
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invite_params\n invite = params.require(:invite).permit(:name, :email, :role)\n current_user ? invite.merge(user_id: T.must(current_user).id) : invite\n end",
"def user_permitted_to_edit(item)\n item.user == current_user \n end",
"def edit_current_user\n end",
"def current_inviter\n if user_signed_in?\n super\n else\n @current_inviter ||= User.new(params[:user])\n end\n end",
"def user_params\n params.require(:user).permit(current_ability.permitted_attributes(:manage, @user))\n end",
"def permitted_params\n \t@permitted_params ||= PermittedParams.new(params, current_user)\n end",
"def edit\n @user = @current_user\n end",
"def set_allowed_user\n unless request.format.json?\n @user = current_account if @user.nil? || !current_account.admin?\n end\n end",
"def user_params\n current_class = @user.class.name.underscore.to_sym if @user\n if @current_account.present? and (@current_account.is_admin? or @current_account.is_boss?)\n params.require(current_class || :user).permit(:phone, :default_address, :name,\n :email_address, :vip_no, :vip_level_id, :pay_password, :recharge_amount)\n else\n params.require(current_class || :user).permit(:phone, :default_address, :name, :email_address)\n end\n end",
"def current_user\n \tsuper || guest_user\n \t#Super quiere decir que exactamente con los valores \n \t#del metodo original sin cambiar nada\n end",
"def permitted_params\n @permitted_params ||= PermittedParams.new(params, current_user)\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.sanitize(:sign_in) { |u| u.permit(:name, :mail_address) }\n if current_user\n @last_user = current_user.clone\n end\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = current_user\n end",
"def update\n inviter_mail = resource_params.delete \"invitermail\"\n \n accepted_inviter = resource_class.to_adapter.find_first(email: inviter_mail)\n \n # before inviting person gets credit for the new user: check if he is\n # really allowed to claim. Only certain vip users are allowed...\n if accepted_inviter && accepted_inviter.ability.can?(:invite, resource_class)\n self.resource = resource_class.accept_invitation!(resource_params) \n resource.invited_by = accepted_inviter\n else\n ## No discussion. User didn't have the right to invite, so show...\n flash[:error] = I18n.t(\"devise.invitations.no_authorized_inviter\")\n raise CanCan::AccessDenied\n end\n\n if resource.errors.empty?\n flash_message = resource.active_for_authentication? ? :updated : :updated_not_active \n set_flash_message :notice, flash_message\n sign_in(resource_name, resource)\n respond_with resource, :location => after_accept_path_for(resource)\n else\n respond_with_navigational(resource){ render :edit }\n end\n end",
"def set_current_user\n current_user\n authorize\n end",
"def edit\n if !(current_user.id == @user.id || is_admin?)\n indicate_illegal_request I18n.t('users.not-your-account')\n end\n end",
"def edit\n @user =current_user\nend",
"def parametrizr_user\n current_user\n end",
"def current_user\n @current_user ||= authorize_request\n end",
"def current_user\n @current_user ||= authorize_request\n end",
"def current_user\n @current_user ||= authorize_request\n end",
"def edit\n @user = current_user\n end",
"def edit\n @user = User.find(params[:id])\n logger.tagged(\"edit current user: \") {logger.debug @current_user.attributes}\n #TODO : make sure permissions are handled correctly\n can_edit_hash = Permissions.currentLoggedInOrHasMorePermissions(@current_user,@user)\n logger.tagged(\"edit user perm hash: \") {logger.debug can_edit_hash}\n if can_edit_hash[:has_permission]\n can_destroy_hash = Permissions.hasMorePermissions(@current_user,@user)\n @can_destroy = can_destroy_hash[:has_permission]\n else\n flash[:warning] = can_edit_hash[:permission_message]\n redirect_to user_path(@user)\n end\n\n end",
"def update_permitted?\n\t\t# TODO: any other fields?\n\t\t# TODO: so does this show them the adminstrator field anyway?\n\t\tacting_user.administrator? || (acting_user == self && only_changed?(\n\t\t\t\t# what fields the user is permitted to change\n\t\t\t\t# NOTE: crypted_password has attr_protected so although it is can\n\t\t\t\t# change, it cannot be changed directly from a form submission\n\t\t\t\t:name,\n\t\t\t\t:user_name,\n\t\t\t\t:email_address,\n\t\t\t\t:crypted_password,\n\t\t\t\t:current_password,\n\t\t\t\t:password,\n\t\t\t\t:password_confirmation\n\t\t\t)\n\t\t)\n\t\t# Note: \n\tend",
"def edit_authorized(current_user)\n return self.user_id == current_user.id\n end",
"def edit_authorized(current_user)\n return self.user_id == current_user.id\n end",
"def edit\n \t@user = current_user\n end",
"def current_user\n raise NotImplementedError\n end",
"def current_user\n raise NotImplementedError\n end",
"def edit\r\n \t@user = current_user\r\n end",
"def edit\n authorize! :edit, @user, :id => current_user.id\n end",
"def current_user\n\t\t@current_user ||= authorize_request\n\tend",
"def user_params\n if current_user.is_admin?\n params.require(:user).permit(:name, :role, :email, :password)\n else\n params.require(:user).permit(:name, :email)\n end\n end",
"def user_params\n if (current_user)\n if (current_user.tipo.eql? 1)\n params.require(:user).permit(:nome, :email, :tipo, :status, :entidade_id, :password, :password_confirmation)\n else\n params.require(:user).permit(:nome, :email, :tipo, :status, :password, :password_confirmation)\n end\n else\n params.require(:user).permit(:nome, :email, :tipo, :status, :password, :password_confirmation)\n end\n end",
"def is_permitted_for?( user )\n ( user.id == self.user.id ) or ( user.privileged? )\n end",
"def user_params\n params.require(:user).permit(:name, :email, :image).merge(user_id: current_user.id)\n end",
"def pundit_user\n # if action_name == \"new\"\n # current_user\n # else\n current_user || current_company\n # end\n end",
"def context; { user: current_user } end",
"def authenticate_current_user_as_invited_user\n\t unless current_user == @invitation.invited_user\n\t redirect_to :back, alert: 'This invitation is not for you!'\n\t end\n\t end",
"def current_user(user)\n @current_user = user\n end",
"def authenticate_inviter!\n if cannot?( :invite, User )\n raise CanCan::AccessDenied\n else\n current_user\n end\n end",
"def update\n invitation_token = Devise.token_generator.digest(User, :invitation_token, params[:invitation_token])\n user = User.find_by(invitation_token: invitation_token)\n if user.present? && user.encrypted_password.present?\n user.accept_invitation\n inviter = User.find(user.invited_by_id)\n user.firm_id = inviter.firm_id\n user.role = user.invitation_role\n user.invitation_role = nil\n user.save!\n\n redirect_to root_path, notice: 'Invitation accepted.'\n else\n super\n # resource.name = resource.first_name + \" \" + resource.last_name\n # resource.save\n end\n # super\n\n\n # class_string_name = User::USER_ROLES[current_user.role].humanize\n # puts \"CONTACT TYPE ------> \" + class_string_name\n # create_contact(class_string_name, current_user, current_user.firm)\n end",
"def invitation_params\n params.permit(:project_id, :message, :invited_user_id)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def current_user\n @current_user ||= context[:current_user]\n end",
"def current_user(*args)\n warden.user(*args)\n end",
"def edit\n @user_array = @current_user.restricted? ? [ @current_user ] : User.active\n end",
"def current_user\n @user\n end",
"def get_current_user\n @current_user = current_or_guest_user\n end",
"def register_user_params\n filtered_params = {}\n if params[:account] && params[:account][:current_user]\n filtered_params.merge!(params.require(:account)\n .require(:current_user).permit(User.attribute_list))\n end\n filtered_params\n end",
"def showInvite\n @user = current_user\n end",
"def process_params!(params)\n #params.dup.update(user: current_user)\n params.merge!(current_user: current_user)\n end",
"def current_user=(user)\n @current_user = user \n end",
"def can_edit?(user)\n user == current_user\n end",
"def edit\n @user = User.find(params[:id])\n\n deny_wrong_user if !current_user?(@user)\n end",
"def unsanitised_user_params\n params.require(:user).permit(\n :name,\n :email,\n :organisation_id,\n :invitation_token,\n :password,\n :password_confirmation,\n :require_2sv,\n :role,\n supported_permission_ids: [],\n ).to_h\n end",
"def current_user\n get_from_options_or_controller(:current_user)\n end",
"def current_user(*args)\n warden.user(*args)\n end",
"def current_user(*args)\n warden.user(*args)\n end",
"def current_user=(user)\r\n @current_user = user\r\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end",
"def current_user=(user)\n @current_user = user\n end"
] | [
"0.6833828",
"0.676723",
"0.66149086",
"0.65951777",
"0.6354091",
"0.6225729",
"0.6192588",
"0.61914057",
"0.6180591",
"0.6169742",
"0.6164466",
"0.6160427",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.61588216",
"0.6138193",
"0.6134496",
"0.6115292",
"0.61132586",
"0.61033714",
"0.6097426",
"0.6097426",
"0.6092269",
"0.60807407",
"0.6078489",
"0.6077905",
"0.6077451",
"0.6077451",
"0.6057379",
"0.6038456",
"0.6038456",
"0.603421",
"0.5989303",
"0.598757",
"0.59849507",
"0.59663594",
"0.59640193",
"0.59054005",
"0.59045005",
"0.587089",
"0.58608043",
"0.585058",
"0.58494276",
"0.5840387",
"0.58359504",
"0.5821194",
"0.58196265",
"0.58189696",
"0.58165145",
"0.58114994",
"0.5790183",
"0.5789946",
"0.5787758",
"0.57865083",
"0.57796425",
"0.57727855",
"0.577194",
"0.57716197",
"0.57596445",
"0.5752368",
"0.5752368",
"0.57492924",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.5747681",
"0.57444704"
] | 0.0 | -1 |
returns true if the given token matches the digest. | def authenticated?(remember_token)
return false if remember_digest.nil?
# so here we compare the remember token, to the remember digest
BCrypt::Password.new(remember_digest).is_password?(remember_token)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticated?(digest, token)\n digest = send(\"#{digest}_digest\")\n # Use metaprogramming to select the appropriate token attribute based on\n # the parameter digest.\n return false if digest.nil? # Digest does not exist in the database.\n BCrypt::Password.new(digest).is_password?(token)\n # Decrypts the digest and compares it to the token.\n end",
"def authenticated?(token, digest = nil)\n return false if digest.present? && BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n digest.is_digest_for? token\n end",
"def validate_token(digest, token)\n if token.nil? || digest.nil?\n false\n else\n BCrypt::Password.new(digest).is_password?(token)\n end\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n digest == Digest::SHA1.hexdigest(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n digest == Digest::SHA1.hexdigest(token)\n end",
"def authenticated_with_token?(token)\n return false if token.nil?\n token == remember_digest\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\") # no need for self.send as we're in the user model\n return false if digest.nil?\n # verify the token matches the digest\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def valid_signature?(token)\n return false unless token =~ /&HMACSHA256=(.*)$/\n original_signature = CGI.unescape(token[/&HMACSHA256=(.*)$/, 1])\n bare_token = token.gsub(/&HMACSHA256=(.*)$/, '')\n signature = Base64.encode64(HMAC::SHA256.new(Base64.decode64(shared_secret)).update(bare_token.toutf8).digest).strip\n return original_signature == signature\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n # when digest nil ist soll die methode false zurückgeben damit Bcrypt keinen Fehler hervorrufen kann, wenn man sich bei zwei BRowsern eingeloggt hat und sich nur bei einem abmeldet, aber beide schließt.\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token) #takes a token, hashes it and compares it to the original hash_digest from the database. If hash_digest of given token is equal to the one saved in the database, authenticatedß returns true.\n end",
"def authenticated?(attribute, token)\n digest = self.try(\"#{attribute}_digest\")\n return false if digest.nil?\n ::BCrypt::Password.new(digest) == token\n end",
"def match_token(token)\n return true\n end",
"def authenticated?(attribute, token)\n \n digest = send(\"#{attribute}_digest\")\n \n return false if digest.blank? \n #ry.binding\n \n #BCrypt::Password.new will fail with invalid_hash as the new hash not having the valid_hash? coming tru for BCrypt gem.\n #It should be passed all the params as in cost and salt, so that it can be successfully be parsed. Otherwise use create.\n #https://github.com/codahale/bcrypt-ruby/blob/master/lib/bcrypt/password.rb\n # alias is_password, :== \n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_token_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token) \n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n\tdigest = send(\"#{attribute}_digest\")\n\treturn false if digest.nil?\n\tBCrypt::Password.new(digest).is_password?(token)\nend",
"def authenticated?(auth_token)\n return false if auth_token_digest.nil?\n BCrypt::Password.new(auth_token_digest).is_password? (auth_token)\n end",
"def authenticated?(attribute, token)\n \tdigest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n \tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil? \n \n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n digest.present? ? BCrypt::Password.new(digest).is_password?(token) : false\n end",
"def authenticated?(attribute, token)\n\t\tdigest = send(\"#{attribute}_digest\")\n\t\treturn false if digest.nil?\n\t\tBCrypt::Password.new(digest).is_password?(token)\n\tend",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute,token)\n digest = send(\"#{attribute}_digest\")\n return false if digest.nil?\n\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{attribute}_digest\") # self is omitted on send()\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(token)\n digest = self.otp_digest\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n\n end",
"def authenticated?(attribute, token)\n \tdigest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n \t\tdigest = send(\"#{attribute}_digest\")\n \treturn false if digest.nil?\n \tBCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = send(\"#{ attribute }_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end",
"def authenticated?(attribute, token)\n digest = self.send(\"#{attribute}_digest\")\n return false if digest.nil?\n BCrypt::Password.new(digest).is_password?(token)\n end"
] | [
"0.7914453",
"0.7654215",
"0.74407446",
"0.72914106",
"0.7161283",
"0.7161283",
"0.71551",
"0.69904083",
"0.69884264",
"0.6974271",
"0.68869066",
"0.687283",
"0.686985",
"0.6847443",
"0.6822308",
"0.6814704",
"0.67911905",
"0.67816776",
"0.67804825",
"0.6777267",
"0.67768365",
"0.67569935",
"0.67432934",
"0.67432934",
"0.67432934",
"0.67432934",
"0.67432934",
"0.67432934",
"0.67432934",
"0.67432934",
"0.67432934",
"0.67432934",
"0.67429096",
"0.674245",
"0.6742401",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.67395836",
"0.6738477",
"0.6729608",
"0.6727587",
"0.67221504",
"0.6717216",
"0.6711244",
"0.6699661",
"0.6699227",
"0.6698354",
"0.6698354",
"0.6698354",
"0.6698354",
"0.6698354",
"0.6698354",
"0.6698354",
"0.6698354",
"0.6698354"
] | 0.0 | -1 |
Originally written by Richard L. Apodaca | def get_text(random, alphabet = 'abcdefghijklmnopqrstuvwxyz', character_count = 6)
if character_count < 1 || character_count > 16
raise "Character count of #{character_count} is outside the range of 1-16"
end
input = "#{@secret}#{random}"
if alphabet != 'abcdefghijklmnopqrstuvwxyz' || character_count != 6
input << ":#{alphabet}:#{character_count}"
end
bytes = Digest::MD5.hexdigest(input).slice(0..(2*character_count - 1)).scan(/../)
text = ''
bytes.each { |byte| text << alphabet[byte.hex % alphabet.size].chr }
text
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def berlioz; end",
"def terpene; end",
"def stderrs; end",
"def suivre; end",
"def offences_by; end",
"def formation; end",
"def verdi; end",
"def anchored; end",
"def villian; end",
"def trd; end",
"def who_we_are\r\n end",
"def jack_handey; end",
"def gounod; end",
"def operations; end",
"def operations; end",
"def malts; end",
"def sitemaps; end",
"def refutal()\n end",
"def isolated; end",
"def isolated; end",
"def dh; end",
"def ibu; end",
"def internal; end",
"def internship_passed; end",
"def appraisals; end",
"def appraisals; end",
"def intensifier; end",
"def custom; end",
"def custom; end",
"def bs; end",
"def schumann; end",
"def weber; end",
"def sld; end",
"def implementation; end",
"def implementation; end",
"def upc_e; end",
"def loc; end",
"def loc; end",
"def loc; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def same; end",
"def rassoc(p0) end",
"def user_os_complex\r\n end",
"def r; end",
"def r; end",
"def blg; end",
"def identify; end",
"def herald; end",
"def silly_adjective; end",
"def ca; end",
"def celebration; end",
"def probers=(_arg0); end",
"def tld; end",
"def tld; end",
"def from; end",
"def from; end",
"def from; end",
"def from; end",
"def feruchemist; end",
"def extra; end",
"def returns; end",
"def operation; end",
"def romeo_and_juliet; end",
"def lsi; end",
"def code_of_conduct; end",
"def used?; end",
"def rossini; end",
"def isp; end",
"def isp; end",
"def ismn; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def offences_by=(_arg0); end",
"def yyerrok; end",
"def yyerrok; end",
"def getc() end",
"def getc() end",
"def getc() end",
"def rest_positionals; end",
"def scientist; end",
"def original_result; end",
"def mambo_no_5; end",
"def required_positionals; end",
"def alt; end",
"def hd\n \n end",
"def king_richard_iii; end",
"def state; end"
] | [
"0.74321735",
"0.6997013",
"0.65936744",
"0.6535431",
"0.6535431",
"0.6535431",
"0.6535431",
"0.63726467",
"0.6290715",
"0.6276794",
"0.621406",
"0.62074137",
"0.62059414",
"0.61825794",
"0.61589366",
"0.6087309",
"0.6086701",
"0.6061067",
"0.60419697",
"0.60411644",
"0.6011067",
"0.6011067",
"0.59978664",
"0.59884274",
"0.59663737",
"0.5958444",
"0.5958444",
"0.59482133",
"0.59403116",
"0.5924719",
"0.5922059",
"0.592118",
"0.592118",
"0.5916983",
"0.5909798",
"0.5909798",
"0.58780795",
"0.58770967",
"0.5866537",
"0.5862159",
"0.5859814",
"0.5859814",
"0.58460444",
"0.5842686",
"0.5842686",
"0.5842686",
"0.5829566",
"0.5829566",
"0.5829566",
"0.5829566",
"0.5822898",
"0.5822824",
"0.5817642",
"0.5813935",
"0.5813935",
"0.5803407",
"0.58030283",
"0.5794234",
"0.5793936",
"0.57743746",
"0.57578236",
"0.57511806",
"0.5734859",
"0.5734859",
"0.57174474",
"0.57174474",
"0.57174474",
"0.57174474",
"0.57001925",
"0.5669213",
"0.5662928",
"0.5659514",
"0.56417257",
"0.5636251",
"0.5636003",
"0.56358993",
"0.5635059",
"0.56323636",
"0.56323636",
"0.5619982",
"0.5605418",
"0.5605418",
"0.5605418",
"0.5605418",
"0.5605418",
"0.5605418",
"0.5596895",
"0.558395",
"0.558395",
"0.5581256",
"0.5581256",
"0.5581256",
"0.55804616",
"0.5576707",
"0.55723405",
"0.55669814",
"0.5563295",
"0.55490255",
"0.55480665",
"0.55473244",
"0.5547241"
] | 0.0 | -1 |
skip can be used for work in progress | def test_raises_error_for_bad_argument
skip "to-do"
assert_raises(ArgumentError) {@fb.convert('foo')}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip\n end",
"def skip\n end",
"def skip\n @skip = true\n end",
"def skip!\n @skip ||= true\n end",
"def skipped!; end",
"def skipped; end",
"def skip\n @scanner.skip(@skip)\n end",
"def skip(skip = nil)\n set_option(:skip, skip)\n end",
"def skipped?; end",
"def skipped?; end",
"def skipped?; end",
"def skipped?; end",
"def skip_during; end",
"def skip_during; end",
"def skip\n self[:skip]\n end",
"def skip!(skip = nil)\n mutate(:skip, skip)\n end",
"def skipped!\n @skipped = true\n end",
"def skips; end",
"def skip\n\t\tif @skipped==false \n\t\t\tswitch_player()\n\t\t\t@skipped = true \n\t\telsif @skipped==true \n\t\t\tend_game()\n\t\tend \n\tend",
"def skip()\n lines = send_message(\"SKIP\", message)\n end",
"def _skip_next\n @index += 1\n\n self\n end",
"def skip_after; end",
"def skip( n=1 )\n\t\t# Jump back into #each with the number of iterations to skip\n\t\tthrow( :skip, n ) if @iterating\n\tend",
"def skip reason = nil\n throw(:__tiramisu_status__, Tiramisu::Skip.new(reason, caller[0]))\n end",
"def skip?\n @skip\n end",
"def skip?\n @skip\n end",
"def skip?\n @skip\n end",
"def skip=(reason)\n @skip = reason\n end",
"def skip_wait\n @skip_wait = true\n end",
"def skip?\n @skip\n end",
"def skip(n)\n end",
"def skip reason = nil\n throw(:__tiramisu_skip__, Tiramisu::Skip.new(reason, caller[0]))\n end",
"def skip?\n false \n end",
"def skip!(msg = '(no message given)')\n @skipmessage = msg\n @skip = true\n end",
"def skip!(msg = '(no message given)')\n @skipmessage = msg\n @skip = true\n end",
"def skip(value)\n\t\t\tparam(\"skip\", value)\n\t\tend",
"def continue; end",
"def continue; end",
"def skip(num)\n @skip = num\n self\n end",
"def redo\n\t\tthrow( :skip, -1 ) if @iterating\n\tend",
"def command_skip\r\n @index += 1 while @list[@index + 1].indent > @indent\r\n end",
"def skip(reason=true)\n if block_given?\n @_skip = reason\n yield\n @_skip = nil\n else\n @_skip = reason\n end\n end",
"def skip\n @page_handler.skip\n end",
"def skip?\n !!@skip\n end",
"def skip_now\n @skipped = true\n raise TestSkip\n end",
"def skip(*args)\n log(*args)\n skip_now\n end",
"def skip!\n not_implemented\n end",
"def skip!\n loop do\n size = @io.getbyte\n break if size <= 0\n @io.seek(size, IO::SEEK_CUR)\n end\n end",
"def exec__working_batch_failure_skipped *args\n @working_batch.shift\n send :exec__batch, @working_batch, *args\n end",
"def skip\n param 'state' => Patriot::JobStore::JobState::SUCCEEDED\n end",
"def skip?\n @result.equal?(:skip)\n end",
"def skipped_lines; end",
"def skipped_lines; end",
"def skip_until(y, m, d, msg); end",
"def skip(amount = 1)\n @read_index += amount\n end",
"def skip(value = 0)\n update_query(:skip => value)\n end",
"def skip_next_move(player_no)\n\t\t@skip_next_move[player_no - 1]\n\tend",
"def skip(reason, &block)\n @_skips << [reason, block]\n end",
"def log_skip(context)\n logger.debug \"Skipped record #{context.position}: #{context.skipmessage}\"\n end",
"def log_skip(context)\n logger.debug \"Skipped record #{context.position}: #{context.skipmessage}\"\n end",
"def skip_page!\n raise(SkipPage)\n end",
"def log_skip(_entity); end",
"def skip(skip_msg = nil, called_from = nil)\n raise Result::TestSkipped, (skip_msg || \"\"), called_from\n end",
"def skip_rows!\n if skip > 0\n local_copy.in_place :tail, \"+#{skip + 1}\"\n end\n end",
"def skip(val)\n raise \"skip requires an Integer.\" unless val.is_a? Integer\n @skip = val\n self\n end",
"def skipped?\n status == :skipped\n end",
"def skipped?\n status == :skipped\n end",
"def process_skipped_lines(lines); end",
"def skip(reason=nil)\n @skipped ||= []\n @skipped |= reason ? Array(reason) : ['Manually skipped']\n end",
"def skip(count)\n\t\tfail ArgumentError.new(\"Count cannot be lower than 1, #{count} given\") unless count > 0\n\t\t@result = nil\n\t\t@skip = count\n\t\treturn self\n\tend",
"def skips_pre \n @skips_pre\n end",
"def skip(val)\n @query[:skip] = val.to_i\n self\n end",
"def skipped?\n @skipped\n end",
"def should_skip\n @skip = process_exist? if @skip.nil?\n @skip\n end",
"def skip!(count = 1)\n @next += count * (@upwards ? 1 : -1)\n end",
"def set_Skip(value)\n set_input(\"Skip\", value)\n end",
"def set_Skip(value)\n set_input(\"Skip\", value)\n end",
"def set_Skip(value)\n set_input(\"Skip\", value)\n end",
"def set_Skip(value)\n set_input(\"Skip\", value)\n end",
"def set_Skip(value)\n set_input(\"Skip\", value)\n end",
"def set_Skip(value)\n set_input(\"Skip\", value)\n end",
"def skip?\n raise NotImplementedError\n end",
"def continue\n @proceed = true\n end",
"def markSkipped message = nil\n raise SkippedTest, message\n end",
"def skip( reason=nil )\n\t\t\tif reason\n\t\t\t\tmsg = \"Skipping %s: %s\" % [ @method_name, reason ]\n\t\t\telse\n\t\t\t\tmsg = \"Skipping %s: No reason given.\" % @method_name\n\t\t\tend\n\t\t\t\n\t\t\t$stderr.puts( msg ) if $VERBOSE\n\t\t\t@method_name = :skipped_test\n end",
"def skip(value)\n query_proxy = OData::Model::QueryProxy.new(self)\n query_proxy.skip(value.to_i)\n end",
"def skip(msg = T.unsafe(nil), bt = T.unsafe(nil)); end",
"def skipped?\n @skipped\n end",
"def skip(name)\n blocks[name] = nil\n skipped_blocks[name] = true\n self.define_block_container(name) do\n end\n nil\n end",
"def skip!(task)\n\t\t\t\t@vertices += 1\n\t\t\t\t\n\t\t\t\tif task.failed?\n\t\t\t\t\t@failed << task\n\t\t\t\tend\n\t\t\tend",
"def skipped?\n !!skipped\n end",
"def skip_pin?\n skip = false\n if @skip_flag == true\n @skip_flag = false\n skip = true\n end\n skip\n end",
"def skipped?\n\t\t@skipped\n\tend",
"def skip_method(a,b,c)\nend",
"def skip_week\n for item in action_items\n item.skip! unless item.complete?\n end\n\n end",
"def skip_step\n session[:skipped_steps] ||= []\n session[:skipped_steps].push current_step\n\n return redirect_to workflow_url\n end",
"def skips=(_arg0); end",
"def skipped(message)\n log << \"[SKIPPED] #{message}\"\n false\n end",
"def continue?; end",
"def skipped?\n !!@skipped\n end",
"def skip(pattern)\n _scan_headonly(pattern, true, false)\n end"
] | [
"0.8477002",
"0.8477002",
"0.8225197",
"0.81066936",
"0.791982",
"0.7809044",
"0.77999854",
"0.7695461",
"0.76680577",
"0.76680577",
"0.76680577",
"0.76680577",
"0.7598539",
"0.7598539",
"0.7496644",
"0.74712086",
"0.7468461",
"0.74598306",
"0.74567366",
"0.74032295",
"0.7401176",
"0.73767424",
"0.7360806",
"0.7341542",
"0.73399013",
"0.73399013",
"0.73399013",
"0.73397964",
"0.732833",
"0.7319364",
"0.73138976",
"0.73080796",
"0.7281479",
"0.7195343",
"0.7195343",
"0.7128681",
"0.71236724",
"0.71236724",
"0.7086536",
"0.7078736",
"0.70229423",
"0.7018552",
"0.70170605",
"0.69725335",
"0.69374955",
"0.69358295",
"0.6909599",
"0.68887794",
"0.6876998",
"0.68693614",
"0.6842443",
"0.68413556",
"0.68413556",
"0.682716",
"0.68218064",
"0.6814795",
"0.6794884",
"0.6764835",
"0.675427",
"0.675427",
"0.6690668",
"0.66601175",
"0.664951",
"0.6639112",
"0.6638483",
"0.6625872",
"0.6625872",
"0.6610731",
"0.6610191",
"0.6585665",
"0.6580058",
"0.6576218",
"0.65642554",
"0.655707",
"0.653633",
"0.6511487",
"0.6511487",
"0.6511487",
"0.6511487",
"0.6511487",
"0.6511487",
"0.6468939",
"0.6458114",
"0.6457953",
"0.6455749",
"0.6451566",
"0.6450999",
"0.64480793",
"0.6422935",
"0.6405317",
"0.63864815",
"0.6384123",
"0.63560665",
"0.6352259",
"0.63510907",
"0.6345298",
"0.6337204",
"0.63241",
"0.6303626",
"0.62854356",
"0.62752074"
] | 0.0 | -1 |
4) Method that will take us to the form to create an new instance | def new
@post = Post.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\r\n\r\n end",
"def new\r\n \r\n end",
"def new\r\n end",
"def new\r\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end",
"def new\n end"
] | [
"0.7909018",
"0.78156126",
"0.7781826",
"0.7781826",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552",
"0.7715552"
] | 0.0 | -1 |
Return all of the fences straight from mongo | def get_all_fences
@coll.find.to_a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetchAllDocuments(collection)\n return collection.find({})\n end",
"def collections\n Collection.find(:all, :find_through => [N::DCT.hasPart, self])\n end",
"def get_fences(*args)\n\tfences = @@vars['access_token'].request(:get, \"/api/v3/geo_fences\", HEADERS)\n\tresult = nil\n\tif args.length > 0\n\t\taux = JSON[fences.body][args[0]]\n\t\tfor i in aux['shapes']\n\t\t\ti['points'] = []\n\t\tend\n\t\tresult = [aux.to_json]\n\n\telse\n\t\tresult = fences.body\n\tend\n\n\treturn result\nend",
"def documents\n collections.each_with_object(Set.new) do |(_, collection), set|\n set.merge(collection.docs).merge(collection.files)\n end.to_a\n end",
"def index\n @fine_collections = FineCollection.all\n end",
"def documents\n authorizations.map(&:document)\n end",
"def results\n documents\n end",
"def documents\n @mapped_documents ||= Basecamp3::Document.all(bucket.id, id)\n end",
"def find_entities\n []\n end",
"def fetch_scenarios\n collection = connect_to_mongo\n scenarios = {}\n collection.find.each { |doc| scenarios.merge!(doc) }\n scenarios.delete('_id')\n scenarios\nend",
"def existing_collections\n query = \"select $object $title from <#ri> \" +\n \"where $object <fedora-model:label> $title \" +\n \"and $object <fedora-model:hasModel> <info:fedora/islandora:collectionCModel>\"\n\n @repository.itql(query).map{ |row| row[0] }\n end",
"def eds_documents(data)\n docs = data&.dig('response', 'docs')\n docs = Array.wrap(docs).compact\n factory = blacklight_config.document_factory\n model_opt = { lens: blacklight_config.lens_key }\n docs.map { |doc| factory.build(doc, data, model_opt) }\n end",
"def all\n @document = Document.all\n end",
"def sample_documents\n HalOpenscience::Document.search(\"authIdFormPerson_s:#{docid}\", fields: ['citationFull_s'], limit: 5)\n .results\n .collect(&:citationFull_s)\n end",
"def documents\n document_entries.map{ |f| FileObject[path, f] }\n end",
"def all; @docs.values end",
"def display_all_data(collection, keys)\n rc_list = []\n parts = collection.parts\n parts.each do |part|\n rc_list += collection.find(part)\n end\n display_data(collection, rc_list, keys)\n end",
"def all\n documents\n end",
"def entities\n _entities\n end",
"def entities\n _entities\n end",
"def index\n @geofences = Geofence.all\n end",
"def docs #returns string array of all documents in collection\n raise \"Must be implemented.\"\n return array_of_documents\n end",
"def object_hash_get_all(collection)\n logger.debug \"Retrieving object documents from collection(#{collection})\"\n @database.object_doc_get_all(collection)\n end",
"def object_hash_get_all(collection)\n logger.debug \"Retrieving object documents from collection(#{collection})\"\n @database.object_doc_get_all(collection)\n end",
"def resources\n self.collection.find({}, :sort => [:_id, :asc]).map do |hash|\n self.normalize hash\n end\n end",
"def index\n @freelance_documents = FreelanceDocument.order('created_at DESC')\n end",
"def tables\n Mongo::DocumentDefinition.defined_document_names\n #db.collection_names\n end",
"def all\n @documents = Document.order(\"id DESC\").all\n end",
"def all_collections\n @all_collections ||= Blacklight.solr.select(\n :params => {\n :fq => \"#{blacklight_config.collection_identifying_field}:\\\"#{blacklight_config.collection_identifying_value}\\\"\",\n :rows => \"10\"\n }\n )[\"response\"][\"docs\"].map do |document|\n SolrDocument.new(document)\n end\n end",
"def documents\n if acknowledged?\n replies.flat_map(&:documents)\n else\n []\n end\n end",
"def list_collections(db)\n return db.collection('__METADATA__').find({'_id' => {'$ne'=> '__METADATA__'}}, {:fields => '_id'}).map {|c| c['_id']}\n end",
"def find_collections_for_form\n query = list_search_builder.with(q: '').query\n response = repository.search(query)\n response.documents\n end",
"def list\n\t\tdocs = proxy_database.view(\"#{shared_data_context.name}/all\")[\"rows\"]\n\t\treturn docs\n \tend",
"def all(coll)\n @db[coll].find\n end",
"def contents\n \tdoc = self.class.mongo_client.database.fs.find_one(:_id => BSON::ObjectId(@id))\n \tif doc\n \t buffer = \"\"\n \t doc.chunks.reduce([]) do |x, chunk|\n \t buffer << chunk.data.data\n \t end\n \t return buffer\n \tend\n end",
"def entities\n @entities\n end",
"def collections\n return [] if name.nil?\n\n query = Solr::Query.new(\n collections_query,\n 100,\n fq: \"-ancestor_id_ssim:[* TO *]\"\n )\n query.to_a\n end",
"def index\n @family_documents = FamilyDocument.all\n end",
"def get_previously_imported_docs\n $db[:standard_documents].find()\n .projection({\"documentMeta.primaryTopic\" => 1, \"retrieved.modifiedAccordingToASNApi\" => 1, \"_id\" => 1})\n .to_a\n .reduce({}){|memo, d|\n memo.merge({\n d[\"documentMeta\"][\"primaryTopic\"] => d[\"retrieved\"][\"modifiedAccordingToASNApi\"]\n })\n }\nend",
"def results\n @solr_data[:docs]\n end",
"def show_pres\r\n pres = Document.new(self).get_pres\r\n puts \"There are #{pres.length} pres\"\r\n index = 1\r\n pres.each do |l|\r\n puts \"pre: id: #{l.id}\"\r\n puts \" name: #{l.name}\"\r\n puts \" index: #{index}\"\r\n index += 1\r\n end\r\n end",
"def collection\n @recommendations ||= end_of_association_chain.find :all, :order => 'position'\n end",
"def collection\n conditions = conditions_from_params\n @collection ||= end_of_association_chain.find(:all, :conditions => conditions)\n end",
"def index\n @resume_collections = ResumeCollection.all\n end",
"def collections(rows: 6)\n builder = Hyrax::CollectionSearchBuilder.new(self)\n .rows(rows)\n response = repository.search(builder)\n response.documents\n rescue Blacklight::Exceptions::ECONNREFUSED, Blacklight::Exceptions::InvalidRequest\n []\n end",
"def index\n @products = Product.all\n # @product = Product.where(:created_at.lte => Date.today).group_by {|d| d.created_at.strftime(\"%d-%m-%y\")}\n respond_to do |format|\n @products_bson1 = []\n @products_bson2 = []\n @products.each do |pro|\n @products_bson = BSON::Document.new(pro.attributes)\n @products_bson1.push(@products_bson)\n @products_bson2 = @products_bson1.to_bson\n format.html # index.html.erb\n format.bson { render json: @products_bson2 }\n format.json { render json: @products }\n format.xml { render xml: @products }\n end\n end\nend",
"def breakdowns_coll\n settings.db['breakdowns']\n end",
"def index\n if params[:fulldoc].nil? then\n @singleparts = Singlepart.all\n else\n @singleparts = Singlepart.where(['fulldoc_id = ?', params[:fulldoc]])\n end\n end",
"def documents; end",
"def documents; end",
"def collections; end",
"def index\n @absences = Absence.all\n end",
"def index\n @absences = Absence.all\n end",
"def documents\n return results[\"result\"] if results.has_key?(\"result\")\n end",
"def documents\n # This function and its helpers are side-effecty for speed\n @documents ||= raw[:hits][:hits].map do |hit|\n doc = extract_source(hit)\n copy_underscores(hit, doc)\n copy_highlight(hit, doc)\n doc\n end\n end",
"def kefed_ordered_data_collections\n yogo_model.ordered_measurements.map do |ym| \n data_collections.select{|dc| dc.id.to_s == ym['uid'].downcase }[0]\n end\n end",
"def results\n @solr_data[:docs]\n end",
"def ordered_docs\n @ordered_docs ||= ActiveFedora::SolrService.query(\"member_of_collection_ids_ssim:#{id}\", rows: 10_000).map { |x| SolrDocument.new(x) }\n end",
"def children\n# Dir[file_path + '/*'].map do |path|\n# child File.basename(path)\n# end\n @collection.find({:filename => /^#{Regexp.escape(@bson['filename'])}[^\\/]+\\/?$/}).map do |bson|\n child bson\n end\n end",
"def from_mongo(docs)\n\n rekey(docs) { |k| k.gsub(/^ⸯ\\$/, '$').gsub(/˛/, '.') }\n end",
"def documents\n reply ? reply.documents : []\n end",
"def entities; end",
"def all\n response = run\n\n while continue?(response)\n @options[:exclusive_start_key] = response.last_evaluated_key\n response = run(response)\n end\n\n @collection.deserialize(response.entities)\n end",
"def all_objects\n objects = []\n each_namespace{|n| objects << n}\n each_namespace{|n| \n n.each_relvar{|r| objects << r}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_candidate_key{|k| objects << k}}\n }\n each_namespace{|n| \n n.each_relvar{|r| r.each_foreign_key{|k| objects << k}}\n }\n objects\n end",
"def documents\n Hancock::Request.send_get_request(\"/envelopes/#{envelope_id}/documents\")[\"envelopeDocuments\"]\n end",
"def solr_associations\n doc = {}\n # update_file_ids\n model.association_fields.each do |f|\n instances = find_association(f.to_param)\n next unless instances\n doc[\"bindery__associations_sim\"] ||= []\n instances.each do |instance|\n doc[\"bindery__associations_sim\"] << instance.persistent_id\n facet_name_for_association = Node.solr_name(f.code, type: 'facet', multivalue:true)\n doc[facet_name_for_association] ||= []\n doc[facet_name_for_association] << instance.title\n field_name_for_association = Node.solr_name(f.code, multivalue:true)\n doc[field_name_for_association] ||= []\n doc[field_name_for_association] << instance.title\n instance.solr_attributes(f.code + '__', multivalue:true).each do |k, v|\n doc[k] ||= []\n doc[k] << v\n end\n end\n end\n doc\n end",
"def collections_coll\n settings.db['collections']\n end",
"def collections\n return self.root_collection.subcollections\n end",
"def process(collection)\n return collection.inject(Results.new) do |h, k|\n key = k.values[0].to_s =~ /(^[-+]?[0-9]+$)|(\\.0+)$/ ? Integer(k.values[0]) : Float(k.values[0])\n val = serialize(k.values[1].is_a?(String) ? k.values[1].split(',') : k.values[1], @field_type)\n h << Document.new(:_key_name => @field_name, :_key_value => key, key.to_s => val, @count_field => val)\n end\n end",
"def get_docs_in_collections(raw_collection_names)\r\n if raw_collection_names.is_a?(String)\r\n collection_names = raw_collection_names.split(/;|,|\\s/)\r\n else\r\n collection_names = raw_collection_names\r\n end\r\n\r\n docs = []\r\n # Now for each of the collections get the docs\r\n collection_names.each do |coll_name|\r\n # Request all the documents for the collection in question, and join it with the total collection \r\n docs += @collection_by_name_lambda.call(coll_name.downcase.strip)\r\n end\r\n\r\n # Hidden documents should not not be processed anywhere.\r\n docs = docs.reject { |doc| doc['hidden'] }\r\n\r\n return docs\r\n end",
"def users\n faves.map do |fave|\n fave.user\n end\n end",
"def index\n @boat_documents = BoatDocument.all\n end",
"def collections(what)\n list = []\n collections = what == 'all' ? all_collections() : local_collections()\n collections.each do |collection|\n model = collection.classify.constantize rescue nil\n next if model.nil?\n next unless model.respond_to?(:mongo_client)\n record = {'id' => collection, 'description' => I18n.t(\"helpers.label.#{collection}.tabletitle\") } \n list << [record, model_fields(collection)]\n end\n list\nend",
"def load_entries_from_edw\n STDERR.puts \"Loading PrefixFence data from EDW for #{mss_name}.\"\n data = []\n SqlServer.create(EDW::SOURCE, EDW::DM_ALCATEL::DATABASE) do |db|\n db.query sql\n # puts db.fields\n data = db.data\n end\n data\n end",
"def collection\n @collection ||= database.collection Crocoduck::Store.server_collection\n end",
"def artists\nSong.all.collect{|x| x.artist}\nend",
"def attachments\n eco_documents = self.eco_documents.reverse\n eco_documents.delete_if { |d| d.specification? }.reverse\n end",
"def index\n @estadisticas = Estadistica.all\n @referers = Usuario.collection.aggregate \"$group\" => { _id: \"$referer\", count: { \"$sum\" => 1}}\n @landings = Usuario.collection.aggregate \"$group\" => { _id: \"$landing\", count: { \"$sum\" => 1}}\n end",
"def index\n @sentences = Sentence.all\n end",
"def find_all\n \n end",
"def ids; @docs.keys end",
"def digest\n @articles = Article.where(include_in_digest: true)\n end",
"def get_nearby_documents(id)\n @original_document = get_solr_response_for_doc_id(id).last # returns an array with a response object and the document.\n return [] unless document_has_required_fields?\n shelfkey = get_value_from_combined_key(combined_key, shelfkey_field)\n reverse_shelfkey = get_value_from_combined_key(combined_key, reverse_shelfkey_field)\n if normalized_page == 0\n previous_documents = get_next_documents_from_field_value(reverse_shelfkey, reverse_shelfkey_field)\n next_documents = get_next_documents_from_field_value(shelfkey, shelfkey_field)\n documents = [previous_documents, @original_document, next_documents].flatten\n elsif @opts[:page].to_i < 0\n documents = get_next_documents_from_field_value(reverse_shelfkey, reverse_shelfkey_field)\n elsif @opts[:page].to_i > 0\n documents = get_next_documents_from_field_value(shelfkey, shelfkey_field)\n end\n documents\n end",
"def index\n @has_documents = HasDocument.all\n @clauses = Clause.all\n end",
"def collection\n feature_id = nil\n if params[:feature_id]\n feature_id = params[:feature_id]\n elsif params[:id]\n feature_id = object.feature_id\n end\n if params[:filter].blank? && !feature_id.blank?\n search_results = parent_object.definitions\n elsif !params[:filter].blank?\n search_results = Definition.search(params[:filter])\n search_results = search_results.where(:feature_id => feature_id) if feature_id\n else\n search_results = []\n end\n @collection = search_results.empty? ? search_results : search_results.page(params[:page])\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def index\n @documents = Document.all\n end",
"def init_collection\n strong_memoize(:init_collection) do\n filter(finder.execute).reorder(nil)\n end\n end",
"def find_films_for_each_customer()\n sql = \"SELECT films.*\n FROM films\n INNER JOIN tickets\n ON tickets.film_id = films.id\n WHERE customer_id = $1\"\n values = [@id]\n films = SqlRunner.run(sql, values)\n result = films.map {|film| Film.new(film)}\n return result\n end",
"def entities\n @entities ||= []\n end",
"def index\n @collections = Collection.all\n end",
"def index\n @collections = Collection.all\n end",
"def getEdgeCollections\r\n result = request(\"GET\", \"edge\", key: :collections)\r\n return result if @database.server.async != false\r\n return result if return_directly?(result)\r\n result.map{|r| Arango::Collection.new(database: @database, name: r, type: :edge)}\r\n end",
"def index\n @frases = Frase.all\n end",
"def search_result\n freelancers = find_all FREELANCERS\n end"
] | [
"0.5769389",
"0.57668024",
"0.574559",
"0.5696761",
"0.56550366",
"0.55680275",
"0.5538155",
"0.55051553",
"0.54959077",
"0.54875195",
"0.5479067",
"0.54726964",
"0.54434806",
"0.54212505",
"0.54137194",
"0.5397044",
"0.53674024",
"0.5364694",
"0.5359403",
"0.5359403",
"0.535915",
"0.5352493",
"0.5340298",
"0.5340298",
"0.5338699",
"0.5321983",
"0.531633",
"0.53114825",
"0.52787334",
"0.52708346",
"0.5256675",
"0.5242781",
"0.5241863",
"0.5237413",
"0.52374077",
"0.52134347",
"0.52102673",
"0.52098674",
"0.52018887",
"0.51731104",
"0.5154162",
"0.51383406",
"0.5115629",
"0.51143396",
"0.5113003",
"0.51053524",
"0.51020163",
"0.50838745",
"0.5081359",
"0.5081359",
"0.50766146",
"0.50685215",
"0.50685215",
"0.50599223",
"0.5051669",
"0.50498533",
"0.5048889",
"0.5048323",
"0.50416386",
"0.5038167",
"0.5033188",
"0.50330603",
"0.5027381",
"0.50201905",
"0.501735",
"0.5016927",
"0.5015087",
"0.5012991",
"0.5012643",
"0.50066555",
"0.5005384",
"0.49972525",
"0.4987429",
"0.49844816",
"0.49758008",
"0.49757758",
"0.49703726",
"0.49692005",
"0.4965244",
"0.4964582",
"0.49643052",
"0.49640444",
"0.49615628",
"0.49605966",
"0.4956337",
"0.49556327",
"0.49556327",
"0.49556327",
"0.49556327",
"0.49556327",
"0.49556327",
"0.49556327",
"0.49441722",
"0.4943748",
"0.49362803",
"0.49335286",
"0.49335286",
"0.49272823",
"0.49266967",
"0.49240285"
] | 0.78418446 | 0 |
, :xml, :json GET /odiseo/reports/new GET /odiseo/reports/new.json GET /odiseo/reports/new.xml | def new
@balance_report = BalanceReport.new(current_company)
respond_to do |format|
format.html # .html.erb
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_type }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_type }\n end\n end",
"def new\n @report = Mg::Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report = Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report2 = Report2.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report2 }\n end\n end",
"def new\n @dailyreport = Dailyreport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dailyreport }\n end\n end",
"def new\n @report_file = ReportFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report_file }\n end\n end",
"def new\n @comparative_report = ComparativeReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @comparative_report }\n end\n end",
"def new\n @stores_report = Stores::Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stores_report }\n end\n end",
"def new\n @report_line = ReportLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_line }\n end\n end",
"def new\n @tps_report = TpsReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tps_report }\n end\n end",
"def new\n @software_report = SoftwareReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @software_report }\n end\n end",
"def new\n @user_report = UserReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_report }\n end\n end",
"def create\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @export = Export.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @export }\n end\n end",
"def new\n @report_field = ReportField.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_field }\n end\n end",
"def new\n @event = Event.find(params[:event_id])\n @report = @event.reports.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @inpatientdailyreport = Inpatientdailyreport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @inpatientdailyreport }\n end\n end",
"def new\n @user_reports = UserReport.new(params[:user_report])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user_reports }\n end\n end",
"def new\n respond_to do |format|\n format.html\n format.xml\n end\n end",
"def new\n @ort = OtrunkReportTemplate.find(:all).map {|ort| [ort.name, ort.id]}\n @report.public = true\n @report.user = current_user\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def new\n @dailyreport_job = DailyreportJob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dailyreport_job }\n end\n end",
"def new\n @fin_report = FinReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fin_report }\n end\n end",
"def create\n\n\n @report = Report.new(params[:report])\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @report_field_template = ReportFieldTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_field_template }\n end\n end",
"def new\n @uncoiler_report = UncoilerReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uncoiler_report }\n end\n end",
"def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end",
"def new\n @statusreport = Statusreport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @statusreport }\n end\n end",
"def new\n @report = Report.new\n\n @menu = \"report\"\n @page_title = \"Report a UFO\"\n @page_description = \"Have you seen a UFO? Report your experience filling in the report form\"\n @notice = 'Introduce the text of the image'\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n\n end",
"def new\n \n #@neuotransmitter_report = NeuotransmitterReport.new\n # LDN_report = Nokogiri::XML(open(\"LDN_neurotransmitter_report\"))\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neuotransmitter_report }\n end\n end",
"def new\n @report = current_user.reports.new\n @sources = current_user.sources\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n @report = Report.new\n @report.build_esclerosi\n @report.build_displasium\n @report.build_tumor\n @report.build_malformacion\n @report.build_conclusion\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml \n end\n end",
"def new\n @report = Report.new\n session[:report_id] = nil\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reports }\n end\n end",
"def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end",
"def create\n @report = Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @report_type.save\n format.html { redirect_to(@report_type, :notice => 'Report type was successfully created.') }\n format.xml { render :xml => @report_type, :status => :created, :location => @report_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n if params[:type].nil? || params[:type].blank?\n redirect_to reports_path, :alert => \"You must select a report type to create a new report\"\n else\n @report_type = ReportType.find_by_name(params[:type].titleize)\n @report = @report_type.reports.new\n @report_type.build_information_for(@report)\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @report }\n end\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.json {render json: @page}\n format.xml {render xml: @page}\n end\n end",
"def new\n @download = Download.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @download }\n end\n end",
"def new\n @download = Download.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @download }\n end\n end",
"def new\n @spam_report = SpamReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spam_report }\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 create_new_report!; end",
"def create_new_report!; end",
"def new\n @group_report = GroupReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group_report }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @inventory_report = InventoryReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inventory_report }\n end\n end",
"def new\n @survey_report = SurveyReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @survey_report }\n end\n end",
"def new\n @analysis = Analysis.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @analysis }\n end\n end",
"def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.json { render json: @page }\n format.xml { render xml: @page }\n end\n end",
"def create\n @report = Mg::Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { flash[:notice] = 'Your report was successfully created, now add some report items.'; redirect_to(edit_mg_report_url @report) }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # debugger\n # reportable = params[:report][:reportable].split(',').collect {|s| s.strip}\n #\n # at this point params might be:\n #\n # {\"commit\"=>\"Create\", \"action\"=>\"create\", \"controller\"=>\"reports\", \n # \"report\"=>{\"name\"=>\"third report\", \"public\"=>\"0\", \"reportable_id\"=>\"1\", \"description\"=>\"another description\", \"otrunk_report_template_id\"=>\"1\"}}\n #\n # we can just create a new @report instance like this:\n #\n # \n # This way all the parameters are set that are present in the\n # hash value for \"report\" in params.\n #\n # but do need to handle hard-coding the reportable_type because\n # it isn't handled more generally yet by the view or the DIY\n #\n #\n # eot_id = params[:report][:reportable_id]\n # ort_id = params[:report][:otrunk_report_template_id]\n # @report = Report.new(:reportable_type => \"ExternalOtrunkActivity\", :reportable_id => eot_id, :otrunk_report_template_id => ort_id)\n #\n @report.user = current_user\n respond_to do |format|\n if @report.save\n flash[:notice] = 'Report was successfully created.' \n format.html { redirect_to reports_url }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n flash[:notice] = 'Errors creating Report.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @download_registration }\n end\n end",
"def new\n @summary_report = SummaryReport.new\n @projects = Project.find :all\n @users = User.find :all\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @summary_report }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report_type }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @report_type }\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to admin_reports_path, notice: t('shared.msgs.success_created',\n obj: t('activerecord.models.report', count: 1)) }\n format.json { render :show, status: :created, location: @report }\n else\n set_date\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n get_sources\n @stg_source = StgSource.all\n @report = Report.find(params[:report_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @source }\n end\n end",
"def new\n @quarterly_report = QuarterlyReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @quarterly_report }\n end\n end",
"def new\n @report_group = Irm::ReportGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report_group }\n end\n end",
"def new\n @suite = Suite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @suite }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @import }\n end\n end",
"def new\n @po = Po.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @po }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n \n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end",
"def new\n @scraper = Scraper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scraper }\n end\n end",
"def new\n @page = Page.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @temp = Temp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @temp }\n end\n end",
"def new_rest\n @answer_localized = AnswerLocalized.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @answer_localized }\n end\n end",
"def new\n @series = Series.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @series }\n end\n end",
"def new\n @transfer_slip = TransferSlip.new\n @report = Report.find(params[:report_id]) if params[:report_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transfer_slip }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @dashboard = Dashboard.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dashboard }\n end\n end",
"def new\n @dashboard = Dashboard.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dashboard }\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 @management_info_system_report = ManagementInfoSystemReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @management_info_system_report }\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 @home_categories_products_report = Home::Categories::Products::Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @home_categories_products_report }\n end\n end",
"def new\n @document = Document.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @document }\n end\n end",
"def new\n @data_set = DataSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @data_set }\n end\n end",
"def create\n @report = Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stores_report = Stores::Report.new(params[:stores_report])\n\n respond_to do |format|\n if @stores_report.save\n format.html { redirect_to @stores_report, notice: 'Report was successfully created.' }\n format.json { render json: @stores_report, status: :created, location: @stores_report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stores_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @page }\n end\n end",
"def new\n @doc = Doc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @doc }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job }\n end\n end",
"def new\n #@team_report = TeamReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team_report }\n end\n end"
] | [
"0.7522353",
"0.7345851",
"0.7345851",
"0.7226597",
"0.696384",
"0.696384",
"0.696384",
"0.696384",
"0.69319963",
"0.6924615",
"0.68323624",
"0.67997795",
"0.6795443",
"0.6787265",
"0.67549235",
"0.6745474",
"0.6707421",
"0.67070466",
"0.67058134",
"0.6678424",
"0.6659346",
"0.66574746",
"0.65903836",
"0.6585157",
"0.6580657",
"0.65793383",
"0.654787",
"0.6543127",
"0.6536797",
"0.65271795",
"0.6524923",
"0.65204096",
"0.6518235",
"0.6502644",
"0.6497897",
"0.6494217",
"0.64933974",
"0.6487099",
"0.6476725",
"0.64734733",
"0.64698863",
"0.6458527",
"0.64477444",
"0.644187",
"0.64298916",
"0.64298916",
"0.6423001",
"0.641998",
"0.6397952",
"0.6397952",
"0.6395996",
"0.63920766",
"0.63894475",
"0.6388346",
"0.63757795",
"0.6372572",
"0.63424444",
"0.6340037",
"0.63383406",
"0.6333057",
"0.6331082",
"0.63309884",
"0.63273495",
"0.63273495",
"0.6291068",
"0.6275504",
"0.6267678",
"0.6266773",
"0.6263533",
"0.62630206",
"0.6253963",
"0.6247599",
"0.62475336",
"0.62475336",
"0.62437177",
"0.62412435",
"0.6237818",
"0.6237366",
"0.6230013",
"0.6228767",
"0.62226415",
"0.62226415",
"0.62226415",
"0.62226415",
"0.62226415",
"0.62226415",
"0.6220021",
"0.6220021",
"0.62157804",
"0.6209227",
"0.6209057",
"0.62064487",
"0.6206257",
"0.61956704",
"0.61946726",
"0.61946726",
"0.61878324",
"0.6185224",
"0.6184398",
"0.6181448",
"0.6181016"
] | 0.0 | -1 |
POST /odiseo/reports POST /odiseo/reports.json POST /odiseo/reports.xml | def create
@balance_report = BalanceReport.new(current_company, params[:odiseo_balance_report])
@accounts = @balance_report.accounts.page(params[:page])
flash.now[:notice] = t('flash.actions.index.notice') if @balance_report.valid? && @accounts.empty?
respond_to do |format|
format.html do
render :new
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reports\n @node = resource\n @reports = params[:kind] == \"inspect\" ? @node.reports.inspections : @node.reports.applies\n respond_to do |format|\n format.html { @reports = paginate_scope(@reports); render 'reports/index' }\n end\n end",
"def report(object)\n full_name = extract_full_name object\n post 'api/report', :id => full_name\n end",
"def report\n \n end",
"def write_report\n\n end",
"def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reports }\n end\n end",
"def create\n @office_report = Office::Report.new(office_report_params)\n\n respond_to do |format|\n if @office_report.save\n format.html { redirect_to @office_report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @office_report }\n else\n format.html { render :new }\n format.json { render json: @office_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def report\n @report = Report.create(reports_params)\n if @report.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create report' }, status: :internal_server_error\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to admin_reports_path, notice: t('shared.msgs.success_created',\n obj: t('activerecord.models.report', count: 1)) }\n format.json { render :show, status: :created, location: @report }\n else\n set_date\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n\n @report = Report.new(params[:report])\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def report\n\t\tend",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = UserReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def create\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to police_index_path, notice: 'Report was successfully created.' }\n format.json { render :index, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n \n @report.test_suite.test_cases.each do |test_case|\n @report.results.create({ status: 'Queued', report_id: @report, test_case_id: test_case.id})\n end\n \n format.html { redirect_to [:admin, @report], notice: 'Report was successfully created.' }\n format.json { render action: 'show', status: :created, location: @report }\n else\n format.html { render action: 'new' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"count_of_table_sid_by_field_sid\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = AccessReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end",
"def reports_list\r\n post= { \"token\" => @token }\r\n file=nessus_http_request('report/list', post)\r\n return file \r\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = DevFeedbackReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'El Reporte fue creado Exitosamente.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to(@report, :notice => 'Report was successfully created.') }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def reports\n collection(\"reports\")\n end",
"def index\n @payrolls = Payroll.all\n reports_data(@payrolls)\n end",
"def create\n @custom_report = CustomReport.new(params[:custom_report])\n\n if @custom_report.save\n render json: @custom_report, status: :created, location: @custom_report\n else\n render json: @custom_report.errors, status: :unprocessable_entity\n end\n end",
"def send_reports(type, reports)\n dir = File.join(\"/tmp\", type, \"#{@start_date.strftime(\"%Y-%m\")}_to_#{@end_date.strftime(\"%Y-%m\")}\")\n FileUtils.mkdir_p dir\n reports.each do |name, report|\n file = File.join(dir, name)\n File.write(file, CounterReporterService.csv(report))\n Rails.logger.info(\"[ROYALTY REPORTS] wrote #{file}\")\n end\n rescue StandardError => e\n \"[ROYALTY REPORTS] Error: #{e}\\n#{e.backtrace.join(\"\\n\")}\"\n end",
"def create\n @action_report = ActionReport.new(action_report_params)\n\n respond_to do |format|\n if @action_report.save\n format.html { redirect_to @action_report, notice: 'Action report was successfully created.' }\n format.json { render :show, status: :created, location: @action_report }\n else\n format.html { render :new }\n format.json { render json: @action_report.errors, status: :unprocessable_entity }\n end\n end\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 index\n @reports = Report.last(7)\n @diaries = Report.order(:created_at)\n respond_to do |format|\n format.html\n format.csv { send_data @diaries.to_csv }\n format.xls { send_data @diaries.to_csv(col_sep: \"\\t\") }\n end\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = BgWorkerReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def save_report\n\n # Parse the result with Nokogiri\n response = connect\n\n # Add the column headers to the file\n write_column_headers\n\n # Append the first batch of data to the file\n write_batch_data\n\n # Save the token for successive calls\n token = \"&token=\" + response[:token] || \"\"\n\n # Loop until the end of the query\n until response[:is_finished] === \"true\"\n response = connect(token)\n write_batch_data\n end\n\n end",
"def index\n @et_reports = EtReport.all\n end",
"def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def reports\n\n \t if params[\"from_date\"].present? and params[\"to_date\"].present?\n @date=params[:from_date]\n @data=JSON.parse RestClient.get $api_service+\"/claims/data_report?from_date=#{params[\"from_date\"]}&to_date=#{params[\"to_date\"]}\"\n elsif params[:date]\n @data=JSON.parse RestClient.get $api_service+\"/claims/data_report?from_date=#{params[\"date\"]}&to_date=#{params[\"date\"]}\"\n @date=params[:date]\n else \n @date=Date.today \n @data=JSON.parse RestClient.get $api_service+'/claims/data_report'\n end\n\n end",
"def create\n @user_report = UserReport.new(params[:user_report])\n @user_report.env = request.env\n respond_to do |format|\n if @user_report.save\n flash[:ok] = 'Got it, thanks for taking the time!'\n format.html { redirect_to_default }\n format.xml { render :xml => @user_report, :status => :created, :location => @user_reports }\n format.js { render :nothing => true}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @hotel = Hotel.find_by(params[:hotel_id])\n @report = @hotel.reports.new(report_params)\n\n respond_to do |format|\n if @report.save\n flash[:success] = \"Report created successfuly.\"\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n flash[:alert] = \"Errors where found.\"\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def export_report\n @report.export_report\n end",
"def export_report\n @report.export_report\n end",
"def create\n @neuotransmitter_report = NeuotransmitterReport.new(params[:neuotransmitter_report])\n\n respond_to do |format|\n if @neuotransmitter_report.save\n format.html { redirect_to @neuotransmitter_report, notice: 'Neuotransmitter report was successfully created.' }\n format.json { render json: @neuotransmitter_report, status: :created, location: @neuotransmitter_report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @neuotransmitter_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # if report is valid, save it and set flag (no need to run it b/c it will be redirected)\n @report.just_created = true if @report.errors.empty?\n \n # return data in json format\n render(:json => {:report => @report}.to_json)\n end",
"def index\n @reportes = Reporte.all\n respond_to do |format|\n format.html\n format.json\n format.csv {send_data @reportes.to_csv}\n format.pdf do\n pdf = ReportPdf.new(@reportes)\n send_data pdf.render, filename: \"report_#{Time.now}.pdf\", type: 'application/pdf'\n end\n end\n end",
"def json_report(test_report)\n test_report.to_json\n end",
"def create_new_report!; end",
"def create_new_report!; end",
"def reports\n backend.reports\n end",
"def create\n @ee_report = EeReport.new(ee_report_params)\n \n\n respond_to do |format|\n if @ee_report.save\n format.html { redirect_to @ee_report, notice: 'Ee report was successfully created.' }\n format.json { render :show, status: :created, location: @ee_report }\n else\n format.html { render :new }\n format.json { render json: @ee_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n raise \"Disabled\"\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @report }\n else\n format.html { render :new }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @action_reports = ActionReport.all\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 save_report\n Report.transaction do\n report = Report.create(name: @name,\n start_date: @start_date,\n end_date: @end_date,\n type: @type,\n creator: User.current.id,\n renderer_type: 'PDF')\n\n values = save_report_values(report)\n\n { report: report, values: values }\n end\n end",
"def create\n if OpinionReport.where(opinion_report_params).count > 0\n render json: {\n status: \"Error\",\n message: \"Ya se ha enviado un reporte sobre esta opinión\"\n }.to_json\n else \n @opinion_report = OpinionReport.new(opinion_report_params)\n if @opinion_report.save\n render json: {\n status: \"Exito\",\n message: \"Se ha enviado la denuncia satisfactoriamente\"\n }.to_json\n else\n format.json { render json: @opinion_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def create\n @stores_report = Stores::Report.new(params[:stores_report])\n\n respond_to do |format|\n if @stores_report.save\n format.html { redirect_to @stores_report, notice: 'Report was successfully created.' }\n format.json { render json: @stores_report, status: :created, location: @stores_report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stores_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def date_reports\n # Parámetros de búsqueda\n @date_start = params[:date_start]\n @date_end = params[:date_end]\n @product_id = params[:product_id]\n @order_type = params[:order_type]\n @product_category = params[:product_category]\n\n # Nombre del producto en caso exista\n @product_name = @product_id.blank? ? '' : Product.find(@product_id).name\n\n # Parámetros de ordenamiento\n @ob_product_name = params[:ob_product_name]\n @ob_product_category = params[:ob_product_category]\n @ob_amount = params[:ob_amount]\n\n @results = Array.new\n\n respond_to do |format|\n format.html do\n if params.length > 3\n @results = OrderDetail.search(params)\n end\n end\n\n format.json {render json: @orders_r}\n format.csv do\n\n @results = OrderDetail.search(params)\n logger.debug \"Parametros\" if params.empty?\n report_csv = CSV.generate(encoding: \"UTF-8\") do |csv|\n csv << ['# de Orden', 'Producto', 'Categoria', 'Cantidad', 'Unidades', 'TipoOrden', 'PrecioTotal']\n\n @results.each do |r|\n order = r.order_id\n productname = r.product.name\n productcat = r.product.category\n quantity = r.quantity\n unidad = r.product.units\n mode = r.order.order_type_text\n var = r.quantity*r.product.price\n precio = var\n\n @row = Array.new\n @row << order\n @row << productname\n @row << productcat\n @row << quantity\n @row << unidad\n @row << mode\n @row << precio\n csv << @row\n end\n end\n filename = \"report.csv\"\n send_data report_csv, :disposition => \"atachment;filename=#{filename}\"\n end\n end\n end",
"def create\n @event = Event.find(params[:event_id])\n @report = @event.reports.new(params[:report])\n @report.attributes = params[:report]\n @report.member_id = current_member.id\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to(event_path(@event)) }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Mg::Report.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { flash[:notice] = 'Your report was successfully created, now add some report items.'; redirect_to(edit_mg_report_url @report) }\n format.xml { render :xml => @report, :status => :created, :location => @report }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def types\n @client.make_request :get, reports_path\n end",
"def http_report(request, _response)\n path = request.path\n\n root_element_name = Box.new('')\n result = @server.xml.parse(request.body, request.url, root_element_name)\n root_element_name = root_element_name.value\n\n if @server.emit('report', [root_element_name, result, path])\n # If emit returned true, it means the report was not supported\n fail Exception::ReportNotSupported\n end\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end",
"def report_file\n File.join(@params[\"SS_output_dir\"], \"report_data.json\")\nend",
"def create_report\n print_sales_report_ASCII\n print_date\n print_products_ASCII\n print_brands_ASCII\n end",
"def save_report\n report = Report.create(name: @name, start_date: @start_date,\n end_date: @end_date, type: @type,\n creator: User.current.id,\n renderer_type: 'PDF')\n\n values = save_report_values(report)\n\n { report: report, values: values }\n end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def index\n if params[:date].present?\n begin\n @date = Date.parse(params[:date])\n rescue => e\n Rails.logger.debug [e.class, e.message].join(' ')\n end\n end\n\n @date ||= (Report.latest_date.presence || Date.today)\n @reports = Report.date(@date).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def export\n respond_to do |format|\n format.xlsx do\n render xlsx: 'export',\n locals: { report: @report, action_type: params[:type] },\n filename: \"report-#{DateTime.now.to_i}\"\n end\n end\n end",
"def index\n @ee_reports = EeReport.all\n end",
"def index\n @ee_reports = EeReport.all\n end",
"def reportes\n # Verificar si se hizo un post\n if params[:fecha_ini]\n if fecha_valida(params[:fecha_ini]) && fecha_valida(params[:fecha_fin]) &&\n (Time.parse(params[:fecha_ini]).to_i <= Time.parse(params[:fecha_fin]).to_i)\n fecha_ini, fecha_fin = transformar_fecha_bd(params[:fecha_ini]), transformar_fecha_bd(params[:fecha_fin])\n else\n fecha = Time.now.strftime(\"%Y-%m-%d\")\n fecha_ini, fecha_fin = fecha, fecha\n end\n reporte = ParteDiario.reporte(fecha_ini, fecha_fin, params[:operacion])\n end\n \n # Responder a cada tipo de recurso (XML, JSON, HTML)\n respond_to do |format|\n format.html {render(:partial => \"reportes\", :locals => {:fecha_ini => params[:fecha_ini], :reporte => reporte,\n :fecha_fin => params[:fecha_fin], :operacion => params[:operacion]}) if request.xhr? }\n format.js\n format.xml { render :xml => reporte }\n end\n end",
"def create\n @admin_report = Admin::Report.new(admin_report_params)\n\n respond_to do |format|\n if @admin_report.save\n format.html { redirect_to @admin_report, notice: 'Report was successfully created.' }\n format.json { render :show, status: :created, location: @admin_report }\n else\n format.html { render :new }\n format.json { render json: @admin_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index \n @agentes = Agente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @agentes }\n #format.pdf do\n # pdf = AgentesPdf.new(@agentes, view_context)\n # send_data pdf.render, filename: \"agentes.pdf\",\n # type: \"application/pdf\",\n # disposition: \"inline\"\n #end\n format.pdf {reporte_agentes(@agentes)}\n format.xls {send_data @agentes.to_xls, :filename => 'reporte.xls' }\n end\n end",
"def report\n search = params[:event_name].strip unless params[:event_name].nil?\n column = params[:column].nil? ? 'event_name' : params[:column]\n direction = params[:direction].nil? ? 'asc' : params[:direction]\n items = Event.my_order(column, direction).where(:creator_user_id => user_id).joins(participants: [:attendee_types]).merge(Participant.where :user_id => user_id).merge(AttendeeType.where :id => AttendeeType.director_id)\n .title_like(search).select(\"events.id AS event_id, events.title AS event_name, 0 AS net_income, \"+\n \"0 AS payment_recived,\"+\n \"0 AS account_balance\")\n .group(\"events.id\")\n json_response_serializer_collection items, AdminReportSerializer\n end",
"def reports\n get(:reports)['Reports'].map do |details|\n Report.new(details['Url'], party: self, details: details)\n end\n end",
"def post_report dep_name, user, vars, log\n require 'net/http'\n require 'uri'\n\n returning(Net::HTTP.post_form(\n URI.parse('http://gist.github.com/api/v1/xml/new'),\n {\n \"files[from]\" => user,\n \"files[vars.yml]\" => vars,\n \"files[#{dep_name}.log]\" => log.decolorize\n }\n )) do |response|\n report_report_result dep_name, response\n end.is_a? Net::HTTPSuccess\n end",
"def report(id)\n get(\"reports/#{id}\")\n end",
"def create\n @report = current_user.reports.new(params[:report])\n\n respond_to do |format|\n if @report.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @dynamic_reports = DynamicReport.all\n end",
"def create\n redirect_to pod_reports_url\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 index\n @inventory_reports = InventoryReport.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventory_reports }\n end\n end",
"def create\n @event_report = EventReport.new(event_report_params)\n\n respond_to do |format|\n if @event_report.save\n format.html { redirect_to @event_report, notice: 'Event report was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event_report }\n else\n format.html { render action: 'new' }\n format.json { render json: @event_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def report\n @employees=Employee.all\n @routing_sheets=RoutingSheet.find(:all, :conditions=> \"routing_sheet_state_id=1\") ## 1 = \"En Proceso\"\n $routing_sheets_details=Array.new\n respond_to do |format|\n format.html # report.html.erb\n format.json {render json: @routing_sheet }\n end\n end",
"def jasper\n param=Hash.new {|k, v| k[v] = {:tipo=>\"\",:valor=>\"\"}}\n param[\"PDIRECCION\"]={:tipo=>\"String\", :valor=>\"DIRECCION DE INFORMATICA\"}\n param[\"PDEPARTAMENTO\"]={:tipo=>\"String\", :valor=>\"DEPARTAMENTO DE BASE DE DATOS\"}\n send_doc_xml(xml,'/records/record', 'directorio','Directorio',param,'pdf')\n end",
"def create\n @user = current_user\n @report = @user.reports.build\n @report.attributes = params[:report]\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @report, notice: 'Report was successfully created.' }\n format.json { render json: @report, status: :created, location: @report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6685929",
"0.64416784",
"0.6415169",
"0.63674515",
"0.6352543",
"0.634552",
"0.6327105",
"0.62638843",
"0.62291545",
"0.62281424",
"0.6210026",
"0.61944443",
"0.6191766",
"0.6180454",
"0.6174855",
"0.6172929",
"0.6172929",
"0.6161767",
"0.6132578",
"0.61313784",
"0.6122995",
"0.61207587",
"0.6120609",
"0.6114757",
"0.6112994",
"0.6109372",
"0.610374",
"0.6102277",
"0.60979867",
"0.6072721",
"0.60578966",
"0.6046579",
"0.6037788",
"0.6030568",
"0.60266393",
"0.60266393",
"0.6021553",
"0.6019145",
"0.60115016",
"0.6006373",
"0.6002677",
"0.6002677",
"0.59994245",
"0.5999255",
"0.59963274",
"0.59963274",
"0.59963274",
"0.5995629",
"0.59929144",
"0.5988899",
"0.5987423",
"0.598738",
"0.5987018",
"0.5987018",
"0.59697545",
"0.59697545",
"0.59697545",
"0.59697545",
"0.59697545",
"0.59697545",
"0.59697545",
"0.59697545",
"0.59697545",
"0.59697545",
"0.59697545",
"0.59697545",
"0.59697545",
"0.5968062",
"0.59630823",
"0.59606254",
"0.5959937",
"0.595909",
"0.5955554",
"0.595527",
"0.59436655",
"0.5940293",
"0.59373707",
"0.59373707",
"0.59373707",
"0.59373707",
"0.59373707",
"0.5934498",
"0.59335643",
"0.5933035",
"0.5933035",
"0.5927751",
"0.5920886",
"0.592077",
"0.5919456",
"0.59190965",
"0.59098434",
"0.59063286",
"0.59030795",
"0.5901846",
"0.58968645",
"0.5894061",
"0.589311",
"0.58845437",
"0.58722126",
"0.5868524",
"0.5856529"
] | 0.0 | -1 |
GET /users/1 GET /users/1.json | def show
@user = User.find(params[:id])
@sessionname = session[:current_user_id]
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end",
"def get \n render :json => User.find(params[:id])\n end",
"def GetUser id\n\n APICall(path: \"users/#{id}.json\")\n\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n # When a http GET request to '/users/1' is received, have it show,\n # in json format, user 1's information.\n @id = params[:id]\n @user = User.find(@id)\n render json: @user\n end",
"def user\n render :json=> User.find(params[:id])\n end",
"def fetch_one_user_data\n get_url(\"/api/v1/users/#{@filter}\")\n end",
"def show\n user = User.find(params[:id])\n render json: @user\nend",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def show\n user = User.find(params[:id])\n\n render json: user\n end",
"def show\n render json: Users.find(params[\"id\"])\n end",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n @user = User.find(params[:id])\n\n render json: @user\n end",
"def show\n user = User.select(:id, :username, :email).find(params[:id])\n render :json => user\n end",
"def show\n render json: User.find(params[\"id\"])\n end",
"def show\n @users = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @users }\n end\n end",
"def show\n @user = User.find(params[:id])\n render json: @user\nend",
"def user_info\n @user = @github.users.get user: params[:username]\n render json: Hash[@user]\n end",
"def show\n render json: User.find(params[:id])\n end",
"def show\n @user = User.find(params[:id])\n render json:@user\n end",
"def show\n @user = User.find(params[:id])\n render json:@user\n end",
"def get_by_id\n \n # the user_id param comes from our route\n user = User.find(params[:user_id])\n \n if user\n render json: user, status: :ok\n else\n render json: { errors: 'User not found' }, status: :not_found\n end\n end",
"def GetUsers params = {}\n\n params = params.merge(path: 'users.json')\n APICall(params)\n\n end",
"def get_user_details\n @user = User.find_by_id(params[:user_id])\n render json: @user\n end",
"def show\n render json: User.find(params[:id])\n end",
"def show\n user = User.find_by(id: params[:id])\n render json: user, status: :ok\n end",
"def user(id)\n self.class.get(\"/user/#{id}\", @options).parsed_response\n end",
"def show\n @user = User.find(params[:id])\n render json: {user: @user}\n end",
"def list_users\n self.class.get('/users')\n end",
"def show\n user = User.find(params[:id])\n render json: user\n end",
"def show\n user = User.friendly.find(params[:user_id]) \n render json: user\n end",
"def show\n render :json => User.find(params[:id])\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response[\"user\"]\n end",
"def index\n users = User.all\n json_response(users)\n end",
"def show\n @user = ActiveRecord::Base.connection.execute(\"\n SELECT * \n FROM users \n WHERE username = '#{params[:username].downcase}' \n LIMIT 1\").first\n\n respond_to do |format|\n format.html\n format.json {render json: User.find(@user[0])}\n end\n end",
"def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response.first[1]\n end",
"def show\n @users = User.all\n json_response(@users)\n end",
"def index\n json_response(User.all) \n end",
"def get(user_id:)\n path = '/users/{userId}'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::User\n )\n end",
"def index\n users = User.all\n render json: { users: users }, status: :ok\n end",
"def show\n # @user = User.first\n user = User.find(params[:id])\n render json: user\n end",
"def user(user_id, params = {})\n make_get_request(\"/users/#{user_id}\", params)\n end",
"def show_user_profile\n @user = User.find(username: params[:username])\n render json: @user\n end",
"def user(id = nil)\n id.to_i.zero? ? get('/user') : get(\"/users/#{id}\")\n end",
"def get_user id, options={}, headers={}\n @connection.get \"users/#{id}.json\", options, headers\n end",
"def user(user=nil)\n if user\n get(\"/users/#{user}\", {}, 3)\n else\n get(\"/user\", {}, 3)\n end\n end",
"def index\n \n @user = User.find(current_user.id) \n\n respond_to do |format|\n format.html { render action: \"show\" }\n format.json { render json: @user }\n end\n end",
"def show\n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @user }\n end\n end",
"def get_user(user_id:)\n parse(JSON.parse(connection.get(\"users/#{user_id}\").body))\n end",
"def index\n user= User.all\n render json: {users:user}\n end",
"def index\r\n users = User.all\r\n render json: users\r\n end",
"def show\n # puts params[:id]\n render json: User.find(params[:id])\n end",
"def get_user_info\n id = params[\"id\"]\n error_list = []\n status = 1\n json_response = {}\n user = User.find_by(id: id)\n\n if user.nil?\n error_list.append(\"Error: The specified user doesn't exist.\")\n status = -1\n else\n json_response[\"user\"] = user.get_user_json_data\n end\n\n if status == -1\n json_response[\"errors\"] = error_list\n end\n\n json_response[\"status\"] = status\n\n # Format the json_response into proper JSON and respond with it\n json_response = json_response.to_json\n\n respond_to do |format|\n format.json { render json: json_response }\n end\n end",
"def show\n @user = User.find(params[:id])\n if @user\n render json: {\n user: @user\n }\n else\n render json: {\n status: 500,\n errors: ['user not found']\n }\n end\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def index\n users = User.all\n render json: users\n end",
"def show\n @user = User.find(params[:id])\n render json: {\n username: @user.username,\n first_name: @user.first_name,\n last_name: @user.last_name,\n email: @user.email,\n phone_number: @user.phone_number,\n contacts: @user.contacts\n }, status: :ok\n end",
"def get_user(user_id)\n request(Route.new(:GET, '/users/%{user_id}', user_id: user_id))\n end",
"def show\n @user = User.find(params[:id])\n render 'api/v1/users/show'\n end",
"def index\n users = User.all\n\n render json: users, each_serializer: Api::V1::UsersSerializer\n end",
"def index\n users = User.all\n render json: users \n end",
"def user(user_id)\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n get(\"users/#{user_id}.json\", params)\n end",
"def index\n users = User.all \n render json: users \n end",
"def list\r\n users = User.all\r\n render json: users\r\n end",
"def json_show_user_profile_by_user_id\n @user = User.find(params[:user_id])\n\n respond_to do |format|\n format.json { render json: @user.as_json(only:[:email,:username]) }\n end\n end",
"def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend",
"def show\n user = User.find_by(uid: params[:id])\n if user\n puts 'USER FOUND'\n render json: user\n else\n puts 'NO USER'\n render json: 'no user'.to_json\n end\n end",
"def show\n render json: UserService.get_user(params[:id]), includes: 'questions, answers'\n end",
"def index\n @users = User.all(limit: 100)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users.as_json(user: current_user) }\n end\n end",
"def index\n render :json => User.all, status: 200\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users\n end",
"def index\n @users = User.all\n render json: @users, status: :ok\n end",
"def show\n @users = User.find(params[:id])\n if @users\n respond_to do |format|\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n else\n head :not_found\n end\n end",
"def index\n @users = User.all\n\n render json: @users\n end",
"def index\n @users = User.all\n\n render json: @users\n end"
] | [
"0.81046426",
"0.7703556",
"0.77011716",
"0.76262826",
"0.7582106",
"0.74818",
"0.7461394",
"0.7446168",
"0.730656",
"0.7300699",
"0.72902125",
"0.72781444",
"0.72358584",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.7225407",
"0.72222257",
"0.72165024",
"0.72137505",
"0.72096044",
"0.71930283",
"0.7182953",
"0.7182144",
"0.7182144",
"0.7180289",
"0.71750754",
"0.7173851",
"0.71640617",
"0.71636444",
"0.71453786",
"0.7145053",
"0.7129776",
"0.71256554",
"0.71160513",
"0.7095665",
"0.70941204",
"0.70772994",
"0.7070785",
"0.7070607",
"0.7063351",
"0.70552826",
"0.7025071",
"0.7014598",
"0.70047677",
"0.6998373",
"0.69910055",
"0.6984177",
"0.6979766",
"0.6972448",
"0.6972228",
"0.6968384",
"0.69666255",
"0.6956339",
"0.69506294",
"0.6945614",
"0.6943135",
"0.69351804",
"0.6932212",
"0.6932212",
"0.6932212",
"0.6932212",
"0.6927094",
"0.69255126",
"0.6925136",
"0.6917375",
"0.6907744",
"0.68947464",
"0.6882589",
"0.6875701",
"0.68749416",
"0.68633634",
"0.6861618",
"0.6858055",
"0.6855495",
"0.68530583",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.685255",
"0.6849599",
"0.6847195",
"0.6847074",
"0.6847074"
] | 0.0 | -1 |
GET /users/new GET /users/new.json | def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end",
"def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n end\n end",
"def new\n @user = user.new\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n # When a http GET request to '/users/new' is received, have it render:\n # a view file with an empty form to create a new user.\n end",
"def new\n @user = User.new\n @action = \"new\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @users = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @users }\n end\n end",
"def new2\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n \n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n \n end",
"def new\n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end"
] | [
"0.8287397",
"0.8169197",
"0.8155916",
"0.80483407",
"0.8022376",
"0.8021751",
"0.8009459",
"0.7950995",
"0.793078",
"0.793078",
"0.7873476",
"0.7873476",
"0.7873476"
] | 0.7860956 | 86 |
POST /users POST /users.json | def create
@user = User.new(params[:user])
respond_to do |format|
if @user.save
if session[:current_user_id].nil?
session[:current_user_id] = @user.id
#flash[:alert] = "You have successfully logged in"
#redirect_to :controller => "posts", :action => "index"
end
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render json: @user, status: :created, location: @user }
else
format.html { render action: "new" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post body=nil, headers={}\n @connection.post \"users.json\", body, headers\n end",
"def create\n # render json: params\n render json: Users.create(params[\"user\"])\n end",
"def create_user(params:)\n parse(JSON.parse(connection.post(\"users\", params.to_json).body))\n end",
"def create\n user = User.create(user_params) \n render json: user, status: :created\n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(form_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: { users: @user }, status: :created }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.new(\n username: user_params[:username],\n password: user_params[:password])\n if user.save\n create_example_collection(user)\n render json: user, except: [:password_digest, :created_at, :updated_at]\n else\n render json: {errors: user.errors.full_messages}\n end\n end",
"def create\n user= User.create(user_params)\n render json: user\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\t@user = User.new(users_params)\n\t\tif @user.save\n\t\t\tjson_response(@user, \"User is created Successfully.\")\n\t\telse\n\t\t\trender json: {message: @user.errors.full_messages.join(\" \")}, status: 400\n\t\tend\t\t\n\tend",
"def create\n user = User.new(@user_info)\n if user.save && user.errors.empty?\n render json: { status: 200, data: UserSerializer.new(user).as_json }\n else\n render json: { status: 400, error: user.errors.full_messages }\n end\n end",
"def create\n user = User.create(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors, status: :unprocessable_entity\n end\n end",
"def create(options = {})\n request(:post, '/users.json', default_params(options))\n end",
"def create\n @user = User.new user_params(params[:user])\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new user_params(params[:user])\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.create user_params\n \n if @user.save\n respond_with(@user) do |format|\n format.json {render}\n end\n end\n end",
"def create\n @user = User.new(user_params(params))\n \n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params(params))\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params(params))\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create_user\n @user = User.new(user_params)\n if @user.save\n render json: UserSerializer.new(@user).serialized_json\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = @application.users.create(user_params)\n\n if @user.valid?\n render json: @user, status: :created, location: api_application_user_path(@application,@user)\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n user = User.create(user_params)\n if user.save\n render json: user\n else\n render json: user.errors, status: :bad\n end\n end",
"def create\n r = @api.create_user(user_params)\n respond_to do |format|\n if r.code == 201\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n else\n response = JSON.parse(r.body)\n format.html { redirect_to users_url, alert: response['message']}\n end\n end\n end",
"def create\n\n puts '-----------------------create in user controller'\n\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: UserSerializer.new(@user).serialized_json\n else\n render json: { error: I18n.t('user_create_error') }, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n render json: { user: @user, success: 'User registration successful' }\n else\n render json: { error: 'User registration unsuccessful' }\n end\n end",
"def create\n @user = User.new(user_params)\n \n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\tputs user_params\n\t\tuser = User.new(user_params)\n\t\tif user.save\n\t\t\trender json: { user: user, status: :success }\n\t\telse\n\t\t\trender json: { status: :failure, errors: user.errors.full_messages.join('') }\n\t\tend\n\tend",
"def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\trender json: @user, status: :created, location: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def add_user(name, value)\n self.class.post(\"/users/#{name}\",\n body: value,\n headers: {\n 'Content-Type' => 'application/json; charset=UTF-8',\n Connection: 'keep-alive',\n Accept: 'application/json, text/plain, */*'\n })\n end",
"def create\n user = User.new(user_params)\n\n respond_to do |format|\n if user.save\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user.users.build(user_params)\n\n if @user.save\n render json: @user\n else\n @user_items = []\n end\n end",
"def create\n user = User.new(user_params)\n render json: { status: 200, msg: 'User was created.', data: \"User Id #{user.id}\" } if user.save\n end",
"def create\n @users = User.new(params[:user])\n\n respond_to do |format|\n if @users.save\n format.html { redirect_to @users, notice: 'Regist was successfully created.' }\n format.json { render json: @users, status: :created, location: @users }\n else\n format.html { render action: \"new\" }\n format.json { render json: @users.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.new(user_params)\n if user.save\n render :json => user, :status => :created\n else\n render :json => {:ok => false, :message => user.errors}, :status => :unprocessable_entity\n end\n end",
"def create\n logger.debug user_params\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :ok\n else\n render json: @user.errors, status: :not_acceptable\n end\n end",
"def create\n user = User.create(user_params)\n render json: user, message: 'user succefully create', status: 200\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n\n up = user_params\n\n if up[:name].present?\n up[:first_name] = up[:name].split(' ')[0]\n up[:last_name] = up[:name].split(' ')[1]\n up.delete :name\n end\n @user = User.new(up)\n\n respond_to do |format|\n if @user.save\n # render json: {user: user, token: token}\n\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: api_user_url(@user)}\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: {status: \"Se creo el usuario\"}, status: :ok\n else\n render json: {status: \"Error al crear el usuario\", errors: user.errors }, status: :unprocessable_entity\n end\n end",
"def create\n user = User.new(params[:user].permit(:username))\n if user.save\n render json: user\n else\n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def create\n puts '>>> params:'\n puts params.inspect\n @user = User.new(params[:user])\n puts '>>> User:'\n puts @user.inspect\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n \tdata = { data: @user, status: :created, message: \"User was successfully created.\" }\n render :json => data\n else\n \tdata = { data: @user.errors, status: :unprocessable_entity }\n render :json => data\n end\n end",
"def create\n user_details = params.permit(:first_name, :last_name, :email)\n success = User.create(user_details)\n\n render json: { success: success }\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user.as_json(only: [:email, :authentication_token]), status: :created\n else\n head(:unprocessable_entity)\n end\n end",
"def create_user\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n post(\"users.json\", params)\n end",
"def create\n @user = User.new(params[:user])\n\n if @user.save\n respond_to do |format|\n format.json { render :json => @user.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create user\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n render :ok, json: @user.to_json\n else\n @errors = @user.errors.full_messages\n render json: { message: @errors }, status: :unauthorized\n end\n end",
"def create\n puts params\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user.as_json(user: current_user), status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: {status: 200, msg: 'User was created.'}\n else\n render json: {errors: user.errors.messages}\n end\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, :notice => 'User was successfully created.' }\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new({name: params[:name], email: params[:email], password: params[:password], photo: params[:photo]})\n @user.save\n render json:@user\n end",
"def create\n user = User.create(user_params)\n\n if user.valid?\n render json: {user: UserSerializer.new(user), token: encode_token(user.id)}\n else\n render json: user.errors.full_messages\n end\n end",
"def create\n\t\tnew_user = User.new(user_params)\n\t\tif new_user.save\n\t\t render status: 200, json: {\n\t\t \tstatus: 200,\n\t\t message:\"New User Created\",\n\t\t response: {\n\t\t name: new_user.name,\n\t\t email: new_user.email,\n\t\t id: new_user.id,\n\t\t facebook_id: new_user.facebook_id,\n\t\t device_id: new_user.device_id,\n\t\t authentication_token: new_user.authentication_token\n\t\t }\n\t\t \n\t\t }.to_json\n\t\telse\n\t\t render status: 404, json: {\n\t\t \tstatus: 404,\n\t\t errors: new_user.errors\n\t\t }.to_json\n\t\tend\n\tend",
"def create\n\t\tresp = {} \n user = User.create(user_params)\n \tif user.valid?\n if user.save\n return render :json => user.as_json\n end\n end\n render json: user.errors.full_messages \n\tend",
"def post_users_with_http_info(users, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UsersApi.post_users ...'\n end\n # verify the required parameter 'users' is set\n if @api_client.config.client_side_validation && users.nil?\n fail ArgumentError, \"Missing the required parameter 'users' when calling UsersApi.post_users\"\n end\n # resource path\n local_var_path = '/users'\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 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(users) \n\n # return_type\n return_type = opts[:return_type] || 'User' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\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(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UsersApi#post_users\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_user(options = {})\n post \"/users\", options\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n user = User.new(user_params)\n\n if user.save\n\n render json: {status: 200, msg: 'User was created.'}\n\n else \n render json: {\n errors: user.errors.full_messages\n }, status: :unprocessable_entity\n\n end\n\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save \n format.html { redirect_to users_url, notice: \"User #{@user.name} was successfully created.\" }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user(body)\n post 'create_user', body\n end",
"def create\n @user = User.new(user_params)\n @user.email = params[:email].downcase\n if @user.save\n render json: @user, status: 200\n else\n render json: { errors: @user.errors.full_messages }, status: 400\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json:@user\n elsif @user.errors\n render json: {error: {code: 400, server_message: @user.errors}}, status: :bad_request\n else\n render json: {error: {code: 500, message: \"Could not save user\", server_message: @user.errors}}, status: :internal_server_error\n end\n\n end",
"def create\n user = User.new(user_params)\n\n if user.valid?\n user.save\n render json: {user: user, token: encode_token({user_id: user.id})}\n else\n render json: {error: \"Failed to create the user\"}\n end\n end",
"def create\n @user = User.new(user_params)\n @user.save\n respond_with @user\n end",
"def create\n @user = User.new(user_params)\n render json: @user && return if @user.save\n\n render json: { error: \"Unable to save user: #{@user.errors.messages}\" }, status: 400\n end",
"def create\n params[:user][\"_id\"] = params[:user][:name]\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save()\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user(attributes)\n post(\"/v1/users\", attributes)\n end",
"def create\n user = User.new(user_params)\n\n # if user is saved sucessfully it will return user and ith status 201 for created\n if user.save\n render json:user,status: :created\n #if request is properly served but data is wrong it ll give ubprocessable_entity with code 422\n else\n render json: user.errors, status: :unprocessable_entity\n end \n end",
"def create\r\n @user = User.new(params[:user])\r\n\r\n respond_to do |format|\r\n if @user.save\r\n format.html { redirect_to users_path, notice: 'Os dados do usuário foram salvos com sucesso!' }\r\n format.json { render json: @user, status: :created, location: @user }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @user.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @user = User.new(\n first_name: params[:first_name],\n last_name: params[:last_name],\n birth_date: params[:birth_date],\n height: params[:height],\n weight: params[:weight],\n user_name: params[:user_name],\n password: params[:password],\n password_confirmation: params[:password_confirmation],\n facebook_url: params[:facebook_url],\n twitter_url: params[:twitter_url],\n instagram_url: params[:instagram_url],\n address: params[:address],\n email: params[:email]\n ) \n if @user.save!\n render 'successful.json.jb', status: :created\n else\n render 'unsuccessful.json.jb', status: :bad_request\n end\n end",
"def post(hash)\n HttpClient::Preconditions.assert_class('hash', hash, Hash)\n @client.request(\"/users\").with_json(hash.to_json).post { |hash| Apidoc::Models::User.new(hash) }\n end",
"def create\n user = User.create!(user_params)\n session[:user_id] = user.id\n render json: user, status: :created\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render json: {message: \"user create successfuly\"}\n else\n render json: {message: \"Error\"}\n end \n end",
"def create\n # Insert new user in database\n user = User.new(user_params)\n\n if user.save\n # On success, send token information to authenticate user\n token = create_token(user.id, user.username)\n render json: {status: 200, token: token, user: user}\n # render json: @user, status: :created, location: @user\n else\n render json: user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(params[:user])\n @user.status = 'active'\n\n respond_to do |format|\n if @user.save\n format.json { render :json => @user, :status => :created }\n format.html { redirect_to(users_path) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n respond_with(@user, location: users_url, notice: 'User was successfully created.')\n else\n respond_with(@user)\n end\n end",
"def create\n user = User.new(user_params)\n \n if user.save\n token = JsonWebToken.encode(user_id: user.id)\n render json: { auth_token: token, user: AuthUserSerializer.new(user).serializable_hash }, status: 201\n else \n render json: { errors: user.errors.full_messages }, status: 400\n end\n end",
"def create\n @user = User.new(params[:user])\n puts params[:user]\n respond_to do |format|\n if @user.save\n format.html { redirect_to :users, notice: 'Registration successful.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render :show, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render :show, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n user = User.create(user_params)\n if user.valid?\n user.username.downcase\n @token = issue_token(user)\n list = List.create(name: user.username)\n list.user_id = user.id\n user.save\n list.save\n render json: { user: UserSerializer.new(user), jwt: @token }, status: :created \n else \n render json: { error: user.errors.full_messages }, status: :not_acceptable\n end \n end",
"def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user_response = API::V1::Users.authenticate params.as_json\n if user_response.success?\n json = HashWithIndifferentAccess.new(user_response.parsed_response)\n auth_response = API::V1::Auth.issue json[:data]\n respond_with auth_response.body, auth_response.code\n else\n respond_with nil, :unauthorized\n end\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n render :json => { :status => 0 }\n else\n render :json => { :status => 1, :msg => @user.errors}\n end\n end",
"def create\n @user = User.new(user_params)\n if @user.save\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token }, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def create\n authorize :user, :create?\n @user = User.new(user_params)\n @user.save\n\n respond_to do |format|\n format.html\n format.json { render :json => @user, status: 200 }\n end\n end",
"def post_accounts(json_hash)\n @options = {:path => '/users.json',\n :body => json_hash[:json]}.merge(@options)\n\n request(\n :expects => 201,\n :method => :post,\n :body => @options[:body]\n )\n end",
"def create\n user = User.new(username: params[:username])\n if user.save\n payload = {'user_id': user.id}\n token = JWT.encode(payload, 'chatapp')\n render json: {\n user: user,\n token: token\n }\n else \n render json: { message: 'There was an error creating your account' }\n end\n end",
"def create\n user = User.create!(user_params)\n if user\n session[:user_id] = user.id\n render json: user, status: :created\n else\n render json: { errors: user.errors.full_messages }, status: :unprocessable_entity\n end\n end",
"def create\r\n @user = User.new user_params\r\n\r\n if @user.save\r\n render json: @user, serializer: SessionSerializer, root: nil\r\n else\r\n render json: { errors: @user.errors }, status: :unprocessable_entity\r\n end\r\n end",
"def create\n user = User.new(user_params)\n if user.save\n render json: { status: 'OK', msg: 'User was created.', error: 'nil' },\n status: :created\n else\n not_good(422)\n end\n end"
] | [
"0.77179813",
"0.75206673",
"0.73831296",
"0.72405374",
"0.719841",
"0.7140812",
"0.71038526",
"0.7058827",
"0.7041636",
"0.70236504",
"0.7003128",
"0.70021695",
"0.70021695",
"0.70021695",
"0.69936967",
"0.6990463",
"0.6980393",
"0.6979075",
"0.69788617",
"0.69788617",
"0.69762856",
"0.6962628",
"0.6952247",
"0.69454783",
"0.69454783",
"0.6920555",
"0.69181055",
"0.691467",
"0.6901315",
"0.6898759",
"0.689459",
"0.6889815",
"0.6880676",
"0.6880467",
"0.6880196",
"0.68797004",
"0.6877297",
"0.686924",
"0.6855058",
"0.6851115",
"0.6844058",
"0.6814104",
"0.6803589",
"0.6777842",
"0.6776859",
"0.67678535",
"0.6757897",
"0.67471397",
"0.6738628",
"0.6734963",
"0.6733872",
"0.6720612",
"0.6711659",
"0.6670256",
"0.66581875",
"0.66573423",
"0.6654514",
"0.6638977",
"0.66325235",
"0.66199607",
"0.6615226",
"0.66148156",
"0.65989614",
"0.65910506",
"0.65792614",
"0.6578957",
"0.6573529",
"0.6573351",
"0.6557221",
"0.6553408",
"0.6551572",
"0.65466446",
"0.6540912",
"0.65399504",
"0.6538697",
"0.6535891",
"0.6533581",
"0.6526114",
"0.65116656",
"0.65072525",
"0.6507116",
"0.6503024",
"0.6490388",
"0.6488653",
"0.64881754",
"0.6473845",
"0.64722794",
"0.64702916",
"0.64702916",
"0.6469406",
"0.64682525",
"0.6462379",
"0.64619774",
"0.646129",
"0.6455196",
"0.645272",
"0.6448271",
"0.6447503",
"0.64468706",
"0.64460355",
"0.6441883"
] | 0.0 | -1 |
PUT /users/1 PUT /users/1.json | def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to @user, notice: 'User was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"def put user_id, options={}, headers={}\n @connection.put \"users/#{user_id}.json\", options, headers\n end",
"def updateUser\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/\"+@current_user[\"id\"].to_s, options)\n render json: results.parsed_response, status: results.code\n end",
"def update\n user = User.find_by(id: params[:id])\n user.update(user_params)\n render json: user\n end",
"def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.role = params[:type]\n @user.save\n render json:@user\n end",
"def update\n if user.update(user_params)\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end",
"def update\n user = @user_service.update_user(params[:id])\n render json: user, status: :ok\n end",
"def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend",
"def modify_user(user)\n query_api_object Model::User, '/rest/user', user.to_hash, 'PUT'\n end",
"def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end",
"def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.save\n render json:@user\n end",
"def update\n user = find_user\n user.update!(user_params)\n render json: user\n end",
"def update\n user = User.find(params[:id])\n\n # Use update with user_params to do a mass-assignment update and save. \n if user.update_attributes(user_params)\n render json: user\n else \n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update_user(user, options = {})\n put \"/users/#{user}\", options\n end",
"def update_user(options)\n patch(\"/user\", options, 3)\n end",
"def modify_user(user)\n query_api_object User, \"/rest/user\", user.dump(), \"PUT\"\n end",
"def update\n begin\n user = User.find(params[:user_id])\n if user.update(user_params)\n render json: { users: user }, status: :ok\n else\n render json: { errors: user.errors.messages }, status: 422\n end\n rescue => e\n render json: { errors: e.message }, status: 404\n end\n end",
"def update\n if @api_v1_user.update(api_v1_user_params)\n head :no_content\n else\n render json: @api_v1_user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n render json:@user\n else\n render json: { error: {code: 404, message: 'Invalid user' }}, status: :not_found\n end\n end",
"def update\n user = User.find(params[:id])\n user.update(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update(id, params = {})\n request(:put, \"/users/#{id}\", body: params)\n end",
"def update\n if @user.update(user_params)\n render json: @user\n else\n render json: {error: \"Could not update user\"}\n end\n end",
"def update\n \trespond_to do |format|\n if @user.update(user_params)\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\t \t\n end",
"def update\n user = User.find(params[:id])\n if user.update(user_params)\n render json: user\n else\n render json: user.errors.full_messages\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user, status: 200\n else\n render json: @user.errors, status: 422\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update_attributes(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update_attributes(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update user_params(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id]) \n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User #{@user.name} was successfully created.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user, status: :ok\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n @user.update(user_params)\n render json: @current_user\n end",
"def update\n user = User.find(params[:id])\n if user.update(params_user)\n render json: user, status: 200\n else\n render json: user.errors, status: 422\n end\n\n end",
"def update\n\t\tif @user.update(user_params)\n\t\t\trender json: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def update\n @user.update(user_params_update)\n json_response(@user)\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params[:user]))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user, status: :ok, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if user.update(user_params)\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_user\n @user = User.find(params[:id])\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status :unprocessable_entity\n end\n end",
"def update\n user = User.find(params[:id])\n render json: { status: 200, msg: 'User details have been updated.' } if user.update(user_params)\n end",
"def update\n @user = User.find(params[:id])\n @user.update_attributes(params[:user])\n respond_with @user\n end",
"def update\n @user = User.find(params[:id])\n @user.update_attributes(params[:user])\n respond_with @user\n end",
"def update\n @user = V1::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'V1::User was successfully updated.'\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @user.id == current_api_user.id\n if @user.update(user_params)\n render json: @user.as_json(except: [:updated_at]), status: :ok\n else\n render json: @user.errors, status: :bad_request\n end\n else\n render json: '', status: :forbidden\n end\n end",
"def update\n @user = User.find(params[:id])\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update \n @current_user.update(user_params)\n render json: @current_user\n end",
"def update\n @user = User.find(params[:id])\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = selected_user\n if @user.update(users_params)\n render 'api/users/show'\n else\n render json: @user.errors.full_messages, status: 422\n end\n end",
"def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.json { head :ok }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = current_api_user\n unless @user.update(user_params)\n render json: { error: @user.errors.full_messages.to_sentence }, status: :not_found\n end\n end",
"def update\n respond_to do |format|\n if @user.update(form_params)\n format.json { render json: { users: @user }, status: :ok, location: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit(id, options={})\n request(:put, \"/users/#{id}.json\", default_params(options))\n end",
"def update_user(id, accountId, model) path = \"/api/v2/accounts/#{accountId}/users/#{id}\"\n put(path, model, {}, AvaTax::VERSION) end",
"def update\n user = User.find(params[:id])\n\n user.attributes = {\n name: params[:name]\n }\n\n user_save user\n end",
"def update\n @user = current_org.users.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user.update(user_params)\n respond_with @user\n end",
"def update\n user = User.find(params[:id])\n if user.update(user_params)\n render json: {\n status: 'OK',\n msg: 'User details have been updated.',\n error: 'nil'\n }, status: :accepted\n else\n not_good(406)\n end\n end",
"def update\n respond_to do |format|\n if @v1_user.update(v1_user_params)\n format.html { redirect_to @v1_user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @v1_user }\n else\n format.html { render :edit }\n format.json { render json: @v1_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n authorize @user\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n\t\tif @user.update(users_params)\n \t\tjson_response(@user, \"User Update Successfully.\")\n \telse\n \t\trender json: {message: @user.errors.full_messages.join(\" \")}, status: 400\n \tend\n\tend",
"def update\n @user = current_user\n if @user.update(update_user_params)\n render 'api/v1/users/show'\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { render action: \"edit\"}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def update(context, name, should)\n res = context.transport.put_request(context, \"security/users/#{name}\", keys_to_camelcase(should))\n\n context.err(name, res.body) unless res.success?\n end",
"def update!(options: {})\n\t\t\tuser = User.perform_request User.api_url(\"users/#{id}\"), :put, options, true\n\n\t\t\tif user\n\t\t\t\toptions.each do |key, value|\n\t\t\t\t\tself.send(\"#{key}=\", user['data'][\"#{key}\"])\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tnil\n\t\t\tend\n\t\tend",
"def update\n @user = user.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end",
"def update\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to users_path }\n format.json { render :json => @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User was successfully updated.' }\n\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_name(user_id:, name:)\n path = '/users/{userId}/name'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n if name.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"name\"')\n end\n\n params = {\n name: name,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'PATCH',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::User\n )\n end",
"def update_current_logged_in_user(args = {}) \n id = args['id']\n temp_path = \"/users.json/current\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\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_user\n @user = User.find(params[:id])\n @user.update(params[:user])\n redirect \"/users/#{@user.id}\"\nend",
"def update\n @api_user = ApiUser.find(params[:id])\n\n if @api_user.update(api_user_params)\n head :no_content\n else\n render json: @api_user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_user\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user.as_json(user: current_user), notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.update(params[:user])\n end",
"def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update \n user = User.where(:id => current_user.user)\n if user.update(user_params)\n render :json => {:user => user }\n else\n render :json => {:error => user.errors.full_messages.first}\n end\nend",
"def update\n @user = User.find(params[:id])\n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @user.update(user_params)\n render json: @user, status: :ok, location: api_application_user_path(@application,@user)\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_path, :notice => 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes_from_api(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { render_for_api :user, :json => @user }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => t('user.update_success') }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status=> :unprocessable_entity }\n end\n end\n end",
"def api_v11_users_user_name_put_with_http_info(user_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi#api_v11_users_user_name_put ...\"\n end\n \n # verify the required parameter 'user_name' is set\n fail \"Missing the required parameter 'user_name' when calling api_v11_users_user_name_put\" if user_name.nil?\n \n # resource path\n path = \"/api/v11/users/{userName}\".sub('{format}','json').sub('{' + 'userName' + '}', user_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = []\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:PUT, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#api_v11_users_user_name_put\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update_user\n user = current_user\n if user.update(update_params)\n render json: { status: { updated: \"Ok\" } }\n else\n render json: user.errors.full_messages\n end\n end",
"def update\n @user = User.find(params[:id])\n if @user.update_attributes(user_params)\n redirect_to @user\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\nend",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = ::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = \"User #{@user.username} successfully updated!\"\n format.html { redirect_to @user }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n user = User.find(params[:id])\n authorize! :update, user\n if user.update_attributes(user_params)\n render :json => {:ok => true, :message => 'successful updated'}, :head => :no_content\n else\n render :json => {:ok => false, :message => user.errors}, :status => :unprocessable_entity\n end\n end"
] | [
"0.74114245",
"0.73920554",
"0.73041475",
"0.7254177",
"0.7202618",
"0.70756376",
"0.70535713",
"0.7029043",
"0.70075685",
"0.69883573",
"0.6983195",
"0.694263",
"0.69409895",
"0.692315",
"0.6909438",
"0.687742",
"0.68486536",
"0.6834162",
"0.6821841",
"0.6801179",
"0.67703044",
"0.6763487",
"0.6761313",
"0.6761313",
"0.67482305",
"0.67473894",
"0.6713073",
"0.6703807",
"0.6693307",
"0.66886777",
"0.66886777",
"0.66646844",
"0.66617274",
"0.66572624",
"0.6653578",
"0.66406506",
"0.6625279",
"0.66213304",
"0.66192704",
"0.6614916",
"0.6612626",
"0.6604333",
"0.65851104",
"0.65851104",
"0.65785134",
"0.65615654",
"0.65518224",
"0.65518224",
"0.6549094",
"0.6530534",
"0.6530534",
"0.65275174",
"0.6523527",
"0.6520384",
"0.6520384",
"0.6516204",
"0.65145653",
"0.65104014",
"0.6504922",
"0.6499594",
"0.64987266",
"0.64906204",
"0.64810187",
"0.64798295",
"0.64702576",
"0.64496434",
"0.6436427",
"0.6433962",
"0.64330167",
"0.6428237",
"0.6406415",
"0.6402615",
"0.6399288",
"0.63881207",
"0.63877773",
"0.6353986",
"0.63537806",
"0.633806",
"0.63360107",
"0.6334851",
"0.632672",
"0.63260114",
"0.63179153",
"0.63173646",
"0.6317282",
"0.6316377",
"0.6316055",
"0.63120025",
"0.6293317",
"0.62857985",
"0.6282219",
"0.6280316",
"0.6264061",
"0.62624925",
"0.625522",
"0.62549126",
"0.62547195",
"0.625327",
"0.625269",
"0.6252329",
"0.6245382"
] | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.json | def destroy
@user = User.find(params[:id])
post = Post.find(:all, :conditions => ["user_id = ?", @user.id])
for n in 0 ... post.size do
Post.destroyCascade(post[n])
end
vote = Vote.find(:all, :conditions => ["user_id = ?", @user.id])
for n in 0 ... vote.size do
Vote.destroyCascade(vote[n])
end
comment = Comment.find(:all, :conditions => ["user_id = ?", @user.id])
for n in 0 ... comment.size do
Comment.destroyCascade(comment[n])
end
commentvote = CommentVote.find(:all, :conditions => ["user_id = ?", @user.id])
for n in 0 ... commentvote.size do
CommentVote.destroyCascade(commentvote[n])
end
@user.destroy
respond_to do |format|
format.html { redirect_to users_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\"])\n end",
"def delete\n @user.destroy\n respond_to do |format|\n format.html { redirect_to v1_resources_users_all_path, notice: 'User was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end",
"def destroy\n @user = V1::User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_users_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n \"\"\"\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n \"\"\"\n end",
"def destroy\n debugger\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n format.json { head :no_content }\n end",
"def destroy\n user = User.find(params[:id]) # from url, nothing to do with table\n user.destroy\n render json: user\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find_by_id_or_username params[:id]\n @user.destroy\n render api_delete @user\n end",
"def destroy\n @user = user.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def delete_user\n @user = User.find(params[:id])\n if @user.destroy\n render :json => @user\n else\n render :json => @user.errors.full_messages\n end\n end",
"def destroy\n @v1_user.destroy\n respond_to do |format|\n format.html { redirect_to v1_users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.78750724",
"0.77518034",
"0.7713981",
"0.7610077",
"0.747295",
"0.74073994",
"0.74073994",
"0.7369968",
"0.7346072",
"0.7340465",
"0.7328618",
"0.7309635",
"0.73095363",
"0.7306841",
"0.7297868",
"0.72917855",
"0.7291585",
"0.7289111",
"0.7284347",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7250935",
"0.7245172",
"0.7242216",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177",
"0.7232177"
] | 0.0 | -1 |
Return a list of taxons from the publishing API with links included. Does not include the details hash of each taxon. | def taxon_content_items(page:, per_page:, query:, states:)
Services
.publishing_api
.get_content_items(
document_type: "taxon",
order: "-public_updated_at",
q: query || "",
search_in: %i[title base_path details.internal_name],
page: page || 1,
per_page: per_page || 50,
states: states || [],
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_taxons_by_permalink(permalink)\n taxonomies = get_taxonomies.taxonomies\n taxons = []\n taxonomies.each do |taxonomy|\n taxons += taxonomy.root.taxons.select { |taxon| taxon.permalink == permalink }\n end\n taxons\n end",
"def index\n @taxons = Taxon.all\n end",
"def get_taxonomies(options = {})\n get \"/api/taxonomies\", options\n end",
"def get_all_taxes\n self.class.get(\"/aldebaran-taxes/v2/taxes\", :basic_auth => @auth)\n end",
"def index\n @pagto_taxas = PagtoTaxa.all\n end",
"def taxons_with_ancestors\n taxons.flat_map(&:breadcrumb_trail)\n end",
"def taxonomies_json\n @taxons_json = []\n query_string = \"%#{params[:term]}%\"\n @taxons = Spree::Taxonomy.categories.taxons#.where(\"name like ? OR id like ?\", query_string, query_string)\n @taxons.collect{ |taxon|\n if (taxon.parent.present? && taxon.parent.parent.present? && taxon.parent.parent.parent.present?)\n name = (taxon.parent.parent.name+\" -> \"+taxon.parent.name+\" -> \"+taxon.name)\n @taxons_json << {'label' => name, 'id' => taxon.id} if name.downcase.include? params[:term].downcase\n end\n }\n render :json=>@taxons_json.to_json\n end",
"def index\n @luxire_taxonomies = LuxireTaxonomy.all\n end",
"def find_taxonomies\n @document.xpath('.//taxonomy').each do |taxonomy_node|\n taxonomy_name = taxonomy_node.at_xpath('.//taxonomy_name')\n tax_node = insert_node(SecureRandom.uuid, taxonomy_name.content, @root_node)\n @taxonomies << tax_node\n add_node(taxonomy_node, tax_node, skip_add: true)\n end\n end",
"def get_taxon(taxonomy_id, taxon_id)\n get \"/api/taxonomies/#{taxonomy_id}/taxons/#{taxon_id}\"\n end",
"def index\n @indicate_taxonomies = Indicate::Taxonomy.all\n @indicate_taxonomies = @indicate_taxonomies.by_towns(params['town_select']) unless params['town_select'].blank?\n end",
"def get_tax_rates\n response_xml = http_get(@client, \"#{xero_url}/TaxRates\")\n parse_response(response_xml, {}, {:request_signature => 'GET/tax_rates'})\n end",
"def tax_rates\n @tax_rates ||= @api.get('TaxRates')['TaxRates'] || []\n end",
"def get_products_in_taxon(taxon_id)\n options = { params: { id: taxon_id } }\n response = get \"/api/taxons/products\", options\n response.products.each do |product|\n sanitize_product!(product)\n end\n response\n end",
"def get_taxonomies(add_params = nil)\n params = {\n uid: uid,\n }\n api_call('/stores/:uid/taxonomies(.:format)',:get,params,add_params)\n end",
"def get_astronomy_pages()\n\treturn @archive_doc.css('body b a').map { |page| @base_url + page[\"href\"] }\nend",
"def get_townhall_urls(townhall_list)\n page = Nokogiri::HTML(URI.open(townhall_list))\n annuaire = []\n page.xpath('//a[@class=\"lientxt\"]/@href').each do |link|\n annuaire << link.text\n end\n annuaire.map!{ |x| [\"https://www.annuaire-des-mairies.com\", x.reverse.chop.reverse].join}\n return annuaire\nend",
"def taxons(product_id:)\n version_ids = taxons_version_ids(product_id: product_id)\n\n versions = PaperTrail::Version.where(id: version_ids)\n versions.map(&:reify)\n end",
"def index\n @all_taxons_seen = Taxon.species_seen.not_excluded\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @all_taxons_seen }\n end\n end",
"def index\n @tax_informations = TaxInformation.all\n end",
"def get_taxonomies_support_data\n return @client.raw(\"get\", \"/config/taxonomies/support-data\")\n end",
"def get_townhall_urls\n page = Nokogiri::HTML(open(\"https://www.annuaire-des-mairies.com/val-d-oise.html\"))\n town_url_list = []\n url_root = \"https://annuaire-des-mairies.com\"\n page.xpath('//*[@class=\"lientxt\"]/@href').each do |node|\n townhall_url = url_root + node.value.to_s.delete_prefix(\".\")\n town_url_list << townhall_url\n end \n town_url_list\nend",
"def get_buylinks( params )\n xml = LastFM.get( \"track.getBuylinks\", params )\n [:physical, :download].each_with_object([]) do |type, buylinks|\n xml.find(\"affiliations/#{type}s/affiliation\").each do |buylink|\n buylinks << LastFM::Buylink.from_xml( buylink, :type => type )\n end\n end\n end",
"def index\n @taxi_images = TaxiImage.all\n end",
"def taxons_including_children_ids\n taxons.inject([]) { |ids, taxon| ids += taxon.self_and_descendants.ids }\n end",
"def index\n @taxfrees = Taxfree.all\n end",
"def taxon_link taxon_or_id\n return \"\" unless taxon_or_id\n \"{#{Taxt::TAX_TAG} #{taxon_or_id.try(:id) || taxon_or_id}}\"\n end",
"def link_objects\n start_at = 0\n stop_after = 1000000\n hol_count = 0\n for hol_details in HolTaxonDatum.order(:tnuid)\n hol_count = hol_count +1\n if (hol_count < start_at)\n next\n end\n if hol_count > start_at + stop_after\n exit\n end\n print_char \".\"\n begin\n details_hash = JSON.parse hol_details.json\n rescue JSON::ParserError\n puts (\"Fatal parse error for tnuid:\" + hol_details.tnuid.to_s)\n next\n end\n\n link_object details_hash, hol_details\n end\n end",
"def get_spree_taxonomies\n @spree_taxonomies = TaxonomySync.find(:all)\n end",
"def links\n\t self.tweets.collect{|t| t.links}.flatten.compact\n\tend",
"def get_townhall_names(townhall_list)\n page = Nokogiri::HTML(URI.open(townhall_list))\n annuaire = []\n page.xpath('//a[@class=\"lientxt\"]').each do |link|\n annuaire << link.text\n end\n return annuaire\nend",
"def prune_links\n links = []\n result = self.perform\n ft_links = result.ft_links\n ft_links.each do |ft_link|\n http = Curl.get(ft_link)\n doc = Nokogiri::HTML(http.body_str)\n link = doc.xpath('//*[@id=\"copy_paste_links\"]').children.first.to_s.chomp\n links.push link if link.empty? == false\n end\n links\n end",
"def index\n @global_links = GlobalLink.all\n @tier_two_links = TierTwoLink.all\n end",
"def order_taxons(order)\n taxon_ids = Spree::Classification.where(product_id: order.product_ids).pluck(:taxon_id).uniq\n\n order.store.taxons.where(id: taxon_ids)\n end",
"def links_and_their_aliases(page_hash)\n @links.inject([]) do |results, link|\n results.concat([link].concat(page_hash[link].aliases))\n end\n end",
"def links_and_their_aliases(page_hash)\n @links.inject([]) do |results, link|\n results.concat([link].concat(page_hash[link].aliases))\n end\n end",
"def print_axons\n\t\t\treturn @axons\n\t\tend",
"def taxon_preview(taxon)\n products = taxon.products[0..4]\n return products unless products.size < 5\n if Spree::Config[:show_descendents]\n taxon.descendents.each do |taxon|\n products += taxon.products[0..4]\n break if products.size >= 5\n end\n end\n products[0..4]\n end",
"def print_axons\n\t\treturn @axons\n\tend",
"def index\n @taxes = Tax.all\n end",
"def index\n @breadcrumbs = [['Tax codes']]\n @tax_codes = current_organization.tax_codes.order(:code)\n @tax_codes = @tax_codes.page(params[:page])\n end",
"def getTaxon\n classification = ['Kingdom:', 'Phylum:', 'Class:', 'Order:', 'Family:', 'Genus:', 'Species:', 'Organism:']\n i = 0\n @gbkObj.classification.each do |taxon|\n puts classification[i] + \"\\t\" + taxon\n i += 1\n end\n puts classification[i] + \"\\t\" + @gbkObj.organism\n end",
"def bok_links\n [\n { :url => 'http://www.noagendashow.com/', :name => 'NoAgendaShow.com'},\n { :url => 'http://noagendachat.net/', :name => 'NoAgenda Chat'},\n { :url => 'http://www.noagendasoundboard.com/', :name => 'NoAgenda Soundboard'},\n { :url => 'http://noagendastream.com/', :name => 'NoAgenda Stream'},\n { :url => 'http://en.wikipedia.org/wiki/No_Agenda', :name => 'wikipedia'}\n ]\n end",
"def get_townhall_urls\n h = {}\n page = 'http://annuaire-des-mairies.com'\n doc = Nokogiri::HTML(open(page + '/val-d-oise.html'))\n doc.xpath('//a[@class=\"lientxt\"]').each do |node|\n h[node.text.capitalize.to_sym] = get_townhall_email(page +\n node.xpath('@href').text.gsub!(/^\\./, '').to_s)\n end\n return h\n end",
"def taggings_with_slugs(links)\n links_with_slugs = {}\n\n # We still call topics \"specialist sectors\" in rummager.\n links_with_slugs[\"specialist_sectors\"] = links[\"topics\"].to_a.map do |content_item|\n content_item[\"base_path\"].sub(\"/topic/\", \"\")\n end\n\n links_with_slugs[\"mainstream_browse_pages\"] = links[\"mainstream_browse_pages\"].to_a.map do |content_item|\n content_item[\"base_path\"].sub(\"/browse/\", \"\")\n end\n\n links_with_slugs[\"organisations\"] = links[\"organisations\"].to_a.map do |content_item|\n content_item[\"base_path\"].sub(\"/government/organisations/\", \"\").sub(\"/courts-tribunals/\", \"\")\n end\n\n links_with_slugs[\"primary_publishing_organisation\"] = links[\"primary_publishing_organisation\"].to_a.map do |content_item|\n content_item[\"base_path\"].sub(\"/government/organisations/\", \"\").sub(\"/courts-tribunals/\", \"\")\n end\n\n links_with_slugs[\"taxons\"] = content_ids_for(links, \"taxons\")\n\n links_with_slugs\n end",
"def tax_share_6\n tax_share(tax6)\n end",
"def links\n links = []\n result = self.perform\n links = result.ft_links\n end",
"def list\n extract_names_and_urls = lambda do |doc|\n [extact_url(@url, document), extract_titles(document)]\n end\n \n html.css('a').map(&extract_names_and_urls)\n end",
"def tax_share_12\n tax_share(tax12)\n end",
"def links_and_their_aliases(page_hash)\n links.inject([]) do |results, link|\n results.concat([link].concat(page_hash[link].aliases))\n end\n end",
"def non_fulltext_links\n links = []\n other_customlinks = @record.fetch('CustomLinks',{})\n if other_customlinks.count > 0\n other_customlinks.each do |other_customlink|\n link_url = other_customlink['Url']\n link_label = other_customlink['Text']\n link_icon = other_customlink['Icon']\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'customlink-other'})\n end\n end\n\n links\n end",
"def show\n @taxon = Taxon.find(params[:id])\n @page_title = @taxon.common_name\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: [@taxon.as_json(:include => { :sightings => { :include => [ :trip ] }, :locations => { }, :photos => { :include => [ :taxon, :trip, :location ], :methods => [ :photo_URL ] } } )]}\n end\n end",
"def links\n json_hyperschema[\"links\"] || []\n end",
"def links\n metadata[:links] || Set.new\n end",
"def output_tax(refseq_data)\n rs = refseq_data\n taxid = rs[:taxid]\n gene_label_url = URI.escape(rs[:gene_label])\n\n $output_ttl.puts triple(\"<http://togogenome.org/gene/#{taxid}:#{gene_label_url}>\", \"rdfs:seeAlso\", \"tax:#{rs[:taxid]}\") unless $gene_list[rs[:gene_rsrc]]\n $output_ttl.puts triple(\"<http://togogenome.org/gene/#{taxid}:#{gene_label_url}>\", \"skos:exactMatch\", \"<http://identifiers.org/refseq/#{rs[:gene_rsrc]}>\") unless $gene_list[rs[:gene_rsrc]]\n $output_ttl.puts triple(\"tax:#{rs[:taxid]}\", \"rdf:type\", \"<http://identifiers.org/taxonomy>\") unless $tax_type_list[rs[:taxid]]\n $tax_type_list[rs[:taxid]] = true # to prevent duplicate output\n $gene_list[rs[:gene_rsrc]] = true # to prevent duplicate output\nend",
"def links\n data['links']\n end",
"def to_taxa(options = {})\n flickr = options.delete(:flickr)\n fp = options.delete(:fp)\n flickr ||= Net::Flickr.authorize(FLICKR_API_KEY, FLICKR_SHARED_SECRET)\n fp ||= flickr.photos.get_info(self.flickr_native_photo_id)\n FlickrPhoto.flickr_photo_to_taxa(fp)\n end",
"def exist_links\n return [] if sumup.blank?\n\n sumup.fetch(\"public_praises\").fetch(\"items\")\n end",
"def flow_taxons_tree root_taxon, current_taxon\n return '' if root_taxon.children.empty?\n\n max_level = 1\n\n content_tag :ul, class: 'taxons-list' do\n taxons = root_taxon.children.map do |taxon|\n css_class = (current_taxon && current_taxon.self_and_ancestors.include?(taxon)) ? 'current' : nil\n content_tag :li, class: css_class do\n extra = nil\n extra = taxons_tree(taxon, current_taxon, max_level - 1) if @taxon && [current_taxon.parent.try(:id), current_taxon.id].include?(taxon.id)\n link_to(taxon.name, seo_url(taxon)) + extra\n end\n end\n safe_join(taxons, \"\\n\")\n end\n end",
"def object_taxon_name_ids\n return taxon_name_id if !taxon_name_id.empty?\n return object_taxon_name_id if !object_taxon_name_id.empty?\n return []\n end",
"def tax_index\n\n end",
"def index\n @ammolist_taxon_calibers = AmmolistTaxonCaliber.all\n end",
"def index\n @guide_taxa = GuideTaxon.includes(:guide_photos => [:photo]).page(params[:page]).per_page(200)\n @guide_taxa = @guide_taxa.where(:guide_id => params[:guide_id]) unless params[:guide_id].blank?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json do\n render :json => {:guide_taxa => @guide_taxa.as_json(\n :root => false, \n :methods => [:guide_photo_ids, :guide_section_ids, :guide_range_ids],\n :include => [:guide_photos => {:include => [{:photo => Photo.default_json_options}]}]\n )}\n end\n end\n end",
"def index\n @taxes = Tax.all\n\n render json: @taxes\n end",
"def setup_taxa2tree\n Typhoeus.stub('http://api.unipept.ugent.be/api/v2/taxa2tree.json').and_return do |_|\n link = req.options[:body][:link] == 'true'\n if link\n Typhoeus::Response.new(code: 200, body: JSON.dump(gist: 'https://gist.github.com/8837824df7ef9831a9b4216f3fb547ee'))\n else\n result = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'resources/taxa2tree.json')))\n Typhoeus::Response.new(code: 200, body: JSON.dump(result))\n end\n end\n end",
"def home_page\n taxon = nil\n taxon_ids= template_resources.select{|template_resource|\n template_resource.source_class == SpreeTheme.taxon_class\n }.collect(&:source_id)\n if taxon_ids.present?\n taxons = SpreeTheme.taxon_class.where( id: taxon_ids )\n taxon = SpreeTheme.taxon_class.homes.where([\"taxonomy_id in (?)\", taxons.map(&:taxonomy_id ) ]).first\n end\n taxon\n end",
"def tax_share_25\n tax_share(tax25)\n end",
"def list_relationships\n end",
"def get_townhall_urls(url)\n\n page = Nokogiri::HTML(URI.open(url)) \n #townhall_url = page.xpath(\"//a/@href\").map {|x| x.value}\n townhall_urls_array_incomplete = page.css('a[href].lientxt').map {|x| x[\"href\"]}\n #remove the dot at the beginning of the url\n townhall_urls_array_incomplete = townhall_urls_array_incomplete.map {|x| x[2..]}\n townhall_urls_array = townhall_urls_array_incomplete.map {|x| \"http://annuaire-des-mairies.com/\" + x}\n return townhall_urls_array\n\nend",
"def index\n @user_taxi_calls = UserTaxiCall.all\n end",
"def affiliation\n []\n end",
"def get_townhall_urls(url)\n urls_department = []\n \n doc = Nokogiri::HTML(open(url))\n \n # Extraire le texte et mettre ça dans un hash \n \n doc.xpath(\"//a[@class=\\\"lientxt\\\"]\").each do |node|\n urls_department << { name: node.text, url: \"http://annuaire-des-mairies.com\" + node[:href][1, node[:href].size - 1]}\n end\n urls_department\n end",
"def all_links\n Link.all\n end",
"def all_links\n Link.all\n end",
"def all_links\n Link.all\n end",
"def toxics\n request = Net::HTTP::Get.new(\"/proxies/#{name}/toxics\")\n response = http_request(request)\n assert_response(response)\n\n JSON.parse(response.body).map do |attrs|\n Toxic.new(\n type: attrs[\"type\"],\n name: attrs[\"name\"],\n proxy: self,\n stream: attrs[\"stream\"],\n toxicity: attrs[\"toxicity\"],\n attributes: attrs[\"attributes\"],\n )\n end\n end",
"def links\n @data[\"_links\"]\n end",
"def export_synonyms(hits_per_page = 100, request_options = {}, &_block)\n res = []\n page = 0\n loop do\n curr = search_synonyms('', { :hitsPerPage => hits_per_page, :page => page }, request_options)['hits']\n curr.each do |synonym|\n res << synonym\n yield synonym if block_given?\n end\n break if curr.size < hits_per_page\n page += 1\n end\n res\n end",
"def list_children(taxons_collection)\n taxons_collection.sort_by {|p| p.hierarchy}\n html_var = \"\"\n taxons_collection.each do |t|\n if not t.children.empty?\n html_var << \"<li><i class='icon-plus'> </i>\" << link_to(t.name, t) << \"<ul>\" << list_children(t.children) << \"</ul>\"\n else\n html_var << \"<li><i class='icon-white' style='visibility: hidden;'> </i>\" << link_to(t.name, t)\n end\n html_var << \"</li>\\n\"\n end\n return html_var.html_safe\nend",
"def add_taxons\n save_if_new\n chain_list = get_each_assoc\n chain_list.each do |chain|\n # Each chain can contain either a single Taxon,\n # or the tree like structure parent>child>child\n name_list = chain.split(/\\s*>\\s*/)\n taxonomy_name = name_list.shift\n taxonomy = @@taxonomy_klass.find_or_create_by_name(taxonomy_name)\n raise DataShift::DataProcessingError.new(\"Could not find or create Taxonomy #{taxonomy_name}\") unless taxonomy\n taxon = taxonomy.root\n name_list.each do |taxon_name|\n taxon = @@taxon_klass.find_or_create_by_name_and_parent_id_and_taxonomy_id(taxon_name, taxon.id, taxonomy.id)\n end\n\n if taxon\n @product.taxons << taxon\n puts \" Added to taxon #{taxon.pretty_name}\"\n else\n puts \" Taxon not found or created: #{name}\"\n end\n\n end\n end",
"def get_related_isbns(isbn)\n response = open(\"http://www.librarything.com/api/thingISBN/\" + isbn)\n if response.nil?; return [isbn] end\n\n page = Nokogiri::XML(response)\n related_isbns = []\n page.css('isbn').each { |related_isbn| related_isbns.push(related_isbn.text) }\n\n related_isbns\nend",
"def links\n each_link.to_set\n end",
"def get_raw_links\n @doc.xpath(LINKS_XPATH).map { |link| link['href'] }\n end",
"def index\n @users_interests_links = UsersInterestsLink.all\n end",
"def list_available_np_as limit:nil\r\n # the base uri for api requests\r\n query_builder = Configuration.BASE_URI.dup\r\n\r\n # prepare query string for API call\r\n query_builder << \"/available-tns/npas/\"\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_query_parameters query_builder, {\r\n \"limit\" => limit,\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n \"user-agent\" => \"Flowroute SDK 1.0\",\r\n \"accept\" => \"application/json\"\r\n }\r\n\r\n response = CustomAuthUtility.append_custom_auth_params method:'GET',\r\n query_url:query_url,\r\n headers:headers\r\n\r\n # Error handling using HTTP status codes\r\n if response.code == 401\r\n raise APIException.new \"NOT AUTHORIZED\", 401, response.raw_body\r\n elsif response.code == 500\r\n raise APIException.new \"APPLICATION/SERVER ERROR\", 500, response.raw_body\r\n elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK\r\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\r\n end\r\n\r\n response.body\r\n end",
"def view(options = {})\n body = options.has_key?(:query) ? options[:query] : {}\n\n response = @client.get \"/core.tax/view/#{@tax_id}\", body, options\n\n return response\n end",
"def index\n @taxes = params['item_id'] ? Item.find(params['item_id']).taxes : Tax.all\n render json: @taxes\n end",
"def pages(taxon_id, query_options = {})\n handle_response self.class.get(\"/pages/1.0/#{taxon_id}.json\", :query => query_options)\n end",
"def links()\n return @links\n end",
"def index\n @tarots = Tarot.all\n end",
"def find_products_by_taxons(taxons)\n Spree::Product.joins(:taxons).includes(:taxons).where(spree_taxons: { name: taxons }).where('available_on <= ?', DateTime.now)\n end",
"def publishing_api_has_no_linked_items\n url = \"#{PUBLISHING_API_V2_ENDPOINT}/linked/\"\n stub_request(:get, %r{#{url}}).to_return(status: 200, body: [].to_json)\n end",
"def sitelinks(params, additional_headers = {})\n perform_request(self, @token, 'sitelinks', 'get', params, additional_headers)\n end",
"def taxon_to_json(taxon, options = {})\n {\n :id => taxon.id,\n :name => taxon.name,\n :rank => taxon.rank,\n :rank_level => taxon.rank_level,\n :iconic_taxon => options[:iconic_taxon] || taxon.iconic_taxon,\n :taxon_names => taxon.taxon_names,\n :photos => taxon.photos,\n :common_name => taxon.common_name,\n :image_url => taxon.image_url,\n :default_name => taxon.default_name\n }.to_json\n end",
"def xref_urls\n xrefs.flat_map { |type, values|\n name = :\"xref_url_for_#{type.tr(\"-\", \"_\")}\"\n respond_to?(name, true) && xref_map(values, name) || values.to_a\n }\n end",
"def links\n nodes = @node.xpath(\"atom:link\", ::AtomFeed::NS) || []\n nodes.map { |node| AtomLink.new(node) }\n end",
"def links\n @links.values\n end",
"def index\n @taxonomies = Taxonomy.find_all_by_taxonomy_type(params[:taxonomy_type].presence || 'category')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taxonomies }\n end\n end",
"def aniade_taxones_query\n end",
"def internal_links\n respond_with @page.internal_links\n end"
] | [
"0.6518563",
"0.63746446",
"0.62156045",
"0.6212406",
"0.60188425",
"0.5924883",
"0.57575035",
"0.57350504",
"0.5601776",
"0.5588982",
"0.55861056",
"0.5584229",
"0.55757415",
"0.55521965",
"0.55432546",
"0.55419827",
"0.5521935",
"0.5507723",
"0.5479883",
"0.54660213",
"0.5449633",
"0.54311955",
"0.54074466",
"0.5377731",
"0.53667206",
"0.5347952",
"0.53289473",
"0.5304446",
"0.5303034",
"0.5293249",
"0.5289871",
"0.52673507",
"0.5238547",
"0.52369547",
"0.52163196",
"0.52163196",
"0.52162975",
"0.5196221",
"0.51751447",
"0.5167207",
"0.5149803",
"0.5146482",
"0.5142616",
"0.5140149",
"0.5138264",
"0.5135546",
"0.5134785",
"0.51328945",
"0.51295733",
"0.51271826",
"0.5120713",
"0.5116574",
"0.5105586",
"0.51007265",
"0.5082708",
"0.5073449",
"0.50724775",
"0.50663185",
"0.5062764",
"0.50486624",
"0.50475734",
"0.5021807",
"0.50002617",
"0.49970922",
"0.4991966",
"0.49865055",
"0.4982319",
"0.4980221",
"0.4977817",
"0.4972511",
"0.49569952",
"0.49550804",
"0.4954999",
"0.4954999",
"0.4954999",
"0.4947906",
"0.49467972",
"0.4944619",
"0.49403882",
"0.4933471",
"0.4924617",
"0.4922569",
"0.49173948",
"0.49136016",
"0.49133462",
"0.49129775",
"0.4911435",
"0.4906958",
"0.4902971",
"0.4895322",
"0.4886105",
"0.48687726",
"0.48670068",
"0.48601076",
"0.4857118",
"0.4848436",
"0.48467374",
"0.48439288",
"0.48414338",
"0.48404628"
] | 0.5996354 | 5 |
Create a new dataset edit | def create_edit(commit, key, value)
ActiveRecord::Base.transaction do
DatasetEdit.create!(
commit_id: commit.id,
key: key,
value: value
)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n authorize! :create, Dataset\n @dataset = Dataset.new(dataset_params)\n respond_to do |format|\n if @dataset.save\n format.html { redirect_to edit_dataset_path(@dataset.key) }\n format.json { render :edit, status: :created, location: edit_dataset_path(@dataset.key) }\n else\n format.html { render :new }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :create, Dataset\n @dataset = Dataset.new(dataset_params)\n respond_to do |format|\n if @dataset.save\n format.html {redirect_to edit_dataset_path(@dataset.key)}\n format.json {render :edit, status: :created, location: edit_dataset_path(@dataset.key)}\n else\n format.html {render :new}\n format.json {render json: @dataset.errors, status: :unprocessable_entity}\n end\n end\n end",
"def create\n @dataset = Dataset.new(dataset_params)\n\n if @dataset.save\n redirect_to @dataset, notice: 'Dataset was successfully created.'\n else\n redirect_to datasets_path, notice: 'Dataset could not be created.'\n end\n end",
"def insert_dataset new_dataset_gapi\n execute { service.insert_dataset @project, new_dataset_gapi }\n end",
"def create\n @dataset = Dataset.new(params[:dataset])\n current_user.datasets << @dataset\n\n respond_to do |format|\n if @dataset.save\n format.html { redirect_to @dataset, notice: 'Dataset was successfully created.' }\n format.json { render json: @dataset, status: :created, location: @dataset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dataset = Dataset.new(params[:dataset])\n\n respond_to do |format|\n if @dataset.save\n format.html { redirect_to(@dataset, :notice => 'Dataset was successfully created.') }\n format.xml { render :xml => @dataset, :status => :created, :location => @dataset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @dataset = Dataset.new(title: params.require(:dataset)[:title].to_s.squish)\n if @dataset.save\n current_user.has_role! :owner, @dataset\n else\n flash[:error] = @dataset.errors.full_messages.to_sentence\n redirect_back(fallback_location: root_url)\n end\n end",
"def create\n @dataset = Dataset.new(dataset_params)\n\n if @dataset.save\n redirect_to @dataset\n flash[:success] = \"Dataset was successfully created.\"\n else\n render :new\n end\n end",
"def new\n @dataset = Dataset.new\n 3.times do\n @dataset.dataset_variables << DatasetVariable.new\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dataset }\n end\n end",
"def create\n @dataset = Dataset.new(params[:dataset])\n\n respond_to do |format|\n if @dataset.save\n flash[:notice] = 'Dataset was successfully created.'\n format.html { redirect_to(@dataset) }\n format.xml { render :xml => @dataset, :status => :created, :location => @dataset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @dataset = Dataset.new(params[:dataset])\n prep_dataset_form\n @dataset.save!\n publish_press_item(\"New dataset added: #{@dataset.title}\")\n\n respond_to do |wants|\n flash[:notice] = 'Dataset was successfully created.'\n wants.html { redirect_to(@dataset) }\n wants.xml { render :xml => @dataset, :status => :created, :location => @dataset }\n end\n end",
"def create\n @dataset = Dataset.new(dataset_params)\n study = @dataset.study\n authorize! :edit, study\n\n respond_to do |format|\n if @dataset.save\n format.html { redirect_to @dataset,\n notice: 'Dataset was successfully created. Your new dataset must be reviewed by an administrator before making it public.' }\n format.json { render :show, status: :created, location: @dataset }\n else\n format.html { render :new }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dataset = Dataset.new(params[:dataset])\n\n respond_to do |format|\n if @dataset.save\n flash[:notice] = 'Dataset was successfully created.'\n format.html { redirect_to dataset_url(@dataset) }\n format.xml { head :created, :location => dataset_url(@dataset) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @dataset.errors.to_xml }\n end\n end\n end",
"def create_or_use_unsubmitted_edit\n if !unsubmitted_edit.nil?\n unsubmitted_edit\n else\n dataset_edits.new\n end\n end",
"def add(dataset)\n \"add dataset\\nset name=#{dataset}\\nend\"\n end",
"def create\n @data_set = DataSet.new(data_set_params)\n\n respond_to do |format|\n if @data_set.save\n format.html { redirect_to [:admin, @data_set], notice: 'Data set was successfully created.' }\n format.json { render :show, status: :created, location: [:admin, @data_set] }\n else\n format.html { render :new }\n format.json { render json: @data_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_new_task(data)\n new_task.click\n new_task_title.when_present.set data[:title] if data[:title]\n new_task_description.set data[:description] if data[:description]\n new_task_status.select data[:status] if data[:status]\n save_new_task.click\n end",
"def create\n @dataset_datum = DatasetDatum.new(dataset_datum_params)\n\n respond_to do |format|\n if @dataset_datum.save\n format.html { redirect_to @dataset_datum, notice: 'Dataset datum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @dataset_datum }\n else\n format.html { render action: 'new' }\n format.json { render json: @dataset_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n id = dataset.insert(attributes)\n\n if id\n self.id = id\n\n self\n else\n nil\n end\n end",
"def create\n @dataset = Dataset.new(params[:dataset])\n @dataset.user = current_user\n\n respond_to do |format|\n if @dataset.save\n @dataset.process!\n format.html { redirect_to(@dataset, :notice => 'Dataset was successfully created.') }\n format.xml { render :xml => @dataset, :status => :created, :location => @dataset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_dataset\n @dataset = Dataset.find(params[:id])\n end",
"def set_dataset\n @dataset = Dataset.find(params[:id])\n end",
"def set_dataset\n @dataset = Dataset.find(params[:id])\n end",
"def set_dataset\n @dataset = Dataset.find(params[:id])\n end",
"def create\n @qdataset = Qdataset.new(qdataset_params)\n\n respond_to do |format|\n if @qdataset.save\n format.html { redirect_to @qdataset, notice: 'Qdataset was successfully created.' }\n format.json { render :show, status: :created, location: @qdataset }\n else\n format.html { render :new }\n format.json { render json: @qdataset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_dataset\n @dataset = Dataset.find(params[:id] || params[:dataset_id])\n end",
"def create\n\t\t@data_set = DataSet.new(params[:data_set])\n\n\t\trespond_to do |format|\n\t\t\tif @data_set.save\n\t\t\t\tformat.html { redirect_to @data_set, notice: 'Data set was successfully created.' }\n\t\t\t\tformat.json { render json: @data_set, status: :created, location: @data_set }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @data_set.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update!(**args)\n @dataset = args[:dataset] if args.key?(:dataset)\n @dataset_display_name = args[:dataset_display_name] if args.key?(:dataset_display_name)\n end",
"def update!(**args)\n @dataset = args[:dataset] if args.key?(:dataset)\n @dataset_display_name = args[:dataset_display_name] if args.key?(:dataset_display_name)\n end",
"def dataset_params\n params.require(:dataset).permit(:name, :description, :contents)\n end",
"def new_datafile\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\t#LOG.debug (fname){\"params=#{params.inspect}\"}\n\t\t@part = Part.find(params[:id])\n\t\t@datafile = Datafile.new({:user => current_user, :thepart => @part})\n\t\tctrl_new_datafile(@part)\n\tend",
"def set_dataset_datum\n @dataset_datum = DatasetDatum.find(params[:id])\n end",
"def create\n @image_dataset = ImageDataset.new(params[:image_dataset])\n\n respond_to do |format|\n if @image_dataset.save\n flash[:notice] = 'ImageDataset was successfully created.'\n format.html { redirect_to(@image_dataset) }\n format.xml { render :xml => @image_dataset, :status => :created, :location => @image_dataset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @image_dataset.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_new_acquisition(data_set)\n enter_acquisition_info_data data_set\n save_record\n end",
"def create_new_acquisition(data_set)\n enter_acquisition_info_data data_set\n save_record\n end",
"def new\n @dataset = Dataset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dataset }\n end\n end",
"def new\n @dataset = Dataset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dataset }\n end\n end",
"def new_datafile\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\t#LOG.debug (fname){\"params=#{params.inspect}\"}\n\t\t@customer = Customer.find(params[:id])\n\t\t@datafile = Datafile.new({:user => current_user, :thecustomer => @customer})\n\t\tctrl_new_datafile(@customer)\n\tend",
"def new_datafile\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\t#LOG.debug(fname){\"params=#{params.inspect}\"}\n\t\t@object_plm = Customer.find(params[:id])\n\t\t@datafile = Datafile.new({:user => current_user, :thecustomer => @object_plm})\n\t\tctrl_new_datafile(@object_plm)\n\tend",
"def edit\n load_data\n end",
"def create\r\n\r\n\r\n end",
"def new\n @dataset = Dataset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dataset }\n end\n end",
"def create_with_datafile\n unless params.require(:datafile).permit(:utf8, :authenticity_token, :title, :file, :'@tempfile', :'@original_filename', :'@content_type', :'@headers')\n flash[:error] = 'No data file given for upload'\n redirect_back(fallback_location: root_url) && return\n end\n\n datafile = Datafile.new(params.require(:datafile).permit(:utf8, :authenticity_token, :title, :file, :'@tempfile', :'@original_filename', :'@content_type', :'@headers'))\n unless datafile.save\n flash[:error] = datafile.errors.full_messages.to_sentence\n redirect_back(fallback_location: root_url) && return\n end\n\n attributes = datafile.general_metadata_hash\n attributes[:title] = params.slice(:title)[:title].to_s.squish if params[:title]\n\n @dataset = Dataset.new(attributes)\n if @dataset.save\n @dataset.add_datafile(datafile)\n @dataset.load_projects_and_authors_from_current_datafile\n current_user.has_role! :owner, @dataset\n @unfound_usernames = datafile.authors_list[:unfound_usernames]\n render action: :create\n else\n datafile.destroy\n flash[:error] = @dataset.errors.full_messages.to_sentence\n redirect_back(fallback_location: root_url)\n end\n end",
"def create\n @dataunit = Dataunit.new(dataunit_params)\n\t@dataunit.dataset_id=dataset_id\n\n respond_to do |format|\n if @dataunit.save\n format.html { redirect_to @dataunit, notice: @dataunit.user_id.to_s + 'Dataunit was successfully created.' }\n format.json { render :show, status: :created, location: @dataunit }\n else\n format.html { render :new }\n format.json { render json: @dataunit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @data_set = DataSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @data_set }\n end\n end",
"def new\n @dataset = Dataset.new\n prep_dataset_form\n \n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @dataset }\n end\n end",
"def create_dataset(name, description, columns)\n authenticate unless authenticated?\n payload = {\n name: name,\n description: description,\n }\n schema = {columns: []}\n columns.each { |col| schema[:columns].push(col) }\n payload[:schema] = schema\n response = RestClient::Request.execute(\n url: @@datasets_endpoint,\n method: :post,\n headers: headers('application/json'),\n payload: JSON.generate(payload)\n )\n return JSON.parse(response.body)\n end",
"def _insert_dataset\n use_server(model.instance_insert_dataset)\n end",
"def _insert_dataset\n use_server(model.instance_dataset)\n end",
"def _insert_dataset\n use_server(model.instance_dataset)\n end",
"def create\n @data_set = DataSet.new(params[:data_set])\n\n respond_to do |format|\n if @data_set.save\n format.html { redirect_to @data_set, notice: 'Project data set was successfully created.' }\n format.json { render json: @data_set.to_hash(false), status: :created, location: @data_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @data_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\t\t@data_set = DataSet.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @data_set }\n\t\tend\n\tend",
"def create(entity)\n @dataset.create(\n _serialize(entity)\n )\n end",
"def create(entity)\n @dataset.create(\n _serialize(entity)\n )\n end",
"def create\n @image_dataset = ImageDataset.new(params[:image_dataset])\n @image_dataset.user = current_user\n respond_to do |format|\n if @image_dataset.save\n # problem with some SCREENSAVE sereies description, null rep_time causing error\n if @image_dataset.series_description == 'SCREENSAVE' and @image_dataset.rep_time.blank?\n @image_dataset.rep_time = 0\n @image_dataset.save\n # if save not work\n #sql = \"UPDATE image_datasets set rep_time=0 where rep_time is NULL and id=\"+@image_dataset.id.to_s\n #connection = ActiveRecord::Base.connection();\n #results = connection.execute(sql)\n end\n flash[:notice] = 'ImageDataset was successfully created.'\n format.html { redirect_to(@image_dataset) }\n format.xml { render :xml => @image_dataset, :status => :created, :location => @image_dataset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @image_dataset.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @dataset_template = args[:dataset_template] if args.key?(:dataset_template)\n end",
"def dataset_params\n params.require(:dataset).permit(:name, :index_name, :document_type, :data)\n end",
"def create\n @data_set = DataSet.new(data_set_params)\n @project = @data_set.project\n\n if @project.lock? and !can_edit?(@project) and !key?(@project)\n redirect_to @project, alert: 'Project is locked'\n return\n end\n\n if !current_user.nil?\n @data_set.user_id = current_user.id\n elsif !session[:contributor_name].nil?\n @data_set.user_id = @project.user_id\n @data_set.contributor_name = session[:contributor_name]\n else\n @data_set.user_id = @project.user_id\n end\n\n respond_to do |format|\n if @data_set.save\n format.html { redirect_to @data_set, notice: 'Project data set was successfully created.' }\n format.json { render json: @data_set.to_hash(false), status: :created, location: @data_set }\n else\n format.html do\n flash[:error] = @data_set.errors\n redirect_to @data_set\n end\n format.json { render json: @data_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n chef_server_rest.post(\"data/#{data_bag}\", self)\n self\n end",
"def update\n if @dataset.update(dataset_params)\n redirect_to @dataset\n flash[:success] = \"Dataset was successfully updated.\"\n else\n render action: 'edit'\n end\n end",
"def create\n @data_set_type = DataSetType.new(data_set_type_params)\n\n respond_to do |format|\n if @data_set_type.save\n format.html { redirect_to @data_set_type, notice: 'Data set type was successfully created.' }\n format.json { render :show, status: :created, location: @data_set_type }\n else\n format.html { render :new }\n format.json { render json: @data_set_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_data_line(which = 1)\n create_line(\"data_line_#{which}\",\"Data_Line\", which)\n end",
"def update\n # raise(\"boobies!\")\n @dataset = Dataset.find(params[:id])\n # raise(params[:dataset][:dataset_variables_attributes][\"0\"].class.to_s)\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n flash[:notice] = 'Dataset was successfully updated.'\n format.html { redirect_to(@dataset) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_dataset(datasetId)\n api(\n api_method: @bq.datasets.insert,\n body_object: { \"datasetReference\" => {\n \"datasetId\" => datasetId,\n \"projectId\" => @project_id,\n }\n }\n )\n end",
"def set_data_set\n @data_set = DataSet.find_by(:id => params[:dataset_id])\n end",
"def insert(*args)\n dataset.insert(*args)\n self\n end",
"def create\n \n end",
"def build!(data_set_name)\n interface(data_set_name).create_empty_data_set\n library[data_set_name] = DataSet.new(data_set_name, interface(data_set_name))\n end",
"def create objid\n DataObj.new @repo, self, objid, true\n end",
"def set_data_set\n @data_set = DataSet.find(params[:id])\n end",
"def set_data_set\n @data_set = DataSet.find(params[:id])\n end",
"def set_dataset\n\n @dataset = Dataset.find_by_key(params[:id])\n unless @dataset\n @dataset = Dataset.find(params[:dataset_id])\n end\n raise ActiveRecord::RecordNotFound unless @dataset\n end",
"def set_data_set\n @data_set = DataSet.find(params[:id])\n end",
"def create\r\n end",
"def create_lab\n @lab = Lab.new(params[:lab])\n @lab.save\n @labs = Lab.find(:all)\n redraw 'labs'\n end",
"def create\n @data_set = DataSet.new(params[:data_set])\n params[:visibility] = 'public' unless current_user\n\n respond_to do |format|\n if @success = @data_set.save_and_upload_file(params)\n @data_set.set_visibility(current_user, params)\n flash[:notice] = 'DataSet was successfully created.'\n format.all_text \n format.html { redirect_to(@data_set) }\n format.xml { render :xml => @data_set, :status => :created, :location => @data_set }\n else\n format.all_text \n format.html { render :action => 'new' }\n format.xml { render :xml => @data_set.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n \n end",
"def update!(**args)\n @dataset_id = args[:dataset_id] if args.key?(:dataset_id)\n end",
"def update!(**args)\n @data_labeling_annotated_datasets = args[:data_labeling_annotated_datasets] if args.key?(:data_labeling_annotated_datasets)\n @dataset = args[:dataset] if args.key?(:dataset)\n @dataset_display_name = args[:dataset_display_name] if args.key?(:dataset_display_name)\n end",
"def update\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to(@dataset, :notice => 'Dataset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dataset.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def insert_routine dataset_id, new_routine_gapi\n execute { service.insert_routine @project, dataset_id, new_routine_gapi }\n end",
"def create\n @sub_data_table = SubDataTable.new(sub_data_table_params)\n\n respond_to do |format|\n if @sub_data_table.save\n format.html { redirect_to @sub_data_table.data_table, notice: 'Se creó el set de datos correctamente.' }\n format.json { render :show, status: :created, location: @sub_data_table }\n else\n format.html { render :new }\n format.json { render json: @sub_data_table.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @datafile = Datafile.new(dataset_id: params[:datafile][:dataset_id])\n uploaded_io = params[:datafile][:upload]\n\n @datafile.web_id ||= @datafile.generate_web_id\n\n @datafile.storage_root = Application.storage_manager.draft_root\n @datafile.filename = uploaded_io.original_filename\n @datafile.storage_key = File.join(@datafile.web_id, @datafile.filename)\n @datafile.size = uploaded_io.size\n\n # Moving the file to some safe place; as tmp files will be flushed timely\n Application.storage_manager.draft_root.copy_io_to(@datafile.storage_key, uploaded_io, nil, uploaded_io.size)\n\n respond_to do |format|\n if @datafile.save\n format.html { redirect_to @datafile, notice: 'Datafile was successfully created.' }\n format.json { render :show, status: :created, location: @datafile }\n else\n format.html { render :new }\n format.json { render json: @datafile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n flash[:notice] = 'Dataset was successfully updated.'\n format.html { redirect_to dataset_url(@dataset) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dataset.errors.to_xml }\n end\n end\n end",
"def set_dataset\n # TODO\n #@dataset = DatasetService.get_dataset\n end",
"def create; end",
"def create; end",
"def create; end",
"def create; end",
"def create!\n end",
"def update\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to @dataset, notice: 'Dataset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n end",
"def create(data, options = {})\n @@grid.put(data, options)\n end",
"def update!(**args)\n @dataset = args[:dataset] if args.key?(:dataset)\n @dataset_display_name = args[:dataset_display_name] if args.key?(:dataset_display_name)\n @migrate_data_labeling_annotated_dataset_configs = args[:migrate_data_labeling_annotated_dataset_configs] if args.key?(:migrate_data_labeling_annotated_dataset_configs)\n end",
"def test_create_from_data\n data = @test_record.all_text\n \n creation_test do |record|\n record.create_from_data('', data)\n end\n end",
"def add_dataset(name)\n unless metadata[:datasets].include? name\n d = MiGA::Dataset.new(self, name)\n @metadata[:datasets] << name\n @dataset_names_hash = nil # Ensure loading even if +do_not_save+ is true\n save\n if d.ref? && d.active?\n recalculate_tasks(\"Reference dataset added: #{d.name}\")\n end\n pull_hook(:on_add_dataset, name)\n end\n dataset(name)\n end",
"def create\n end",
"def update!(**args)\n @dataset = args[:dataset] if args.key?(:dataset)\n @project_id = args[:project_id] if args.key?(:project_id)\n @table = args[:table] if args.key?(:table)\n end",
"def update!(**args)\n @dataset = args[:dataset] if args.key?(:dataset)\n @project_id = args[:project_id] if args.key?(:project_id)\n @table = args[:table] if args.key?(:table)\n end"
] | [
"0.68801874",
"0.68705106",
"0.6591719",
"0.6581154",
"0.6516188",
"0.6506433",
"0.6491185",
"0.6483731",
"0.6472215",
"0.6436314",
"0.6412467",
"0.6405469",
"0.6388114",
"0.638208",
"0.6238408",
"0.6166315",
"0.6138559",
"0.6121323",
"0.6091757",
"0.60863113",
"0.6073443",
"0.6073443",
"0.6073443",
"0.6073443",
"0.6026959",
"0.602689",
"0.5986422",
"0.59730643",
"0.59730643",
"0.592758",
"0.59057665",
"0.5898794",
"0.58917266",
"0.5891022",
"0.5891022",
"0.5862626",
"0.5862626",
"0.58393747",
"0.5820382",
"0.58173984",
"0.5809021",
"0.58031535",
"0.5800066",
"0.5799242",
"0.57839024",
"0.57728255",
"0.57455117",
"0.5738563",
"0.57291967",
"0.57291967",
"0.57252693",
"0.5720614",
"0.5693678",
"0.5693678",
"0.5690353",
"0.5684566",
"0.5679593",
"0.56725705",
"0.5669574",
"0.56663954",
"0.56478906",
"0.5646124",
"0.5623954",
"0.5620041",
"0.5619211",
"0.5608265",
"0.56059587",
"0.5596078",
"0.5536008",
"0.5526364",
"0.5526364",
"0.55178845",
"0.5515654",
"0.5515543",
"0.5498843",
"0.5497661",
"0.5479696",
"0.5478265",
"0.5470268",
"0.54525626",
"0.5435911",
"0.5435171",
"0.5431165",
"0.54268926",
"0.54235417",
"0.54201615",
"0.54201615",
"0.54201615",
"0.54201615",
"0.54138947",
"0.5413296",
"0.5411666",
"0.54036003",
"0.54030013",
"0.5392318",
"0.53894544",
"0.5384162",
"0.5375904",
"0.5375904"
] | 0.7034984 | 1 |
Finds all commits belonging to a dataset with an edit to the given key. | def find_commits(dataset, edit_key)
dataset.commits
.joins(:dataset_edits)
.where(dataset_edits: { key: edit_key })
.order(updated_at: :desc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_edit(dataset, edit_key)\n commits = find_commits(dataset, edit_key)\n\n return nil unless commits.any?\n\n DatasetEdit\n .where(commit_id: commits.pluck(:id), key: edit_key)\n .order(updated_at: :desc)\n .first\n end",
"def find_edit(dataset, edit_key)\n commits = find_commits(dataset, edit_key)\n\n return nil unless commits.any?\n\n DatasetEdit\n .where(commit_id: commits.pluck(:id), key: edit_key)\n .order(updated_at: :desc)\n .first\n end",
"def destroy_edits(dataset, edit_key)\n commits = find_commits(dataset, edit_key)\n\n return if commits.none?\n\n commits.each do |commit|\n if commit.dataset_edits.one?\n commit.destroy\n else\n commit.dataset_edits.find_by_key(edit_key).destroy\n end\n end\n end",
"def destroy_edits(dataset, edit_key)\n commits = find_commits(dataset, edit_key)\n\n return if commits.none?\n\n commits.each do |commit|\n if commit.dataset_edits.one?\n commit.destroy\n else\n commit.dataset_edits.find_by_key(edit_key).destroy\n end\n end\n end",
"def get_commit(key, id)\n key = key_for(key)\n commit = git.commit(id)\n blob = commit.tree / key\n decode(blob.data) if blob\n end",
"def commits\n return @commits if @commits\n # perform search and memoize result\n commits_from_search = []\n commits_from_search = parent_report_group.commits if parent_report_group\n find_by_hash.each do |field, args|\n commits_from_search = self.send(\"find_by_#{field}\".to_sym, commits_from_search, args)\n end\n @commits = commits_from_search\n end",
"def changelogs\n changelog.entries(pattern: \"*#{key.digest}*\")\n end",
"def select_commits_matching_dataset_criteria(grit_commits, dataset_filter_options)\n return [] if grit_commits.empty?\n repo = GitRepo.first(:name => grit_commits.first.repo_name)\n raise \"This commit does not have a repo_name set on it: #{grit_commits.first.sha}\" unless repo\n commits_dataset = Commit.select(:sha).filter(:sha => grit_commits.map(&:sha), :git_repo_id => repo.id).\n filter(dataset_filter_options)\n commit_ids = Set.new(commits_dataset.all.map(&:sha))\n grit_commits.select { |grit_commit| commit_ids.include?(grit_commit.sha) }\n end",
"def filtered_by_key(key)\n where(key: key)\n end",
"def find_by_key(key)\n find_by_id(key) # backlog method looks exactly the same except for the parameter type\n end",
"def create_edit(commit, key, value)\n ActiveRecord::Base.transaction do\n DatasetEdit.create!(\n commit_id: commit.id,\n key: key,\n value: value\n )\n end\n end",
"def create_edit(commit, key, value)\n ActiveRecord::Base.transaction do\n DatasetEdit.create!(\n commit_id: commit.id,\n key: key,\n value: value\n )\n end\n end",
"def select_commits_currently_in_db(grit_commits)\n # This filter doesn't have any specific dataset criteria, other than the commits need to exist in the DB.\n select_commits_matching_dataset_criteria(grit_commits, {})\n end",
"def commit_entries(pr_id)\n q = <<-QUERY\n select c.sha as sha\n from pull_requests pr, pull_request_commits prc, commits c\n where pr.id = prc.pull_request_id\n and prc.commit_id = c.id\n and pr.id = ?\n QUERY\n commits = db.fetch(q, pr_id).all\n\n commits.reduce([]){ |acc, x|\n a = mongo.find(:commits, {:sha => x[:sha]})[0]\n acc << a unless a.nil?\n acc\n }.select{|c| c['parents'].size <= 1}\n end",
"def watch_commits\n watch( \"COMMIT_EDITMSG\") do |md| \n run_all\n end\nend",
"def find_by_key(key)\n find_by('key', key)\n end",
"def commit_entries(pr_id)\n q = <<-QUERY\n select c.sha as sha\n from pull_requests pr, pull_request_commits prc, commits c\n where pr.id = prc.pull_request_id\n and prc.commit_id = c.id\n and pr.id = ?\n QUERY\n commits = db.fetch(q, pr_id).all\n\n commits.reduce([]){ |acc, x|\n a = mongo['commits'].find_one({:sha => x[:sha]})\n acc << a unless a.nil?\n acc\n }.select{|c| c['parents'].size <= 1}\n end",
"def fetch_open_edit_kyc_cases\n # No Kycs present\n return if @user_kyc_details.blank?\n\n case_ids = @user_kyc_details.map {|x| x[1].id}\n @open_edit_cases = EditKycRequest.using_client_shard(client: @client).\n under_process.where(case_id: case_ids).collect(&:case_id)\n end",
"def fetch_all(key); end",
"def getChangesOfCommit(commit_id = false)\n my_commit = ((commit_id == false and @repo.commits.size > 0) ? @repo.commits.first : @repo.commit(commit_id))\n if my_commit == nil\n return false\n end\n \n # get list of changed files and parse it\n @filelist = Hash.new\n options = {:r => true, :name_status => true, :no_commit_id => true}\n if @repo.commit(my_commit.sha).parents[0] == nil # if my_commit is the first commit\n options[:root] = true\n end\n changed_files_list = @git.diff_tree(options, my_commit.id).strip\n if changed_files_list.class == String and changed_files_list.length > 0\n changed_files_list.split(\"\\n\").each do |f|\n commit = my_commit\n operation = f[0,1] # D/M/A\n filepath = f[2..-1] # path+filename\n path = \"/\" + filepath.match(/^.+\\//).to_s # just path\n status = \"created\"\n if operation =~ /^D$/i # deleted\n # the file was deleted, so get the blob from the parent-commit\n commit = @repo.commit(my_commit.parents[0].sha)\n status = \"deleted\"\n elsif operation =~ /^M$/i # modified\n status = \"updated\"\n end\n blob = commit.tree/(filepath)\n\n #name = filepath.gsub(path[1..-1], '') #blob.name\n path = path.gsub(/\\/private\\/[0-9]+\\//,'')\n \n \n \n @filelist[\"/\" + filepath] = {\"uploaded\" => '1', \"status\" => status, \"blob_hash\" => blob.id, \"name\" => blob.name, \"path\" => \"/#{path}\", \"size\" => blob.size, \"filetype\" => blob.mime_type, \"filedate\" => @repo.commit(commit.sha).date.strftime('%T %F').to_s}\n \n \n end\n end\n\n if @filelist.size > 0\n return @filelist\n else\n return false\n end\n end",
"def find_issues(key, search_title: true, search_commits: false, search_branch: false)\n regexp = build_regexp_from_key(key)\n jira_issues = []\n\n jira_issues.concat(search_title(regexp)) if search_title\n jira_issues.concat(search_commits(regexp)) if search_commits\n jira_issues.concat(search_branch(regexp)) if search_branch\n jira_issues.concat(search_pr_body(regexp)) if jira_issues.empty?\n\n @issues = jira_issues.uniq(&:downcase).map { |issue_key| @api.Issue.find(issue_key) }\n end",
"def search_commit(commit)\n search_text(commit.message)\n end",
"def fetch_commit(commit_id)\n found = commits.find do |commit|\n commit[\"sha\"] == commit_id\n end\n if found\n stringify_keys_deep(found.to_hash)\n else\n # cache miss; don't add to @commits because unsure of order.\n check_github_response do\n commit = @client.commit(user_project, commit_id)\n commit = stringify_keys_deep(commit.to_hash)\n commit\n end\n end\n end",
"def files_at_commit(pr_id, filter = lambda{true})\n q = <<-QUERY\n select c.sha\n from pull_requests p, commits c\n where c.id = p.base_commit_id\n and p.id = ?\n QUERY\n\n base_commit = db.fetch(q, pr_id).all[0][:sha]\n files = repo.lstree(base_commit, :recursive => true)\n\n files.select{|x| filter.call(x)}\n end",
"def find_by_subkey(key, value=true)\n @@commands.select {|meth, meth_value| meth_value[key]==value}\n end",
"def changed?(key = nil)\n if key.nil?\n changes.any?\n else\n changes.include?(key)\n end\n end",
"def changed?(key = nil)\n if key.nil?\n changes.any?\n else\n changes.include?(key)\n end\n end",
"def commits\n @commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse\n end",
"def find(key)\n find_helper(@root, key)\n end",
"def find(key)\n find_helper(@root, key)\n end",
"def find(collection, *key)\n command(collection).get(key)\n end",
"def edits\n @edits ||= {}\n end",
"def find_by_key(key)\n by_key[key]\n end",
"def find_by_key(key)\n by_key[key]\n end",
"def find(revision, key, options = {})\n get_path(\n path_to_find(revision, key),\n options,\n get_parser(:object, Tinybucket::Model::BuildStatus)\n )\n end",
"def get_comments(issue_id_or_key, params = {})\n get(\"issues/#{issue_id_or_key}/comments\", params)\n end",
"def show_edits!\n\t\treturn unless self.edited?\n\t\tself.edits.each do |k, v|\n\t\t\tnext if @@not_tracked.include? k\n\t\t\tself.send(\"#{k}=\", v)\n\t\tend\n\tend",
"def [](key)\n _data.fetch(key) { search_in_kept_data(key) }\n end",
"def key?(key)\n !(head && head.commit.tree / key_for(key)).nil?\n end",
"def key?(key)\n !(head && head.commit.tree / key_for(key)).nil?\n end",
"def commits(commit=head)\n commits_for(commit)\n end",
"def fetch_data(key)\n map { |om| om.fetch_data(key) }.flatten.compact\n end",
"def dirty?(key=nil, **opts)\n if key.nil?\n !@dirty.empty?\n else\n @dirty.key?(key.to_sym)\n end\n end",
"def lookup(key)\n key = key.to_i if key.to_i.to_s == key.to_s # casting for things like \"10\"\n case key\n when Fixnum, Bignum, Integer\n changelog.node_id_for_index(key)\n when \".\"\n dirstate.parents().first\n when \"null\", nil\n NULL_ID\n when \"tip\"\n changelog.tip\n else\n \n n = changelog.id_match(key)\n return n if n\n \n return tags[key] if tags[key]\n return branch_tags[key] if branch_tags[key]\n \n n = changelog.partial_id_match(key)\n return n if n\n \n # bail\n raise RepoError.new(\"unknown revision #{key}\")\n end\n end",
"def find(key)\n helper_find(@root, key)\n end",
"def get_all_commits_in_repo\n @branches.collect(&:commits).flatten.sort_by { |k| k.authored_date }.reverse\n end",
"def fetch_edit_kyc_request\n edit_kyc_requests = EditKycRequest.using_client_shard(client: @client).where(case_id: @user_kyc_detail.id,\n status: GlobalConstant::EditKycRequest.unwhitelist_in_process_status).all\n\n\n if edit_kyc_requests.length != 1\n notify_devs(\n {kyc_whitelist_log_id: @kyc_whitelist_log.id, edit_kyc_requests: edit_kyc_requests},\n \"Error in getting Edit kyc request row\"\n )\n\n return error_with_data(\n 'am_pu_b_fekr_1',\n 'Error in getting Edit kyc request row',\n 'Error in getting Edit kyc request row',\n GlobalConstant::ErrorAction.default,\n {}\n )\n end\n\n\n @edit_kyc_request = edit_kyc_requests[0]\n\n success\n end",
"def grep_cmd\n sprintf 'grep -Fq \"%s\" %s', key_set_string, @file\n end",
"def commits\n object.commits.map { |c| c.id }\n end",
"def find_by_commit_path(commits, args)\n raise \"Configuration Error: #{path.join('>')} specified 'find_by' 'commit_path' without any 'match' or 'omit' attributes\" unless args[\"match\"] || args[\"omit\"]\n match = eval(args[\"match\"]) rescue nil\n omit = eval(args[\"omit\"]) rescue nil\n commits.select {|commit| commit.paths.any?{|commit_path| (match.nil? || commit_path.path =~ match) && (omit.nil? || (commit_path.path =~ omit).nil?)}}\n end",
"def find(key, filters = {}, context = nil)\n with_scope(context) do\n get(filters)[key].map(&:keys).flatten rescue []\n end\n end",
"def find(key)\n find_node(checked_get_node(key))\n end",
"def get_changes_for(changeable, opts = {})\n limit = opts.delete(:limit)\n my_id = changeable.id\n return self.send(\"find_all_by_#{self.changeable_fk}\", my_id, {:order => 'updated_at'}) unless limit\n self.send(\"find_all_by_#{self.changeable_fk}\", my_id, {:order => 'updated_at', :limit => limit})\n end",
"def owners_by_key\n @owners_by_key ||= owners.group_by do |owner|\n key = owner[owner_key_name]\n key && key.to_s\n end\n end",
"def changes(key)\n changed_attributes[key]\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def delete(key, opts = {})\n options = setup_commit_options({:message => \"deleted #{key}\"}.merge(opts))\n self[key].tap do\n save(options) {|index| index.delete(key_for(key)) }\n end\n end",
"def delete(key, opts = {})\n options = setup_commit_options({:message => \"deleted #{key}\"}.merge(opts))\n self[key].tap do\n save(options) {|index| index.delete(key_for(key)) }\n end\n end",
"def project_commits(id)\n begin\n JSON(RestClient.get GITLAB_WS_URL + \"projects/#{id}/repository/commits\", {:private_token => GITLAB_TOKEN}).reverse\n rescue Exception\n return []\n end\n end",
"def changeset_params\n params.require(:changeset).permit(:key, :project_id, :description)\n end",
"def files_at_commit(pr_id, filter = lambda{true})\n q = <<-QUERY\n select c.sha\n from pull_requests p, commits c\n where c.id = p.base_commit_id\n and p.id = ?\n QUERY\n\n def lslr(tree, path = '')\n all_files = []\n for f in tree.map{|x| x}\n f[:path] = path + '/' + f[:name]\n if f[:type] == :tree\n begin\n all_files << lslr(repo.lookup(f[:oid]), f[:path])\n rescue Exception => e\n STDERR.puts e\n all_files\n end\n else\n all_files << f\n end\n end\n all_files.flatten\n end\n\n base_commit = db.fetch(q, pr_id).all[0][:sha]\n begin\n files = lslr(repo.lookup(base_commit).tree)\n files.select{|x| filter.call(x)}\n rescue Exception => e\n STDERR.puts \"Cannot find commit #{base_commit} in base repo\"\n []\n end\n end",
"def list_checkout_keys\n CircleCi.request(@conf, \"/project/#{username}/#{project}/checkout-key\").get\n end",
"def search_in_kept_data(key)\n string_key = key.to_s\n\n data = kept.find do |kept_data|\n parsed = Hanami::Utils::Json.parse(kept_data)\n parsed['data'].fetch(string_key, nil) if is_hash?(parsed['data'])\n end\n\n Hanami::Utils::Json.parse(data)['data'][string_key] if data\n end",
"def company_updates_comments(update_key, options={})\n path = \"#{company_path(options)}/updates/key=#{update_key}/update-comments\"\n get(path, options)\n end",
"def is_editable?(key)\n (@options[:editable] || {})[key.to_sym] || true\n end",
"def get(user_name, repo_name, sha, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n _validate_presence_of sha\n normalize! params\n\n get_request(\"/1.0/repositories/#{user}/#{repo.downcase}/changesets/#{sha}\", params)\n end",
"def find_pivotal_stories(key: nil, search_title: true, search_commits: true)\n keys = key.kind_of?(Array) ? key.join(\" |\") : key\n story_key_regex_string = /(#{keys} )#(\\d{6,})/i\n regexp = Regexp.new(/#{story_key_regex_string}/)\n\n matching_stories = []\n\n if search_title\n github.pr_title.gsub(regexp) do |match|\n matching_stories << extract_id(match).first\n\n puts \"matches #{matching_stories}\"\n end\n end\n\n if search_commits\n puts \"git commits #{git.commits}\"\n git.commits.map do |commit|\n commit.message.gsub(regexp) do |match|\n matching_stories << extract_id(match).first\n end\n end\n end\n\n if matching_stories.empty?\n github.pr_body.gsub(regexp) do |match|\n matching_stories << extract_id(match).first\n end\n end\n\n return matching_stories.uniq\n end",
"def set_credential_key\n @credential = Credential.find(params[:id])\n end",
"def add_read(key)\n if (@is_commit)\n raise RuntimeError.new('No further request supported after a commit!')\n end\n @requests << {'read' => key}\n self\n end",
"def update_commitlist(h)\n h.map do |entry|\n sha = entry[\"commit\"].to_s.strip\n n = entry[\"note\"]\n # First, try to look it up in our existing repo\n if commit_exists?(sha) || sha.empty?\n entry # do nothing, put it back in the hash\n else\n # Ok, we know it doesn't exist. Now look it up in gitlog.json\n if @gitlog_json.key? sha\n m = @gitlog_json[sha][\"message\"]\n svn_id = m.lines.select {|l| l.match? /git-svn-id/ }.join.strip\n grep_cmd = <<~EOS.strip\n git -C ./tmp/src rev-list --all --grep=\"#{svn_id}\" --\n EOS\n stdout, stderr, status = Open3.capture3(grep_cmd)\n if stderr.empty?\n {\n \"commit\" => stdout.strip,\n \"note\" => <<~EOS.strip\n #{entry[\"note\"].to_s.lines.join(\"\\n\")}\n\n Formerly #{sha} before HTTPD rewrote Git history.\n EOS\n }\n else\n warn \"ERROR getting commit #{sha}. #{stderr}\"\n entry\n end\n else\n warn \"ERROR commit #{sha} does not exist in gitlog.json\"\n entry\n end\n end\n end\nend",
"def set_scope(key)\n response_filters << lambda do |data|\n fetch_path(data, *key)\n end\n end",
"def keys\n head.commit.tree.contents.map{|blob| deserialize(blob.name) }\n end",
"def keys\n head.commit.tree.contents.map{|blob| deserialize(blob.name) }\n end",
"def project_commit(project, commit_id)\n get(\"/projects/#{project}/commits/#{commit_id}\")\n end",
"def find(key)\n current_node = @root \n return find_helper(current_node, key)\n end",
"def edit_commit_log( logfile )\n\t\t\tdiff = make_commit_log()\n\n\t\t\tFile.open( logfile, 'w' ) do |fh|\n\t\t\t\tfh.print( diff )\n\t\t\tend\n\n\t\t\tedit( logfile )\n\t\tend",
"def find(key)\n items.find do |item|\n item.key == key\n end\n end",
"def batch_by_oid(repo, oids)\n wrapped_gitaly_errors do\n repo.gitaly_commit_client.list_commits_by_oid(oids)\n end\n end",
"def get_commits(pull_req_id)\n do_request(\"https://api.github.com/repos/#{CONFIG[\"repo\"][\"org\"]}/#{CONFIG[\"repo\"][\"repo\"]}/pulls/#{pull_req_id}/commits\", true)\n end",
"def commit(id)\n Gitlab::Git::Commit.find(self, id)\n end",
"def fetch_changelogs\n @changelogs = @spkg.changelogs\n .includes(:maintainer)\n .order(at: :desc, evr: :desc, created_at: :desc)\n end",
"def find(revision, options = {})\n get_path(\n path_to_find(revision),\n options,\n get_parser(:object, Tinybucket::Model::Commit)\n )\n end",
"def include?(key)\n key_to_hashes(key).all? do |hash|\n filter.set?(hash)\n end\n end",
"def project(key)\n @tracker.getProjects.detect { |pro| pro.key == key }\n end",
"def all_file_commits_data(path)\n time = ` cd /tmp/#{@repo} && git log --format=%ct #{path} `.split(\"\\n\").map{|time| time.to_i}\n ins_del = ` cd /tmp/#{@repo} && git log --numstat --format=%h #{path} | grep #{path} `.split(\"\\n\").map{|line| line.split(\" \")[0..1]}.map{|insert| insert.map{|x| x.to_i}}\n time.zip(ins_del)\n end",
"def list_checkout_keys\n CircleCi.request(conf, \"#{base_path}/checkout-key\").get\n end",
"def changed?(key)\n changed.has_key?(key)\n end",
"def changed?(key)\n changed.has_key?(key)\n end",
"def change_key\n return @change_key\n end",
"def index\n @credential_keys = CredentialKey.all\n end",
"def set_credential_key\n @credential_key = CredentialKey.find(params[:id])\n end",
"def data_criteria(id)\n find(all_data_criteria, :id, id)\n end",
"def changeset\n @changeset ||= Changeset.new @repo, change_id\n end",
"def replay_edits\n document_edits.order(:id).each(&:execute_change)\n end",
"def cache_scope(point_key, *c_scope)\n c_scope.flatten!\n c_scope.uniq!\n c_scope.sort!{ |a, b| a.to_s <=> b.to_s }\n @_point_keys[point_key] = c_scope\n end"
] | [
"0.7414475",
"0.7414475",
"0.6316527",
"0.6316527",
"0.5576506",
"0.53682905",
"0.5332031",
"0.5199947",
"0.5138429",
"0.5011507",
"0.49512532",
"0.49512532",
"0.49301142",
"0.48456606",
"0.48201632",
"0.48169738",
"0.47939104",
"0.47882327",
"0.47566804",
"0.47307977",
"0.46919438",
"0.467705",
"0.46746615",
"0.461617",
"0.4612886",
"0.45898715",
"0.45898715",
"0.4584039",
"0.4571714",
"0.4571714",
"0.45404568",
"0.45362443",
"0.45343283",
"0.45343283",
"0.45286626",
"0.45199555",
"0.45110255",
"0.44839385",
"0.44757345",
"0.44757345",
"0.4443252",
"0.4436471",
"0.44181278",
"0.44075015",
"0.4403653",
"0.4389129",
"0.43857163",
"0.43843013",
"0.43831304",
"0.43818524",
"0.43777195",
"0.436771",
"0.43635964",
"0.43243378",
"0.43235683",
"0.43205136",
"0.43205136",
"0.43205136",
"0.43205136",
"0.43205136",
"0.43185246",
"0.43185246",
"0.43124187",
"0.43110606",
"0.43060574",
"0.43059132",
"0.42878112",
"0.42807385",
"0.42727822",
"0.42672676",
"0.42563483",
"0.4248942",
"0.4247297",
"0.42432368",
"0.42410925",
"0.42370957",
"0.42370957",
"0.42354035",
"0.4234392",
"0.42294553",
"0.42167303",
"0.42144436",
"0.4212418",
"0.42055202",
"0.41935268",
"0.41610476",
"0.4153631",
"0.41372043",
"0.41369188",
"0.41363612",
"0.41298145",
"0.41298145",
"0.4127759",
"0.4126831",
"0.41263282",
"0.41261035",
"0.41185483",
"0.4115302",
"0.41143936"
] | 0.8118308 | 1 |
Finds the most recent edit of a key belonging to a dataset. | def find_edit(dataset, edit_key)
commits = find_commits(dataset, edit_key)
return nil unless commits.any?
DatasetEdit
.where(commit_id: commits.pluck(:id), key: edit_key)
.order(updated_at: :desc)
.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_commits(dataset, edit_key)\n dataset.commits\n .joins(:dataset_edits)\n .where(dataset_edits: { key: edit_key })\n .order(updated_at: :desc)\n end",
"def find_commits(dataset, edit_key)\n dataset.commits\n .joins(:dataset_edits)\n .where(dataset_edits: { key: edit_key })\n .order(updated_at: :desc)\n end",
"def last_id\n # hashs are ordered, so just return the latest entry\n @entries.keys.last\n end",
"def stored_data_last_key\n stored_data.keys.sort.last || nil\n end",
"def find(key)\n if !contains?(key)\n return nil\n end\n\n @semaphore.synchronize {\n @internal_clock += 1\n previous_data = @key_data[key]\n update_access_time_locked(key, @internal_clock, previous_data.access_time)\n\n return previous_data.value\n }\n end",
"def last_edited_time\n begin\n $redis.hget 'last_edit:instrument', self.id\n rescue\n nil\n end\n end",
"def find_by_key(key)\n find_by_id(key) # backlog method looks exactly the same except for the parameter type\n end",
"def last_keystroke\n # Looks if we are still in the middle of our last keystroke, and returns it if necessary.\n @keystrokes.reverse_each do |keystroke|\n if(keystroke[:time_released] == nil)\n return keystroke\n end\n end\n # If all the logged keystrokes were released, return the last one in the array.\n @keystrokes.last\n end",
"def current_key(keyspace)\n keyspace.key(last_modified_time)\n end",
"def find_by_key(key)\n by_key[key]\n end",
"def find_by_key(key)\n by_key[key]\n end",
"def last\n model[key.call(\"LINDEX\", -1)]\n end",
"def get(key)\n idx, bucket = find_bucket_and_index(key)\n idx ? bucket[idx].last : -1\n end",
"def get_latest_for(changeable)\n my_id = changeable.id\n self.send(\"find_by_#{self.changeable_fk}\", my_id, {:order => 'updated_at DESC', :limit => 1})\n end",
"def [] key\n if @table[hash_index(key)]\n detected_item = @table[hash_index(key)].detect do |item|\n item.first == key\n end\n detected_item.last\n end\n end",
"def last_commit\n self.lookup self.head.target\n end",
"def first_key\n @cursor_instance.jump( nil )\n return current_key\n end",
"def get_key record\n record\n end",
"def last\n _id, entry = @redis.xrevrange(key, '+', '-', count: 1).first\n entry\n end",
"def find_by_key(key)\n find_by('key', key)\n end",
"def last_ent\n ed.SelectLast.Value[0].ObjectId\n end",
"def last_id(key, id = nil)\n ids = $configure[:twitter][:last_ids] || {}\n current_id = ids[key]\n # Save last id if id is passed\n ids[key] = id if id\n $configure[:twitter][:last_ids] = ids;\n current_id\nend",
"def edited_at\n updated_at if @data['edited']\n end",
"def last_edited\n self.latest_update.to_date\n end",
"def get(key)\n get_all(key).first\n end",
"def most_recently_found_word\n i = index_of_most_recently_found_word\n @word_index.key(i)\n end",
"def last_modified_date()\n\t\tmax_update = @database.execute(\"SELECT MAX(updated) as maxmodified FROM invoices;\")\n\t\tif (DBCHOICE == 'sqlite3') then\n\t\t\treturn max_update[0][0]\n\t\telsif (DBCHOICE == 'mysqltest' || DBCHOICE == 'mysql') then\n\t\t\t# structure is hash of hashes, look for the maxmodified key in 1st record and return\n\t\t\tmax_update.each do |row|\n\t\t\t\treturn row['maxmodified']\n\t\t\tend # max_update.each\n\t\tend\n\tend",
"def last_edited\n\t\tself.latest_update.to_date\n\tend",
"def get_latest(rule_key)\n unless @timestamps.key?(rule_key)\n @timestamps[rule_key] = {\n 'latest_run' => nil,\n 'is_running' => false\n }\n end\n @timestamps.fetch(rule_key).fetch('latest_run')\n end",
"def fetch(key); end",
"def getLastUpdate(group_id)\n database = SQLite3::Database.new( @database )\n group = $gm.get(\"/groups/#{group_id}\", @token)['response']\n\n return group['updated_at']\n end",
"def last_read\n id = self.id\n book = Book.where(\"author_id = ?\", id).order(\"read_date desc\").first\n if book\n book.read_date\n end\n end",
"def _refresh_get(dataset)\n if (sql = model.fast_pk_lookup_sql) && !dataset.opts[:lock]\n sql = sql.dup\n ds = use_server(dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_first(sql)\n else\n dataset.first\n end\n end",
"def _refresh_get(dataset)\n if (sql = model.fast_pk_lookup_sql) && !dataset.opts[:lock]\n sql = sql.dup\n ds = use_server(dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_first(sql)\n else\n dataset.first\n end\n end",
"def latest_key\n key = Habit.get_progress_key_from(Date.today)\n initialize_progress_hash_from(key) if progress[key].nil?\n key\n end",
"def last_line_modified_date()\n\t\tmax_update = @database.execute(\"SELECT MAX(updated) as maxmodified FROM invoice_lines;\")\n\t\tif (DBCHOICE == 'sqlite3') then\n\t\t\treturn max_update[0][0]\n\t\telsif (DBCHOICE == 'mysqltest' || DBCHOICE == 'mysql') then\n\t\t\t# structure is hash of hashes, look for the maxmodified key in 1st record and return\n\t\t\tmax_update.each do |row|\n\t\t\t\treturn row['maxmodified']\n\t\tend # max_update.each\n\tend\nend",
"def key\n self.keys.first\n end",
"def [](key)\n @data ||= @dbman.restore\n @data[key]\n end",
"def get_operation_by_key(key)\n r = @operations.select{|o| o[:key]==key}\n if r != nil\n return r.first if r.size>0\n end\n return nil\n end",
"def get_key(record)\n get(self.by, record)\n end",
"def get key\n entry = @keydict[key]\n\n if entry\n if entry[0] == @data_file.path\n pos = @data_file.pos\n @data_file.pos = entry[2]\n value = @data_file.read entry[1]\n @data_file.pos = pos\n value\n else\n data_file = @old_data_files[entry[0]]\n unless data_file\n data_file = File.open(entry[0], \"rb\")\n @old_data_files[entry[0]] = data_file\n end\n\n data_file.pos = entry[2]\n data_file.read entry[1]\n end\n end\n end",
"def key\n @keys.last or raise \"No key specified for collectible! (#{__FILE__}, #{__LINE__})\"\n end",
"def find_last_updated_mir\n @team.meeting_individual_results.exists? ? @team.meeting_individual_results.sort_by_updated_at('DESC').first.updated_at : 0\n end",
"def snapshot\n if snapshot_key\n snapshots.find_by(key: snapshot_key)\n else\n snapshots.order('created_at DESC').limit(1).first\n end\n end",
"def get(key)\n node = @table[key]\n return -1 if node.nil?\n\n make_most_recent_used(node)\n node.value\n end",
"def latest_doc\n self.documents.find_with_deleted(:first, :order => 'id DESC')\n end",
"def destroy_edits(dataset, edit_key)\n commits = find_commits(dataset, edit_key)\n\n return if commits.none?\n\n commits.each do |commit|\n if commit.dataset_edits.one?\n commit.destroy\n else\n commit.dataset_edits.find_by_key(edit_key).destroy\n end\n end\n end",
"def destroy_edits(dataset, edit_key)\n commits = find_commits(dataset, edit_key)\n\n return if commits.none?\n\n commits.each do |commit|\n if commit.dataset_edits.one?\n commit.destroy\n else\n commit.dataset_edits.find_by_key(edit_key).destroy\n end\n end\n end",
"def get_key(data)\n\t\t keys = data.keys\n\t\t if keys.length != 1 || INDICES.none? { |key| key.to_sym == keys.first.to_sym }\n\t\t raise ArgumentError.new(\"`find_by` accepts only one of #{INDICES.join(\" or \")} as argument. none provided\")\n\t\t end\n\t\t keys.first\n\t\t end",
"def get_key(id)\n @keys[id]\n end",
"def search(key)\n return binary(0, @keys.size-1, key)\n end",
"def find _key\n _object = store.transaction(:read_only) { |s| s[prepare_key(_key)] }\n _object.send(:after_load) if _object\n _object\n end",
"def key\n refresh_key unless key_valid?\n @key\n end",
"def [] key\n @internal_hash[key].last\n end",
"def get_key(data)\n keys = data.keys\n if keys.length != 1 || INDICES.none? { |key| key.to_sym == keys.first.to_sym }\n raise ArgumentError, \"`find_by` accepts only one of #{INDICES.join(' or ')} as argument. none provided\"\n end\n\n keys.first\n end",
"def get_key(data)\n keys = data.keys\n if keys.length != 1 || INDICES.none? { |key| key.to_sym == keys.first.to_sym }\n raise ArgumentError, \"`find_by` accepts only one of #{INDICES.join(' or ')} as argument. None provided\"\n end\n\n keys.first\n end",
"def last_activity\n relevant_data = player_data_points_dataset.\n where(relevant: true).\n order(Sequel.desc(:created_at)).\n first\n\n if relevant_data\n relevant_data.created_at\n else\n nil\n end\n end",
"def choose_last_command\n real_last = Readline::HISTORY.to_a[-2]\n real_last == 'rt' ? @@saved_last : (@@saved_last = real_last)\nend",
"def choose_last_command\n real_last = Readline::HISTORY.to_a[-2]\n real_last == 'rt' ? @@saved_last : (@@saved_last = real_last)\nend",
"def get_last_check\n\n resp = client.execute(\n :api_method => datastore.datasets.lookup,\n :parameters => {:datasetId => dataset_id},\n :body_object => {\n # Set the transaction, so we get a consistent snapshot of the\n # value at the time the transaction started.\n # :readOptions => {:transaction => tx},\n # Add one entity key to the lookup request, with only one\n # :path element (i.e. no parent)\n :keys => [lckey]\n })\n if !resp.data.found.empty?\n # Get the entity from the response if found.\n entity = resp.data.found[0].entity\n puts \"Found last_check entity: #{entity.inspect}\"\n # Get `question` property value.\n last_check = entity.properties.last_check.dateTimeValue.to_datetime\n else\n last_check = Date.today.prev_day.to_datetime # \"2015-01-01T00:00:01z\"\n end\n puts \"last_check: #{last_check.inspect} class=#{last_check.class.name}\"\n return last_check\n end",
"def lookup(key)\n key = key.to_i if key.to_i.to_s == key.to_s # casting for things like \"10\"\n case key\n when Fixnum, Bignum, Integer\n changelog.node_id_for_index(key)\n when \".\"\n dirstate.parents().first\n when \"null\", nil\n NULL_ID\n when \"tip\"\n changelog.tip\n else\n \n n = changelog.id_match(key)\n return n if n\n \n return tags[key] if tags[key]\n return branch_tags[key] if branch_tags[key]\n \n n = changelog.partial_id_match(key)\n return n if n\n \n # bail\n raise RepoError.new(\"unknown revision #{key}\")\n end\n end",
"def getLatest()\r\n return EeKonto.get(self.KtoNr)\r\n end",
"def read_key; end",
"def latest_commit current_project = last_changed_craft, saves = save_history, new_and_changed = new_and_changed \n crft = \"Ships/#{current_project.craft_type.upcase}/#{current_project.name}.craft\" if current_project\n \n return :current_project if saves[:quicksave].nil? || saves[:quicksave].size.eql?(1)\n if new_and_changed[:changed].include?(crft) || new_and_changed[:new].include?(crft)\n return :current_project\n else \n qs_commit = saves[:quicksave].first if saves[:quicksave] \n if qs_commit && current_project\n craft_commit = current_project.history(:limit => 1).first\n t= [[:quicksave, qs_commit], [:current_project, craft_commit]].sort_by{|_, c| c.try(:date) || Time.now}.last\n return t[0]\n else\n return :current_project\n end\n end\n end",
"def find(key)\n raise UnknownEntity unless key?(key)\n\n collection[ukey(key)]\n end",
"def get_last_entry\n @entry = FeedEntry.find(:first, :conditions => {:person_id => self.id})\n end",
"def find_key(key)\n leaf, stack = walk_towards_key(key)\n return nil if leaf && leaf.peek_item.key != key\n leaf\n end",
"def find_last_updated_mir\n @max_updated_at = @swimmer.meeting_individual_results.exists? ? @swimmer.meeting_individual_results.sort_by_updated_at('DESC').first.updated_at : 0\n end",
"def last_revision\n self.revision_model.find(:first, :conditions => { klass + '_id' => self.id }, :order => \"number DESC\")\n end",
"def first_savefile_index\r\n DataManager.latest_savefile_index\r\n end",
"def fetch(key)\n trace_store.fetch(key)\n end",
"def find(key)\n items.find do |item|\n item.key == key\n end\n end",
"def [](key)\r\n assert_exists\r\n arr_rows = rows\r\n return arr_rows[key - 1]\r\n end",
"def last_change_of(attribute)\n index = audits.count\n audits.reverse_each do |audit|\n index -= 1\n if audit.modifications[attribute].present?\n prev_audit = audits[index-1] if index > 0\n return audit.diff(prev_audit)[attribute]\n end\n end\n nil\n end",
"def dataset_key\n :id\n end",
"def key\n self.id\n end",
"def key\n self.id\n end",
"def key\n self.id\n end",
"def find key_or_kind, id_or_name = nil\n key = key_or_kind\n unless key.is_a? Google::Cloud::Datastore::Key\n key = Key.new key_or_kind, id_or_name\n end\n find_all(key).first\n end",
"def change_key\n return @change_key\n end",
"def last\n asc(:id).last\n end",
"def get_max_key()\n \n end",
"def change_key\n return @change_key\n end",
"def key\n @entity.key\n end",
"def key\n id\n end",
"def find(index_key)\n index[index_key]\n end",
"def id\n key = self.key\n key.first if key.size == 1\n end",
"def last_revision\n self.class.last_revision(id)\n end",
"def get_rev_range(key, most_recent, last_modified)\n log(\"get :Deltas, #{key}, :reversed => true, :start => #{timestamp_name(most_recent)}, :finish => #{timestamp_name(last_modified)}\")\n connection.get(:Deltas, key, :reversed => true, :start => timestamp_name(most_recent), :finish => timestamp_name(last_modified), :count => MAX_DELTAS).values\n end",
"def find_entry(key)\n key_hash = key.hash\n\n entry = @entries[key_index(key_hash)]\n while entry\n if entry.match? key, key_hash\n return entry\n end\n entry = entry.next\n end\n end",
"def last_seen_at\n @data[:last_seen_at]\n end",
"def ideas_cache_key\n count = ideas.published.count\n max_updated_at = ideas.maximum(:updated_at).try(:utc).try(:to_s, :number)\n \"school_ideas/all-#{count}-#{max_updated_at}\"\n end",
"def last_changed_at\n @last_changed_at ||= @changes.map { |c| c[:changed_at] }.max\n end",
"def getKey; argSetTextual.to_sym end",
"def last_value_set(xs)\n xs.sort_by {|y| [y[:updated_at], y[:id]] }.last[:new_value]\n end",
"def most_recent\n self.stats.first\n end",
"def key\n @key\n end",
"def key\n @key\n end",
"def read_entry(key, options)\n query = Google::Cloud::Datastore::Key.new @datastore_kind_name, key\n entities = dataset.lookup query\n return nil unless entities.any?\n entity = entities.first\n entry = deserialize_entry( entity[:_value], entity[:_format] )\n return entry\n end"
] | [
"0.7036318",
"0.7036318",
"0.5754164",
"0.56819737",
"0.5619952",
"0.56044763",
"0.55192584",
"0.5518867",
"0.54308164",
"0.5340288",
"0.5340288",
"0.5337979",
"0.533101",
"0.53158754",
"0.5237369",
"0.5227485",
"0.5189971",
"0.5189153",
"0.5186359",
"0.516649",
"0.5147567",
"0.5128587",
"0.5080932",
"0.5077977",
"0.5072172",
"0.50676197",
"0.5066162",
"0.50643504",
"0.5063073",
"0.5053091",
"0.50355905",
"0.5032176",
"0.5031676",
"0.5031676",
"0.5025734",
"0.50227505",
"0.50119096",
"0.49995917",
"0.49962544",
"0.49887002",
"0.4980371",
"0.49792528",
"0.49668577",
"0.49641067",
"0.49615037",
"0.49599418",
"0.49520385",
"0.49520385",
"0.49404672",
"0.49297267",
"0.49271476",
"0.49197945",
"0.4916545",
"0.49122542",
"0.49026442",
"0.48973227",
"0.48963514",
"0.48959276",
"0.48959276",
"0.4891782",
"0.48898095",
"0.48863146",
"0.48841137",
"0.4883372",
"0.4882519",
"0.4879513",
"0.48784292",
"0.48722273",
"0.48653123",
"0.4860915",
"0.48594582",
"0.48593694",
"0.4852719",
"0.48479632",
"0.48475823",
"0.48436746",
"0.48436746",
"0.48436746",
"0.48396143",
"0.48381305",
"0.48348773",
"0.48331094",
"0.48318738",
"0.48235762",
"0.48234504",
"0.48196843",
"0.48158115",
"0.48097587",
"0.4803388",
"0.4802332",
"0.4799516",
"0.47991174",
"0.47982812",
"0.47971627",
"0.47960177",
"0.47940072",
"0.47898006",
"0.47898006",
"0.4788918"
] | 0.8002472 | 1 |
Removes all dataset edits matching the `edit_key`. If the key is the only dataset belonging to the commit, the commit will also be removed. | def destroy_edits(dataset, edit_key)
commits = find_commits(dataset, edit_key)
return if commits.none?
commits.each do |commit|
if commit.dataset_edits.one?
commit.destroy
else
commit.dataset_edits.find_by_key(edit_key).destroy
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear(opts = {}) \n save(setup_commit_options({:message => \"all clear\"}.merge(opts))) do |index|\n if tree = index.current_tree\n tree.contents.each do |entry|\n index.delete(key_for(entry.name))\n end\n end\n end\n end",
"def clear(opts = {}) \n save(setup_commit_options({:message => \"all clear\"}.merge(opts))) do |index|\n if tree = index.current_tree\n tree.contents.each do |entry|\n index.delete(key_for(entry.name))\n end\n end\n end\n end",
"def unset(key)\n update(key) { |option| @data.delete(option.name) }\n end",
"def delete(key, opts = {})\n options = setup_commit_options({:message => \"deleted #{key}\"}.merge(opts))\n self[key].tap do\n save(options) {|index| index.delete(key_for(key)) }\n end\n end",
"def delete(key, opts = {})\n options = setup_commit_options({:message => \"deleted #{key}\"}.merge(opts))\n self[key].tap do\n save(options) {|index| index.delete(key_for(key)) }\n end\n end",
"def clear_by_key(key)\n delete(key)\n end",
"def delete(key)\n responsible_clients(key).each do |v|\n with_retries { v.logical.delete(wrap_key(key)) }\n end\n end",
"def delete(key)\n @data.delete(key).tap {\n save if autosave?\n }\n end",
"def delete_data(key)\n @data.delete(key)\n end",
"def delete _key\n store.transaction() { |s| s.delete(prepare_key(_key)) }\n end",
"def find_commits(dataset, edit_key)\n dataset.commits\n .joins(:dataset_edits)\n .where(dataset_edits: { key: edit_key })\n .order(updated_at: :desc)\n end",
"def find_commits(dataset, edit_key)\n dataset.commits\n .joins(:dataset_edits)\n .where(dataset_edits: { key: edit_key })\n .order(updated_at: :desc)\n end",
"def find_edit(dataset, edit_key)\n commits = find_commits(dataset, edit_key)\n\n return nil unless commits.any?\n\n DatasetEdit\n .where(commit_id: commits.pluck(:id), key: edit_key)\n .order(updated_at: :desc)\n .first\n end",
"def find_edit(dataset, edit_key)\n commits = find_commits(dataset, edit_key)\n\n return nil unless commits.any?\n\n DatasetEdit\n .where(commit_id: commits.pluck(:id), key: edit_key)\n .order(updated_at: :desc)\n .first\n end",
"def del(keys)\n keys.each { |key| _data.delete(key) }\n _save\n end",
"def delete(key)\n transaction do |y|\n y.delete(key)\n end\n end",
"def remove(key)\n @store.delete_if { |i| i[:key] == build_key(key) }\n end",
"def unset_cmd\n sprintf 'sed -i /%s/d %s', key_set_string, @file\n end",
"def shell_registry_deletekey(key, view)\n key = normalize_key(key)\n # REG DELETE KeyName [/v ValueName | /ve | /va] [/f]\n shell_registry_cmd_result(\"delete \\\"#{key}\\\" /f\", view)\n end",
"def erase(key)\n if !contains?(key)\n return\n end\n\n erase_internal(key)\n end",
"def abort_current_edit\n ensure_active_edit!\n\n result = api_client.execute(\n api_method: android_publisher.edits.delete,\n parameters: {\n 'editId' => current_edit.data.id,\n 'packageName' => current_package_name\n },\n authorization: auth_client\n )\n\n raise result.error_message.red if result.error?\n\n self.current_edit = nil\n self.current_package_name = nil\n end",
"def delete(key)\n data.delete(key)\n @deleted_hash[key] = nil\n end",
"def delete_entry(key, options)\n dataset.delete Google::Cloud::Datastore::Key.new @datastore_kind_name, key\n end",
"def delete *entities_or_keys\n @commit.delete(*entities_or_keys)\n # Do not delete yet\n true\n end",
"def delete_key(key)\n end",
"def clear!(key = nil)\n key.nil? ? @data.clear : @data.delete(key)\n end",
"def del(key)\n @first.del(key)\n end",
"def delete_entry(key, **options)\n rescue_error_with(false) { @data.with { |c| c.delete(key) } }\n end",
"def delete(key = nil)\n key ? self.data.delete(key) : self.data.clear\n end",
"def delete(key = nil)\n key ? self.data.delete(key) : self.data.clear\n end",
"def delete_all\n store.delete(KEY)\n self\n end",
"def delete_all\n self.store.delete_keys(find_keys)\n end",
"def delete(key)\n return if @no_update == true\n @store.transaction do\n @store.delete(key)\n end\n end",
"def reload\n self.edits.clear\n end",
"def delete! key = nil\n if key.nil?\n @schema.delete!\n @values.clear\n else\n key = ::Kernel.String(key).to_sym\n @schema.delete! key\n @values.delete key\n end\n self\n end",
"def del(key)\n response = db.delete_item(@table_name, {'HashKeyElement' => {'S' => key}})\n true\n end",
"def xdel(key, *ids); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key)\n pop if change_key(key, nil, true)\n end",
"def remove_key(key_id, key_content)\n system(\"#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \\\"#{key_content}\\\"\")\n end",
"def delete_key(key)\n @keys.delete(key)\n @passwords.each_key { |id| set_password(id, get_password(id)) }\n @otp_keys.each_key { |id| set_otp_key(id, get_otp_key(id)) }\n end",
"def delete key\n\t\tdata = @data_base.delete key\n\t\tupdate_database\n\t\tdata\n\tend",
"def delete key\n @internal_hash[key].clear\n end",
"def delete(key)\n @data.delete(key)\n @key_size.delete(key)\n end",
"def abort_current_edit\n ensure_active_edit!\n\n call_google_api { android_publisher.delete_edit(current_package_name, current_edit.id) }\n\n self.current_edit = nil\n self.current_package_name = nil\n end",
"def delete_by_key(key)\n HttpClient::Preconditions.assert_class('key', key, String)\n @client.request(\"/organizations/#{CGI.escape(key)}\").delete\n nil\n end",
"def delete! key = nil\n if key.nil?\n @defaults.clear\n @validators.clear\n else\n @defaults.delete key\n @validators.delete key\n end\n self\n end",
"def delete(key)\n @store.delete(key)\n end",
"def delete_entry(key, **options); end",
"def clear!(key = nil)\n key = key.to_sym unless key.nil?\n @store.clear! key\n end",
"def clear(key)\n\n mon_synchronize do\n perform([\"hclear\", key], :proc => T_INT) +\n perform([\"zclear\", key], :proc => T_INT) +\n perform([\"qclear\", key], :proc => T_INT) +\n perform([\"del\", key], :proc => T_INT)\n end\n end",
"def delete_all_rows\n scan.each do |row|\n delete_row(row['key'])\n end\n end",
"def delete(key)\n\t\t\t\t[self, self, false]\n\t\t\tend",
"def delete key\n write_data_entry key, nil, true\n @keydict[key] = nil\n\n sync\n end",
"def delete(key)\n @store.delete(key)\n end",
"def rm(key)\n options.values.collect do |option| \n if option.key == key \n unregister(option)\n else\n nil\n end\n end.compact\n end",
"def remove(key); end",
"def xdel(key, *ids)\n args = [:xdel, key].concat(ids.flatten)\n send_command(args)\n end",
"def delete(key)\n\n end",
"def delete(key)\n key = to_key key\n @group.delete key if @group.key? key\n end",
"def delete(key)\n removeAttribute(key.to_s)\n end",
"def delete(key)\n removeAttribute(key.to_s)\n end",
"def delete(key)\n removeAttribute(key.to_s)\n end",
"def del\n connection.del(key_label)\n end",
"def remove(key)\n with_client do |client|\n client.del(build_key(key))\n end\n end",
"def delete(key)\n db.delete(key)\n end",
"def del\n redis do |conn|\n conn.multi do |pipeline|\n pipeline.zrem(DIGESTS, key.digest)\n pipeline.del(key.digest, key.queued, key.primed, key.locked, key.info)\n end\n end\n end",
"def delete(key)\n @hash.delete key\n @key_hash.delete key\n end",
"def create_edit(commit, key, value)\n ActiveRecord::Base.transaction do\n DatasetEdit.create!(\n commit_id: commit.id,\n key: key,\n value: value\n )\n end\n end",
"def create_edit(commit, key, value)\n ActiveRecord::Base.transaction do\n DatasetEdit.create!(\n commit_id: commit.id,\n key: key,\n value: value\n )\n end\n end",
"def clear_prior_rows(key: nil, existing_entries: nil)\n # TODO: store a reference to those, and delete only after the new ones were imported successfully\n # And support multiple per run\n raise \"No data provided\" if key.nil? && existing_entries.nil?\n existing_entries ||= raw_data.where(key: key)\n\n if existing_entries.count > 0\n puts \"Using database #{ENV['DATABASE_URL'][0...30]}...\"\n puts \"Already #{existing_entries.count} entries for #{key}, are you sure you want to replace all of those entries? (y/n)\"\n raise \"user cancelled\" unless gets.strip == 'y'\n existing_entries.delete\n puts \"Deleted...\"\n end\n end",
"def del(key)\n position = find(key)\n if position != nil\n # delete\n value = @values[position]\n @slots[position] = nil\n @values[position] = nil\n value\n else\n nil\n end\n end",
"def delete(key)\n perform_delete(:delete, key)\n end",
"def delete( key )\n context.delete(key.to_s)\n end",
"def clear\n synchronize_block do\n @data.clear\n @key_access_store.clear\n end\n end",
"def delete(collection, key)\n @data[collection].delete(key)\n end",
"def clear_changes!\n @changes.clear\n end",
"def filter_data(data)\n data[\"items\"].each do |repo|\n UNUSED_KEYS.each { |unused_key| repo.delete(unused_key) }\n end\n end",
"def clear_all(key)\n _mutex.synchronize do\n _store[key] = {}\n end\n end",
"def delete(key)\n doozer_pool.with_connection do |doozer|\n doozer.delete(full_key(key))\n end\n end",
"def delete_entry(key, **options)\n failsafe(:delete_entry, returning: false) do\n with { |c| c.del key }\n end\n end",
"def delete_entry(key, **_options)\n failsafe(:delete_entry, returning: false) do\n res = collection.remove(key)\n @last_mutation_token = res.mutation_token\n true\n end\n end",
"def delete_item(table_name, key, options = {})\n range_key = options.delete(:range_key)\n data[table_name][:data].delete(\"#{key}.#{range_key}\")\n end",
"def delete_data key\n init_data\n\n Bot::DB[my_name].delete key\n end",
"def delete_data key\n init_data\n\n Bot::DB[my_name].delete key\n end",
"def delete(key)\n @mutex.synchronize do\n x = anchor\n level = node_level(x)\n update = Array.new(level)\n x = find_with_update(x, level, key, update)\n \n # remove existing key\n \t if node_compare(x, key) == 0\n \t level = node_level(x)\n \t while level > 0\n \t level -= 1\n \t node_delete_after!(x, update[level], level)\n end\n \t end\n end\n \tself\n \tend",
"def delete(key)\n attribute = key.to_sym\n details.delete(attribute)\n messages.delete(attribute)\n end",
"def delete(key)\n in_transaction_wr\n @table.delete key\n end",
"def delete_all\n Nvmkv.kv_delete_all(@kv_id)\n end",
"def delete(key)\n key = alternate_key(key) unless has_key?(key)\n super\n end",
"def delete(key)\n id = @cache[key]\n @cache.delete(key)\n @index.delete(id) if id\n end",
"def del(key)\n @meta.delete(key.to_sym) if key\n end",
"def remove(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n @a[row].delete_at(column)\n end\n end",
"def clear_changes\n versioned_columns.each do |key|\n changed_attributes.delete(key)\n end\n end",
"def delete_entry(key, options) # :nodoc:\n @data.where(key: key).delete\n rescue Sequel::Error => e\n logger.error(\"Sequel::Error (#{e}): #{e.message}\") if logger\n false\n end"
] | [
"0.56993616",
"0.56993616",
"0.55326927",
"0.5507723",
"0.5507723",
"0.54427415",
"0.5336602",
"0.5282212",
"0.52799416",
"0.5257944",
"0.52420187",
"0.52420187",
"0.52420086",
"0.52420086",
"0.52356845",
"0.5219676",
"0.5217735",
"0.52150834",
"0.5194139",
"0.5193831",
"0.51342446",
"0.51269615",
"0.51033497",
"0.50939536",
"0.5075678",
"0.5061508",
"0.506126",
"0.50578684",
"0.5039998",
"0.5039998",
"0.50348216",
"0.5007296",
"0.50031734",
"0.4981401",
"0.4974838",
"0.4973997",
"0.49543655",
"0.49495864",
"0.49495864",
"0.49495864",
"0.49495864",
"0.49495864",
"0.494022",
"0.49279568",
"0.49250948",
"0.49228138",
"0.49075663",
"0.49068472",
"0.48967767",
"0.48917562",
"0.4884141",
"0.4878337",
"0.4871507",
"0.48653078",
"0.48634726",
"0.48015577",
"0.4790937",
"0.4789555",
"0.4783814",
"0.4781804",
"0.47764274",
"0.47677422",
"0.47534442",
"0.47469485",
"0.47403142",
"0.47403142",
"0.47403142",
"0.47280896",
"0.47203624",
"0.47130674",
"0.47100282",
"0.47068822",
"0.47055647",
"0.47055647",
"0.4705397",
"0.46971643",
"0.469708",
"0.46946913",
"0.46887228",
"0.4688226",
"0.46847925",
"0.46823972",
"0.46805114",
"0.46737507",
"0.46652034",
"0.4663285",
"0.4650788",
"0.46486887",
"0.46486887",
"0.46374008",
"0.46350008",
"0.4634465",
"0.46311727",
"0.46248665",
"0.46173972",
"0.46144798",
"0.46132255",
"0.46109137",
"0.4606174"
] | 0.82388973 | 1 |
Cart content management Used to implement ProductsList interface each method | def quantified_items
products.map { |product| [product.variant, product.quantity] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def products\n end",
"def view_cart\n @products\n end",
"def show_cart_detail\n @products = Product.find(session[:cart])\n end",
"def index\n set_cart\n get_products_array\n end",
"def cart\n # Calculate price\n # Warn: Need to update cart price every time items changed in cart for the safe side\n update_total_price_and_quantity_in_cart\n @cart = get_current_cart\n \n # prepare coupons\n @available_coupons = get_available_coupons(@cart) \n end",
"def index\n @cart_products = current_customer.cart_products\n end",
"def index\n\t\t@products = Product.all\n\t\t@cart_line_item = CartLineItem.new\n\tend",
"def index\n \n @cart = setup_cart\n \n if params[:package_id]\n @cart.add_package(params[:package_id])\n @package = Package.find(params[:package_id])\n elsif @cart.package_id\n @package = Package.find(@cart.package_id)\n else\n @package = Package.find_by_name(\"Simon XT Pro Plus Package\")\n end\n \n @cart_has_combo_item = @cart.combo_item?\n \n @blog = Blog.last\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end",
"def index\n @parent = parent\n @products = collection\n @line_items = LineItem.all(session[:cart])\n @cart = find_cart\n end",
"def products_list\n\t\t@view.products_list\n\t\tproducts = @store.products\n\t\tproducts.each do |product|\n\t\t\tputs \"Name: #{product.name} ---> Price: #{product.price}\"\n\t\tend\n\t\t@view.second_view(@current_user, @current_user.actions)\n\tend",
"def show\n\t\t@cart = current_cart\n\t\t\n\t\t# para mostrar a listagem de produtos na barra lateral (partial)\n\t\t@products = Product.all\n\tend",
"def index\n @cart_products = CartProduct.all\n end",
"def show\n @items = cart.items\n @products = @items.collect(&:product)\n \n respond_to do |format|\n format.html { render layout: false } \n format.json { render json: @items }\n end\n end",
"def index\n @cart_items = current_customer.cart_items\n @cart_item = CartItem.new\n end",
"def index\n # this method will pass the content of the cart to the page view\n \n if session[:cart] then\n @cart = session[:cart] # if session exists the pass cart contents to the cart view\n else \n @cart = {} # if the cart isnt a session the say the cart contents is empty\n \n end \n \n end",
"def index\n # this method will pass the content of the cart to the page view\n \n if session[:cart] then\n @cart = session[:cart] # if session exists the pass cart contents to the cart view\n else \n @cart = {} # if the cart isnt a session the say the cart contents is empty\n \n end \n \n end",
"def show\n @product = Product.find(params[:id])\n @title=@product.title\n @linked=@product.linked\n @cart_item = @current_cart.cart_items.new(product_id: @product.id, quantity:1)\n end",
"def index\n\n \t#Redirect if we have a locale set\n \tif params[:set_locale]\n \t\tredirect_to store_path(locale: params[:set_locale])\n\telse\n \n \t#Get all products and order by title\n \t@products = Product.order(:title)\n \t@cart = current_cart\n end\n \n end",
"def items\n \tbegin\n \t\t@categories = Category.all.includes(items: [:dimensions])\n\t \tif user_signed_in?\n\t \t\t@cart = Cart.find_by(user_id: current_user.id, purchased: false)\n\t \t\telse\n\t \t\t@cart = Cart.find_by(session_id: session[:session_id], purchased: false)\n\t \tend\n\t \trender :items, status: :ok\n \trescue Exception => e\n \t\terror_handling_bad_request(e)\n \tend\n\n\tend",
"def index\n @cart = get_cart()\n end",
"def index\n # This method will pass the content of the cart to the page view\n \n if session[:cart] then\n @cart = session[:cart] # if session exists then pass cart contents to the cart view\n else\n @cart = {} # if the cart isnt a session then say the cart contents is empty\n \n end\n \n end",
"def index\n if params[:set_locale]\n redirect_to store_url(locale: params[:set_locale])\n else\n @products = Product.order(:title)\n @time = Time.now.strftime(\"%H:%M\")\n cart = :current_cart\n end\n end",
"def show\n @cart = current_user.cart\n @all_items = @cart.items\n end",
"def create_cart\n\tend",
"def show_the_cart\n @cart_items = Nacho.find(cart)\n end",
"def index\n @cart_items = CartItem.all\n end",
"def index\n @cart_items = CartItem.all\n end",
"def index\n @cart_items = CartItem.all\n end",
"def index\n @cart_items = CartItem.all\n end",
"def index\n @cart_items = CartItem.all\n end",
"def index\n @categories = Category.all\n @cart_item = current_cart.cart_items.new\n end",
"def Order_all\n\t\t@all_products = Cart.where(:user_id => current_user.id) \n\tend",
"def show\n @cart = @product.carts.new\n end",
"def make_item_list\n @data = $game_temp.forge_shop.products\n end",
"def products\r\n\t\t@current_area = 'products'\r\n\t\t@current_menu = 'products'\r\n\r\n\t\tsort_order ||= get_sort_order(\"s-code\", \"product_code\")\r\n\t\tsort_order ||= get_sort_order(\"s-name\", \"product_name\")\r\n\t\tsort_order ||= \"product_name ASC\"\r\n\r\n\t\tpage = params[:page] ? params[:page].to_i : 1\r\n\t\titems_per_page = 30\r\n\t\toffset = (page - 1) * items_per_page\r\n\r\n\t\tif params[:query] and !params[:query].empty?\r\n\t\t\t@keywords = params[:query].split\r\n\t\t\t@query = @keywords.join(' ')\r\n\t\t\tmode = params[:mode] || 'all'\r\n\t\t\twhere_parts = @keywords.collect { |k| \"(product_code LIKE '%#{k}%' OR product_name LIKE '%#{k}%' OR description LIKE '%#{k}%' OR id='#{k}')\" }\r\n\t\t\twhere_clause = where_parts.join(mode == 'all' ? ' AND ' : ' OR ')\r\n\t\telse\r\n\t\t\twhere_clause = '1'\r\n\t\tend\r\n\t\t@product_count = Product.count('available=1 AND ' + where_clause)\r\n\r\n\t\t@pages = Paginator.new(self, @product_count, items_per_page, page)\r\n\r\n\t\tif params[:delete] and params[:select]\r\n\t\t\tc = params[:select].keys.collect { |k| \"id=#{k}\" }.join(' OR ')\r\n\t\t\tProduct.update_all 'available=0', c\r\n\t\t\tredirect_to :action => :products\r\n\t\tend\r\n\r\n\t\tif params[:add_to]\r\n\t\t\tif params[:select]\r\n\t\t\t\tc = Category.find(params[:category_id])\r\n\t\t\t\tProduct.find(:all, :conditions => params[:select].keys.collect { |k| \"id=#{k}\" }.join(' OR ')).each do |p|\r\n\t\t\t\t\t# don't crash with a MySQL \"duplicate key\" error if the product already belongs to the selected category\r\n\t\t\t\t\tif !p.categories.index(c)\r\n\t\t\t\t\t\tp.categories << c\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\tredirect_to :action => :new, :category_id => params[:category_id]\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\t@products = Product.find(:all, :conditions => 'available=1 AND ' + where_clause, :order => sort_order, :offset => offset, :limit => items_per_page)\r\n\tend",
"def index\n\t\t@cart_items = current_user.shoppingkarts \n\t\t#Shoppingkart.find(current_user)\n\tend",
"def list_products\n @company = Company.find(params[:company_id])\n @pagetitle = \"#{@company.name} - Products\"\n \n if(@company.can_view(current_user))\n if(params[:restock])\n @products = Product.where([\"company_id = ? AND quantity <= reorder\", @company.id]).paginate(:page => params[:page])\n @view_restock = true\n else\n if(params[:q] and params[:q] != \"\")\n fields = [\"name\", \"code\", \"category\", \"description\", \"comments\"]\n \n q = params[:q].strip\n @q_org = q\n \n query = str_sql_search(q, fields)\n \n @products = Product.where([\"company_id = ? AND (#{query})\", @company.id]).paginate(:page => params[:page]) \n else\n @products = Product.where(company_id: @company.id).paginate(:page => params[:page])\n end\n end\n else\n errPerms()\n end\n end",
"def index\n #IPSocket.getaddress(\"www.sandbox.paypal.com\")\n #@cart_items = CartItem.all\n \n if current_user == nil\n @cart_items = Array.new\n if session[:music_cart] != nil\n visitedArtistId = nil\n session[:music_cart].each do |cart_item_row|\n cart_item_temp = CartItem.new\n cart_item_temp.product_id = cart_item_row[:product_id]\n cart_item_temp.product_name = cart_item_row[:product_name]\n cart_item_temp.product_final_price = cart_item_row[:product_final_price]\n visitedArtistId = cart_item_row[:product_user_id]\n @cart_items.push(cart_item_temp)\n end\n \n if visitedArtistId == nil\n @continueShoppingLink = root_path\n else\n visitedArtist = User.find(visitedArtistId)\n visitedArtistName = visitedArtist.first_name+\" \"+visitedArtist.last_name\n @continueShoppingLink = artist_dashboard_path(id: visitedArtist.id.to_s+':'+visitedArtistName.parameterize) \n end\n \n else\n @continueShoppingLink = root_path\n end\n \n else\n @cart = Cart.where(:user_id => current_user.id).first\n @continueShoppingLink = root_path\n @cart_items = []\n if @cart != nil\n lastItem = nil\n @cart.cart_items.each do |item|\n lastItem = item\n end\n @cart_items = @cart.cart_items\n if lastItem != nil\n lastItemRow = Audio.find(lastItem.product_id)\n visitedArtist = User.find(lastItemRow.user_id)\n visitedArtistName = visitedArtist.first_name+\" \"+visitedArtist.last_name\n @continueShoppingLink = artist_dashboard_path(id: lastItemRow.user_id.to_s+':'+visitedArtistName.parameterize) \n \n end \n end\n end \n \n end",
"def index\n @carts = if params[:customer_id]\n if current_product_manager\n Customer.find(params[:customer_id]).carts\n elsif current_customer\n current_customer.carts\n end\n elsif current_product_manager\n if params[:referral_id]\n Referral.find(params[:referral_id]).carts\n else\n Cart\n end.order('status', 'created_at desc')\n else\n redirect_to(root_url) && return\n end.page(params[:page])\n\n respond_to do |format|\n format.html do\n if current_product_manager\n render\n else\n render :action => 'purchase_history', :layout => 'customer'\n end\n end\n format.json { render json: @carts }\n end\n end",
"def addtocart\n\t\tinsidecart<< createproduct\n\t\taddtocart\n\tend",
"def cart\n Product.find(session[:user_cart])\n end",
"def add\n response.headers['Content-type'] = \"text/plain; charset=utf-8\"\n unless cookies[:cart].nil?\n @cart = Cart.find_by_unique_identifier(cookies[:cart])\n unless @cart.nil?\n @cart.add_product_to_products(params[:catalog_id], params[:product_id])\n if @cart.save\n render :text => {:cart => { 'result' => true, 'cart_unique_id' => @cart.unique_identifier, 'products_count' => @cart.products_count(params[:catalog_id]), 'product_count' => @cart.product_count(params[:catalog_id],params[:product_id])}}.to_json()\n else\n render :text => {'result' => false }.to_json()\n end\n else\n render :text => {'result' => false }.to_json()\n end\n else\n @cart = Cart.new()\n # @cart.catalog_id = params[:catalog_id]\n @cart.unique_identifier = BCrypt::Engine.hash_secret(\"#{@cart.id}\", BCrypt::Engine.generate_salt)\n @cart.add_product_to_products(params[:catalog_id], params[:product_id])\n if @cart.save\n # render :text => {:cart => {'result' => true, 'cart_unique_id' => @cart.unique_identifier }}.to_json()\n render :text => {:cart => { 'result' => true, 'cart_unique_id' => @cart.unique_identifier, 'products_count' => @cart.products_count(params[:catalog_id]), 'product_count' => @cart.product_count(params[:catalog_id],params[:product_id])}}.to_json()\n else\n render :text => {'result' => false }.to_json()\n end\n end\n end",
"def index\n @carts_products = @cart.carts_products.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @carts_products }\n end\n end",
"def create\n # if user is not logged_in\n if cart_product_params[:user_id].empty?\n session[:temp_cart] = cart_product_params\n redirect_to login_path, :notice => \"Please log in, the product will be placed in your cart once you've logged in.\"\n else\n @cart_product = CartProduct.new(cart_product_params)\n respond_to do |format|\n if cart_product_params[:quantity].to_i > 0\n if @cart_product.save\n format.html { redirect_to request.referrer, notice: \"Added to Cart. Please go to your cart to pay for your items!\" }\n format.json { render :show, status: :created, location: @cart_product }\n \n # Then remove from savedlist\n session[:savedlist] ||= []\n session[:savedlist].delete(cart_product_params[:product_id])\n \n # update admin stats\n saved_products_stats(cart_product_params[:product_id], -1)\n \n # Then update popularity of product\n increase_product_popularity_by_product_id(cart_product_params[:product_id])\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @cart_product.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to request.referrer, notice: \"Quantity cannot be 0 or less!.\" }\n end\n end\n end\n end",
"def set_cart\n @cart = current_api_v1_user&.products&.find(params[:id])\n end",
"def show\n @shopping_cart = ShoppingCart.find(params[:id])\n if(@shopping_cart.user == current_user)\n @shopping_cart_hash = eval(@shopping_cart.item_list)\n @shopping_item_list = Array.new\n @total_price = 0\n @shopping_cart_hash.each do |item_id, quantity|\n @item = Item.find(Integer(item_id))\n @shopping_item_list += [{:item => @item, :quantity => quantity, :price => (quantity * @item.price)}]\n @total_price += (quantity * @item.price)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shopping_cart }\n end\n else\n redirect_to root_path\n end\n end",
"def add_to_cart\n session[:item_list] ? session[:item_list] << @product.id : session[:item_list] = [@product.id]\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product added to cart!' }\n format.json { head :no_content }\n end\n end",
"def set_cart\n @cart = Cart.find(params[:id]).decorate\n end",
"def find_cart_items\n\t\tconditions = {:resource_id => get_resource.id.to_s, :parent_id => self.id.to_s}\n\t\tself.cart_items = Auth.configuration.cart_item_class.constantize.where(conditions).order(:created_at => 'asc')\n\t\t\n\t\tself.cart_items\n\tend",
"def catalog; end",
"def view_cart\n render json: products_in_cart(false)\n end",
"def products\n find_products\n end",
"def list_products\n @company = Company.find(params[:company_id])\n @pagetitle = \"#{@company.name} - Products\"\n \n if(@company.can_view(current_user))\n if(params[:restock])\n @products = Product.where([\"company_id = ? AND quantity <= reorder\", @company.id]).order('name').paginate(:page => params[:page]) \n @view_restock = true\n else\n if(params[:search] and params[:search] != \"\") \n @products = Product.where([\"company_id = ? and (code LIKE ? OR name LIKE ?)\", @company.id,\"%\" + params[:search] + \"%\", \"%\" + params[:search] + \"%\"]).order('code').paginate(:page => params[:page]) \n else\n @products = Product.where([\"company_id = ?\",@company.id ]).order('code').paginate(:page => params[:page]) \n end\n end\n else\n errPerms()\n end\n end",
"def create\n #This will find or create a cart based on applications controller method\n @cart = current_cart\n #We use params to get the product ID from the request\n #This is stored locally as no need to let view see it\n product = Product.find(params[:product_id])\n \n #Adds an item to the cart using the \"add_product\" \n #function in the \"cart.rb\" file.\n @line_item = @cart.add_product(product.id)\n\n respond_to do |format|\n if @line_item.save\n format.html { redirect_to(store_url) }\n #.js is added to stop the create action from \n #redirecting to the index display if the request is \n #from javascript\n format.js { @current_item = @line_item }\n format.json { render json: @line_item, status: :created, location: @line_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def products\n request :public, :get, :products\n end",
"def index #when user goes to the /cart then the cart should be empty or full of some product.\n @product = Product\n if session[:cart] then\n @cart = session[:cart]\n else\n @cart = {}\n end\n end",
"def cart_op\n session[:cart] = yield(get_cart)\n end",
"def catalog_item\n \tif params[:search]\n \t\t @products = Product.search(params[:search])\n \telse\n \t\t@products=Product.all\n \tend\n end",
"def show\n @cart = Cart.find_by(buyer_id:current_buyer.id)\n @entries = CartCarry.where(cart_id:@cart.id)\n @TotalPrice = 0\n @entries.each do |item|\n @TotalPrice += Product.find_by(id:item.product_id).currentPrice * item.quantity\n end\n end",
"def show_cart\n # GETTING ALL THE ITEMS\n\n @cart_nachos = Nacho.find(cart)\n\n end",
"def get_items_info_in_cart\n return [] unless page.has_css?('.no-style.cart__list', wait: TimeOut::WAIT_BIG_CONST)\n\n items_arr = []\n str = page.evaluate_script(\"$('.no-style.cart__list').html();\")\n html_doc = Nokogiri::HTML(str)\n\n # get all information of product\n html_doc.css('.cart__item.ng-scope').each do |el|\n prod_id = el.css('div.media >a.pull-left> @href').to_s.split('/')[-1].gsub('A-', '')\n title = el.css('div.media>div>div.row>div>h3.title>a.ng-binding').text\n strike = el.css('div.media>div>div.row>div.span3>div.qty-price>span.single.price.strike.ng-binding').text\n sale = el.css('div.media>div>div.row>div.span3>div.qty-price>span.single.price.ng-binding.sale').text\n price = el.css('div.media>div>div.row>div.span3>div.qty-price>span.single.price').text if strike == ''\n\n # Put all info into array\n items_arr.push(prod_id: prod_id, title: title, price: price, strike: strike, sale: sale)\n end\n\n items_arr\n end",
"def product_list()\n $tracer.trace(__method__)\n return GameStopProductList.new(ToolTag.new(div.className(create_ats_regex_string(\"products\")).div.className(\"/^product$/\"), __method__), self)\n end",
"def index\n @cart_products = if current_user.cart.present?\n current_user.cart.carts_products.includes(:product).all\n else\n []\n end\n render formats: :json\n end",
"def set_cart\n @article = Cart.find(params[:id])\n end",
"def shopping_cart\n Cart.new session\n end",
"def add_to_products\n \t@@products << self\n \tend",
"def all\n @carts = Cart.get_all_of_carts(@user, params[:page])\n if @carts.present?\n @carts\n else\n @object = 'Cart'\n render \"api/v1/errors/404\", status: 401\n end\n end",
"def cart\n current_cart\n end",
"def index\n @carts = current_user.carts\n end",
"def index\r\n @carts = Cart.all\r\n end",
"def update_products_details; end",
"def show\n # todo: Se sigue usando???\n # @cart_action = @producto.cart_action(session)\n end",
"def show\n redirect_to cart_items_url\n end",
"def set_carts_product\n @carts_product = CartsProduct.find(params[:id])\n end",
"def items_from_cart\n items = session[:cart]\n products = []\n items.each do |item|\n product = Product.find(item['product'])\n products << { name: product.name, price: product.price, image: product.product_images[0].image.url(:thumb), quantity: item['quantity'] }\n end\n return products\n end",
"def index\n @cartels = Cartel.all\n end",
"def set_cart_item\r\n \t \t@cart_item = CartItem.find(params[:id])\r\n \t\tend",
"def index\n # if not signed in\n if current_user == nil\n redirect_to user_session_path\n else\n unless params[:id].nil?\n # get product info\n @purchased = ProductListing.find(params[:id])\n # get restaurant info\n @restaurant = Seller.where(id: @purchased.seller_id).first\n # grab a random number\n ref = 15.times.map{rand(10)}.join\n # qrcode check it\n # testing qr code\n # @qr = RQRCode::QRCode.new(\"#{@restaurant.website_url}?ref:#{ref}\").to_img.resize(200, 200).to_data_url\n # real qr code with reference number\n @qr = RQRCode::QRCode.new(\"https://kendodeal.herokuapp.com/scans/outcome?ref=#{ref}\").to_img.resize(200, 200).to_data_url\n # check if product exits in model where currentuser\n # Seller cannot add the same product name twice anyways\n @checkIfExists = Cart.where(product_name: @purchased.product_name, user_id: current_user.id ).first\n if @checkIfExists == nil\n # insert into cart\n @addToCart = Cart.create(company_name: @restaurant.company_name, product_name: @purchased.product_name, description: @purchased.description, was_price: @purchased.was_price, price: @purchased.price, reference_number: ref, expiry_date: @purchased.expiry_date, qrcode: @qr.to_str, user_id: current_user.id)\n end\n end\n # insert into cartcart_params\n\n # @addToCart = Cart.create(company_name: @restaurant.company_name, product_name: @purchased.product_name, description: @purchased.description, was_price: @purchased.was_price, price: @purchased.price, reference_number: ref, expiry_date: @purchased.expiry_date, qrcode: @qr.to_str, user_id: current_user.id)\n # @addToCart = Cart.create(addToCart_params)\n\n # @addToCart.picture.attach(@purchased.picture)\n\n \n @carts = Cart.where(user_id: current_user.id)\n # cart quantity check\n @quantity = Cart.where(user_id: current_user.id).count\n # seller check needed - no adding to cart for seller\n @sellerCheck = Seller.where(user_id: current_user.id).first\n # get sum for stripe\n userCart = Cart.where(user_id: current_user.id)\n # grand total\n @sumForStripe = 0\n # cart savings calculations for display only\n @savings = 0\n userCart.each do |price|\n @sumForStripe += price[:price].to_i\n @savings += price[:was_price].to_i\n end\n end\n end",
"def show_cart\n render json: User.find(params[:id]).cart_products\n end",
"def show\n @cart.destroy_cart_items\n\n end",
"def index\n @carts = Cart.all\n end",
"def index\n @carts = Cart.all\n end",
"def index\n @carts = Cart.all\n end",
"def index\n @carts = Cart.all\n end",
"def add_univstub_with_discount() add_to_cart_common(:add_product, params[:id]) end",
"def cart\n type = params[:type]\n\n if type == \"addcart\"\n #current_user.cart_additions << @item\n current_user.carts.create!(:item =>@item, :iscart? =>true)\n redirect_to cart_index_path, notice: \"#{@item.name} was added to your cart\"\n elsif type == \"removecart\"\n current_user.carts.update(:item =>@item, :iscart? =>false)\n #current_user.cart_additions.delete(@item)\n redirect_to root_path, notice: \"#{@item.name} was removed from your cart\"\n else\n redirect_to item_path(@item), notice: \"Looks like nothing happened. Try again!\"\n\n end\n end",
"def list_products\n render \"products_view/all\"\n end",
"def index\n @retail_carts = Retail::Cart.all\n end",
"def index\n @cart = current_user.cart\n end",
"def index\n Shop.set_store_session\n @products = ShopifyAPI::Product.all\n end",
"def index\n @mycarts = Mycart.all\n end",
"def add_product(name, price)\n new_product = Product.new(name, price)\n @products_in_cart << new_product\n new_product\nend",
"def show_cart\n render :action => 'show'\n end",
"def index\n @products = Product.featured.available.paginate(\n :per_page =>\n (CartConfig.get(:products_per_page, :store) || 15),\n :page => (params[:page] || 1).to_i,\n :readonly => true,\n :order =>'updated_at desc'\n )\n end",
"def cart_line_items(products)\n products.map {|p| self.cart_line_item(p)}\n end",
"def add\n add_to_cart_common(:add_product, params[:id])\n end",
"def show_cart;\n render layout: 'cart'\n end",
"def create\n # create or increment existing CartLineItem\n @line_item = add_line_item\n # save CartLineItem and create flash message indicating result\n if @line_item.save\n flash[:success] = \"#{params[:desc]} Successfully Added to Cart\"\n else\n flash[:error] = \"#{params[:desc]} not Added to Cart - Please contact Support\"\n end\n # redirect back to Products page to allow user to continue shopping\n if params[:current_page] == 1\n logger.debug \"*** Redirecting to First Products Page...\"\n redirect_to products_path\n else\n logger.debug \"Redirecting to Products Page #{params[:current_page]}\"\n redirect_to products_path(page: params[:current_page])\n end\n end",
"def index\n if current_user\n order_id = Order.where(user_id: current_user.id, status: 0).ids\n @carts = OrderProduct.where(order_id: order_id).includes(product: :images)\n @amount = Payment.total_amount(current_user.id)\n @widgets_count = Payment.widgets_count(current_user.id)\n @email = current_user.email\n else\n @order_products = []\n unless cookies[:add_to_cart].nil?\n JSON.parse(cookies[:add_to_cart]).each do |cookie|\n arr = []\n arr.push(Product.find(cookie['product_id'].to_i))\n arr.push(cookie['quantity'].to_i)\n @order_products << arr\n end\n end\n end\n end",
"def create\n #Now let’s modify the LineItemsController to find the shopping cart for the current\n #session (creating one if there isn’t one there already), add the selected product\n #to that cart, and display the cart contents.\n\n # Line item will be created from adding Product to the Cart\n #@line_item = LineItem.new(params[:line_item])\n\n #current_cart is the function/method define n the ApplicationController\n @cart = current_cart\n product = Product.find(params[:product_id])\n=begin\n We then pass that product we found into @cart.line_items.build. This causes a\n new line item relationship to be built between the @cart object and the product.\n You can build the relationship from either end, and Rails will take care of\n establishing the connections on both sides.\n\n=end\n # *** Here :product_id reference the cart product_id. So that we an find out the specific product from the cart\n #@line_item = @cart.line_items.build(:product_id => product)\n #p(\"Product Id : \"+product.id)\n @line_item = @cart.add_product(product.id)\n\n respond_to do |format|\n if @line_item.save\n #format.html { redirect_to @line_item, :notice => 'Line item was successfully created.' }\n # Redirect t line_item cart after saving it\n #format.html { redirect_to(@line_item.cart, :notice => 'Line item was successfully created.') }\n # This function is used to redirect to store_url after saving\n format.html { redirect_to(store_url) }\n #For ajax calling , The first change is to stop the create action from redirecting to the index dis-\n #play if the request is for JavaScript. We do this by adding a call to respond_to\n #telling it that we want to respond with a format of .js.\n\n format.js { @current_item = @line_item }\n\n format.xml { render :xml => @line_item,\n :status => :created, :location => @line_item }\n\n # For rendering no template\n #render :nothing => true\n #format.json { render :json => @line_item, :status => :created, :location => @line_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @line_item.errors,\n :status => :unprocessable_entity }\n\n #format.json { render :json => @line_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @in_shopping_carts = InShoppingCart.all\n end"
] | [
"0.68885434",
"0.679729",
"0.6707468",
"0.6682198",
"0.6550222",
"0.6547867",
"0.6538446",
"0.65215296",
"0.6502721",
"0.64763033",
"0.64118445",
"0.63991445",
"0.6287897",
"0.6266605",
"0.62369055",
"0.62369055",
"0.6233141",
"0.6221749",
"0.62062645",
"0.61998177",
"0.61985743",
"0.61851656",
"0.6164784",
"0.61634517",
"0.61261165",
"0.61202776",
"0.61202776",
"0.61202776",
"0.61202776",
"0.61202776",
"0.61114913",
"0.6094741",
"0.6079136",
"0.6077768",
"0.6060375",
"0.6055155",
"0.6051424",
"0.60246885",
"0.6023935",
"0.602101",
"0.6000403",
"0.5994189",
"0.599092",
"0.59588265",
"0.5942899",
"0.59187573",
"0.5914743",
"0.59146756",
"0.5913685",
"0.59116894",
"0.589644",
"0.5887149",
"0.5882953",
"0.5882073",
"0.5871282",
"0.58643764",
"0.5862623",
"0.5852248",
"0.5851073",
"0.58463025",
"0.5842212",
"0.5840866",
"0.5833651",
"0.5829228",
"0.5827196",
"0.5815432",
"0.5812892",
"0.58055574",
"0.57969224",
"0.57938534",
"0.5790583",
"0.57787764",
"0.57786304",
"0.5778093",
"0.57723296",
"0.57723016",
"0.57712245",
"0.57709104",
"0.5768689",
"0.5751218",
"0.5749949",
"0.5749949",
"0.5749949",
"0.5749949",
"0.5736321",
"0.5732152",
"0.5729416",
"0.5719699",
"0.5719635",
"0.570624",
"0.5705159",
"0.57023686",
"0.5702159",
"0.57020843",
"0.56999624",
"0.56976926",
"0.56938916",
"0.56931514",
"0.5692749",
"0.56899023",
"0.5688928"
] | 0.0 | -1 |
Mass products assignement, from session hash | def products=(items)
if items.is_a? Array
@products = items.map do |product|
Product.new(product)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n\t\t# @product = Product.new\n\t\tputs params\n @comparison = Comparison.find(params[:id])\n\t\t# @products_hash = Hash.new\n # @tributes_all_hash = Hash.new\n @user = current_user\n\t\t@user.comparisons += [@comparison]\n\t\t# @product = Product.create(url: session[0][:url_hash][:url])\n\t\t# @product = Product.create(url: session[1][:url_hash][:url])\n\t\tputs 'showing the count below 888888888888888888888888888888888888888888888888'\n\t\tputs @comparison.products.count\n\t\tunless @comparison.products.count > 1\n\t\t\tsession[:url_hash].each do |a|\n\t\t\t\t# because this returns the numerical key as a string instead of a key and \"flattens\" the hash\n\t\t\t\t# we loop to access the actual hash that has the url value.\n\t\t\t\tputs 'showing the session a below 888888888888888888888888888888888888888888888888'\n\t\t\t\tputs a\n\t\t\t\ta.each do |b|\n\t\t\t\t\tif b.is_a? Hash\n\t\t\t\t\t\tputs 'showing the session b below 888888888888888888888888888888888888888888888888'\n\t\t\t\t\t\tputs b\n\t\t\t\t\t\t# so b here is {:url => \"google.com\"} for instance.\n\t\t\t\t\t\t# we push because @comparison.products is an array\n\t\t\t\t\t\t@product = Product.create(url: b[:url])\n\t\t\t\t\t\t@comparison.products.push(@product)\n\t\t\t\t\t\t# crunchm!!!!!!!!!\n\t\t\t\t\t\tcrunchm(@comparison, @product, b[:url])\n\t\t\t\t\t\t# puts \"CRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHM\"\n\t\t\t\t\t\t# # puts @crunchm.keys\n\t\t\t\t\t\t# puts \"CRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHM\"\n\n\t\t\t\t\t\t\n\t\t\t\t\t\t# @comparison.tributes.push()\n\t\t\t\t\t\t\n\t\t\t\t\t\t# parseAmazon (b[:url])\n\t\t\t\t\t\t# p = Product.create (url: b[:url], name: name_from_nokogiri)\n\t\t\t\t\t\t# tributes_from_nokogiri.each do |tribute|\n\t\t\t\t\t\t# t = Tribute.create ( tribute attributes )\n\t\t\t\t\t\t# p.tributes.push(t)\n\t\t\t\t\t\t# end\n\t\t\t\t\t\t\n\t\t\t\t\t\t# end\n\n\t\t\t\t\tend\n\t\t\t\tend\t\n\t\t\tend\n\t\telse \n\t\t\tsession[:url_hash].each do |a|\n\t\t\t\t# because this returns the numerical key as a string instead of a key and \"flattens\" the hash\n\t\t\t\t# we loop to access the actual hash that has the url value.\n\t\t\t\tputs 'showing the session a below 888888888888888888888888888888888888888888888888'\n\t\t\t\tputs a\n\t\t\t\ta.each do |b|\n\t\t\t\t\tif b.is_a? Hash\n\t\t\t\t\t\tputs 'showing the session b below 888888888888888888888888888888888888888888888888'\n\t\t\t\t\t\tputs b\n\t\t\t\t\t\t@product = Product.new(url: b[:url])\n\t\t\t\t\t\t# so b here is {:url => \"google.com\"} for instance.\n\t\t\t\t\t\t# we push because @comparison.products is an array\t\t\t\t\t\t\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\t\n\t\t# @product = Product.new(url: 'just a placeholder for now')\n\t\tputs 'looks like it fails right here 888888888888888888888888888'\n\t\t@crunchm = create_table_hash(@comparison)\n\t\tputs 'looks like it fails right here 888888888888888888888888888'\n\t\t@products = current_comparison.products.all\t\t\n\tend",
"def create\n # if user is not logged_in\n if cart_product_params[:user_id].empty?\n session[:temp_cart] = cart_product_params\n redirect_to login_path, :notice => \"Please log in, the product will be placed in your cart once you've logged in.\"\n else\n @cart_product = CartProduct.new(cart_product_params)\n respond_to do |format|\n if cart_product_params[:quantity].to_i > 0\n if @cart_product.save\n format.html { redirect_to request.referrer, notice: \"Added to Cart. Please go to your cart to pay for your items!\" }\n format.json { render :show, status: :created, location: @cart_product }\n \n # Then remove from savedlist\n session[:savedlist] ||= []\n session[:savedlist].delete(cart_product_params[:product_id])\n \n # update admin stats\n saved_products_stats(cart_product_params[:product_id], -1)\n \n # Then update popularity of product\n increase_product_popularity_by_product_id(cart_product_params[:product_id])\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @cart_product.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to request.referrer, notice: \"Quantity cannot be 0 or less!.\" }\n end\n end\n end\n end",
"def process_params(list)\n # Parameters: {\"utf8\"=>\"✓\", \"authenticity_token\"=>\"tGvVyCEfLgpv2xvd2UcSLnhS56lrjAqxg/O5M4DNmiY=\", \"order\"=>{\"products\"=>{\"product0\"=>\"3\", \"quantity0\"=>\"3\", \"product1\"=>\"\", \"quantity1\"=>\"\", \"product2\"=>\"\", \"quantity2\"=>\"\", \"product3\"=>\"\", \"quantity3\"=>\"\", \"product4\"=>\"\", \"quantity4\"=>\"\"}}, \"commit\"=>\"Save changes\", \"id\"=>\"302\"}\n hash = {}\n memory = []\n list[:products].each do |k, value|\n if k[0] == \"p\" && !value.empty?\n hash[value] = nil\n memory[k[-1].to_i] = value.to_i\n elsif k[0] == \"q\" && !value.empty?\n key = memory[k[-1].to_i]\n hash[key] = value if key\n end\n end\n hash\n end",
"def set_product\n \n end",
"def set_products\n @products_ordered = Product.where(\"id = ?\", params[:product_id]) \n end",
"def add_in_cart \n product_id=params[:id].to_i\n @product=Product.find(product_id)\n total_request=1\n update_through_cart=0 \n if params.has_key?(:quant) \n total_request=params[:quant][:total_request].to_i\n update_through_cart=1 \n end \n if(check_availabilty(product_id,total_request,update_through_cart))\n update_session(product_id,total_request,update_through_cart)\n else\n flash[:notice] = \"#{Product.find(product_id).name} is not available in this quantity\" \n end\n end",
"def add_to_cart_if_temp_cart\n if session[:temp_cart]\n \n product_params = session[:temp_cart]\n product_params[\"user_id\"] = logged_in\n @cart_product = CartProduct.new(product_params)\n @cart_product.save\n session[:temp_cart] = nil\n \n # Then remove from savedlist\n session[:savedlist] ||= []\n session[:savedlist].delete(product_params[\"product_id\"])\n \n # Then update popularity of product\n increase_product_popularity_by_product_id(product_params[\"product_id\"])\n return true\n end\n return false\n end",
"def products\n end",
"def permitted_params\n\n \n if action_name.to_s == \"update\" && !current_signed_in_resource.is_admin?\n\n \n params.permit({cart_item: [:discount_code,:quantity]},:id)\n\n elsif action_name.to_s == \"create_multiple\"\n params.permit({discount: [:id, {:product_ids => []}]})\n else\n\n params.permit({cart_item: [:product_id,:discount_code,:quantity]},:id)\n\n end\n\n\n end",
"def purchase_action\n # from cart\n if params[:product_id] == '0'\n @items = session[:cart]\n @purchase = Purchase.new(bill_address_id: params[:bill_address_id], ip: IPAddr.new(request.remote_ip).to_i)\n @purchase.save\n @items.each do |item|\n @purchase_products = PurchaseProduct.new(purchase_id: @purchase.id, product_id: item['product'], quantity: item['quantity'])\n @purchase_products.save\n stock_minus(item['product'], item['quantity'])\n end\n # via product page\n else\n @purchase = Purchase.new(bill_address_id: params[:bill_address_id], ip: IPAddr.new(request.remote_ip).to_i)\n if @purchase.save\n @purchase_products = PurchaseProduct.new(purchase_id: @purchase.id, product_id: params[:product_id], quantity: session[:quantity])\n @purchase_products.save\n stock_minus(params[:product_id], session[:quantity])\n else\n render 'purchase_show'\n end\n end\n # Send email\n UserMailer.purchase_email(@purchase).deliver\n session[:purchased_item] = params[:product_id]\n redirect_to purchase_success_path\n end",
"def bulk_update\n if current_user\n @user = User.find(current_user.id) # TODO: is it necessary to find user? \n @product_details = @user.product_details \n end\n end",
"def add(product_name,quantity)\n $products[product_name] = quantity\n $products\nend",
"def associate_inventory_units\n params[:return_quantity].each { |variant_id, qty| @return_authorization.add_variant(variant_id.to_i, qty.to_i) }\n end",
"def product\n if PRODUCT_UPDATE_MUST_HAVE.include?(Employee.where(id: session[\"found_user_id\"]).first.admin_rights)\n id = params[\"product_id\"]\n if id == \"new\"\n @product = Product.new\n @product.items_per_bunch = 100\n @product.markup = 100\n else\n @product = Product.where(florist_id: session[\"found_florist_id\"]).where(id: id).first\n end\n render(:product_updates) and return\n else\n redirect_to \"/products\" and return\n end\n end",
"def update_quantity_to_cart\n \t\n\n \tproduct_id_ = params[:product_id].to_i\n\n \tsession[\"cart\"].each do |h|\n \t\tif h['id'] == product_id_\n \t\t\th['quantity'] = params[:quantity_update].to_i\n \t\t\th['total'] = h['price'] * h['quantity']\n \t\t\t\n \t\tend\n \tend\n\n \tredirect_to :back\n end",
"def store_visited_product\n id = @product.id\n unless cookies[:user_visited_products]\n cookies[:user_visited_products] = id\n else\n cookies_array = cookies[:user_visited_products].to_s.split(',')\n if cookies_array.size < 20\n cookies_array << id unless cookies_array.include?(\"#{id}\")\n cookies[:user_visited_products] = cookies_array.join(\",\")\n end\n end\n end",
"def save_products\n self.products = @products_cache if @products_cache\n end",
"def set_product\n @product = Product.find_by_hashid(params[:id])\n end",
"def shoes\n\t@user=User.find(session[:id])\n\t@products=Product.all\nend",
"def save_products\n self.products = @products if @products\n end",
"def create\n #if user is not logged in, store all the attributes under its own session cookies.\n if current_user.nil?\n p = Product.find(session[:tmp_cart_pid])\n pv_id = p.product_variants.find_by(size: params[:size], color: params[:color]).id\n session[:tmp_cart_vid] = pv_id\n session[:tmp_quantity] = bag_params[:quantity]\n redirect_to signin_path\n else\n bag_params1 = bag_params\n pr = Product.find(bag_params1[:product_id])\n bag_params1[:product_variant_id] = pr.product_variants.find_by(size: params[:size], color: params[:color]).id\n @bag = Bag.new(bag_params1)\n\n respond_to do |format|\n if @bag.save\n #Add popularity when successfully added to cart\n product = Product.find(bag_params1[:product_id])\n product.popularity += 1\n product.save\n \n format.html { redirect_to pr, notice: \"Item added to cart!\" }\n format.json { render :show, status: :created, location: pr }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bag.errors, status: :unprocessable_entity }\n end\n end\n end \n end",
"def update_harman_employee_pricing\n authorize! :update, :harman_employee_pricing\n params[:product_attr].to_a.each do |key, attr|\n product = Product.find(key)\n product.update_attributes(attr)\n end\n redirect_to(harman_employee_pricing_admin_products_path, notice: \"Pricing updated successfully.\")\n end",
"def custom_craft_step3\n #first step, we set new session that will store data from step 1, also insert some signal that step 1 has been completed\n @craft = Craft.find_by(:id=>params[:craft_id])\n #custom_craft = session[:custom_craft]\n session[:custom_craft_categories] = params[:category_selected]\n session[:material_selected] = params[:material_selected]\n\n @material = []\n session[:material_selected].each do |x|\n temp = Material.find(x) \n @material << temp\n end\n @categories = Category.all\n @subcategories = Subcategory.all\n @craft_material = @craft.craft_materials.build\n end",
"def set_product\n @product = current_user.products.find(params[:id])\n end",
"def set_products\n @product = Product.find(params[:id])\n end",
"def assign_parts(hash={})\n return if hash.nil? or hash == {}\n self.parts = []\n hash ||= {}\n hash.each do |h|\n i = self.vendor.items.visible.find_by_sku(h[:sku])\n if i then\n i.is_part = true\n i.part_quantity = self.string_to_float(h[:part_quantity])\n result = i.save\n if result == false\n raise \"Could not save Item because #{ i.errors.messages }\"\n end\n self.parts << i\n end\n end\n result = self.save\n if result == false\n raise \"Could not save Item because #{ self.errors.messages }\"\n end\n end",
"def product_params\n params.require(:product).permit(:product_name,:product_code,:grade,:formula,:molar_mass,{chemical_images: []},:pakaging, :price)\n end",
"def index\n @stocks = Stock.all\n @webhooks = ShopifyAPI::Webhook.find(:all)\n\n\n # After Authenticate Job / after change in product listings\n if Product.count < 1\n ProductSize.all.each do |size|\n _items = ShopifyAPI::Product.find(:all, params: { collection_id: size.collection_id })\n _items.each do |product|\n prod = Product.create(name: product.title, item_id: product.id, product_size: size)\n product.variants.each do |var|\n prod.variants.create!(quantity: var.inventory_quantity, variant_id: var.id, title: var.title, inventory_item_id: var.inventory_item_id )\n end\n end\n end\n end\n\n\n end",
"def set_ordered_product\n @ordered_product =OrderedProduct.find_by(product_id: params[:product_id])\n end",
"def update_harman_employee_pricing\n authorize! :update, :harman_employee_pricing\n Array(params[:product_attr].to_unsafe_h).each do |key, attr|\n product = Product.find(key)\n product.update(attr)\n end\n redirect_to(harman_employee_pricing_admin_products_path, notice: \"Pricing updated successfully.\")\n end",
"def store!\n session['order'] = unpromoted_order.dump\n end",
"def inventory_product_params\n params.fetch(:inventory_product, {}).permit(:image_url, :name, :price, :gift, :inventory_category_id,\n :product_link, :is_stock, :hot_category_name)\n end",
"def set_product\n @products = Product.find(params[:id])\n end",
"def set_product\n @product_promotion = ProductPromotion.find(params[:id])\n end",
"def set_product\n\t\t@product = params[:id]\n\tend",
"def products\n @products ||= hash[\"Products\"].map { |p| Merchant::Product.new p }\n end",
"def create\n product_id = shopping_cart_params[:product_id]\n\n # ensure the product is not added to the cart twice\n return if session[:shopping_cart][product_id].present?\n\n session[:shopping_cart][product_id] = {\n quantity: shopping_cart_params[:quantity],\n size: shopping_cart_params[:size]\n }\n\n @product = Product.find(product_id.to_i)\n end",
"def set_admin_product\n @product = Product.find(params[:id])\n end",
"def product_list\n current_user.products.order('name').collect {|p| [ p.name, p.ticket_project_id, p.id ]}\n end",
"def increase_items_count\n # ensure count cannot go above 5\n s_id = params[:product_id].to_s\n return if session[:shopping_cart][s_id]['quantity'].to_i >= 5\n\n session[:shopping_cart][s_id]['quantity'] =\n session[:shopping_cart][s_id]['quantity'].to_i + 1\n\n @product = Product.find(params[:product_id].to_i)\n calculate_order_total\n end",
"def index\n @products = []\n @@this_week.each_with_index do |id,index|\n puts \"#{id}\"\n @products[index] = Product.find(id)\n end\n if member_signed_in?\n @order = Order.create(:member => @current_member,\n :cheap_beer => @count_cheap,\n :class_beer => @count_class)\n else\n @order = Order.create(:cheap_beer => @count_cheap,\n :class_beer => @count_class)\n end\n end",
"def product_params\n if @current_user.shops.where(id: params[:product][:shop_id]).first\n @product_params = params.require(:product).permit(:name,\n :description,\n :price,\n :rating,\n :shop_id,\n :category_id)\n true\n else\n render(json: { error: 'Not authorized' }, status: :unauthorized)\n false\n end\n end",
"def basket\nif session[:basket].nil?\n\t#basket is an empty list, using set because we don't want to add the same thing twice(an empty array[] allows you to add the same thing twice)\n\tsession[:basket] = Set.new\nend\n#actually give them the basket\nsession[:basket]\nend",
"def store_product_params\n params.require(:store_product).permit(:user_id, :product_id, :price, :stock, :in_w, :in_r)\n end",
"def purchase_show\n if params[:product_id] == '0'\n @items = session[:cart]\n else\n @items = []\n @items << { 'product' => params[:product_id], 'quantity' => session[:quantity] }\n end\n @sum = 0\n @count = 0\n @items.each do |item|\n product = Product.find(item['product'])\n @sum += product.price * item['quantity'].to_i\n @count += item['quantity'].to_i\n end\n @address = BillAddress.find(params[:bill_address_id])\n @user = current_user\n end",
"def product_params\n params.permit(:product_id,:promotion_id)\n end",
"def index\n @products = Product.all\n @products.each do |prod|\n if prod.pid == 1 # pid is a flag\n prod.bb = current_user.id\n prod.tbid += 1\n if prod.price <= prod.pbidprice && prod.tbid != 1\n prod.bb = prod.pbid\n prod.price = prod.pbidprice\n prod.tbid -= 1\n else\n prod.pbidprice = prod.price\n prod.pbid = prod.bb\n end\n prod.pid = 0\n prod.save\n end\n end\n end",
"def product_params\n params.require(:product).permit(:page,:product_name,:brand_id,:category_id,:desc,:avatar,:inventory,:store_id,:price,:inventory_policy,:sku,:token,option_value: [], option_name: [])\n end",
"def product_assign_params\n params.require(:product_assign).permit(ProductAssign.safe_attributes)\n end",
"def set_product_share\r\n @product_share = ProductShare.find(params[:id])\r\n end",
"def cart\n Product.find(session[:user_cart])\n end",
"def product_params\n params.fetch(:product,{}).permit!\n end",
"def populate\n\n\n\n#Cart limit set\n\n# @powerbeat_qty = 0\n# @variant = Spree::Product.find(23).variants\n# if(current_order)\n# current_order.line_items.each do |linevalidate|\n# @variant.each do |linevariants|\n# if (linevariants.id == linevalidate.variant_id)\n# @powerbeat_qty += linevalidate.quantity\n# #raise (\"Powerbeat_Qty: \" << @powerbeat_qty.to_yaml)\n# \t\t if(@powerbeat_qty >=2 )\n# flash.notice = 'You can not add more than 2 Powerbeat product'\n# end\n# \tend\n# \tend \n# end\n# end\n\t\n\npopulator = Spree::OrderPopulator.new(current_order(create_order_if_necessary: true), current_currency)\n\nif populator.populate(params[:variant_id], params[:quantity], params[:options])\n\nrespond_with(@order) do |format|\nformat.html { redirect_to cart_path }\nend\nelse\nflash[:error] = populator.errors.full_messages.join(\" \")\nredirect_back_or_default(spree.root_path)\nend\nend",
"def create\n @products = Product.all\n order_products = []\n @products.each do |p|\n sym = \"product_#{p.id}\".to_sym\n if params[sym].present?\n count = params[sym].to_i\n if count > 0\n order_product = OrderProduct.new(product: p, count: count)\n order_products << order_product\n end\n end\n end\n\n if order_products.size > 0\n order = Order.new(user: current_user)\n order.save!\n order_products.each do |i|\n i.order = order\n i.save!\n end\n redirect_to order_path(order.id)\n else\n redirect_to new_order_path\n end\n end",
"def fill_in_products\n products = []\n @data.products.all_products.each_with_index do |p, i|\n prod = {}\n prod['index'] = i\n prod['qty'] = @data.product_qty[p.prd_id]\n prod['desc'] = p.prd_long_desc\n prod['price'] = \"$\" + p.fmt_total_price\n prod['prd_id'] = p.prd_id\n products << prod\n end\n \n products\n end",
"def execute\n guest.cart.order_items.create product: product\n end",
"def update_unauthenticated_product_answers\r\n return if session[:unauthenticated_product_answers].blank?\r\n session[:unauthenticated_product_answers].each do |product_answer_id|\r\n product_answer = ProductAnswer.find_by_id(product_answer_id)\r\n product_answer.update_attribute(:user_id, session_user.id) if product_answer\r\n end\r\n session.delete :unauthenticated_product_answers\r\n end",
"def set_product\n #クライアントから入力された商品IDの情報をすでに登録されているDBから取ってくる \n #/product/1\n @product = Product.find(params[:id])\n \n end",
"def create\n\n session[:cart] ||= Hash.new(0)\n session[:cart][params[:product_id]] += 1\n respond_to do |format|\n format.html do\n redirect_to products_path, notice: \"Product #{params[:product_id]} was added to your cart.\"\n end\n format.json do\n render json: {\n cart: session[:cart],\n item_count: session[:cart].values.sum\n }\n end\n end\n end",
"def set_product\n @product = Product.includes(:lotteries, :ranking_config_items).find(params[:id])\n end",
"def edit\n respond_to do |format|\n session[:savedlist] ||= []\n if session[:savedlist].include? params[:id]\n session[:savedlist].delete(params[:id])\n \n # update admin stats\n saved_products_stats(params[:id], -1)\n \n format.html { redirect_to request.referrer, notice: \"Item removed from Saved list.\" }\n else\n session[:savedlist] << params[:id]\n \n # update admin stats\n saved_products_stats(params[:id], 1)\n \n # Then update popularity of product\n increase_product_popularity_by_product_id(params[:id])\n format.html { redirect_to request.referrer, notice: \"Item added to Saved list!\" }\n end\n end\n end",
"def product_params\n params.require(:product).permit(:title, :user_id, :cost, :collection, :items, :contents, :perishables, :non_perishables, :description, {images: []})\n end",
"def add_to_cart\n\t\tcart_hash = session[:cart]\n\t\tproduct = find_key(cart_hash, params[:id])\n\t\tproduct[:quantity] += 1\n\t\tcart_hash[params[:id]] = product\n\n\t\tredirect_to root_url\n\tend",
"def update\n item_quantities = Array.new\n item_quantities = params[:shopping_cart]\n item_list = Hash.new\n @shopping_cart = ShoppingCart.find(params[:id])\n shopping_cart_hash = eval(@shopping_cart.item_list)\n counter = 0\n shopping_cart_hash.each do |item_id, quantity|\n item_list[item_id] = Integer(item_quantities[counter])\n counter += 1\n end\n params[:shopping_cart] = Hash[\"item_list\" => item_list.to_s]\n respond_to do |format|\n if @shopping_cart.update_attributes(params[:shopping_cart])\n format.html { redirect_to @shopping_cart, notice: 'Shopping cart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shopping_cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @product_sets = args[:product_sets] if args.key?(:product_sets)\n end",
"def product_params\n params.require(:product).permit(:name, :sku, :product_type, :price, store_ids: [])\n end",
"def set_admin_product\n @product = Product.find(params[:id])\n end",
"def product_params\n params.fetch(:product, {})\n end",
"def product_params\n params.fetch(:product, {})\n end",
"def set_prod\n @product = Product.find(params[:id])\n end",
"def params_shopping_cart_products\n params.permit(:product_quantity, :product_id, :shopping_cart_id)\n end",
"def set_product\n @product = Product.find_by( :id => params[:id] )\n end",
"def add_inventory\n begin\n if product_params[:sku].present? && inventory_stock_params[:items_count].present?\n\n # SKU will remain unique through out the course of application\n @product = Product.find_by_sku(product_params[:sku])\n if @product.present?\n # In case of existing product with provided SKU, product will get updated with\n # parameters of name and price if provided .\n @product.update_attributes!(product_params) if product_params[:name] ||\n product_params[:price]\n else\n # In case of no product found with provided SKU, then new product will be created\n @product = Product.create!(product_params)\n end\n @product_stock = @product.stock_inventories\n .available_stock_for_specific_distribution_center(@distribution_center.id).first\n\n # If there isn't any stock entry for such product in specified distribution center.\n @product_stock = @product.stock_inventories.create!(available: true,\n items_count: 0,\n distribution_center_id:\n @distribution_center.id) unless @product_stock.present?\n\n # Update the inventory count.\n if @product_stock.update_attribute(:items_count,\n @product_stock.items_count +\n inventory_stock_params[:items_count].to_i)\n response = {message: \"Inventory has been updated successfully.\"}\n status_code = 200\n else\n response = {errors:\n [{detail: \"We can't apply this operation at this time, please try later.\"}]}\n status_code = 403\n end\n else\n response = {errors:\n [{detail: \"Required parameters are missing.\"}]}\n status_code = 400\n end\n rescue => ex\n response = {errors: [{detail: ex.message}]}\n status_code = 403\n end\n render json: response, status: status_code\n end",
"def set_ids products\n products.each do |k, sp|\n size= Size.find_by_name sp[:size]\n color = Color.find_by_name sp[:color]\n if !size.nil? && !color.nil?\n p= Product.where(\"reference = ? and size_id = ? and color_id = ?\", sp[:reference], size.id, color.id)[0]\n sp[:product_id] = p.id if !p.nil?\n end\n end\n end",
"def product_params\n params.require(:product).permit(:products)\n end",
"def set_inventory_product\n @inventory_product = InventoryProduct.find(params[:id])\n end",
"def set_product\n @product = current_api_v1_user.products.find(params[:id])\n end",
"def find_product_and_release\n params[:product] = { :id => Product.active_products.find_by_short_name( params[:product]).try(:id) } if params[:product]\n params[:release] = { :id => Release.current.enabled.find_by_name( params[:release]).try(:id) } if params[:release]\n end",
"def product_params\n params.require(:product).permit(:name, :description, :stockCount, :pricePence, :image, :section_id)\n end",
"def add_to_inventory(category, product, quantity, price, refid)\n @inventory = {\n category => [\n product: product,\n quantity: quantity,\n price: price,\n refid: refid\n ]\n}\nend",
"def set_product\n @product = Product.find(params[:id])\n @item = Product.find(params[:id])\n end",
"def index\n @products = current_user.products\n end",
"def show_cart_detail\n @products = Product.find(session[:cart])\n end",
"def own_product_params\n params.require(:own_product).permit(:product_id, :user_id, :count, :memo)\n end",
"def add_product\n @user = User.find_by(id: params['user'])\n products = params['products'].split(',')\n products.each do |product_id|\n @user.cart.products << Product.find_by(id: product_id)\n end \n render json: {data: @user.cart.products }\n end",
"def home\n\n @account_type = session[:user_type]\n \n# @product=Product.all\n \nend",
"def product_params\n params.permit(:quantity, :product_id, :store_id)\n end",
"def products\n @products ||= begin\n items = []\n\n for i in (1..params[\"NumItens\"].to_i)\n items << {\n :id => params[\"ProdID_#{i}\"],\n :description => params[\"ProdDescricao_#{i}\"],\n :quantity => params[\"ProdQuantidade_#{i}\"].to_i,\n :price => to_price(params[\"ProdValor_#{i}\"]),\n :shipping => to_price(params[\"ProdFrete_#{i}\"]),\n :fees => to_price(params[\"ProdExtras_#{i}\"])\n }\n end\n\n items\n end\n end",
"def set_product\n\n # @product = Product.find(params[:id])\n\n end",
"def set_user_monthly_product_information\n @user_monthly_product_information = UserMonthlyProductInformation.find(params[:id])\n end",
"def set_product\n\t\t@product = Item.find(params[:id])\n\tend",
"def set_admin\n @adminproduct = Productcla.find(params[:id])\n end",
"def product_params\n params[:advertiser_id] = current_advertiser.id if advertiser_signed_in?\n params.permit *%i[id advertiser_id product_code product_name product_url image_url price slug]\n end",
"def index\n if Bucket.find_by(user_id: current_user.id).present?\n @buckets = []\n @a = Bucket.find_by(user_id: current_user.id)\n @a.product_id.each do |b|\n if Product.exists?(id: b[0])\n c = Product.find(b[0])\n @buckets << c\n else\n b = nil\n end\n end\n @a.product_id = @a.product_id.compact\n @a.save\n @buckets\n @a\n end\n end",
"def product_params\n params[:product]\n end",
"def add_to_cart\n session[:item_list] ? session[:item_list] << @product.id : session[:item_list] = [@product.id]\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product added to cart!' }\n format.json { head :no_content }\n end\n end",
"def create_multiple\n #puts \"came to create multiple.\"\n #puts \"params are:\"\n #puts params.to_s\n @auth_shopping_cart_items = []\n @auth_shopping_cart = @auth_shopping_cart_class.new(:add_cart_item_ids => [], :remove_cart_item_ids => [])\n #puts \"auth shopping discount is:\"\n #puts @auth_shopping_discount.to_s\n @auth_shopping_cart.discount_id = @auth_shopping_discount.id.to_s\n \n\n #puts \"is it is a new record\"\n #puts @auth_shopping_discount.new_record?\n unless @auth_shopping_discount.new_record?\n @auth_shopping_discount.product_ids.each do |product_id|\n \n if product = @auth_shopping_product_class.find(product_id)\n \n cart_item = create_cart_item_from_product(product)\n cart_item = add_owner_and_signed_in_resource(cart_item) \n \n if cart_item.save == true\n @auth_shopping_cart_items << cart_item\n @auth_shopping_cart.add_cart_item_ids << cart_item.id.to_s\n else\n puts \"the errors trying to save the item\"\n puts cart_item.errors.full_messages.to_s\n end\n end\n \n end\n else\n\n end\n \n \n\n end",
"def success\n if session[:purchased_item] == '0'\n @items = items_from_cart\n session.delete(:cart)\n else\n item = Product.find(session[:purchased_item])\n @items = []\n @items << { name: item.name, price: item.price, image: item.product_images[0].image.url(:thumb), quantity: session[:quantity] }\n end\n @sum = 0\n @count = 0\n @items.each do |item|\n @sum += item[:price] * item[:quantity].to_i\n @count += item[:quantity].to_i\n end\n end",
"def product_params\n params.permit(:title, :price, :inventory_count)\n end",
"def permitted_attributes\n if @role_name == 'member'\n [:product_name, :product_category_id]\n else\n [:product_name, :product_category_id, :SKU]\n end\n end",
"def set_inventory_product\n @inventory_product = InventoryProduct.find(params[:id])\n end"
] | [
"0.65751374",
"0.59400374",
"0.5892504",
"0.5760927",
"0.57149035",
"0.56984293",
"0.5634715",
"0.5616302",
"0.56048393",
"0.5571613",
"0.55640316",
"0.5547466",
"0.55435264",
"0.55426425",
"0.553087",
"0.55282557",
"0.5516176",
"0.5511952",
"0.5510311",
"0.5494565",
"0.546189",
"0.54475313",
"0.544545",
"0.5422175",
"0.54115057",
"0.5400031",
"0.53846514",
"0.5382317",
"0.538146",
"0.537146",
"0.5370145",
"0.53598374",
"0.5359676",
"0.53479886",
"0.53468245",
"0.5341473",
"0.5335765",
"0.5329878",
"0.5316012",
"0.531458",
"0.53130543",
"0.5310554",
"0.53078884",
"0.5303908",
"0.5297633",
"0.52944404",
"0.52854186",
"0.5284597",
"0.52774423",
"0.5277056",
"0.52745664",
"0.52725977",
"0.5271666",
"0.52665836",
"0.5250099",
"0.52482194",
"0.5243463",
"0.5243437",
"0.52383745",
"0.523502",
"0.5230343",
"0.522269",
"0.5221846",
"0.52201617",
"0.52196693",
"0.521758",
"0.52166814",
"0.51970017",
"0.5196462",
"0.5196445",
"0.5191896",
"0.51908463",
"0.518975",
"0.51868427",
"0.518616",
"0.51745594",
"0.51703775",
"0.5169617",
"0.51692766",
"0.516922",
"0.5169087",
"0.5168332",
"0.51625013",
"0.51609755",
"0.5158777",
"0.5155576",
"0.5155229",
"0.5154406",
"0.5152482",
"0.51516557",
"0.5146068",
"0.51353955",
"0.513038",
"0.51294494",
"0.5128921",
"0.51258874",
"0.51254576",
"0.51254493",
"0.51217914",
"0.51212376",
"0.51144594"
] | 0.0 | -1 |
Mass adjustments assignement, from session hash | def adjustments=(items)
if items.is_a? Array
@adjustments = items.map do |adjustment|
Adjustment.build(self, adjustment)
end.compact
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mod\n # get the grade params\n grade_params = Hash.new\n params.each{ |key, value|\n begin\n key = key.to_i\n if key.kind_of?(Fixnum) && key != 0\n grade_params[key] = value\n end\n rescue Error\n # ignore\n end\n }\n grade_params.each{ |key,value|\n as = AssignmentsStudents.find(key.to_i)\n as.grade = value\n as.save\n } \n redirect_to :action => 'index', :controller => 'assignments_students'\n end",
"def assign\n @previous_assignment_count = @costume.costume_assignments.count # gets no. of assignments before updating\n # check if the dance_season or song_name value is empty\n redirect_to_assign_costume_form_if_required_fields_empty and return\n # try to persist to db\n @updated = @costume.update(costume_params)\n # check that if updates, @costume.costume_assignments.count is now greater than count\n redirect_to_assign_costume_form_if_assignment_incomplete and return\n # redirect if updated correctly\n redirect_to_season_assignments_path_if_updated and return\n # redirect if costume assignments are invalid\n redirect_to assign_costume_path(@costume), danger: \"Assignment failure: #{@costume.errors.full_messages.to_sentence}\"\n end",
"def assign\n\n\t@id=params[:id]\n\t@schedule=Schedule.find(@id)\n\tif @schedule.nil?\n\t\tflash[:notice]=\"No schedule by the name: \" && params[:schedule]\n\t\t@schedule=Schedule.last\n\t\treturn\n\tend\n\t@area=@schedule.area\n\tif @area.nil?\n\t\tflash[:error]=\"No area set for the schedule\"\n\t\treturn\n\tend\n\t@shifts=@schedule.shifts.to_a\n\t@volunteers=@area.volunteers.to_a\n\tif @volunteers.empty?\n\t\tflash[:error]=\"No volunteers for this area. Please edit some volunteers.\"\n\t\treturn\n\tend\n\ttaskData=session[:taskData]\n\tif !taskData.nil?\n\t\tflash[:error]=\"Save failed. Logout and restart browser\"\n\tend\n\t@pending=taskData\n\tif request.post?\n\t\t@volunteer = Volunteer.find(params[:vol])\n\telse\n\t\t@volunteer=Volunteer.find(session[:update_vol]) if session[:update_vol]\n\t\tvarea=@volunteer.area\n\t\t@volunteer=nil if (varea.nil?||(varea.id != @area.id))\n\tend\t\n\t\n\tif @volunteer.nil? \n\t\t@volunteer=@volunteers[0]||Volunteer.find(2)\n\tend\n\t@vname=@volunteer.name\n\tsession[:update_vol]=@volunteer.id\n\t\n\t@shift_days=@shifts.group_by{|x| x.start.day}\n\t@locations=Location.where(:area_id => @schedule.area_id)\n\t@x=@locations.size + 1\n\t# count the total number of shifts assigned in the schedule\n\t@assigned=Hash.new 0\n\tvol_shifts=Hash.new []\n\tputs \"shift size *** \"+@shifts.length.to_s\n\t@shifts.each do |s|\n\t\tv=s.volunteer_id\n\t\tif !v.nil?\n\t\t@assigned[v]+=1\n\t\tvol_shifts[v] << s.id\n\t\tend\n\tend\n\t@n_shifts=@assigned[@volunteer.id]\n\t@n_assigned = @assigned.values.sum\n\t#\n\t# get signed up volunteers by year, get all volunteers in an area\n\t# intersection is the list of volunteers for that schedule\n\tvol_by_year=Signup.where(:year => @schedule.year).map{|x| x.volunteer_id}\n\t vol_by_area=@area.volunteers.map{|x| x.id}\n\t vols=vol_by_year & vol_by_area\n\t@arvols=Volunteer.find(vols)\n\t@vol_info=@arvols.map{|i| [i.id, i.name, @assigned[i.id]||0, i.signups.last.early, i.restrictions]}\n\t@droplist=@arvols.map{|i| [i.name, i.id]}\n end",
"def mass_assign_protected_attributes\n @admin.systems_enabled = params[:admin][:systems_enabled] || []\n @admin.active = params[:admin][:active]\n @admin.permissions_attributes = params[:admin][:permissions_attributes] || {}\n @admin.can_act_as_customer = params[:admin][:can_act_as_customer]\n @admin.can_change_prices = params[:admin][:can_change_prices]\n @admin.limited_sales_rep = params[:admin][:limited_sales_rep]\n @admin.updated_by = current_admin.email\n end",
"def edit\n\t\t# @product = Product.new\n\t\tputs params\n @comparison = Comparison.find(params[:id])\n\t\t# @products_hash = Hash.new\n # @tributes_all_hash = Hash.new\n @user = current_user\n\t\t@user.comparisons += [@comparison]\n\t\t# @product = Product.create(url: session[0][:url_hash][:url])\n\t\t# @product = Product.create(url: session[1][:url_hash][:url])\n\t\tputs 'showing the count below 888888888888888888888888888888888888888888888888'\n\t\tputs @comparison.products.count\n\t\tunless @comparison.products.count > 1\n\t\t\tsession[:url_hash].each do |a|\n\t\t\t\t# because this returns the numerical key as a string instead of a key and \"flattens\" the hash\n\t\t\t\t# we loop to access the actual hash that has the url value.\n\t\t\t\tputs 'showing the session a below 888888888888888888888888888888888888888888888888'\n\t\t\t\tputs a\n\t\t\t\ta.each do |b|\n\t\t\t\t\tif b.is_a? Hash\n\t\t\t\t\t\tputs 'showing the session b below 888888888888888888888888888888888888888888888888'\n\t\t\t\t\t\tputs b\n\t\t\t\t\t\t# so b here is {:url => \"google.com\"} for instance.\n\t\t\t\t\t\t# we push because @comparison.products is an array\n\t\t\t\t\t\t@product = Product.create(url: b[:url])\n\t\t\t\t\t\t@comparison.products.push(@product)\n\t\t\t\t\t\t# crunchm!!!!!!!!!\n\t\t\t\t\t\tcrunchm(@comparison, @product, b[:url])\n\t\t\t\t\t\t# puts \"CRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHM\"\n\t\t\t\t\t\t# # puts @crunchm.keys\n\t\t\t\t\t\t# puts \"CRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHM\"\n\n\t\t\t\t\t\t\n\t\t\t\t\t\t# @comparison.tributes.push()\n\t\t\t\t\t\t\n\t\t\t\t\t\t# parseAmazon (b[:url])\n\t\t\t\t\t\t# p = Product.create (url: b[:url], name: name_from_nokogiri)\n\t\t\t\t\t\t# tributes_from_nokogiri.each do |tribute|\n\t\t\t\t\t\t# t = Tribute.create ( tribute attributes )\n\t\t\t\t\t\t# p.tributes.push(t)\n\t\t\t\t\t\t# end\n\t\t\t\t\t\t\n\t\t\t\t\t\t# end\n\n\t\t\t\t\tend\n\t\t\t\tend\t\n\t\t\tend\n\t\telse \n\t\t\tsession[:url_hash].each do |a|\n\t\t\t\t# because this returns the numerical key as a string instead of a key and \"flattens\" the hash\n\t\t\t\t# we loop to access the actual hash that has the url value.\n\t\t\t\tputs 'showing the session a below 888888888888888888888888888888888888888888888888'\n\t\t\t\tputs a\n\t\t\t\ta.each do |b|\n\t\t\t\t\tif b.is_a? Hash\n\t\t\t\t\t\tputs 'showing the session b below 888888888888888888888888888888888888888888888888'\n\t\t\t\t\t\tputs b\n\t\t\t\t\t\t@product = Product.new(url: b[:url])\n\t\t\t\t\t\t# so b here is {:url => \"google.com\"} for instance.\n\t\t\t\t\t\t# we push because @comparison.products is an array\t\t\t\t\t\t\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\t\n\t\t# @product = Product.new(url: 'just a placeholder for now')\n\t\tputs 'looks like it fails right here 888888888888888888888888888'\n\t\t@crunchm = create_table_hash(@comparison)\n\t\tputs 'looks like it fails right here 888888888888888888888888888'\n\t\t@products = current_comparison.products.all\t\t\n\tend",
"def transfer_order_items_from_previous_session\n if session[:cart_id].present? && Cart.find_by(id: session[:cart_id]).order_items.present?\n \n @cart = Cart.first_or_create(user_id: current_user.id)\n \n #we iterate through order_items of the cart which was in previous session, \n #and we add order items to our current_user cart (if order_item is present \n #in current_user cart then we update quantity of that order_item)\n #debugger\n Cart.find_by(id: session[:cart_id]).order_items.each do |order_item|\n if @cart.order_items.find_by(product_id: order_item.product_id).present?\n\n @cart.order_items.find_by(product_id: order_item.product_id).update_attributes(quantity: @cart.order_items.find_by(product_id: order_item.product_id).quantity + order_item.quantity)\n \n else\n \n order_item.update_attributes(cart_id: @cart.id)\n end \n end\n session[:cart_id] = @cart.id\n end\n end",
"def update\n @order = Order.find(params[:id])\n @order.order_items = []\n @order.coupon_code = session[:coupon] if session[:coupon].present?\n session[:coupon] = @order.coupon_code\n @order.update_attributes order_params\n #@order.order_item_ids = params[:order][:order_item_attributes].keys.map {|a| a.to_i}\n calculate_total\n respond_to do |format|\n if @order.save\n session[:coupon] = nil\n format.html { redirect_to(@order, :notice => 'Order was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def permitted_params\n\n \n if action_name.to_s == \"update\" && !current_signed_in_resource.is_admin?\n\n \n params.permit({cart_item: [:discount_code,:quantity]},:id)\n\n elsif action_name.to_s == \"create_multiple\"\n params.permit({discount: [:id, {:product_ids => []}]})\n else\n\n params.permit({cart_item: [:product_id,:discount_code,:quantity]},:id)\n\n end\n\n\n end",
"def process_params(list)\n # Parameters: {\"utf8\"=>\"✓\", \"authenticity_token\"=>\"tGvVyCEfLgpv2xvd2UcSLnhS56lrjAqxg/O5M4DNmiY=\", \"order\"=>{\"products\"=>{\"product0\"=>\"3\", \"quantity0\"=>\"3\", \"product1\"=>\"\", \"quantity1\"=>\"\", \"product2\"=>\"\", \"quantity2\"=>\"\", \"product3\"=>\"\", \"quantity3\"=>\"\", \"product4\"=>\"\", \"quantity4\"=>\"\"}}, \"commit\"=>\"Save changes\", \"id\"=>\"302\"}\n hash = {}\n memory = []\n list[:products].each do |k, value|\n if k[0] == \"p\" && !value.empty?\n hash[value] = nil\n memory[k[-1].to_i] = value.to_i\n elsif k[0] == \"q\" && !value.empty?\n key = memory[k[-1].to_i]\n hash[key] = value if key\n end\n end\n hash\n end",
"def tariff_update\n a=check_user_id_with_session(@tariff.owner_id)\n return false if !a\n @tariff.update_attributes(params[:tariff].each_value(&:strip!))\n @tariff.owner_id = session[:user_id]\n @tariff.save\n flash[:status] = _('Sms_tariff_updated')\n redirect_to :action => 'tariffs'\n end",
"def update\n item_quantities = Array.new\n item_quantities = params[:shopping_cart]\n item_list = Hash.new\n @shopping_cart = ShoppingCart.find(params[:id])\n shopping_cart_hash = eval(@shopping_cart.item_list)\n counter = 0\n shopping_cart_hash.each do |item_id, quantity|\n item_list[item_id] = Integer(item_quantities[counter])\n counter += 1\n end\n params[:shopping_cart] = Hash[\"item_list\" => item_list.to_s]\n respond_to do |format|\n if @shopping_cart.update_attributes(params[:shopping_cart])\n format.html { redirect_to @shopping_cart, notice: 'Shopping cart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shopping_cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assignment_upgrade_params\n params.require(:assignment_upgrade).permit(:oldcmid, :oldinstance, :newcmid, :newinstance, :timecreated)\n end",
"def update_quantity(list_item,quantity,user_list)\n user_list[list_item] = quantity\n user_list\nend",
"def assignpossession\n principal = Party.find(params[:party_id])\n possession = Party.find(params[:possession_id])\n principal.possessions << possession\n Partyrelationship.find_by_principal_id_and_possession_id(principal,possession).update_attributes(:interest => params[:interest])\n \n redirect_to :action => 'relationshipassignment', :party_id => $party_id\n end",
"def modify\n if params[ :eamt ].blank?\n session[ :editmsg ] = \"empty\"\n redirect_to :back\n elsif params[ :etype ].blank?\n session[ :editmsg ] = \"empty type\"\n redirect_to :back\n else\n if params[ :eamt ].to_i == 0\n session[ :editmsg ] = \"number\"\n redirect_to :back\n else\n @expense_details = Expense.find(session[:exp_id].to_i)\n @expense_details.expense_amount = params[ :eamt ]\n @expense_details.expense_desc = params[ :edesc ]\n @expense_details.expense_type = params[ :etype ]\n @expense_details.expense_date = Date::civil(params[ :date_prefix ][ :year ].to_i, params[ :date_prefix ][ :month ].to_i, params[ :date_prefix ][ :day ].to_i)\n @expense_details.save\n session[:exp_dets] = @expense_details\n shared_expense = SharedExpense.find_by_expense_id( session[:exp_id].to_i)\n if shared_expense.nil?\n shared_expense = SharedExpense.new\n shared_expense.user_name = session[ :uname ]\n shared_expense.expense_id = @expense_details.id\n end\n if params[:shuser].blank?\n shared_expense.destroy\n else\n shared_expense.expense_type = params[ :etype ]\n shared_expense.expense_amount = params[ :eamt ]\n shared_expense.expense_date = Date::civil(params[ :date_prefix ][ :year ].to_i, params[ :date_prefix ][ :month ].to_i, params[ :date_prefix ][ :day ].to_i)\n shared_expense.expense_desc = params[ :edesc ]\n shared_expense.shared_user_name = params[:shuser]\n shared_expense.save\n end\n session[:sh_exp] = shared_expense\n session[ :editmsg ]=\"filled\"\n redirect_to :back\n end\n end\n end",
"def update_shift\n\tsh = Shift.find(params[:id])\n \t@schedule=sh.schedule\n \tvol = Volunteer.find(params[:vol])\n\n\tsession[:work].tasks<<[params[:id],params[:vol]]\n\tredirect_to :action => 'assign', :id => sh.schedule.id, :vol=> vol\n end",
"def store!\n session['order'] = unpromoted_order.dump\n end",
"def save_to_session\n\t\t\t\t\tresult = {}\n\t\t\t\t\t\n\t\t\t\t\tif !self.user_id.blank? && !self.role_ref.blank?\n\t\t\t\t\t\tresult[\"user_id\"] = self.user_id\n\t\t\t\t\t\tresult[\"role_ref\"] = self.role_ref\n\t\t\t\t\t\tresult[\"changed\"] = true\n\t\t\t\t\t\n\t\t\t\t\telsif !self.user_id.blank?\n\t\t\t\t\t\tresult[\"user_id\"] = self.user_id\n\t\t\t\t\t\tself.role_ref = self.user.role\n\t\t\t\t\t\tresult[\"role_ref\"] = self.role_ref\n\t\t\t\t\t\tresult[\"changed\"] = true\n\n\t\t\t\t\tend\n\n\t\t\t\t\treturn result\n\t\t\t\tend",
"def details_store(name, pass_encripted, balance, accounts, account_id, trans_array)\n accounts[account_id] = { name: name, password: pass_encripted, balance: balance,transaction:trans_array } \nend",
"def update_quantity_to_cart\n \t\n\n \tproduct_id_ = params[:product_id].to_i\n\n \tsession[\"cart\"].each do |h|\n \t\tif h['id'] == product_id_\n \t\t\th['quantity'] = params[:quantity_update].to_i\n \t\t\th['total'] = h['price'] * h['quantity']\n \t\t\t\n \t\tend\n \tend\n\n \tredirect_to :back\n end",
"def custom_craft_step3\n #first step, we set new session that will store data from step 1, also insert some signal that step 1 has been completed\n @craft = Craft.find_by(:id=>params[:craft_id])\n #custom_craft = session[:custom_craft]\n session[:custom_craft_categories] = params[:category_selected]\n session[:material_selected] = params[:material_selected]\n\n @material = []\n session[:material_selected].each do |x|\n temp = Material.find(x) \n @material << temp\n end\n @categories = Category.all\n @subcategories = Subcategory.all\n @craft_material = @craft.craft_materials.build\n end",
"def update_harman_employee_pricing\n authorize! :update, :harman_employee_pricing\n params[:product_attr].to_a.each do |key, attr|\n product = Product.find(key)\n product.update_attributes(attr)\n end\n redirect_to(harman_employee_pricing_admin_products_path, notice: \"Pricing updated successfully.\")\n end",
"def edit_custom_craft_materials_step2\n #first step, we set new session that will store data from step 1, also insert some signal that step 1 has been completed\n @craft = Craft.find_by(:id=>params[:id])\n @craft_material = CraftMaterial.where(:craft_id => @craft.id)\n @categories = Category.all\n @subcategories = Subcategory.all\n end",
"def edit\n @assignment_parts = Hash.new\n # Retrieve assignment\n @assignment = Relationship.find(params[:id])\n\n # Retrieve each part of assignment (if it exists)\n @assignment_parts[\"purchasers\"] = @assignment[:purchasers].nil? ? nil : Purchaser.find(@assignment[:purchasers])\n @assignment_parts[\"endusers\"] = @assignment[:endusers].nil? ? nil : EndUser.find(@assignment[:endusers])\n @assignment_parts[\"purchaseorders\"] = @assignment[:purchaseorders].nil? ? nil : PurchaseOrder.find(@assignment[:purchaseorders])\n @assignment_parts[\"keys\"] = @assignment[:keys].nil? ? nil : Key.find(@assignment[:keys])\n end",
"def assign_parts(hash={})\n return if hash.nil? or hash == {}\n self.parts = []\n hash ||= {}\n hash.each do |h|\n i = self.vendor.items.visible.find_by_sku(h[:sku])\n if i then\n i.is_part = true\n i.part_quantity = self.string_to_float(h[:part_quantity])\n result = i.save\n if result == false\n raise \"Could not save Item because #{ i.errors.messages }\"\n end\n self.parts << i\n end\n end\n result = self.save\n if result == false\n raise \"Could not save Item because #{ self.errors.messages }\"\n end\n end",
"def update_switches\nif !current_user.admin?\n @tabs = Array.new\n@tabs1 = Array.new\n@mod = Array.new\n @tab1 = current_user.orgtabs\n\n@tab1.each do |id|\n @tabs << id.tabname\n\tend\n\n@tabs.each do |tab|\n@mod << SwitchTab.find_by_module_name_and_user_value(tab,current_user.id)\n\nif !@mod.any?\n@item = SwitchTab.create\n@item.module_name = tab.to_s\n@item.user_value = current_user.id\n\n@item.save\nend\n @mod.clear \nend \n\nend\nend",
"def reassign(step, user)\n # Determine the proper user who should be making the edits\n step_flow = step_flows.find_by(current_step: step)\n target_role = step_flow.current_step_role\n\n # Update the record\n current_step_role\n end",
"def update!(**args)\n @total_billable_characters = args[:total_billable_characters] if args.key?(:total_billable_characters)\n @total_tokens = args[:total_tokens] if args.key?(:total_tokens)\n end",
"def update_harman_employee_pricing\n authorize! :update, :harman_employee_pricing\n Array(params[:product_attr].to_unsafe_h).each do |key, attr|\n product = Product.find(key)\n product.update(attr)\n end\n redirect_to(harman_employee_pricing_admin_products_path, notice: \"Pricing updated successfully.\")\n end",
"def update_quantity\n @shopping_cart = ShoppingCart.find_by_user_id(current_user.id)\n @shopping_cart_hash = eval(params[:item_hash])\n @counter = 0\n error_msg = \"\"\n @shopping_cart_hash.each do |item_id, quantity|\n item = Item.find(Integer(item_id))\n if item.quantity < Integer(params[:change_quantity_item_id][@counter])\n error_msg = \"Sorry! Only #{item.quantity} of #{item.title} is available at the moment\"\n end\n @counter+=1\n end\n @counter = 0\n if error_msg.empty?\n @shopping_cart_hash.each do |item_id, quantity|\n @shopping_cart_hash[item_id.to_s] = Integer(params[:change_quantity_item_id][@counter])\n if !params[:delete_item_id].nil? && (params[:delete_item_id].include? @counter.to_s)\n @shopping_cart_hash.delete(item_id.to_s)\n end\n @counter+=1\n end\n\n @shopping_cart.item_list = @shopping_cart_hash.to_s\n @shopping_cart.save\n\n redirect_to @shopping_cart\n else\n redirect_to @shopping_cart, notice: error_msg\n end\n end",
"def update\n #found_role = Role.where(:id=> UserRoleMap.select(\"role_id\").where(:user_id => @user.id)).first\n # found_roles = Role.getRolesByRoleid(UserRoleMap.getRoleidByUserid(@user.id))\n # found_role = found_roles.to_a[0]\n # @selected_role = found_role.id\n # @user.assign_attributes(:role_id => found_role.id)\n\n # Assign user the selected Roles\n @user.assign_attributes(:role_id => user_params[:role_id])\n\n @disabled=true\n @user.assign_attributes({:first_name => user_params[:first_name],\n :last_name => user_params[:last_name],\n :email => user_params[:email],\n :city_id => user_params[:city_id],\n :phone_no => user_params[:phone_no],\n :address => user_params[:address],\n :manager_id => user_params[:manager_id]\n })\n cost = 10\n encrypted_password = ::BCrypt::Password.create(\"#{user_params[:password]}#{nil}\", :cost => cost).to_s\n @user.assign_attributes(:encrypted_password => encrypted_password, :password => user_params[:password])\n @user.transaction do\n begin\n if @user.save\n UserRoleMap.delete_all(:user_id=> @user.id)\n @reports_tos= ReportsTo.where(:user_id=> @user.id)\n if @reports_tos.present?\n @reports_tos=ReportsTo.delete_all(:user_id=> @user.id)\n end\n assign_managers\n respond_to do |format|\n format.html {redirect_to @user, notice: 'Users was successfully updated.'}\n end\n else\n respond_to do |format|\n format.html {render action: 'edit'}\n populate_user_managers_value(\"\",\"\")\n end \n end\n rescue ActiveRecord::Rollback\n handle_rollback\n end\n end\n end",
"def assign\n @order.assigned_to_id = params[:order][:assigned_to_id]\n @order.reload if @order.save\n render 'status'\n end",
"def assignment_params\n params.require(:assignment).permit(:ref_id, :qty)\n end",
"def update!(**args)\n @promotion_amount = args[:promotion_amount] if args.key?(:promotion_amount)\n @promotion_id = args[:promotion_id] if args.key?(:promotion_id)\n end",
"def update\n @workout_session = WorkoutSession.find(params[:id])\n if !user_is_allowed?(@workout_session)\n redirect_to workout_sessions_path\n return\n end\n\n @workout_session = WorkoutSession.find(params[:id])\n\n @workout_session.date = params[:session][:date]\n\n params[:exercises].each_value do |e|\n e.each_value do |thrill|\n exercise = Exercise.find(thrill[:id])\n ewt = ExercisesWorkoutThrill.find(thrill[:thrill_id])\n ewt.multiplier = thrill[:multiplier]\n ewt.value = thrill[:value]\n\n ewt.save!\n # TODO: recalculate points...\n #award_points_by_thrill(ewt)\n #end\n end\n\n end\n @workout_session.save!\n\n respond_to do |format|\n if @workout_session.save!\n format.html { redirect_to @workout_session, notice: 'Workout session was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout_session.errors, status: :unprocessable_entity }\n end\n end\n end",
"def associate_inventory_units\n params[:return_quantity].each { |variant_id, qty| @return_authorization.add_variant(variant_id.to_i, qty.to_i) }\n end",
"def set_form_vars\n @edit = {}\n @edit[:sm_id] = @sm.id\n @edit[:key] = \"sm_edit__#{@sm.id || \"new\"}\"\n @edit[:new] = {}\n @edit[:current] = {}\n\n @edit[:new][:name] = @sm.name\n @edit[:sm_types] = StorageManager.storage_manager_types\n @edit[:new][:hostname] = @sm.hostname\n @edit[:new][:ipaddress] = @sm.ipaddress\n @edit[:new][:port] = @sm.port\n @edit[:new][:sm_type] = @sm.type_description\n # @edit[:new][:agent_type] = @sm.agent_type\n if @sm.zone.nil? || @sm.my_zone == \"\"\n @edit[:new][:zone] = \"default\"\n else\n @edit[:new][:zone] = @sm.my_zone\n end\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] = @sm.authentication_userid\n @edit[:new][:password] = @sm.authentication_password\n @edit[:new][:verify] = @sm.authentication_password\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 update_quantity(list, upd_item, new_quantity)\n# steps:\n # reassign key (item) a new value (quantity)\n list[upd_item] = new_quantity\n # return list\n list\nend",
"def lcr_update_user\n @user.sms_lcr_id = params[:lcr_id] if session[:usertype] == 'admin'\n @user.sms_tariff_id = params[:tariff_id]\n if @user.save\n Action.add_action_hash(User.current, {:action=>'sms_lcr_changed_for_user', :data=>@user.id, :target_id=>@user.sms_lcr_id, :target_type=>'sms_lcr'} )\n if @user.usertype.to_s == 'reseller' and session[:usertype] == 'admin'\n users = User.find(:all, :conditions=>{:owner_id => @user.id})\n if users and users.size.to_i > 0\n for user in users\n user.sms_lcr_id = params[:lcr_id]\n if user.save\n Action.add_action_hash(User.current, {:action=>'sms_lcr_changed_for_user', :data=>user.id, :target_id=>user.sms_lcr_id, :target_type=>'sms_lcr'} )\n end\n end\n end\n end\n flash[:status] = _('User_updated')\n else\n flash[:notice] = _('User_not_updated')\n end\n redirect_to :action => 'lcr_edit_user', :id => @user.id\n end",
"def update!(**args)\n @owner_email = args[:owner_email] if args.key?(:owner_email)\n @recording_session_id = args[:recording_session_id] if args.key?(:recording_session_id)\n @session_state_info = args[:session_state_info] if args.key?(:session_state_info)\n end",
"def save_session(params, session)\n\t\tsession[:zip] = params[:zip] if params[:zip]\n\t\tsession[:min_price] = params[:min_price].to_i if params[:min_price]\n\t\tsession[:max_price] = params[:max_price].to_i if params[:max_price]\n\t\tsession[:query] = params[:query].split(' ').join('+') if params[:query]\n\tend",
"def update_tally(guid)\n session[:tally][guid] ? session[:tally][guid] += 1 : session[:tally][guid] = 1 \nend",
"def copy_object_to_session(hash)\n flash['session'] ||= {}\n hash.is_a?(Hash) && hash.each { |k,v| flash['session'][k] = v }\n persist_session!\n nil\n end",
"def add_in_cart \n product_id=params[:id].to_i\n @product=Product.find(product_id)\n total_request=1\n update_through_cart=0 \n if params.has_key?(:quant) \n total_request=params[:quant][:total_request].to_i\n update_through_cart=1 \n end \n if(check_availabilty(product_id,total_request,update_through_cart))\n update_session(product_id,total_request,update_through_cart)\n else\n flash[:notice] = \"#{Product.find(product_id).name} is not available in this quantity\" \n end\n end",
"def assign_detail_params\n params.require(:assign_detail).permit(:quantity, :stock_id, :assignation_stock_id)\n end",
"def update\n @masut_assay = MasutAssay.find(params[:id])\n @authorized_user = User.find(session[:user_id])\n respond_to do |format|\n if @masut_assay.update_attributes(params[:masut_assay])\n format.html { redirect_to masut_assays_url, notice: 'Данные анализа качества мазута успешно скорректированы.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @masut_assay.errors, status: :unprocessable_entity }\n end\n end\n end",
"def copy_session_variables!; end",
"def assign_state\n\t\t_username = user_params[:username]\n\t\tuser = User.where(username: _username).first\n\t\tif user.present?\n\t\t\t_role_id = role_params[:role_id]\n\t\t\tuser.role_id = _role_id.presence || user.role_id\n\t\t\t_vendor_id = vendor_params[:vendor_id]\n\t\t\tuser.vendor_id = _vendor_id\n\t\t\tuser.save\n\t\t\tflash[:assignment_status] = \"The role and vendor was successfully updated!\"\n\t\telse\n\t\t\tflash[:assignment_status] = \"The username provided does not exist!\"\n\t\tend\n \t\tredirect_to :administrations\n\tend",
"def assign_params\n account.assign_attributes(account_params)\n account\n end",
"def update_quantity(input_hash, item, qty)\n# steps: use input item as key and input quantity as value\n# output: hash \n input_hash[item] = qty\n \nreturn input_hash\nend",
"def save_to_session(session,key)\n session[key] ||= {}\n ClaimFilter.columns.each do |c|\n session[key][c.name.to_sym] = self.read_attribute(c.name)\n end\n nil\n end",
"def update_junk\n\n #\n ##people = { 1 => { \"first_name\" => \"David\" }, 2 => { \"first_name\" => \"Jeremy\" } }\n ##PurchasesEntries.update(people.keys, people.values)\n #\n #\n #params[:purchase].each do |attributes|\n # logger.warn \"####################################### attributes: \" + attributes.inspect\n # g = \"g\"\n # #purchases_entry = @purchase.purchases_entries.detect {|pe| pe.id == attributes[1][0][:id] }\n # #\n # #@purchase.purchases_entries.each do |pe|\n # # if pe.id == attributes[1][0][:id]\n # #end\n #\n #\n # people = { 1 => { \"first_name\" => \"David\" }, 2 => { \"first_name\" => \"Jeremy\" } }\n # PurchasesEntries.update(people.keys, people.values)\n #\n #\n #\n # logger.warn \"####################################### purchases_entry.id \" + purchases_entry.id.to_s\n # purchases_entry_opposite_entry = purchases_entry.opposite_entry if purchases_entry.opposite_entry != false\n # purchases_entry.attributes = attributes\n # purchases_entry_opposite_entry.attributes = attributes if purchases_entry_opposite_entry\n # purchases_entry.save!(:validate=> false)\n # purchases_entry_opposite_entry.save(:validate=> false) if purchases_entry_opposite_entry\n #\n # purchases_entry.destroy if purchases_entry.QuantityOnOrder <= 0.0\n # if purchases_entry_opposite_entry\n # purchases_entry_opposite_entry.destroy if purchases_entry_opposite_entry.QuantityOnOrder <= 0.0\n # end\n # end\n #\n #\n #\n # delete_purchase_cache\n #\n\n\nend",
"def update_assignment_form(exist_assignment)\n questionnaire_array = assignment_form_params[:assignment_questionnaire]\n questionnaire_array.each { |cur_questionnaire| cur_questionnaire[:assignment_id] = exist_assignment.id.to_s }\n assignment_form_params[:assignment_questionnaire]\n due_array = assignment_form_params[:due_date]\n due_array.each { |cur_due| cur_due[:parent_id] = exist_assignment.id.to_s }\n assignment_form_params[:due_date]\n @assignment_form.update(assignment_form_params, current_user)\n end",
"def update!(**args)\n @session_state_info = args[:session_state_info] if args.key?(:session_state_info)\n @transcription_session_id = args[:transcription_session_id] if args.key?(:transcription_session_id)\n end",
"def edit_reports\n \n # name = params[\"module_name\"]\n #count = params[\"wondersoft\"]\n\n wondersoft_value ={\n purchase_order_count: params[:purchase_order_count], purchase_order_reason: params[:purchase_order_reason], purchase_order_email_reason: params[:purchase_order_email_reason],\n expiry_broken_count: params[:expiry_broken_count], expiry_broken_reason: params[:expiry_broken_reason], expiry_broken_email_reason: params[:expiry_broken_email_reason],\n free_discount_count: params[:free_discount_count], free_discount_reason: params[:free_discount_reason], free_discount_email_reason: params[:free_discount_email_reason],\n purchase_return_count: params[:purchase_return_count], purchase_return_reason: params[:purchase_return_reason], purchase_return_email_reason: params[:purchase_return_email_reason], \n rate_change_count: params[:rate_change_count], rate_change_reason: params[:rate_change_reason], rate_change_email_reason: params[:rate_change_email_reason], \n excess_stock_count: params[:excess_stock_count], excess_stock_reason: params[:excess_stock_reason], excess_stock_email_reason: params[:excess_stock_email_reason], \n pogr_count: params[:pogr_count], pogr_reason: params[:pogr_reason], pogr_email_reason: params[:pogr_email_reason], appointment_count: params[:appointment_count], \n appointment_reason: params[:appointment_reason], appointment_email_reason: params[:appointment_email_reason], claim_issue_count: params[:claim_issue_count], \n claim_issue_reason: params[:claim_issue_reason], claim_issue_email_reason: params[:claim_issue_email_reason], inbox_count: params[:inbox_count], \n inbox_reason: params[:inbox_reason], inbox_email_reason: params[:inbox_email_reason], non_findable_claim_count: params[:non_findable_claim_count], \n non_findable_claim_reason: params[:non_findable_claim_reason], non_findable_claim_email_reason: params[:non_findable_claim_email_reason], report_date: params[:report_date]\n }\n \n wondersoft=RestClient.post $api_service+'/claims/edit_reports',wondersoft_value\n \n end",
"def purchase\n song = Song.find(params[:id])\n if @auth.balance > song.price && song.update_attributes(params[:song]) && @auth.update_attributes(:balance =>(@auth.balance - song.price))\n @auth.mixtapes[0].songs << song if !@auth.mixtapes[0].nil?\n redirect_to mixtapes_path\n else\n redirect_to song_path(song.id)\n end\nend",
"def update_medals\n Medal.transaction do\n updated_medals = fetch_medals\n existing_medals = {}\n \n self.medals.each { |medal| existing_medals[[medal.medal_name_id, medal.playlist_type]] = medal }\n \n updated_medals.each { |medal|\n if existing_medal = existing_medals[[ medal[:medal_name_id], medal[:playlist_type] ]]\n existing_medal.update_attribute(:quantity, medal[:quantity])\n else\n Medal.create({:medal_name_id => medal[:medal_name_id], :quantity => medal[:quantity], :gamertag_id => self.id, :playlist_type => medal[:playlist_type]})\n end\n }\n \n end\n end",
"def update\n notice = ''\n @order = Order.find(params[:id])\n unless current_member.admin or (!@order.paid and !@order.taken)\n store_location\n flash[:notice] = \"Too late to edit that one, bro.\"\n redirect_to orders_path\n end\n\n # remove empty items\n params[:order][:order_details_attributes].each{ |k,v|\n if v[:id].nil?\n params[:order][:order_details_attributes].delete(k) if v[:quantity].to_f == 0.0 or v[:quantity].strip == ''\n next\n end\n\n if v[:quantity].to_f == 0.0 or v[:quantity].strip == ''\n OrderDetail.find(v[:id]).destroy\n params[:order][:order_details_attributes].delete(k)\n end\n }\n\n # combine same-stock entries\n stock_quantities = {}\n params[:order][:order_details_attributes].each{ |k,v|\n sid = v[:stock_id].to_i\n q = v[:quantity].to_f\n if stock_quantities[sid].nil?\n stock_quantities[sid] = q\n else\n stock_quantities[sid] += q\n OrderDetail.find(v[:id]).destroy unless v[:id].nil?\n params[:order][:order_details_attributes].delete(k)\n end\n }\n params[:order][:order_details_attributes].each{ |k,v|\n params[:order][:order_details_attributes][k][:quantity] = stock_quantities[v[:stock_id].to_i]\n }\n \n unless current_member.admin\n @order.member = current_member\n end\n\n old_stock_quantities = {}\n @order.order_details.each{ |od|\n next if od.stock.nil?\n old_stock_quantities[od.stock.id] = od.quantity\n } \n\n # first check to make sure there is enough stock available\n stock_quantities.each{ |sid,q|\n s = Stock.find(sid)\n old_stock_quantities[sid] = 0.0 if old_stock_quantities[sid].nil?\n qmax = s.quantity + old_stock_quantities[sid]\n if s.limited and qmax < stock_quantities[sid]\n unless current_member.admin\n @order.errors.add \"Limited Stock Item:\",\"Sorry, there are only #{qmax} #{s.product.units} #{s.name} remaining and you have tried to order #{stock_quantities[sid]}.\"\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n return false\n else\n notice = \"Limited Stock Item: There were only #{qmax} \n #{s.product.units} #{s.name} remaining, \n but I let you do it anyway since you're the boss!\"\n end\n elsif !s.limited and qmax < stock_quantities[sid]\n notice = \"You ordered more #{s.name} than is currently in stock. It may be some delay before this order item is available for pick up.\"\n end\n }\n\n # add back quantity and then subtract it off again\n @order.order_details.each{ |od|\n next if od.stock.nil?\n od.stock.quantity += od.quantity\n od.stock.save\n }\n if !@order.paid and params[:order][:paid].to_i == 1\n @order.paid_at = Time.now\n @order.marked_paid_by = current_member\n @order.save\n end\n\n if !@order.taken and params[:order][:taken].to_i == 1\n @order.taken_at = Time.now\n @order.archived = true\n @order.save\n end\n\n # delete items before we add back the new ones\n @order.order_details = []\n @order.save \n\n respond_to do |format|\n \n if @order.update_attributes(params[:order])\n @order.order_details.each{ |od|\n next if od.stock.nil?\n od.stock.quantity -= od.quantity\n od.stock.save\n if @order.archived\n od.archived_name = od.stock.name\n od.archived_cost = od.stock.final_cost\n od.archived_supplier = od.stock.supplier\n od.archived_product = od.stock.product\n od.archived_markup_pct = od.stock.markup_pct\n od.archived_markup_const = od.stock.markup_const\n end\n od.save\n }\n format.html { redirect_to(orders_path, :notice => \"Order was successfully updated. #{notice}\") }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def fetch_shared_assignment_info\n if costume_assignments_attributes.nil?\n # studio doesn't have any current dancers\n @assignment_info = {'dance_season'=>'', 'song_name'=>'', 'genre'=>'', 'hair_accessory'=>'', 'shoe'=>'', 'tight'=>''}\n else\n @assignment_info = costume_assignments_attributes.permit!.to_h.first.pop\n # => {\"dance_season\"=>\"\", \"song_name\"=>\"\", \"genre\"=>\"\", \"hair_accessory\"=>\"\", \"shoe\"=>\"\", \"tight\"=>\"\"}\n @dance_season_empty = @assignment_info[:dance_season].empty?\n @song_name_empty = @assignment_info[:song_name].empty?\n end\n end",
"def update\n Log.new({user: current_user.user, \n subject: \"user:\"+@assigned.grantee,\n operation: \"modified access\",\n object: \"table:\"+@assigned.relation,\n parameters: \"canGrant:\"+@assigned.can_grant.to_s\n }).save\n\n respond_to do |format|\n if @assigned.update(assigned_params)\n format.html { redirect_to @assigned, notice: 'Assigned was successfully updated.' }\n format.json { render :show, status: :ok, location: @assigned }\n else\n format.html { render :edit }\n format.json { render json: @assigned.errors, status: :unprocessable_entity }\n end\n end\n end",
"def securityquestion_submit\n @securityhash = Hash.new()\n @securityhash[:security_answer] = BCrypt::Engine.hash_secret( user_params[:security_answer], @user[:salt])\n @securityhash[:security_question] = user_params[:security_question]\n if @user.update_attributes( @securityhash)\n flash[:notice] = \"Succeessfully Updated Your Security Question and Answer\"\n redirect_to(profile_user_path (@user))\n else\n flash[:error] = \"Could not save your security question and answer. Please try again\"\n puts @user.errors.inspect\n redirect_to securityquestion_user_path(@user)\n end\n end",
"def trans(inventory, transfer_id, inventory_type)\n @inventory_log = InventoryLog.create!(inventory_type_id: params[:transfer][:id] )\n @inventory_update = Inventory.find(params[:inventory])\n @inventory_update.transfer.inventory_type.inventories.each do |i|\n if @inventory_update.part_no == i.part_no\n value = i.warehouse_stock_qty\n final = value.to_i - params[:transfer_item].to_i\n # stock = final + i.engineer_stock_qty.to_i\n i.update(warehouse_stock_qty: final) \n tot = final + i.engineer_stock_qty.to_i\n i.update(total_stock_qty: tot)\n end\n end\n @inventory.inventories.each do |f|\n if @inventory_update.part_no == f.part_no\n value = f.warehouse_stock_qty\n final = value.to_i + params[:transfer_item].to_i\n f.update(warehouse_stock_qty: final) \n tot = final + f.engineer_stock_qty.to_i\n f.update(total_stock_qty: tot)\n end\n end\n @inv = Inventory.create!(branch: @inventory_update.branch, part_no: @inventory_update.part_no, description: @inventory_update.description, warehouse_stock_qty: params[:transfer_item].to_i, transfered_stock_qty: params[:transfer_item].to_i, engineer_stock_qty: @inventory_update.engineer_stock_qty,location1: @inventory_update.location1,location2:@inventory_update.location2, location3: @inventory_update.location3,map: @inventory_update.map,total_stock_value: @inventory_update.total_stock_value,status: @inventory_update.status, latest_modify_date: @inventory_update.latest_modify_date,remark: @inventory_update.remark, inventory_type_id: @inventory.id, transfer_id: @transfer.id)\n total_stock_qty1 = @inv.warehouse_stock_qty.to_i + @inv.engineer_stock_qty.to_i\n @inv.update(total_stock_qty: total_stock_qty1 )\n\n end",
"def update\n # check if there is an existing assignment\n form = record\n if form.nil?\n render 'shared/http_status', locals: { code: '404', message:\n 'Grade Entry Form not found' }, status: :not_found\n return\n end\n\n ApplicationRecord.transaction do\n update_params = params.permit(*DEFAULT_FIELDS)\n unless form.update(update_params)\n render 'shared/http_status', locals: { code: '500', message:\n form.errors.full_messages.first }, status: :internal_server_error\n raise ActiveRecord::Rollback\n end\n\n position = form.grade_entry_items.count\n params[:grade_entry_items]&.each do |column_params|\n if column_params[:id].nil?\n column_params = column_params.permit(:name, :out_of, :bonus).to_h.symbolize_keys\n grade_item = form.grade_entry_items.build(**column_params, position: position += 1)\n unless grade_item.save\n render 'shared/http_status', locals: { code: '500', message:\n grade_item.errors.full_messages.first }, status: :internal_server_error\n raise ActiveRecord::Rollback\n end\n else\n column_params = column_params.permit(:id, :name, :out_of, :bonus).to_h.symbolize_keys\n grade_item = form.grade_entry_items.where(id: column_params[:id]).first\n if grade_item.nil?\n render 'shared/http_status', locals: { code: '404', message:\n \"Grade Entry Item with id=#{column_params[:id]} not found\" }, status: :not_found\n raise ActiveRecord::Rollback\n end\n unless grade_item.update(column_params)\n render 'shared/http_status', locals: { code: '500', message:\n grade_item.errors.full_messages.first }, status: :internal_server_error\n raise ActiveRecord::Rollback\n end\n end\n end\n render 'shared/http_status', locals: { code: '200', message:\n HttpStatusHelper::ERROR_CODE['message']['200'] }, status: :ok\n end\n end",
"def params=(hash); end",
"def params=(hash); end",
"def update!(**args)\n @total_actions = args[:total_actions] if args.key?(:total_actions)\n end",
"def update_qty(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend",
"def update_queue_items\n ActiveRecord::Base.transaction do\n params[:queue_items].each do |queue_item_data|\n #queue_item = QueueItem.find(queue_item_data[\"id\"])\n #queue_item.update_attributes!(position: queue_item_data[\"position\"]) if queue_item.user == current_user\n queue_item = current_user.queue_items.find_by(id: queue_item_data[\"id\"])\n # In rails4 update! is preferred than update_attributes! \n queue_item.update!(position: queue_item_data[\"position\"], rating: queue_item_data[\"rating\"]) if queue_item\n end\n end\n end",
"def update_quantity(hash, item_name, quantity)\r\n hash[item_name] = quantity\r\n hash\r\nend",
"def assign_groups_to_reviews\n\n # Go through the parameters and extract the role id and review id\n # from the keys.\n params[:review_type].each { | key, value |\n\n role_id, review_type_id = key.split('_')\n\n role = Role.find(role_id)\n review_type = ReviewType.find(review_type_id)\n\n if review_type.roles.include?(role)\n\t review_type.roles.delete(role) if value == '0'\n else\n\t review_type.roles << role if value == '1'\n end\n }\n\n flash['notice'] = 'Assignments have been updated'\n redirect_to(:action => 'review_type_role_assignment')\n\n end",
"def update!(**args)\n @successful_actions = args[:successful_actions] if args.key?(:successful_actions)\n @total_actions = args[:total_actions] if args.key?(:total_actions)\n end",
"def updated_quantity(list, item_name, quantity)\r\n\tlist[item_name] = quantity\r\n\tlist\r\nend",
"def setInputsInSession()\n session[:dayComboId] = params[\"conflict_checker\"][\"day_combinations_id\"]\n session[:timeRanges] = params[\"conflict_checker\"][\"time_ranges\"]\n session[:buildingId] = params[\"conflict_checker\"][\"buildings_id\"]\n end",
"def update\n check_for_update(@auth_shopping_cart_item)\n @auth_shopping_cart_item.assign_attributes(@auth_shopping_cart_item_params)\n @auth_shopping_cart_item = add_owner_and_signed_in_resource(@auth_shopping_cart_item) \n @auth_shopping_cart_item.save\n puts @auth_shopping_cart_item.errors.full_messages.to_s\n respond_with @auth_shopping_cart_item\n end",
"def update_quant(current_list, item, quantity)\n current_list[item] = quantity\n current_list\nend",
"def update_assignment_queue\n return unless @training_request&.assigned_to_user_id\n\n # Find the queue entry for the user in the queue\n queue_entry = AssignmentQueue.queue.detect do |q|\n q.user_id == @training_request.assigned_to_user_id\n end\n\n AssignmentQueue\n .update(queue_entry.id, status: 'ASSIGNED',\n training_request_id: @training_request.id)\n end",
"def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @os_policy_assignment_reports = args[:os_policy_assignment_reports] if args.key?(:os_policy_assignment_reports)\n end",
"def update_other_tables\n # unassigned eobs will not have a link to insurance billings.\n # if the status is greater than paid, leave it alone.\n # if the status is paid, we need to still update the session. a manual second eob may be entered.\n if !self.insurance_billing_id.blank? && self.insurance_billing.status < BillingFlow::PAID\n # eob has been received, so mark the claim as paid\n # this triggers the updating of the balance owed; also triggers the updating of manage care records if any\n self.insurance_billing.update_attributes(:status => BillingFlow::PAID, :updated_user => (self.updated_user.blank? ? self.created_user : self.updated_user))\n # re-calc all the fields belonging to the session.\n begin\n self.insurance_billing.insurance_session.save!\n rescue Exception => e\n self.insurance_billing.insurance_session.update_attributes(:status => self.insurance_billing.secondary_status)\n end\n end\n end",
"def update_multiple\n RankItem.update(params[:rank_items].keys, params[:rank_items].values)\n flash[:success] = \"Score updated successfully.\"\n portfolio = Portfolio.find(params[:portfolio_id])\n selection_action = find_action(portfolio)\n redirect_to controller: :selections, action: selection_action\n end",
"def bulk_update\n if current_user\n @user = User.find(current_user.id) # TODO: is it necessary to find user? \n @product_details = @user.product_details \n end\n end",
"def assignment_form_save_handler\n exist_assignment = Assignment.find_by(name: @assignment_form.assignment.name)\n assignment_form_params[:assignment][:id] = exist_assignment.id.to_s\n fix_assignment_missing_path\n update_assignment_form(exist_assignment)\n aid = Assignment.find_by(name: @assignment_form.assignment.name).id\n ExpertizaLogger.info \"Assignment created: #{@assignment_form.as_json}\"\n redirect_to edit_assignment_path aid\n undo_link(\"Assignment \\\"#{@assignment_form.assignment.name}\\\" has been created successfully. \")\n end",
"def card_assignment_params\n params.fetch(:card_assignment, {})\n end",
"def increase_pets_sold(shop, sold_amount)\n shop[:admin][:pets_sold] += sold_amount\nend",
"def update\n # Find the assignment and update it\n entry = Relationship.find(params[:id])\n entry.update_attributes(assignment_parameters)\n \n @active=\"assignments\"\n redirect_to \"/manage\"\n end",
"def edit\r\n if request.get? #GET\r\n @ses = get_object\r\n else #POST\r\n @ses = get_object\r\n begin\r\n TrainingSession.transaction do\r\n @ses.training_sets.clear #hace un delete y un update por cada TS, cambiar por un delete where session_id=x\r\n @ses.build_training_sets_from_hash!(params[:set],current_user) if params[:set]\r\n if @ses.update_attributes(params[:ses])\r\n flash[:notice] = \"Training session data updated.\"\r\n else\r\n raise Exception, \"Error saving training session, rolling back\"\r\n end\r\n end\r\n rescue\r\n log_error($!) if logger\r\n flash[:error] = \"Error saving training session.\"\r\n ensure\r\n redirect_to(:action => \"index\")\r\n end\r\n end\r\n end",
"def update_user_params(params)\n if params[:reassign_user].present?\n if (params[:user_type] == \"CommonPoolAgent\" or params[:user_type] == \"ClusterUsers\") and params[:task][:assigned_to_user_id] ==\"\"\n params[:task].delete(:assigned_to_user_id)\n elsif (params[:user_type] == \"CommonPool\")\n params[:task].merge!(:assigned_to_user_id => \"\")\n end\n unless params[:task][:assigned_to_user_id].blank?\n params[:task][:assigned_by_user_id] = current_user.id\n end\n else\n params[:task].delete(:assigned_to_user_id)\n end\n params\n end",
"def update_code_assignments\n if code_assignment_amounts\n code_assignments.delete_all\n code_assignment_amounts.delete_if { |key,val| val.empty?}\n selected_codes = code_assignment_amounts.nil? ? [] : code_assignment_amounts.keys.collect{ |id| Code.find_by_id(id) }\n selected_codes.each { |code| self.code_assignments << CodeAssignment.new( :activity => self, :code => code, :amount => code_assignment_amounts[code.id.to_s]) }\n end\n end",
"def update_session_statistics\n @session_travel_distance += @mission.travel_distance\n @missions_aborted += 1 if @mission.aborted?\n @explosions += 1 if @mission.exploded?\n @session_fuel_burned += @mission.fuel_burned\n @session_flight_time += @mission.flight_time\n end",
"def set_update_values(link_hash)\n\thash = CreateHash.read_hash_file(link_hash[\"asset\"])\n\tnew_hash = {}\n\tnew_hash.store(\"Asset Number\", hash[\"fields\"][\"Asset Number\"])\n\tnew_hash.store(\"Purchase Date\", hash[\"fields\"][\"Purchase Date\"])\n\tnew_hash.store(\"Purchase Cost\", hash[\"fields\"][\"Purchase Cost\"])\n\tnew_hash.store(\"Supplier\", hash[\"fields\"][\"Supplier\"])\n\tnew_hash.store(\"Order Number\", hash[\"fields\"][\"Order Number\"])\n\treturn new_hash\nend",
"def edit_params_setting\n @assignment = Assignment.find(params[:id])\n @num_submissions_round = @assignment.find_due_dates('submission').nil? ? 0 : @assignment.find_due_dates('submission').count\n @num_reviews_round = @assignment.find_due_dates('review').nil? ? 0 : @assignment.find_due_dates('review').count\n\n @topics = SignUpTopic.where(assignment_id: params[:id])\n @assignment_form = AssignmentForm.create_form_object(params[:id])\n @user = current_user\n\n @assignment_questionnaires = AssignmentQuestionnaire.where(assignment_id: params[:id])\n @due_date_all = AssignmentDueDate.where(parent_id: params[:id])\n @due_date_nameurl_not_empty = false\n @due_date_nameurl_not_empty_checkbox = false\n @metareview_allowed = false\n @metareview_allowed_checkbox = false\n @signup_allowed = false\n @signup_allowed_checkbox = false\n @drop_topic_allowed = false\n @drop_topic_allowed_checkbox = false\n @team_formation_allowed = false\n @team_formation_allowed_checkbox = false\n @participants_count = @assignment_form.assignment.participants.size\n @teams_count = @assignment_form.assignment.teams.size\n end",
"def update!(**args)\n @session_segment = args[:session_segment] if args.key?(:session_segment)\n @name = args[:name] if args.key?(:name)\n @user_segment = args[:user_segment] if args.key?(:user_segment)\n end",
"def update!(**args)\n @finalize_enrollment_time = args[:finalize_enrollment_time] if args.key?(:finalize_enrollment_time)\n @hashing_algorithm = args[:hashing_algorithm] if args.key?(:hashing_algorithm)\n @period_sec = args[:period_sec] if args.key?(:period_sec)\n @session_info = args[:session_info] if args.key?(:session_info)\n @shared_secret_key = args[:shared_secret_key] if args.key?(:shared_secret_key)\n @verification_code_length = args[:verification_code_length] if args.key?(:verification_code_length)\n end",
"def update_season_assignments\n @costume.update(costume_params)\n\n redirect_to season_assignments_path(@costume, season: costume_assignments_attributes.values[0].values[0])\n end",
"def adding\n shipping_manifest = {\n \"whale bone corsets\" => 5, \n \"porcelain vases\" => 2, \n \"oil paintings\" => 3\n }\nshipping_manifest[\"muskets\"] = 2\nshipping_manifest[\"gun powder\"]= 4\nshipping_manifest\nend",
"def update\n @assign_stage.update(assign_stage_params)\n end",
"def update_quantity (item,list, quantity)\n list[item] = quantity\nlist\nend",
"def smash_report_params\n params.require(:smash_report).permit(:submitted_by, :approved, :smash_setting_id, :game, :filename, :hash, :record_count, :smash_version, :notes, :approved_at)\n end",
"def update\n #@auth_assign_permit = Auth::AssignPermit.find(params[:id])\n if current_user.admin_group?\n @admin_user = current_user\n @owner_user = User.find(params[:id])\n\n respond_to do |format|\n if @owner_user.update_attributes(params[:user])\n format.html { redirect_to auth_assign_permit_path(@owner_user), notice: 'Assign permit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @auth_assign_permit.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update_copy_session\n @user = current_user\n session[:copy_flag] = true\n end",
"def update_quantity(list, item, qty)\n list[item] = qty\n list\nend",
"def add_assignment(assignment_symbol, user)\n past_assignments = GroupLoanAssignment.find(:all, :conditions => {\n :group_loan_id => self.id,\n :assignment_type => GROUP_LOAN_ASSIGNMENT[assignment_symbol],\n :user_id => user.id \n })\n \n if past_assignments.count > 0 \n puts \"The past assignment value is #{past_assignments.count}\"\n puts \"The user email is :#{user.email} \"\n puts \"past_assignments.first.inspect: #{past_assignments.first.inspect}\"\n return nil\n else\n puts \"we are gonna create the new one\"\n return GroupLoanAssignment.create(\n :group_loan_id => self.id,\n :assignment_type => GROUP_LOAN_ASSIGNMENT[assignment_symbol],\n :user_id => user.id\n )\n end\n end"
] | [
"0.5585577",
"0.55624104",
"0.5513046",
"0.55000865",
"0.54717654",
"0.5445686",
"0.53606796",
"0.5336261",
"0.53207535",
"0.53205603",
"0.531966",
"0.53177094",
"0.5307758",
"0.52890116",
"0.5272111",
"0.52651477",
"0.5249088",
"0.5246537",
"0.5228947",
"0.52206343",
"0.52088255",
"0.5207322",
"0.51980364",
"0.51936084",
"0.51686615",
"0.5165416",
"0.51601034",
"0.5152033",
"0.5151697",
"0.51498705",
"0.51446986",
"0.5136448",
"0.51239073",
"0.51133215",
"0.5113122",
"0.5108258",
"0.510305",
"0.5090179",
"0.50680315",
"0.50665957",
"0.5046743",
"0.50414747",
"0.50359493",
"0.50344914",
"0.50300485",
"0.5024007",
"0.5012686",
"0.5010339",
"0.50078976",
"0.50064665",
"0.50031877",
"0.49999318",
"0.49872816",
"0.49871087",
"0.49802294",
"0.49801114",
"0.49671492",
"0.49541968",
"0.49449223",
"0.49396354",
"0.49284762",
"0.49253505",
"0.49238172",
"0.49234986",
"0.49234986",
"0.49229914",
"0.4916789",
"0.49165738",
"0.49153483",
"0.49130785",
"0.49108446",
"0.49103138",
"0.49087834",
"0.49075675",
"0.4906208",
"0.49061963",
"0.49022177",
"0.4896999",
"0.48964518",
"0.4894828",
"0.48887905",
"0.4885895",
"0.4883649",
"0.4882186",
"0.48817655",
"0.48747036",
"0.48697492",
"0.4868212",
"0.48675704",
"0.48670006",
"0.48656622",
"0.48653257",
"0.48646623",
"0.48638356",
"0.48635608",
"0.4863382",
"0.48616275",
"0.48571378",
"0.48568535",
"0.48566046",
"0.48553297"
] | 0.0 | -1 |
Quantities management Product scoped quantity update | def set_quantity product_id, quantity, options = {}
options.reverse_merge!(override: false)
quantity = quantity.to_i
return unless quantity > 0
# If product was in cart
if (product = self.product(product_id))
if options[:override]
product.quantity = quantity
else
product.quantity += quantity
end
else
@products << Glysellin::Cart::Product.new(
id: product_id,
quantity: quantity
)
end
# Refresh discount code adjustment
self.discount_code = discount_code
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_product_qty\n @order = Spree::Order.find_by_id(params[:order_id])\n @line_item = Spree::LineItem.find_by_id(params[:line_item_id])\n request_to_update_qty = params[:quantity].to_i\n # code to find the order_total\n if @order.market_place.present?\n case @order.market_place.code\n when \"qoo10\"\n order_total = @order.market_place_details.present? ? @order.market_place_details[\"total\"] : @order.total\n when \"lazada\", 'zalora'\n order_total = @order.total\n end\n end\n if @line_item.present?\n prev_qty = @line_item.quantity.to_i\n final_qty = prev_qty - request_to_update_qty\n @variant = @line_item.variant\n @product = @variant.product if @variant.present?\n # code to update line item\n @line_item.update_column(:quantity, request_to_update_qty)\n @sellers_market_places_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", @order.seller_id, @order.market_place_id, @product.id).try(:first)\n if @sellers_market_places_product.present?\n @stock_product = Spree::StockProduct.where(\"sellers_market_places_product_id=? AND variant_id=?\", @sellers_market_places_product.id, @variant.id).try(:first)\n if @stock_product.present?\n @stock_product.update_attributes(:count_on_hand=>(@stock_product.count_on_hand + final_qty.to_i) >= 0 ? (@stock_product.count_on_hand + final_qty.to_i) : 0)\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity + final_qty.to_i) >= 0 ? (@variant.fba_quantity + final_qty.to_i) : 0) if !@variant.quantity_inflations.present?\n msg = 'Admin/Orders Controller update_product_qty '\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n end\n end\n end\n # code to update order total after creating line item for order\n @order.update_column(:total, order_total)\n @order.reload\n line_items = @order.line_items\n respond_to do |format|\n format.html { render :partial=>\"modify_shipping\", :locals => { :line_items => line_items }}\n end\n end",
"def update_quantity token, cart_id, product_code, qty = 1\n\tend",
"def update_product\n if inbound_order? || quantity_adjustment?\n product.update(stock: product.stock + quantity)\n else outbound_order?\n product.update(stock: product.stock - quantity)\n end\n end",
"def set_product_quantities(quantities)\n quantities.each_pair do |product_id, quantity|\n quantity = quantity.to_i\n if quantity < 1\n BasketItem.where(basket_id: id, product_id: product_id).destroy_all\n else\n item = BasketItem.find_by(basket_id: id, product_id: product_id)\n if item\n item.quantity = quantity\n item.save\n else\n BasketItem.create(basket_id: id, product_id: product_id, quantity: quantity)\n end\n end\n end\n end",
"def update_quantity\n product = Product.find_by_title(params[:product_title])\n order_item = OrderItem.find_by(product: product)\n if params[:quantity_of_products].present? && product.present?\n if product.quantity_products + order_item.quantity >= params[:quantity_of_products].to_i\n order_item.update_quantity_product(params[:quantity_of_products], true)\n order_item.order.update_total_price_cents(nil)\n redirect_to cart_path, notice: \"Количество товара #{params[:product_title]} было обновлено до #{params[:quantity_of_products]}\"\n else\n redirect_to cart_path, notice: \"Простите, вы не можите купить этот товар количеством в #{params[:quantity_of_products].to_i} так как их всего #{product.quantity_products}\"\n end\n end\n end",
"def update_quantities!\n @products = products.reduce([]) do |products, product|\n # If product is not published\n if !product.variant.published\n set_error(:item_not_for_sale, item: product.variant.name)\n # If product is not in stock\n elsif !product.variant.in_stock?\n set_error(:item_out_of_stock, item: product.variant.name)\n # If product's available stock is less than required quantity\n elsif !product.variant.available_for(product.quantity)\n set_error(\n :not_enough_stock_for_item,\n item: product.variant.name, stock: product.variant.in_stock\n )\n product.quantity = product.variant.in_stock\n products << product if product.quantity > 0\n # Else, keep product as is in cart\n else product.variant.unlimited_stock || product.variant.in_stock >= product.quantity\n products << product\n end\n\n products\n end\n\n # TODO: Doesn't work, think in something else ...\n if discount_code == false\n set_error(:invalid_discount_code)\n end\n\n reset! if @products.length == 0\n end",
"def update_cart\n product = Product.find_by_cs_sku(params[:sku])\n item = ReservedItem.where('user_id = ? and product_id = ? and session_id = ?', current_user.id,\n product.id,\n session.id).first\n qty = BigDecimal.new(get_qty)\n\n if available?(product, item, qty)\n product.update_attribute(:qty, (product.qty + item.qty) - qty)\n item.update_attribute(:qty, qty)\n respond_with_format { @cart.update_item(params[:sku], get_qty) }\n else\n flash[:error] = 'Not enough item in inventory'\n respond_with_format\n end\n end",
"def update_product_on_order\n prod_id = params[:id].to_i\n qty_to_order = params[:qty].to_i\n\n add_or_update_product_qty(prod_id, qty_to_order)\n\n flash[:notice] = 'Updated qty in cart'\n redirect_back(fallback_location: cart_path)\n end",
"def change_inventory\n order_item_obj = OrderItem.last\n product_id = order_item_obj.product_id\n inventory_of_ordered_product = InventoryStock.where(product_id:product_id)\n quantity_in_inventory = inventory_of_ordered_product[0].quantity\n quantity_in_ordered_item = order_item_obj.quantity\n updated_quantity_in_inventory = quantity_in_inventory.to_i-quantity_in_ordered_item.to_i\n InventoryStock.where(product_id:product_id).update(quantity: updated_quantity_in_inventory)\n end",
"def update_quantity(quantity)\n if quantity != self.quantity\n old_cost = self.extra_cost || 0\n transaction do\n self.quantity = quantity\n self.extra_cost = self.extra_unit_cost * quantity\n self.save\n shopping_cart.extras_cost += (self.extra_cost - old_cost)\n shopping_cart.calculate_cost(false, false)\n shopping_cart.save\n end\n end\n end",
"def update_product(a_product, quantity, options={})\n return remove(a_product, options) if quantity <= 0\n item = find(:first, a_product)\n item.quantity = quantity if item\n item\n end",
"def set_quantity\n @subscription.quantity += 1 if @subscription.persisted?\n end",
"def update_quantity\n @id=params[:id]\n @quantity=params[:quantity]\n CartItem.where(:cart_id =>@@cartId ,:product_id => @id).limit(1).update_all(:quantity => @quantity) \n redirect_to \"/carts\"\n end",
"def deduct_quantity\n line_items.each do |i|\n i.product.current_stock -= i.quantity\n i.product.save\n end\n end",
"def increment_quantity\n self.quantity_needed += self.quantity\n save\n end",
"def update\n @product = TempProduct.find(params[:id])\n @product.qty = params[:qty]\n # save product\n if @product.save\n # success\n render :json => { :success => true }\n else\n # failed\n render :json => { :success => false }\n end\n end",
"def update_quantity(quantity)\n\n if quantity != self.quantity\n\n old_quantity = self.quantity || 0\n old_item_cost = self.item_cost || 0\n old_item_deposit = self.product_deposit_cost || 0\n old_category_supplement_1_cost = self.category_supplement_1_cost || 0\n old_category_supplement_2_cost = self.category_supplement_2_cost || 0\n old_category_supplement_3_cost = self.category_supplement_3_cost || 0\n\n transaction do\n\n # Update the item\n self.quantity = quantity\n self.item_cost = (self.item_unit_cost || 0) * quantity\n self.product_deposit_cost = (self.product_deposit_unit_cost || 0) * quantity\n self.category_supplement_1_cost = (self.category_supplement_1_unit_cost || 0) * quantity\n self.category_supplement_2_cost = (self.category_supplement_2_unit_cost || 0) * quantity\n self.category_supplement_3_cost = (self.category_supplement_3_unit_cost || 0) * quantity\n self.save\n\n # Update the shopping cart cost\n self.shopping_cart_item_cost_variation(old_item_cost, \n old_item_deposit, \n old_category_supplement_1_cost,\n old_category_supplement_2_cost,\n old_category_supplement_3_cost)\n self.shopping_cart.calculate_cost(false, true)\n\n begin\n self.shopping_cart.save\n rescue DataMapper::SaveFailureError => error\n p \"Error saving shopping cart: #{self.shopping_cart.errors.full_messages.inspect}\"\n raise error\n end\n\n # Add or shopping cart item resources\n if quantity < old_quantity\n (quantity..(old_quantity-1)).each do |resource_number|\n self.item_resources[quantity].destroy unless self.item_resources[quantity].nil?\n self.item_resources.reload\n end\n elsif quantity > old_quantity\n product = ::Yito::Model::Booking::BookingCategory.get(item_id)\n (old_quantity..(quantity-1)).each do |resource_number|\n shopping_cart_item_resource = ShoppingCartItemResourceRenting.new\n shopping_cart_item_resource.item = self\n shopping_cart_item_resource.pax = product.capacity unless product.nil?\n shopping_cart_item_resource.save\n end\n end\n\n end\n end\n end",
"def update_qty(shopping_list, item, quantity)\r\n\r\n\tadd_item(shopping_list, item, quantity)\r\n\r\nend",
"def update\n if params[:commit] == 'Add'\n current_quantity = params[:product_quantity].to_i + 1\n stock_status = @line_item.product.has_enough_products(current_quantity)\n update_quantity(stock_status, \"add\")\n end\n\n if params[:commit] == 'Reduce'\n if params[:product_quantity].to_i > 1 #at least 1\n current_quantity = params[:product_quantity].to_i - 1\n stock_status = @line_item.product.has_enough_products(current_quantity)\n update_quantity(stock_status, \"reduce\")\n else #1\n @notice = \"Only one in your cart. You can only remove it.\"\n @add_class = \"alert-danger\"\n end\n end\n\n respond_to do |format|\n format.js\n end\n\n # respond_to do |format|\n # if @line_item.update(line_item_params)\n # format.html { redirect_to @line_item, notice: 'Line item was successfully updated.' }\n # format.json { render :show, status: :ok, location: @line_item }\n # else\n # format.html { render :edit }\n # format.json { render json: @line_item.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def quantity=(q)\n delta = quantity - q\n self.quantity_consumed += delta\n save\n end",
"def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend",
"def stock_minus(product, amount)\n product = Product.find(product)\n quantity = product.quantity\n quantity -= amount.to_i\n product.update(quantity: quantity)\n end",
"def update_quantity\n\t\t@user_basket = UserBasket.find(params[:id])\n\t\t@shop_product = ShopProduct.find_by(id: @user_basket.shop_product_id)\n\t @user_basket.quantity = params[:user_basket][:quantity].to_f\n\n\t # for checking quantity exists in shop_inventory\n\t if @shop_product.shop_inventory.quantity - @user_basket.quantity < 0\n\t\t\tflash[:danger] = 'Insufficient Quantity'\n\t\t\tredirect_to edit_user_basket_path and return\n\t\tend\n\n\t\tif (@shop_product.unit_type == 'packet' or @shop_product.unit_type == 'pcs') and \n\t\t\t@user_basket.quantity % 1 != 0\n\t\t\tflash[:danger] = 'Please enter whole numbers for packed products'\n\t\t\tredirect_to edit_user_basket_path and return\n\t\tend\n\n\t\tif @user_basket.update_attributes(user_baskets_params)\n\t\t\tflash[:success] = 'Quantity Updated'\n\t\t\tredirect_to edit_user_basket_path\n\t\telse\n\t\t flash[:danger] = 'Not Updated'\n\t\t\tredirect_to edit_user_basket_path\n\t\tend\t\n\tend",
"def increment_units\n contents.each do |key,content|\n id = content[\"_id\"] || content[\"item_id\"]\n begin\n \n product = shop.products.find(id)\n return false if product.nil? || product.dont_track_quantities?\n\n new_pv = []\n\n if product.price_variants.length==1\n\n new_pv = product.price_variants.first\n new_pv['quantity'] = new_pv['quantity'].to_i+content['quantity'].to_i\n product.num_orders = [product.num_orders-content['quantity'].to_i].max\n product.price_variants = [ new_pv ]\n\n else\n\n product.price_variants.each do |pv|\n name = [pv['primary'],pv['secondary']].join(\" \").downcase.trim\n name = \"\" if name==\" \"\n if name==content['variant_name'].trim.downcase && !pv['quantity'].blank?\n new_pv << pv.merge( 'quantity' => (pv['quantity'].to_i+content['quantity'].to_i) )\n else \n new_pv << pv\n end\n end\n product.num_orders = [product.num_orders-content['quantity'].to_i].max\n product.price_variants = new_pv\n\n end\n product.save\n\n rescue Exception => e\n ::Exceptional::Catcher.handle(e)\n # raise(e)\n end\n end\n end",
"def update_product_amounts\n commits = Commit.where(:product_id => self.product_id)\n price_with_fee = commits.collect(&:sale_amount_with_fees).reduce(:+)\n price = commits.collect(&:sale_amount).reduce(:+)\n if price_with_fee.nil?\n product.current_sales_with_fees = 0\n product.current_sales = 0\n else\n product.current_sales_with_fees = price_with_fee\n product.current_sales = price\n end\n product.save(validate: false)\n end",
"def item_inventory_update\n \n item = Item.find(params[:item_id])\n order= Order.find(params[:id])\n item_order = ItemOrder.where(item_id: item.id, order_id: order.id).first\n new_inventory = item.inventory - item_order.quantity\n item_order.update(status: \"fulfilled\")\n item.update(inventory: new_inventory)\n end",
"def update_quant(item, quant)\n\t$grocery_list.store(item, quant)\n\tp \"You updated #{item} number to #{quant}.\"\nend",
"def adjust_quantity\n self.quantity = quantity.ceil unless product.allow_fractional_quantity?\n end",
"def update_quantity(opts = {})\n data, _status_code, _headers = update_quantity_with_http_info(opts)\n data\n end",
"def set_quantity(qty) #should be quantity=(), but then calling from child doesn't work?\n @stall_current *= qty / @quantity\n @stall_torque *= qty / @quantity\n @max_power *= qty / @quantity\n @quantity = qty\n end",
"def update_quantity_to_cart\n \t\n\n \tproduct_id_ = params[:product_id].to_i\n\n \tsession[\"cart\"].each do |h|\n \t\tif h['id'] == product_id_\n \t\t\th['quantity'] = params[:quantity_update].to_i\n \t\t\th['total'] = h['price'] * h['quantity']\n \t\t\t\n \t\tend\n \tend\n\n \tredirect_to :back\n end",
"def update_purchase_receival_stock_entry(purchase_receival_entry)\n self.quantity = stock_migration.quantity \n self.save \n \n stock_mutation = StockMutation.where(\n :stock_entry_id => self.id , \n :source_document_entry_id => stock_migration.id,\n :source_document_entry => stock_migration.class.to_s \n ).first \n stock_mutation.quantity = self.quantity \n stock_mutation.save \n end",
"def purchase\n @order = current_order\n @order_items = @order.order_items\n @order_items.each do |item|\n new_inventory = Product.find(item.product_id).inventory_count - item.quantity\n Product.update(item.product_id, inventory_count: new_inventory)\n end\n @order_items.destroy_all\n end",
"def update_quantities\n if params[:quantities]\n params[:quantities].each do |id, num|\n li = @cart.update_quantity(id, num)\n\n if !li\n p = @cart.line_items.find(id) rescue nil\n if p\n (flash[:notice] ||= '') << \"Unable to change quantity of \" +\n \"#{p.name} to #{num}, there are not \"+\n \"enough available at this time.\"\n end\n else #updated quantity\n # update any coupon generated lines for this line\n if cl = li.coupon_line\n cl.coupon.update_quantity_of_coupon_line(cl)\n end \n end\n end\n\n # if any master lines for coupon lines were destroyed,\n # remove their coupon lines as well\n @cart.line_items.select{|x| x.custom_double_line_id}.each do |cl|\n unless @cart.line_items.find_by_id(cl.custom_double_line_id)\n cl.destroy\n end\n end\n\n # (and their coupons)\n @cart.coupons.each do |x|\n @cart.coupons.delete(x) unless x.applies_to?(@cart)\n end\n\n end\n\n # update comments as well\n if params[:cart] and params[:cart][:comments]\n @cart.comments = params[:cart][:comments]\n end\n\n # build the redirect Url Options based on submitted action and\n # what already exists in the session\n uo = {}\n if params[:commit] == 'Checkout'\n uo = build_url_options_for_checkout\n else # just update\n uo = {:controller => 'cart', :action => 'show'}\n end\n\n # save the cart, so we know when the last action was taken on it\n unless @cart.save\n flash[:warning] = \"Unable to save cart: <ul><li>\" +\n \"#{@cart.errors.full_messages.join('</li><li>')}\" + \n \"</li></ul>\"\n end\n\n redirect_to uo\n end",
"def increment_quantity\n self.quantity += 1\n save\n end",
"def update\n @cart = current_cart\n @item = @cart.cart_items.find_by(product_id: params[:id])\n if @item.product.quantity >= item_params[:quantity].to_i\n @item.update(item_params)\n flash[:notice] = \"Updated!\"\n else\n flash[:warning] = \"Could not update.\"\n end\n\n redirect_to carts_path\n end",
"def set_quantity\n @quantity = Quantity.find(params[:id])\n end",
"def update_usage(served_quantity) \n self.used_quantity += served_quantity \n self.save \n \n self.mark_as_finished\n \n item = self.item \n item.deduct_ready_quantity(served_quantity ) \n \n return self \n end",
"def update_usage(served_quantity) \n self.used_quantity += served_quantity \n self.save \n \n self.mark_as_finished\n \n item = self.item \n item.deduct_ready_quantity(served_quantity ) \n \n return self \n end",
"def update\n @order.earliest_pickup_date = calculate_earliest_pickup_date(:update)\n # Save off original quantity for order_products\n original_quantities = {}\n @order.order_products.each { |order_product| original_quantities[order_product.id] = order_product.quantity }\n respond_to do |format|\n if @order.update(order_params)\n okay = true\n @order.order_products.each do |order_product|\n new_quantity = order_product.quantity\n original_quantity = original_quantities[order_product.id]\n unless (new_quantity == original_quantity)\n product = order_product.product\n new_quantity_in_stock = (product.quantity_in_stock + original_quantity - new_quantity)\n if new_quantity_in_stock < 0 # Desired quantity no longer available\n okay = false if okay\n # Update the order the best we can and notify user of discrepancy\n new_quantity_in_stock = 0\n # The original quantity was already subtracted from the stock; quantity should never have to decrease below what was previously ordered\n new_quantity = original_quantity + product.quantity_in_stock\n order_product.update_attributes(quantity: new_quantity)\n end\n product.update_attributes(quantity_in_stock: new_quantity_in_stock)\n end\n end\n redirect_to(edit_order_path(@order), notice: t('orders.not_available')) and return if (!okay) # \"One or more of the products you selected is not available in the desired quantity. Please review the updated order.\"\n if session[:showing_user]\n format.html { redirect_to @order.user, notice: t('orders.create') } # \"Order was successfully updated.\"\n format.json { head :no_content }\n else\n format.html { redirect_to orders_path, notice: t('orders.create') } # \"Order was successfully updated.\"\n format.json { head :no_content }\n end\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_quantity(grocery_list, item, quantity)\r\n add_item(grocery_list, item, quantity)\r\n \r\nend",
"def update\n @recipe = Recipe.find(params[:id])\n db_quantities = @recipe.quantities.where(\"recipe_id = :this_id\", {this_id: @recipe.id})\n\n params[:recipe][:quantities_attributes].each do |quantity_raw|\n quantity = quantity_raw.to_a.last\n if quantity[:item_id].blank?\n next\n end\n #Look to see if the item name is already there and if it is, replace the new amount\n if db_quantities.map{|q| q.item_id}.include?(quantity[:item_id].to_i)\n (db_quantities.detect{|q| q.item_id == quantity[:item_id].to_i})\n .update(amount: quantity[:amount].to_i)\n else\n @recipe.add_item(quantity[:item_id], quantity[:amount])\n end\n\n end\n\n @recipe.attributes = recipe_params\n if @recipe.update_attributes(recipe_params)\n redirect_to edit_recipe_url, id: @recipe.id\n else\n render edit\n end\n end",
"def update_qty(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend",
"def update_stock(_product, _store, _quantity, _is_new)\n if _product.product_type.id != 2\n _stock = Stock.find_by_product_and_store(_product, _store)\n if !_stock.nil?\n _stock.current = _is_new ? _stock.current - _quantity : _stock.current + _quantity\n if !_stock.save\n return false\n end\n end\n end\n true\n end",
"def update_quantity(name, quantity, list)\n list[name] += quantity\nend",
"def update_quantity(list, item_name, qty)\n list[item_name] = qty\nend",
"def get_from_product_stock(product_id, quantity_to_add)\n product = Product.find_by(id: product_id)\n if (product.stock >= quantity_to_add)\n product.stock -= quantity_to_add\n self.quantity += quantity_to_add\n\n if self.valid? && product.valid?\n self.save\n product.save\n return self\n end\n end\n end",
"def add_in_cart \n product_id=params[:id].to_i\n @product=Product.find(product_id)\n total_request=1\n update_through_cart=0 \n if params.has_key?(:quant) \n total_request=params[:quant][:total_request].to_i\n update_through_cart=1 \n end \n if(check_availabilty(product_id,total_request,update_through_cart))\n update_session(product_id,total_request,update_through_cart)\n else\n flash[:notice] = \"#{Product.find(product_id).name} is not available in this quantity\" \n end\n end",
"def update_quantity(grocery_list, item_to_update, qty)\n grocery_list[item_to_update] = qty\n grocery_list\nend",
"def update\n logger.debug \"***Updating Line Item #{params[:id]} quantity to #{params[:cart_line_item][:quantity]}\"\n @cart_line_item = CartLineItem.find(params[:id])\n @cart_line_item.quantity = params[:cart_line_item][:quantity]\n if @cart_line_item.save\n flash[:success] = \"Cart Item successfully updated\"\n else\n flash[:error] = \"Cart Item update unsuccessful\"\n end\n redirect_to cart_path(session[:cart_id])\n end",
"def update_quantity(list, item, quantity)\n\tadd_to_list(list, item, quantity)\nend",
"def increment_quantity\n @quantity += 1\n end",
"def si_update_amount_from_price_or_quantity\n price = params[:price].to_f / 10000\n qty = params[:qty].to_f / 10000\n tax_type = params[:tax_type].to_i\n discount_p = params[:discount_p].to_f / 100\n discount = params[:discount].to_f / 10000\n product = params[:product]\n tbl = params[:tbl]\n if tax_type.blank? || tax_type == \"0\"\n if !product.blank? && product != \"0\"\n tax_type = Product.find(product).tax_type.id\n else\n tax_type = TaxType.where('expiration IS NULL').order('id').first.id\n end\n end\n tax = TaxType.find(tax_type).tax\n if discount_p > 0\n discount = price * (discount_p / 100)\n end\n amount = qty * (price - discount)\n tax = amount * (tax / 100)\n qty = number_with_precision(qty.round(4), precision: 4)\n price = number_with_precision(price.round(4), precision: 4)\n amount = number_with_precision(amount.round(4), precision: 4)\n tax = number_with_precision(tax.round(4), precision: 4)\n discount_p = number_with_precision(discount_p.round(2), precision: 2)\n discount = number_with_precision(discount.round(4), precision: 4)\n @json_data = { \"quantity\" => qty.to_s, \"price\" => price.to_s, \"amount\" => amount.to_s, \"tax\" => tax.to_s,\n \"discountp\" => discount_p.to_s, \"discount\" => discount.to_s, \"tbl\" => tbl.to_s }\n render json: @json_data\n end",
"def so_update_amount_from_price_or_quantity\n price = params[:price].to_f / 10000\n qty = params[:qty].to_f / 10000\n tax_type = params[:tax_type].to_i\n discount_p = params[:discount_p].to_f / 100\n discount = params[:discount].to_f / 10000\n product = params[:product]\n tbl = params[:tbl]\n if tax_type.blank? || tax_type == \"0\"\n if !product.blank? && product != \"0\"\n tax_type = Product.find(product).tax_type.id\n else\n tax_type = TaxType.where('expiration IS NULL').order('id').first.id\n end\n end\n tax = TaxType.find(tax_type).tax\n if discount_p > 0\n discount = price * (discount_p / 100)\n end\n amount = qty * (price - discount)\n tax = amount * (tax / 100)\n qty = number_with_precision(qty.round(4), precision: 4)\n price = number_with_precision(price.round(4), precision: 4)\n amount = number_with_precision(amount.round(4), precision: 4)\n tax = number_with_precision(tax.round(4), precision: 4)\n discount_p = number_with_precision(discount_p.round(2), precision: 2)\n discount = number_with_precision(discount.round(4), precision: 4)\n @json_data = { \"quantity\" => qty.to_s, \"price\" => price.to_s, \"amount\" => amount.to_s, \"tax\" => tax.to_s,\n \"discountp\" => discount_p.to_s, \"discount\" => discount.to_s, \"tbl\" => tbl.to_s }\n render json: @json_data\n end",
"def reduce_quantity\n @batch = Batch.find_by(batchID: params[:batchID])\n #update the quantity \n #@batch[:quantity] -= 1\n \n @batch.quantity = @batch.quantity - 1\n end",
"def quantity=(q)\n \t@quantity = q\n \tnotify_observers unless @observers.empty?\n end",
"def update\n requested_qty = params[:quantity].to_i\n\n # Check that user hasn't entered invalid qty\n unless requested_qty > 0\n flash[:item_error] = 'Please enter a valid quantity.'\n redirect_to cart_path\n return\n end\n\n # Get the line_item to update\n current_item = LineItem.find params[:id]\n\n # Ensure users don't update line items that don't belong to their cart\n unless @cart.line_items.include?(current_item)\n redirect_to cart_path\n return\n end\n\n # Invoke method in line_item.rb that checks the\n # requested qty against current stock levels\n update_qty = current_item.get_update_qty requested_qty\n\n # If the user's requested quantity can not be fulfilled, set a flash error\n unless update_qty == requested_qty\n flash[:item_error] = \"Sorry, not enough stock. Your shopping basket has been adjusted accordingly.\"\n end\n\n # Save the line_item update\n current_item.update quantity: update_qty\n\n # Redirect to My Basket page\n redirect_to cart_path\n end",
"def set_quantity_and_price(purchase, n, price, entry = find_or_create_item(purchase))\n entry.components.clear\n update_entry(entry) do |i|\n i.components.build(:price => price, :quantity => n, :total => price * n)\n end\n end",
"def update(stuff, quantity, options={})\n if stuff.is_a?(MerchantSidekick::ShoppingCart::LineItem)\n self.update_cart_line_item(stuff, quantity, options)\n else\n self.update_product(stuff, quantity, options)\n end\n end",
"def update_quant(current_list, item, quantity)\n current_list[item] = quantity\n current_list\nend",
"def reshelf(product, quantity)\n # NOT DEFINED IN EXAMPLES\n @inventory[product][\"quantity\"] += quantity\nend",
"def updated_quantity(list, item_name, quantity)\r\n\tlist[item_name] = quantity\r\n\tlist\r\nend",
"def update\n respond_to do |format|\n if @order_product.update(order_product_params)\n format.html { redirect_to order_path(@order_product.order), notice: 'Quantity updated.' }\n format.json { render :show, status: :ok, location: @order_product }\n else\n format.html { render :edit }\n format.json { render json: @order_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_quantity(list, item, quant)\n list[item] = quant\nend",
"def add_product(product, quantity)\n current_item = OrderItem.find_by(product_id: product.id, order_id: self.id )\n\n if current_item\n current_item.quantity = quantity\n current_item.save\n else\n new_item = OrderItem.new(product_id: product.id, quantity: quantity, order_id: self.id)\n new_item.save\n end\n end",
"def get_update_qty(requested_qty)\n update_qty = requested_qty\n\n if self.product_size.quantity < requested_qty\n update_qty = self.product_size.quantity\n end\n\n update_qty\n end",
"def add_product(product,quant=1)\n\t\tproduct_id = product.id\n\t\tif exist?(product_id)\n\t\t\tproducts[product_id] += quant\n\t\telse\n\t\t\tproducts[product_id] = quant \n\t\tend\n\t\tsave\n\tend",
"def update\n order_items_params = {\n product_id: @order_item.product_id,\n order_id: @order_item.order_id,\n quantity: params[:quantity]\n} \n\nif @order_item.update(order_items_params)\n redirect_to order_path(@order_item.order_id)\n return\nend\nend",
"def add_product(product_id)\n current_item = line_item.find_by_product_id(product_id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product_id)\n end\t\n current_item\nend",
"def update\n quantity_increase = item_params[:quantity].to_i\n previous_quantity = @item.quantity\n respond_to do |format|\n if @item.update(item_params)\n @item.quantity = previous_quantity + quantity_increase\n @item.save \n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # find order item by params id\n\n if order_item_params[:quantity].to_i == 0\n @orders_item.destroy\n flash.now[:danger] = \"Removed item from your cart\"\n redirect_to order_path(@current_order.id)\n else\n if @orders_item && @orders_item.product.can_purchase?(order_item_params[:quantity].to_i) && @orders_item.update(order_item_params)\n flash[:success] = \"The cart item #{@orders_item.product.name} has been updated\"\n redirect_to order_path(@current_order.id)\n elsif @orders_item && !@orders_item.product.can_purchase?(order_item_params[:quantity].to_i) #the order item exists and it was invalid input for quantity\n flash.now[:danger] = \"There is not enought stock to add that quantity to the cart!\"\n redirect_to order_path(@current_order.id)\n else\n flash[:danger] = \"Something went wrong\"\n redirect_to order_path(@current_order.id)\n end\n end\nend",
"def update\n @first_value = session[:passed_variable] \n @get_value = @first_value\n @p = Product.find_by(id:@get_value)\n\n\n\n puts @p.name \n puts cart_params[\"quantity\"]\n\n \n if cart_params[\"quantity\"].to_i > @p.quantity\n puts \"LAAAAAAAAAAAAAA\"\n flash.now[:danger] = \"You cannot order more than the product's quantity\"\n render :new\n\n else\n @cart = Cart.find_by(buyer_id:current_buyer.id)\n @editing_Quantity = session[:edited_Quantity]\n puts \"FOUND CART\"\n\n if @editing_Quantity != nil\n @entry = CartCarry.find_by(cart_id:@cart.id , product_id:@p.id)\n puts \"Cart Carry\"\n puts \"EDITING\"\n @entry.quantity = cart_params[\"quantity\"]\n @entry.save\n session[:edited_Quantity] = nil\n else\n puts \"ADDING\"\n @entry = CartCarry.create(cart_id:@cart.id,product_id:@p.id,quantity: cart_params[\"quantity\"].to_i)\n Rails.logger.info(@entry.errors.inspect) \n end\n respond_to do |format|\n format.html { redirect_to cart_path, notice: \"Product added to cart\" }\n end\n end\n\n\n\n # respond_to do |format|\n # if @cart.update(cart_params)\n # format.html { redirect_to @cart, notice: \"Cart was successfully updated.\" }\n # format.json { render :show, status: :ok, location: @cart }\n # else\n # format.html { render :edit, status: :unprocessable_entity }\n # format.json { render json: @cart.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update_value(quantity)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# quantity == crypto value NOT USD\n\t\t# debugger\n\n\t\tif quantity > 0\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# BUY \n\t\t\tself.total_value = self.total_value + quantity\t\t\t# increment wallet value by quantity\n\t\telse \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# SELL\n\t\t\tself.total_value = self.total_value + quantity\t\t\t# quantity is Negative!! so adding, will decrement\n\t\tend\n\n\t\tsave!\n\tend",
"def update_sales_line_qty\r\n sales_line = ERP::SalesLine.find params[:id]\r\n result = sales_line.update_sales_qty( params[:value].to_i )\r\n @store_user.my_account_log(sales_line,\"Update Sales Line Qty: #{sales_line.invent_trans_id} (#{sales_line.item_id}), returns #{result}\")\r\n render :text => result\r\n end",
"def update_quantity(item_name, grocery_list, quantity)\n grocery_list[item_name] = quantity\n grocery_list\n end",
"def update_quantity (grocery, item_name, new_quantity)\n grocery[item_name] = new_quantity\n display_list(grocery)\n end",
"def add_product(product_id)\n \tcurrent_item = line_items.find_by(product_id: product_id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product_id)\n end\n current_item\n end",
"def add_inventory(product_name, quantity)\n @products.each do |product|\n if product.name == product_name.upcase\n product.quantity += quantity\n end\n end\n end",
"def add_product(product)\n current_item = line_items.find_by(product_id: product.id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product.id)\n end\n current_item\n end",
"def update_quantity(list, item, qty)\n list[item] = qty\n list\nend",
"def add_product(product)\n current_item = line_items.find_by(product_id: product.id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product.id)\n end\n current_item\n end",
"def update\n notice = ''\n @order = Order.find(params[:id])\n unless current_member.admin or (!@order.paid and !@order.taken)\n store_location\n flash[:notice] = \"Too late to edit that one, bro.\"\n redirect_to orders_path\n end\n\n # remove empty items\n params[:order][:order_details_attributes].each{ |k,v|\n if v[:id].nil?\n params[:order][:order_details_attributes].delete(k) if v[:quantity].to_f == 0.0 or v[:quantity].strip == ''\n next\n end\n\n if v[:quantity].to_f == 0.0 or v[:quantity].strip == ''\n OrderDetail.find(v[:id]).destroy\n params[:order][:order_details_attributes].delete(k)\n end\n }\n\n # combine same-stock entries\n stock_quantities = {}\n params[:order][:order_details_attributes].each{ |k,v|\n sid = v[:stock_id].to_i\n q = v[:quantity].to_f\n if stock_quantities[sid].nil?\n stock_quantities[sid] = q\n else\n stock_quantities[sid] += q\n OrderDetail.find(v[:id]).destroy unless v[:id].nil?\n params[:order][:order_details_attributes].delete(k)\n end\n }\n params[:order][:order_details_attributes].each{ |k,v|\n params[:order][:order_details_attributes][k][:quantity] = stock_quantities[v[:stock_id].to_i]\n }\n \n unless current_member.admin\n @order.member = current_member\n end\n\n old_stock_quantities = {}\n @order.order_details.each{ |od|\n next if od.stock.nil?\n old_stock_quantities[od.stock.id] = od.quantity\n } \n\n # first check to make sure there is enough stock available\n stock_quantities.each{ |sid,q|\n s = Stock.find(sid)\n old_stock_quantities[sid] = 0.0 if old_stock_quantities[sid].nil?\n qmax = s.quantity + old_stock_quantities[sid]\n if s.limited and qmax < stock_quantities[sid]\n unless current_member.admin\n @order.errors.add \"Limited Stock Item:\",\"Sorry, there are only #{qmax} #{s.product.units} #{s.name} remaining and you have tried to order #{stock_quantities[sid]}.\"\n respond_to do |format|\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n return false\n else\n notice = \"Limited Stock Item: There were only #{qmax} \n #{s.product.units} #{s.name} remaining, \n but I let you do it anyway since you're the boss!\"\n end\n elsif !s.limited and qmax < stock_quantities[sid]\n notice = \"You ordered more #{s.name} than is currently in stock. It may be some delay before this order item is available for pick up.\"\n end\n }\n\n # add back quantity and then subtract it off again\n @order.order_details.each{ |od|\n next if od.stock.nil?\n od.stock.quantity += od.quantity\n od.stock.save\n }\n if !@order.paid and params[:order][:paid].to_i == 1\n @order.paid_at = Time.now\n @order.marked_paid_by = current_member\n @order.save\n end\n\n if !@order.taken and params[:order][:taken].to_i == 1\n @order.taken_at = Time.now\n @order.archived = true\n @order.save\n end\n\n # delete items before we add back the new ones\n @order.order_details = []\n @order.save \n\n respond_to do |format|\n \n if @order.update_attributes(params[:order])\n @order.order_details.each{ |od|\n next if od.stock.nil?\n od.stock.quantity -= od.quantity\n od.stock.save\n if @order.archived\n od.archived_name = od.stock.name\n od.archived_cost = od.stock.final_cost\n od.archived_supplier = od.stock.supplier\n od.archived_product = od.stock.product\n od.archived_markup_pct = od.stock.markup_pct\n od.archived_markup_const = od.stock.markup_const\n end\n od.save\n }\n format.html { redirect_to(orders_path, :notice => \"Order was successfully updated. #{notice}\") }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n product = Product.find(params[:id])\n product_details = params.permit(:title, :inventory_count, :price)\n\n product.update(product_details)\n\n render json: product\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n product = Product.find_by_id(@line_item.product.id)\n product.update_attributes(:remaining_quantity => (product.remaining_quantity + @line_item.quantity))\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(orders_path) }\n format.json { head :ok }\n end\n end",
"def update_quantity (item, quantity)\n item_hash[item] = quantity\nend",
"def update_quantity(list, item, quant)\n list[item] = quant\nend",
"def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity.to_i\n\tlist\nend",
"def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend",
"def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend",
"def reserve_inventory!(order_quantity)\n self.quantity -= order_quantity\n save!\n end",
"def update_quantity(list, item_name, new_quantity)\n list[item_name] = new_quantity\nend",
"def update_quantity(list, item_name, new_quantity)\n list[item_name] = new_quantity\nend",
"def update_qty(list_items, item_name, new_qty)\n raise ArguementError.new(\"This item does not exist\") unless list_items.include?(item_name)\n list_items[item_name] = item_qty\nend",
"def set_quantity(purchase, n, entry = find_or_create_item(purchase))\n\n if n == 0\n delete(entry)\n else\n entry.components.clear\n\n max_qty = maximum_quantity_allowed(purchase)\n\n if max_qty > n\n assign_components(entry, purchase, n)\n else\n assign_components(entry, purchase, max_qty)\n if !stock_available?(purchase, n)\n entry.errors.add(:quantity, \"There #{max_qty > 1 ? 'are' : 'is'} only #{max_qty} of this item available.\")\n elsif purchase_limited?(purchase)\n entry.errors.add(:quantity, \"This item is limited to #{purchase.purchase_limit} per customer.\")\n end\n end\n\n entry.quantity = entry.components.map(&:quantity).sum\n\n if entry.quantity == 0\n delete(entry)\n else\n entry.total = entry.components.reduce(SpookAndPuff::Money.new('0')) {|m, c| m + c.total }\n entry.pre_discount_total = entry.total\n end\n end\n\n entry\n end",
"def update_quantity_of_item(list,item,quantity)\r\n add_item_to_list(list,item,quantity)\r\n list\r\nend",
"def apply_to_quantity(q)\n ops.inject(q){ |tot,op| op.call(tot) }\n end",
"def update_quantity(new_list, item_name, quantity)\r\n \r\n new_list[item_name] = quantity\r\nend",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end"
] | [
"0.75993234",
"0.7597482",
"0.7406935",
"0.7183835",
"0.71742105",
"0.709927",
"0.70612174",
"0.70300794",
"0.7022384",
"0.6984835",
"0.69317746",
"0.69176215",
"0.6912161",
"0.6902257",
"0.68883896",
"0.6884053",
"0.6878218",
"0.68733764",
"0.68595797",
"0.68537545",
"0.6797144",
"0.67355365",
"0.67268735",
"0.67238",
"0.6717052",
"0.669663",
"0.6684624",
"0.6664629",
"0.66607994",
"0.66604817",
"0.6640942",
"0.6636432",
"0.6624224",
"0.66223586",
"0.66214806",
"0.6619914",
"0.6597711",
"0.6581384",
"0.6581384",
"0.65756536",
"0.6557501",
"0.65469253",
"0.65358067",
"0.65321237",
"0.65297145",
"0.65258443",
"0.651415",
"0.6508445",
"0.65075654",
"0.6506117",
"0.6502712",
"0.6493923",
"0.6488137",
"0.6487368",
"0.6480803",
"0.6477015",
"0.6470851",
"0.64580774",
"0.6457125",
"0.64569914",
"0.6455227",
"0.64441234",
"0.6434788",
"0.6432911",
"0.64253765",
"0.6419696",
"0.6417607",
"0.641657",
"0.6409148",
"0.6402217",
"0.64013463",
"0.63981014",
"0.6396205",
"0.639504",
"0.63860875",
"0.6383323",
"0.6381844",
"0.6378197",
"0.63749015",
"0.636428",
"0.6355139",
"0.635089",
"0.6348794",
"0.63412464",
"0.63398397",
"0.6339815",
"0.63341236",
"0.63337934",
"0.63337934",
"0.63311476",
"0.63306296",
"0.63306296",
"0.63239175",
"0.631473",
"0.6314434",
"0.6311614",
"0.6305299",
"0.6300503",
"0.6300503",
"0.6300503"
] | 0.6819326 | 20 |
Remove product from cart, given its id | def remove product_id
products.reject! { |product| product.variant.id == product_id.to_i }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_from_cart\n Cart.remove_from_cart(session[:cart], params[:id])\n redirect_to show_cart_products_path\n end",
"def removeProduct\n id = params[:id]\n cart = session[:cart]\n cart.delete id\n redirect_to :action => :index\n \n end",
"def delete_product_to_cart\n \tid = params[:id]\n \tif !session[\"cart\"].nil?\n \t\tsession[\"cart\"].each do |t|\n \t\t\tif t['id'].to_i == id.to_i\n \t\t\t\tsession[\"cart\"].delete(t)\n \t\t\tend\n \t\tend\n \tend\n \tredirect_to :back\n end",
"def remove_product(name)\n @products_in_cart.delete(Product)\nend",
"def remove_from_cart\n\t\tcart_hash = session[:cart]\n\n\t\tcart_hash[params[:id]][\"quantity\"] -= 1\n\t\tif cart_hash[params[:id]][\"quantity\"] === 0\n\t\t\tcart_hash.delete(params[:id])\n\t\tend\n\n\t\tredirect_to root_url\n\tend",
"def remove_from_cart\n id = params[:id]\n session[:cart].delete(id)\n redirect_to root_path\n end",
"def delete_from_cart\n cart_op {|cart| cart.delete(params[:id].to_i); cart }\n render_cart_size\n end",
"def remove\n\t\tremove_from_cart(Item.find(params[:id]))\n\t\tredirect_to :controller => \"cart\", :action => \"index\"\n\tend",
"def destroy\n if current_user.cart.present? && current_user.cart.carts_products.where(id: params[:id]).present?\n current_user.cart.carts_products.delete(params[:id])\n render json: { message: \"Item removed from cart\" }\n else\n render json: { message: \"Can't find item in cart\" }, status: :not_found\n end\n end",
"def destroy\n id = params[:id].to_i\n session[:shopping_cart].delete(id)\n\n product = Product.find(id)\n\n flash[:delete_notice] = \"Removed Item #{product.product_name} from Cart.\"\n redirect_to root_path\n end",
"def remove_item\n prod_id = params[:product_id].to_s\n item = cart[prod_id] || {\"Num\" => 0}\n item[\"Num\"] -=1\n cart[prod_id] = item\n cart.delete(prod_id) if item[\"Num\"] < 1\n update_cart cart\n flash[:success] = t('itm_removed')\n redirect_back fallback_location: :root\n end",
"def remove\n id = params[:id]\n cart = session[:cart]\n cart.delete id\n \n redirect_to :action => :index\n end",
"def delete_by_id(id)\n delete_product_by_id(id)\n end",
"def remove_item\n product_id = params[:product_id].to_s\n modify_cart_delta(product_id, -1)\n redirect_to :back\n end",
"def remove_from_cart\n render json: CartProduct.find(params[:id]).destroy\n end",
"def destroy\n @product_id = params[:product_id].to_s\n\n # remove the item from the session\n session[:shopping_cart].delete(@product_id)\n\n calculate_order_total\n end",
"def destroy\n @cart = current_cart\n @item = @cart.find_cart_item(params[:id])\n @product = @item.product\n @item.destroy\n flash[:warning] = \"#{@product.name} removed with success!\"\n redirect_to :back\n end",
"def remove_item\r\n cart_item_id = params[:id].to_i\r\n session[:cart].delete(cart_item_id)\r\n\r\n flash[:info] = 'Item has been removed!'\r\n redirect_to cart_url\r\n end",
"def delete\n\t\t@cart.delete(:item_id)\n end",
"def destroy\n\n @cart = current_cart\n @line_item = @cart.remove_product(@cart.line_items.find(params[:id]))\n #the @cart is a security measure to ensure that the item is within\n # the current cart; I'm not certain if this is needed\n\n\n respond_to do |format|\n format.html { redirect_to store_url }\n format.json { head :no_content }\n end\n end",
"def remove_from_cart\n @showbuttons = true\n begin\n product = Product.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n logger.error(\"Attempt to access invalid product #{params[:id]}\")\n redirect_to_index(\"Invalid product\" )\n else\n @cart = find_cart\n @current_item = @cart.remove_product(product)\n @order = find_order\n respond_to do |format|\n format.js if request.xhr?\n format.html {redirect_to_index}\n end\n end\n end",
"def delete_product(id)\n @client.raw('delete', \"/ecommerce/products/#{id}\")\n end",
"def remove_product(product)\n products.delete(product)\n # save\n end",
"def remove(item)\n cart_items.where(item_id: item.id).first.try(:destroy)\n end",
"def remove_from_cart\n #see if you can change number of items in cart\n item_id = params[:remove_from_cart][:item_id]\n remove_item_from_cart(item_id)\n\n redirect_to cart_path\n end",
"def delete_cart(id)\n db = database()\n db.execute(\"DELETE FROM carts WHERE UserId = ?\", id)\n end",
"def delete\n self.class.delete_product_by_id(self.id)\n end",
"def destroy\n cart_item = CartItem.where(cart_id: current_user.cart_id).where(\"item_id = ?\", cart_items_params[:item_id]).first\n if cart_item.delete\n @cart = CartItem.where(cart_id: current_user.cart_id).order(created_at: :desc)\n render 'carts/show'\n else\n render json: ['no such product in the cart'], status: 404\n end\n end",
"def remove_from_cart\n if @cart.candle_carts.count == 1\n destroy\n else\n item = CandleCart.find(cart_params[:id])\n item.destroy\n flash[:alert] = \"Succesfully Removed\"\n redirect_back fallback_location: root_path\n end\n end",
"def remove_product(index)\n @cart.delete_at(index)\n puts \"**Product removed from cart.**\"\n view_cart\nend",
"def remove_item\n item = Item.find(params[\"format\"])\n #select the cart of the log-in user\n if user_signed_in?\n cart = current_user.cart\n #check if the item is in the cart\n if item.carts.find(cart.id)\n item.carts.delete(cart)\n end\n redirect_to carts_show_path\n else\n redirect_to root_path\n end\n end",
"def destroy_from_cart\n unless cookies[:cart].nil?\n @cart = Cart.find_by_unique_identifier(cookies[:cart])\n @cart.delete_product(params[:catalog_id],params[:product_id])\n if @cart.save\n if @cart.products.size == 1\n products = @cart.products[0]\n if products[:products_count] == 0\n @cart.destroy\n cookies.delete(:cart)\n redirect_to root_url, :alert => t('cart.msg_cart_destroyed_no_products')\n else\n redirect_to show_mycart_path, :notice => t('cart.msg_del_prod')\n end\n else\n redirect_to show_mycart_path, :notice => t('cart.msg_del_prod')\n end\n else\n redirect_to show_mycart_path, :alert => t('cart.msg_no_del_prod')\n end\n else\n redirect_to root_url, :alert => t('cart.msg_nothing')\n end\n end",
"def destroy\r\n @cart_item = CartItem.find(params[:id])\r\n if @cart_item.destroy\r\n \t@cart_item.unbuy # returns unbought items in the cart to products table\r\n \tflash[:notice] = \"Item has been removed from cart!\"\r\n end\r\n redirect_to edit_cart_item_path(@cart_item)\r\n end",
"def remove_product(index)\n @cart.delete_at(index)\n puts \"Product removed from cart.\"\n view_cart\nend",
"def remove_product(name)\n @cart_items = @cart_items.select do |item|\n item.name != name\n end\n end",
"def destroy\n @cart = current_cart\n product = Product.find(params[:product_id])\n #@line_item = LineItem.find(params[:id])\n @line_item = @cart.remove_product(product.id)\n product.update_attributes(:quantity => product.quantity + 1)\n\n respond_to do |format|\n format.html { redirect_to store_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @carts_product = @cart.carts_products.find(params[:id])\n @carts_product.destroy\n\n respond_to do |format|\n format.html { redirect_to @cart }\n format.json { head :no_content }\n end\n end",
"def remove_item(id:)\n order.items.destroy(id)\n end",
"def delete\n session[:cart].delete(params[:id])\n flash[:success] = 'Delete done'\n redirect_to cart_index_path\n end",
"def remove_item_from_stock(product_id)\n\t\tproduct = Product.find(product_id)\n\t\tif product.stock - 1 < 0\n\t\t\trender :json => \"No hay suficientes productos\"\n\t\telse\n\t\t\tproduct.stock -= 1\n\t\t\tproduct.save\n\t\tend\n\n\tend",
"def remove_cart\n\t\tcart = current_user.saved.carts.find(params[:cart])\n #saved.carts.delete(cart)\n cart.destroy\n redirect_to :back\n\tend",
"def destroy\n if current_user\n @order_product = OrderProduct.find(params[:id])\n @order_product.destroy\n else\n x = JSON.parse(cookies[:add_to_cart])\n x.delete_if { |h| h[\"product_id\"] == params[:id] }\n cookies[:add_to_cart] = JSON.generate(x)\n end\n respond_to do |format|\n format.html { redirect_to carts_url, notice: 'Order product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@cart = current_cart\n\t\t@cart.delete\n\n\t\tsession.delete(:aregos_cart_id)\n\n\t\tflash[:notice] = \"O carrinho de compras foi eliminado.\"\n\n\t\tredirect_to products_path\n\tend",
"def delete_product(single_product_id)\n Product.new.destroy_product(single_product_id)\n end",
"def delCart\n session.delete(:cart_id)\n end",
"def delete(product_id)\n delete_request(t_url(:product, product_id))\n end",
"def destroy\n # get the item with id and get the quantity of this item\n @item = ShoppingCart.find(params[:id]).item\n\n @item.save\n current_user.remove_item_from_cart!(@item)\n # remove the item from shopping cart\n respond_to do |format|\n format.html { redirect_to @item }\n format.js\n end\n end",
"def destroy\n li = @cart.line_items.find_by_id!(params[:id])\n li.destroy\n render json: {}, status: :ok\n end",
"def destroy\n id = params[:id].to_i\n cart_books = session[:cart].map { |c| c[0] }\n \n session[:cart].delete_at(cart_books.index(id))\n \n redirect_back(fallback_location: root_path)\n \n # logger.debug(\"Cart Destroy triggered\")\n end",
"def destroy\n @cart = @current_cart\n @cart.destroy\n session[:cart_id] = nil\n redirect_to cart_path(@cart.id)\n end",
"def destroy\n if @cart.cart?\n @cart.destroy\n end\n session[:cart_id] = nil\n redirect_to cart_url\n end",
"def decrease\n id = params[:id]\n cart = session[:cart]\n \n if cart[id] == 1 then\n cart.delete id\n else\n cart[id] = cart[id]-1\n end\n redirect_to :action => :index\n \n end",
"def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n @cart_id = @cart_item.cart_id\n\n respond_to do |format|\n format.html { redirect_to cart_path(@cart_id) }\n format.json { head :no_content }\n end\n end",
"def remove(params, userid)\n id = params[\"product_id\"]\n db = connect()\n result = db.execute(\"DELETE FROM ProduCart WHERE product_id = ? AND user_id = ?\",id,userid)\n end",
"def remove_product(product, quantity=1, payment_method='deposit')\n item = @items.find { |i| i.product_id == product.id && i.payment_method == payment_method }\n if item\n if item.quantity > quantity then\n item.quantity -= quantity\n else\n @items.delete(item)\n end\n end\n end",
"def destroy\n @in_shopping_cart.destroy\n end",
"def remove(stuff, options={})\n if stuff.is_a?(MerchantSidekick::ShoppingCart::LineItem)\n self.remove_cart_line_item(stuff, options)\n else\n self.remove_product(stuff, options)\n end\n end",
"def call(_obj, args, _ctx)\n cart = ShoppingCart.find_by(user_id: args[:user_id])\n product = Product.find_by(product_id: args[:product_id])\n item = CartItem.find_by(product_id: args[product_id])\n cart.cart_items.delete(item)\n cart.total_cost -= product.price * item.quantity + product.shipping\n cart.save\n cart\n end",
"def destroy\n @cart = current_cart\n @cart.destroy\n \n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { \n redirect_to products_url,\n notice: 'Obsah košíku byl vysypán na zem. Zaměstnanci jej nyní uklízí.' \n }\n format.json { \n head :ok \n }\n end \n end",
"def remove_item(id)\n @items.delete_at(id)\n end",
"def remove!(product_ids)\n\t\t\tcart = Cart.perform_request Cart.api_url(\"carts/#{self.id}\", {}), :patch,\n\t\t\t\t{ op: \"remove\",\n\t\t\t\t\titems: product_ids }, true\n\n\t\t\tif cart\n\t\t\t\tself.items = cart[\"data\"][\"items\"]\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\tend",
"def destroy\n @shopping_carts_product.destroy\n respond_to do |format|\n format.html { redirect_to shopping_cart_url(params[:shopping_cart_id]), notice: 'Product was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def remove\n product = Product.find(params[:id])\n wishlist = Wishlist.get_current(current_user, session)\n wishlist.products.delete(product)\n render :update do |page| \n page.remove(\"dg_#{product.id}\")\n end\n end",
"def destroy\n @cart_product.destroy\n respond_to do |format|\n format.html { redirect_to cart_products_url, notice: \"Item Removed from Cart\" }\n format.json { head :no_content }\n end\n end",
"def remove_product(a_product, options={})\n deleted_line_item = nil\n item_to_remove = find(:first, a_product)\n deleted_line_item = @line_items.delete(item_to_remove) if item_to_remove\n deleted_line_item\n end",
"def remove_item\n\t\tset_sale\n\t\tpopulate_products\n\n\t\tline_item = Item.where(sale_id: params[:sale_id], product_id: params[:product_id]).first\n\t\tline_item.quantity -= 1\n\n\t\tif line_item.quantity == 0\n\t\t\tline_item.destroy\n\t\telse\n\t\t\tline_item.save\n\t\t\tupdate_line_item_totals(line_item)\n\t\tend\n\n\t\t# Llama método que devuelve cantidad al stock\n\t\treturn_item_to_stock(params[:product_id])\n\n\t\tupdate_totals\n\n\t\trespond_to do |format|\n\t\t\tformat.js { ajax_refresh }\n\t\tend\n\tend",
"def destroy\n @cart_item.destroy\n\n head :no_content\n end",
"def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n\n respond_to do |format|\n format.html { redirect_to current_cart_url }\n format.json { head :no_content }\n end\n end",
"def delete\n @product = Kernel.const_get(params[:type].camelize)[params[:id].to_i]\n\n\n cart = get_cart()\n cart.delete_product(@product)\n rescue Exception => e\n flash[:message] = 'Error: Delete from cart operation failed'\n ExceptionNotifier::Notifier.exception_notification(request.env, e).deliver\n ensure\n redirect_to(:action => '')\n end",
"def destroy\n\t\t@cart_item.destroy\n\n\t\thead :no_content\n\tend",
"def destroy\n\n if params[:product_id] then\n# TODO need to use @cart.id to ensure only this users line_item is accessed.\n current_item = LineItem.find_by_product_id(params[:product_id] )\n else\n current_item = LineItem.find(params[:id])\n end\n\n if current_item\n current_item.quantity -= 1\n puts current_item.quantity\n if current_item.quantity <= 0\n current_item.destroy\n else\n current_item.save\n end\n else\n current_item.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to store_url }\n format.json { head :no_content }\n end\n end",
"def remove_product(product_name)\n if products.has_key?(product_name)\n products.delete(product_name)\n else\n raise ArgumentError\n end\n end",
"def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n\n respond_to do |format|\n format.html { redirect_to cart_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n\n respond_to do |format|\n format.html { redirect_to cart_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @line_item = LineItem.find(params[:id])\n # @line_item.destroy\n\n @cart = current_cart\n #We use params to get the product ID from the request\n #This is stored locally as no need to let view see it\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n \n #Adds an item to the cart using the \"add_product\" \n #function in the \"cart.rb\" file.\n\n\n respond_to do |format|\n format.html { redirect_to(store_url) }\n format.js { @current_item = @line_item }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cart_item.destroy\n Product.update(@cart_item.product.id, :quantity => @cart_item.product.quantity + @cart_item.quantity)\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Cart item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove_product(product_name)\n\t\tif @products.key? product_name\n\t\t\tproducts.delete(product_name)\n\t\telse\n\t\t\traise ArgumentError, \"Product already does not exist\"\n\t\tend\n\tend",
"def delete_item\n if current_user\n @item = Item.find(params[:id].to_i)\n current_cart.items.delete(@item)\n redirect_to cart_path\n else\n delete_item_in_guest_cart(params[:id].to_i)\n redirect_to cart_path\n end\n end",
"def delete_product(product_code)\n @product_list.delete(product_code)\n end",
"def destroy\n if params[:line_item_id]\n @cart.line_items.find(params[:line_item_id]).destroy\n else\n @cart.destroy\n end\n end",
"def destroy\n cart = Cart.find_by(id: params[:id])\n cart.destroy\n render json: CartSerializer.new(cart)\n end",
"def destroy\n @line_item = @current_cart.line_items.where(:id => params[:id]).first\n unless @line_item.nil?\n @line_item.destroy\n end\n end",
"def remove_product\n @collection_of_products.each do |current_product|\n if @collection_of_products.include?(current_product) == true\n @collection_of_products.delete(current_product)\n\n end\n end\n end",
"def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to(store_url) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cart = current_cart\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n \n respond_to do |format|\n flash[:notice] = \"Successfully removed item from cart.\"\n format.html { redirect_to(current_cart_url) }\n format.js # destroy.rjs\n end\n end",
"def destroy\n # make sure user is accessing cart currently\n # held in their session\n if params[:id].to_i == session[:cart_id].to_i\n logger.debug \"***Destroying line item #{params[:line_id]}...\"\n @cart_line_item.destroy\n flash[:success] = \"Item successfully removed from Cart\"\n redirect_to cart_path(session[:cart_id])\n else\n logger.debug \"***Cart id Supplied does NOT match session cart id\"\n no_cart_line_item_found\n end\n end",
"def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end",
"def destroy\n\t\t@cart.destroy\n\t\tsession.delete(:cart)\n\tend",
"def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n respond_to do |format|\n format.html { redirect_to carts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n respond_to do |format|\n format.html { redirect_to carts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n respond_to do |format|\n format.html { redirect_to carts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n\n respond_to do |format|\n format.html { redirect_to carts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cart = Cart.find(params[:id])\n @cart.destroy\n session[:cart_id] = nil\n\n respond_to do |format|\n format.html { redirect_to(root_path,\n\t:notice => 'Your cart is currently empty') }\n format.json { head :no_content }\n end\n end",
"def remove_item(id, amt = 1)\n @inventory[:container].remove(id, amt)\n end",
"def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(cart_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cart_item = CartItem.find(params[:id])\n @cart_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(carts_url) }\n format.xml { head :ok }\n end\n end",
"def remove_product(product_name)\n if @products.keys.include?(product_name)\n @products.reject! { |k| k == product_name }\n else\n raise ArgumentError, \"The product does not exist in the order\"\n end\n end",
"def remove_item(item_id)\n @items.delete_if { |item| item.id.to_i == item_id.to_i}\n end",
"def destroy\n OrderItem.find_by(product: Product.find_by_title(params[:product_title]))\n .destroy_product(params[:quantity_of_products])\n order = Order.find_by_user_session_id(session['session_id'])\n if order.present?\n order.update_total_price_cents(nil)\n end\n redirect_to cart_path, notice: \"Вы убрали из корзины #{params[:product_title]}\"\n end",
"def destroy\n if @cart_item.destroy\n # if @cart_item.cart.items.present?\n build do\n message 'Удаление товара из корзины'\n view 'cart_items/delete'\n end\n # else\n # @cart = @cart_item.cart\n # @cart.destroy\n # build do\n # message 'Удаление корзины'\n # view 'carts/delete'\n # end\n # end\n end\n end"
] | [
"0.81934404",
"0.80725896",
"0.8059468",
"0.7939361",
"0.7878694",
"0.7850877",
"0.7825493",
"0.78220546",
"0.7785838",
"0.77223897",
"0.7717683",
"0.77165973",
"0.7672113",
"0.7590824",
"0.7572497",
"0.7561115",
"0.7523862",
"0.7523843",
"0.7422722",
"0.735829",
"0.7342795",
"0.72602695",
"0.72219",
"0.71569854",
"0.7145955",
"0.7141084",
"0.71050024",
"0.7077017",
"0.7005137",
"0.6995599",
"0.69747114",
"0.6961662",
"0.69596964",
"0.6934468",
"0.6926985",
"0.6919346",
"0.69035095",
"0.6884306",
"0.68590266",
"0.6854577",
"0.6849514",
"0.6826494",
"0.6822054",
"0.68122536",
"0.6802475",
"0.67948425",
"0.6768029",
"0.67679334",
"0.6757204",
"0.6742332",
"0.67323506",
"0.67212623",
"0.67053634",
"0.66968584",
"0.669413",
"0.6692245",
"0.6685159",
"0.6680947",
"0.6679925",
"0.6667995",
"0.66664124",
"0.6663752",
"0.6656645",
"0.66143996",
"0.65855455",
"0.65730673",
"0.65689796",
"0.65664357",
"0.6565404",
"0.65609896",
"0.6555774",
"0.654089",
"0.65407485",
"0.65407485",
"0.6538103",
"0.6522685",
"0.6513069",
"0.65076107",
"0.64992577",
"0.6447354",
"0.6436179",
"0.6421142",
"0.6409669",
"0.63812655",
"0.6376715",
"0.63701457",
"0.6369706",
"0.63629985",
"0.63546145",
"0.63546145",
"0.63546145",
"0.63546145",
"0.6347025",
"0.6333529",
"0.63136536",
"0.6313083",
"0.6312527",
"0.6309885",
"0.6309238",
"0.6298798"
] | 0.7551595 | 16 |
General check to see if cart is valid | def update_quantities!
@products = products.reduce([]) do |products, product|
# If product is not published
if !product.variant.published
set_error(:item_not_for_sale, item: product.variant.name)
# If product is not in stock
elsif !product.variant.in_stock?
set_error(:item_out_of_stock, item: product.variant.name)
# If product's available stock is less than required quantity
elsif !product.variant.available_for(product.quantity)
set_error(
:not_enough_stock_for_item,
item: product.variant.name, stock: product.variant.in_stock
)
product.quantity = product.variant.in_stock
products << product if product.quantity > 0
# Else, keep product as is in cart
else product.variant.unlimited_stock || product.variant.in_stock >= product.quantity
products << product
end
products
end
# TODO: Doesn't work, think in something else ...
if discount_code == false
set_error(:invalid_discount_code)
end
reset! if @products.length == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_not_product_item\n\t\tif product_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'This item is in a shopping cart')\n\t\t\treturn false\n\t\tend\n\t\t\t\n\t\t\t\n\tend",
"def cart_check\n puts \"cart checking\"\n \n sleep(2)\n mini_cart_text.click\n wait_for_spinner\n sleep(2)\n puts @prod2 = cartpage_productname.text.downcase\n if(@prod1 == @prod2)\n puts \"product is added to the cart: PASS\"\n else\n puts \"product is not added to the cart: FAIL\" # cart is invalid ie when items in the cart are sold out \n end\n end",
"def cart_not_empty\n if @cart.line_items.length <= 0\n redirect_to :controller=>'cart', :action=>'show'\n return false\n end\n end",
"def validate_product_quantity_in_stock\n init_order_and_order_item\n session[:cart].values.each do |item|\n product = Product.find_by id: item[\"product_id\"].to_i\n next if conditional_checking(product, item)\n @order.errors.add(:unit_in_stock, add_flash_danger(product))\n end\n return if @order.errors.blank?\n render :new\n end",
"def ensure_cart_isnt_empty\n if @cart.line_items.empty?\n redirect_to store_index_url, notice: 'Cart is empty'\n end\n end",
"def valid_for?(cart)\n minimum_order_value.nil? || minimum_order_value < cart.item_sum\n end",
"def ecommerce_verify_cart_errors(cart)\n errors = []\n # products verification\n cart.product_items.decorate.each do |item|\n unless item.is_valid_qty?\n product = item.product.decorate\n errors << t('plugins.ecommerce.messages.not_enough_product_qty', product: product.the_title, qty: product.the_qty_real, default: 'There is not enough products \"%{product}\" (Available %{qty})')\n end\n end\n\n # coupon verification\n res = cart.discount_for(cart.coupon)\n if res[:error].present?\n errors << commerce_coupon_error_message(res[:error], res[:coupon])\n cart.update_column(:coupon, '')\n end\n\n args = {cart: cart, errors: errors}; hooks_run(\"commerce_on_error_verifications\", args)\n errors\n end",
"def require_cart_to_have_items\n if shopping_cart.empty?\n redirect_to(cart_items_path, alert: 'Tu carrito está vacio, deberías agregar items a tu carrito antes.')\n end\n end",
"def ecommerce_verify_cart_errors(cart)\n errors = []\n # products verification\n cart.product_items.decorate.each do |item|\n unless item.is_valid_qty?\n product = item.product.decorate\n errors << t('plugins.ecommerce.messages.not_enough_product_qty', product: product.the_variation_title(item.variation_id), qty: product.the_qty(item.variation_id), default: 'There is not enough products \"%{product}\" (Available %{qty})')\n end\n end\n\n # coupon verification\n res = cart.discount_for(cart.coupon)\n if res[:error].present?\n errors << commerce_coupon_error_message(res[:error], res[:coupon])\n cart.update_column(:coupon, '')\n end\n\n args = {cart: cart, errors: errors}; hooks_run(\"commerce_on_error_verifications\", args)\n errors\n end",
"def cart_item_check\n cart_item = current_end_user.cart_items\n unless cart_item.exists?\n redirect_to items_path\n end\n end",
"def valid?\n return false if @quantity.nil?\n return false if @unit_price.nil?\n true\n end",
"def not_refer_to_cart_item\n if cart_items.empty?\n return true\n else\n errors.add(:base, I18n.t('models.product.validations.lines'))\n return false\n end\n end",
"def ensure_not_referenced_by_any_cart_item\n if cart_items.empty?\n return true\n else\n errors.add(:base, 'Cart Items present')\n return false\n end\n end",
"def validate_line_item\n if @line_item = @quote.line_items.find(params[:id])\n return true\n else\n flash.now[:alert] = 'Order item is not in your cart.'\n respond_to do |format|\n format.html { render 'show' }\n format.json { render json: { result: 'false', errors: flash[:alert] }, status: 401 }\n end\n return false\n end\n end",
"def non_existing_cart\n\t\t# A user goes to the orders page\n\t\tget \"/carts/243233\"\n\n\t\t# He is re directed to store index with a error message at the top of the page\n\t\tassert_redirected_to store_url\n\t\tassert_equal 'Invalid cart', flash[:notice]\n\n\t\t# An email is sent to the Administrator telling the error had occured.\n\t\tmail = ActionMailer::Base.deliveries.last\n\t\tassert_equal [\"marcotello@grupovidanta.com\"], mail.to\n\t\tassert_equal 'Depot Application <depot@example.com>', mail[:from].value\n\t\tassert_equal 'Pragmatic Store Error Raised', mail.subject\n\n\tend",
"def check_session\n \n # check session for cart exists?\n if session[:cart]\n \n # if session exists then assign it to @cart\n @cart = session[:cart]\n # store the @cart.items array in a variable\n @cart_items = @cart.items\n \n # check the @cart_items length greater than two\n if @cart_items.length > 2\n # set the @cart_flag to 1\n session[:cart_flag] = 1\n else\n # set the cart_flag to 0\n session[:cart_flag] = 0\n end\n \n else\n session[:cart_flag] = 0\n end\n \n end",
"def valid_item_code?(item_code)\n @product = Product::PRODUCTS[item_code]\n (!@product.nil? && !@product.empty?)\n end",
"def is_valid_qty?\n (get_product.the_qty(object.variation_id) - object.qty).to_i >= 0\n end",
"def is_cart_empty?\n total_price = self.get_total_price\n\n if total_price > 0\n return false\n else\n return true\n end\n end",
"def confirm\n elements=CartItem.where(:cart_id=>current_user.cart.id)\n\n # if there are no items in the cart, the order will not be placed\n if elements.length==0\n redirect_to carts_path, :notice => \"EMPTY CART!!!\"\n end\n\n # Checks to see if any item in the cart is low in stock. If so, abort. If not, update the sales, and stock quantity of the items\n out_of_stock_items=Item.check_validity(elements)\n\n # This actually checks if any items are below stock\n if out_of_stock_items.length!=0\n redirect_to carts_path, :notice => Item.show_low_stock_message(out_of_stock_items)\n else\n # Save the changes in sales and stocks.\n Item.save_sales(elements)\n #after all the validations are processed, the pre-place order view will be rendered\n @item_list=CartItem.where(:cart_id => current_user.cart.id)\n end\n end",
"def has_items?\n\t\tget_cart_items.size > 0\n\tend",
"def non_existing_cart\n\t\t# A user goes to the orders page\n\t\tget \"/orders/243233\"\n\n\t\t# He is re directed to store index with a error message at the top of the page\n\t\tassert_redirected_to store_url\n\t\tassert_equal 'Invalid order', flash[:notice]\n\n\t\t# An email is sent to the Administrator telling the error had occured.\n\t\tmail = ActionMailer::Base.deliveries.last\n\t\tassert_equal [\"marcotello@grupovidanta.com\"], mail.to\n\t\tassert_equal 'Depot Application <depot@example.com>', mail[:from].value\n\t\tassert_equal 'Pragmatic Store Error Raised', mail.subject\n\n\tend",
"def fetch_cart_and_check_inventory\n @cart = Cart.find_or_create_by user_id: @current_user.id\n\n # Check user's line items against current inventory levels\n updated_line_items = []\n\n @cart.line_items.each do |item|\n if item.quantity > item.product_size.quantity\n update_qty = item.get_update_qty item.quantity\n item.update quantity: update_qty\n updated_line_items << item\n end\n end\n\n # If items in the user's cart had to be adjusted,\n # redirect to carts#user_cart and set flash error\n if updated_line_items.length > 0\n flash[:item_error] = \"Sorry, stock is running low. Your shopping basket has been adjusted accordingly.\"\n redirect_to cart_path\n return\n end\n end",
"def check_cart_full?\n current_cart.destroy if current_cart.present? && !current_cart.is_full?\n end",
"def check_if_cart_is_empty_or_session_cart_id_is_nil\n\n @cart = Cart.find_by(id: session[:cart_id]) if session[:cart_id] =! nil\n if session[:cart_id] == nil && @cart.order_items.empty?\n redirect_to root_path\n \n flash.notice = \"Please add any product before placing an order\"\n redirect_to root_path\n else\n end\n \n end",
"def valid_coupon?(coupon, cart)\n cart.has_key?(coupon[:item]) && cart[coupon[:item]].fetch(:count) >= coupon[:num]\nend",
"def valid?\n return false if @currency_code.nil?\n return false if @description.nil?\n return false if @original_price.nil?\n return false if @sku.nil?\n return true\n end",
"def valid?\n return false if @inventory_code.nil?\n return false if @plu.nil?\n return false if @name.nil?\n return false if @host_id.nil?\n return false if @size.nil?\n return false if @category.nil?\n return false if @group.nil?\n return false if @master_group.nil?\n return false if @price_level.nil?\n return false if @clerk.nil?\n return false if @location.nil?\n return false if @quantity.nil?\n return false if @total_ex.nil?\n return false if @total_inc.nil?\n return false if @counter.nil?\n return false if @barcode.nil?\n return false if @normal_price.nil?\n return false if @item_cost.nil?\n return false if @tax.nil?\n return false if @tax_free.nil?\n return false if @is_discount.nil?\n return false if @is_refund.nil?\n return false if @is_void.nil?\n return false if @is_surcharge.nil?\n return false if @is_promotion.nil?\n return false if @reason.nil?\n return true\n end",
"def valid?\n return false if !@sku.nil? && @sku.to_s.length > 50\n return false if !@stock_picking_location.nil? && @stock_picking_location.to_s.length > 20\n true\n end",
"def invalid_cart\n redirect_to root_path, notice: I18n.t('carts.name') + I18n.t('messages.not_exist')\n end",
"def is_enough\r\n \tProduct.find(@cart_item.product_id).count - @cart_item.count >= 0\r\n end",
"def valid?\n return false if @beez_up_order_item_id.nil?\n return false if @order_item_order_item_type.nil?\n return true\n end",
"def clean\n # Call method clean! on model\n current_cart.clean!\n flash[:warning] = \"Shopping cart is empty!\"\n redirect_to carts_path \n end",
"def add_in_cart \n product_id=params[:id].to_i\n @product=Product.find(product_id)\n total_request=1\n update_through_cart=0 \n if params.has_key?(:quant) \n total_request=params[:quant][:total_request].to_i\n update_through_cart=1 \n end \n if(check_availabilty(product_id,total_request,update_through_cart))\n update_session(product_id,total_request,update_through_cart)\n else\n flash[:notice] = \"#{Product.find(product_id).name} is not available in this quantity\" \n end\n end",
"def validate_item_quantity\n return true if item.nil?\n unless item.could_be_ordered?(quantity - quantity_was.to_i) # check only quantities diff\n errors.add(:quantity, :could_not_be_ordered)\n end\n end",
"def valid?\n return false if @id.nil?\n return false if @id !~ Regexp.new(/^bck_[a-zA-Z0-9]+$/)\n return false if @auto_reorder.nil?\n return false if @threshold_amount.nil?\n return false if @url.nil?\n return false if @url.to_s.length > 2083\n return false if @url.to_s.length < 1\n return false if @raw_url.nil?\n return false if @raw_url.to_s.length > 2083\n return false if @raw_url.to_s.length < 1\n return false if @front_original_url.nil?\n return false if @front_original_url.to_s.length > 2083\n return false if @front_original_url.to_s.length < 1\n return false if @back_original_url.nil?\n return false if @back_original_url.to_s.length > 2083\n return false if @back_original_url.to_s.length < 1\n return false if @thumbnails.nil?\n return false if @available_quantity.nil?\n return false if @allocated_quantity.nil?\n return false if @onhand_quantity.nil?\n return false if @pending_quantity.nil?\n return false if @projected_quantity.nil?\n return false if @buckslip_orders.nil?\n return false if @buckslip_orders.length < 0\n return false if @stock.nil?\n stock_validator = EnumAttributeValidator.new('String', [\"text\", \"cover\"])\n return false unless stock_validator.valid?(@stock)\n return false if @weight.nil?\n weight_validator = EnumAttributeValidator.new('String', [\"80#\"])\n return false unless weight_validator.valid?(@weight)\n return false if @finish.nil?\n finish_validator = EnumAttributeValidator.new('String', [\"gloss\", \"matte\"])\n return false unless finish_validator.valid?(@finish)\n return false if @status.nil?\n status_validator = EnumAttributeValidator.new('String', [\"processed\", \"rendered\"])\n return false unless status_validator.valid?(@status)\n return false if @object.nil?\n object_validator = EnumAttributeValidator.new('String', [\"buckslip\"])\n return false unless object_validator.valid?(@object)\n return false if @description.to_s.length > 255\n size_validator = EnumAttributeValidator.new('String', [\"8.75x3.75\"])\n return false unless size_validator.valid?(@size)\n true\n end",
"def check_item_cart(book_id)\n return if requests.nil?\n\n check = (book_ids requests).include? book_id\n end",
"def validate\n errors.add_to_base \"Enter atleast one product\" if items.empty?\n end",
"def validate_pricing(promocode, submitted_promocode = nil, cart = nil)\n nil\n end",
"def did_anyone_buy_this_thing?\n if line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items Present')\n return false\n\n end\n end",
"def check_cart item\n \tcheck = false\n \t#Doc tat ca san pham trong cart session\n \tsession[\"cart\"].each do |x|\n \t\t#So sanh ID product voi ID product trong gio hang\n \t\tif x['id'] == item[:id]\n \t\t\tx['quantity'] = x['quantity'] + 1\n \t\t\tx['total'] = x['price'] * x['quantity']\n \t\t\treturn\n \t\tend\n \tend\n \tsession[\"cart\"].push(item)\n end",
"def checkout_allowed?\n order_items.count > 0\n end",
"def verify_cart_shopping_cart_size(count)\n cart_page = MemberManagement::Page::Cart.new $browser\n @soft_asserts.verify { expect(cart_page.shopping_cart_rows.size).to eq count }\n end",
"def checkout_allowed?\n line_items.count > 0\n end",
"def has_invalid_items?\n unless @offer[:items].empty? || @offer[:items].select { |item_name|\n !Inventory.items_and_values.include?(item_name)}.empty?\n add_error(:offer, :items, \"There is an invalid item in the list\")\n error = true\n end\n unless @for[:items].empty? || @for[:items].select { |item_name|\n !Inventory.items_and_values.include?(item_name)}.empty?\n add_error(:for, :items, \"There is an invalid item in the list\")\n error = true\n end\n\n error ||= false\n end",
"def determine_valid_product(product)\n valid = true\n if @products.has_key?(product)\n valid\n else\n puts \"Undefined product: #{product}\"\n puts \"\"\n valid = false\n end\n end",
"def update\n # find order item by params id\n\n if order_item_params[:quantity].to_i == 0\n @orders_item.destroy\n flash.now[:danger] = \"Removed item from your cart\"\n redirect_to order_path(@current_order.id)\n else\n if @orders_item && @orders_item.product.can_purchase?(order_item_params[:quantity].to_i) && @orders_item.update(order_item_params)\n flash[:success] = \"The cart item #{@orders_item.product.name} has been updated\"\n redirect_to order_path(@current_order.id)\n elsif @orders_item && !@orders_item.product.can_purchase?(order_item_params[:quantity].to_i) #the order item exists and it was invalid input for quantity\n flash.now[:danger] = \"There is not enought stock to add that quantity to the cart!\"\n redirect_to order_path(@current_order.id)\n else\n flash[:danger] = \"Something went wrong\"\n redirect_to order_path(@current_order.id)\n end\n end\nend",
"def missing_product_code?\n product_code.to_s == ''\n end",
"def display_cart\n @items = @cart.items\n if @items.empty?\n redirect_to_index(\"Your cart is currently empty\")\n end\n\n if params[:context] == :checkout\n render(:layout => false)\n end\n end",
"def create\n exist = false\n current_user.carts.each do |c|\n if c.item == cart_params.fetch(\"item\")\n exist = true\n break\n end\n end\n if !exist \n @cart = current_user.carts.new(cart_params)\n else\n @cart = User.new.carts.new\n end\n if @cart.save\n redirect_to view_cart_path\n else\n redirect_to view_cart_path\n end\n end",
"def check_product_quantity\n if self.product.present?\n if self.quantity.present? && self.product.required_quantity.present?\n if self.quantity < self.product.required_quantity || self.quantity.nil?\n self.quantity = self.product.required_quantity unless self.product.required_quantity.nil?\n end\n else\n self.quantity = self.product.required_quantity unless self.product.required_quantity.nil?\n end\n end\n end",
"def checkout\n @items = @cart.items\n if @items.empty?\n redirect_to_index(\"There's nothing in your cart!\")\n else\n @order = Order.new\n end\n end",
"def valid?\n return false if @id.nil?\n return false if @ordertext.nil?\n return false if @amount.nil?\n return false if @vat.nil?\n return false if @quantity.nil?\n return false if @quantity < 1\n return false if @origin.nil?\n origin_validator = EnumAttributeValidator.new('String', [\"plan\", \"add_on\", \"ondemand\", \"additional_cost\", \"credit\", \"discount\", \"setup_fee\"])\n return false unless origin_validator.valid?(@origin)\n return false if @timestamp.nil?\n return false if @amount_vat.nil?\n return false if @amount_ex_vat.nil?\n return false if @unit_amount.nil?\n return false if @unit_amount_vat.nil?\n return false if @unit_amount_ex_vat.nil?\n return false if @amount_defined_incl_vat.nil?\n return true\n end",
"def validate(rid, price, item)\n flag = false\n flag = true if rid > 0 && price > 0.0 && !item.nil? && !item.empty?\n end",
"def valid?\n return false if @merchant_id.nil?\n return false if @capacity.nil?\n return false if @date_time.nil?\n true\n end",
"def valid?\n return false if !@channel_partner_item_id.nil? && @channel_partner_item_id.to_s.length > 30\n return false if !@country_code_of_origin.nil? && @country_code_of_origin.to_s.length > 2\n return false if !@description.nil? && @description.to_s.length > 2000\n return false if !@merchant_item_id.nil? && @merchant_item_id.to_s.length > 20\n return false if !@parent_merchant_item_id.nil? && @parent_merchant_item_id.to_s.length > 20\n return false if !@perishable_class.nil? && @perishable_class.to_s.length > 50\n return false if !@quickbooks_class.nil? && @quickbooks_class.to_s.length > 31\n tax_product_type_validator = EnumAttributeValidator.new('String', ['', 'digital', 'physical', 'service'])\n return false unless tax_product_type_validator.valid?(@tax_product_type)\n true\n end",
"def require_product?\n !!!catalog_request?\n end",
"def require_product?\n !!!catalog_request?\n end",
"def cart(display_cc = false)\n c = Cart.new(self)\n\n tstotal = (tshirts || 0) + (tshirtm || 0) + (tshirtl || 0)+ (tshirtxl || 0) + \n (tshirtxxl || 0) + (tshirtxxxl || 0)\n\n # 2013\n # if staff? \n # tstotal = tstotal - 1\n # tstotal = 0 if tstotal < 0\n # elsif board? # Board gets flat rate, with dorm rooms, sunday arrival and one T-shirt included\n # c.set_quantity(\"Board Member Flat Rate\", 1)\n # tstotal = tstotal - 1\n # tstotal = 0 if tstotal < 0\n # else\n # c.set_quantity(\"Registration\", 1)\n # c.set_quantity(\"Tuition\", participant ? 1 : 0)\n # c.set_quantity(\"Dorm\", dorm ? 1 : 0)\n # c.set_quantity(\"Meals\", meals ? 1 : 0)\n # c.set_quantity(\"No Breakfast\", meals && meals_lunch_and_dinner_only ? 1 : 0)\n # end\n #c.set_quantity(\"Commemorative Wine Glass\", wine_glasses)\n #\n # 2015 pre change\n # elsif board?\n # tstotal = tstotal <= 1 ? 0 : tstotal - 1\n # c.set_quantity(\"Dorm\", (dorm_selection == 'd' || dorm_selection == 's') ? 1 : 0)\n # c.set_quantity(\"Single Room\", dorm_selection == 's' ? 1 : 0)\n # c.set_quantity(\"Meals\", (meals_selection == 'f' || meals_selection == 'l') ? 1 : 0)\n # c.set_quantity(\"No Breakfast\", meals_selection == 'l' ? 1 : 0)\n\n # FIXME: Nothing is preventing these from being mutually exclusive in the database.\n\n if staff?\n tstotal = tstotal <= 1 ? 0 : tstotal - 1\n elsif board? # Board gets flat rate, with dorm rooms, sunday arrival and one T-shirt included\n c.set_quantity(\"Board Member Flat Rate\", 1)\n tstotal = tstotal - 1\n tstotal = 0 if tstotal < 0\n elsif major_volunteer? #Major volunteer -- no registration or tuition, but pay for everything else\n c.set_quantity(\"Dorm\", (dorm_selection == 'd' || dorm_selection == 's') ? 1 : 0)\n c.set_quantity(\"Meals\", (meals_selection == 'f' || meals_selection == 'l') ? 1 : 0)\n c.set_quantity(\"No Breakfast\", meals_selection == 'l' ? 1 : 0)\n c.set_quantity(\"Sunday Arrival\", (sunday && dorm) ? 1 : 0)\n elsif faculty?\n tstotal = tstotal - 1\n tstotal = 0 if tstotal < 0\n else\n c.set_quantity(\"Registration\", 1)\n c.set_quantity(\"Tuition\", participant ? 1 : 0)\n c.set_quantity(\"Dorm\", (dorm_selection == 'd' || dorm_selection == 's') ? 1 : 0)\n c.set_quantity(\"Meals\", (meals_selection == 'f' || meals_selection == 'l') ? 1 : 0)\n c.set_quantity(\"No Breakfast\", meals_selection == 'l' ? 1 : 0)\n c.set_quantity(\"Sunday Arrival\", (sunday && dorm) ? 1 : 0)\n end\n\n # Add-ons for everybody\n c.set_quantity(\"Tshirts\", tstotal)\n c.set_quantity(\"Single Room\", (dorm_selection == 's') ? 1 : 0)\n c.set_quantity(\"Commemorative Wine Glass\", wine_glasses)\n donation ? c.install_charge(\"Donation\", donation) : c.set_quantity(\"Donation\", 0)\n\n c\n end",
"def on_cart_page?\n expect(page).to have_current_path(customer_cart_path)\n end",
"def validate_can_purchase\n\n return error_with_data(\n 'um_ea_1',\n 'Sale is not active',\n 'Sale is not active',\n GlobalConstant::ErrorAction.default,\n {}\n ) if !@client_token_sale_details.is_token_sale_live?\n\n return error_with_data(\n 'um_ea_2',\n 'Invalid action',\n 'Invalid action',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @client_token_sale_details.ethereum_deposit_address.blank?\n\n return error_with_data(\n 'um_ea_3',\n 'Unauthorized to purchase',\n 'Unauthorized to purchase',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @user_kyc_detail.blank? || !@user_kyc_detail.kyc_approved? ||\n (@client.is_whitelist_setup_done? && !@user_kyc_detail.done_whitelist_status?)\n\n success\n end",
"def test_should_checkout_with_unavailable_products\n # Add full quantity of an item to the cart.\n @product = items(:towel)\n xhr(:post, :add_to_cart_ajax, :id => @product.id, :quantity => @product.quantity)\n assert_response :success\n assert_equal 1, assigns(:order).items.length\n\n # Emulate another customer purchasing items before we checkout\n @product.update_attribute(:quantity, 1)\n\n get :checkout\n assert_response :success\n assert_template 'checkout'\n assert_equal \"Please enter your information to continue this purchase.\", assigns(:title)\n assert_not_nil assigns(:cc_processor)\n \n # Post to it an order.\n post :checkout,\n :order_account => {\n :cc_number => \"4007000000027\",\n :expiration_year => 4.years.from_now.year,\n :expiration_month => \"1\"\n },\n :shipping_address => {\n :city => \"\",\n :zip => \"\",\n :country_id => countries(:US).id,\n :first_name => \"\",\n :telephone => \"\",\n :last_name => \"\",\n :address => \"\",\n :state => \"\"\n },\n :billing_address => @scrooge_address.attributes,\n :order_user => {\n :email_address => \"uncle.scrooge@whoknowswhere.com\"\n }\n \n assert_redirected_to :action => :index\n assert flash[:notice].include?(\"have gone out of stock before you could purchase them\")\n end",
"def validate\n # Not not perform basic Api::Product validations\n end",
"def validate_records\n have_enough_items_to_trade?\n end",
"def no_cart?(user_id)\n Order.where(:checked_out => false, :user_id => user_id).empty?\nend",
"def show\n assert_product_is_accessible!\n add_to_cart = true\n @login_required = false\n\n # does the product have active price policies?\n unless @product.available_for_purchase?\n add_to_cart = false\n @error = \"not_available\"\n end\n\n # is user logged in?\n if add_to_cart && acting_user.blank?\n @login_required = true\n add_to_cart = false\n end\n\n # when ordering on behalf of, does the staff have permissions for this facility?\n if add_to_cart && acting_as? && !session_user.operator_of?(@product.facility)\n add_to_cart = false\n @error = \"not_authorized_acting_as\"\n end\n\n # does the user have a valid payment source for purchasing this reservation?\n if add_to_cart && acting_user.accounts_for_product(@product).blank?\n add_to_cart = false\n @error = \"no_accounts\"\n end\n\n # does the product have any price policies for any of the groups the user is a member of?\n if add_to_cart && !price_policy_available_for_product?\n add_to_cart = false\n @error = \"not_in_price_group\"\n end\n\n # is the user approved?\n if add_to_cart && !@product.can_be_used_by?(acting_user) && !session_user_can_override_restrictions?(@product)\n if SettingsHelper.feature_on?(:training_requests)\n if TrainingRequest.submitted?(session_user, @product)\n flash[:notice] = text(\".already_requested_access\", product: @product)\n return redirect_to facility_path(current_facility)\n else\n return redirect_to new_facility_product_training_request_path(current_facility, @product)\n end\n else\n add_to_cart = false\n @error = \"requires_approval\"\n end\n end\n\n if @error\n flash.now[:notice] = text(@error, singular: @product.class.model_name.to_s.downcase,\n plural: @product.class.model_name.human(count: 2).downcase)\n end\n\n @add_to_cart = add_to_cart\n @active_tab = \"home\"\n render layout: \"application\"\n end",
"def valid?\n return false if !@item_id.nil? && @item_id.to_s.length > 6\n return false if !@item_id.nil? && @item_id.to_s.length < 1\n true\n end",
"def fail_add_shoppingcart\n\t\tstock = @product.stock\n\t\t@msg_type = \"danger\"\n\t\t@msg = \"Sorry, the maximum ordering amount for each item is #{Rails.configuration.max_order_quantity}.\"\n\tend",
"def require_email\n return true unless new_record? or state == 'cart'\n end",
"def valid?\n return false if @plan.nil?\n return false if !@amount.nil? && @amount < 0\n return false if !@quantity.nil? && @quantity < 1\n return false if !@plan_version.nil? && @plan_version < 1\n return false if !@grace_duration.nil? && @grace_duration < 0\n return false if @signup_method.nil?\n return true\n end",
"def add_to_cart\n # Params to find product and how much to place in cart\n product_name = params['name']\n product_id = params['item_id']\n product_quantity = params['quantity'].to_s\n\n # Making sure necessary params are not empty\n if (product_name.empty? && product_id.empty?) || product_quantity.empty?\n @return = { 'Error': 'Quantity must be specified'} if product_quantity.empty?\n @return = { 'Error': 'One of name or item_id must be specified' } if product_id.empty? && product_name.empty?\n @return = { 'Error': 'Quantity and one of name or item_id must be specified' } if product_id.empty? && product_name.empty? && product_quantity.empty?\n else\n # Finding product\n if product_name.present?\n product_name.capitalize\n @return = Product.find_by(name: product_name)\n else\n @return = Product.find_by(item_id: product_id)\n end\n\n if @return.nil? # Making sure product was found\n @return = { 'Error': 'Product not found' }\n else\n stock = @return.quantity\n\n if stock == 0\n @return = { 'Error': 'Product is sold out' }\n elsif stock < product_quantity.to_i\n @return = { 'Error': 'Not enough stock left to meet quantity' }\n else\n if Cart.find_by(item_id: @return.item_id).present?\n @return = { 'Error': 'Product already exists in cart'}\n else\n Cart.create(name: @return.name, description: @return.description, item_id: @return.item_id, price: @return.price, quantity: product_quantity)\n @return = { 'Success': product_quantity + ' x ' + @return.name + ' added to cart!' }\n end\n end\n end\n end\n render json: @return\n end",
"def valid?\n return false if @account.nil?\n return false if @currency.nil?\n return true\n end",
"def ensure_cart\n @cart = Order.find_by(id: session[:order_id])\n\n if @cart.nil?\n @cart = Order.make_cart\n session[:order_id] = @cart.id\n end\n\n if @cart.nil?\n flash[:error] = \"A problem occurred. The shopping cart could not be found.\"\n redirect_to root_path\n end\n\n @cart.status = \"pending\"\n @cart.save\n end",
"def invalid_cart\n logger.error \"Cart cannot be accessed - #{params[:id]}\"\n redirect_to root_path, notice: \"Cart cannot be accessed. Please try again.\"\n end",
"def test_check_inventory\n # Create a cart and add some products.\n a_cart = Order.new\n a_cart.add_product(items(:red_lightsaber), 2)\n a_cart.add_product(items(:blue_lightsaber), 4)\n assert_equal a_cart.items.length, 2\n \n an_out_of_stock_product = items(:red_lightsaber)\n assert an_out_of_stock_product.update_attributes(:quantity => 1)\n \n # Assert that the product that was out of stock was removed.\n removed_products = a_cart.check_inventory\n assert_equal removed_products, [an_out_of_stock_product.name]\n\n # Should last the right quantity of the rest.\n assert_equal a_cart.items.length, 1\n end",
"def valid?\n return false if !@store_id.nil? && @store_id.to_s.length > 20\n return false if @transaction_amount.nil?\n return false if @transaction_type.nil?\n return false if !@hosted_payment_page_text.nil? && @hosted_payment_page_text.to_s.length > 255\n true\n end",
"def product_present\n if product.nil?\n errors.add(:product, 'is not valid.')\n end\n end",
"def confirm_checkout\n lineItems = LineItem.find_all_by_user_id(current_user.id)\n if(lineItems)\n @transaction = Transaction.create(:buyer_id => current_user.id)\n user = current_user\n baddress = params[:address]\n bzipcode = params[:zipcode]\n if(!baddress || !bzipcode || baddress.length <=0 || bzipcode.length <=0)\n redirect_to cart_checkout_path, :notice => 'Please enter the address' #TODO: This notice should appear on page\n elsif (!params[:card][:user_id] || params[:card][:user_id].length<=0)\n redirect_to cart_checkout_path, :notice => 'Please select a credit card for payment'\n else\n if(params[:saddress] && params[:szipcode] && params[:saddress].length>0 && params[:szipcode].length == 5 )\n @saddress = params[:saddress]\n @szipcode = params[:szipcode]\n else\n @saddress= baddress\n @szipcode = bzipcode\n end\n\n\n @confirmed_items = \"\"\n @unavailable_items = \"\"\n @orders = []\n if @transaction.save\n lineItems.each do |lineItem|\n if(lineItem.line_item_type==9)\n order = Order.new\n item = Item.find(lineItem.item_id)\n auction = Auction.find_by_id(lineItem.auction_id)\n if(auction.state==1)\n auction.update_attribute(:state,2)\n order.billing_address = baddress + bzipcode\n order.shipping_address = @saddress + @szipcode\n order.item_quantity = lineItem.quantity\n order.price = Auction.find_by_item_id(lineItem.item_id).bid_amount\n order.total_price = Auction.find_by_item_id(lineItem.item_id).bid_amount * lineItem.quantity\n order.transaction_id = @transaction.id\n order.seller_id = item.user_id\n order.buyer_id = current_user.id\n order.item_id = item.id\n order.state = 0\n\n if(!order.save)\n redirect_to \"back\", :notice => \"Error creating order, or contact administrator with this message\"\n else\n @orders.push(order)\n @confirmed_items = @confirmed_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n NotifyUser.order_confirmation(user,@confirmed_items,@orders).deliver\n lineItem.destroy\n end\n end\n\n end\n\n\n if(lineItem.line_item_type==0)\n order = Order.new\n item = Item.find(lineItem.item_id)\n if(lineItem.quantity<=item.availability)\n order.billing_address = baddress + bzipcode\n order.shipping_address = @saddress + @szipcode\n order.item_quantity = lineItem.quantity\n order.price = item.price\n order.total_price = Float(item.price) * lineItem.quantity\n order.transaction_id = @transaction.id\n order.seller_id = item.user_id\n order.buyer_id = current_user.id\n order.item_id = item.id\n order.state = 0\n\n if(order.save)\n item.sold_count += lineItem.quantity\n item.availability -= lineItem.quantity\n item.save\n @orders.push(order)\n @confirmed_items = @confirmed_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n NotifyUser.order_confirmation(user,@confirmed_items,@orders).deliver\n lineItem.destroy\n else\n redirect_to :back, :notice => \"Error creating order, verify your inputs or contact administrator with this message\"\n end\n else\n @unavailable_items = @unavailable_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n end\n end\n end\n end\n end\n #redirect_to :action => 'index', :controller => 'orders'\n else\n redirect_to :back, :notice => 'Unknown processing error. Please verify your orders' #TODO: Cart screen\n end\n end",
"def check_line_items_quantities?\n self.line_items.each do |line_item|\n line_item_addresses_quantity = line_item.line_item_addresses.pluck(:quantity).sum\n if line_item.quantity == line_item_addresses_quantity\n line_item.line_item_addresses.each do |line_item_address|\n if line_item_address.quantity < 1\n unless self.user.quadvision_user.quadvision_delivery_addresses.pluck(:id).include?(line_item_address.address.id)\n return false\n end\n end\n end\n else\n return false\n end\n end\n return true\n end",
"def validate(order)\n raise \"Total price is incorrect!\" if calculate_price != expected_price\n end",
"def valid?\n return false if !@description.nil? && @description.to_s.length > 512\n return false if !@merchant_id.nil? && @merchant_id.to_s.length > 5\n return false if !@merchant_item_id.nil? && @merchant_item_id.to_s.length > 20\n true\n end",
"def valid?\n return false if @marketplace_technical_code.nil?\n return false if @account_id.nil?\n return false if @beez_up_order_id.nil?\n return false if @marketplace_business_code.nil?\n return false if @order_marketplace_order_id.nil?\n return false if @order_status_beez_up_order_status.nil?\n return false if @order_purchase_utc_date.nil?\n return false if @order_last_modification_utc_date.nil?\n return false if @order_marketplace_last_modification_utc_date.nil?\n return false if @processing.nil?\n return false if @etag.nil?\n return false if @links.nil?\n return false if @order_items.nil?\n return false if @transition_links.nil?\n return true\n end",
"def multiple_items?\n self.frontend == :shopcart\n end",
"def add_to_cart (data)\n added = false\n data.each do |product_data|\n products = product_data[:product]\n if products != nil\n @browser.goto(@custom_base_url + products[:url])\n products[:attributes].each do |attribute|\n @browser.select_list(attribute[:identifier],attribute[:element]).select attribute[:select] if attribute[:select]\n @browser.radio(attribute[:identifier],attribute[:element]).set if attribute[:radio]\n @browser.text_field(attribute[:identifier],attribute[:element]).set attribute[:text] if attribute[:text]\n end\n #add the qty to the json data\n @browser.text_field(:id, \"qty\").set '3'\n @helper.custom_click_button :title, 'Add to Cart'\n # assert_section 'cart'\n #cart tests \n added = true\n end\n end\n exit 1 if !added\n end",
"def check_shop_details\n\t \tunless @shop.domain.present? && @shop.email.present? && @shop.currency_symbol.present? && @shop.currency.present?\n \t\tcurrency_symbol = ISO4217::Currency.from_code(@current_shop.currency).symbol\n\t \t\t@shop.update(email: @current_shop.email,domain: @current_shop.domain,currency_symbol: currency_symbol,currency: @current_shop.currency)\n\t \tend\n\t end",
"def user_buying_unsigned?\n if session[:cart_id]\n cart = Cart.find_by(id: session[:cart_id])\n # if current and devise the user just logged\n # and only gets session cart, if there is cart_offers in it\n devise_controller? && current_user && cart&.cart_offers.present?\n else\n # if session has not cart_id, the user just logged out\n false\n end\n end",
"def check_luxire_inventory\n order = Spree::Order.find(params[:order_id])\n line_items = order.line_items\n line_items.each do |line_item|\n variant = Spree::Variant.find(line_item.variant_id)\n product = variant.product\n unless Spree::Product.non_depletable_product.include? product.name.downcase\n length_required_per_product = product.luxire_product.length_required\n quantity = line_item.quantity\n stock = product.luxire_stock\n unless stock.backorderable\n total_length_required = length_required_per_product * quantity\n if(stock.virtual_count_on_hands - total_length_required < 0)\n response = {msg: \"#{product.name} is out of stock\"}\n render json: response.to_json, status: 422 and return\n end\n end\n end\n end\n end",
"def update\n cart_item = current_user.cart.cart_items.where(\"item_id = ?\", cart_items_params[:item_id]).first\n cart_item.quantity += cart_items_params[:quantity].to_i\n if cart_item.quantity < 1\n if cart_item.delete\n @cart = CartItem.where(cart_id: current_user.cart_id).order(created_at: :desc)\n render 'carts/show'\n else\n render json: ['no such product in the cart'], status: 404\n end\n else\n if cart_item.save\n @cart = CartItem.where(cart_id: current_user.cart_id).order(created_at: :desc)\n render 'carts/show'\n else\n render cart_item.errors.full_messages, status: 422\n end\n end\n end",
"def added_to_cart?(product)\n return false unless user_signed_in?\n return false if current_user.shopping_cart.blank?\n current_user.shopping_cart.includes_product?(product)\n end",
"def update_cart\n product = Product.find_by_cs_sku(params[:sku])\n item = ReservedItem.where('user_id = ? and product_id = ? and session_id = ?', current_user.id,\n product.id,\n session.id).first\n qty = BigDecimal.new(get_qty)\n\n if available?(product, item, qty)\n product.update_attribute(:qty, (product.qty + item.qty) - qty)\n item.update_attribute(:qty, qty)\n respond_with_format { @cart.update_item(params[:sku], get_qty) }\n else\n flash[:error] = 'Not enough item in inventory'\n respond_with_format\n end\n end",
"def valid?\n return false if @amount.nil?\n return false if @cardnumber.nil?\n return false if @cardnumber.to_s.length > 22\n return false if @cardnumber.to_s.length < 12\n return false if !@csc.nil? && @csc.to_s.length > 4\n return false if !@csc.nil? && @csc.to_s.length < 3\n return false if !@currency.nil? && @currency.to_s.length > 3\n return false if !@currency.nil? && @currency.to_s.length < 3\n return false if @expmonth.nil?\n return false if @expmonth > 12\n return false if @expmonth < 1\n return false if @expyear.nil?\n return false if @expyear > 2100\n return false if @expyear < 2000\n return false if @identifier.nil?\n return false if @identifier.to_s.length > 50\n return false if @identifier.to_s.length < 4\n return false if @merchantid.nil?\n return false if !@trans_info.nil? && @trans_info.to_s.length > 50\n return false if !@trans_type.nil? && @trans_type.to_s.length > 1\n true\n end",
"def create\r\n @cart_item = CartItem.new(cart_item_params)\r\n @cart_item.user = current_user\r\n\r\n if is_enough && @cart_item.save\r\n @cart_item.buy # pre-emtively \"buys\" the item to save it from other users\r\n flash[:notice] = \"Item was added to cart!\"\r\n else\r\n flash[:danger] = \"Item could not be added to cart!\"\r\n end\r\n redirect_to products_path\r\n end",
"def empty_item_list?\n if @offer[:items] && @offer[:items].empty?\n error = true\n add_error(:offer, :items, \"Empty item-list is not allowed\")\n end\n\n if @for[:items] && @for[:items].empty?\n error = true\n add_error(:for, :items, \"Empty item-list is not allowed\")\n end\n\n error ||= false\n end",
"def valid?\n !vendor_no.nil? && !name.nil?\n end",
"def valid?\n valid = true\n\n if self.name.nil? || self.name == \"\"\n valid = false\n end\n\n if self.general_info.nil? || self.general_info == \"\"\n valid = false\n end\n\n if self.technical_specs.nil? || self.technical_specs == \"\"\n valid = false\n end\n\n if self.where_to_buy.nil? || self.where_to_buy == \"\"\n valid = false\n end\n\n product_to_find = DATABASE.execute(\"SELECT name FROM products;\")\n\n product_to_find.each do |names|\n if names[\"name\"] == @name\n valid = false\n end\n end\n\n return valid\n end",
"def is_it_in_the_shopping_cart?(user)\n cart = user.shopping_carts.find_by(status: 'open')\n\n if cart\n CartProduct.find_by(shopping_cart: cart, product: self).present?\n else\n false\n end\n end",
"def available?\n cart.respond_to?(:adjustments)\n end",
"def test_when_created_be_empty\n a_cart = Order.new\n \n assert_equal a_cart.items.size, 0\n assert_equal a_cart.tax, 0.0\n assert_equal a_cart.total, 0.0\n assert_equal a_cart.shipping_cost, 0.0\n end",
"def not_paid_at_all\n\t\tget_cart_pending_balance == get_cart_price\n\tend",
"def valid?\n return false if @seller_fulfillment_order_id.nil?\n return false if @marketplace_id.nil?\n return false if @displayable_order_id.nil?\n return false if @displayable_order_date.nil?\n return false if @displayable_order_comment.nil?\n return false if @shipping_speed_category.nil?\n return false if @destination_address.nil?\n return false if @received_date.nil?\n return false if @fulfillment_order_status.nil?\n return false if @status_updated_date.nil?\n true\n end",
"def check_stock\n receiving_details.each{|p|\n #errors.add(:quantity, \" in size #{p.product_size.size_detail.size_number} can't be more than PO quantity\") if p.product_size.size_detail.present? && p.quantity.to_i > ProductDetail.find_by_warehouse_id_and_product_size_id(origin_warehouse_id, p.product_size_id).available_qty.to_i\n }\n end"
] | [
"0.73606306",
"0.7079607",
"0.7047941",
"0.6979637",
"0.69685185",
"0.69503045",
"0.6945538",
"0.6928824",
"0.6911176",
"0.6888914",
"0.68579835",
"0.68327284",
"0.67756546",
"0.6747164",
"0.6687966",
"0.6687386",
"0.6667642",
"0.6659361",
"0.6607726",
"0.65892345",
"0.6561191",
"0.65365857",
"0.648534",
"0.64723253",
"0.6468481",
"0.64415365",
"0.63893306",
"0.63465476",
"0.6273265",
"0.6246739",
"0.6214756",
"0.6213876",
"0.6196183",
"0.61954135",
"0.6195135",
"0.61941737",
"0.61874354",
"0.6186204",
"0.6160958",
"0.61445206",
"0.6140175",
"0.6139421",
"0.61365515",
"0.61109966",
"0.605962",
"0.6053127",
"0.6038946",
"0.60309106",
"0.6024249",
"0.6012936",
"0.60000217",
"0.59761924",
"0.5966924",
"0.5964288",
"0.5959658",
"0.59575677",
"0.5945458",
"0.5945458",
"0.5940426",
"0.59327537",
"0.5926227",
"0.5921614",
"0.59174",
"0.59146774",
"0.5909397",
"0.5905521",
"0.590456",
"0.5897294",
"0.5880354",
"0.587397",
"0.58737504",
"0.5869141",
"0.5868529",
"0.5864745",
"0.584873",
"0.58463496",
"0.5844762",
"0.5843633",
"0.5837216",
"0.5829919",
"0.58278877",
"0.5826449",
"0.58140856",
"0.58073205",
"0.5785895",
"0.57825536",
"0.57752436",
"0.57752264",
"0.5766885",
"0.5765368",
"0.5765",
"0.5755297",
"0.57547337",
"0.57484645",
"0.5747735",
"0.57451344",
"0.5742049",
"0.5733576",
"0.57311547",
"0.57222533",
"0.57089245"
] | 0.0 | -1 |
Address Allows setting use_another_address_for_shipping attribute, ensuring it is stored as a Boolean value and not a number string | def use_another_address_for_shipping=(val)
value = val.is_a?(String) ? (val.to_i > 0) : val
@use_another_address_for_shipping = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone_shipping_address\n if Spree::AddressBook::Config[:show_bill_address_on_cc_form] == false\n if self.ship_address\n self.bill_address = self.ship_address\n end\n else\n if self.bill_address_id == nil\n self.bill_address = self.ship_address\n end\n end\n true\n end",
"def ship_address=(address)\n be_default = Spree::Config.automatic_default_address\n save_in_address_book(address.attributes, be_default) if address\n end",
"def set_shipping_address(address)\n @fields.merge!(address.to_hash)\n end",
"def ship_to_address\n (shipping_address || user.shipping_address || user.billing_address).try(:full_address)\n end",
"def ship_to_address(options)\n for setting in [:first_name, :last_name, :company, :city, :state, :zip, :country] do\n if options[setting] then\n add_field 'x_ship_to_' + setting.to_s, options[setting]\n end\n end\n raise 'must use :address1 and/or :address2' if options[:address]\n add_field 'x_ship_to_address', (options[:address1].to_s + ' ' + options[:address2].to_s).strip\n end",
"def shipping_address\n source = shipping_address_customization || order\n source.shipping_address\n end",
"def seller_address? \r\n sold_by_business? && user.has_address? rescue false\r\n end",
"def needs_address?\n !flagged? && !sent?\n end",
"def shipping_address\n default_shipping_address ? default_shipping_address : shipping_addresses.first\n end",
"def shipping_address\n default_shipping_address ? default_shipping_address : shipping_addresses.first\n end",
"def address?\n if self.address\n return false\n else\n return true\n end\n end",
"def addressing_ok?\n if billing_address.nil?\n return false\n elsif billing_address.filled_in? and (shipping_address.nil? or !shipping_address.filled_in?)\n return true\n elsif billing_address.filled_in? and shipping_address.filled_in?\n return false\n else\n return false\n end\n end",
"def before_address\n @order.bill_address ||= current_user.try(:bill_address).try(:clone) || Address.new(:country => default_country)\n @order.ship_address ||= current_user.try(:ship_address).try(:clone) || Address.new(:country => default_country)\n end",
"def shipping_address=( address )\n return unless address and address.is_a? Address\n \n duplicate_address = Address.where( frame_id: address.frame_id,\n first_name: address.first_name,\n last_name: address.last_name,\n address_1: address.address_1,\n address_2: address.address_2,\n city: address.city,\n province: address.province,\n country: address.country,\n postal_code: address.postal_code ).first\n \n if duplicate_address\n self.shipping_address_id = duplicate_address.id\n else\n address.save\n self.shipping_address_id = address.id\n end\n end",
"def billing_address\n default_billing_address ? default_billing_address : shipping_address\n end",
"def billing_address\n default_billing_address ? default_billing_address : shipping_address\n end",
"def has_shipping?\n return false unless customer_required?\n order_type.has_shipping?\n end",
"def require_shipping(require_shipping = nil)\n return unless require_shipping == false\n\n @fields.delete_if do |k, _|\n k.start_with?('HPP_SHIPPING_') || k == 'HPP_ADDRESS_MATCH_INDICATOR'\n end\n end",
"def shipping?\n true\n end",
"def primary_shipping_address\n self.customers_shipping_address.find_by(primary: true).address\n end",
"def vault_shipping_address\n return nil if shipping_details.id.nil?\n @gateway.address.find(customer_details.id, shipping_details.id)\n end",
"def tax_address\n self.ship_address || self.bill_address\n end",
"def supports_cash_addr_format?\n false\n end",
"def setup_address_hash(options)\n default_address = {\n address1: 'Unspecified',\n city: 'Unspecified',\n state: 'NC',\n zip: '00000',\n country: 'US'\n }\n\n submitted_address = options[:billing_address] || options[:address] || default_address\n options[:billing_address] = default_address.merge(submitted_address.symbolize_keys) { |_k, default, submitted| check_billing_field_value(default, submitted) }\n options[:shipping_address] = options[:shipping_address] || {}\n end",
"def with_address?(address)\n return false\n if address_today_paid(address) > 0\n (order_price + address_today_paid(address)) > Setting.instance.max_total_per_day\n end\n end",
"def shipping (address)\n if address.include? (\"Mexico\")\n \"Order received\"\n else \n \"We only ship orders to Mexico\"\n end \nend",
"def shipping?\n @config[:shipping].present? and shipping.present?\n end",
"def primary_shipping_address\n self.customers_shipping_address.find_by(primary: true).address\nend",
"def save\n \tself.errors = [\"Shipping Addresses are readonly\"]\n \treturn false\n end",
"def save\n \tself.errors = [\"Shipping Addresses are readonly\"]\n \treturn false\n end",
"def is_free_shipping\n end",
"def add_address(post, options)\n if address = options[:billing_address] || options[:address]\n post[:ci_billaddr1] = address[:address1]\n post[:ci_billaddr2] = address[:address2] if address[:address2]\n post[:ci_billcity] = address[:city]\n post[:ci_billstate] = address[:state]\n post[:ci_billzip] = address[:zip]\n post[:ci_billcountry] = address[:country]\n end\n\n if address = options[:shipping_address]\n post[:ci_shipaddr1] = address[:address1]\n post[:ci_shipaddr2] = address[:address2] if address[:address2]\n post[:ci_shipcity] = address[:city]\n post[:ci_shipstate] = address[:state]\n post[:ci_shipzip] = address[:zip]\n post[:ci_shipcountry] = address[:country]\n end\n end",
"def shipping_address_post\n params[:address][:country] = params[:address][:state].split(\"-\")[0]\n params[:address][:state] = params[:address][:state].split(\"-\")[1]\n @address = Address.new(params[:address])\n @address.customer = @customer\n if @address.save\n @cart.shipping_address = @address\n unless @cart.billing_address\n @cart.billing_address = @address\n end\n if @cart.save\n redirect_to build_url_options_for_checkout\n return\n end\n else\n flash[:error] = @address.errors.full_messages.join('<br/>')\n render :action => 'shipping_address'\n end\n end",
"def full_order_to_address\n ship_address.address1 + ' ' + ship_address.address2\n end",
"def payer_address_two(*options)\n @payer.address_two.to_s.strip.upcase\n end",
"def add_address(request, address)\r\n return if address.nil?\r\n request.Set(RocketGate::GatewayRequest::BILLING_ADDRESS, address[:address1])\r\n request.Set(RocketGate::GatewayRequest::BILLING_CITY, address[:city])\r\n request.Set(RocketGate::GatewayRequest::BILLING_ZIPCODE, address[:zip])\r\n request.Set(RocketGate::GatewayRequest::BILLING_COUNTRY, address[:country])\r\n\r\n#\r\n#\tOnly add the state if the country is the US or Canada.\r\n#\t \r\n if address[:state] =~ /[A-Za-z]{2}/ && address[:country] =~ /^(us|ca)$/i\r\n request.Set(RocketGate::GatewayRequest::BILLING_STATE, address[:state].upcase)\r\n end\r\n end",
"def default_billing_address(options={})\n unless self.billing_address\n self.build_billing_address(options.merge({\n :company_name => self.company_name, :academic_title_id => self.academic_title_id, :gender => self.gender,\n :first_name => self.first_name, :last_name => self.last_name,\n :street => self.business_address.street, :street_number => self.business_address.street_number,\n :note => self.business_address.note, :postal_code => self.business_address.postal_code,\n :city => self.business_address.city, :country_code => self.business_address.country_code,\n :email => self.email}))\n else\n self.billing_address\n end\n end",
"def address_two=(address_two)\n if !address_two.nil? && address_two.to_s.length > 30\n fail ArgumentError, 'invalid value for \"address_two\", the character length must be smaller than or equal to 30.'\n end\n\n pattern = Regexp.new(/(?=.*[^\\s])^[^|]+$/)\n if !address_two.nil? && address_two !~ pattern\n fail ArgumentError, \"invalid value for \\\"address_two\\\", must conform to the pattern #{pattern}.\"\n end\n\n @address_two = address_two\n end",
"def address_from_spree_address(address)\n ::ShipCompliant::Address.new(\n first_name: address.first_name,\n last_name: address.last_name,\n country: address.country.iso,\n city: address.city,\n state: address.try(:state).try(:abbr),\n street1: address.address1,\n street2: address.address2,\n zip1: address.zipcode.try(:[], 0...5)).address\n end",
"def add_address(options)\n address = options[:billing_address]\n\n post = {}\n post['Address 1'] = address[:address1] unless empty?(address[:address1])\n post['Address 2'] = address[:address2] unless empty?(address[:address2])\n post['City'] = address[:city] unless empty?(address[:city])\n post['State or Province'] = address[:state] unless empty?(\n address[:state]\n )\n post['ZIP or Postal Code'] = address[:zip] unless empty?(address[:zip])\n post['Country'] = address[:country] unless empty?(address[:country])\n\n post\n end",
"def set_prober_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def address_valid?(validation_contexts)\n return true if address.nil?\n return true unless reg_company_contact_address_yes_no == 'N' || reg_company_contact_address_yes_no.to_s.empty?\n\n address.valid?(validation_contexts)\n end",
"def set_Address2(value)\n set_input(\"Address2\", value)\n end",
"def define_address_line2\n @address_line2 = Faker::Address.secondary_address\n @address_line2 = '' unless @set_blank == false\n end",
"def set_postal_address\n\n\tpostal_address = PostalAddress.find_by_postal_address_type_code_and_city_and_address1_and_address2(self.postal_address_type_code,self.city,self.address1,self.address2)\n\t if postal_address != nil \n\t\t self.postal_address = postal_address\n\t\t return true\n\t else\n\t\terrors.add_to_base(\"combination of: 'postal_address_type_code' and 'city' and 'address1' and 'address2' is invalid- it must be unique\")\n\t\t return false\n\tend\nend",
"def shipper_address\n @shipper_address ||= SimpleShipping::Address.new(\n :country_code => 'US',\n :state_code => 'TX',\n :city => 'Texas',\n :street_line => 'SN2000 Test Meter 8',\n :postal_code => '73301'\n )\n end",
"def add_shipping_address(_params, customer, subscription)\n # Adding address to the subscription for shipping product to the customer.\n # Sends request to the ChargeBee server and adds the shipping address \n # for the given subscription Id.\n result = ChargeBee::Address.update({\n :subscription_id => subscription.id, \n :label => \"shipping_address\", \n :first_name => customer.first_name, \n :last_name => customer.last_name, \n :addr => _params[\"addr\"], \n :extended_addr => _params[\"extended_addr\"],\n :city => _params[\"city\"], \n :state => _params[\"state\"], \n :zip => _params[\"zip_code\"]\n })\n end",
"def address_change\n @update_cart_invoice = zip_code_changed?\n true\n end",
"def address_two=(address_two)\n\n if !address_two.nil? && address_two.to_s.length > 50\n fail ArgumentError, \"invalid value for 'address_two', the character length must be smaller than or equal to 50.\"\n end\n\n @address_two = address_two\n end",
"def assign_addresses\n self.billing_address ||= Address.default(store)\n self.shipping_address ||= Address.default(store)\n\n if billing_group && billing_group.billing_address.present?\n billing_address.copy_from(billing_group.billing_address)\n end\n if shipping_group && shipping_group.shipping_address.present?\n shipping_address.copy_from(shipping_group.shipping_address)\n end\n check_separate_shipping_address\n end",
"def requires_shipping\n requires = false\n self.order_line_items.each do |li|\n if li.variant.requires_shipping\n requires = true\n break\n end\n end\n return requires\n end",
"def clone_billing_address\n self.ship_address = self.bill_address if self.bill_address\n end",
"def tvc_address?\n self.id == Rails.application.config.fedex_vc_address_id || (self.first_name == \"The Visible\" && self.last_name == \"Closet\")\n end",
"def addresses_set\n if @cart.shipping_address.nil?\n redirect_to :action=>'shipping_address'\n return false\n elsif @cart.billing_address.nil?\n redirect_to :action=>'billing_address'\n return false\n end\n end",
"def set_address_type\n\n end",
"def recipient_address\n @recipient_address ||= SimpleShipping::Address.new(\n :country_code => 'US',\n :state_code => 'MN',\n :city => 'Minneapolis',\n :street_line => 'Nightmare Avenue 13',\n :postal_code => '55411'\n )\n end",
"def associate_address\n order = Spree::Order.where(\"email = ?\", @user.email).order(\"created_at\").last\n if order.present?\n @user.update_attributes(bill_address_id: order.billing_address.id, ship_address_id: order.shipping_address.id)\n end\n end",
"def street_address(include_secondary=false)\n Faker::Address.street_address(include_secondary: include_secondary)\n end",
"def valid_shipping_cost?(cost)\n flatrate_shipping_option_costs.member? cost\n end",
"def set_street_address_2_update\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_2, @customer.street_address_2)\n end",
"def update_order_addresses\n order = current_order\n if order.bill_address.blank? || order.shipping_address.blank?\n order.bill_address ||= build_bill_address(payment_details_response)\n order.shipping_address ||= build_shipping_address(payment_details_response)\n\n complete_order_step(order, 'address')\n end\n end",
"def before_address\n @order.bill_address ||= Spree::Address.default\n @order.ship_address ||= Spree::Address.default\n\n @restaurants = Restaurant.all\n end",
"def set_street_address_2_save\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_2, @customer.street_address_2)\n end",
"def secondary_address; end",
"def add_original_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def check_for_eligible_of_free_shipping(order)\n if order > 100\n return true\n else\n return false\n end\nend",
"def delink_addresses_validation\n if bill_address.try(:user_id)\n bill_copy = bill_address.clone_without_user\n bill_copy.save\n self.bill_address = bill_copy\n end\n\n if ship_address && (\n ship_address.user_id ||\n (ship_address.id && ship_address.id == bill_address.try(:id)) ||\n (ship_address.changed? && ship_address == bill_address))\n ship_copy = ship_address.clone_without_user\n ship_copy.save\n self.ship_address = ship_copy\n shipments.update_all address_id: ship_address_id\n end\n end",
"def address_selected?\n return unless address_line1.to_s.empty? || town.to_s.empty?\n\n errors.add(:postcode, :address_not_chosen)\n end",
"def street_address(include_secondary=false)\n Faker::Address.street_address(include_secondary)\n end",
"def billing_address=( address ) \n return unless address and address.is_a? Address\n \n duplicate_address = Address.where( frame_id: address.frame_id,\n first_name: address.first_name,\n last_name: address.last_name,\n address_1: address.address_1,\n address_2: address.address_2,\n city: address.city,\n province: address.province,\n country: address.country,\n postal_code: address.postal_code ).first\n \n if duplicate_address\n self.billing_address_id = duplicate_address.id\n else\n address.save\n self.billing_address_id = address.id\n end\n end",
"def ship_address_tax_update\n if ship_address and (ship_address_id_changed? or ship_address.changed?)\n create_avalara_tax_adjustment\n end\n end",
"def billing_address=(address)\n @billing_address = ensure_type(Address, address)\n end",
"def street_address(include_secondary: T.unsafe(nil)); end",
"def can_update_addresses?\n !complete?\n end",
"def address\n load_step # Need to load the account to make the decision\n if AccountType.other_organisation?(@account.account_type)\n # Uses overrides as the address is at address.company not at company\n wizard_address_step(STEPS, address_attribute: :org_address,\n next_step: :address_next_step)\n elsif AccountType.registered_organisation?(@account.account_type)\n wizard_address_step(STEPS, address_not_required: :reg_company_contact_address_yes_no,\n next_step: :address_next_step)\n else # must be individual\n wizard_address_step(STEPS, next_step: :address_next_step)\n end\n end",
"def confirm_shipping_addr1_label\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.span.id(create_ats_regex_string(\"ShippingAddressLine1Label\")), format_method(__method__))\n end",
"def set_local_address(opts)\n opts = check_params(opts,[:addresses])\n super(opts)\n end",
"def populate_billing_address!(options)\n options['contract.default'].billing_address ||= Address.new\n end",
"def fake_address\n {\n first_name: 'Jack',\n last_name: 'Macdowall',\n company_name: 'Macdowalls',\n line_1: '1225 Invention Avenue',\n line_2: 'Birmingham',\n postcode: 'B21 9AF',\n county: 'West Midlands',\n country: 'UK'\n }\n end",
"def use_for_local_addresses=(value)\n @use_for_local_addresses = value\n end",
"def validate_shippable\n if !shipping || !shipping.valid\n code = use_another_address_for_shipping ?\n shipping_address.country : billing_address.country\n country = Glysellin::Helpers::Countries::COUNTRIES_LIST[code]\n\n errors.add(\n :shipping_method_id,\n I18n.t(\n \"glysellin.errors.cart.shipping_method_unavailable_for_country\",\n method: shipping_method.name,\n country: country\n )\n )\n end\n end",
"def delivery_address_update\n # stores the current delivery address\n delivery_address = @current_user.addresses.find_by(delivery_address: true)\n delivery_address.delivery_address = nil\n delivery_address.save!\n # changes the current delivery address to the given address id as a parameter\n address = @current_user.addresses.find(params[:id])\n address.delivery_address = true\n address.save!\n redirect_to cart_items_path\n end",
"def set_buyer_payout(address)\n if buyer_payout && buyer_payout.btc_amount > 0 && !buyer_payout.paid\n self.buyer_payout.btc_address = address\n self.buyer_payout.save\n else\n false\n end\n end",
"def check_order_address(user, order, type)\n addr = order.send(type)\n user ||= order.user\n\n if addr && addr.user_id && addr.user_id != user.try(:id)\n raise \"Order #{order.id} has address that belongs to user #{addr.user_id.inspect} instead of #{user.try(:id).inspect}\"\n end\n\n addr\n end",
"def constructShippingAddress(tmp_email_order_hash, email_order_hash)\n\t\temail_order_hash[:ship_to_first_name] = tmp_email_order_hash[\"response\"][\"order\"][\"ship_to_first_name\"].to_s\n\t\temail_order_hash[:ship_to_last_name] = tmp_email_order_hash[\"response\"][\"order\"][\"ship_to_last_name\"].to_s\n\t\temail_order_hash[:ship_to_company] = tmp_email_order_hash[\"response\"][\"order\"][\"ship_to_company\"].to_s\n\t\temail_order_hash[:ship_to_addr1] = tmp_email_order_hash[\"response\"][\"order\"][\"ship_to_addr1\"].to_s\n\t\temail_order_hash[:ship_to_addr2] = tmp_email_order_hash[\"response\"][\"order\"][\"ship_to_addr2\"].to_s\n\t\temail_order_hash[:ship_to_city] = tmp_email_order_hash[\"response\"][\"order\"][\"ship_to_city\"].to_s\n\t\temail_order_hash[:ship_to_state] = tmp_email_order_hash[\"response\"][\"order\"][\"ship_to_state\"].to_s\n\t\temail_order_hash[:ship_to_zip] = tmp_email_order_hash[\"response\"][\"order\"][\"ship_to_zip\"].to_s\n\t\temail_order_hash[:ship_to_phone] = formatPhoneNumber(tmp_email_order_hash[\"response\"][\"order\"][\"ship_to_phone\"].to_s)\n\t\temail_order_hash[:ship_to_phone] = tmp_email_order_hash[\"response\"][\"order\"][\"ship_to_phone\"].to_s\n\t\temail_order_hash[:shipping_address] = \"#{email_order_hash[:ship_to_first_name]} #{email_order_hash[:ship_to_last_name]}<br />\"\n\t\temail_order_hash[:shipping_address] += \"#{email_order_hash[:ship_to_company]}<br />\" if email_order_hash[:ship_to_company] !=\"\"\n\t\temail_order_hash[:shipping_address] += \"#{email_order_hash[:ship_to_addr1]}<br />\"\n\t\temail_order_hash[:shipping_address] += \"#{email_order_hash[:ship_to_addr2]}<br />\" if email_order_hash[:ship_to_addr2] !=\"\"\n\t\temail_order_hash[:shipping_address] += \"#{email_order_hash[:ship_to_city]}, #{email_order_hash[:ship_to_state]} #{email_order_hash[:ship_to_zip]}<br />\"\t\n\t\temail_order_hash[:shipping_address] += \"#{email_order_hash[:ship_to_phone]}<br />\" if email_order_hash[:ship_to_phone] !=\"\"\n\t\t\n\tend",
"def set_shipping_info\n if params[:address_id]\n @cart.set_shipping_info(params[:address_id].to_i)\n redirect_to billing_address_account_path\n else\n @address_book = AddressBook.find_or_new(params[:address_book], @cart.buyer)\n render :update do |page|\n if @address_book.save\n @cart.set_shipping_info(@address_book.id)\n page.redirect_to confirm_order_account_path\n else\n page.show \"#message-wraper\"\n page.replace_html \"#message-wraper\", error_messages_for('address_book', :object => @address_book)\n end\n end\n end\n end",
"def ship_to_existing\n address = Address.find params[:id]\n unless address.customer_id.eql?(@customer.id)\n redirect_to :controller=>'cart', :action=>'shipping_address'\n return\n end\n\n @cart.shipping_address = address\n unless @cart.billing_address\n @cart.billing_address = address\n end\n @cart.save\n redirect_to build_url_options_for_checkout\n end",
"def it_should_ensure_only_one_address_has_field_true field\n it \"should ensure only one address has field #{field} set to true\" do\n user = FactoryGirl.create :user\n first_address = FactoryGirl.create :address, :user => user, field => true\n\n # creation of second address with value true should update first's field\n # value to false\n FactoryGirl.create :address, :user => user, field => true\n\n first_address.reload.send(field).should eq false\n end\n end",
"def address2_set(address)\n self.address2.set address\n end",
"def has_shipping_weight?\n weight and use_weight_for_shipping?\n end",
"def edit_frontend_address(user, address, expect_success, values, default_bill=nil, default_ship=nil)\n address = address.id if address.is_a?(Spree::Address)\n\n visit spree.account_path\n if address\n click_link \"edit_address_#{address}\"\n expect(current_path).to eq(spree.edit_address_path(address))\n else\n within('#addresses > tbody > tr:first-child') do\n click_link Spree.t(:edit)\n end\n end\n\n fill_in_address(values)\n check_frontend_defaults(default_bill, default_ship)\n\n click_button Spree.t(:update)\n\n if expect_success\n expect(page).to have_content(Spree.t(:successfully_updated, :resource => Spree.t(:address1)))\n expect(current_path).to eq(spree.account_path)\n expect_frontend_addresses(user)\n else\n expect(page).to have_no_content(Spree.t(:successfully_updated, :resource => Spree.t(:address1)))\n end\n end",
"def payment_address!\n return unless currency.coin?\n record = payment_address\n\n # The address generation process is in progress.\n if record.address.blank?\n record\n else\n # allows user to have multiple addresses.\n payment_addresses.create!(currency: currency)\n end\n end",
"def address_one=(address_one)\n if address_one.nil?\n fail ArgumentError, 'address_one cannot be nil'\n end\n\n if address_one.to_s.length > 50\n fail ArgumentError, 'invalid value for \"address_one\", the character length must be smaller than or equal to 50.'\n end\n\n pattern = Regexp.new(/(?=.*[^\\s])^[^|]+$/)\n if address_one !~ pattern\n fail ArgumentError, \"invalid value for \\\"address_one\\\", must conform to the pattern #{pattern}.\"\n end\n\n @address_one = address_one\n end",
"def create_shipping_address(customer_id, num_states, is_primary)\n\tshipping_state = State.all[rand(num_states)]\n\tshipping_address = Address.create!(\n\t\tstreet: Faker::Address.street_address,\n\t\tcity: Faker::Address.city,\n\t\tstate: shipping_state,\n\t\tzipcode: Faker::Address.zip\n\t)\n\tCustomersShippingAddress.create!(customer_id: customer_id, address: shipping_address, primary: is_primary)\nend",
"def full_address(include_country = false, include_secondary = false)\n address = \"#{street_address(include_secondary)} #{postal_code} #{city}\"\n address = \"#{address} POLOGNE\" if include_country\n address\n end",
"def test_get_shipping_prices\n # Test a national shipping order.\n assert_same_elements @order.get_shipping_prices, OrderShippingType.get_domestic\n \n # Turn it into an international one and test.\n an_address = order_addresses(:santa_address)\n an_address.country = countries(:GB)\n an_address.save\n @order.reload\n assert_same_elements @order.get_shipping_prices, OrderShippingType.get_foreign\n \n # Now we say that we are in that same other country.\n prefs = {\n \"store_home_country\" => countries(:GB).id\n }\n assert Preference.save_settings(prefs)\n \n # And that same shipment should be national now.\n assert_same_elements @order.get_shipping_prices, OrderShippingType.get_domestic\n end",
"def set_for_manual_address\n @show_manual_address = true\n @address_read_only = false\n # clear the identifier as this address is no longer from the search\n @address_detail.address_identifier = nil\n end",
"def create\n user_id = @current_user.id\n input_address = params[:address].delete(\" \").delete(\",\").capitalize # removes all spaces and comma's from the newly entered address.\n address = @current_user.addresses\n address_arr = []\n address.each do |a|\n address_arr.push(a.address.delete(\" \").delete(\",\").capitalize)\n end\n # checks whether the address entered already exists for the current user\n unless (address_arr.include?(input_address))\n if (address.empty?) # if user have no address, address created first should be the delivery address.\n new_address = Address.create!(\n :user_id => user_id,\n :address => params[:address],\n :delivery_address => true,\n )\n else\n new_address = Address.create!(\n :user_id => user_id,\n :address => params[:address],\n )\n end\n else\n flash[:error] = \"Already Existing Address!!!\"\n end\n redirect_to cart_items_path\n end",
"def set_street_address_1_update\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_1, @customer.street_address_1)\n end",
"def avalara_eligible?\n if ship_address.present? and ship_address.state.present?\n SpreeAvalara.sales_tax_states.keys.include? ship_address.state.abbr\n else\n false\n end\n end"
] | [
"0.7160694",
"0.707022",
"0.7040528",
"0.69067323",
"0.68452656",
"0.6739886",
"0.668143",
"0.6675411",
"0.64960355",
"0.64960355",
"0.64561355",
"0.6442628",
"0.6440753",
"0.6406462",
"0.64005226",
"0.64005226",
"0.638846",
"0.6365498",
"0.63600713",
"0.6350871",
"0.6248851",
"0.6236811",
"0.6220718",
"0.62157047",
"0.6208128",
"0.61963207",
"0.61883914",
"0.61840606",
"0.6161446",
"0.61612236",
"0.6160404",
"0.6148356",
"0.61284566",
"0.6116371",
"0.6069807",
"0.6046876",
"0.5997849",
"0.59945565",
"0.597215",
"0.59717673",
"0.5926596",
"0.5925283",
"0.5923933",
"0.5921475",
"0.5916104",
"0.59057665",
"0.59010637",
"0.589826",
"0.5894987",
"0.58844733",
"0.5883262",
"0.5880827",
"0.5878491",
"0.58713573",
"0.5864636",
"0.5851859",
"0.58250785",
"0.58223844",
"0.5807811",
"0.5807455",
"0.5806433",
"0.57906795",
"0.5785411",
"0.57704175",
"0.5760554",
"0.5757775",
"0.57388246",
"0.5733676",
"0.57264316",
"0.5725502",
"0.57055557",
"0.5702075",
"0.5700219",
"0.56986266",
"0.5696428",
"0.5686363",
"0.567901",
"0.5676789",
"0.56667376",
"0.56657165",
"0.5659972",
"0.5659727",
"0.5652472",
"0.5650877",
"0.56459594",
"0.5644999",
"0.56398845",
"0.56119967",
"0.56090707",
"0.560494",
"0.5604008",
"0.5603867",
"0.5598433",
"0.55951303",
"0.5594319",
"0.5574471",
"0.5573392",
"0.5565468",
"0.5565169",
"0.5563219"
] | 0.8390254 | 0 |
Set the shipping method id on the cart by creating the corresponding adjustment at the same time to ensure cart price and recap takes shipping costs into account | def shipping_method_id=(val)
@shipping_method_id = val
if shipping_method_id
adjustments.reject! { |a| a.type == "shipping-method" }
adjustment = Glysellin::Cart::Adjustment::ShippingMethod.new(self,
shipping_method_id: shipping_method_id
)
adjustments << adjustment
end
@shipping_method_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_shipping_method\n @shipping_method = ShippingMethod.find(params[:id])\n end",
"def shipping_method=(method)\n raise ArgumentError.new(\"method cannot be nil\") unless method.present?\n self.shipping_name = method.name\n self.shipping_cost = method.cost\n end",
"def set_shipmentmethod\r\n @shipmentmethod = Shipmentmethod.find(params[:id])\r\n end",
"def update_shipping_methods\n @retailer = Retailer.find(params[:retailer_id])\n params[:retailer][:shipping_method_ids] ||= []\n @retailer.update_attributes(params[:retailer])\n flash[:notice] = \"Shipping methods have been updated\"\n redirect_to admin_retailer_shipping_methods_url(@retailer)\n end",
"def add_shipping_method(method, name, price)\n @command.create_shipping_method(method) do |sm|\n sm.name = name \n sm.price = Money.new(price * 100, \"USD\")\n sm.create_allowed_area(Google4R::Checkout::WorldArea)\n end\n end",
"def shipping_method\n @shipping_methods = @order.available_shipping_methods\n @shipping_method = @shipping_methods.find(params[:method_id])\n if @shipping_method.shipping_gateway.present?\n @shipping_gateway = @shipping_method.shipping_gateway_class.new(order: @order)\n @data = @shipping_gateway.prepare_interface_data(params)\n else\n @shipping_gateway = nil\n end\n rescue => e\n flash.now[:error] = e.message\n head :unprocessable_entity\n end",
"def shipping\n adjustments.find { |a| a.type == \"shipping-method\" }\n end",
"def set_add_shipping\n @add_shipping = AddShipping.find(params[:id])\n end",
"def create_shipment!\n shipping_method(true)\n\n if shipment.present?\n shipment.update_attributes!(:shipping_method => shipping_method)\n else\n self.shipments << Shipment.create!({ :order => self,\n :shipping_method => shipping_method,\n :address => self.ship_address}, :without_protection => true)\n end\n \n end",
"def perform_get_shipping_methods_thru_cart(session_id, cart_id, version, ship_addr1, ship_addr2, ship_city, ship_state, ship_zip, ship_country, promo_code, cart_items)\n $tracer.trace(\"GameStopShippingServiceDSL: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n get_available_shipping_methods_req = self.get_request_from_template_using_global_defaults(:get_available_shipping_methods, ShippingServiceRequestTemplates.const_get(\"GET_AVAILABLE_SHIPPING_METHODS#{version}\"))\n get_available_shipping_methods_req.find_tag(\"session_id\").at(0).content = session_id\n get_available_shipping_methods_req.find_tag(\"targeting_context\").items.name_value_property.remove_self\n get_available_shipping_methods_req.find_tag(\"client_channel\").content = 'GS-US'\n get_available_shipping_methods_req.find_tag(\"locale\").content = 'en-US'\n\n get_available_shipping_methods_data = get_available_shipping_methods_req.find_tag(\"get_available_shipping_methods_request\").at(0)\n get_available_shipping_methods_data.customer_id.content = cart_id\n get_available_shipping_methods_data.customer_loyalty_number.content = nil\n\n if !promo_code.empty?\n get_available_shipping_methods_data.promocodes.at(0).string.content = promo_code\n else\n get_available_shipping_methods_data.promocodes.remove_self\n end\n\n cart_items.each_with_index do |cart, i|\n get_available_shipping_methods_req.find_tag(\"shipment\").at(0).clone_as_sibling if i > 0\n shipments_data = get_available_shipping_methods_req.find_tag(\"shipment\").at(i)\n\n line_item = shipments_data.line_items.line_item.at(0)\n line_item.line_item_id.content = cart.line_item_id.content\n line_item.list_price.content = cart.list_price.content\n line_item.quantity.content = cart.quantity.content\n line_item.sku.content = cart.sku.content\n\n ship_to_data = shipments_data.ship_to.at(0)\n ship_to_data.address_id.content = generate_guid\n ship_to_data.city.content = ship_city\n ship_to_data.country_code.content = ship_country\n ship_to_data.line1.content = ship_addr1\n ship_to_data.line2.content = ship_addr2\n ship_to_data.postal_code.content = ship_zip\n ship_to_data.state.content = ship_state\n shipments_data.shipment_id.content = generate_guid #shipment_id\n shipments_data.shipment_type.content = 'ShipToAddress' #shipment_type\n end\n\n $tracer.trace(get_available_shipping_methods_req.formatted_xml)\n get_available_shipping_methods_rsp = self.get_available_shipping_methods(get_available_shipping_methods_req.xml)\n get_available_shipping_methods_rsp.code.should == 200\n $tracer.trace(get_available_shipping_methods_rsp.http_body.formatted_xml)\n return get_available_shipping_methods_rsp\n end",
"def set_shipping\n @shipping = Shipping.find(params[:id])\n end",
"def create\n all_selected = true\n params[:shipping_category].each_pair do |category_id, rate_id|#[rate]\n if rate_id\n session_admin_cart[:order_items].each do |item|\n if item.second[:variant].product.shipping_category_id == category_id.to_i\n ship_rate = ShippingRate.find(rate_id)\n item.second[:shipping_rate] = ship_rate\n\n end\n end\n else\n all_selected = false\n end\n end\n session_admin_cart[:shipping_rate] = all_selected # complete\n respond_to do |format|\n if all_selected\n format.html { redirect_to(admin_shopping_carts_url, :notice => 'Shipping method was successfully selected.') }\n else\n format.html { redirect_to( admin_shopping_shipping_methods_url, :notice => 'All the Shipping Methods must be selected') }\n end\n end\n end",
"def set_shipping\n @shipping = Shipping.find(params[:id])\n end",
"def set_shipping_line\n @shipping_line = ShippingLine.find(params[:id])\n end",
"def set_shipping\n @shipping = Shipping.find(params[:id])\n authorized_shipping\n end",
"def apply_shipping_cost!(shipment)\n cost = shipment.cost(product_pricing)\n unless cost.nil?\n order_items.create(\n product: shipment.shipping_cost_product,\n amount: 1,\n priority: 1e9,\n price: cost.amount,\n tax_rate: cost.tax_rate,\n price_includes_tax: cost.tax_included,\n label: ''\n )\n end\n order_items.reload\n end",
"def update\n @order.update_attribute(:state, 'cart')\n if params[:shipments_attributes].present?\n if cookies[:board_id].present?\n @order.room_cookie = cookies[:board_id]\n end\n if cookies[:portfolio_id].present?\n @order.portfolio_cookie = cookies[:portfolio_id]\n end\n #params[:shipments_attributes].each do |key, value|\n #\n # shipment = @order.shipments.where(id: value[:id]).first\n # if shipment.present?\n # rate = shipment.shipping_rates.where(id: value[:selected_shipping_rate_id]).first\n #\n # if rate.present?\n # shipment.update_attributes({selected_shipping_rate_id: rate.id, cost: rate.cost})\n # end\n # end\n # shipment.adjustments.create(amount: shipment.cost, source_type: 'Spree::Order', order_id: @order.id, label: 'Shipment')\n #\n # #if @order.adjustments.where(label: 'Shipment').blank?\n # #@order.adjustments.shipping.create(amount: @order.shipments.sum(:cost), source_type: 'Spree::Shipment' ,label: 'Shipment')\n # #end\n #end\n if @order.update_from_params(params, permitted_checkout_attributes)\n persist_user_address\n unless @order.next\n\n flash[:error] = @order.errors.full_messages.join(\"\\n\")\n redirect_to one_page_checkout_path and return\n end\n\n if @order.completed?\n @order.payments.destroy_all if request.put?\n @order.update_totals\n # @order.update(shipment_total: @order.shipments.sum(&:cost))\n shipment_total = @order.shipments.sum(&:cost)\n @order.update(total: @order.item_total + @order.additional_tax_total + shipment_total + @order.promo_total + @order.adjustment_total,shipment_total: shipment_total)#+ @order.adjustment_total\n unless @order.confirmation_delivered?\n @order.deliver_order_confirmation_email\n @order.update_columns(send_order_confirmation_email: true, order_confirmation_sent: true)\n end\n # Rails.logger.info session[:order_id]\n # session[:order_id] = nil\n if @order.subscribe == true\n @subscriber = Spree::Subscriber.find_by_email(@order.email)\n if @subscriber.present?\n @subscriber.update_attribute(\"last_subscribed_at\", Time.now)\n else\n sub = Spree::Subscriber.create(:email => @order.email, :last_subscribed_at => Time.now)\n Rails.logger.info \"ADDED TO MAILCHIMP LIST\" if sub.add_subscriber_to_mailchimp('subscribers')\n end\n end\n\n if @order.user_id.nil? and @order.email.present?\n user = Spree::User.find_by_email(@order.email)\n @order.update_columns(user_id: user.id) if user\n end\n\n flash.notice = Spree.t(:order_processed_successfully)\n flash[:commerce_tracking] = \"nothing special\"\n cookies[:user_movement_id] = nil\n redirect_to order_confirmation_path\n else\n redirect_to checkout_state_path(@order.state)\n end\n else\n\n render :edit\n end\n else\n @order.errors.add(:shipments, \"Can't be blank\")\n flash[:error] = @order.errors.full_messages.join(\"\\n\")\n redirect_to cart_path\n end\n\n end",
"def set_as_default\n store = Breeze::Commerce::Store.first\n unless store.default_shipping_method\n store.default_shipping_method = self\n store.save\n end\n end",
"def set_shipping_information\n @shipping_information = ShippingInformation.find(params[:id])\n end",
"def set_shipping_detail\n @shipping_detail = ShippingDetail.find(params[:id])\n end",
"def shipping_method_code\n hash [\"ShippingMethodCode\"]\n end",
"def set_shipping_service\n @shipping_service = ShippingService.find(params[:id])\n end",
"def set_cartship\n @cartship = Cartship.find(params[:id])\n end",
"def update\n \n @preference = get_preference()\n @preference.shop_url = session[:shopify_domain].to_s\n\n shipping_methods_long_desc_int = params.require('shipping_methods_long_desc_int').permit(:INT_PARCEL_COR_OWN_PACKAGING, :INT_PARCEL_EXP_OWN_PACKAGING, :INT_PARCEL_STD_OWN_PACKAGING, :INT_PARCEL_AIR_OWN_PACKAGING, :INT_PARCEL_SEA_OWN_PACKAGING)\n shipping_methods_allowed_int = params.require('shipping_methods_allowed_int').permit(:INT_PARCEL_COR_OWN_PACKAGING, :INT_PARCEL_EXP_OWN_PACKAGING, :INT_PARCEL_STD_OWN_PACKAGING, :INT_PARCEL_AIR_OWN_PACKAGING, :INT_PARCEL_SEA_OWN_PACKAGING)\n shipping_methods_allowed_dom = params.require('shipping_methods_allowed_dom').permit(:AUS_PARCEL_REGULAR,:AUS_PARCEL_EXPRESS,:AUS_PARCEL_REGULAR_SATCHEL_500G,:AUS_PARCEL_EXPRESS_SATCHEL_500G,:AUS_PARCEL_REGULAR_SATCHEL_3KG,:AUS_PARCEL_EXPRESS_SATCHEL_3KG,:AUS_PARCEL_REGULAR_SATCHEL_5KG, :AUS_PARCEL_EXPRESS_SATCHEL_5KG)\n shipping_methods_long_desc_dom = params.require('shipping_methods_long_desc_dom').permit(:AUS_PARCEL_REGULAR,:AUS_PARCEL_EXPRESS,:AUS_PARCEL_REGULAR_SATCHEL_500G,:AUS_PARCEL_EXPRESS_SATCHEL_500G,:AUS_PARCEL_REGULAR_SATCHEL_3KG,:AUS_PARCEL_EXPRESS_SATCHEL_3KG,:AUS_PARCEL_REGULAR_SATCHEL_5KG, :AUS_PARCEL_EXPRESS_SATCHEL_5KG)\n\n @preference[:shipping_methods_long_desc_int] = shipping_methods_long_desc_int.to_h || {}\n @preference[:shipping_methods_long_desc_dom] = shipping_methods_long_desc_dom.to_h || {}\n @preference[:shipping_methods_allowed_int] = shipping_methods_allowed_int.to_h || {}\n @preference[:shipping_methods_allowed_dom] = shipping_methods_allowed_dom.to_h || {}\n @preference.save\n\n shopify_api_shop = ShopifyAPI::Shop.current \n \n shipping_methods_long_desc_int.each do |method_name, value|\n find_or_create_metafield(shopify_api_shop, method_name, value.to_s) \n end\n \n shipping_methods_long_desc_dom.each do |method_name, value|\n find_or_create_metafield(shopify_api_shop, method_name, value.to_s) \n end\n \n\n respond_to do |format|\n @preference.attributes = preference_params\n @carrier_preference = get_carrier_preference(@preference.carrier)\n \n #get free shipping option\n if @preference.free_shipping_by_collection\n colls = ShopifyAPI::CustomCollection.find(:all)\n\n colls.each do |col|\n free_shipping = (params[\"#{col.title}\"] == \"1\")\n \n update_coll_metafield(col, free_shipping)\n end\n\n colls = ShopifyAPI::SmartCollection.find(:all)\n colls.each do |col|\n free_shipping = params[\"#{col.title}\"] == \"1\"\n \n update_coll_metafield(col, free_shipping)\n end\n end\n installer_class = carrier_installer_class_for('aus_post')\n installer = installer_class.new( session[:shopify_domain], @preference)\n installer.port = request.port if Rails.env.development?\n installer.configure(params)\n\n if @preference.save\n #save carrier preference\n unless params[:carrier_preference].nil?\n @carrier_preference.attributes = params[:carrier_preference] \n @carrier_preference.shop_url = @preference.shop_url\n \n @carrier_preference.save\n end\n installer.install\n\n format.html { redirect_to preferences_url, notice: 'Preference was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @preference.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_product_shipment\n @product_shipment = ProductShipment.find(params[:id])\n end",
"def shipping_item\n shipping_scope.first || shipping_scope.build(shipping_options)\n end",
"def shipping_methods\n @retailer = Retailer.find(params[:retailer_id])\n @shipping_methods = Spree::ShippingMethod.all\n end",
"def set_status_shipping\n @status_shipping = StatusShipping.find(params[:id])\n end",
"def edit\n @order = current_order(session) || create_order(session)\n shipping_methods = Breeze::Commerce::ShippingMethod.unarchived\n unless @order.shipping_method && shipping_methods.include?(@order.shipping_method)\n if Breeze::Commerce::ShippingMethod.count > 1\n @order.shipping_method = shipping_methods.unarchived.where(:is_default => true).first\n else\n @order.shipping_method = shipping_methods.unarchived.first\n end\n @order.save\n end\n end",
"def calculate_shipping\n return :skipped unless basket?\n run_callbacks :shipping_updated do\n shipping_item.update! \\\n display_name: shipping_display_name,\n price: calculate_shipping_cost\n end\n end",
"def set_pay_method\n @pay_method = PayMethod.find(params[:id])\n end",
"def create\n if params[:line_item].has_key? \"option_id\"\n if !params[:line_item][:option_id].eql?(\"\")\n @option = Option.find(params[:line_item][:option_id])\n @line_item = LineItem.find_by_cart_id_and_option_id(current_cart.id, @option.id)\n if @line_item == nil\n # Didn't find existing line_item, create new one\n @line_item = LineItem.create!(:cart => current_cart, :option => @option, :quantity => ((params.has_key? \"quantity\") ? params[:quantity].to_i : 1), :unit_price => @option.price)\n flash[:notice] = \"Added #{@line_item.quantity} #{@option.item.name} - #{@option.details} to cart.\"\n else\n #Found existing line_item, increment quantity\n @line_item.update_attribute(:quantity, @line_item.quantity + ((params.has_key? \"quantity\") ? params[:quantity].to_i : 1))\n flash[:notice] = \"Updated #{@option.item.name} - #{@option.details} in cart to #{@line_item.quantity}.\"\n end\n end\n end\n \n respond_to do |format|\n format.html { redirect_to current_cart_url }\n format.js # create.rjs\n end\n end",
"def set_shipment_product\n @shipment_product = ShipmentProduct.find(params[:id])\n end",
"def shipping_methods\n [\"Next Day Shipping\", \"2 Day Shipping\",\"Ground Service\"]\n end",
"def new\n @shipping_detail = ShippingDetail.new\n @options = ''\n \n unless params[:shipping_detail].nil?\n @product = Product.find(params[:shipping_detail][:product_id])\n @question_response = QuestionResponse.find(params[:shipping_detail][:question_response_id]) \n else\n \n @params_to_pass_to_shipping_details = {}\n\n @product = Product.find(params['product_id'])\n @x = 0\n\n # Add all options\n params.each do |param|\n key = param[0]\n value = param[1]\n\n if key.start_with?('option') \n if value.end_with?('1') == true\n @current_question_option_id = @product.question_options[@x].id\n @options = @options + @current_question_option_id.to_s\n end\n @x = @x + 1\n end\n\n if key.start_with?('option') or key.start_with?('question')\n @params_to_pass_to_shipping_details[key] = value\n end\n end\n\n @question_response = QuestionResponse.new(:product_id => params['product_id'], \n :question_1 => (params[:question_1] == 'answer_1' ? 'True' : 'False'), \n :question_2 => (params[:question_2] == 'answer_5' ? 'True' : 'False'),\n :question_3 => (case params[:question_3] \n when 'answer_5' \n '1' \n when 'answer_6' \n '2'\n when 'answer_7' \n '3'\n when 'answer_8' \n '4'\n else\n '0'\n end),\n :question_4 => @options)\n \n if @question_response.valid?\n @question_response.save\n end\n end\n \n @uuid = nil\n\n # Required by uSell intergration -- Set a 30 day cookie\n if !params[:uuid].nil? # Always transfer to new UUID if uSell provides one\n cookies[:uuid] = { :value => params[:uuid], :expires => 30.day.from_now }\n @uuid = params[:uuid]\n elsif !cookies[:uuid].nil? # If a new UUID is not provided, use the ID from the cookie\n @uuid = cookies[:uuid]\n end\n \n @device = Device.new(:product_id => params['shipping_detail']['product_id'],\n :question_response_id => @question_response.id\n )\n @device.status_code = 0\n \n if @device.valid?\n @device.save\n end\n \n # Assume just 1 device per shipping details\n @shipping_detail.devices[0] = @device\n @shipping_detail.uuid = @uuid unless @uuid.nil?\n @shipping_detail.referer = params[:ref] unless params[:ref].nil?\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shipping_detail }\n end\n end",
"def shipping\n cart = Cart.new(request.cookies[\"cart\"])\n cart.set_extra_data(params)\n shipping_methods = ShippingMethod.lookup_methods(cart)\n render :json => shipping_methods\n end",
"def set_quantity product_id, quantity, options = {}\n options.reverse_merge!(override: false)\n quantity = quantity.to_i\n\n return unless quantity > 0\n\n # If product was in cart\n if (product = self.product(product_id))\n if options[:override]\n product.quantity = quantity\n else\n product.quantity += quantity\n end\n else\n @products << Glysellin::Cart::Product.new(\n id: product_id,\n quantity: quantity\n )\n end\n\n # Refresh discount code adjustment\n self.discount_code = discount_code\n end",
"def shipping_method_name\n hash[\"ShippingMethodName\"]\n end",
"def shipping_method\n VERZENDMETHODE[self.verzendmethode]\n end",
"def add_univstub_with_discount() add_to_cart_common(:add_product, params[:id]) end",
"def shipping\n to_price mapping_for(:shipping)\n end",
"def shipping\n total_quantity = items.inject(0) {|q, item| q + item.quantity}\n if total_quantity == 1\n return items.first.product.base_shipping\n else\n return items.inject(0) {|total, item|\n total + (item.product.add_on_shipping * item.quantity)\n }\n end\n end",
"def change_delivery_drink_quantity\n # get data to add/update\n @data = params[:id]\n @data_split = @data.split(\"-\")\n @add_or_subtract = @data_split[0]\n @user_delivery_id = @data_split[1]\n \n # get User Delivery info\n @account = Account.find_by_id(current_user.account_id)\n @user_subscription = UserSubscriptionn.where(account_id: current_user.account_id, currently_active: true).first\n @user_delivery_info = UserDelivery.find_by_id(@user_delivery_id)\n @delivery = Delivery.find_by_id(@user_delivery_info.delivery_id)\n @inventory = Inventory.find_by_id(@user_delivery_info.inventory_id)\n \n # adjust drink quantity, price and inventory\n @original_quantity = @user_delivery_info.quantity\n @drink_price = @user_delivery_info.inventory. + @user_subscription.pricing_model\n @current_inventory_reserved = @inventory.reserved\n if @add_or_subtract == \"add\"\n # set new quantity\n @new_quantity = @original_quantity + 1\n \n #set new price totals\n @original_subtotal = @delivery.subtotal\n @new_subtotal = @original_subtotal + @drink_price\n @new_sales_tax = @new_subtotal * @account.delivery_zone.excise_tax\n @new_total_price = @new_subtotal + @new_sales_tax\n \n # update reserved inventory \n @new_inventory_reserved = @current_inventory_reserved + 1\n @inventory.update(reserved: @new_inventory_reserved)\n\n # update user delivery info\n @user_delivery_info.update(quantity: @new_quantity)\n \n else\n # set new quantity\n @new_quantity = @original_quantity - 1\n \n #set new price totals\n @original_subtotal = @delivery.subtotal\n @new_subtotal = @original_subtotal - @drink_price\n @new_sales_tax = @new_subtotal * @account.delivery_zone.excise_tax\n @new_total_price = @new_subtotal + @new_sales_tax\n \n # update reserved inventory \n @new_inventory_reserved = @current_inventory_reserved - 1\n @inventory.update(reserved: @new_inventory_reserved)\n \n # update user delivery info\n @user_delivery_info.update(quantity: @new_quantity)\n end\n \n # update delivery info and note a confirmation email should be sent\n @delivery.update(subtotal: @new_subtotal, sales_tax: @new_sales_tax, total_drink_price: @new_total_price, delivery_change_confirmation: false)\n \n # add change to the customer_delivery_changes table\n @customer_delivery_change = CustomerDeliveryChange.where(user_delivery_id: @user_delivery_id).first\n if !@customer_delivery_change.blank?\n @customer_delivery_change.update(new_quantity: @new_quantity, change_noted: false)\n else\n @new_customer_delivery_change = CustomerDeliveryChange.new(user_id: current_user.id, \n delivery_id: @user_delivery_info.delivery_id,\n user_delivery_id: @user_delivery_id,\n beer_id: @user_delivery_info.beer_id,\n original_quantity: @original_quantity,\n new_quantity: @new_quantity,\n change_noted: false)\n @new_customer_delivery_change.save!\n end\n \n # set new delivery details and delivery info\n @next_delivery = UserDelivery.where(delivery_id: @user_delivery_info.delivery_id)\n @delivery = Delivery.find_by_id(@user_delivery_info.delivery_id)\n \n # count number of drinks in delivery\n @drink_count = @next_delivery.sum(:quantity)\n # count number of drinks that are new to user\n @next_delivery_cooler = 0\n @next_delivery_cellar = 0\n @next_delivery_small = 0\n @next_delivery_large = 0\n # cycle through next delivery drinks to get delivery counts\n @next_delivery.each do |drink|\n @quantity = drink.quantity\n if drink.cellar == true\n @next_delivery_cellar += (1 * @quantity)\n else\n @next_delivery_cooler += (1 * @quantity)\n end\n if drink.large_format == true\n @next_delivery_large += (1 * @quantity)\n else\n @next_delivery_small += (1 * @quantity)\n end\n end \n \n respond_to do |format|\n format.js\n end # end of redirect to jquery\n end",
"def add_product_skus\n @order = Spree::Order.find_by_id(params[:order_id])\n @variant = Spree::Variant.find_by_id(params[:variant_id])\n @product = @variant.product\n requested_qty = params[:quantity]\n is_customer_pickup = @order.market_place_details.present? ? (@order.market_place_details[\"OrderType\"] == \"Pickup\" ? true : false) : false\n # code to find the order_total\n if @order.market_place.present?\n case @order.market_place.code\n when \"qoo10\"\n order_total = @order.market_place_details.present? ? @order.market_place_details[\"total\"] : @order.total\n when \"lazada\",'zalora'\n order_total = @order.total\n end\n end\n # code to create line item\n price = @variant.price.present? ? @variant.price : 0.0 \n @line_item = Spree::LineItem.create!(:variant_id=>@variant.id, :order_id=>@order.id, :quantity=>requested_qty, :price=>price, :currency=>@order.currency, :is_pick_at_store => is_customer_pickup)\n if @line_item.present?\n @sellers_market_places_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", @order.seller_id, @order.market_place_id, @product.id).try(:first)\n if @sellers_market_places_product.present?\n @stock_product = Spree::StockProduct.where(\"sellers_market_places_product_id=? AND variant_id=?\", @sellers_market_places_product.id, @variant.id).try(:first)\n if @stock_product.present?\n @stock_product.update_attributes(:count_on_hand=>(@stock_product.count_on_hand - requested_qty.to_i) >= 0 ? (@stock_product.count_on_hand - requested_qty.to_i) : 0)\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - requested_qty.to_i) >= 0 ? (@variant.fba_quantity - requested_qty.to_i) : 0) if !@variant.quantity_inflations.present?\n msg = 'Admin/Orders Controller add_product_skus Line 182'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n else\n @stock_product = Spree::StockProduct.create!(:sellers_market_places_product_id=>@sellers_market_places_product.id, :variant_id=>@variant.id, :count_on_hand=>requested_qty.to_i, :virtual_out_of_stock=>false)\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - requested_qty.to_i) >= 0 ? (@variant.fba_quantity - requested_qty.to_i) : 0) if !@variant.quantity_inflations.present?\n msg = 'Admin/Orders Controller add_product_skus Line 187'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n end\n end\n end\n # code to update order total after creating line item for order\n @order.update_column(:total, order_total)\n @order.reload\n line_items = @order.line_items\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => @order})\n respond_to do |format|\n format.html { render :partial=>\"modify_shipping\", :locals => { :line_items => line_items }}\n end\n end",
"def shipping_method\n @shipping_method ||=\n if ltl_elg_shp_meth_name.nil? then nil\n elsif ltl_elg_shp_meth_name.include?(THRESHOLD) then THRESHOLD\n elsif ltl_elg_shp_meth_name.include?(ROOM_OF_CHOICE) then 'Room of Choice'\n elsif ltl_elg_shp_meth_name.include?(WHITE_GLOVE) then WHITE_GLOVE\n end\n end",
"def calculate cart, current_tax_rate\n net_amount = cart.total_price + (delivery.try(:price) || 0)\n tax_amount = net_amount * current_tax_rate\n self.attributes = { cart_id: cart.id, net_amount: net_amount, tax_amount: tax_amount, gross_amount: net_amount + tax_amount }\n self.save(validate: false)\n \tend",
"def set_default_shipping_price\n if new_record? || shipping_price.blank?\n self.shipping_price = shipping_method.try(:calculate_price, { city_id: city_id , total_price: items_price.to_f }) || 0\n #if city.eql? 'Москва' and items_price > 1000\n #self.shipping_price = 300\n #else\n #self.shipping_price = shipping_method.try(:calculate_price, { city_id: city_id , total_price: items_price.to_f }) || 0\n #end\n end\n end",
"def create_virtual_methods!\n\n unless shipping_methods.to_bilneur.first\n shipping_method = ShippingMethod.new(:calculator => Calculator::FlatRate.new,\n :name => \"Ship to Bilneur\",\n :seller_id => self.id,\n :virtual => true,\n :method_kind => ShippingMethod::METHOD_KIND_TO_BILNEUR,\n :zone_id => Zone.first.try(:id))\n shipping_method.save(:validate => false)\n end\n\n unless shipping_methods.with_seller.first\n shipping_method = ShippingMethod.new(:calculator => Calculator::FlatRate.new,\n :name => \"Store with seller\",\n :seller_id => self.id,\n :virtual => true,\n :method_kind => ShippingMethod::METHOD_KIND_WITH_SELLER,\n :zone_id => Zone.first.try(:id))\n\n shipping_method.save(:validate => false)\n end\n\n end",
"def validate_shipping_method\n if shipping_method && !shipping_method.available?(city_id: city_id)\n errors.add(:shipping_method, :invalid)\n end\n end",
"def shipping_method_params\n # params.require(:shipping_method).permit(:name, :admin_name, :display_on, :shipping_categories)\n params.require(:shipping_method).permit(:name, :admin_name, :display_on, :shipping_category_ids => [])\n end",
"def create\n # Find associated product and current cart\n chosen_cabinet = CabConfig.find(params[:cab_config_id])\n current_cart = @current_cart\n \n # If cart already has this product then find the relevant line_item and iterate quantity otherwise create a new line_item for this product\n if current_cart.cab_configs.include?(chosen_cabinet)\n # Find the line_item with the chosen_product\n @cart_item = current_cart.cart_items.find_by(cab_config_id: chosen_cabinet)\n # Iterate the line_item's quantity by one\n @cart_item.quantity += 1\n else\n @cart_item = CartItem.new\n \n @cart_item.cart = current_cart\n @cart_item.cab_config = chosen_cabinet\n end\n \n\n # Save and redirect to cart show path\n @cart_item.save\n redirect_to cart_path(current_cart)\n end",
"def shipping_class!\n @shipping_class = find_shipping_class(session[:shipping_class_id])\n end",
"def set_shipmment_item\n @shipmment_item = ShipmmentItem.find(params[:id])\n end",
"def create\n @shipping_method = ShippingMethod.new(shipping_method_params)\n respond_to do |format|\n if @shipping_method.save\n format.html { redirect_to [:admin, @shipping_method], notice: 'Shipping method was successfully created.' }\n format.json { render action: 'show', status: :created, location: @shipping_method }\n else\n format.html { render action: 'new' }\n format.json { render json: @shipping_method.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @shipping_method.update(shipping_method_params)\n format.html { redirect_to [:admin, @shipping_method], notice: 'Shipping method was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @shipping_method.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_itemized_shipping\r\n\t\tfor counter in (1..2) do\r\n\t\t\t@cart.add_product products(:cow)\r\n\t\tend\r\n\r\n\t\tfor counter in (1..5) do\r\n\t\t\t@cart.add_product products(:chicken)\r\n\t\tend\r\n\r\n\t\tassert_equal 7, @cart.total_items\r\n\r\n\t\tassert_equal 14.0, @cart.shipping_cost(shipping_zones(:itemized_shipping))\r\n\r\n\t\tfor counter in (1..5) do\r\n\t\t\t@cart.add_product products(:cow)\r\n\t\tend\r\n\r\n\t\tassert_equal 12, @cart.total_items\r\n\r\n\t\tassert_equal 24.0.to_s, @cart.shipping_cost(shipping_zones(:itemized_shipping)).to_s\r\n\tend",
"def set_shipment\n @shipment = @order.shipments.find(params[:id])\n end",
"def shipping=(shipping)\n @shipping = ensure_type(Shipping, shipping)\n end",
"def shipping_method\n object.shipping_method.try(:name)\n end",
"def shipping_method\n #shipping = Shipping.find(self.shipping_method_id)\n self.shipping.display_text\n end",
"def ship_to_existing\n address = Address.find params[:id]\n unless address.customer_id.eql?(@customer.id)\n redirect_to :controller=>'cart', :action=>'shipping_address'\n return\n end\n\n @cart.shipping_address = address\n unless @cart.billing_address\n @cart.billing_address = address\n end\n @cart.save\n redirect_to build_url_options_for_checkout\n end",
"def create\n\n lineItem_details = line_item_params\n item = Item.find_by(:id => lineItem_details['item_id'])\n\n \n if ( !session[:shopping_cart_id] || !ShoppingCart.find(session[:shopping_cart_id]).active )\n @shopping_cart = ShoppingCart.new(:user_id => @current_user.id, :active => true)\n @shopping_cart.save\n session[:shopping_cart_id] = @shopping_cart.id\n end\n\n @shopping_cart = ShoppingCart.find(session[:shopping_cart_id])\n lineItem_details[\"shopping_cart_id\"] = @shopping_cart.id\n lineItem_details[\"quantity_purchased\"] = params[:quantity]\n\n @line_item = LineItem.new lineItem_details\n\n # Update cart\n @cart = ShoppingCart.find(session[:shopping_cart_id])\n\n\n # @li = LineItem.find_by(:shopping_cart_id => session[:shopping_cart_id])\n \n # gon.address = []\n # gon.address << @li.item.user.address\n\n\n respond_to do |format|\n if @line_item.save\n format.html { redirect_to shopping_cart_path(session[:shopping_cart_id]), notice: 'Line item was successfully created.' }\n format.json { render :show, status: :created, location: @line_item }\n else\n format.html { render :new }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def prepare_cart_items(variant_id)\n self.update_attributes(variant_id: variant_id, quantity: 1)\n end",
"def shipping\n if defined?(shipping_rate)\n shipping_rate\n else\n 0\n end\n end",
"def set_cart(cart_id)\t\n\t\t\n\t\t\n\t\tself.cart = Auth.configuration.cart_class.constantize.find(cart_id)\n\t\n\t\t\n\t\tself.cart.prepare_cart\n\t\t\n\n\tend",
"def add_to_cart\n @cart = current_user.carts.find_or_create_by(completed: false)\n @line_item = @cart.line_items.find_or_create_by(product_id: params[:product_id])\n @line_item.update quantity: @line_item.quantity + 1\n end",
"def create\n # Find the item in the user's cart, if the user does not already\n # have the item in their cart, create a new line_item\n current_item = LineItem.find_or_create_by product_size_id: params[:product_size_id], cart_id: @cart.id\n\n # Increment the item's quantity by one\n requested_qty = current_item.quantity + 1\n\n # Invoke method in line_item.rb that checks the\n # requested qty against current stock levels\n update_qty = current_item.get_update_qty requested_qty\n\n # If the user's requested quantity can not be fulfilled, set a flash error\n unless update_qty == requested_qty\n flash[:item_error] = \"Sorry, not enough stock. Your shopping basket has been adjusted accordingly.\"\n end\n\n # Save the line_item update\n current_item.update quantity: update_qty\n\n # Redirect to My Basket page\n redirect_to cart_path\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def finalize_post\n @cart.comments = params[:cart][:comments]\n\n # If it has been too long since shipping was computed\n threshold = (CartConfig.get(:shipping_expiration, :payment) || 3).hours\n ca = @cart.shipping_computed_at\n if ca.nil? or ((ca.localtime + threshold) < Time.now.localtime)\n flash[:warning] = 'Idle time exceeded. ' +\n 'Please check shipping price and confirm payment.'\n render :action => 'finalize'\n return\n end\n\n if @cart.shipping_responses.length == 1\n resp = @cart.shipping_responses.first\n else\n resp = @cart.shipping_responses.find_by_id(params[:shipping_method][:id])\n end\n\n if resp.nil?\n flash[:error] = 'Unable to compute shipping!'\n render :action => 'finalize'\n return\n end\n\n resp.update_attribute :selected, true\n @cart.shipping_price = resp.cost\n\n @cart.tax_price # compute so it will be saved, in case shipping is taxed\n\n # Payment method might not be shown, in case of only one payment method\n # with a radiant integrtion or overridden view. But if it is shown but\n # not selected by customer, prompt them to select.\n if params[:payment] and params[:payment][:method] == '-- SELECT PAYMENT TYPE --'\n flash[:error] = \"Select Payment Type\"\n render :action => 'finalize'\n return\n end\n\n status = CartLib.process_payment(@cart, params)\n\n unless status.is_a?(PaymentResponse) and status.success?\n # wasn't successful, possibly array of multiple failures\n msg = nil\n if status.is_a?(Array)\n status.each do |stat|\n stat.cart = @cart\n stat.save\n end\n\n if status.empty?\n msg = \"Unable to process payment. No payment module installed?\"\n end\n end\n\n msg ||= status.first.message\n flash[:error] = msg\n ErrorMessage.create(\n :scope => 'Payment',\n :message => \"#{@cart.customer.email}: #{msg}\"\n )\n render :action => 'finalize'\n return\n end\n\n status.selected = true\n status.cart = @cart\n status.save\n @cart.error_message = nil\n @cart.mark_as_sold\n @cart.save\n\n fr = CartLib.process_fulfillment @cart\n @cart.fulfillment_responses = fr\n\n sel = fr.select{|x| x.success }.first\n\n # XXX TODO Error check (processed okay, but store admin needs to know)\n # log unsuccessful fulfillment response\n unless sel\n msg = \"Unable to fulfill shipping. #{fr.first.message}\"\n\n ErrorMessage.create(\n :scope => 'Fulfillment',\n :message => \"#{@cart.customer.email}: #{msg}\"\n )\n end\n\n sel.selected = true\n sel.save\n\n session[:cart_id] = nil\n\n redirect_to :controller=>'cart', :action=>'receipt', :id=>@cart.id\n end",
"def update\n @shipping_service.shipping_methods[-1].destroy if @shipping_service.shipping_methods.last.name == '' || @shipping_service.shipping_methods.last.price == nil\n if @shipping_service.update(shipping_service_params)\n redirect_to dashboard_shipping_service_path(@shipping_service), notice: 'Shipping service was successfully updated.'\n else\n render :edit\n end\n end",
"def shipping_category_id\n product.shipping_category_id\n end",
"def set_shipping_region\n raise Error::CustomError.error(422, :SHI_01, \"shipping_region\") unless Number.is_integer?(params[:shipping_region_id])\n begin\n @shipping_region = ShippingRegion.find(params[:shipping_region_id])\n rescue ActiveRecord::RecordNotFound\n raise Error::CustomError.error(404, :SHI_02, \"shipping_region\")\n rescue\n raise Error::CustomError.error(500, :ISE, \"shipping_region\")\n end\n end",
"def create\n @item = Item.new(params[:item])\n @stock = Stock.find_by_color_id_and_body_style_size_id(@item.color.id, @item.body_style_size.id)\n @item.garment = Garment.find_by_stock_id_and_design_id(@stock.id, @item.design.id)\n @item.cart = current_cart\n @item.set_default_quantity\n \n unless @item.cart\n @cart = Cart.create\n session[:cart_id] = @cart.id\n @item.cart = @cart\n end\n \n if params[:moved_from_wishlist]\n current_customer.andand.primary_wishlist.andand.wishlist_items.andand.find_by_product_color_id_and_size_id(@item.product_color_id, @item.size_id).andand.destroy\n end\n \n if params[:coupon_id].present?\n current_cart.update_attribute :coupon_id, params[:coupon_id]\n end\n\n identical_item = Item.find_by_product_color_id_and_size_id_and_cart_id(@item.product_color_id, @item.size_id, @item.cart_id)\n if identical_item\n identical_item.update_attribute(:quantity, identical_item.quantity + @item.quantity)\n @item = identical_item\n else\n @item.save\n end\n\n respond_to do |format|\n format.js\n format.html { redirect_to current_cart }\n format.json { render json: @item, status: :created, location: @item }\n end\n end",
"def add_shipping_as_line_item(extra_options = {})\n raise 'must set shipping/freight before calling this' unless @fields['x_freight']\n add_line_item extra_options.merge({:name => 'Shipping and Handling Cost', :quantity => 1, :unit_price => @fields['x_freight'], :line_title => 'Shipping'})\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def create\n # clear_cart param can be added if restaurant or location changed for initial\n # this means that we need to clear the cart before add anything to it\n if params[:clear_cart] == '1'\n @current_cart.clear!\n @current_cart.force_location session[:current_location]\n end\n # add item to cart\n @current_cart.add_product line_item_params[:product_id], line_item_params[:count], line_item_params[:note], line_item_params[:product_option_ids]\n # add related products if exists\n for i in 0..2\n unless params[\"related_product_#{i}\"].nil?\n @current_cart.add_product params[\"related_product_#{i}\"], params[\"related_product_count_#{i}\"] || 1\n end\n end\n end",
"def set_cart\n @cart = Cart.find(params[:id]) || @cart = Cart.create(:cart => params[:id])\n end",
"def set_shipment\n @shipment = Shipment.find(params[:id])\n end",
"def ship_items\n if current_user && current_user.seller\n @cart_item = CartItem.find_by(cart_id: params[:cart_id], item_id: params[:item_id])\n @cart_item.update(shipped: true)\n redirect_to buyer_orders_path\n else\n redirec_to root_path\n end\n end",
"def set_line\n @cart = Cart.find(params[:cart_id])\n @cart_line = @cart.cart_lines.find_by_id(params[:id])\n end",
"def create\n item = Item.find(params[:item_id])\n @line_item = @cart.line_items.find_by(item: item)\n if @line_item\n @line_item.quantity += 1\n else\n @line_item = @cart.line_items.new(item: item)\n end\n\n respond_to do |format|\n if @line_item.save\n format.html { redirect_to @line_item.cart, notice: 'Line item was successfully created.' }\n format.json { render :show, status: :created, location: @line_item }\n else\n format.html { render :new }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\nend",
"def set_cart_item\n @cart_item = @cart.cart_items.find(params[:id])\n end",
"def set_shipping_category\n old_set_shipping_category unless params['shipping_method'][:translations_attributes]\n end",
"def set_shipment\n @company = Company.find(params[:company_id])\n @shipment = Shipment.find(params[:id])\n\n if !@shipment.Client_ID.blank?\n @client=Client.find(@shipment.Client_ID)\n @shipment.Client_Name = @client.Name\n @shipment.Pickup_Location = @client.Address\n end\n end",
"def set_product_option_typeship\n @product_option_typeship = ProductOptionTypeship.find(params[:id])\n end",
"def shipping_method_ids\n if state_id && state.shipping_zone\n state.shipping_zone.shipping_method_ids\n else\n country.shipping_zone_id ? country.shipping_zone.shipping_method_ids : []\n end\n end",
"def update\n success = true\n if params.has_key? :product_option_vehicle_model_id\n unless @cart.order_items.find(:first, :conditions => {:product_option_vehicle_model_id => params[:product_option_vehicle_model_id].to_i})\n povm = ProductOptionVehicleModel.find(params[:product_option_vehicle_model_id])\n order_item = OrderItem.create(:order_id => @cart.id, :product_option_id => povm.product_option.id, :sku => povm.product_option.sku, :price => povm.product_option.price, :product_option_vehicle_model_id => povm.id, :quantity => 1) || success = false\n @cart.reload\n end\n elsif params.has_key? :order_item\n unless @cart.order_items.find(:first, :conditions => {:product_option_id => params[:order_item][:product_option_id].to_i})\n product_option = ProductOption.find(params[:order_item][:product_option_id].to_i)\n order_item = OrderItem.create(:order_id => @cart.id, :product_option_id => product_option.id, :sku => product_option.sku, :price => product_option.price, :quantity => 1)\n @cart.reload\n end\n elsif params.has_key? :credit_card_number\n gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(\n :login => '4MEdAu2X7K',\t\n :password => '7nmd9vK4333BHW5u'\n )\n credit_card = ActiveMerchant::Billing::CreditCard.new(\n :number => params[:credit_card_number],\n :first_name => @cart.billing_address.first_name,\n :last_name => @cart.billing_address.last_name,\n :month => params[:credit_card_month],\n :year => params[:credit_card_year],\n :verification_value => params[:credit_card_ccv]\n )\n options = {:address => {}, \n :billing_address => { \n :name => @cart.billing_address.full_name,\n :address1 => @cart.billing_address.address_1,\n :city => @cart.billing_address.city,\n :state => @cart.billing_address.state,\n :country => @cart.billing_address.country.iso,\n :zip => @cart.billing_address.zipcode\n }\n }\n response = gateway.purchase(@cart.total, credit_card, options)\n if response.success?\n @cart.accept_card\n Notifier.deliver_order_confirmation(@cart)\n session[:cart_id] = nil\n render :template => 'carts/card_accepted' and return\n else\n @cart.reject_card\n @cart.gateway_status_message = response.message\n flash[:error] = \"The credit card processor rejected the transaction. Here's the reason they gave-- #{response.message}\"\n render :template => 'carts/billing_info' and return\n end\n elsif params.has_key? :cart and params[:cart].has_key? :email\n if @cart.update_attributes(params[:cart])\n render :partial => 'show_email' and return\n else\n render :partial => 'edit_email', :status => 409 and return\n end\n elsif params.has_key? :shipping_country\n case params[:shipping_country]\n when '465' # USA\n @cart.shipping_address.update_attributes(:country_id => params[:shipping_country], :state => params[:shipping_state])\n @cart.update_attributes(params[:cart])\n else\n @cart.shipping_address.update_attributes(:country_id => params[:shipping_country])\n @cart.shipping_method = 'International'\n @cart.save || success = false\n end\n else\n @cart.update_attributes(params[:cart]) || success = false\n end\n if success\n render :template => 'carts/show' and return\n else\n render :template => 'carts/edit' and return\n end\n end",
"def create_current_cart\n new_cart = self.carts.create # instantiate and save to DB new cart already belonging to user instance\n self.current_cart_id = new_cart.id\n self.save\n end",
"def set_cart_item\r\n \t \t@cart_item = CartItem.find(params[:id])\r\n \t\tend",
"def set_shipment_type\n @shipment_type = ShipmentType.find(params[:id])\n end",
"def add_to_line_item(line_item, variant, quantity, currency=nil, shipment=nil, price=nil)\n if line_item\n line_item.target_shipment = shipment\n line_item.quantity += quantity.to_i\n line_item.currency = currency unless currency.nil?\n line_item.save\n else\n line_item = order.line_items.new(quantity: quantity, variant: variant)\n # line_item = Spree::LineItem.new(quantity: quantity)\n line_item.target_shipment = shipment\n line_item.variant = variant\n if currency\n line_item.currency = currency unless currency.nil?\n line_item.price = price || variant.price_in(currency).amount\n else\n line_item.price = price || variant.price\n end\n # order.line_items << line_item\n # line_item\n end\n \n line_item.save\n order.reload\n line_item\n end",
"def set_cart_item\n @cart_item = CartItem.find(params[:id])\n end"
] | [
"0.7311231",
"0.69348556",
"0.6675137",
"0.65214896",
"0.64189833",
"0.6386776",
"0.63038546",
"0.6272877",
"0.62681246",
"0.6259641",
"0.6211111",
"0.6166128",
"0.6083758",
"0.6027638",
"0.60275894",
"0.601285",
"0.59340817",
"0.5926229",
"0.59045064",
"0.5890188",
"0.58339244",
"0.58328575",
"0.57983655",
"0.57876027",
"0.57820135",
"0.57681787",
"0.5761164",
"0.5750393",
"0.57222307",
"0.57149833",
"0.569011",
"0.5675606",
"0.5665915",
"0.56269556",
"0.5618471",
"0.56150234",
"0.5607688",
"0.5554692",
"0.5553888",
"0.5547636",
"0.55426085",
"0.5532858",
"0.55302954",
"0.55298805",
"0.55288744",
"0.5526686",
"0.5522057",
"0.55047333",
"0.55022347",
"0.5499945",
"0.5498359",
"0.5492106",
"0.54879457",
"0.54878336",
"0.5485771",
"0.5479329",
"0.5462536",
"0.5460611",
"0.5459228",
"0.5458388",
"0.54554",
"0.5435354",
"0.54343235",
"0.54315865",
"0.5423992",
"0.5421687",
"0.54145837",
"0.5406464",
"0.53956467",
"0.5387893",
"0.53806293",
"0.53797734",
"0.5358313",
"0.5357151",
"0.53518534",
"0.53518534",
"0.53518534",
"0.53518534",
"0.53518534",
"0.53518534",
"0.53518534",
"0.53518534",
"0.53518534",
"0.5339984",
"0.5336798",
"0.5327991",
"0.532509",
"0.53236306",
"0.53197855",
"0.53186184",
"0.5306327",
"0.53037",
"0.5299323",
"0.5298149",
"0.52926034",
"0.5274482",
"0.5274066",
"0.52732414",
"0.5266312",
"0.5264016"
] | 0.8019703 | 0 |
Shortcut method to get shipping adjustments from adjustments list | def shipping
adjustments.find { |a| a.type == "shipping-method" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price_adjustments\n adjustments = []\n\n line_items.each do |line_item|\n adjustments.concat (line_item.adjustments - line_item.adjustments.gift_packaging)\n end\n\n adjustments\n end",
"def update_adjustments\n self.adjustments.reload.each do |adjustment|\n if adjustment.originator.class == Spree::Shipment\n adjustment.update!\n else\n adjustment.update!(self)\n end\n end\n end",
"def shipping_scope\n fee_adjustments.shipping\n end",
"def shipping\n total_quantity = items.inject(0) {|q, item| q + item.quantity}\n if total_quantity == 1\n return items.first.product.base_shipping\n else\n return items.inject(0) {|total, item|\n total + (item.product.add_on_shipping * item.quantity)\n }\n end\n end",
"def shipping_amount\n shipping_calculator.amount\n end",
"def separate_shipment_costs\n return if @order.canceled?\n extracted_total = 0.to_d\n @order.shipments.each do |shipment|\n # Spree 2.1.x: shipment costs are expressed as order adjustments linked through source to the shipment\n # Spree 2.2.x: shipments have a cost which is authoritative, and one or more adjustments (shiptax, etc)\n cost = if shipment.respond_to?(:adjustment)\n shipment.adjustment.try(:amount) || 0.to_d\n else\n shipment.cost + shipment.adjustment_total\n end\n\n if cost > 0\n extracted_total += cost\n shipment.adjustment.open if shipment.respond_to? :adjustment\n shipment.adjustments.delete_all if shipment.respond_to? :adjustments\n shipment.shipping_rates.delete_all\n shipment.cost = 0\n shipment.add_shipping_method(rop_tbd_method, true)\n shipment.save!\n end\n end\n\n if extracted_total > 0\n # TODO: is Standard Shipping the best name for this? Should i18n happen?\n @order.adjustments.create(amount: extracted_total, label: \"Standard Shipping\", mandatory: false)\n @order.save!\n end\n end",
"def paid_expense_items\n paid_details.map{|pd| pd.expense_item }\n end",
"def shipping_methods\n [\"Next Day Shipping\", \"2 Day Shipping\",\"Ground Service\"]\n end",
"def adjustments=(args)\n @adjustments = *args\n end",
"def adjustments=(args)\n @adjustments = *args\n end",
"def promotions\n adjustments.where( promotion: true )\n end",
"def adjustments=(items)\n if items.is_a? Array\n @adjustments = items.map do |adjustment|\n Adjustment.build(self, adjustment)\n end.compact\n end\n end",
"def adjusted_total\n total = unadjusted_total\n \n for adjustment in adjustments\n total += adjustment.amount\n end\n \n total\n end",
"def shipping\n @data[:shipping]\n end",
"def get_adjustment_line\n prd = Product.get_adjustment_product\n raise \"Missing adjustment product: please add using Maintain/Products function\" unless prd\n @lines.find {|li| li.li_prd_id == prd.prd_id }\n end",
"def shipping\n to_price mapping_for(:shipping)\n end",
"def shipping_fee\n @admin_options = Admin::Option.where(\"id = ?\" , 44) \n end",
"def fetch_rates(package)\n zone = self.calculable.zones.match(package.order.ship_address)\n return nil if zone.nil?\n\n rates = { :ground => nil, :standard => nil }\n\n package.contents.each do |line_item|\n ship_rate = Spree::VariantShippingRate.where(:zone => zone, :variant => line_item.variant).take\n unless ship_rate.nil?\n rates[:standard] = rates[:standard].to_f + (ship_rate.standard_rate * line_item.quantity) if ship_rate.standard_rate\n rates[:ground] = rates[:ground].to_f + (ship_rate.ground_rate * line_item.quantity) if ship_rate.ground_rate\n end\n end\n\n rates\n end",
"def shipping_points\r\n AxInventory.sum(\r\n \"shipping_points\",\r\n :joins => \"RIGHT JOIN erp_sales_lines ON erp_sales_lines.item_id = ax_inventories.item_id\",\r\n :conditions => [\"erp_sales_lines.erp_sales_order_id = ?\", self.id]\r\n )\r\n end",
"def all_expense_items\n owing_expense_items + paid_expense_items\n end",
"def retrieval\n shipping_manifest['oil paintings']\nend",
"def get_shipping_prices\n prices = Array.new\n # If they're in the USA\n address = self.shipping_address\n if address.country_id == 1 then\n shipping_types = OrderShippingType.get_domestic\n else \n shipping_types = OrderShippingType.get_foreign\n end\n\n ship = Shipping::FedEx.new(:prefs => \"#{RAILS_ROOT}/config/shipping.yml\")\n ship.fedex_url = SHIP_FEDEX_URL\n ship.fedex_account = SHIP_FEDEX_ACCOUNT\n ship.fedex_meter = SHIP_FEDEX_METER\n ship.sender_zip = SHIP_SENDER_ZIP\n ship.sender_country = SHIP_SENDER_COUNTRY\n ship.weight = self.weight\n ship.zip = address.zip\n ship.city = address.city\n ship.country = address.country.fedex_code\n\n logger.info(\"\\n\\nCREATED A SHIPPING OBJ\\n#{ship.inspect}\\n\\n\")\n\n for type in shipping_types\n ship.service_type = type.service_type\n ship.transaction_type = type.transaction_type\n # Rescue errors. The Shipping gem likes to throw nasty errors\n # when it can't get a price.\n #\n # Usually this means the customer didn't enter a valid address (zip code most of the time)\n # In that case we go for our own shipping prices.\n begin\n # FedEx can be flaky sometimes and return 0 for prices.\n # Make sure we always calculate a shipping rate even if they're being wacky.\n price = ship.discount_price\n if price == 0\n price = ship.price\n end\n if price == 0\n type.calculate_price(self.weight)\n else\n type.price = price + @@handling_fee\n end\n rescue\n logger.error \"\\n[ERROR] #{$!.message}\"\n type.calculate_price(self.weight)\n type.price += @@handling_fee\n end\n # logger.info \"#{type.name} : ship.discount_price / type.price\"\n prices << type\n end\n\n return prices\n\n end",
"def retrieve_rates(origin_zip, destination_zip, shipping_weight, shipping_volume)\n params = {\n 'nCdEmpresa' => Spree::CorreiosBoundedStore::Config[:company_code],\n 'sDsSenha' => Spree::CorreiosBoundedStore::Config[:company_password],\n 'sCepOrigem' => origin_zip,\n 'sCepDestino' => destination_zip,\n 'nVlPeso' => shipping_weight, # Must be in grams.\n 'nVlVolume' => shipping_volume # Must be in cubic centimeters.\n }\n\n result = soap_service.consultarFrete(params)\n \n available_services = {}\n \n case result.consultarFreteResult.codigo\n when 1\n # 1 OK.\n if result.consultarFreteResult.fretesDisponiveis.respond_to? :each\n result.consultarFreteResult.fretesDisponiveis.each do |i|\n available_services.merge!(\n SERVICE_REFERENCES.index(i.codigo).to_sym => {\n :code => i.codigo, # Service code.\n :price => i.valor, # Estimated shipping price.\n :time => i.prazoEntrega # Estimated shipping time in days.\n }\n )\n end\n end\n else\n # 2 Serviço indisponível para este CEP.\n # 3 Parametros inválidos.\n # 4 Acesso não autorizado.\n # 5 Loja não aberta.\n # 6 Peso não atendido.\n # 7 Serviço indisponível, tente mais tarde.\n RAILS_DEFAULT_LOGGER.info \"Error in the returned available shipping services: #{result.consultarFreteResult.codigo}, #{result.consultarFreteResult.descricao}\"\n end\n \n available_services\n end",
"def tax_total\n adjustments.where(:originator_type => \"TaxRate\").map(&:amount).sum\n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n \n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total + gift_packaging_total\n end",
"def get_fallback_shipping_rates(international_shipment)\n spree_shipping_methods = Spree::ShippingMethod.all\n if international_shipment\n # First filter to international shipping methods then to methods that use\n # preferred packaging, assuming preferred packaging has one word of method's\n # name in it, i.e. \"FedExPak\" contains \"FedEx.\"\n international_methods = spree_shipping_methods.select { |m| m.name.match /international/i }\n packaging_name = Spree::Config.preferred_international_packaging\n methods = international_methods.select { |m| !m.name.split.select { |word| packaging_name.match word }.empty? }\n cost = 25\n else\n methods = spree_shipping_methods.select { |m| !m.name.match /international/i }\n cost = 10\n end\n methods.map { |method| Spree::ShippingRate.new(name: method.name, cost: cost, shipping_method: method) }\n end",
"def retrieval\n shipping_manifest = shipping_manifest = {\"whale bone corsets\" => 5,\"porcelain vases\" => 2,\"oil paintings\" => 3}\n return shipping_manifest[\"oil paintings\"]\nend",
"def shipping_manifest\n shipping_manifest = {\n \"whale bone corsets\" => 5,\n \"porcelain vases\" => 2,\n \"oil paintings\" => 3\n }\nend",
"def shipping_manifest\n shipping_manifest = {\n \"whale bone corsets\" => 5,\n \"porcelain vases\" => 2,\n \"oil paintings\" => 3\n }\nend",
"def adjustments(reverse = false)\n @adjustments ||= parse(str, reverse)\n end",
"def retrieve_inventory_adjustment(adjustment_id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::GET,\n '/v2/inventory/adjustments/{adjustment_id}',\n 'default')\n .template_param(new_parameter(adjustment_id, key: 'adjustment_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 line_items_for_compute(order, options={})\n if calculable.is_a?(Spree::Promotion)\n line_items = if calculable.product\n order.line_items.joins(:variant).where(:variants => {product_id: calculable.product})\n elsif calculable.store\n order.line_items.where(:store_id => calculable.store)\n else\n order.line_items\n end\n \n if self.is_a?(Spree::Calculator::FreeShipping)\n puts \"free shipping\"\n line_items\n else\n puts \"not free shipping\"\n line_items.order('spree_line_items.price DESC').not_on_sale\n end\n else\n puts \"all line items\"\n order.line_items\n end\n end",
"def shipping_item\n shipping_scope.first || shipping_scope.build(shipping_options)\n end",
"def get_eligible_shipping_services(shipment_request_details)\n operation('GetEligibleShippingServices')\n .add('ShipmentRequestDetails' => shipment_request_details)\n .structure!('ItemList', 'Item')\n\n run\n end",
"def state_fulfillment_fee\n adjustments.eligible.where(:label => 'Additional State Fulfillment Fee').first.amount rescue 0.0\n end",
"def update_shipments\n shipping_method_filter = order.completed? ? ShippingMethod::DISPLAY_ON_BACK_END : ShippingMethod::DISPLAY_ON_FRONT_END\n\n shipments.each do |shipment|\n next unless shipment.persisted?\n\n shipment.update!(order)\n shipment.refresh_rates(shipping_method_filter)\n shipment.update_amounts\n end\n end",
"def additional_shipping_total\n self.line_items.inject(0) { |total,line_item| total + line_item.variation.product.additional_shipping_cost }\n end",
"def shipping_address_edit\n @shipping_address = retrieve_shipping_address(@subscription_id)\n @country_codes = get_country_codes\n end",
"def retrieval\n shipping_manifest = {\"whale bone corsets\" => 5, \"porcelain vases\" => 2, \"oil paintings\" => 3}\n shipping_manifest[\"oil paintings\"]\nend",
"def calculate_shipping\n return :skipped unless basket?\n run_callbacks :shipping_updated do\n shipping_item.update! \\\n display_name: shipping_display_name,\n price: calculate_shipping_cost\n end\n end",
"def shipping_params\n params[:shipping]\n end",
"def shipping\n if defined?(shipping_rate)\n shipping_rate\n else\n 0\n end\n end",
"def shipping_address\n source = shipping_address_customization || order\n source.shipping_address\n end",
"def shipments\n ret = []\n elements = @document.search self.shipments_found_in\n elements.each do |element| \n li = Shipment.new\n li.document = element\n ret << li\n end\n ret\n end",
"def update_adjustments\n self.adjustments.reload.each { |adjustment| adjustment.update!(self) }\n end",
"def shipping_methods\n @retailer = Retailer.find(params[:retailer_id])\n @shipping_methods = Spree::ShippingMethod.all\n end",
"def retrieval\n shipping_manifest = { \"whale bone corsets\" => 5, \"porcelain vases\" => 2, \"oil paintings\" => 3 }\n\n shipping_manifest[\"oil paintings\"]\nend",
"def ship_prices_for(user)\r\n # package we are shipping\r\n package = Package.new(weight,\r\n [length, width, height],\r\n :units => :imperial)\r\n \r\n # where we are shipping from\r\n origin = Location.new(:country => 'US',\r\n :state => 'NY',\r\n :address1 => '3399 North Rd.',\r\n :city => 'Poughkeepsie',\r\n :zip => '12601')\r\n \r\n # where we are shipping to the user\r\n destination = Location.new(:country => 'US',\r\n :state => user.state,\r\n :city => user.city,\r\n :zip => user.zipcode,\r\n :address1 => user.address)\r\n \r\n # ups api login\r\n ups = UPS.new(:login => 'KayoticSully', :password => 'WiivoUPS310', :key => 'DCA75091423BBDC8')\r\n # get the shipping rates\r\n response = ups.find_rates(origin, destination, package)\r\n # pull out only the data we need\r\n response.rates.sort_by(&:price).collect {|rate| [rate.service_name, rate.price]}\r\n end",
"def express\n items = current_order.line_items.map do |item|\n {\n :Name => item.product.name,\n :Quantity => item.quantity,\n :Amount => {\n :currencyID => current_order.currency,\n :value => item.price\n },\n :ItemCategory => \"Physical\"\n }\n end\n\n tax_adjustments = current_order.adjustments.tax\n shipping_adjustments = current_order.adjustments.shipping\n\n current_order.adjustments.eligible.each do |adjustment|\n next if (tax_adjustments + shipping_adjustments).include?(adjustment)\n items << {\n :Name => adjustment.label,\n :Quantity => 1,\n :Amount => {\n :currencyID => current_order.currency,\n :value => adjustment.amount\n }\n }\n end\n\n # Because PayPal doesn't accept $0 items at all.\n # See #10\n # https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECCustomizing\n # \"It can be a positive or negative value but not zero.\"\n items.reject! do |item|\n item[:Amount][:value].zero?\n end\n\n pp_request = provider.build_set_express_checkout({\n :SetExpressCheckoutRequestDetails => {\n :ReturnURL => confirm_paypal_url(:payment_method_id => params[:payment_method_id]),\n :CancelURL => cancel_paypal_url,\n :PaymentDetails => [payment_details(items)]\n }})\n\n current_order.vwo_type = params['return_type'] #return type is being hooked into to pass vwo type\n current_order.save\n\n begin\n pp_response = provider.set_express_checkout(pp_request)\n if pp_response.success?\n redirect_to provider.express_checkout_url(pp_response)\n else\n flash[:error] = \"PayPal failed. #{pp_response.errors.map(&:long_message).join(\" \")}\"\n redirect_to checkout_state_path(:payment)\n end\n rescue SocketError\n flash[:error] = \"Could not connect to PayPal.\"\n redirect_to checkout_state_path(:payment)\n end\n end",
"def shipment\n @shipment ||= shipments.first\n end",
"def update_adjustments\n self.adjustments.reload.each(&:update!)\n end",
"def rate_info(code, to_zip_code, from_zip_code)\n code = code.to_sym\n config.rates.key?(code) or\n raise UnsupportedShippingOption.new(\"Unsupported shipping option #{code}\")\n rate = config.rates[code].reverse_merge(\n to_zip_code: to_zip_code,\n from_zip_code: from_zip_code,\n ship_date: Date.current.to_s\n )\n rate[:add_ons] = {add_on: [\n {type: 'US-A-DC'}, # delivery confirmation (so that we can track the shipment)\n {type: 'SC-A-HP'} # hidden postage (don't show the seller how much the label cost)\n ]}\n rate\n end",
"def paypal_shipping_and_handling_costs(order)\n {}\n end",
"def preview_order_items\n [\n {title: 'Item One', quantity: 2, price: 999, tax_exempt: false},\n {title: 'Item Two', quantity: 1, price: 25000, tax_exempt: false},\n {title: 'Item Three', quantity: 1, price: 8999, tax_exempt: false},\n {title: 'Item Four', quantity: 1, price: 100000, tax_exempt: false}\n ]\n end",
"def fulfilled_line_items\n return self.order_line_items.where(:status => 'shipped').all\n end",
"def total\n self.line_items_total + self.shipping_cost\n end",
"def shipment\n @shipment ||= shipments.last\n end",
"def shipment\n @shipment ||= shipments.last\n end",
"def list_inbound_shipment_items(opts = {})\n operation('ListInboundShipmentItems')\n .add(opts)\n\n run\n end",
"def spend\n amounts = []\n orders.where(order_status_id: 4).each do |order|\n amounts << order.subtotal\n end\n return amounts.inject(:+)\n end",
"def set_adjustment\n @adjustment = Adjustment.find(params[:id])\n end",
"def all_fees\n services.map{|el| el[:fee]}\n end",
"def retrieve_inventory_adjustment(adjustment_id:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/inventory/adjustment/{adjustment_id}'\n _query_builder = APIHelper.append_url_with_template_parameters(\n _query_builder,\n 'adjustment_id' => { 'value' => adjustment_id, 'encode' => true }\n )\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url,\n headers: _headers\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 get_additional_cost_totals\n pos_cost = 0.0 # init result\n neg_cost = 0.0 # init result\n AppParameterCustomizations.get_receipt_costs().each do |c|\n if c[:value] > 0\n pos_cost += c[:value].to_f / 100.0\n elsif self.price >= 78.19\n neg_cost += c[:value].to_f / 100.0 unless self.patient.is_a_firm?\n end\n end\n return { :negative => neg_cost, :positive => pos_cost }\n end",
"def retrieval\n shipping_manifest = {\n \"whale bone corsets\" => 5,\n \"porcelain vases\" => 2,\n \"oil paintings\" => 3\n }\n shipping_manifest[\"oil paintings\"]\n\nend",
"def shipping_address\n default_shipping_address ? default_shipping_address : shipping_addresses.first\n end",
"def shipping_address\n default_shipping_address ? default_shipping_address : shipping_addresses.first\n end",
"def update_adjustments\n self.adjustments.reload.each { |adjustment| adjustment.update!(self) }\n end",
"def retrieval\n shipping_manifest = {\n \"whale bone corsets\" => 5, \n \"porcelain vases\" => 2, \n \"oil paintings\" => 3\n }\n \nshipping_manifest[\"oil paintings\"]\nend",
"def shipped\n order = Order.second\n items = LineItem.where(order_id: order.id)\n items.each do |item|\n order.line_items << item\n end\n OrderNotifier.shipped(order)\n end",
"def test_itemized_shipping\r\n\t\tfor counter in (1..2) do\r\n\t\t\t@cart.add_product products(:cow)\r\n\t\tend\r\n\r\n\t\tfor counter in (1..5) do\r\n\t\t\t@cart.add_product products(:chicken)\r\n\t\tend\r\n\r\n\t\tassert_equal 7, @cart.total_items\r\n\r\n\t\tassert_equal 14.0, @cart.shipping_cost(shipping_zones(:itemized_shipping))\r\n\r\n\t\tfor counter in (1..5) do\r\n\t\t\t@cart.add_product products(:cow)\r\n\t\tend\r\n\r\n\t\tassert_equal 12, @cart.total_items\r\n\r\n\t\tassert_equal 24.0.to_s, @cart.shipping_cost(shipping_zones(:itemized_shipping)).to_s\r\n\tend",
"def index\n @adjustment_types = AdjustmentType.all\n end",
"def shipping\n shipping = self.order_items.max(:shipping)\n \n if products_price >= 100\n shipping = 0\n end\n\n shipping\n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total\n end",
"def payment_items\n\t\t\t\t\treturn self.order_items\n\t\t\t\tend",
"def price_adjustment_fixed \n options.inject(0){|m,x| m + x.price_adjustment_fixed.to_i} \n end",
"def get_shipping_amount_for_quotation\n doc = Hpricot::XML(request.raw_post)\n doc = doc.to_s.gsub(\"&\",\"&\")\n doc = Hpricot::XML(doc)\n shipping_code = parse_xml(doc/:params/'shipping_code')\n if shipping_code == 'UPS'\n response_doc,text = Quotation::SalesQuotationCrud.get_ups_shipping_methods(doc)\n if text == 'error'\n render :xml=>\"<errors><error>#{response_doc}</error></errors>\"\n else\n @ups_shipping_methods = Hpricot::XML(response_doc)\n response_status_code = parse_xml(@ups_shipping_methods/:RatingServiceSelectionResponse/:Response/'ResponseStatusCode') if parse_xml(@ups_shipping_methods/:RatingServiceSelectionResponse/:Response/'ResponseStatusCode').first\n rate = parse_xml(@ups_shipping_methods/:RatingServiceSelectionResponse/:RatedShipment/'NegotiatedRates')\n if rate.blank?\n render :xml=>\"<errors><error>Negotiated Rates not found. Please Contact System Administrator.</error></errors>\"\n elsif(response_status_code.to_i == 1)\n respond_to_action('get_shipping_methods')\n else\n render :xml=>\"<errors><error>UPS API ERROR FOUND. Please Contact System Administrator.</error></errors>\"\n end\n end\n elsif shipping_code == 'FEDEX'\n @estimated_ship_date = Time.now.to_date\n @fedex_shipping_methods,text = Quotation::SalesQuotationCrud.get_fedex_shipping_methods(doc)\n if text == 'error'\n render :xml=>\"<errors><error>#{@fedex_shipping_methods}.</error></errors>\"\n else\n respond_to_action('get_shipping_methods')\n end\n elsif shipping_code == 'USPS'\n @usps_shipping_methods,@usps_method_rates,@inhand_dates,text = Quotation::SalesQuotationCrud.get_usps_shipping_methods(doc)\n if text == 'error'\n render :xml=>\"<errors><error>#{@inhand_dates}.</error></errors>\"\n else\n respond_to_action('get_shipping_methods')\n end\n else\n render :xml=>\"<errors><error>No Methods Available For #{shipping_code}</error></errors>\"\n end\n end",
"def perform_get_shipping_methods_thru_cart(session_id, cart_id, version, ship_addr1, ship_addr2, ship_city, ship_state, ship_zip, ship_country, promo_code, cart_items)\n $tracer.trace(\"GameStopShippingServiceDSL: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n get_available_shipping_methods_req = self.get_request_from_template_using_global_defaults(:get_available_shipping_methods, ShippingServiceRequestTemplates.const_get(\"GET_AVAILABLE_SHIPPING_METHODS#{version}\"))\n get_available_shipping_methods_req.find_tag(\"session_id\").at(0).content = session_id\n get_available_shipping_methods_req.find_tag(\"targeting_context\").items.name_value_property.remove_self\n get_available_shipping_methods_req.find_tag(\"client_channel\").content = 'GS-US'\n get_available_shipping_methods_req.find_tag(\"locale\").content = 'en-US'\n\n get_available_shipping_methods_data = get_available_shipping_methods_req.find_tag(\"get_available_shipping_methods_request\").at(0)\n get_available_shipping_methods_data.customer_id.content = cart_id\n get_available_shipping_methods_data.customer_loyalty_number.content = nil\n\n if !promo_code.empty?\n get_available_shipping_methods_data.promocodes.at(0).string.content = promo_code\n else\n get_available_shipping_methods_data.promocodes.remove_self\n end\n\n cart_items.each_with_index do |cart, i|\n get_available_shipping_methods_req.find_tag(\"shipment\").at(0).clone_as_sibling if i > 0\n shipments_data = get_available_shipping_methods_req.find_tag(\"shipment\").at(i)\n\n line_item = shipments_data.line_items.line_item.at(0)\n line_item.line_item_id.content = cart.line_item_id.content\n line_item.list_price.content = cart.list_price.content\n line_item.quantity.content = cart.quantity.content\n line_item.sku.content = cart.sku.content\n\n ship_to_data = shipments_data.ship_to.at(0)\n ship_to_data.address_id.content = generate_guid\n ship_to_data.city.content = ship_city\n ship_to_data.country_code.content = ship_country\n ship_to_data.line1.content = ship_addr1\n ship_to_data.line2.content = ship_addr2\n ship_to_data.postal_code.content = ship_zip\n ship_to_data.state.content = ship_state\n shipments_data.shipment_id.content = generate_guid #shipment_id\n shipments_data.shipment_type.content = 'ShipToAddress' #shipment_type\n end\n\n $tracer.trace(get_available_shipping_methods_req.formatted_xml)\n get_available_shipping_methods_rsp = self.get_available_shipping_methods(get_available_shipping_methods_req.xml)\n get_available_shipping_methods_rsp.code.should == 200\n $tracer.trace(get_available_shipping_methods_rsp.http_body.formatted_xml)\n return get_available_shipping_methods_rsp\n end",
"def index\n @shipping_lines = ShippingLine.all\n end",
"def shipping_charges_payment\n {'PaymentType' => payment_type,\n 'Payor' => {'AccountNumber' => @model.payor_account_number},\n :order! => ['PaymentType', 'Payor']}\n end",
"def shipping\n cart = Cart.new(request.cookies[\"cart\"])\n cart.set_extra_data(params)\n shipping_methods = ShippingMethod.lookup_methods(cart)\n render :json => shipping_methods\n end",
"def add_shipping_as_line_item(extra_options = {})\n raise 'must set shipping/freight before calling this' unless @fields['x_freight']\n add_line_item extra_options.merge({:name => 'Shipping and Handling Cost', :quantity => 1, :unit_price => @fields['x_freight'], :line_title => 'Shipping'})\n end",
"def shipping_base_amount\n # sum total_amount of all line_items that:\n # a) are not virtual (see formats table, is_virtual)\n # b) are not saved for later (see line items table, saved_for_later)\n self.line_items.includes(:product_format => :format).where(\"formats.is_virtual != 1 AND (line_items.saved_for_later != 1 OR line_items.saved_for_later IS NULL)\").map(&:total_amount).sum\n end",
"def index\n @shipping_methods = ShippingMethod.page params[:page]\n end",
"def available_shipping_methods\n return ShippingMethod.none unless has_shipping?\n ids = order_items.map { |item| item.product.available_shipping_methods.pluck(:id) }.inject(:&)\n store.shipping_methods.where(id: ids)\n end",
"def calculate_real_time_shipping(items, zipcode)\n grouped_items = items.group_by { |item| item.product.vendor }\n shipping_total = 0\n grouped_items.keys.each do |vendor|\n ## this might be useful if a vendor packages products together:\n # if vendor.groups_packages\n # weight = total_weight(grouped_items[vendor])\n # shipping_total += shipping_quote([weight], zipcode, vendor.zipcode)\n items = grouped_items[vendor]\n vendor_total = calculate_shipping_per_vendor(items, zipcode, vendor.zipcode)\n shipping_total += vendor_total\n end\n shipping_total\n end",
"def index\r\n @shipmentmethods = Shipmentmethod.all\r\n end",
"def update_totals\n update_payment_total\n update_item_total\n update_shipment_total\n update_adjustment_total\n end",
"def index\n @shipping_details = ShippingDetail.all\n end",
"def shipping_method\n object.shipping_method.try(:name)\n end",
"def shipping_calculator(destination)\n @shipping_caluclator ||= ShippingCalculator.new(order, \"US\", destination)\n end",
"def shipping_address\n [name_tb.value,address1_tb.value,address2_tb.value,city_tb.value,state_tb.value,country_select.first_selected_option.text,zip_tb.value,phone_tb.value,power_adapter_select.first_selected_option.text]\n end",
"def sell_bonus\n rpg_shop.sell_bonus\n end",
"def available_shipping_methods(display_on = nil)\n return [] unless ship_address\n all_methods = Spree::ShippingMethod.all_available(self, display_on)\n\n if self.digital?\n all_methods.detect { |m| m.calculator.class == Spree::Calculator::DigitalDelivery }.try { |d| [d] } || all_methods\n else\n all_methods\n end\n end",
"def update!\n update_totals\n # update_payment_state\n\n shipments.each { |shipment| shipment.update!(self) }#(&:update!)\n update_shipment_state\n\n update_adjustments \n\n # give each of the shipments a chance to update themselves\n # update totals a second time in case updated adjustments have an effect on the total\n update_totals\n \n update_attributes({\n :payment_state => payment_state,\n :item_total => item_total,\n :adjustment_total => adjustment_total,\n :payment_total => payment_total,\n :total => total\n })\n end",
"def sum_of_tax_rates line_item\n line_item.adjustments.tax.\n joins(\"INNER JOIN spree_tax_rates ON spree_tax_rates.id = spree_adjustments.source_id\").\n where(spree_tax_rates: { included_in_price: true }).\n map(&:source).\n sum(&:amount)\n end",
"def calculate_flat_rate_shipping\n shipping_method = ShippingMethod.find(self.shipping_method_id)\n price = shipping_method.flat_rate_shipping_cost(self)\n end",
"def adjust(data) \n # blow up if no amount or reason have been submitted\n raise RException.new(\"Undefined adjustment amount\") if data[\"amount\"].nil?\n raise RException.new(\"You must provided an adjustment reason\") if data[\"reason\"].nil?\n \n data[\"commissionable\"] = (!data[\"commissionable\"].nil? && data[\"commissionable\"] == 'on') ? true : false\n data[\"invoiceable\"] = (!data[\"invoiceable\"].nil? && data[\"invoiceable\"] == 'on') ? true : false \n \n # create the adjustment helper class\n adj = Invoice::Adjustment.new(data) \n \n # User selected \"[x]Apply to invoice\" on adjustment form. This adjustment will be applied to both teh Payable AND Invoice\n # THIS IS CLEVER BUT TRICKY since if adjusting a vendor cost, we have to hide the client-adjustment in the all-encompassing\n # \"Freight Charge\" InvoiceItem \n if (adj.invoiceable) \n iitem = get_invoice_item\n \n # blow up if we didn't find a corresponding invoice item to apply adjustment to\n raise RException.new(\"Failed to find invoice-item to apply adjustment to\") if iitem.nil? \n \n # tricky here. we've just loaded the InvoiceItem corresponding to this Payable. Since the user selected [x] \"apply to \n # invoice\" for this Payable adjustment, we're going to apply the adjustment to client as well. \n adj.invoice_item = iitem\n iitem.adjust(adj)\n end\n \n self.adjustments << adj.to_h \n self.cost += adj.amount\n \n return (self.save!) ? adj : false \n end",
"def receipt_items\n returning = []\n sales_tax = 0.0\n total = 0.0\n @shopping_cart.each do |line_item|\n sales_tax = sales_tax + line_item.tax\n total = total + line_item.price_with_tax\n returning << \"#{line_item.count} #{line_item.description}: %.2f\" % line_item.price_with_tax\n end\n returning << \"Sales Taxes: %.2f\" % sales_tax\n returning << \"Total: %.2f\" % total\n end",
"def show\n @orders = Order.paginate(page: params[:orders_page], per_page: 5).with_current_status().by_customer_id(params[:id])\n @shipping_address = ShippingAddress.new\n end"
] | [
"0.68257123",
"0.6116949",
"0.595517",
"0.57656324",
"0.57333547",
"0.57320666",
"0.5691638",
"0.559194",
"0.5571389",
"0.5571389",
"0.5569709",
"0.55529946",
"0.55518365",
"0.55427825",
"0.5446775",
"0.54047704",
"0.54012316",
"0.53729624",
"0.536094",
"0.5332664",
"0.53314453",
"0.53293985",
"0.5324056",
"0.5311104",
"0.53084886",
"0.52900183",
"0.52813774",
"0.5264838",
"0.5264838",
"0.5241136",
"0.5215495",
"0.519483",
"0.5178596",
"0.5177273",
"0.51714456",
"0.5157676",
"0.51523167",
"0.5112021",
"0.51083535",
"0.50949675",
"0.507831",
"0.5061737",
"0.50597215",
"0.50505614",
"0.5048432",
"0.50335616",
"0.49994817",
"0.49847096",
"0.49710608",
"0.49703872",
"0.4964613",
"0.49291503",
"0.4927489",
"0.49181566",
"0.4910077",
"0.4891863",
"0.48736426",
"0.48736426",
"0.48730642",
"0.48694044",
"0.4860812",
"0.48599344",
"0.48551786",
"0.48487914",
"0.48484266",
"0.48432365",
"0.48432365",
"0.48426563",
"0.4832313",
"0.48253313",
"0.48245412",
"0.4823169",
"0.48201835",
"0.48195267",
"0.48174745",
"0.48015252",
"0.47979385",
"0.47913268",
"0.47856987",
"0.47856954",
"0.47628304",
"0.476072",
"0.47518313",
"0.47437957",
"0.4742622",
"0.47404277",
"0.4729624",
"0.4725636",
"0.47249892",
"0.47191143",
"0.4714948",
"0.47138277",
"0.47083873",
"0.469859",
"0.46959975",
"0.4694455",
"0.4684052",
"0.46839535",
"0.46819568",
"0.4678207"
] | 0.73404694 | 0 |
Validates customer informations are correctly filled | def validate_customer_informations
validate_nested_resource(:customer)
validate_nested_resource(:billing_address)
if use_another_address_for_shipping
validate_nested_resource(:shipping_address)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_pos_invoice\n if self.customer_id && !self.pos_invoice_addresses\n raise_error('Billing address Required!!!!')\n end\nend",
"def validate_billing_info\n errors = super.merge(validate_required(posted, ['password']))\n errors['password'] ||= error_for_passwords(posted['password'], posted['password_confirm'])\n errors.delete_if { |k,v| v.nil? }\n end",
"def validate_billing_info\n errors = {}\n\n if (posted['stripeToken'].nil? || posted['stripeToken'].empty?)\n errors['stripeToken'] = \"Your card wasn't accepted.\"\n end\n\n errors\n end",
"def validate_parameters\n r = validate_payment_nonce_uuid\n return r unless r.success?\n\n error_identifiers = []\n\n error_identifiers << 'invalid_first_name' if @first_name.present? &&\n (!Util::CommonValidateAndSanitize.is_string?(@first_name) || @first_name.length > 255)\n\n error_identifiers << 'invalid_last_name' if @last_name.present? &&\n (!Util::CommonValidateAndSanitize.is_string?(@last_name) || @last_name.length > 255)\n\n error_identifiers << 'invalid_company' if @company.present? &&\n (!Util::CommonValidateAndSanitize.is_string?(@company) || @company.length > 255)\n\n error_identifiers << 'invalid_email' if @email.present? &&\n (!Util::CommonValidateAndSanitize.is_valid_email?(@email))\n\n\n error_identifiers << 'invalid_phone' if @phone.present? &&\n (!Util::CommonValidateAndSanitize.is_string?(@phone) || @phone.length > 255)\n\n error_identifiers << 'invalid_fax' if @fax.present? &&\n (!Util::CommonValidateAndSanitize.is_string?(@fax) || @fax.length > 255)\n\n error_identifiers << 'invalid_website' if @website.present? &&\n (!Util::CommonValidateAndSanitize.is_valid_domain?(@website) || @website.length > 255)\n\n\n return error_with_identifier('invalid_api_params',\n 'ra_c_c_vp_1',\n error_identifiers\n ) if error_identifiers.present?\n\n @customer_details[:first_name] = @first_name if @first_name.present?\n @customer_details[:last_name] = @last_name if @last_name.present?\n @customer_details[:company] = @company if @company.present?\n @customer_details[:email] = @email if @email.present?\n @customer_details[:phone] = @phone if @phone.present?\n @customer_details[:fax] = @fax if @fax.present?\n @customer_details[:website] = @website if @website.present?\n\n success\n end",
"def create\n\n customerParams = params[:customer]\n\n # convert enums to integer equivalent\n customerParams[:other_language] = customerParams[:other_language].to_i\n customerParams[:gender] = customerParams[:gender].to_i\n customerParams[:residence_code] = customerParams[:residence_code].to_i\n customerParams[:remote_access] = customerParams[:remote_access].to_i\n customerParams[:preferred_contact_method] = customerParams[:preferred_contact_method].to_i\n\n\n\n @customer = Customer.new(customer_params)\n\n @customer.last_name = @customer.last_name.upcase\n @customer.first_name = @customer.first_name.upcase\n @customer.middle_name = @customer.middle_name.upcase\n @customer.address1 = @customer.address1.upcase\n @customer.address2 = @customer.address2.upcase\n @customer.city = @customer.city.upcase\n @customer.state = @customer.state.upcase\n @customer.zip_code = @customer.zip_code.upcase\n @customer.active = “true”\n @customer.birthdate = DateTime.strptime(params[:customer][:birthdate], '%m-%d-%Y') if !customerParams[:birthdate].empty?\n @customer.ssn = customerParams[:ssn].gsub!(/[\\-]/, '').to_i\n\n # TODO: need to restrict view to 2 digits only\n customerPct = customerParams[:discount_pct].to_f\n @customer.discount_pct = customerPct > 1 ? 0 : customerPct\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_customer_data\n @customer.init_id = self.id\n @customer.external_code = @parsed['buyer']['id']\n @customer.name = @parsed['buyer']['nickname']\n @customer.email = @parsed['buyer']['email']\n @customer.contact = @parsed['buyer']['phone']['area_code'] \n @customer.contact.concat(@parsed['buyer']['phone']['number'])\n rescue Exception => e\n self.processamento = \"Erro\"\n puts e.message\n \n self.save\n @customer.save\n end",
"def active_customer\n\t errors.add(:customer_id, \"is not active\") unless customer.active?\n\tend",
"def create\n @customer = Customer.new(customer_params)\n @customer.phone = Generic.clean_phone(@customer.phone)\n \n respond_to do |format|\n if @customer.save\n format.html {\n redirect_to campaign_customers_path\n }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def valid_attributes\n {\n :user_id=> 1 ,\n :credit_card_no =>\"1234567812345678\",\n :billing_address =>\"MyText\" ,\n :zipcode =>12345\n }\n end",
"def validate_lock_customer_account\n\n end",
"def customer_params\n params.require(:customer).permit(\n :name, :phone_number, :email,\n :registered_address_line_1, :registered_address_line_2, :registered_address_city, :registered_address_country,\n :mailing_address_line_1, :mailing_address_line_2, :mailing_address_city, :mailing_address_country\n )\n end",
"def customer_params\n params.require(:customer).permit(:name, :complete_name, :email, :address, :state, :country)\n end",
"def customer_params\n params.require(:customer).permit(:name, :phone_1, :phone_2, :email, :notes)\n end",
"def valid?\n return false if !@billing_city.nil? && @billing_city.to_s.length > 32\n return false if !@billing_company.nil? && @billing_company.to_s.length > 50\n return false if !@billing_country_code.nil? && @billing_country_code.to_s.length > 2\n return false if !@billing_day_phone.nil? && @billing_day_phone.to_s.length > 25\n return false if !@billing_evening_phone.nil? && @billing_evening_phone.to_s.length > 25\n return false if !@billing_first_name.nil? && @billing_first_name.to_s.length > 30\n return false if !@billing_last_name.nil? && @billing_last_name.to_s.length > 30\n return false if !@billing_postal_code.nil? && @billing_postal_code.to_s.length > 20\n return false if !@billing_state.nil? && @billing_state.to_s.length > 32\n return false if !@pricing_tier_name.nil? && @pricing_tier_name.to_s.length > 50\n return false if !@shipping_city.nil? && @shipping_city.to_s.length > 32\n return false if !@shipping_company.nil? && @shipping_company.to_s.length > 50\n return false if !@shipping_country_code.nil? && @shipping_country_code.to_s.length > 2\n return false if !@shipping_day_phone.nil? && @shipping_day_phone.to_s.length > 25\n return false if !@shipping_evening_phone.nil? && @shipping_evening_phone.to_s.length > 25\n return false if !@shipping_first_name.nil? && @shipping_first_name.to_s.length > 30\n return false if !@shipping_last_name.nil? && @shipping_last_name.to_s.length > 30\n return false if !@shipping_postal_code.nil? && @shipping_postal_code.to_s.length > 20\n return false if !@shipping_state.nil? && @shipping_state.to_s.length > 32\n true\n end",
"def customer_params\n params.require(:customer).permit(:email, :password, :password_confirmation, :customerName, :contactName, :address, :city, :postalCode, :country)\n end",
"def create_customer\n input_param = params[:user] || params[:customer]\n if input_param\n input_param.delete(:password)\n input_param.delete(:password_confirmation)\n input_param.delete(:username)\n if current_user.is_a?(Referral) && input_param[:profile_attributes].present?\n input_param[:referral_category_id] = current_user.referral_category_id\n input_param[:profile_attributes][:referal_id] = current_user.code\n input_param[:profile_attributes][:referal] = current_user.referral_category.name if current_user.referral_category\n end\n end\n\n @customer = Customer.find_or_initialize_by_email(input_param[:email])\n @membership_order = Membership.find(session[:current_premium_id]) if session[:current_premium_id]\n \n if @customer.update_attributes(input_param)\n order.orderable = @customer\n # CustomerMailer.delay.welcome_email(@customer)\n CustomerMailer.delay.welcome_email_admin(@customer)\n \n if order.save && session[:current_premium_id].present?\n redirect_to extra_manage_orders_path\n else\n redirect_to premium_manage_orders_path\n end\n else\n @customer = Customer.new(input_param)\n flash[:errors] = @customer.errors.full_messages.uniq.join(', ')\n prepare_customer_form\n render :new\n end\n end",
"def customer_params\n params.require(:customer).permit(:first_name, :last_name, :email, :phone, :birthdate, :postcode, :address, :city, :country, :gender, :password, :confirmation)\n end",
"def validate\n #errors.add(:cc_number, \"There appears to be a typo in your Credit Card number.<br/>Please re-enter your card number.<br/> If you continue to have trouble, please <a url='/contactus.htm'>Contact Us.</a>\") unless cc_number.creditcard?\n today = DateTime.now\n #if (today.month > self.expiration_month && today.year >= self.expiration_year)\n #\terrors.add(:expiration_month, 'Please enter a valid expiration date.')\n #end\n\n # Add errors for credit card accounts\n #if (credit_card_payment? && self.cc_number.blank?)\n # errors.add(:cc_number, ERROR_EMPTY)\n #end\n end",
"def create\n @customer = Customer.new(customer_params)\n\n @existing_customers = Customer.where(customer_surname: @customer.customer_surname)\n\n @err = 0\n @existing_customers.each do |c|\n if c.customer_surname == @customer.customer_surname && c.customer_name == @customer.customer_name\n @dubl = c\n @err += 1\n end\n end\n\n respond_to do |format|\n if @err == 0\n if @customer.save\n format.html { redirect_to @customer, notice: 'Person wurde erfolgreich erstellt.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to @dubl, notice: 'Person existiert bereits!' }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n\n\n\n end",
"def validate_that_at_least_one_set_of_contact_info_is_present\n return if veteran_contact_info.present? || claimant_contact_info.present?\n\n errors.add :form_data, I18n.t('appeals_api.errors.contact_info_presence')\n end",
"def valid?\n return false if @address1.nil?\n return false if @address1.to_s.length > 100\n return false if @address1.to_s.length < 1\n return false if !@address2.nil? && @address2.to_s.length > 100\n return false if @amount.nil?\n return false if @amount > 10000000\n return false if @amount < 1\n return false if !@business_description.nil? && @business_description.to_s.length > 500\n business_type_validator = EnumAttributeValidator.new('String', [\"corporate\", \"individual\"])\n return false unless business_type_validator.valid?(@business_type)\n return false if !@corporate_number.nil? && @corporate_number !~ Regexp.new(/^\\\\d{13}$/)\n return false if @email.nil?\n return false if @end_date.nil?\n return false if @prefecture.nil?\n prefecture_validator = EnumAttributeValidator.new('String', [\"北海道\", \"青森県\", \"岩手県\", \"宮城県\", \"秋田県\", \"山形県\", \"福島県\", \"茨城県\", \"栃木県\", \"群馬県\", \"埼玉県\", \"千葉県\", \"東京都\", \"神奈川県\", \"新潟県\", \"富山県\", \"石川県\", \"福井県\", \"山梨県\", \"長野県\", \"岐阜県\", \"静岡県\", \"愛知県\", \"三重県\", \"滋賀県\", \"京都府\", \"大阪府\", \"兵庫県\", \"奈良県\", \"和歌山県\", \"鳥取県\", \"島根県\", \"岡山県\", \"広島県\", \"山口県\", \"徳島県\", \"香川県\", \"愛媛県\", \"高知県\", \"福岡県\", \"佐賀県\", \"長崎県\", \"熊本県\", \"大分県\", \"宮崎県\", \"鹿児島県\", \"沖縄県\"])\n return false unless prefecture_validator.valid?(@prefecture)\n return false if !@remark.nil? && @remark.to_s.length > 500\n return false if !@representative_name.nil? && @representative_name.to_s.length > 30\n return false if @tel.nil?\n return false if @tel !~ Regexp.new(/^0((\\\\d{1,2}-?\\\\d{1,4}|\\\\d{3,4}-?\\\\d{1,2})-?\\\\d{4}|120-?\\\\d{3}-?\\\\d{3})$/)\n return false if !@url.nil? && @url.to_s.length > 500\n return false if @zip_code.nil?\n return false if @zip_code !~ Regexp.new(/^\\\\d{3}-?\\\\d{4}$/)\n return true\n end",
"def customer_params\n params.require(:customer).permit(:unit_id, :name, :cnpj, :cpf, :zipcode, :state, :city_name, :address, :address_number, :address_complement, :neighborhood, :email, :phone_number, :created_at, :fl_charge_monetary_correction, :fl_charge_interest, :fl_charge_fine, :fl_charge_tax)\n end",
"def customer_params\n params.require(:customer).permit(:first_name, :last_name, :email, :phone, :address, :city, :state_id, :zipcode, :country_id, :comment, :customer_status_id)\n end",
"def customer_params\n params.require(:customer).permit(:customer_name, :customer_street, :customer_town, :customer_phone, :customer_fax, :customer_email, :customer_notes, :customer_surname, :customer_mobile, :customer_club, :customer_newsletter, :supplier_id, :customer_group)\n end",
"def customer_params\n params.require(:customer).permit(:customer_id, :last_name, :first_name, :email, :home_phone, :cell_phone, :fax, :address, :city, :state_province, :zip_postal_code, :country_region)\n end",
"def customer_params\n params.require(:customer).permit(:name, :addrline1, :addr_city, :addr_state, :addr_country, :addr_pincode, :phone_no, :note)\n end",
"def customer_params\n params.require(:customer).permit(:email, :password, :password_confirmation, :firstname, :lastname, :address, :postcode, :city, :phone, :age, :gender)\n end",
"def customer_params\n params.require(:customer).permit(:first_name, :middle_name, :last_name, :address, :phone, :email, :gender, :age, :status)\n end",
"def customer_detail_params\n params.require(:customer_detail).permit(:CustomerName, :POC, :BillingAddress, :InstallationAddress, :AttendentContact)\n end",
"def customer_params\n params.permit(:customer, :name, :email, :password, :credit_card, :address_1, :address_2, :city, :region, :postal_code, :country, :shipping_region_id, :day_phone, :eve_phone, :mob_phone)\n end",
"def customer_params\n params.require(:customer).permit(:first_name, :last_name, :phone, :query, :email,\n :street_address, :city, :acct_open_date, :agreement_status, :trans_type,\n :last_trans_date, :street_address2, :postal, :province, :notes)\n end",
"def create\n @customer_payment = CustomerPayment.new(params[:customer_payment])\n #if check_validation\n if @customer_payment.save\n redirect_to(edit_customer_payment_path(@customer_payment), :notice => 'customer payment was successfully created.')\n else\n render :action => \"new\"\n end\n\n end",
"def customer_params\n params.require(:customer).permit(:name, :fname, :mname, :country, :city, :uf, :birth, :email, :annotation, :schooling, :civil_status, :cpf, :rg)\n end",
"def customer_params\n params.require(:customer).permit(:first_name, :last_name, :phone_number , :city)\n end",
"def customer_params\n params.require(:customer).permit(:firstname, :lastname, :email, :phone, :country_id, :state_id, :city, :zipcode, :address, :customerstatusid)\n end",
"def customer_params\n params.require(:customer).permit :name,\n :surname,\n :mobile,\n :email\n end",
"def customer_params\n params.require(:customer).permit(:first_name, :last_name, :mobile, :otpsent, :otpreceived)\n end",
"def customer_params\n params.require(:customer).permit(\n :name,\n :email,\n :address,\n :org_number,\n :contact_person,\n :phone)\n end",
"def customer_info_params\n params.require(:customer_info).permit(:user_id, :real_name, :comment_info, :phone_number, :resturant_address, :identify_number)\n end",
"def load_customer_info(customer)\n self.customer_id = customer.id\n self.cardholder_email = customer.email\n\n customer_card = get_default_card(customer)\n\n self.cardholder_name = customer_card.name\n self.card_type = customer_card.type\n self.last4 = customer_card.last4\n self.expiration = customer_card.exp_month.to_s +\n '/' + customer_card.exp_year.to_s\n end",
"def customer_params\n params.require(:customer).permit(:accountid, :userclass, :fullname, :password, :zipcode, :address, :country, :birthday, :sex, :nationality, :tel, :fax, :mobile, :email, :parentid, :bank_id, :holderid, :service1, :service2, :cbc)\n end",
"def test_validations \n c = Customer.new\n c.email = 'foo'\n c.first_name = 'A'\n c.last_name = 'A'\n c.password = 'foobar'\n c.password_confirmation = 'barfoo'\n assert !c.valid?\n# XYZ FIX P4: get these validations back in (see app/models/customer.rb, line 52)\n# assert c.errors.invalid?(:first_name)\n# assert c.errors.invalid?(:last_name)\n# assert c.errors.invalid?(:email)\n# assert c.errors.invalid?(:password)\n # Different password error\n c.password = 'foo'\n c.password_confirmation = 'foo'\n assert !c.valid?\n# assert c.errors.invalid?(:password)\n # Password OK\n c.password = 'foobar'\n c.password_confirmation = 'foobar'\n assert !c.valid?\n# assert !c.errors.invalid?(:password)\n # Last name OK\n c.last_name = 'Aaron'\n assert !c.valid?\n# assert !c.errors.invalid?(:last_name)\n # First name OK\n c.first_name = 'Abernathy'\n assert !c.valid?\n# assert !c.errors.invalid?(:first_name)\n # Different email error, duplicate\n c.email = 'bob@bob.com'\n assert !c.valid?\n# assert c.errors.invalid?(:email)\n # Email OK, entire customer OK\n c.email = 'aaron@bob.com'\n assert c.valid?\n# assert !c.errors.invalid?(:email)\n end",
"def validate\n errors.add(:post_office, \"- must be filled for postalcode #{self.postal_code}\") if self.post_office.blank? && !self.postal_code.blank?\n errors.add(:postal_code, \"- must be filled for #{self.post_office}\") if self.postal_code.blank? && !self.post_office.blank? \n errors.add_to_base(\"- Person must have at least one phonenumber\") if (self.phone_home.blank? && self.phone_cell.blank? && self.phone_work.blank?) \n end",
"def check_values\n check_numericity\n check_zip_code\n end",
"def customer_params\n params.require(:customer).permit(:email, :first_name, :last_name, :custid, :dob, :active, :notes)\n end",
"def validate(args)\n if args.keys.sort == PARAMS.sort\n unless Float(args[:x]) && Float(args[:y]) && Float(args[:id])\n raise \"Wrong Customer params type: #{args}\"\n end\n else\n raise \"Illformed Customer params: #{args}\"\n end\n end",
"def customer_params\n params.require(:customer).permit(:title, :first_name, :last_name, :email, :phone, :address, :city, :state, :zip, :country, :reservation_ids => [])\n end",
"def customer_params\n params.require(:customer).permit(:name, :address, :payment_term, :note)\n end",
"def customer_params\n params.require(:customer).permit(:first_name, :last_name, :mobile, :address, :photo, :gps_location, :id_pp, :sex, :disabled, :race, :number_in_household, :terms_agreed, :start_date, :end_date, :end_date_reason, :power_pack_paid, :lease_stove, :stove_number, :installed, :fuel_cook, :cook_kerosene, :cook_coal, :cook_wood, :cook_charcoal, :cook_lpg, :cook_cng, :cook_electricity, :fuel_heat, :heat_kerosene, :heat_coal, :heat_wood, :heat_charcoal, :heat_lpg, :heat_cng, :heat_electricity, :user_id)\n end",
"def customer_params\n params.require(:customer).permit(:name, :email, :password)\n end",
"def validate\n cc = self.credit_card\n cc.validate\n cc.errors.full_messages.each do |e|\n self.errors.add_to_base(e)\n end\n end",
"def customer_params\n params.require(:customer).permit(:nome, :email, :telefone, :dispositivo, :price, :profissao, :endereco)\n end",
"def test_validate_fields\n ba = BillingAddress.new\n assert_equal [:name, :address1, :city, :state, :zip, :country, :phone, :email], ba.validate_fields\n end",
"def contact_fields\n if contact_type == 'contact'\n validates_length_of :first_name, minimum: 2, maximum: 20 if validates_presence_of :first_name\n validates_length_of :last_name, minimum: 2, maximum: 20 if validates_presence_of :last_name\n end\n end",
"def customer_params\n params.require(:customer).permit(:id, :email, :password, :password_confirmation, \n :preferred_store_id,\n :first_name, :last_name, :nick_name, \n :home_phone, :cell_phone, \n :address1, :city, :state_id, :zip\n )\n end",
"def customer_params\n params.require(:customer).permit(:customer_name, :username, :registration_date, :email, :phone_number, :address, :gender)\n end",
"def customer_params\n params.require(:customer).permit(:CompanyName, :NameOfContact, :CompanyContactPhone, :EmailOfTheCompany, :CompanyDescription, :NameOfServiceTechAuthority, :TechAuhtorityPhone, :TechManagerServiceEmail)\n end",
"def create\n @customer_detail = CustomerDetail.new(customer_detail_params)\n # When we make a new CustomerDetail, also make a Customer to go with it, using the Email from CustomerDetail\n customer_info = customer_detail_params['customer_attributes']\n customer_info['email'] = customer_detail_params['email']\n @customer = Customer.create(customer_info)\n @customer_detail.customer = @customer\n\n respond_to do |format|\n if @customer_detail.save\n format.html { redirect_to wines_url,\n notice: \"User #{@customer_detail.email} was successfully created. Please proceed to Login.\" }\n format.json { render :show, status: :created, location: @customer_detail }\n else\n format.html { render :new }\n format.json { render json: @customer_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def customer_params\n params.require(:customer).permit(:name, :company_name, :address1, :address2, :postal_code)\n end",
"def customer_params\n params.require(:customer).permit(:name, :last_name, :phone, :address)\n end",
"def customer_params\n params.require(:customer).permit(:name, :first_name, :email, :password, :password_confirmation, :language, :country_id, :mobile, :birthdate, :picture, :picture_cache, :formatted_address, :street_address, :administrative_area_level_1, :administrative_area_level_2, :postal_code, :locality, :lat, :lng, :description, :terms_of_service)\n end",
"def customer_params\n params.require(:customer).permit(:customer_id, :email, :occupation, :birthday, :shop_domain, :avatar)\n end",
"def customer_params\n params.require(:customer).permit(:full_name, :phone_number, :email, :image, :notes)\n end",
"def validate_cuit\n errors[:base] << \"El CUIT no es válido\" if not validar_cuit(self.cuit)\n end",
"def customer(params={})\n add_field(mappings[:customer][:email], params[:email])\n add_field(mappings[:customer][:phone], params[:phone])\n add_field('name', \"#{params[:first_name]} #{params[:last_name]}\")\n end",
"def single_customer_params\n unless params[:single_customer].nil?\n params.require(:single_customer).permit(:name, :gender, :ethnic_name, :birth, :id_no, :id_address, :hukou_type, \n :education, :tel, :other_contact_person, :other_contact_call, :qq, :wechat, \n :email, :communication_address, :is_doc_for_shebao, :is_doc_for_shigong, \n :is_doc_for_shenggong, :is_doc_for_butuichajia, :is_doc_for_xufei, \n :is_doc_for_qita, :is_usage_zhengchang, :is_usage_ruxue, :is_usage_luohu, \n :is_usage_shenyu, :is_usage_yiliao, :is_usage_gouche, :is_usage_goufang, \n :is_usage_daikuan, :creator, :creator_tel, :comment, :user_id, :input_date, \n :document_no, :workflow_state, :comment_for_qita)\n end\n end",
"def new_customer_params\n params.require(:customer).permit(:name, :email, :phone, :description, :company, :address, :city, :state, :zip)\n end",
"def customer_params\n params.require(:customer).permit(:company_id, :title, :first_name, :surname, :position, :address_1, :address_2, :city, :county, :country, :postcode, :phone, :alt_phone, :email, :company_name, :notes)\n end",
"def customer_params\n params.require(:customer).permit(:name, :lastname, :firstname, :zipcode, :address, :vatid, :locked, :active)\n end",
"def validate_client_details\n\n return error_with_data(\n 'um_su_3',\n 'Client is not active',\n 'Client is not active',\n GlobalConstant::ErrorAction.default,\n {}\n ) if !@client.is_web_host_setup_done?\n\n return error_with_data(\n 'um_su_4',\n 'Registration has ended, it is no longer possible to signup now',\n 'Registration has ended, it is no longer possible to signup now',\n GlobalConstant::ErrorAction.default,\n {},\n {}\n ) if @client_token_sale_details.has_registration_ended?\n\n success\n end",
"def valid_attributes\n { :customer_paypal_id => '1234' }\n end",
"def handle_cust\n email = @rec.clientemail\n\n # if email is nil and this is an out email try cc_addr for email\n if email == nil and @dir == 'out'\n email = @rec.cc_addr\n end\n\n # ignore if no customer email\n if email == nil\n @rec.ignore_match = true\n @rec.error_str = 'No customer email address'\n @rec.save\n @no_cust += 1\n return nil\n end\n\n email.strip!\n if email == ''\n @rec.ignore_match = true\n @rec.error_str = 'No customer email address'\n @rec.save\n @no_cust += 1\n return nil\n end\n\n # find customer or add\n cust = Customer.find_by_email(email)\n if cust == nil\n if @rec.clientphone != nil\n home = @rec.clientphone\n mobile = nil\n if home[0..1] == '07'\n mobile = home\n home = nil\n end\n else\n home = nil\n mobile = nil\n end\n\n cust = Customer.create(\n :email => email,\n :title => @rec.cust_tl,\n :firstname => @rec.cust_fs,\n :lastname => @rec.cust_ls,\n :phone_home => home,\n :phone_mobile => mobile,\n :active => true,\n :gets_fu => true\n )\n @new_cust += 1\n else\n @custpres += 1\n end\n\n return cust\n end",
"def list_invalid_properties\n invalid_properties = Array.new\n if !@billing_city.nil? && @billing_city.to_s.length > 32\n invalid_properties.push('invalid value for \"billing_city\", the character length must be smaller than or equal to 32.')\n end\n\n if !@billing_company.nil? && @billing_company.to_s.length > 50\n invalid_properties.push('invalid value for \"billing_company\", the character length must be smaller than or equal to 50.')\n end\n\n if !@billing_country_code.nil? && @billing_country_code.to_s.length > 2\n invalid_properties.push('invalid value for \"billing_country_code\", the character length must be smaller than or equal to 2.')\n end\n\n if !@billing_day_phone.nil? && @billing_day_phone.to_s.length > 25\n invalid_properties.push('invalid value for \"billing_day_phone\", the character length must be smaller than or equal to 25.')\n end\n\n if !@billing_evening_phone.nil? && @billing_evening_phone.to_s.length > 25\n invalid_properties.push('invalid value for \"billing_evening_phone\", the character length must be smaller than or equal to 25.')\n end\n\n if !@billing_first_name.nil? && @billing_first_name.to_s.length > 30\n invalid_properties.push('invalid value for \"billing_first_name\", the character length must be smaller than or equal to 30.')\n end\n\n if !@billing_last_name.nil? && @billing_last_name.to_s.length > 30\n invalid_properties.push('invalid value for \"billing_last_name\", the character length must be smaller than or equal to 30.')\n end\n\n if !@billing_postal_code.nil? && @billing_postal_code.to_s.length > 20\n invalid_properties.push('invalid value for \"billing_postal_code\", the character length must be smaller than or equal to 20.')\n end\n\n if !@billing_state.nil? && @billing_state.to_s.length > 32\n invalid_properties.push('invalid value for \"billing_state\", the character length must be smaller than or equal to 32.')\n end\n\n if !@pricing_tier_name.nil? && @pricing_tier_name.to_s.length > 50\n invalid_properties.push('invalid value for \"pricing_tier_name\", the character length must be smaller than or equal to 50.')\n end\n\n if !@shipping_city.nil? && @shipping_city.to_s.length > 32\n invalid_properties.push('invalid value for \"shipping_city\", the character length must be smaller than or equal to 32.')\n end\n\n if !@shipping_company.nil? && @shipping_company.to_s.length > 50\n invalid_properties.push('invalid value for \"shipping_company\", the character length must be smaller than or equal to 50.')\n end\n\n if !@shipping_country_code.nil? && @shipping_country_code.to_s.length > 2\n invalid_properties.push('invalid value for \"shipping_country_code\", the character length must be smaller than or equal to 2.')\n end\n\n if !@shipping_day_phone.nil? && @shipping_day_phone.to_s.length > 25\n invalid_properties.push('invalid value for \"shipping_day_phone\", the character length must be smaller than or equal to 25.')\n end\n\n if !@shipping_evening_phone.nil? && @shipping_evening_phone.to_s.length > 25\n invalid_properties.push('invalid value for \"shipping_evening_phone\", the character length must be smaller than or equal to 25.')\n end\n\n if !@shipping_first_name.nil? && @shipping_first_name.to_s.length > 30\n invalid_properties.push('invalid value for \"shipping_first_name\", the character length must be smaller than or equal to 30.')\n end\n\n if !@shipping_last_name.nil? && @shipping_last_name.to_s.length > 30\n invalid_properties.push('invalid value for \"shipping_last_name\", the character length must be smaller than or equal to 30.')\n end\n\n if !@shipping_postal_code.nil? && @shipping_postal_code.to_s.length > 20\n invalid_properties.push('invalid value for \"shipping_postal_code\", the character length must be smaller than or equal to 20.')\n end\n\n if !@shipping_state.nil? && @shipping_state.to_s.length > 32\n invalid_properties.push('invalid value for \"shipping_state\", the character length must be smaller than or equal to 32.')\n end\n\n invalid_properties\n end",
"def validate\n validate_vendor\n end",
"def customer_params\n params.require(:customer).permit(:email, :password, :password_confirmation, :current_password, :firstname, :lastname, :address, :postcode, :city, :phone, :date_of_birth, :gender)\n end",
"def customer_params\n params.require(:customer).permit(:email, :password, :password_confirmation, :current_password, :firstname, :lastname, :address, :postcode, :city, :phone, :date_of_birth, :gender)\n end",
"def customer_params\n params.require(:customer).permit(:name, :first_name, :email, :password, :password_confirmation, :language, :country_id, :mobile, :picture, :picture_cache, :formatted_address, :street_address, :administrative_area_level_1, :administrative_area_level_2, :postal_code, :locality, :lat, :lng, :description, :terms_of_service)\n end",
"def valid_with_credit_card?\n self.valid?\n errors.add(:credit_card, \"can't be blank\") if self.credit_card == \"0\" || \n self.credit_card.blank?\n\n errors.add(:cvv, \"can't be blank\") if self.cvv == \"0\" || \n self.cvv.blank?\n\n self.expiration_date = DateTime.new(self.card_year.to_i, self.card_month.to_i).end_of_month\n\n errors.add(:expiration_date, \"can't be in past\") if self.expiration_date < Time.now\n\n end",
"def customer_params\n params.require(:customer).permit(:name, :phone, :delivery_date, :work, :mobile, :address, :request_date, :cash, :paid, :remained, :lft_sp, :lft_cl, :lft_ax, :rght_sp, :rght_cl, :rght_ax, :doctor, :req_store, :deliv_store, :comment, :delivered)\n end",
"def valid?\n return false if @remit_name.nil?\n return false if @remit_name.to_s.length > 50\n return false if @location.nil?\n return false if !@address_one.nil? && @address_one.to_s.length > 50\n return false if !@address_two.nil? && @address_two.to_s.length > 50\n return false if !@city.nil? && @city.to_s.length > 50\n return false if !@zip.nil? && @zip.to_s.length > 12\n return false if !@phone.nil? && @phone.to_s.length > 15\n return false if @invoice_title.nil?\n return false if @invoice_title.to_s.length > 50\n return false if @payable_name.nil?\n return false if @payable_name.to_s.length > 50\n return false if !@topcomment.nil? && @topcomment.to_s.length > 4000\n return false if !@invoice_footer.nil? && @invoice_footer.to_s.length > 500\n return false if !@quote_footer.nil? && @quote_footer.to_s.length > 1000\n return false if @overall_invoice_default.nil?\n prefix_suffix_flag_validator = EnumAttributeValidator.new('String', [\"Prefix\", \"Suffix\"])\n return false unless prefix_suffix_flag_validator.valid?(@prefix_suffix_flag)\n return false if !@prefix_suffix_text.nil? && @prefix_suffix_text.to_s.length > 5\n return false if @email_template.nil?\n return false if !@business_number.nil? && @business_number.to_s.length > 50\n return false if !@custom_label.nil? && @custom_label.to_s.length > 50\n return false if !@custom_text.nil? && @custom_text.to_s.length > 500\n return false if !@company_code.nil? && @company_code.to_s.length > 250\n return true\n end",
"def customer_params\n params.require(:customer).permit(:phone, :first_name, :last_name, :campaign_id, :custom1, :custom2, :custom3)\n end",
"def crm_customer_params\n params.require(:customer).permit(:name, :gender, :mobile, :address, :zip,:company,:birth_date,\n :email,:password,:customer_type_id,:is_enabled,:province_id,\n :city_id,:area_id) \n end",
"def setCustomerAttributes(customernumber, email, firstname, lastname, salutation, password, shopId, street, city, zipcode, country)\n #if string_country\n customer_properties = {\n :number => customernumber,\n :email => email,\n :firstname => firstname,\n :lastname => lastname,\n :salutation => salutation,\n :password => password,\n :shopId => shopId,\n :billing => {\n :firstname => firstname,\n :lastname => lastname,\n :salutation => salutation,\n :street => street,\n :city => city,\n :zipcode => zipcode,\n :country => country\n }\n }\n createCustomer(customer_properties)\n end",
"def add_customer_data(post, options)\n a = options[:address] || {} # shipping address\n \n phone = get_phone_number(a[:phone])\n \n c = {\n :firstname => options[:first_name],\n :lastname => options[:last_name],\n :email => options[:email],\n :zippostal => a[:zip],\n :city => a[:city],\n :address1 => a[:address1],\n :address2 => nil,\n :stateregioniso => a[:state],\n :countryiso => iso_code_for(a[:country]),\n \n :phone1phone => phone[:number],\n :phone1country => phone[:country],\n :phone1area => phone[:area],\n \n :phone2phone => nil,\n :phone2country => nil,\n :phone2area => nil,\n \n :birthday => options[:birth_day] || 01,\n :birthmonth => options[:birth_month] || 01,\n :birthyear => options[:birth_year] || 1980,\n :ipaddress => options[:ip],\n :accountid => options[:id]\n }\n\n post[:customer] = c\n post\n end",
"def valid?\n !vendor_no.nil? && !name.nil?\n end",
"def customer_params\n params.require(:customer).permit(:name, :print_name, :contact_person, :contact_phone, \n :is_leaf, :group_id)\n end",
"def customer_params\n params.require(:customer).permit(:name)\n # , :username, :email)\n end",
"def customer_params\n params.require(:customer).permit(:first_name, :last_name, :user_id)\n end",
"def customer(params={})\n add_field(mappings[:customer][:email], params[:email])\n add_field(mappings[:customer][:phone], params[:phone])\n add_field('name', \"#{params[:first_name]} #{params[:last_name]}\")\n end",
"def validate_telefones\n # must have one or more telefones\n return false if @telefones.empty?\n @telefones.each do |t|\n # each telefone must have ddd and numero\n return false if t.ddd == \"\" || t.numero == \"\"\n end\n return true\n end",
"def update_customer_details\n\n # Make the order in final state to add specific validations\n @order.is_final\n \n if @order.update_attributes(params[:order])\n redirect_to confirm_order_path(@order)\n else\n render :edit_customer_details\n end\n end",
"def valid?\n return false if @identifier.nil?\n return false if @identifier.to_s.length > 15\n return false if !@password.nil? && @password.to_s.length > 60\n return false if @first_name.nil?\n return false if @first_name.to_s.length > 30\n return false if @last_name.nil?\n return false if @last_name.to_s.length > 30\n return false if !@title.nil? && @title.to_s.length > 50\n return false if @license_class.nil?\n license_class_validator = EnumAttributeValidator.new('String', [\"F\", \"A\", \"C\", \"X\"])\n return false unless license_class_validator.valid?(@license_class)\n return false if !@employee_identifer.nil? && @employee_identifer.to_s.length > 10\n return false if @time_zone.nil?\n return false if !@office_email.nil? && @office_email.to_s.length > 250\n return false if !@office_phone.nil? && @office_phone.to_s.length > 15\n return false if !@office_extension.nil? && @office_extension.to_s.length > 10\n return false if !@mobile_email.nil? && @mobile_email.to_s.length > 250\n return false if !@mobile_phone.nil? && @mobile_phone.to_s.length > 15\n return false if !@mobile_extension.nil? && @mobile_extension.to_s.length > 10\n return false if !@home_email.nil? && @home_email.to_s.length > 250\n return false if !@home_phone.nil? && @home_phone.to_s.length > 15\n return false if !@home_extension.nil? && @home_extension.to_s.length > 10\n return false if @default_email.nil?\n default_email_validator = EnumAttributeValidator.new('String', [\"Office\", \"Mobile\", \"Home\"])\n return false unless default_email_validator.valid?(@default_email)\n return false if @default_phone.nil?\n default_phone_validator = EnumAttributeValidator.new('String', [\"Office\", \"Mobile\", \"Home\"])\n return false unless default_phone_validator.valid?(@default_phone)\n return false if @security_role.nil?\n return false if @structure_level.nil?\n return false if @security_location.nil?\n return false if @default_location.nil?\n return false if @default_department.nil?\n return false if @work_role.nil?\n return false if @time_approver.nil?\n return false if @expense_approver.nil?\n return false if @hire_date.nil?\n return false if @sales_default_location.nil?\n return false if !@ldap_user_name.nil? && @ldap_user_name.to_s.length > 50\n return false if @company_activity_tab_format.nil?\n company_activity_tab_format_validator = EnumAttributeValidator.new('String', [\"SummaryList\", \"DetailList\"])\n return false unless company_activity_tab_format_validator.valid?(@company_activity_tab_format)\n return false if @invoice_time_tab_format.nil?\n invoice_time_tab_format_validator = EnumAttributeValidator.new('String', [\"SummaryList\", \"DetailList\"])\n return false unless invoice_time_tab_format_validator.valid?(@invoice_time_tab_format)\n return false if @invoice_screen_default_tab_format.nil?\n invoice_screen_default_tab_format_validator = EnumAttributeValidator.new('String', [\"ShowInvoicingTab\", \"ShowAgreementInvoicingTab\"])\n return false unless invoice_screen_default_tab_format_validator.valid?(@invoice_screen_default_tab_format)\n return false if @invoicing_display_options.nil?\n invoicing_display_options_validator = EnumAttributeValidator.new('String', [\"RemainOnInvoicingScreen\", \"ShowRecentInvoices\"])\n return false unless invoicing_display_options_validator.valid?(@invoicing_display_options)\n return false if @agreement_invoicing_display_options.nil?\n agreement_invoicing_display_options_validator = EnumAttributeValidator.new('String', [\"RemainOnInvoicingScreen\", \"ShowRecentInvoices\"])\n return false unless agreement_invoicing_display_options_validator.valid?(@agreement_invoicing_display_options)\n return false if !@corelytics_username.nil? && @corelytics_username.to_s.length > 50\n return false if !@corelytics_password.nil? && @corelytics_password.to_s.length > 50\n remote_package_validator = EnumAttributeValidator.new('String', [\"LogMeIn\", \"NTR\"])\n return false unless remote_package_validator.valid?(@remote_package)\n return false if !@remote_package_platform.nil? && @remote_package_platform.to_s.length > 250\n return false if !@remote_package_user_name.nil? && @remote_package_user_name.to_s.length > 50\n return false if !@remote_package_password.nil? && @remote_package_password.to_s.length > 50\n return false if !@remote_package_account.nil? && @remote_package_account.to_s.length > 250\n authentication_service_type_validator = EnumAttributeValidator.new('String', [\"AuthAnvil\", \"GoogleAuthenticator\"])\n return false unless authentication_service_type_validator.valid?(@authentication_service_type)\n return true\n end",
"def customer_params\n params.require(:customer).permit(:name, :phone, :email, :desc, :subscribed, :accessible, :child_friendly)\n end",
"def presence_of_mandatory_fields\n if promo_amount.blank? and info.blank?\n errors[:base] << 'Au moins un des champs doivent être remplis'\n end\n end",
"def valid?\n return false if !@external_id.nil? && @external_id.to_s.length > 64\n return false if !@first_name.nil? && @first_name.to_s.length > 128\n return false if @last_name.nil?\n return false if @last_name.to_s.length > 64\n return false if @last_name.to_s.length < 1\n return false if !@middle_name.nil? && @middle_name.to_s.length > 64\n gender_validator = EnumAttributeValidator.new('String', [\"M\", \"F\"])\n return false unless gender_validator.valid?(@gender)\n return false if !@language.nil? && @language.to_s.length > 32\n return false if !@phone.nil? && @phone.to_s.length > 64\n return false if !@email.nil? && @email.to_s.length > 128\n return false if !@doc_type.nil? && @doc_type.to_s.length > 32\n return false if !@doc_issuer_info.nil? && @doc_issuer_info.to_s.length > 256\n return false if !@doc_series.nil? && @doc_series.to_s.length > 64\n return false if !@doc_number.nil? && @doc_number.to_s.length > 64\n return false if !@department_code.nil? && @department_code.to_s.length > 64\n return false if !@department_name.nil? && @department_name.to_s.length > 256\n return false if !@building_no.nil? && @building_no.to_s.length > 8\n return false if !@city.nil? && @city.to_s.length > 32\n return false if !@country_code.nil? && @country_code.to_s.length > 8\n return false if !@country_name.nil? && @country_name.to_s.length > 64\n return false if !@district.nil? && @district.to_s.length > 64\n return false if !@flat_no.nil? && @flat_no.to_s.length > 8\n return false if !@house_no.nil? && @house_no.to_s.length > 16\n return false if !@region.nil? && @region.to_s.length > 64\n return false if !@room_no.nil? && @room_no.to_s.length > 8\n return false if !@settlement_type.nil? && @settlement_type.to_s.length > 32\n return false if !@street.nil? && @street.to_s.length > 64\n return false if !@raw_address.nil? && @raw_address.to_s.length > 512\n true\n end",
"def create\n @customer = Customer.new(customer_params)\n @city=City.find(params[:customer][:city])\n @cleaners=@city.cleaners\n @current_customer= Customer.find_by(phone_number: @customer.phone_number)\n if @current_customer.nil?\n respond_to do |format|\n if @customer.save\n @cleaners.each do |cleaner|\n if Booking.where(date:params[:customer][:booking][:date],cleaner_id: cleaner.id).count == 0\n @booking=Booking.create(cleaner_id:cleaner.id, customer_id: @customer.id , date: params[:customer][:booking][:date])\n customer=@customer\n CleanerMailer.cleaner_email(cleaner , customer).deliver\n break\n end\n end\n format.html { redirect_to booking_path(@booking), notice: 'Customer was successfully created.' }\n format.json { render :show, status: :created, location: @customer }\n else\n format.html { render :new }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n else\n @cleaners.each do |cleaner|\n if Booking.where(date:params[:customer][:booking][:date],cleaner_id: cleaner.id).count == 0\n @booking=Booking.create(cleaner_id:cleaner.id, customer_id: @current_customer.id , date: params[:customer][:booking][:date])\n customer = @current_customer\n CleanerMailer.cleaner_email(cleaner , customer).deliver\n break\n end\n end\n if @booking.nil?\n flash[:notice] = \"Sorry cleaners not available or invalide date please try again!!\"\n redirect_to new_customer_path\n else\n redirect_to booking_path(@booking)\n end\n end\n end",
"def before_POST(req)\n super\n @errors = validate_billing_info\n render template_path() if has_errors?\n end",
"def customer?\n \n customers = Customer.where([\"email_company_contact = ?\", email])\n #customer_id = Customer.find()\n if customers.size > 0\n true\n else\n end\n end",
"def customer_params\n params.require(:customer).permit(:custID, :interested, :bought, :phone)\n end",
"def account_customer_info?\n !current_customer.nil?\n end"
] | [
"0.6997937",
"0.6833675",
"0.6657448",
"0.65981555",
"0.640802",
"0.63878965",
"0.6309316",
"0.62906444",
"0.62375975",
"0.6229901",
"0.6203611",
"0.62035406",
"0.61952627",
"0.6194715",
"0.61937976",
"0.6193378",
"0.6192048",
"0.6161645",
"0.61593807",
"0.6143251",
"0.6132394",
"0.61269397",
"0.61185247",
"0.61174583",
"0.61173034",
"0.61164665",
"0.61011904",
"0.6093333",
"0.6092277",
"0.6088603",
"0.6082916",
"0.608192",
"0.6080509",
"0.6062109",
"0.6061316",
"0.6051185",
"0.6039426",
"0.60304224",
"0.6025827",
"0.6024448",
"0.60119325",
"0.60110426",
"0.6010414",
"0.5994011",
"0.5993379",
"0.5993083",
"0.5988794",
"0.59884006",
"0.59614676",
"0.5955478",
"0.5951387",
"0.5947683",
"0.59381336",
"0.59340626",
"0.5929137",
"0.5925488",
"0.5924027",
"0.5920056",
"0.591806",
"0.59172505",
"0.59160733",
"0.5912771",
"0.59125084",
"0.5908979",
"0.5903526",
"0.5901965",
"0.5900055",
"0.58956903",
"0.58929265",
"0.5891843",
"0.58905816",
"0.58883935",
"0.58829206",
"0.5876381",
"0.5874676",
"0.5874676",
"0.58729917",
"0.58671886",
"0.58642167",
"0.58635265",
"0.58622175",
"0.58621323",
"0.58590597",
"0.5847221",
"0.5845223",
"0.5843195",
"0.58333546",
"0.5831505",
"0.58297783",
"0.5827935",
"0.58277595",
"0.58180946",
"0.5817323",
"0.58150923",
"0.5806695",
"0.5805712",
"0.57973623",
"0.579554",
"0.5794064",
"0.57851696"
] | 0.73036194 | 0 |
Validates the selected country is eligible for the current cart contents to be shipped to | def validate_shippable
if !shipping || !shipping.valid
code = use_another_address_for_shipping ?
shipping_address.country : billing_address.country
country = Glysellin::Helpers::Countries::COUNTRIES_LIST[code]
errors.add(
:shipping_method_id,
I18n.t(
"glysellin.errors.cart.shipping_method_unavailable_for_country",
method: shipping_method.name,
country: country
)
)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new3 \n @order = Order.find( :first,\n :conditions => [\"user_id = ? and status = ? and id = ?\", self.current_user.id, \"incomplete\", params[:id]])\n begin\n @country = params[:order][:user_country]\n @order.step = \"step3\"\n logger.info(@country)\n #How many items are there in total to ship? What is the total price for the items?\n a = 0\n price = 0\n deliverables = @order.deliverables.find(:all)\n deliverables.each do |d| #How many items are there in total to ship? What is the total price for the items?\n a += d.amount\n price += d.price.to_f * d.amount.to_i\n end\n @a = a \n cost = 0\n @europe = [\"country.Austria\", \"country.Belgium\", \"country.Bulgaria\", \"country.Cyprus\", \"country.Czech Republic\", \"country.Denmark\", \"country.Estonia\", \"country.Finland\", \"country.France\", \"country.Germany\",\n \"country.Greece\", \"country.Hungary\", \"country.Ireland\", \"country.Italy\", \"country.Latvia\", \"country.Lithuania\", \"country.Luxembourg\", \"country.Malta\", \"country.Netherlands\",\n \"country.Poland\", \"country.Portugal\", \"country.Romania\", \"country.Slovakia\", \"country.Slovenia\", \"country.Spain\", \"country.Sweden\", \"country.United Kingdom\"]\n #This array can be filled with item-ids that will not be shipped to the country selected. If the user continues, they will be deleted.\n @failure = [] \n #If only a single item \n if a == 1\n logger.info(@country)\n logger.info(\"only one item!\")\n deliverables.each do |d|\n if d.country1 == @country #Directly compare the country given with the country set in the listing.\n cost += (d.country1_shipping * d.amount)\n elsif d.country2 == @country\n cost += (d.country2_shipping * d.amount)\n elsif d.country3 == @country\n cost += (d.country3_shipping * d.amount)\n elsif d.country4 == @country\n cost += (d.country4_shipping * d.amount)\n elsif d.country5 == @country\n cost += (d.country5_shipping * d.amount)\n #If the listing has EU somewhere, check whether the country in the shipping address is also in the EU\n elsif @europe.include?(@country) and (d.country1 == \"country.European_Union\" or d.country2 == \"country.European_Union\" or d.country3 == \"country.European_Union\" or d.country4 == \"country.European_Union\" or d.country5 == \"country.European_Union\") \n logger.info(\"Listing uses EU, Buyer country inside EU.\") \n logger.info(\"Buyers address is in Europe!\")\n if d.country1 == \"country.European_Union\"\n cost += (d.country1_shipping_with_another_item * d.amount)\n elsif d.country2 == \"country.European_Union\"\n cost += (d.country2_shipping_with_another_item * d.amount)\n elsif d.country3 == \"country.European_Union\"\n cost += (d.country3_shipping_with_another_item * d.amount)\n elsif d.country4 == \"country.European_Union\"\n cost += (d.country4_shipping_with_another_item * d.amount)\n elsif d.country5 == \"country.European_Union\"\n cost += (d.country5_shipping_with_another_item * d.amount)\n \n end \n elsif d.country1 == \"country.Everywhere\" #Check whether the user ships \"Everywhere else\" at any position, if not - > No shipping!\n cost += (d.country1_shipping * d.amount)\n elsif d.country2 == \"country.Everywhere\" \n cost += (d.country2_shipping * d.amount)\n elsif d.country3 == \"country.Everywhere\" \n cost += (d.country3_shipping * d.amount) \n elsif d.country4 == \"country.Everywhere\" \n cost += (d.country4_shipping * d.amount) \n elsif d.country5 == \"country.Everywhere\" \n cost += (d.country5_shipping * d.amount)\n else #The seller does not ship to your country. User may cancel the whole order or just remove the item.\n @failure << d.id\n price = price - (d.amount * d.price)\n @ultrafail = 1\n end\n end\n \n #If multiple items\n else\n logger.info(\"multiple items\") \n deliverables.each do |d|\n logger.info(\"Evaluating\" + d.title.to_s)\n logger.info(\"Cost at run is \"+ cost.to_s)\n if d.country1 == @country #Directly compare the country given with the country set in the listing.\n cost += (d.country1_shipping_with_another_item * d.amount)\n elsif d.country2 == @country\n cost += (d.country2_shipping_with_another_item * d.amount)\n elsif d.country3 == @country\n cost += (d.country3_shipping_with_another_item * d.amount)\n elsif d.country4 == @country\n cost += (d.country4_shipping_with_another_item * d.amount)\n elsif d.country5 == @country\n cost += (d.country5_shipping_with_another_item * d.amount)\n \n #If the listing has EU somewhere, check whether the country in the shipping address is also in the EU\n elsif @europe.include?(@country) and (d.country1 == \"country.European_Union\" or d.country2 == \"country.European_Union\" or d.country3 == \"country.European_Union\" or d.country4 == \"country.European_Union\" or d.country5 == \"country.European_Union\") \n logger.info(\"Listing uses EU, Buyer country inside EU.\") \n logger.info(\"Buyers address is in Europe!\")\n if d.country1 == \"country.European_Union\"\n cost += (d.country1_shipping_with_another_item * d.amount)\n elsif d.country2 == \"country.European_Union\"\n cost += (d.country2_shipping_with_another_item * d.amount)\n elsif d.country3 == \"country.European_Union\"\n cost += (d.country3_shipping_with_another_item * d.amount)\n elsif d.country4 == \"country.European_Union\"\n cost += (d.country4_shipping_with_another_item * d.amount)\n elsif d.country5 == \"country.European_Union\"\n cost += (d.country5_shipping_with_another_item * d.amount) \n end \n elsif d.country1 == \"country.Everywhere\" #Check whether the user ships \"Everywhere else\" at any position, if not - > No shipping!\n cost += (d.country1_shipping_with_another_item * d.amount)\n elsif d.country2 == \"country.Everywhere\" \n cost += (d.country2_shipping_with_another_item * d.amount)\n elsif d.country3 == \"country.Everywhere\" \n cost += (d.country3_shipping_with_another_item * d.amount) \n elsif d.country4 == \"country.Everywhere\" \n cost += (d.country4_shipping_with_another_item * d.amount) \n elsif d.country5 == \"country.Everywhere\" \n cost += (d.country5_shipping_with_another_item * d.amount)\n else #The seller does not ship to your country. User may cancel the whole order or just remove the item.\n @failure << d.id\n price = price - (d.amount * d.price)\n a = a - d.amount\n end\n logger.info(\"Cost at end of run is \"+ cost.to_s)\n end\n end\n \n @order.number_of_deliverables = a #All amounts added up, subtracted by the amounts of the removed items\n @order.price_of_all_deliverables = price #All prices added up, ...\n @order.cost_of_shipping = cost\n @order.total_cost_of_order = @order.price_of_all_deliverables + @order.cost_of_shipping\n \n #Used in view\n @total_cost_of_deliverables = @order.price_of_all_deliverables\n @total_cost_of_shipping = @order.cost_of_shipping\n @total_cost = @order.total_cost_of_order\n \n if a <= 0\n @ultrafail = 1\n end\n \n if @ultrafail == 1\n @delete_full_order = 1\n end\n \n #Check whether Cash on Delivery (CoD) has been selected, then status directly to \"payment_arrived\"\n if @order.payment_chosen == \"cod\"\n @order.status = \"payment_arrived\"\n end\n \n @shown_failures = []\n #If items should be removed, then list the ok and the fail items on the new3 page. User can proceed (items will be deleted) or cancel (back to cart)\n respond_to do |format|\n if @order.update_attributes(params[:order])\n if @failure.length >= 1 \n #Show failures on new3, allow proceed (fails have been killed but are still in cart - simply restart in cart to select different address)\n @failure.each do |fail|\n #read key and value from the hash, take the id and remove the deliverable from the order.\n @fail = Deliverable.find( :first, :conditions => [\"id = ? and order_id = ?\", fail, @order.id])\n @shown_failures << @fail\n @fail.destroy\n end\n end\n if @delete_full_order == 1\n @order.destroy\n logger.info (\"full order killed -see ya! right to cart again\")\n flash[:notice_bad] = t(\"controllers.orders.s12\") \n format.html { redirect_to @cart }\n end\n format.html #Show new3\n format.xml { head :ok }\n else\n #Create a new hash called @order. Insert the order id as the value to the key id.\n flash[:notice_bad] = t(\"controllers.orders.s13\") \n a = 0 \n price = 0\n deliverables = @order.deliverables.find(:all)\n deliverables.each do |d| #How many items are there in total to ship? What is the total price for the items?\n a += d.amount\n price += d.price.to_f * d.amount.to_i\n end\n @a = a\n @price = price\n @cost_of_shipping = 0 \n logger.info (\"rendered new 2\")\n format.html { render :action => \"new2\"}\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n rescue\n flash[:notice_bad] = t(\"controllers.orders.s11\")\n logger.info (\"Rescued and jumped to cart\")\n redirect_to cart_path()\n \n else\n end\n\n end",
"def validate_shipping_method\n if shipping_method && !shipping_method.available?(city_id: city_id)\n errors.add(:shipping_method, :invalid)\n end\n end",
"def require_country?\n true\n end",
"def supports_shipment_between_countries?(sender_country_code: nil, destination_country_code: nil)\n return false\n end",
"def validate_pos_invoice\n if self.customer_id && !self.pos_invoice_addresses\n raise_error('Billing address Required!!!!')\n end\nend",
"def valid_shipping_cost?(cost)\n flatrate_shipping_option_costs.member? cost\n end",
"def validate_country\n return unless country.present?\n return if country.valid?\n\n errors.add(:country, \"Is invalid: #{country.errors.full_messages}\")\n end",
"def apply_free_shippling_rule\n if (@subtotal > 100.00 || @customer[:state] == 'IL') # If subtotal greater than 100 or state is IL\n if !(@line_items.detect { |item| item.sku == '123' }) # If a particular item is not present\n @shipping_charge = 0\n end\n end\n end",
"def validate\r\n invalid_strings = [\r\n 'PO BOX', 'P.O. BOX', 'P.O BOX', 'PO. BOX', 'POBOX',\r\n 'P.OBOX', 'P.O.BOX', 'PO.BOX', 'P.BOX', 'PBOX', 'AFO',\r\n 'A.F.O.', 'APO', 'A.P.O.'\r\n ]\r\n cap_address = self.address.upcase()\r\n invalid_strings.each do |string|\r\n if cap_address.include?(string) then\r\n errors.add(:address, \"Sorry, we don't ship to P.O. boxes\")\r\n end\r\n end\r\n if self.country && self.country.name == \"United States of America\"\r\n unless zip.blank?\r\n unless zip =~ /^\\d{5}/\r\n errors.add(:zip, \"Please enter a valid zip.\")\r\n end\r\n end\r\n self.state = self.state.upcase\r\n errors.add(:state, \"Please use a US state abbreviation\") unless US_STATES.include?(self.state)\r\n end\r\n end",
"def scotland_country_code_valid?(country)\n country == Rails.configuration.x.allowed_property_country_code\n end",
"def validate(country)\n raise UnknownCountry, \"Country not found.\" if country.empty?\n end",
"def invalid_for_country?(country)\n !valid_for_country?(country)\n end",
"def allows?\n !(coupable_countries - restricted_countries).empty?\n end",
"def confirm_checkout\n lineItems = LineItem.find_all_by_user_id(current_user.id)\n if(lineItems)\n @transaction = Transaction.create(:buyer_id => current_user.id)\n user = current_user\n baddress = params[:address]\n bzipcode = params[:zipcode]\n if(!baddress || !bzipcode || baddress.length <=0 || bzipcode.length <=0)\n redirect_to cart_checkout_path, :notice => 'Please enter the address' #TODO: This notice should appear on page\n elsif (!params[:card][:user_id] || params[:card][:user_id].length<=0)\n redirect_to cart_checkout_path, :notice => 'Please select a credit card for payment'\n else\n if(params[:saddress] && params[:szipcode] && params[:saddress].length>0 && params[:szipcode].length == 5 )\n @saddress = params[:saddress]\n @szipcode = params[:szipcode]\n else\n @saddress= baddress\n @szipcode = bzipcode\n end\n\n\n @confirmed_items = \"\"\n @unavailable_items = \"\"\n @orders = []\n if @transaction.save\n lineItems.each do |lineItem|\n if(lineItem.line_item_type==9)\n order = Order.new\n item = Item.find(lineItem.item_id)\n auction = Auction.find_by_id(lineItem.auction_id)\n if(auction.state==1)\n auction.update_attribute(:state,2)\n order.billing_address = baddress + bzipcode\n order.shipping_address = @saddress + @szipcode\n order.item_quantity = lineItem.quantity\n order.price = Auction.find_by_item_id(lineItem.item_id).bid_amount\n order.total_price = Auction.find_by_item_id(lineItem.item_id).bid_amount * lineItem.quantity\n order.transaction_id = @transaction.id\n order.seller_id = item.user_id\n order.buyer_id = current_user.id\n order.item_id = item.id\n order.state = 0\n\n if(!order.save)\n redirect_to \"back\", :notice => \"Error creating order, or contact administrator with this message\"\n else\n @orders.push(order)\n @confirmed_items = @confirmed_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n NotifyUser.order_confirmation(user,@confirmed_items,@orders).deliver\n lineItem.destroy\n end\n end\n\n end\n\n\n if(lineItem.line_item_type==0)\n order = Order.new\n item = Item.find(lineItem.item_id)\n if(lineItem.quantity<=item.availability)\n order.billing_address = baddress + bzipcode\n order.shipping_address = @saddress + @szipcode\n order.item_quantity = lineItem.quantity\n order.price = item.price\n order.total_price = Float(item.price) * lineItem.quantity\n order.transaction_id = @transaction.id\n order.seller_id = item.user_id\n order.buyer_id = current_user.id\n order.item_id = item.id\n order.state = 0\n\n if(order.save)\n item.sold_count += lineItem.quantity\n item.availability -= lineItem.quantity\n item.save\n @orders.push(order)\n @confirmed_items = @confirmed_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n NotifyUser.order_confirmation(user,@confirmed_items,@orders).deliver\n lineItem.destroy\n else\n redirect_to :back, :notice => \"Error creating order, verify your inputs or contact administrator with this message\"\n end\n else\n @unavailable_items = @unavailable_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n end\n end\n end\n end\n end\n #redirect_to :action => 'index', :controller => 'orders'\n else\n redirect_to :back, :notice => 'Unknown processing error. Please verify your orders' #TODO: Cart screen\n end\n end",
"def exists_in_country_list\n country_code.upcase!\n if !Map.is_country_code?(country_code)\n errors.add(:country_code, \"is not in the list of allowed countries\")\n end\n end",
"def affects?(country)\n (country.regions & restricted_regions).any?\n end",
"def check_for_eligible_of_free_shipping(order)\n if order > 100\n return true\n else\n return false\n end\nend",
"def available_for_country?(country)\n self.supplies_for_country(country).select{|s| s[:available]}.length > 0 and self.available?\n end",
"def valid_countries\n @valid_countries ||= countries.select do |iso2|\n @data[iso2][:valid].any?\n end\n end",
"def vat_number_expected?\n return false unless has_billing?\n billing_address.country != store.country\n end",
"def qualifies_for_free_shipping?\n \n # Adjust default shipping rate based on customer tag\n customer = Input.cart.customer\n \n if customer\n \n if customer.tags.include?(\"swell_vip_silver\")\n DEFAULT_MINIMUM = Money.new(cents: 100) * 75.00\n end\n \n if customer.tags.include?(\"swell_vip_gold\")\n DEFAULT_MINIMUM = Money.new(cents: 100) * 75.00\n end\n \n end\n \n # Determine if the order qualifies for free shipping...\n \n # Case: Cart total is greater than the default minimum\n if Input.cart.subtotal_price >= DEFAULT_MINIMUM\n HIDE_FREE_SHIPPING = false\n end\n \nend",
"def valid?\n return false if !@billing_city.nil? && @billing_city.to_s.length > 32\n return false if !@billing_company.nil? && @billing_company.to_s.length > 50\n return false if !@billing_country_code.nil? && @billing_country_code.to_s.length > 2\n return false if !@billing_day_phone.nil? && @billing_day_phone.to_s.length > 25\n return false if !@billing_evening_phone.nil? && @billing_evening_phone.to_s.length > 25\n return false if !@billing_first_name.nil? && @billing_first_name.to_s.length > 30\n return false if !@billing_last_name.nil? && @billing_last_name.to_s.length > 30\n return false if !@billing_postal_code.nil? && @billing_postal_code.to_s.length > 20\n return false if !@billing_state.nil? && @billing_state.to_s.length > 32\n return false if !@pricing_tier_name.nil? && @pricing_tier_name.to_s.length > 50\n return false if !@shipping_city.nil? && @shipping_city.to_s.length > 32\n return false if !@shipping_company.nil? && @shipping_company.to_s.length > 50\n return false if !@shipping_country_code.nil? && @shipping_country_code.to_s.length > 2\n return false if !@shipping_day_phone.nil? && @shipping_day_phone.to_s.length > 25\n return false if !@shipping_evening_phone.nil? && @shipping_evening_phone.to_s.length > 25\n return false if !@shipping_first_name.nil? && @shipping_first_name.to_s.length > 30\n return false if !@shipping_last_name.nil? && @shipping_last_name.to_s.length > 30\n return false if !@shipping_postal_code.nil? && @shipping_postal_code.to_s.length > 20\n return false if !@shipping_state.nil? && @shipping_state.to_s.length > 32\n true\n end",
"def update_zone_prices\n # Same country do not update prices\n return if get_user_country_id == object.ship_address.country.id \n # Update the order prices using the ship to country\n @order.update_zone_prices(object.ship_address.country.id)\n # Update selected country with ship to country\n session[:zone_pricing_country] = object.ship_address.country.id\n end",
"def confirm_checkout\n if !address_valid?\n flash[:error] = @address.errors.full_messages.first\n redirect_to shipping_path\n elsif !payment_valid?\n flash[:error] = @payment.errors.full_messages.first\n redirect_to payment_path\n elsif session[:shipping_method].blank?\n flash[:error] = 'Please select a shipping method'\n redirect_to payment_path\n else\n if login?\n user_checkout\n else\n guest_checkout\n end\n clear_private_info\n end\n end",
"def at_least_one_country\n errors.add :countries, \"Please select at least one country\" if countries.blank? || countries.reject(&:blank?).compact.empty?\n end",
"def valid_for_country?(country)\n country = country.to_s.upcase\n @data.select do |iso2, data|\n country == iso2 && data[:valid].any?\n end.any?\n end",
"def valid?\n country_code && country_code.size == 2 && city_code && city_code.size == 3\n end",
"def aramex_address_validation\n zones = Spree::ShippingMethod.where(['LOWER(admin_name) like ?', '%aramex%']).map(&:zones).flatten\n if zones.map(&:countries).flatten.map(&:iso).include?(country.iso)\n response = JSON.parse(validate_address(city, zipcode, country.iso))\n if response['HasErrors'] == true && errors[:zipcode].blank?\n if response['SuggestedAddresses'].present?\n errors.add(:base, response['Notifications'].map { |data| data['Message'] }.join(', ') + ', Suggested city name is - ' + response['SuggestedAddresses'].map { |data| data['City'] }.join(', '))\n else\n cities_response = JSON.parse(fetch_cities(country.iso, city[0..1]))\n errors.add(:base, cities_response['Notifications'].map { |data| data['Message'] }.join(', ') + ', Suggested city name is - ' + cities_response['Cities'].join(' ,'))\n end\n end\n end\n rescue\n return true\n end",
"def validate_country(country)\n return false if country.to_s.length == 0\n return false if !validate_residency(country)\n if(PRgovCAPWebApp::App.settings.country_codes.has_key? country)\n return true\n else\n return false\n end\n end",
"def checkout_allowed?\n order_items.count > 0\n end",
"def checkout_allowed?\n line_items.count > 0\n end",
"def eligible?(options = {})\n return unless order = options[:order]\n quantity_ordered = product.variants_including_master.inject(0) do |sum, v|\n sum + order.quantity_of(v)\n end\n quantity_ordered >= preferred_quantity\n end",
"def before_delivery\r\n return if params[:order].present?\r\n \r\n if @order.bill_address.address1 == 'dummy_address1' or @order.bill_address.city == 'dummy_city' or @order.bill_address.address2.include? \"CityBox\"\r\n @disable_all_except_citybox = true\r\n end\r\n\r\n packages = @order.shipments.map { |s| s.to_package }\r\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\r\n end",
"def ship_to_existing\n address = Address.find params[:id]\n unless address.customer_id.eql?(@customer.id)\n redirect_to :controller=>'cart', :action=>'shipping_address'\n return\n end\n\n @cart.shipping_address = address\n unless @cart.billing_address\n @cart.billing_address = address\n end\n @cart.save\n redirect_to build_url_options_for_checkout\n end",
"def shipped_from_country_code=(shipped_from_country_code)\n if !shipped_from_country_code.nil? && shipped_from_country_code.to_s.length > 3\n fail ArgumentError, 'invalid value for \"shipped_from_country_code\", the character length must be smaller than or equal to 3.'\n end\n\n if !shipped_from_country_code.nil? && shipped_from_country_code.to_s.length < 0\n fail ArgumentError, 'invalid value for \"shipped_from_country_code\", the character length must be great than or equal to 0.'\n end\n\n @shipped_from_country_code = shipped_from_country_code\n end",
"def enter_billship_address_plus_country(country, first_name, last_name, address1, city, state_province, zip_postal_code, phone_number)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n chkout_country_selector.value = country\n chkout_first_name_field.value = first_name\n chkout_last_name_field.value = last_name\n chkout_address_1_field.value = address1\n chkout_city_field.value = city\n chkout_select_state.value = state_province\n chkout_zip_code_field.value = zip_postal_code\n chkout_phone_number_field.value = phone_number\n end",
"def applicable?\n adjustment_source && adjustment_source.eligible?(order) && super\n end",
"def valid_delivery_option\n\n # Formats 'both' for checking\n if tool.delivery_options == 'Both'\n options = ['Delivery', 'Pickup']\n end\n\n # Checks the delivery option against tool delivery options\n if tool.delivery_options.include?(delivery_option) || options.include?(delivery_option)\n return true\n else\n # Failed validation error.\n errors.add(:delivery_option, 'is not available for this tool.')\n end\nend",
"def shipping (address)\n if address.include? (\"Mexico\")\n \"Order received\"\n else \n \"We only ship orders to Mexico\"\n end \nend",
"def package_level_delivery_confirmation?(shipment)\n origin, destination = shipment.origin.country.code, shipment.destination.country.code\n origin == destination || [['US', 'PR'], ['PR', 'US']].include?([origin, destination])\n end",
"def valid_for?(cart)\n minimum_order_value.nil? || minimum_order_value < cart.item_sum\n end",
"def needs_country_code?\n country_code.nil?\n end",
"def confirm!\n no_stock_of = self.order_items.select(&:validate_stock_levels)\n unless no_stock_of.empty?\n raise Shoppe::Errors::InsufficientStockToFulfil, :order => self, :out_of_stock_items => no_stock_of\n end\n \n run_callbacks :confirmation do\n # If we have successfully charged the card (i.e. no exception) we can go ahead and mark this\n # order as 'received' which means it can be accepted by staff.\n self.status = 'received'\n self.received_at = Time.now\n self.save!\n\n self.order_items.each(&:confirm!)\n\n # Send an email to the customer\n deliver_received_order_email\n end\n \n # We're all good.\n true\n end",
"def shipping_address_post\n params[:address][:country] = params[:address][:state].split(\"-\")[0]\n params[:address][:state] = params[:address][:state].split(\"-\")[1]\n @address = Address.new(params[:address])\n @address.customer = @customer\n if @address.save\n @cart.shipping_address = @address\n unless @cart.billing_address\n @cart.billing_address = @address\n end\n if @cart.save\n redirect_to build_url_options_for_checkout\n return\n end\n else\n flash[:error] = @address.errors.full_messages.join('<br/>')\n render :action => 'shipping_address'\n end\n end",
"def test_get_shipping_prices\n # Test a national shipping order.\n assert_same_elements @order.get_shipping_prices, OrderShippingType.get_domestic\n \n # Turn it into an international one and test.\n an_address = order_addresses(:santa_address)\n an_address.country = countries(:GB)\n an_address.save\n @order.reload\n assert_same_elements @order.get_shipping_prices, OrderShippingType.get_foreign\n \n # Now we say that we are in that same other country.\n prefs = {\n \"store_home_country\" => countries(:GB).id\n }\n assert Preference.save_settings(prefs)\n \n # And that same shipment should be national now.\n assert_same_elements @order.get_shipping_prices, OrderShippingType.get_domestic\n end",
"def shipping?\n true\n end",
"def ensure_CountryName\n\t\tif self.CountryName == \"\"\n\t\t\tself.CountryName = \"United States\"\n\t\tend\n\t\tif [\"AB\", \"BC\", \"MB\", \"NB\"].include?(self.State)\n\t\t\tself.CountryName = \"Canada\"\n\t\tend\n\tend",
"def ensure_CountryName\n\t\tif self.CountryName == \"\"\n\t\t\tself.CountryName = \"United States\"\n\t\tend\n\t\tif [\"AB\", \"BC\", \"MB\", \"NB\"].include?(self.State)\n\t\t\tself.CountryName = \"Canada\"\n\t\tend\n\tend",
"def avalara_eligible?\n if ship_address.present? and ship_address.state.present?\n SpreeAvalara.sales_tax_states.keys.include? ship_address.state.abbr\n else\n false\n end\n end",
"def address_selected?\n return unless address_line1.to_s.empty? || town.to_s.empty?\n\n errors.add(:postcode, :address_not_chosen)\n end",
"def has_shipping?\n return false unless customer_required?\n order_type.has_shipping?\n end",
"def validate_can_purchase\n\n return error_with_data(\n 'um_ea_1',\n 'Sale is not active',\n 'Sale is not active',\n GlobalConstant::ErrorAction.default,\n {}\n ) if !@client_token_sale_details.is_token_sale_live?\n\n return error_with_data(\n 'um_ea_2',\n 'Invalid action',\n 'Invalid action',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @client_token_sale_details.ethereum_deposit_address.blank?\n\n return error_with_data(\n 'um_ea_3',\n 'Unauthorized to purchase',\n 'Unauthorized to purchase',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @user_kyc_detail.blank? || !@user_kyc_detail.kyc_approved? ||\n (@client.is_whitelist_setup_done? && !@user_kyc_detail.done_whitelist_status?)\n\n success\n end",
"def purchase_order_required?\n if self.solution.purchase_order_required && self.purchase_order.blank?\n errors.add(:purchase_order_required, \"PROBLEM: A purchase order is required for solution #{self.solution.name}.\")\n end\n end",
"def validate_countries\n @validate_countries = ValidateLanding.validation_countries\n @validate_countries.each do |key,country|\n #find(:css,country,wait:10)\n # puts \"Se valido el link de #{key}\".cyan\n end\n end",
"def validate_order_approval\n units_beings_prepared = self.has_units_being_prepared\n if not units_beings_prepared.empty?\n errors[:order_status] << \"cannot be set to approved because units #{units_beings_prepared.map(&:id).join(', ')} are neither approved nor canceled\"\n end\n end",
"def confirm\n elements=CartItem.where(:cart_id=>current_user.cart.id)\n\n # if there are no items in the cart, the order will not be placed\n if elements.length==0\n redirect_to carts_path, :notice => \"EMPTY CART!!!\"\n end\n\n # Checks to see if any item in the cart is low in stock. If so, abort. If not, update the sales, and stock quantity of the items\n out_of_stock_items=Item.check_validity(elements)\n\n # This actually checks if any items are below stock\n if out_of_stock_items.length!=0\n redirect_to carts_path, :notice => Item.show_low_stock_message(out_of_stock_items)\n else\n # Save the changes in sales and stocks.\n Item.save_sales(elements)\n #after all the validations are processed, the pre-place order view will be rendered\n @item_list=CartItem.where(:cart_id => current_user.cart.id)\n end\n end",
"def can_request_purchase?\n true # TODO: Should this be !virginia_borrower? ?\n end",
"def may_purchase?(_company)\n false\n end",
"def addresses_set\n if @cart.shipping_address.nil?\n redirect_to :action=>'shipping_address'\n return false\n elsif @cart.billing_address.nil?\n redirect_to :action=>'billing_address'\n return false\n end\n end",
"def is_free_shipping\n end",
"def billing_address_post\n params[:address][:country] = params[:address][:state].split(\"-\")[0]\n params[:address][:state] = params[:address][:state].split(\"-\")[1]\n @address = Address.new(params[:address])\n @address.customer = @customer\n if @address.save\n @cart.billing_address = @address\n @cart.save\n redirect_to build_url_options_for_checkout\n return\n else\n flash[:error] = @address.errors.full_messages.join('<br/>')\n render :action => 'billing_address'\n end\n end",
"def ship\n count = 0\n if things_to_ship = params[:to_be_shipped]\n count = do_shipping(things_to_ship)\n if count > 0\n count_text = pluralize(count, \"order\")\n flash.now[:notice] = \"#{count_text} marked as shipped\"\n end\n end\n @pending_orders = Order.pending_shipping\n end",
"def validate_pricing(promocode, submitted_promocode = nil, cart = nil)\n nil\n end",
"def check_for_mixed_billing_mode(product)\n billing_modes = Set.new\n billing_modes << product.billing_mode\n @order.order_details.each { |od| billing_modes << od.product.billing_mode }\n\n if billing_modes.count > 1 && billing_modes.include?(\"Nonbillable\")\n raise NUCore::MixedBillingMode\n end\n end",
"def require_cart_to_have_items\n if shopping_cart.empty?\n redirect_to(cart_items_path, alert: 'Tu carrito está vacio, deberías agregar items a tu carrito antes.')\n end\n end",
"def accepts?(countries)\n return false if done?\n\n @possibles.any? do |ops_modifiers, count|\n all_ops_modifiers_qualify?(countries, ops_modifiers, count)\n end\n end",
"def mark_as_shipped\n @context.no_going_back\n\n list = @data.display_list\n update_from_form(list)\n\n list.each do |address_entry|\n address_entry.each_order do |order_info|\n next unless order_info.ship_order\n\n order = Order.with_id(order_info.order_id)\n\n if order\n order.mark_as_shipped\n else\n raise \"Missing order\"\n end\n\n end\n end\n @session.pop\n end",
"def requires_shipping\n requires = false\n self.order_line_items.each do |li|\n if li.variant.requires_shipping\n requires = true\n break\n end\n end\n return requires\n end",
"def apply\n assign_order_attributes\n assign_payments_attributes\n\n if order.save\n order.set_shipments_cost if order.shipments.any?\n true\n else\n @errors = order.errors\n false\n end\n end",
"def disallow_if_accepted_proposal\n if listing.accepted_proposal and listing.accepted_proposal.id == id\n errors.add(:base, \"You can't remove an accepted proposal.\") \n end\n\n #if blank, return true, and therefore allow destruction\n errors.blank? \n end",
"def shippable?\n status != \"shipped\" && products.count >= 1\n end",
"def check_current_billing_in_use\n if Billing.current.where(:member_id => member_id).present? \n errors.add(:base, 'Tidak Dapat Membuat Billing Baru Jika Ada Billing Sebelumnya Yang Belum Di Tutup') \n end \n end",
"def in_zone?(order)\n # shipping address is in promotional zones?\n if self.zone\n order.shipment && order.ship_address && self.zone.include?(order.ship_address)\n else\n true\n end\n end",
"def shippable?\n can_supply? && !(on_hold? || collection?)\n end",
"def shipped?\n ! ship_date.blank?\n end",
"def check_total_shipped\n total_shipped = self.other_receivable_shipments.sum(:receivable_shipment_count) + self.receivable_shipment_count.to_f\n if total_shipped > self.so_line.so_line_shipped\n errors.add(:receivable_shipment_count, \"exceeded than total shipped!\")\n end\n end",
"def save\n \tself.errors = [\"Shipping Addresses are readonly\"]\n \treturn false\n end",
"def save\n \tself.errors = [\"Shipping Addresses are readonly\"]\n \treturn false\n end",
"def not_paid_at_all\n\t\tget_cart_pending_balance == get_cart_price\n\tend",
"def cart_not_empty\n if @cart.line_items.length <= 0\n redirect_to :controller=>'cart', :action=>'show'\n return false\n end\n end",
"def taxes_valid?\n errors.add(:taxes, :one_must_be_chosen) if taxes.compact_blank.size != 1\n end",
"def valid_non_transportation_line_item\n lb_return = true\n if non_ts_service == \"Y\"\n if service_date.blank?\n errors.add(:service_date, \"is required.\")\n lb_return = false\n end\n\n if actual_cost.blank?\n errors.add(:actual_cost, \"is required.\")\n lb_return = false\n end\n end\n return lb_return\n end",
"def test_should_checkout_with_unavailable_products\n # Add full quantity of an item to the cart.\n @product = items(:towel)\n xhr(:post, :add_to_cart_ajax, :id => @product.id, :quantity => @product.quantity)\n assert_response :success\n assert_equal 1, assigns(:order).items.length\n\n # Emulate another customer purchasing items before we checkout\n @product.update_attribute(:quantity, 1)\n\n get :checkout\n assert_response :success\n assert_template 'checkout'\n assert_equal \"Please enter your information to continue this purchase.\", assigns(:title)\n assert_not_nil assigns(:cc_processor)\n \n # Post to it an order.\n post :checkout,\n :order_account => {\n :cc_number => \"4007000000027\",\n :expiration_year => 4.years.from_now.year,\n :expiration_month => \"1\"\n },\n :shipping_address => {\n :city => \"\",\n :zip => \"\",\n :country_id => countries(:US).id,\n :first_name => \"\",\n :telephone => \"\",\n :last_name => \"\",\n :address => \"\",\n :state => \"\"\n },\n :billing_address => @scrooge_address.attributes,\n :order_user => {\n :email_address => \"uncle.scrooge@whoknowswhere.com\"\n }\n \n assert_redirected_to :action => :index\n assert flash[:notice].include?(\"have gone out of stock before you could purchase them\")\n end",
"def card_issuing_country\r\n params['cardIssuingCountry']\r\n end",
"def ensure_cart_isnt_empty\n if @cart.line_items.empty?\n redirect_to store_index_url, notice: 'Cart is empty'\n end\n end",
"def mark_stuff_shipped(values)\n values['address_list'] = @data.display_list.map do |address|\n address.add_to_hash({})\n end\n\n values['update_url'] = url(:mark_as_shipped)\n standard_page(\"Confirm Shipping\", values, CONFIRM_SHIPPING)\n end",
"def validate_custom_make\n employee = Employee.current\n country_id =\n if employee.present? && employee.operating_country_id.present?\n employee.operating_country_id\n elsif self.facility.present?\n self.facility.country_id\n else\n nil\n end\n country = Country.find(country_id) if country_id.present?\n if self.custom_make_enabled? && self.custom_make.present?\n # Add errors if make is already available for current country\n if country.present? && country.makes.where(\"LOWER(name) = ?\", self.custom_make.strip.downcase).present? && self.vehicle_type.makes.where(\"LOWER(name) = ?\", self.custom_make.strip.downcase).present?\n self.errors.add(:custom_make, I18n.t(\"activerecord.errors.models.vehicle.attributes.custom_make_exists\"))\n end\n end\n end",
"def applicable?\n mandatory || amount != 0\n end",
"def validate_inventory()\n validated = true\n line_item_total = 0\n line_item_hash = Hash.new \n self.line_items.each do |line_item|\n line_item_hash[line_item.variant_id] = line_item.quantity\n line_item_total += line_item.quantity\n end\n \n \n inventory_total = 0\n inventory_hash = Hash.new \n self.inventory_units.each do |unit|\n inventory_total += 1\n if inventory_hash.has_key?(unit.variant_id)\n inventory_hash[unit.variant_id] += 1\n else\n inventory_hash[unit.variant_id] = 1\n end \n end\n \n validated = false if (inventory_total != line_item_total)\n self.line_items.each do |line_item|\n validated = false if line_item_hash[line_item.variant_id] != inventory_hash[line_item.variant_id]\n break if !validated \n end\n \n raise \"inventory_units not matched with line item: \" + self.number if !validated\n\n\n shipping_events_total = 0\n shipping_events_hash = Hash.new\n self.shipments.first.shipping_events.each do |se|\n se.inventory_units.each do |unit|\n # puts se.id.to_s + \"#\" + unit.id.to_s\n # puts se.shipped_at\n # puts unit.state \n shipping_events_total += 1\n if se.is_shipped?\n validated = false if unit.state != 'returned' && unit.state != 'shipped' \n else\n validated = false if unit.state == 'shipped'\n end\n \n \n break if !validated \n end\n end\n \n \n raise \"inventory_units state not matched with shipping events: \" + self.number if !validated\n \n validated = false if (inventory_total != shipping_events_total)\n # puts inventory_total\n # puts shipping_events_total\n raise \"inventory_units total not matched with shipping events: \" + self.number if !validated\n \n return validated \n \n end",
"def free?\n cost == 0.0 || payment_not_required\n end",
"def valid_country?(move)\n country = original_countries.find(move.instruction.country_name)\n neighbors = country.neighbors.lazy.map { |n| original_countries.find(n) }\n\n return true if country.presence?(player)\n return true if country.adjacent_superpower?(player)\n return true if neighbors.any? { |n| n.presence?(player) }\n return false\n end",
"def filter_country_ok?(cert)\n return true if (!@countries_include && !@countries_exclude)\n\n country = cert_country(cert)\n\n if @countries_exclude && @countries_exclude.include?(country)\n return false\n end\n\n if @countries_include && !@countries_include.include?(country)\n return false\n end\n\n return true\n end",
"def validate_product_quantity_in_stock\n init_order_and_order_item\n session[:cart].values.each do |item|\n product = Product.find_by id: item[\"product_id\"].to_i\n next if conditional_checking(product, item)\n @order.errors.add(:unit_in_stock, add_flash_danger(product))\n end\n return if @order.errors.blank?\n render :new\n end",
"def included_in_cost\n false\n end",
"def saved_cart\n if @cart.new_record? and !@cart.save\n redirect_to :action=>'shipping_address'\n end\n end",
"def address_change\n @update_cart_invoice = zip_code_changed?\n true\n end",
"def confirm_shipping_country_label\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.span.id(create_ats_regex_string(\"ShippingAddressCountryLabel\")), format_method(__method__))\n end",
"def confirm_options\n # Postals are the easiest to find\n # Whatever is after is probably the country!\n # Whatever is before is probaby city/state\n confirm_postal\n\n # Must confirm state first\n # Because it's easier than country to detect\n # When no postal is present\n confirm_state\n confirm_country\n\n # Street number is probably the next easiest thing to find\n confirm_street_number\n confirm_street_label\n confirm_street_direction\n\n confirm_unit\n # name is between number && (label || direction)\n confirm_street_name\n # city is between (label || direction || name) && (state || postal)\n confirm_city\n end",
"def correct(country)\n MAPPING_FIX[country] || country\n end",
"def deliver\n \n \n params[:order][:actual_cost] = (params[:order][:actual_cost].to_f * 100.00).floor rescue nil \n #params[:order][:approx_cost] = (params[:order][:approx_cost].to_f * 100.00).floor rescue nil \n \n @order.approx_cost = (@order.approx_cost.to_f * 100.0).floor\n \n @upper_amount_in_cents = (@order.approx_cost.to_f * 1.35)\n \n #here is where you should \n if params[:order][:actual_cost].present? && params[:order][:receipt_image].present? && @upper_amount_in_cents >= params[:order][:actual_cost] && @order.update_attributes(params[:order]) && @order.deliver \n render 'status'\n else\n respond_to do |format|\n format.js\n end \n \n end\n \n end"
] | [
"0.6430206",
"0.63863885",
"0.6351647",
"0.61710215",
"0.6063709",
"0.6032792",
"0.601626",
"0.6011317",
"0.60096824",
"0.59700227",
"0.59072745",
"0.5896389",
"0.5879385",
"0.58095425",
"0.5784177",
"0.5767197",
"0.57669985",
"0.57496136",
"0.5741747",
"0.57321084",
"0.57046276",
"0.56942147",
"0.5673318",
"0.56710005",
"0.56677264",
"0.566678",
"0.56080616",
"0.56013864",
"0.5585771",
"0.556653",
"0.55054724",
"0.54803175",
"0.54800797",
"0.54609334",
"0.5454123",
"0.5453837",
"0.54457784",
"0.54367024",
"0.5419551",
"0.540777",
"0.5390581",
"0.53877014",
"0.53717333",
"0.5369338",
"0.53403777",
"0.5337354",
"0.5323841",
"0.5323841",
"0.5317949",
"0.5312604",
"0.52872765",
"0.5278486",
"0.5277249",
"0.52704054",
"0.5258535",
"0.52571845",
"0.52567726",
"0.52545595",
"0.5251558",
"0.5239866",
"0.5224304",
"0.5220552",
"0.5211218",
"0.5209433",
"0.5207993",
"0.51706564",
"0.5169762",
"0.5165621",
"0.5164845",
"0.5158253",
"0.51568836",
"0.5154594",
"0.5152127",
"0.5145262",
"0.5137434",
"0.51333934",
"0.5122441",
"0.51204866",
"0.5115462",
"0.5115342",
"0.5114243",
"0.5110373",
"0.5107895",
"0.51058215",
"0.51023394",
"0.5096988",
"0.5083984",
"0.50813293",
"0.50796556",
"0.5068631",
"0.5064687",
"0.5062969",
"0.5061496",
"0.50470006",
"0.5046633",
"0.5042106",
"0.5037401",
"0.50216997",
"0.5018408",
"0.50155497"
] | 0.709786 | 0 |
Order management Generates an order from the current cart state and stores its id in the cart to be fetched back later | def generate_order
clean_order!
attrs = attributes(:json).reject do |key, _|
[:adjustments, :state, :order_id, :shipping_method_id].include?(key)
end
%w(billing shipping).each do |addr|
attrs[:"#{ addr }_address_attributes"] =
attrs.delete(:"#{ addr }_address")
end
unless use_another_address_for_shipping
attrs[:shipping_address_attributes] =
attrs[:billing_address_attributes]
end
# Append shipping method id after addresses so the latters are present
# when shipping adjustment is processed on order
attrs[:shipping_method_id] = shipping_method_id
attrs[:discount_code] = discount_code
self.order = Glysellin::Order.create!(attrs)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @order = Order.new(params[:order])\n @order.user_id = current_user.id\n @order.add_line_items_from_cart(current_cart)\n #logger.debug \"New order: #{@order.attributes.inspect}\"\n #logger.debug \"Order should be valid: #{@order.valid?}\"\n\n respond_to do |format|\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to(store_url, :notice =>\n 'Thank you for your order.') }\n format.xml { render :xml => @order, :status => :created,\n :location => @order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def create\n params = order_params.merge(cart_items: @cart.cart_items)\n @order = Order.new(params)\n\n respond_to do |format|\n if @order.save\n session[:order] = @order.id\n @cart.destroy\n format.html { redirect_to active_order_path, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render 'carts/show' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_order\n @cart = current_cart\n @order = Order.find(params[:id])\n @orders = Order.where(\"cart_id=? AND id<>?\", @cart.id, params[:id])\n end",
"def create\n @order = current_user.orders.new(params[:order])\n @order.add_line_items_from_cart(current_cart)\n respond_to do |format|\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to(\"http://cs410.cs.ualberta.ca:42001/paybuddy/payment.cgi?grp=5&amt=#{@order.total_price}&tx=#{@order.id}&ret=#{paid_url}\") }\n format.json { render json: @order, status: :created, location: @order }\n else\n @cart = current_cart\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n cart = Cart.find_by(user_id: @current_user.id)\n order = Order.new(user_id: @current_user.id,\n date: DateTime.now,\n delivery_address: @current_user.role == \"user\" ? @current_user.addresses.find_by(delivery_address: true).address : \"Walk-in-customer\",\n is_cancel: false,\n total_amount: cart.cart_items.sum(:temp_price))\n if (order.save!)\n cart.cart_items.all.each do |cart_item|\n OrderItem.create!(\n order_id: order.id,\n menu_item_id: cart_item.menu_item_id,\n menu_item_name: cart_item.menu_item_name,\n menu_item_price: cart_item.menu_item_price,\n quantity: cart_item.quantity,\n )\n end\n cart.cart_items.destroy_all\n end\n redirect_to customer_order_details_path(order.id)\n end",
"def create\n @order = Order.new(order_params)\n @cart = Cart.find(@order.cart_id)\n\n # @store_products = StoreProduct.all\n # @products = Product.all\n #\n # @store_product = StoreProduct.find(params[:store_product_id])\n # @product = Product.find(params[:product_id])\n #\n # @order.product_id = @product.id\n # @order.store_product_id = @store_product.id\n\n @order.store_product_id = @cart.line_items { |item| item.store_product.store_product_id}\n\n # respond_to do |format|\n if @order.save\n\n session[:cart_id] = nil\n\n # @cart.destroy\n # format.html { redirect_to @order, notice: 'Order was successfully created.' }\n # format.json { render :show, status: :created, location: @order }\n redirect_to '/'\n flash[:notice] = \"Order was successfully created.\"\n\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n # end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.add_line_items_from_cart(current_cart)\n @order.user_id = session[:user_id]\n\n respond_to do |format|\n if @order.save\n destroy_cart\n OrderNotifier.received(@order).deliver\n format.html { redirect_to store_url, notice: I18n.t('.thanks') }\n format.json { render action: @order, status: :created, location: @order }\n else\n @cart = current_cart\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\n #Create new order object associated to the user\n order=current_user.orders.build\n order.save\n\n cart_items=current_user.cart.cart_items.all\n\n cart_items.each do |cart_item|\n item=Item.find(cart_item.item_id)\n\n #Create immutable object \"OrderItem\" that holds everything about the item.\n order_items=OrderItem.new(item.name,item.price,cart_item.quantity,item.keeper_id,item.id,order.id)\n order_items.save\n end\n\n #Clear cart after placing an order\n current_user.cart.clear_cart\n\n end",
"def create\n @cart = current_cart\n @product = Product.find(params[:id])\n @order_item = @cart.order_items.build\n @order_item.product_id = @product.id\n #@order_item = OrderItem.create!(:cart => current_cart, :product => @product, :qty_ordered => params[:qty_ordered], :qty_ordered_price => @product.price)\n #@order_item = OrderItem.find_or_initialize_by_cart_id(:cart_id => current_cart.id, :cart => current_cart, :product => @product, :qty_ordered => params[:qty_ordered], :qty_ordered_price => @product.price)\n # @order_item = OrderItem.new\n # @order_item.cart_id = current_cart.id\n # @order_item.product_id = @product.id\n @order_item.qty_ordered = params[:qty]\n @order_item.qty_ordered_price = @product.price\n @order_item.save\n flash[:notice] = \"Added #{@product.name} to cart.\"\n redirect_to current_cart_url\n\n # @order = current_order\n # product = Product.find(params[:product_id])\n # # @order_item = OrderItem.new(params[:order_item]) Ian's line\n # @order_item = @order.add_product(product.id)\n \n # if Order.last == nil\n # @order_item.order_id = 1\n # else @order_item.order_id = Order.last.id + 1\n # end\n # @order_item.qty_ordered_price = @order_item.product.price\n\n # respond_to do |format|\n # if @order_item.save\n # format.html { redirect_to @order_item.order, notice: 'Order item was successfully created.' }\n # format.json { render json: @order_item, status: :created, location: @order_item }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @order_item.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @order = Order.new(:user => current_user)\n respond_to do |format|\n if @order.save\n session[:payment_method] = nil\n @cart = current_user.cart\n Cache.put 'user_' + current_user.id.to_s + '_cart', @cart\n @cart_products = @cart.cart_products\n Cache.put 'cart_' + @cart.id.to_s, @cart_products\n format.html { redirect_to(@order, :notice => 'Order was successfully processed.') }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n else\n format.html { flash[:notice] = \"Sorry, we experienced a problem. Please try again.\" \n redirect_to(:controller => :checkout, :action => \"new\") }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_new_cart_upon_submit()\n new_order = Order.create()\n return new_order\n end",
"def create\n @cart = current_cart\n @usr = current_user\n @order = @usr.orders.new(order_params)\n @order.add_line_items_from_cart(current_cart)\n respond_to do |format|\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n\n Notifier.order_received(@order).deliver\n\n format.html { redirect_to(store_url, :notice => 'Thank you for your order.' ) }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors,:status => :unprocessable_entity }\n end\n end\n end",
"def process_cart_items()\n \torder = self.customer.orders.create\n \tself.cart_items.each do |item|\n \t\torder.order_items.create :product_id => item.product_id\n \tend\n \tself.cart_items = [] #clear the cart\n \treturn order\n end",
"def create\n @order = Order.new(order_params)\n @order.add_line_items_from_cart(@cart)\n\n respond_to do |format|\n if @order.save \n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to store_index_url, notice: 'Thank you come again!'}\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if order_params[:status] == \"completed\"\n @current_order.update_order(session[:order], order_params)\n if @current_order.save_order(current_user)\n session[:order] = {}\n session[:cart] = {}\n # delete user current cart record\n current_user.current_cart.destroy\n flash[:success] = \"Your order has been successfully placed.\"\n redirect_to root_path\n else\n flash[:error] = \"An error occured while saving your order. Please try again.\"\n redirect_to cart_checkout_path\n end\n end\n end",
"def create\n @order = current_user.orders.build(:order_date => DateTime.now, :status => 'Pending')\n\n respond_to do |format|\n if @order.save\n @cart.line_items.each do |line_item| \n\n @orderitem = @order.order_items.create!(\n record_id: line_item.record_id,\n quantity: line_item.quantity,\n title: line_item.record.title,\n artist: line_item.record.artist,\n price: line_item.record.price,\n year: line_item.record.year,\n )\n end\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def checkout\n #@carts.each do |c|\n @order = Order.new\n @order.item_ordered = params[:itemid]\n @order.user_id = params[:user_id] \n @order.orderdate = Datetime.now\n @order.save\n #end\n end",
"def create\n #@order = Order.new(params[:order])\n\n cart = session[:cart]\n\n @order.add_line_items_to_order_from_cart(cart)\n\n @order.user = current_user\n\n respond_to do |format|\n if @order.save\n #Send an email to admin\n UserMailer.order_created_to_admin(@order).deliver\n #empty cart\n session.delete(:cart)\n \n format.html { redirect_to :dashboard, notice: \"L'ordine è stato creato correttamente.\" }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new\n @order.add_line_items_from_cart(@cart)\n\n respond_to do |format|\n if @order.save\n session[:cart_id] = nil\n OrderNotifier.received(@order).deliver\n redirect_to preorder_confirmation_path\n=begin\n format.html { redirect_to root_path, notice: 'Thank you for your order.' }\n format.json { render action: 'show', status: :created, location: @order }\n=end\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @total = 0\n current_cart.lineitems.each{|line|\n @total = AddService.call(@total.to_i, line.product.price * line.quantity)\n }\n @order.add_lineitem_from_cart(current_cart)\n @order.customer_id = @current_customer.id\n @order.total = @total\n #Use of logger class to log messages into the log file\n Logger.instance.log(Time.now.to_s + \": Order created by user \\n\")\n\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n flash[:success] = 'Thank You for your order.'\n redirect_to root_path\n else\n @cart = current_cart\n render 'new'\n end\n end",
"def create\n\t\t@customer = current_customer\n @order = Order.new(params[:order].merge!({:customer_id => @customer.id}))\n\t\t@order.add_line_items_from_cart(current_cart)\n\t\n respond_to do |format|\n if @order.save\n\t\t\t\tCart.destroy(session[:cart_id])\n\t\t\t\tsession[:cart_id] = nil\n\t\t\t\tNotifier.order_received(@order).deliver\n format.html { redirect_to(store_url, :notice => I18n.t('.thanks')) }\n format.xml { render :xml => @order, :status => :created, :location => @order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def build\n my_order = nil\n if cart = user && user.cart\n Order.transaction do\n my_order = Order.create(user: user)\n my_order.products = cart.products\n cart.destroy\n end\n else\n error = Struct.new(:full_messages).new\n error.full_messages = [\"No cart to create order from\"]\n @errors = error\n end\n my_order\n end",
"def create\n @user = User.find(session[:user_id])\n @order = Order.new(params[:order])\n @order[:User_order] = @user[:id]\n @order.add_line_items_from_cart(current_cart)\n if @order.save\n UserMailer.order_confirmation(@order).deliver\n UserMailer.order_admin(@order).deliver\n render \"_good\"\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.user_id = current_user.id if @order.user_id == 0\n @order.price = @order.product.price\n another_order = current_user.orders.in_cart.where(product_id: @order.product_id).first\n logger.debug(\"----------------#{@order.price}..........\")\n if another_order\n another_order.quantity += @order.quantity\n another_order.price += (@order.quantity*@order.price)\n logger.debug(\"----------------#{@order.price}..........\")\n @order = another_order\n end\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: t('Order was successfully created') }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n\n # delivery_price get from session, not from hidden input\n @order.delivery_price = session[:delivery_price]\n @order.total_price = @cart.total_price\n @order.status = 0\n @user = current_user\n\n respond_to do |format|\n if @order.save\n # delete session data\n clear_delivery_session\n @user.orders << @order\n @order.add_item_from_cart(@cart)\n format.html { redirect_to private_office_path, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n order = Order.find_by(id: session[:order_id])\n \n if session[:order_id].nil? || order.nil?\n order = Order.create\n session[:order_id] = order.id\n end\n \n order_items = {\n product_id: params[:product_id].to_i,\n quantity: params[:quantity].to_i,\n order_id: session[:order_id],\n }\n \n order = Order.find(session[:order_id])\n # if order item already exists in cart, increase quantity.\n order.order_items.each do |oi|\n if oi.product.id == order_items[:product_id]\n if oi.quantity + order_items[:quantity] > oi.product.stock\n flash[:failure] = \"Sorry, there are not enough items in stock.\"\n redirect_to product_path(order_items[:product_id])\n return\n else\n oi.quantity += order_items[:quantity]\n oi.save\n \n flash[:success] = \"Successfully updated quantity.\"\n redirect_to product_path(order_items[:product_id])\n return\n end\n end\n end\n \n order_item = OrderItem.new(order_items)\n if order_item.save\n flash[:success] = \"Successfully added item to your cart.\"\n redirect_to product_path(order_items[:product_id])\n return\n else\n flash[:failure] = \"Item could not be added to your cart.\"\n redirect_to product_path(order_items[:product_id])\n return\n end\nend",
"def create\n @order = current_cart.build_order(params[:order])\n @order.ip_address = request.remote_ip\n if @order.save\n if @order.purchase\n #transaction was successfull. Now we can update our required database table\n @order.cart.cart_items.each do |cart_item|\n job = Job.find(cart_item.job_id)\n job.update_attributes(:total_paid_amount => cart_item.unit_price * cart_item.quantity, :status => 1)\n end\n flash[:notice] = \"Transaction was successfull.\"\n redirect_to user_jobs_list_by_status_url(current_user.id,\"open\")\n else\n flash[:notice] = \"#{@order.transactions.last.message}. Please check your credit card or paypal account and insert your information carefully. You can contact us at anytime for support.\"\n render :action => 'new'\n # render :text => \"#{@order.transactions.last.message}\"\n end\n else\n render :action => 'new'\n end\n end",
"def convert_to_order\n @order = self.wholesale_profile.orders.create(status: :draft)\n self.cart_items.each do |ci|\n pv = ProductVariant.find(ci.product_variant_id)\n @order.order_items.create(product_variant_id: pv.id, quantity: ci.quantity, line_item_total: (ci.quantity * pv.price_in_cents))\n end\n @invoice = @order.create_invoice\n if @order.update(status: :processing)\n self.cart_items.destroy_all\n end\n return @order\n end",
"def create\n @order = Order.new(order_params)\n @order.cart = @cart\n OrderMailer.demandelocation(Order.first).deliver_now\n\n\n respond_to do |format|\n if @order.save\n session.delete(:cart_id)\n format.html { redirect_to order_validations_path}\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = current_cart\n if @cart.items_in_cart.empty?\n redirect_to store_url, notice: \"Your cart is empty\"\n return\n end\n\n @order = Order.new(params[:order])\n # which user was involved\n @order.user = current_user.id\n # add every item from the cart to this order\n @order.add_items_from_cart(current_cart)\n # withdraw money from user\n current_user.pay(@order)\n # remember new balance\n new_balance = current_user.balance\n #logout user\n current_user_session.destroy\n #increase cleaning counter\n coffee_count = Settings.coffees_since_last_clean_up.to_i\n Settings.coffees_since_last_clean_up = coffee_count + @order.coffees_in_order\n\n respond_to do |format|\n if @order.save && current_user.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to invoice_path(id: @order.id, balance: new_balance) }\n format.json { render json: @order, status: :created, location: @order }\n else\n @cart = current_cart\n format.html { redirect_to store_url, notice: 'Could not save order!' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_order\n @order = ShopOrder.find(params[:id])\n end",
"def create\n @shopping_order = ShoppingOrder.new(shopping_order_params)\n @shopping_order.add_lineitems_from_cart(current_cart) \n @shopping_order.customer_id = current_user.id\n @shopping_order.currentStatus = \"Submited\"\n\n\n respond_to do |format|\n if @shopping_order.save\n \n @packing_job=createAPackingJob(@shopping_order.id)\n @shipping_job=createAshippingManifest(@shopping_order.id)\n @message = \"New order created\"\n @adminnoti=createAdminNotification(@shopping_order.id, @message)\n \n\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to root_path, notice: 'Thank you for your order' }\n UserMailer.created_order_email(current_user).deliver\n format.json { render :show, status: :created, location: @shopping_order }\n else\n @cart = current_cart\n format.html { render :new }\n format.json { render json: @shopping_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if current_user\n @carted_products = CartedProduct.where(status: \"Carted\", user_id: current_user.id)\n\n @subtotal = 0\n @tax = 0\n @total = 0\n @carted_products.each do |carted_product|\n @subtotal += carted_product.product.price * carted_product.quantity\n end\n \n @tax = @subtotal * SALES_TAX\n @total = @subtotal + @tax\n\n # quantity = carted_products.quantity\n # price = Product.find_by(id: params[:product_id]).price\n # subtotal = quantity * price\n # tax = subtotal * 0.09\n # total = subtotal + tax\n\n order = Order.create(user_id: current_user.id, subtotal: @subtotal, tax: @tax, total_price: @total) \n\n @carted_products.each do |carted_product|\n carted_product.update(status: \"Purchased\", order_id: order.id)\n end\n\n end\n redirect_to \"/orders/#{order.id}\"\n end",
"def create\n @order, @errors = Order.create_from_cart(@cart, order_params)\n\n if @order\n render json: @order, status: :created, location: @order\n else\n render json: @errors, status: :unprocessable_entity\n end\n end",
"def create_order_id\n self.order_id = \"GO%.5d\" % self.id\n self.save\n end",
"def build_order\n @order ||= ManagementCenter::Order.new\n end",
"def create\n @cart= Cart.find(params[:invoice]);\n @order = Order.new\n @order.OrderDate= Time.now\n @order.member_id=@cart.member_id\n @order.add_line_items_from_cart(@cart)\n respond_to do |format|\n if @order.save\n Cart.destroy(@cart.id)\n session[:cart] = nil\n format.html { redirect_to store_index_url notice: 'Gracias por su orden.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_order\n @order = Order.new(params[:order]) \n @order.line_items << @cart.items \n if @order.save \n @cart.empty!\n redirect_to_index('Thank you for your order.')\n else\n render(:action => 'checkout') \n end\n end",
"def set_order\n @order = current_order\n\n if @order.new_record?\n @order.save!\n session[:order_id] = @order.id\n end\n end",
"def create\n @order = Order.new(params[:order])\n @order.add_line_items_from_cart(current_cart)\n\n respond_to do |format|\n if @order.save\n destroy_cart\n OrderNotifier.received(@order).deliver\n format.html { redirect_to store_path, notice: 'ご注文ありがとうございます' }\n format.json { render json: @order, status: :created, location: @order }\n else\n @cart = current_cart\n format.html { @disabled = true; render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_order(order)\n build_persisted_order(\n post('/market/orders', order.symbolize_keys.merge(side: SIDES_MAP.fetch(order.fetch(:side))))\n )\n end",
"def set_order\n @order = Order.find(params[:id])\n OrderStateMgr.instance(self).set_curr_state(@order)\n end",
"def create\n\n @order = Order.new(order_params)\n @shopping_cart = ShoppingCart.find(params[:shopping_cart_id])\n @order.shopping_cart_id = @shopping_cart.id\n @order.fulfilled = false\n @order.in_transit = false\n\n if(user_signed_in?)\n @order.user_id = current_user.id\n else\n @order.user_id = -1\n end\n\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n begin\n charge = Stripe::Charge.create(\n :amount => (@shopping_cart.total * 100).floor,\n :currency => \"eur\",\n :card => token\n )\n flash[:notice] = \"We're on our way!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n\n session[:shopping_cart_id] = ShoppingCart.new.id\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to root_url}\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_order\n @my_order = Order.find(params[:id])\n end",
"def create\n @order = Order.new(order_params)\n @order.add_line_items_from_cart(@cart)\n respond_to do |format| if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n #send email\n OrderNotifier.notify_admin(@order).deliver\n OrderNotifier.received(@order).deliver\n format.html { redirect_to '/order_submitted', notice: %Q[Your order was successfully created. Thank You for choosing Americo! We will send you an email when your order is ready to ship.<p>Don't forget to join our Mailing List for special offers and periodic newsletters. <a target=\"new\" href=\"http://visitor.r20.constantcontact.com/d.jsp?llr=j4rb9sqab&p=oi&m=1117322790889&sit=8wpamrxib&f=7e954c51-d956-4ceb-b3be-2a8cf6773713\" class=\"button btn btn-success\" style=\"color: rgb(255, 255, 255); text-shadow: none; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; display:inline-block; vertical-align: middle;\">Join our Mailing List here.</a>].html_safe }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = current_order\n # if there already is an order_item with that product_id, then just update the quantity of the order_item\n # if product_in_cart?, redirect to the edit method\n unless product_in_cart?\n @item = @order.order_items.new(item_params)\n @item.save\n @order.save\n session[:order_id] = @order.id\n redirect_to cart_path\n else\n edit\n end\n end",
"def create\n unless logged_in?\n session[:checking_out] = true\n redirect_to login_path, notice: t('orders.must_log_in') # \"You must log in before placing an order.\"\n else\n @order = current_user.orders.new(order_params)\n @order.earliest_pickup_date = calculate_earliest_pickup_date(:create)\n # User could have place product in cart days ago, make sure still available\n okay = true\n index = (session[:shopping_cart].size - 1)\n while (index >= 0)\n element = session[:shopping_cart][index]\n product = Product.find(element[:product_id])\n quantity = element[:quantity]\n if (product.quantity_in_stock == 0)\n okay = false if (okay)\n session[:shopping_cart].delete_at(index)\n # If cart empty as a result of the deletion, redirect user to product index\n redirect_to(products_path, notice: t('orders.not_in_stock')) and return if session[:shopping_cart].empty? # \"The product(s) ordered are no longer in stock; order cannot be placed.\"\n elsif (product.quantity_in_stock < quantity)\n okay = false if (okay)\n # Update quantity in shopping cart based on quantity available\n new_product_hash = { product_id: product.id, quantity: product.quantity_in_stock }\n session[:shopping_cart][index] = new_product_hash\n end\n index -= 1\n end\n redirect_to(new_order_path, notice: t('orders.please_review')) and return if (!okay) # \"One or more of the products you selected is either out of stock or not available in the desired quantity. Please review the updated order and resubmit if okay.\"\n # Proceed to save order\n respond_to do |format|\n if @order.save\n @order.update_attributes(order_date: Date.today, order_status_id: 1) # set order date to today, status to New\n session[:shopping_cart].each do |element| # create an order_product record for each product in the shopping cart and update quantity in stock of products\n product = Product.find(element[:product_id])\n quantity = element[:quantity]\n @order.order_products.create(product_id: product.id, quantity: quantity)\n new_quantity_in_stock = (product.quantity_in_stock - quantity)\n product.update_attributes(quantity_in_stock: new_quantity_in_stock)\n end\n session[:shopping_cart].clear\n format.html { redirect_to root_path, notice: t('orders.create') } # \"Your order was successfully submitted!\"\n format.json { render action: 'index', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def execute\n guest.cart.order_items.create product: product\n end",
"def create\n @book_order = BookOrder.new(new_book_order_params)\n @book_order.cart = @cart\n @book_order.user = @current_user\n # @book_order.decrease_q\n @book_order.add_lineitems(@cart)\n if @book_order.save\n session.delete(:cart_id)\n redirect_to root_path, notice: 'Заказ оформлен.'\n else\n render :new\n end\n end",
"def set_order\n @order = Product::Order.find(params[:id])\n end",
"def set_order\n @order = Product::Order.find(params[:id])\n end",
"def new\n @order = OrderFinder.new(order_id: session[:order_id], cart: @cart).retrieve\n find_addresses\n if @order.line_items.any?\n session[:order_id] = @order.id\n else\n redirect_to store_path, notice: \"No items in your cart!\"\n end\n end",
"def create\n @order = Order.new(order_params)\n @cart.line_items.each do |i|\n qty = i.quantity\n product = Product.find(i.product_id)\n product.quantity_update(product, qty)\n end\n @order.add_line_items_from_cart(@cart)\n if user_signed_in?\n @order.user_id = current_user.id\n end\n \n respond_to do |format|\n \n # Dynamically update Products quantity (same as in ProdController)\n # dynamically_update_products\n \n if @order.save && @order.pay_type == \"Karta kredytowa\"\n format.html { redirect_to new_charge_url }\n format.json { render :show, status: :created, location: @order }\n elsif @order.save && @order.pay_type != \"Karta kredytowa\"\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n OrderMailer.received(@order).deliver_later\n format.html { redirect_to store_index_url,\n notice: 'Zamówienie zostało złożone.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.line_items.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n candidateOrder = Order.new(email: params[:order][:Email],\n totalCost: cart_total,\n user: curr_user)\n cart.each do |pId, info|\n if (prod = Product.find_by(id: pId))\n if prod.stockCount > info[\"Num\"].to_i\n candidateOrder.order_entries.new(\n product: prod,\n quantity: info[\"Num\"].to_i,\n unitprice: prod.price,\n totalprice: prod.price * info[\"Num\"].to_i,\n order_id: candidateOrder.id\n )\n candidateOrder.order_entries.last.validate!\n if candidateOrder.valid?\n prod.stockCount -= info[\"Num\"].to_i\n Product.update(prod.id, stockCount: prod.stockCount)\n end\n end\n end\n end\n if candidateOrder.save!\n clear_cart\n redirect_to order_path(candidateOrder), notice: t(:order_placed)\n else\n redirect_to carts_path, error: t(:order_failed)\n end\n end",
"def create_order\n @order = Order.create\n end",
"def current_order(create_order_if_necessary = false)\n return @current_order if @current_order\n if session[:order_id]\n @current_order = Spree::Order.find_by_id(session[:order_id], :include => :adjustments)\n end\n if create_order_if_necessary and (@current_order.nil? or @current_order.completed?)\n @current_order = Spree::Order.new\n before_save_new_order\n @current_order.save!\n after_save_new_order\n end\n session[:order_id] = @current_order ? @current_order.id : nil\n @current_order\n end",
"def new\n # @url = \"http://rate-exchange.appspot.com/currency?from=IDR&to=USD\"\n @cart = current_cart\n @cart.line_items.each do |item|\n @productid = item.product.id\n end\n @destinations = Destination.find(:all, group: \"state_id\")\n # @states = State.find(:all, conditions: { state_status: 1 })\n @states = State.find(:all, conditions: { state_status: 1 })\n\n @user = current_user\n if @user.blank?\n @order = Order.new(cart_id: @cart.id)\n else\n @order = Order.new(account_member_id: @user.id, cart_id: @cart.id)\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def transfer cart\n \t\tself.order_items.destroy_all\n \t\tcart.cart_items.each do |item|\n \t\t\t@order_item = order_items.build(price: item.price, quantity: item.quantity, sku_id: item.sku_id, weight: item.weight, order_id: id)\n \t\t\t@order_item.build_order_item_accessory(accessory_id: item.cart_item_accessory.accessory_id, price: item.cart_item_accessory.price, quantity: item.cart_item_accessory.quantity) unless item.cart_item_accessory.nil?\n \t\t\t@order_item.save!\n \t\tend\n \tend",
"def order(params, id)\n db = database()\n cart = cart(id)\n i = 0\n time = Time.now.to_s[0..18]\n db.execute(\"INSERT INTO invoices (Sum, UserId, Timestamp) VALUES (?, ?, ?)\", params[\"sum\"].to_i, id, time)\n invoiceid = db.execute(\"SELECT Id FROM invoices WHERE Timestamp = ?\", time)\n cart.each do |item|\n print item\n db.execute(\"INSERT INTO pizza_invoice_relation (InvoiceId, PizzaId) VALUES (?, ?)\", invoiceid, item[2])\n end\n delete_cart(id)\n end",
"def set_order\n @order = Order.find(session[:order_id])\n end",
"def create\n @cart = current_cart\n @desti = Destination.find(params[:order][:destination_id])\n alltotal_price = @desti.price + @cart.total_price\n @order = Order.new(params[:order])\n @order.total_all(alltotal_price)\n\n respond_to do |format|\n if @order.save\n if @order.purchase\n # if @order.save\n # render :action => \"success\"\n @cart.line_items.each do |item|\n item.order_id = @order.id\n item.save!\n end\n\n session[:cart_id] = nil\n\n format.html { redirect_to root_path, notice: 'Order berhasil, tunggu untuk konfirmasi selanjutnya' }\n format.json { render json: @order, status: :created, location: @order }\n # else\n # format.html { redirect_to root_path, alert: response.message }\n # end\n else\n # render :action => \"failure\"\n format.html { redirect_to root_path, alert: 'Pembayaran gagal' }\n end\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def buildOrder(orderObject)\n return Order.new(orderObject['id'], orderObject['customer_email'], orderObject['fulfilled'], buildProducts(orderObject['products']))\nend",
"def create\n @cart = current_cart\n @product = Product.find(params[:product_id])\n @order = Order.add_product(@product, @cart)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n puts \"======ENTERING ORDER CREATE ROUTINE===\"\n\n @order = Order.new(order_params)\n\n puts \"=====EXECUTED ORDER.new ===============\"\n\n @order.user_id = current_user.id\n\n puts \"===Retrieving LINE_ITEMS in Order.create==============\"\n if user_signed_in? \n @line_items = LineItem.all.where(user: current_user).order(\"created_at DESC\")\n else\n @line_items = LineItem.all.where(user: 0)\n end\n\n @line_item = @line_items.first\n @order.delivery_date = @line_item.delivery_date\n @order.total_price = @line_items.to_a.sum { |item| item.unit_price(item.quantity) }\n\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n begin\n charge = Stripe::Charge.create(\n :amount => ( 11.99 * 100).floor,\n :currency => \"usd\",\n :card => token\n )\n flash[:notice] = \"Thanks for ordering!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n \n puts \"=======Entering Order.save=====\"\n\n respond_to do |format|\n if @order.save\n \n puts \"=====EXECUTED ORDER.new Order Id is #{@order.id}\"\n LineItem.where(:user_id => current_user).update_all(\"order_id = #{@order.id}\")\n\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n\n format.html { redirect_to store_index_path, notice: 'Thank you for your order.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.add_line_items_from_cart(@cart)\n @order.donor_id = current_donor.id\n @order.price = @cart.total_price\n respond_to do |format|\n if @order.save\n @order.line_items.each do |line|\n thing = Product.find(line.product_id)\n thing.sold = true\n thing.save\n end\n token = params[:stripeToken]\n @amount = @cart.total_price.to_i*100\n\n charge = Stripe::Charge.create({\n amount: @amount,\n currency: 'aud',\n description: 'Example charge',\n source: token,\n \n })\n \n Order.new[:params]\n\n redirect_to controller: 'orders', action: 'show', id: Order.last.id\n\n\n Cart.destroy(session[:cart_id])\n session[:cart_id]\n format.html \n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def prepare_new_order\n @order = Order.new(order_params)\n @order.user_id = current_user.id\n @product = Product.find(params[:orders][:product_id])\n @order.product = @product\n @order.price_cents = @product.price_cents\n end",
"def set_order\r\n @order = Order.find(params[:id])\r\n end",
"def set_order\r\n @order = Order.find(params[:id])\r\n end",
"def current_shopping_cart\n Order.where(user_id: current_user.id, complete: false).first_or_create\n end",
"def orders_add\n\t\t@product_id = params[:product_id].to_i\n\t\t@quantity = params[:quantity].to_i\n\t\t\n\t\tfound = false\n\t\tsession[:orders].each do |order|\n\t\t\tif (order[\"table\"][\"product_id\"]==@product_id and not found) #session-ized variable uses [table]\n\t\t\t\trespond_to do |format|\n\t\t\t\t\tformat.json { render json: { error: \"Product already ordered. Please check your cart.\"} }\n\t\t\t\tend\n\t\t\t\tfound = true\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\t\n\t\tif (not found)\n\t\t\tif (@quantity>0)\n\t\t\t\tneworder = OpenStruct.new product_id: @product_id, quantity: @quantity\n\t\t\t\tsession[:orders] << neworder\n\t\t\t\t\n\t\t\t\trespond_to do |format| #success\n\t\t\t\t\tformat.json { render json: {} }\n\t\t\t\tend\n\t\t\telse\n\t\t\t\trespond_to do |format|\n\t\t\t\t\tformat.json { render json: { error: \"Invalid quantity to be added to cart.\"} }\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn nil\n\tend",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n # finds the current order using the params\n @order = Order.find(params[:id])\n end",
"def create\n @order1 = Order1.new(params[:order1])\n\t@order1.add_lineitem2s_from_cart(current_cart)\n\t@order1.member_id=@current_member.id\n\t\n respond_to do |format|\n if @order1.save\n\t\t\n\t\t\tCart.destroy(session[:cart_id])\n\t\t\tsession[:cart_id]=nil\n\t\t\tformat.html { redirect_to store_url, notice: 'Thank you for your order' }\n\t\t\tformat.json { render json: @order1, status: :created, location: @order }\n else\n\t\t\t@cart=current_cart\n\t\t\tformat.html { render action: \"new\" }\n\t\t\tformat.json { render json: @order1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def create\n @order = Order.new(order_params)\n @order.user_id = current_user.id\n @order.uuid = SecureRandom.hex(8)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render 'show', status: :created, location: @order }\n else\n format.html { render 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_order\n @order = Order.find(session[:order_id])\n end",
"def create \n\t\tcarted_products = current _user.\n\t\tcarted_products.where(status: \"carted\")\n\n\t\tcarted_products.each do |carted_products|\n\t\t\tsum += (carted_product.product.product.price\n\t\t\t* carted_product.quantity)\n\t\tend \n\n\t\ttax =subtotal * 0.09\n\t\ttotal = subtotal + tax \n\n\t\torder = Order.create(user_id: current_user_id ,subtotal: subtotal, tax: tax,\n\t\t\ttotal: total)\n\n\t\tcarted_products.update_all (status: \"purchased\",order_id:\"order_id\")\n\n\t\tflash [success:] = \"Order succesfully created\" \n\t\tredirect_to \"/orders/#{order.id}\"\n\tend",
"def create\n @order = current_order\n @order_item = @order.order_items.new(order_item_params)\n if @order.save\n session[:order_id] = @order.id\n end\n head :ok\n\n # @order_item = OrderItems.new(order_item_params)\n # respond_to do |format|\n # if @order_item.save\n # format.html { redirect_to @order_item, notice: 'Order item was successfully created.' }\n # format.json { render :show, status: :created, location: @order_item }\n # else\n # format.html { render :new }\n # format.json { render json: @order_item.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n order_data = order_params\n order_data[:user_id] = current_user.id\n total_amount = 0\n @order = Order.new(order_data)\n @basket.basket_items.each do |basket_item|\n order_item = OrderItem.new( {\n product_id: basket_item.product_id,\n quantity: basket_item.quantity,\n price: basket_item.price\n } )\n @order.order_items << order_item\n total_amount += basket_item.price.to_f * basket_item.quantity.to_i\n end\n\n @order[:total_amount] = total_amount\n\n respond_to do |format|\n if @order.save\n @basket.destroy\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_order_product\n @cart = OrderProduct.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n #Также нужны переменные\n @client=Client.find(@order.client_id)\n @delivery=Delivery.find(@order.delivery_id)\n @employee=Employee.find(@order.employee_id)\n @ordered=Ordered.where(\"order_id=?\",@order.id)\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end"
] | [
"0.7156335",
"0.7149351",
"0.7116741",
"0.705756",
"0.70562285",
"0.70512074",
"0.70152026",
"0.7002662",
"0.699866",
"0.69817525",
"0.6954266",
"0.69529325",
"0.6925748",
"0.6883563",
"0.686639",
"0.686195",
"0.6856604",
"0.68191713",
"0.68070155",
"0.68064046",
"0.67997366",
"0.6791623",
"0.678992",
"0.6767856",
"0.670722",
"0.6705427",
"0.6701662",
"0.6670835",
"0.66634285",
"0.66602045",
"0.6653341",
"0.6630169",
"0.66167057",
"0.6607629",
"0.6603959",
"0.65886647",
"0.6584025",
"0.6577182",
"0.6567775",
"0.6564159",
"0.65590656",
"0.6557788",
"0.65508556",
"0.65310156",
"0.65286124",
"0.6527966",
"0.65202117",
"0.65200293",
"0.6514951",
"0.65148395",
"0.65148395",
"0.65026706",
"0.64880455",
"0.6486032",
"0.64668727",
"0.64666843",
"0.6449743",
"0.6443581",
"0.64392346",
"0.64297026",
"0.6428927",
"0.6428762",
"0.6427619",
"0.642431",
"0.64238775",
"0.64173377",
"0.641595",
"0.641595",
"0.641467",
"0.64122653",
"0.6400978",
"0.6400298",
"0.6390134",
"0.63822466",
"0.63820446",
"0.6381886",
"0.63794166",
"0.63732463",
"0.6370332",
"0.6370059",
"0.63637125",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097",
"0.63616097"
] | 0.6939319 | 12 |
Retrieve order from database if it exists, or use cached version | def order
@order ||= Glysellin::Order.where(id: order_id).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_reusable_order\n return # FIXME: currently it may return address which is being used by other active order\n expired_orders = find_expired_orders_row\n if expired_orders.size >= Config.reuse_address_orders_threshold &&\n fetch_transactions_for(expired_orders.last.address).empty?\n return expired_orders.last\n end\n nil\n end",
"def order\n @order ||= Order.find_by(id: session[:order_id]) if session[:order_id]\n end",
"def get_order(order_id)\n authenticated? do\n query_and_build \"marketplace/orders/#{order_id}\"\n end\n end",
"def get_order\n @order = Order.find(params[:id])\n end",
"def get_order\n @order = Order.find(params[:id])\n end",
"def current_order\n @current_order ||= load_order_from_session unless @current_order == false\n end",
"def show\n #respond_with @order if stale? @order # another method of caching\n fresh_when @order\n end",
"def order(order_id)\n Order.find(order_id)\n end",
"def find_order \n unless session[:order_id].blank?\n @order = Order.find_or_create_by_id(session[:order_id])\n else \n @order = Order.create\n end\n session[:order_id] = @order.id\n @order\n end",
"def simple_current_order\n return @simple_current_order if @simple_current_order\n\n @simple_current_order = find_order_by_token_or_user\n\n if @simple_current_order\n @simple_current_order.last_ip_address = ip_address\n return @simple_current_order\n else\n @simple_current_order = current_store.orders.new\n end\n end",
"def load_order!\n @order = current_user.orders.find params[:id]\n # @order = @cookbook.get_active_reorder(params[:id]) if @cookbook.is_owner? current_user\n end",
"def find_order\n @order = Order.find(params[:id])\n end",
"def order\n @order ||= if session['order']\n OrderBasket.load(session['order']).tap(&:apply_promotions!)\n else\n OrderBasket.new\n end\n end",
"def getOrder(id)\n @orders.find {|ord| ord.orderId.to_i == id.to_i}\n end",
"def pending_purchase_order\n @pending_purchase_order_cache || @pending_purchase_order_cache = if self.purchase_orders\n self.purchase_orders.select(&:pending?).last unless self.purchase_orders.empty?\n end\n end",
"def load!\n transfer = find_or_create_transfer\n transfer.load!(order.items_waiting)\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 show\n @order = Cache.get 'order_' + params[:id].to_s\n unless @order\n @order = Order.find(params[:id])\n Cache.put 'order_' + params[:id].to_s, @order\n end\n redirect_to :controller => :sessions, :action => :new and return unless @order.user == current_user\n @products = Cache.get 'order_' + @order.id.to_s + '_products'\n unless @products\n @products = @order.products\n Cache.put 'order_' + @order.id.to_s + '_products', @products\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @order }\n end\n end",
"def current_order(options = {})\n options[:create_order_if_necessary] ||= false\n options[:lock] ||= false\n\n return @current_order if @current_order\n\n if session[:order_id]\n current_order = Spree::Order.includes(:adjustments).lock(options[:lock]).find_by(id: session[:order_id], currency: current_currency)\n @current_order = current_order unless current_order.try(:completed?)\n end\n\n if options[:create_order_if_necessary] and (@current_order.nil? or @current_order.completed?)\n @current_order = Spree::Order.new(currency: current_currency)\n @current_order.user ||= try_spree_current_user\n # See issue #3346 for reasons why this line is here\n @current_order.created_by ||= try_spree_current_user\n @current_order.save!\n\n # make sure the user has permission to access the order (if they are a guest)\n if try_spree_current_user.nil?\n session[:access_token] = @current_order.token\n end\n end\n\n if @current_order\n @current_order.last_ip_address = ip_address\n session[:order_id] = @current_order.id\n return @current_order\n end\n end",
"def test_order\n @@test_orders[self] || AVAILABLE_ORDERS.first\n end",
"def get(key)\n # Return nothing if not in the cache or it has expired.\n return if key.nil?\n\n entry = @cache[key]\n return unless entry\n return if entry.expired?\n\n # Otherwise return the cached object.\n # We don't delete the cached entry because we might need to force its use if its expired and offline\n entry.object\n end",
"def force_get(key)\n # Return nothing if not in the cache or it has expired.\n return if key.nil?\n\n entry = @cache[key]\n return unless entry\n entry.object\n end",
"def fetch_from_cache\n get_cache_object().get make_key\n end",
"def current_order\n @current_order ||= Order.find_by(id: user_id)\n end",
"def simple_current_order\n @order ||= Spree::Order.find_by(id: session[:order_id], currency: current_currency)\n end",
"def find_or_create_object(row)\n store = Store.find_by_account_number(row[\"account_number\"])\n order = store.orders.for_current_period.first if store\n order ? order : Order.new(store: store, status: Order::AWAITING_PRINT)\n end",
"def load_customer\n if read_from_cache(\"customers\")\n @customer = read_from_cache(\"customers\").find(params[:id])\n else\n @customer = Customer.find(params[:id])\n end\n end",
"def order\n @order ||= Elong::API::GHotel::Order.new(@client)\n end",
"def current_order(options = {})\n options[:create_order_if_necessary] ||= false\n options[:includes] ||= true\n\n if @current_order\n @current_order.last_ip_address = ip_address\n return @current_order\n end\n\n @current_order = find_order_by_token_or_user(options, true)\n\n if options[:create_order_if_necessary] && (@current_order.nil? || @current_order.completed?)\n @current_order = current_store.orders.create!(current_order_params)\n @current_order.associate_user! try_spree_current_user if try_spree_current_user\n @current_order.last_ip_address = ip_address\n end\n\n @current_order\n end",
"def current_order\n if session[:order_id]\n Order.find(session[:order_id])\n else\n Order.new\n end\n end",
"def current_order\n if session[:order_id]\n Order.find(session[:order_id])\n else\n Order.new\n end\n end",
"def load_order\n\t\tparams[:order_param] ||= session[:order_param]\n\t\tsession[:order_param] = params[:order_param]\n\tend",
"def order\n # Or equals is used so that if an order has been assigned previously, return that instance (find) but if it\n # is nil, we create one in the database on the token. \n @order ||= Order.find_or_create_by(token: @token) do |order|\n order.sub_total = 0\n end\n end",
"def get_item(**opt)\n cache_read(**opt) || default\n end",
"def get_or_create_open_order\n self.open_order || self.orders.create(:status => Order::OPEN, :subtotal => 0)\n end",
"def order\n Spree::Order.find(@attributes[:order_id].to_i)\n end",
"def load_order\n @cache_load_order = read_load_order unless defined?(@cache_load_order)\n @cache_load_order\n end",
"def index\n @orders = Order.all\n @cache_key_orders = cache_key('all', @orders)\n fresh_when @cache_key_orders, public: true\n end",
"def check_order\n return if order.present? && Faq.where(order: order).where.not(id: id).empty?\n self.order = begin\n Faq.order(order: :desc).limit(1).first.order + 1.0\n rescue\n 1\n end\n end",
"def set_order_info\n @order_info = OrderInfo.where(id: params[:id]).first\n @order_info ||= OrderInfo.find_by!(enc_id: params[:id])\n end",
"def get(order_id)\n get_request(t_url(:order, order_id))\n end",
"def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end",
"def fetch\n\n caching_enabled = is_caching_enabled()\n if caching_enabled\n result = fetch_from_cache\n end\n\n if !caching_enabled || (caching_enabled && result == nil)\n db_return = query()\n\n result = make_result_object(db_return.columns.as_json, db_return.as_json)\n if caching_enabled\n store_in_cache result\n end\n end\n result\n end",
"def fetch(name)\n load_cache(name)\n end",
"def fetch_by_id(id)\n ensure_base_model\n raise_if_scoped\n return unless id\n raise NotImplementedError, \"fetching needs the primary index enabled\" unless primary_cache_index_enabled\n if IdentityCache.should_use_cache?\n\n require_if_necessary do\n object = nil\n coder = IdentityCache.fetch(rails_cache_key(id)){ coder_from_record(object = resolve_cache_miss(id)) }\n object ||= record_from_coder(coder)\n IdentityCache.logger.error \"[IDC id mismatch] fetch_by_id_requested=#{id} fetch_by_id_got=#{object.id} for #{object.inspect[(0..100)]} \" if object && object.id != id.to_i\n object\n end\n\n else\n self.reorder(nil).where(primary_key => id).first\n end\n end",
"def fetch_from_inventory(an_order)\n order = extract_code_qty(an_order)\n return Inventory.fetch_an_item(order[:code])\n end",
"def alipay_load_order\n Rails.logger.debug \"#{__LINE__} alipay_load_order called \"\n raise \"'out_trade_no' requird to load the order\" unless params.key?('out_trade_no')\n #order_number = parse_alipay_out_trade_no(params['out_trade_no'])[:payment_order_number]\n order_number, payment_identifier = parse_alipay_out_trade_no(params['out_trade_no'])\n @order = Order.find_by_number(order_number) #if request.referer=~/alipay.com/\n @payment = Payment.find_by(identifier: payment_identifier)\n #@current_order = @order\n unless @order.present?\n raise RuntimeError, \"Could not find order #{order_number}\"\n end\n Rails.logger.debug \"#{__LINE__} alipay_load_order called and order is found #{@order.inspect}\"\n end",
"def set_authed_order\n @order = current_user.orders.find(params[:id])\n end",
"def latest\n latest_order.first\n end",
"def fetch\n @order = Order.where(owner_id: current_user.branch.nodes.pluck(:id)).order('orders.quantity').last\n\n render json: {id: @order.id, quantity: @order.quantity,\n date: @order.created_at.strftime('%d/%m/%Y'),\n time: @order.created_at.strftime('%p %I:%M'),\n destination: \"#{t('fridge')} - #{@order.owner_id}\"\n }, status: :ok\n end",
"def fetch_from_cache\n if paginate?\n\n # Return a paginated collection\n if cached.ids.empty?\n\n # No ids, return an empty WillPaginate result\n [].paginate(opts_for_paginate)\n\n elsif combined_options.include?(:order)\n\n # An order has been specified. We have to go to the database\n # and paginate there because the contents of the requested\n # page will be different.\n klass.paginate(cached.ids, { :total_entries => cached.ids.size }.merge(opts_for_find.merge(opts_for_paginate)))\n\n else\n\n # Order is unchanged. We can paginate in memory and only select\n # those ids that we actually need. This is the most efficient.\n paged_ids = cached.ids.paginate(opts_for_paginate)\n paged_ids.replace(klass.find_all_by_id(paged_ids, opts_for_find(paged_ids)))\n\n end\n\n elsif cached.ids.empty?\n\n # We are returning a regular (non-paginated) result.\n # If we don't have any ids, that's an empty result\n # in any language.\n []\n\n elsif combined_options.include?(:order)\n\n # An order has been specified, so use it.\n klass.find_all_by_id(cached.ids, opts_for_find)\n\n else\n\n # No order has been specified, so we have to maintain\n # the current order. We do this by passing some extra\n # SQL which orders by the current array ordering.\n offset, limit = combined_options.delete(:offset) || 0, combined_options.delete(:limit) || cached.count\n ids = cached.ids[offset, limit]\n\n klass.find_all_by_id(ids, opts_for_find(ids))\n end\n end",
"def order(order, options = {})\n id = epages_id(order)\n perform_get_with_object(\"/orders/#{id}\", options, Epages::Order)\n end",
"def load_work_order\n @work_order = WorkOrder.accessible_by(current_ability).find(params[:id])\n end",
"def fetch\n self.version = begin\n ver = cache.fetch(CACHE_VERSION_KEY) do\n {'version' => Tml.config.cache[:version] || 'undefined', 't' => cache_timestamp}\n end\n validate_cache_version(ver)\n end\n end",
"def recent_orders()\n\t\twith_auth nil do |options|\n\t\t\tself.class.get(\"/api/v1/orders\", options)\n \tend\n\tend",
"def current_order\n \torders = self.orders\n \t@current_order = nil\n \tfor order in orders\n \t\t@current_order = order if order.current?\n \tend\n \t\n \tif @current_order == nil\n \t\t@current_order = self.orders.create\n \t\t@current_order.current = true\n \t\t@current_order.save\n \tend\n \t@current_order\n end",
"def cached_instance\n @cached_instance ||= read_instance\n end",
"def retrieve_order(order_id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::GET,\n '/v2/orders/{order_id}',\n 'default')\n .template_param(new_parameter(order_id, key: 'order_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 my_order\n @orders = Order.where(user: current_user)\n end",
"def get_orders\n orders\n end",
"def index\n @orders = Order.where(:customer_id => params[:customer_id])\n @order = @orders.first \n end",
"def get_order(order_id)\n res = request('get', \"https://#{orders_path}/#{order_id}\")\n parse_response res\n end",
"def smart_fetch_from_cache(opts={}, &block)\n id = opts[:id]\n key = cache_key id\n force_write = opts[:force_write]\n expiration = self.expires_in\n Rails.logger.debug \"#{self.name} cache_key will be #{key}, expiration #{expiration}\"\n unless force_write\n entry = Rails.cache.read key\n if entry\n Rails.logger.debug \"#{self.name} Entry is already in cache: #{key}\"\n return (entry == NilClass) ? nil : entry\n end\n end\n wrapped_response = handling_exceptions(key, opts, &block)\n response = wrapped_response[:response]\n if wrapped_response[:exception]\n Rails.logger.debug \"#{self.name} Error occurred; writing entry to cache with short lifespan: #{key}\"\n expiration = Settings.cache.expiration.failure\n else\n Rails.logger.debug \"#{self.name} Writing entry to cache: #{key}\"\n end\n response = process_response_before_caching(response, opts)\n cached_entry = (response.nil?) ? NilClass : response\n Rails.cache.write(key,\n cached_entry,\n :expires_in => expiration,\n :force => true)\n response\n end",
"def _fetch\n cache_get(:_fetch) || @opts[:fetch]\n end",
"def set_order\n @my_order = Order.find(params[:id])\n end",
"def get_cached(args)\n cache_key = gen_cache_key(args)\n\n begin\n cached_val = MongoMapper::Document.redis.get(cache_key)\n rescue Exception\n cached_val = nil\n end\n\n unless cached_val\n res = where(args)\n result_count = res.count\n if result_count == 0\n return nil\n elsif result_count == 1\n cached_val = Octo::Utils.serialize(res.first)\n MongoMapper::Document.redis.setex(cache_key, get_ttl, cached_val)\n elsif result_count > 1\n cached_val = Octo::Utils.serialize(res)\n MongoMapper::Document.redis.setex(cache_key, get_ttl, cached_val)\n end\n end\n begin\n Octo::Utils.deserialize(cached_val)\n rescue Exception => e\n Octo.logger.error e\n nil\n end\n end",
"def fetch_by_id(id)\n if IdentityCache.should_cache?\n\n require_if_necessary do\n object = IdentityCache.fetch(rails_cache_key(id)){ resolve_cache_miss(id) }\n IdentityCache.logger.error \"[IDC id mismatch] fetch_by_id_requested=#{id} fetch_by_id_got=#{object.id} for #{object.inspect[(0..100)]} \" if object && object.id != id.to_i\n object\n end\n\n else\n self.find_by_id(id)\n end\n end",
"def latest!\n latest_order!.first\n end",
"def cached?; end",
"def set_order\n @order = Order::Preorder.find(params[:id])\n end",
"def show\n @order = Order.includes(:items).find(params[:id])\n end",
"def me_order_pending\n object_from_response(self, Artsy::Client::Domain::Order, :get, \"/api/v1/me/order/pending\", {})\n end",
"def edit\n@order = current_order || Order.incomplete.find_or_initialize_by(guest_token: cookies.signed[:guest_token])\nassociate_user\nend",
"def cached\n @cached ||= Rails.cache.read(self.cache_key, opts_for_cache)\n end",
"def transaction(reload: false)\n transactions(reload: reload).first\n end",
"def cache\n the_current_time = current_time\n cache_loaded_at = @cache.loaded_at if @cache\n\n if @cache && cache_expiration_policy_object.stale?(cache_loaded_at, the_current_time)\n flush!(:stale, :loaded => cache_loaded_at, :now => the_current_time)\n end\n\n unless @cache\n instrument('cache_load') do\n @cache = LowCardTables::LowCardTable::Cache.new(@low_card_model, @low_card_model.low_card_options)\n end\n end\n\n @cache\n end",
"def load_cached\n content = File.open(self.cache_file_name, \"rb\") { |f| f.read }\n puts(\"[MODEL_FILE] Loaded #{self.cache_file_name} from cache\")\n return content\n end",
"def get_order_item(id, options = nil)\r\n @client.raw('get', \"/ecommerce/order-items/#{id}\", options, nil, @contact_v1_url)\r\n end",
"def get_order(order_id)\n\tputs \"Getting order: \" + order_id\n\tresponse = request_get(\"/api/order/\" + order_id)\n\tputs response.body\nend",
"def set_order\n @order = Order.friendly.find(params[:id])\n end",
"def set_order\n @order = Order.friendly.find(params[:id])\n end",
"def fetch_item(klass:, cache_key:, default: nil)\n memory_item = @memory_adapter.fetch_item(\n klass: klass,\n cache_key: cache_key,\n default: default\n )\n\n return memory_item if memory_item != default\n\n redis_item = @redis_adapter.fetch_item(\n klass: klass,\n cache_key: cache_key,\n default: default\n )\n\n return default if redis_item == default\n\n @memory_adapter.cache_item(\n klass: klass,\n cache_key: cache_key,\n item: redis_item\n )\n\n redis_item\n end",
"def cache_fetch(key, default = nil)\n nkey = namespaced(key)\n\n # Delete expired rows\n @dataset.select.filter(:key => nkey) do\n expires < Time.now\n end.delete\n\n # Get remaining row (if any)\n result = @dataset.select(:value).filter(:key => nkey).limit(1)\n\n if result.empty?\n return default\n else\n return deserialize(result.first[:value])\n end\n end",
"def cache_fetch(key, default = nil)\n nkey = namespaced(key)\n\n # Delete expired rows\n @dataset.select.filter(:key => nkey) do\n expires < Time.now\n end.delete\n\n # Get remaining row (if any)\n result = @dataset.select(:value).filter(:key => nkey).limit(1)\n\n if result.empty?\n return default\n else\n return deserialize(result.first[:value])\n end\n end",
"def edit_existing(order)\n @data.order = order\n @data.user = User.with_id(order.order_user_id)\n\n order_common(false)\n end",
"def find_order\n @order = Order.find_by!(number: params[\"order_refnum\"].to_s)\n authorize! :update, @order\n end",
"def find_order\n\t\t\tbegin\n\t\t\t\t@order = Order.find(params[:id])\n\t\t\trescue\n\t\t\t\tflash[:error] = \"Error: The Order with id #{params[:id]} does not exists.\"\n\t\t\t\tredirect_to root_path\n\t\t\tend\n\t\tend",
"def cache_fetch(key, default = nil)\n # Retrieve the data and return it\n record = @store[:key => namespaced(key)]\n record.value rescue default\n end",
"def unpromoted_order\n @unpromoted_order ||= if session['order']\n OrderBasket.load(session['order'])\n else\n OrderBasket.new\n end\n end",
"def set_order\n @order = Order.find(params[:id])\n @order_product = OrderProduct.where(order_id: params[:id]).first\n if @order_product\n @product = Product.where(id: @order_product.product_id).first\n end\n end",
"def show\n @order = Order.includes([:customer,:order_details => :product]).find(params[:id])\n \n if !@order.delivered?\n @order_detail = @order.order_details.new\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def load_item_from_infinite_stock(order_item)\n create_item_from(order_item, order_item.order.number)\n true\n end",
"def show\n @order = Order.where(id: params[:id], user: current_user).first\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def _refresh_get(dataset)\n if (sql = model.fast_pk_lookup_sql) && !dataset.opts[:lock]\n sql = sql.dup\n ds = use_server(dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_first(sql)\n else\n dataset.first\n end\n end",
"def _refresh_get(dataset)\n if (sql = model.fast_pk_lookup_sql) && !dataset.opts[:lock]\n sql = sql.dup\n ds = use_server(dataset)\n ds.literal_append(sql, pk)\n ds.with_sql_first(sql)\n else\n dataset.first\n end\n end",
"def build_order\n @order ||= ManagementCenter::Order.new\n end",
"def my_account\n @orders = current_customer.orders.includes(:product).in_order || []\n end",
"def current_order(create_order_if_necessary = false)\n return @current_order if @current_order\n if session[:order_id]\n @current_order = Spree::Order.find_by_id(session[:order_id], :include => :adjustments)\n end\n if create_order_if_necessary and (@current_order.nil? or @current_order.completed?)\n @current_order = Spree::Order.new\n before_save_new_order\n @current_order.save!\n after_save_new_order\n end\n session[:order_id] = @current_order ? @current_order.id : nil\n @current_order\n end",
"def show\n @order = get_pending_order\n @food_item = @order == nil ? nil : FoodItem.find(@order.food_item_id)\n end"
] | [
"0.6614834",
"0.65239745",
"0.6267619",
"0.6260162",
"0.6260162",
"0.62495434",
"0.62246215",
"0.6205484",
"0.6169941",
"0.6156872",
"0.5986064",
"0.59423125",
"0.59379375",
"0.5934422",
"0.5932394",
"0.5884787",
"0.5870997",
"0.5867054",
"0.5844494",
"0.5812997",
"0.5798022",
"0.5779641",
"0.5771182",
"0.5762875",
"0.573883",
"0.57219255",
"0.5720228",
"0.56793344",
"0.56737256",
"0.56607044",
"0.56607044",
"0.56584233",
"0.5658028",
"0.564371",
"0.5637747",
"0.5634483",
"0.5616586",
"0.5605729",
"0.559623",
"0.5582937",
"0.55828536",
"0.5571297",
"0.55590063",
"0.55436814",
"0.5542027",
"0.55266243",
"0.55193913",
"0.55188835",
"0.55161506",
"0.5508601",
"0.5497128",
"0.54924953",
"0.5471352",
"0.5466963",
"0.54662824",
"0.54584986",
"0.545632",
"0.5451868",
"0.54445916",
"0.54371566",
"0.54343015",
"0.543381",
"0.54247385",
"0.5418547",
"0.54079294",
"0.5401802",
"0.5398496",
"0.539837",
"0.53935015",
"0.53832376",
"0.5379031",
"0.53699905",
"0.5365494",
"0.5362096",
"0.53572744",
"0.5353939",
"0.53431845",
"0.5338378",
"0.53301084",
"0.5322633",
"0.5322633",
"0.5319997",
"0.5305108",
"0.5305108",
"0.5303854",
"0.52882165",
"0.528653",
"0.52830845",
"0.5271272",
"0.5259383",
"0.5256772",
"0.5255829",
"0.52554727",
"0.5254865",
"0.5248608",
"0.5248608",
"0.5242908",
"0.5236107",
"0.5229171",
"0.5221145"
] | 0.6616279 | 0 |
Assign order and order_id, if nil is explicitly passed, ensure we set order id to nil too | def order=(order)
self.order_id = order && order.id
@order = order
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_order\n if params[:customer_id].nil?\n @customer=nil\n else\n @customer=Customer.find(params[:customer_id])\n end\n @order = Order.find(params[:id])\n end",
"def set_transaction_order\n\n # if params[:order_id].nil?\n # @transaction_order = TransactionOrder.find(params[:id])\n # end\n @transaction_order = TransactionOrder.find(params[:id])\n\n\n #@transaction_order = TransactionOrder.find(params[:order_id]) if @transaction_order.nil?\n end",
"def set_order\n @order = Order.find(params[:order_id])\n end",
"def set_order\n @order = Order.find(params[:order_id])\n end",
"def set_order\n\t\t@order = Order.find(params[:id])\n\tend",
"def set_order\n\t\t\t@order = Order.find(params[:id])\n\t\tend",
"def set_order\n # finds the current order using the params\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = check_owner_user_id(Order.find(params[:id]))\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end"
] | [
"0.72710454",
"0.70966864",
"0.7045644",
"0.7045644",
"0.6994384",
"0.696573",
"0.6947896",
"0.6939692",
"0.6892608",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845",
"0.68920845"
] | 0.7348318 | 0 |
Cleans cart stored order if it exists | def clean_order!
if order
# Destroy current cart order if not paid already, cause
# we're creating a new one
order.destroy if order.state_name == :ready
# unset order
self.order = nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shopping_cart_cleanup\n\n end",
"def remove!\n if order_item.destroy\n order_maker.handle_coupon!\n order_maker.destroy_empty_order!\n return_with(:success)\n else\n return_with(:error, error: order_maker.order_errors)\n end\n end",
"def empty_cart\n self.each do |item|\n item.cart_id = nil\n item.save!\n end\n end",
"def destroy\n flash.notice = I18n.t(:basket_successfully_cleared)\n @order.line_items.clear\n @order.update_totals!\n after :destroy\n set_flash :destroy\n response_for :destroy\n end",
"def test_cleanup_successful\n setup_new_order()\n @o.order_line_items << @li\n @o.order_status_code = order_status_codes(:cart)\n @o.notes = \"test test\"\n assert @o.save\n\n # Make sure inventory control is enabled.\n assert Preference.find_by_name('store_use_inventory_control').is_true?\n # Make sure cc number obfuscation is enabled.\n assert Preference.find_by_name('cc_clear_after_order').is_true?\n \n initial_quantity = @li.item.quantity\n notes_before = @o.notes.clone\n \n @o.cleanup_successful\n @li.item.reload\n \n # Quantity should be updated.\n assert_equal @li.item.quantity, (initial_quantity - @li.quantity)\n # Status code should be updated.\n @o.reload\n assert_equal @o.order_status_code, order_status_codes(:ordered_paid_to_ship)\n \n # CC number should be obfuscated.\n number_len = @o.account.cc_number.length\n new_cc_number = @o.account.cc_number[number_len - 4, number_len].rjust(number_len, 'X')\n assert_equal @o.account.cc_number, new_cc_number\n \n # A new note should be added.\n notes_after = @o.notes\n assert_not_equal notes_before, notes_after\n end",
"def destroy\n if order.new?\n # this won't trigger the before_destroy validation, don't forget\n order.order_items.delete_all\n order.order_payments.delete_all\n order.delete\n else\n OrderCanceller.new(order).all!\n # we refresh the cart manager (this should remove the entry)\n cart_manager.refresh!\n end\n flash[:success] = I18n.t('edit_order.delete_ok')\n redirect_to customer_orders_path\n end",
"def local_clean_new_order(mail)\n local_clean_extract_from_body(mail)\n return false unless @order_number\n logger.info \"Cleanup of #{@order_number}\"\n true\n end",
"def clean\n # Call method clean! on model\n current_cart.clean!\n flash[:warning] = \"Shopping cart is empty!\"\n redirect_to carts_path \n end",
"def destroy\n @order.destroy\n if Order.all.empty?\n @cart = current_cart\n @cart.destroy\n respond_to do |format|\n format.html { redirect_to menu_path, notice: 'Cart is empty!' }\n format.json { head :ok }\n end\n else\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end\n end",
"def cleanup_successful\n\t\tself.order_status_code_id = 5\n self.new_notes=\"Order completed.\"\n self.product_cost = self.line_items_total\n self.account.clear_personal_information\n self.save\n\tend",
"def clear_cart\n update_cart({})\n end",
"def cancel_order\n system 'clear'\n CoffeeMan.stay_logo\n @@cart.clear\n puts \"Your cart has been emptied\"\n sleep(0.09)\n main_menu\n sleep(2)\n end",
"def remove_items_from_cart\n line_items.each { |i| i.cart = nil }\n end",
"def reset_basket(order)\n order.empty_basket\n session[:coupons] = nil\n end",
"def confirm\n # resets sessions to clear the current cart once the order has been confirmed\n session[:order_id] = nil\n end",
"def remove_from_old_order\n coupon.orders&.first&.update(\n coupon_discount: 0,\n coupon_applied_at: nil,\n coupon_id: nil\n )\n end",
"def destroy\n if @cart_item.destroy\n # if @cart_item.cart.items.present?\n build do\n message 'Удаление товара из корзины'\n view 'cart_items/delete'\n end\n # else\n # @cart = @cart_item.cart\n # @cart.destroy\n # build do\n # message 'Удаление корзины'\n # view 'carts/delete'\n # end\n # end\n end\n end",
"def destroy\n @order_item.destroy\n @order_items = current_order.order_items\n if @order_items.empty?\n # empty session cart\n session[:order_id] = nil\n respond_to do |format|\n format.html { redirect_to catalog_products_path, flash: {alert: t('dialog.shop.alert_empty_cart')} }\n format.js { render js: \"window.location='#{catalog_products_path}'\", flash: {alert: t('dialog.shop.alert_empty_cart')} }\n end\n else\n respond_to do |format|\n format.html { redirect_to order_items_path, notice: t('views.flash_delete_message') }\n format.json { head :no_content }\n format.js {}\n end\n end\n end",
"def remove_nil_quantities\n\t\tself.order_contents.each do |order_content|\n\t\t\tif order_content.quantity <= 0\n\t\t\t\torder_content.destroy!\n\t\t\tend\n\t\tend\n\tend",
"def destroy\n @order = Order.find(params[:id])\n unless current_member.admin or (!@order.paid and !@order.taken)\n store_location\n flash[:notice] = \"Too late to edit that one, bro.\"\n redirect_to orders_path\n end\n\n # add stock back\n @order.order_details.each{ |od|\n od.stock.quantity += od.quantity\n od.stock.save\n }\n\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to(orders_url) }\n format.xml { head :ok }\n end\n end",
"def process_cart_items()\n \torder = self.customer.orders.create\n \tself.cart_items.each do |item|\n \t\torder.order_items.create :product_id => item.product_id\n \tend\n \tself.cart_items = [] #clear the cart\n \treturn order\n end",
"def destroy\n if @book.orderitems.present?\n @book.deleted = true\n @cartitems = @book.cartitems\n @cartitems.delete_all\n @book.save\n else \n @book.destroy\n end \n flash[:danger] = \"Book was successfully deleted\"\n redirect_to books_path\n end",
"def purge!\n unless self.ordered?\n self.line_items.each do |line_item|\n remove_line_item(line_item) if line_item.invalid?\n end\n end\n end",
"def complete_cart\n render json: { status: 'Success', message: 'Checkout Complete! Thank you for shopping with us!', data: products_in_cart(true) }\n Cart.destroy_all\n end",
"def create\n @order = Order.new(order_params)\n @order.add_line_items_from_cart(@cart)\n\n respond_to do |format|\n if @order.save \n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to store_index_url, notice: 'Thank you come again!'}\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def empty_cart\n puts \"========= Emptying Cart\"\n @b.goto 'http://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n\n if @b.link(class: \"remove-all-product\").exists?\n @b.link(class: \"remove-all-product\").click\n @b.div(class: \"ui-window-btn\").button.click\n end\n end",
"def empty_cart\n puts \"========= Emptying Cart\"\n @b.goto 'http://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n\n if @b.link(class: \"remove-all-product\").exists?\n @b.link(class: \"remove-all-product\").click\n @b.div(class: \"ui-window-btn\").button.click\n end\n end",
"def test_cleanup_successful\n\t\t@order.cleanup_successful\n\t\tassert_equal @order.order_status_code_id, 5\n\t assert_equal @order.notes.include?(\"Order completed.\"), true\n\t assert_equal @order.product_cost, @order.line_items_total\n\tend",
"def delete\n LineItem.delete_for_order(order_id)\n CreditCardTransaction.remove_references_to_order(order_id)\n super\n end",
"def destroy\n @in_shopping_cart.destroy\n end",
"def remove_from_cart\n if @cart.candle_carts.count == 1\n destroy\n else\n item = CandleCart.find(cart_params[:id])\n item.destroy\n flash[:alert] = \"Succesfully Removed\"\n redirect_back fallback_location: root_path\n end\n end",
"def perform_empty_cart(session_id, owner_id, client_channel, locale, version)\n $tracer.trace(\"GameStopCartServiceDSL: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n remove_products_from_cart_rsp = perform_empty_cart_and_return_message(session_id, owner_id, client_channel, locale, version)\n unless remove_products_from_cart_rsp.nil? == true\n remove_products_from_cart_rsp.code.should == 200\n end\n return true\n end",
"def checkout_cart\n self.line_items.each do |li|\n li.item.inventory -= li.quantity\n li.item.save\n end\n self.line_items.clear\n self.status = \"submitted\"\n self.user.current_cart_id = nil\n self.user.save\n end",
"def test_should_empty_cart_after_checkout\n test_checkout_success()\n \n an_order_id = session[:order_id]\n \n post :empty_cart\n assert_redirected_to :action => :index\n\n assert_equal 0, assigns(:order).items.length\n assert_nil session[:order_id]\n \n # Assert the order was destroyed.\n assert_raise(ActiveRecord::RecordNotFound) {\n Order.find(an_order_id)\n }\n end",
"def ensure_cart_isnt_empty\n if @cart.line_items.empty?\n redirect_to store_index_url, notice: 'Cart is empty'\n end\n end",
"def clear_cart\n items=CartItem.where(:cart_id=>self.id)\n items.each do |item|\n item.destroy\n end\n end",
"def destroy\n OrderItem.find_by(product: Product.find_by_title(params[:product_title]))\n .destroy_product(params[:quantity_of_products])\n order = Order.find_by_user_session_id(session['session_id'])\n if order.present?\n order.update_total_price_cents(nil)\n end\n redirect_to cart_path, notice: \"Вы убрали из корзины #{params[:product_title]}\"\n end",
"def clear_cart\n sleep(1)\n #element = $driver.find_element(:css,\"#mini-cart-wrap > li > div.minicart-inner-div > a:nth-child(3) > span\") \n \n puts \"moving cursor to minicart\"\n $driver.action.move_to(mini_cart_text).perform\n\n sleep(2) \n begin\n empty_my_cart = $driver.find_element(:css,\"#minicart-bottom > p.pull-left > a\")\n sleep(1)\n empty_my_cart.click\n sleep(1)\n rescue \n puts \"cart is already empty\"\n end \n end",
"def before_confirm\n return if defined?(SpreeProductAssembly)\n return unless @order.checkout_steps.include? 'delivery'\n\n packages = @order.shipments.map(&:to_package)\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\n @differentiator.missing.each do |variant, quantity|\n @order.contents.remove(variant, quantity)\n end\n end",
"def before_destroy\n if (self.costs.count > 0)\n raise RException.new(\"This order has cost-items attached to it -- You must first delete those costs before you can delete this order\")\n end\n end",
"def destroy\n @order_item_extra.destroy\n\n head :no_content\n end",
"def destroy_along_with_units\n self.quantity = 0\n OrderInventoryAssembly.new(self).verify\n self.destroy\n end",
"def destroy_along_with_units\n self.quantity = 0\n OrderInventoryAssembly.new(self).verify\n self.destroy\n end",
"def cart_clear\n cc = CartClear.new\n cc.params.merge!( { 'CartId' => @cart_id, 'HMAC' => @hmac } )\n cart = search( cc, @rg ).cart_clear_response.cart\n @cart_items = []\n @saved_for_later_items = []\n end",
"def check_cart_full?\n current_cart.destroy if current_cart.present? && !current_cart.is_full?\n end",
"def save_order\n @order = Order.new(params[:order]) \n @order.line_items << @cart.items \n if @order.save \n @cart.empty!\n redirect_to_index('Thank you for your order.')\n else\n render(:action => 'checkout') \n end\n end",
"def destroy\n\t\t@cart_item.destroy\n\n\t\thead :no_content\n\tend",
"def clear_carts\n current_user.carts.each_with_index do |cart, i|\n cart.delete if i != current_user.carts.length - 1\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.cart = @cart\n OrderMailer.demandelocation(Order.first).deliver_now\n\n\n respond_to do |format|\n if @order.save\n session.delete(:cart_id)\n format.html { redirect_to order_validations_path}\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def clear_item_from_cart\n\t\tcart_hash = session[:cart]\n\n\t\tredirect_to root_url\n\tend",
"def destroy\n @order_detail = OrderDetail.find(params[:id])\n product_detail = ProductDetail.find_by_id(@order_detail.product_detail_id)\n if product_detail.product_quantity.nil?\n details = 0\n else\n details = product_detail.product_quantity\n end\n @order_detail.destroy\n details +=1\n product_detail.update_attributes(:product_quantity => details)\n respond_to do |format|\n format.html {\n unless params[:cart_id].blank?\n redirect_to carts_url\n else\n redirect_to carts_url\n end\n }\n format.json { head :ok }\n end\n end",
"def empty_cart\n @cart.empty!\n redirect_to_index('Your cart is now empty')\n end",
"def clear_cart(cart)\n cart(:CartClear, {:CartId => cart.cart_id, :HMAC => cart.hmac})\n end",
"def empty_new_cart\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n if edit_cart_link.exists\n edit_cart_link.click\n wait_for_landing_page_load\n len = timeout(1000).remove_item_link.length\n while len > 0\n remove_item_link.at(0).click\n wait_for_landing_page_load\n len-=1\n end\n end\n\n shopping_cart_empty_label.should_exist\n end",
"def test_when_created_be_empty\n a_cart = Order.new\n \n assert_equal a_cart.items.size, 0\n assert_equal a_cart.tax, 0.0\n assert_equal a_cart.total, 0.0\n assert_equal a_cart.shipping_cost, 0.0\n end",
"def test_remove_product\n o = Order.new\n o.expects(:cleanup_promotion).times(4)\n o.add_product(items(:red_lightsaber), 2)\n o.add_product(items(:blue_lightsaber), 2)\n assert_equal o.items.length, 2\n\n # When not specified a quantity all units from the product will be removed.\n o.remove_product(items(:blue_lightsaber))\n assert_equal o.items.length, 1\n\n # When specified a quantity, just these units from the product will be removed.\n o.remove_product(items(:red_lightsaber), 1)\n assert_equal o.items.length, 1\n\n # It should not be empty.\n assert !o.empty?\n\n # Now it should be empty.\n o.remove_product(items(:red_lightsaber), 1)\n assert o.empty?\n end",
"def remove_coupon_in_cart\n cart = get_current_cart\n if cart.coupon\n cart.coupon = nil\n cart.discount_price = nil\n cart.save\n end\n end",
"def delete\n\t\t@cart.delete(:item_id)\n end",
"def merge!(order)\n if self.line_items.count > 0\n order.destroy\n else\n self.billing_address = self.billing_address || order.billing_address\n self.shipping_address = self.shipping_address || order.shipping_address\n order.line_items.each do |line_item|\n next unless line_item.currency == currency\n line_item.order_id = self.id\n line_item.save\n end\n\n end\n end",
"def checkout\n if @cart.items.empty?\n redirect_to_index(\"カートは現在空です\")\n else\n @order = Order.new\n end\n end",
"def destroy\n @purchase_order.destroy\n end",
"def destroy_from_cart\n unless cookies[:cart].nil?\n @cart = Cart.find_by_unique_identifier(cookies[:cart])\n @cart.delete_product(params[:catalog_id],params[:product_id])\n if @cart.save\n if @cart.products.size == 1\n products = @cart.products[0]\n if products[:products_count] == 0\n @cart.destroy\n cookies.delete(:cart)\n redirect_to root_url, :alert => t('cart.msg_cart_destroyed_no_products')\n else\n redirect_to show_mycart_path, :notice => t('cart.msg_del_prod')\n end\n else\n redirect_to show_mycart_path, :notice => t('cart.msg_del_prod')\n end\n else\n redirect_to show_mycart_path, :alert => t('cart.msg_no_del_prod')\n end\n else\n redirect_to root_url, :alert => t('cart.msg_nothing')\n end\n end",
"def check_if_cart_is_empty_or_session_cart_id_is_nil\n\n @cart = Cart.find_by(id: session[:cart_id]) if session[:cart_id] =! nil\n if session[:cart_id] == nil && @cart.order_items.empty?\n redirect_to root_path\n \n flash.notice = \"Please add any product before placing an order\"\n redirect_to root_path\n else\n end\n \n end",
"def clear_cart\n sleep(1)\n element = $driver.find_element(:css,\"#mini-cart-wrap > li > div.minicart-inner-div > a:nth-child(3) > span\") \n puts \"moving cursor to minicart\"\n $driver.action.move_to(element).perform\n\n sleep(2) \n begin\n empty_my_cart = $driver.find_element(:css,\"#minicart-bottom > p.pull-left > a\")\n sleep(1)\n empty_my_cart.click\n sleep(1)\n rescue \n\n puts \"cart is already empty\"\n end \n end",
"def destroy\n\t\t@cart = current_cart\n\t\t@cart.delete\n\n\t\tsession.delete(:aregos_cart_id)\n\n\t\tflash[:notice] = \"O carrinho de compras foi eliminado.\"\n\n\t\tredirect_to products_path\n\tend",
"def destroy\n @order.destroy\n respond_to do |format|\n format.html { redirect_to @cart }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @cart.id == session[:cart_id]\n session[:cart_id] = nil\n end\n\n respond_to do |format|\n format.html { redirect_to store_index_url, notice: \"Your cart is currently empty\" }\n format.json { head :no_content }\n end\n end",
"def my_cart\n @cart = @current_branch.carts.find(current_cart.id)\n @cart.line_items.where(:quantity => 0).destroy_all\n render layout: 'mobile/application'\n end",
"def remove_items\n system 'clear'\n CoffeeMan.stay_logo\n @@cart = @@cart.flatten\n cart_arr = @@cart \n if cart_arr.count == 0 \n puts \"Your cart is empty, please add items\"\n sleep 1\n view_cart\n end\n if cart_arr.count > 0 \n splitted_cart = cart_arr.split(\" \")\n selected_items = prompt.multi_select(\"Which item would you like to remove?\", splitted_cart)\n selected_items.each do |del| \n cart_arr.delete_at(cart_arr.index(del))\n end \n # @@cart = cart_arr\n sleep(0.6)\n view_cart\n end\n end",
"def destroy\n #@order = Order.find(params[:id])\n @order = current_order\n @order.destroy\n\n session[:order_id] = nil\n\n respond_to do |format|\n #format.html { redirect_to orders_url }\n format.html { redirect_to store_url, notice: 'Your order is currently empty' }\n format.json { head :no_content }\n end\n end",
"def remove_item(name, cart)\n \n if cart.delete(name) != nil\n puts 'Item successfully removed!'\n else\n puts 'No such item in cart!'\n end\n \n p cart\n \nend",
"def create\n candidateOrder = Order.new(email: params[:order][:Email],\n totalCost: cart_total,\n user: curr_user)\n cart.each do |pId, info|\n if (prod = Product.find_by(id: pId))\n if prod.stockCount > info[\"Num\"].to_i\n candidateOrder.order_entries.new(\n product: prod,\n quantity: info[\"Num\"].to_i,\n unitprice: prod.price,\n totalprice: prod.price * info[\"Num\"].to_i,\n order_id: candidateOrder.id\n )\n candidateOrder.order_entries.last.validate!\n if candidateOrder.valid?\n prod.stockCount -= info[\"Num\"].to_i\n Product.update(prod.id, stockCount: prod.stockCount)\n end\n end\n end\n end\n if candidateOrder.save!\n clear_cart\n redirect_to order_path(candidateOrder), notice: t(:order_placed)\n else\n redirect_to carts_path, error: t(:order_failed)\n end\n end",
"def reset_order!\n order.update(\n coupon_discount: 0,\n coupon_applied_at: nil,\n coupon_id: nil\n )\n end",
"def destroy\n @order = current_order\n @confirmed_order = ConfirmedOrder.new\n @confirmed_order.user_id = current_user.id\n @confirmed_order.payment_method = \"Cash\"\n @confirmed_order.payment_status = \"Not paid yet.\"\n @confirmed_order.save\n @orderlines = Orderline.where(\"order_id like ?\", current_order.id) \n @orderlines.each do |orderline|\n orderline.order_id = @confirmed_order.id\n orderline.save\n end\n\n session[:order_id] = nil\n respond_to do |format|\n if @confirmed_order.save\n format.html { redirect_to foods_path, notice: 'Your order was successfully placed.' }\n format.json { head :no_content }\n else\n format.html { render :new }\n format.json { render json: @confirmed_order.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def create\n @customer = CustomerManagement.find(order_params[:customer_id])\n if @customer.cart.address_id\n if @customer.cart_items.length > 0 \n location_same = false\n if @customer.cart.address.city && @customer.cart.address.city.downcase == current_location.downcase\n location_same = true \n end\n \n serve_all = true\n \n if !location_same\n @extra_cart_items = \"\"\n @customer.cart_items.each do |cart_item| \n if !((!cart_item.product_variant.location) || cart_item.product_variant.location == \"\")\n @temp_item = ProductVariant.where(:product_id => cart_item.product_variant.product_id, :location => @customer.cart.address.city, :value => cart_item.product_variant.value).first\n if @temp_item\n cart_item.update_columns(product_id: @temp_item.id, price: (@temp_item.price + (cart_item.include_service ? @temp_item.service_price : 0))) \n else\n @extra_cart_items = @extra_cart_items + \" & \" + cart_item.product.name\n serve_all = false\n end \n end \n end \n end\n \n if location_same || serve_all\n @order = Order.find_or_create_by(:customer_id => order_params[:customer_id],:active => true) \n @customer.cart_items.each do |cart_item| \n @order_to_product = OrderToProduct.where(:product_id => cart_item.product_id, :order_id => @order.id).first_or_create\n @order_to_product.update_price_quantity(cart_item.unit_price, cart_item.quantity,cart_item.include_service)\n cart_item.delete \n end\n @order.save\n @order.update_columns(address_id: @customer.cart.address_id, customer_id: @customer.id, active: true, additional_info: order_params[:additional_info],appointment_time: @customer.cart.appointment_time)\n @customer.cart.delete \n @customer.send_order_confirmation_mail(@order)\n redirect_to action: 'show', id: @order\n else\n redirect_back_or(root_url, notice: @extra_cart_items+\" can not be served at #{@customer.cart.address.city}\")\n end \n else\n redirect_back_or(root_url, notice: 'Empty Cart.')\n end\n else\n redirect_back_or(root_url, notice: 'Kindly select service address')\n end \n end",
"def build\n my_order = nil\n if cart = user && user.cart\n Order.transaction do\n my_order = Order.create(user: user)\n my_order.products = cart.products\n cart.destroy\n end\n else\n error = Struct.new(:full_messages).new\n error.full_messages = [\"No cart to create order from\"]\n @errors = error\n end\n my_order\n end",
"def checkout\n if session[:cart] then\n session[:cart] = nil\n redirect_to ('/shopper/new')\n flash[:notice] = \"Your order has been placed!\"\n else\n redirect_to ('/cart')\n flash[:notice] = \"Your cart is empty!\"\n end\n end",
"def remove\n @order.ig_remove_order\n redirect_to admin_orders_path\n end",
"def delCart\n session.delete(:cart_id)\n end",
"def create\n @order = Order.new(params[:order])\n @order.user_id = current_user.id\n @order.add_line_items_from_cart(current_cart)\n #logger.debug \"New order: #{@order.attributes.inspect}\"\n #logger.debug \"Order should be valid: #{@order.valid?}\"\n\n respond_to do |format|\n if @order.save\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.html { redirect_to(store_url, :notice =>\n 'Thank you for your order.') }\n format.xml { render :xml => @order, :status => :created,\n :location => @order }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @order.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @custom_cake_order.destroy\n respond_to do |format|\n format.html { redirect_to custom_cake_orders_url, notice: 'Custom cake order was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def active_archive class_name, symbol, record\n class_name.where(symbol => record.id).destroy_all unless record.carts.empty?\n record.orders.empty? ? record.destroy : Store.inactivate!(record)\n end",
"def empty_cart\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n view_cart_button.click\n wait_for_landing_page_load\n shopping_cart_label.should_exist\n\n # note: edit_link does NOT have to to be clicked to remove items, but we will perform steps\n unless (empty_cart_label.exists)\n len = timeout(1000).cart_list.length\n while len > 0\n shopping_cart_edit_link.should_exist\n shopping_cart_edit_link.click\n shopping_cart_edit_done_link.should_exist\n\n cart_list.at(0).remove_button.click\n wait_for_landing_page_load\n len-=1\n end\n end\n end",
"def destroy_all\n @order = current_order\n @basket_items = @order.basket_items\n @basket_items.clear\n redirect_to(:back)\n end",
"def remove\n transaction do\n destroy!\n order.remove_delivery_service_if_invalid\n self\n end\n end",
"def destroy\n @cart = current_cart\n #need to first destroy each of the line items\n @cart.line_items.each do |i|\n i.destroy\n end\n #now destroy the cart and set the cookie to nil so that it will request a new cookie.\n @cart.destroy if @cart.id == session[:cart_id]\n session[:cart_id] = nil\n respond_to do |format|\n format.html { redirect_to '/', notice: 'Cart was successfully emptied.' }\n format.json { head :no_content }\n end\n end",
"def clear_cart\r\n session[:cart] = []\r\n flash[:info] = 'Cart has been emptied!'\r\n redirect_to root_url\r\n end",
"def checkout\n @items = @cart.items\n if @items.empty?\n redirect_to_index(\"There's nothing in your cart!\")\n else\n @order = Order.new\n end\n end",
"def destroy\n if @order.update(order_status: OrderStatus::Canceled.first)\n respond_to do |format|\n format.html { redirect_to admin_preorders_url }\n format.json { head :no_content }\n end\n end\n end",
"def ensure_cart\n @cart = Order.find_by(id: session[:order_id])\n\n if @cart.nil?\n @cart = Order.make_cart\n session[:order_id] = @cart.id\n end\n\n if @cart.nil?\n flash[:error] = \"A problem occurred. The shopping cart could not be found.\"\n redirect_to root_path\n end\n\n @cart.status = \"pending\"\n @cart.save\n end",
"def destroy\n if @order.destroy\n build do\n message 'Удаление заказа'\n view 'consumer/orders/delete'\n end\n end\n end",
"def destroy\n @cart = current_cart\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def test_cleanup_failed\n setup_new_order()\n @o.order_line_items << @li\n @o.order_status_code = order_status_codes(:cart)\n @o.notes = \"test test\"\n assert @o.save\n \n notes_before = @o.notes.dup\n\n @o.cleanup_failed(\"A message!\")\n \n # Status code should be updated.\n assert_equal @o.order_status_code, order_status_codes(:on_hold_payment_failed)\n # A new note should be added.\n notes_after = @o.notes\n assert_not_equal notes_before, notes_after\n end",
"def test_add_product_with_negative_quantity\n a_cart = Order.new\n a_cart.add_product(items(:blue_lightsaber), 2)\n a_cart.add_product(items(:blue_lightsaber), -1)\n a_cart.reload\n # Calling add_product with a negative quantity should remove that many units\n assert_equal 1, a_cart.items[0].quantity\n a_cart.add_product(items(:blue_lightsaber), -3) \n# a_cart.reload\n assert a_cart.empty?\n end",
"def consume!(recipe_order)\n in_stock?(recipe_order) ? execute_command(:consume, recipe_order) : false\n end",
"def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end",
"def destroy\n\n in_order = OrderItem.find_by(item_id: @item.id)\n\n\n if in_order\n flash[:error] = \"Item cannot be deleted. There is a pending order with this item\"\n # redirect_back (fallback_location: root_path)\n redirect_back(fallback_location: root_path)\n else\n success = @item.destroy\n flash[:success] = \"Item successfully deleted.\"\n redirect_back(fallback_location: root_path)\n end\n\n end",
"def destroy\n @order.line_items.clear\n respond_to do |format| \n format.html { redirect_to(edit_object_url) } \n end\n end",
"def perform_empty_cart_and_return_message(session_id, owner_id, client_channel, locale, version)\n $tracer.trace(\"GameStopCartServiceDSL: #{__method__}, Line: #{__LINE__}\")\n $tracer.report(\"Should #{__method__}.\")\n remove_products_from_cart_rsp = nil\n line_item_guids = perform_get_cart_and_return_guids(session_id, owner_id, client_channel, locale, version)\n # why call to empty an empty cart if not needed?\n unless line_item_guids.empty?\n\n remove_products_from_cart_rsp = perform_remove_products_from_cart_and_return_message(session_id, owner_id, *line_item_guids, client_channel, locale, version)\n remove_products_from_cart_rsp.code.should == 200\n end\n\n return remove_products_from_cart_rsp\n end",
"def destroy\n @cart_item.destroy\n\n head :no_content\n end"
] | [
"0.66634125",
"0.6385331",
"0.637041",
"0.6333764",
"0.6294137",
"0.6226806",
"0.6210823",
"0.6205874",
"0.6202296",
"0.6192225",
"0.6157101",
"0.6145244",
"0.6136879",
"0.6035419",
"0.6035146",
"0.6029133",
"0.6014464",
"0.59497297",
"0.5945101",
"0.59246194",
"0.5895154",
"0.5881033",
"0.587198",
"0.5870298",
"0.5870105",
"0.585278",
"0.585278",
"0.5840947",
"0.58344966",
"0.5832572",
"0.5821763",
"0.5811188",
"0.5795965",
"0.57882833",
"0.57767546",
"0.5770338",
"0.57693106",
"0.57591385",
"0.57543963",
"0.5739855",
"0.5737386",
"0.57321215",
"0.57321215",
"0.5731883",
"0.5709363",
"0.56901634",
"0.56860626",
"0.5684317",
"0.56633717",
"0.5660833",
"0.56546336",
"0.56517893",
"0.56491834",
"0.5647817",
"0.5620714",
"0.5618176",
"0.5613838",
"0.56116384",
"0.5603989",
"0.5587366",
"0.55852824",
"0.55753976",
"0.5573466",
"0.5563135",
"0.5534568",
"0.55291605",
"0.55227476",
"0.5522612",
"0.5520379",
"0.55198216",
"0.5516735",
"0.55140376",
"0.5504307",
"0.55034286",
"0.5503365",
"0.54851246",
"0.54841715",
"0.54841",
"0.5482937",
"0.54808277",
"0.54740906",
"0.54693156",
"0.5468841",
"0.5467112",
"0.5461966",
"0.54605323",
"0.5459623",
"0.5459095",
"0.5456709",
"0.5444283",
"0.5435062",
"0.54289955",
"0.54283047",
"0.54241776",
"0.5423751",
"0.5422109",
"0.5421923",
"0.54156274",
"0.5412529",
"0.5410287"
] | 0.7631401 | 0 |
a random timeout in range range between the min timeout and twice that | def random_timeout
@IS_TIMEOUT_RANDOM ? @MIN_TIMEOUT + rand(@MIN_TIMEOUT) : @MIN_TIMEOUT
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_spawn_countdown minimum\n 10.randomize(:ratio, :sign).to_i + 60\n end",
"def random_duration\n min_duration + rand(max_duration - min_duration + 1)\n end",
"def sleep_time(attempt)\n 1 + (2**attempt) + rand(2**attempt)\n end",
"def sleep_time(attempt)\n 1 + (2**attempt) + rand(2**attempt)\n end",
"def sleep_time\n 1.0/(rand(10) + 1)\n end",
"def interval(retries)\n JITTER * (rand(2 ** retries - 1) + 1)\n end",
"def next\n Time.now + @min + Random.rand(@max - @min)\n end",
"def sleep_rand(min, max)\n sleep_time = rand(min..max)\n sleep(1)\n print_time_stamp\n puts \"Sleeping for #{sleep_time - 1} seconds ...\".colorize(:red)\n sleep(sleep_time - 1)\n end",
"def random_range_end(start)\n start + (rand(1..5) * 30).minutes\n end",
"def next_duration\n @durations.empty? ? rand(20) : @durations.shift\n end",
"def random_range_start\n base.to_datetime + (rand(1..30) * 30).minutes\n end",
"def random_on_interval(min, max)\n min + @prng.rand(max - min)\n end",
"def time_rand(from = 0.0, to = Time.now)\n Time.at(from + rand * (to.to_f - from.to_f))\nend",
"def time_rand from = 0.0, to = Time.now\n Time.at(from + rand * (to.to_f - from.to_f))\nend",
"def time_rand from = 0.0, to = Time.now\n Time.at(from + rand * (to.to_f - from.to_f))\nend",
"def next_interval\n if !@last_good_time.nil?\n good_duration = Time.now.to_f - @last_good_time\n @attempts = 0 if good_duration >= @reconnect_reset_interval\n end\n @last_good_time = nil\n target = ([@base_interval * (2 ** @attempts), @max_interval].min).to_f\n @attempts += 1\n if target == 0\n 0 # in some Ruby versions it's illegal to call rand(0)\n else\n (target / 2) + @jitter_rand.rand(target / 2)\n end\n end",
"def rand_time(from, to=Time.now)\n Time.at(rand(from.to_f..to.to_f))\nend",
"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 next_move_time\n delay = random.rand.clamp(1, 7)\n Time.current.to_f + delay\n end",
"def intervalRand(min, max)\r\n\treturn rand(max-min)+min\r\nend",
"def generate_random_time\n\t\trandom_value = Random.rand(0.0..1.0)\n\t\t(0..(@nbTSInOneDay - 1)).each do |ts|\n\t\t\treturn ts if @demandOverTimeCumulatedAndNormalised[ts] >= random_value\n\t\tend\n\tend",
"def gen_speed\n rand + 15.0\n end",
"def delay\n sleep(rand / 100)\n end",
"def timeout_after(time); end",
"def sleep_for(rate)\r\n -Math.log(1.0 - Random.rand) / rate\r\n end",
"def random_time_offset(max_minutes_offset=5)\n rand(max_minutes_offset) * (-1).power!(rand(2)) * 60\n end",
"def wait_for_seconds\n\t\tsleep(1 * rand + 1)\n\tend",
"def calc_rand_range\n range = Damage_Settings::RANDOM_RANGE\n rand(range)-range/2\n end",
"def reset_wait\n @wait = @t + rand(@t_rand)\n end",
"def XOwaitThinkTime(rangeTO)\n\t\tsleepTime= rand(rangeTO[0]..rangeTO[1])\n\t\t$alog.lwrite(('Sleeping for '+sleepTime.to_f.to_s+' s.'), 'DEBG')\n\t\tsleep(sleepTime)\n\t\treturn OK\n\tend",
"def random_sleep(how_much = SLEEP_GENERIC, multiplier = 1, min_base = 0)\n sleep_for = rand(how_much * multiplier) + min_base\n puts \"Sleeping for a random #{sleep_for} seconds\\n\"\n sleep(sleep_for)\n end",
"def time(min, max=nil)\n if max.nil? && min.respond_to?(:max)\n max = min.max\n min = min.min\n end\n \n start = Time.now\n Timeout::timeout(max) do\n while true\n yield\n if min.nil? || (Time.now - start) > min \n break\n end\n end\n end\n rescue Timeout::Error\n end",
"def simulate_roll(min = 1, max = 7)\n rand(max) + min\nend",
"def sleep_time\n 60\n end",
"def long_range (min, max)\n long = rand(0..(max - min)) + min\n long\nend",
"def delay_for_retry(retries, prng = Random::DEFAULT)\n maximum_wait = (2 ** [retries, 10].min) - 1\n slots_to_wait = prng.rand(0 .. maximum_wait)\n delay = (0.34 * slots_to_wait).round(2)\n end",
"def rand_between(min, max)\n rand(max - min + 1) + min\nend",
"def get_random(min, max)\r\n rand(min..max)\r\n end",
"def timeout_seconds\n return 1200\n end",
"def tirar_dado\r\n\trand 1..6\r\nend",
"def simulate_roll(min = 1, max = 5)\n rand(max)\nend",
"def timeout_at; end",
"def time_range min, max\n spawn :@trange, [min, max].map { |e| time_to_long e }\n end",
"def do_later(random_sleep_max_time = SLEEP_GENERIC, multiplier = 1, min_base = 0, &block)\n Thread.start do\n random_sleep(random_sleep_max_time, multiplier, min_base)\n block.call\n end\n end",
"def random_time_range(range)\n min = time_to_float(range.min)\n max = time_to_float(range.max)\n time = Time.at(random(min..max))\n\n if defined?(DateTime) && range.min.is_a?(DateTime)\n time = time.to_datetime\n elsif range.min.is_a?(Date)\n time = time.to_date\n end\n\n return time\n end",
"def random_ammount (min_amnt, max_amnt)\r\n random_ammt = (rand * (max_amnt - min_amnt) + min_amnt).round(2)\r\n return random_ammt\r\n end",
"def get_rand range\n\t\t@random_number = rand(range)\n\tend",
"def roll(min, max)\n return rand(min..max)\nend",
"def rand_range(min,max)\n return min + (max-min)*rand\nend",
"def rand(max=0) end",
"def new_random (min, max)\n\treturn (rand * (max-min) + min)\nend",
"def random_time_range\n i = Array((3..20)).sample\n [(Date.current - i.months).iso8601, (Date.current + i.months).iso8601]\n end",
"def rand_in_range(from, to); end",
"def rand_in_bounds(min, max)\n return min + (max-min)*rand()\nend",
"def tirar_dado\r\n rand 1..6\r\nend",
"def kick\n rng.rand(value_range)\n end",
"def randr(min, max)\n rand(max - min + 1) + min\nend",
"def usw_random(max=-1, min=0)\n Sass::Script::Number.new( max.to_i < 0 ? rand() : rand(min.to_i .. max.to_i ))\n end",
"def random_number(min, max)\n rand(max-min+1)+min\n end",
"def get_random floor, ceiling\n rand(floor..ceiling)\nend",
"def get_random_time(option)\n case option\n when '1 month'\n rand(1.month.ago..Time.now)\n when '3 months'\n rand(3.month.ago..Time.now)\n when '1 year'\n rand(1.year.ago..Time.now)\n when '3 years'\n rand(3.year.ago..Time.now)\n end\n end",
"def timeout_in\n 15.minutes\n end",
"def fake_cycles\n return if test?\n sleep(rand(0.25..0.75))\n end",
"def delay\n val = (self['min-time']/1000.0/60.0)\n val < 1 ? val.round(1) : val.round\n end",
"def rand_time( from = Time.now - 4.months, to = Time.now + 4.months)\n Time.at(from + rand * (to.to_time.to_f - from.to_time.to_f))\nend",
"def sleep_value\n 20\n end",
"def tirar_dado\n rand 1..6\nend",
"def question_timer(minutes)\n choice = :blank_answer\n Timeout::timeout(minutes * 60) do\n puts \"Времени на ответ в минутах: #{minutes}\"\n puts \"Выберите номер: \"\n choice = STDIN.gets.to_i\n end\n rescue Timeout::Error\n choice\nend",
"def delay(x=1) \n current_time = Time.now.to_i\n while Time.now.to_i - current_time < x \n\tend\nend",
"def get_random_span(from, to)\n rand(to - from) + from\nend",
"def delay_time\n end",
"def tirar_dado\n rand 1..6\nend",
"def tirar_dado\n rand 1..6\nend",
"def tirar_dado\n rand 1..6\nend",
"def random_within_range\n\t\t\trand(self.start_num..self.end_num)\n\t\tend",
"def rand(max)\n max-1\nend",
"def schedule_to_close_timeout; Float::INFINITY; end",
"def rut(min_rut: 1, max_rut: 99_999_999, fixed: false)\n @last_rut = fixed ? min_rut : rand_in_range(min_rut, max_rut)\n end",
"def default_timeout\n 900\n end",
"def wait_time(attempts)\n 2 ** (attempts.to_i + 2)\n end",
"def fake_time_from(time_ago = 1.year.ago)\n time_ago+(rand(8770)).hours\n end",
"def default_timeout\n 3\n end",
"def random(range)\n return rand(range + 1)\nend",
"def timeout=(_arg0); end",
"def timeout; end",
"def timeout; end",
"def timeout; end",
"def retry_delay(_ = nil)\n delay = backoff_strategy[retry_attempt] || backoff_strategy.last\n # if the values are the same don't bother generating a random number, if\n # the delta is zero, some platforms will raise an error\n if retry_delay_multiplicand_min == retry_delay_multiplicand_max\n delay_multiplicand = retry_delay_multiplicand_max\n else\n delay_multiplicand = \\\n rand(retry_delay_multiplicand_min..retry_delay_multiplicand_max)\n end\n (delay * delay_multiplicand).to_i\n end",
"def _timeout_in\n 1.minute\n end",
"def wait_for(wait_max: 3, step: 0.001, &block)\n stop_at = wait_max.seconds.from_now\n\n sleep step while !block.call && (@time = Time.now) < stop_at\n\n fail \"Timeout of #{wait_max} seconds exceeded!\" unless @time < stop_at\nend",
"def roll\n return rand(1..6)\nend",
"def dice(minimum, maximum)\n rand(minimum..maximum)\nend",
"def rand_in_range(from, to)\n rand * (to - from) + from\nend",
"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 timer\n time < 100 ? small_time : big_time\n end",
"def move_type_random\r\n case rand(6)\r\n when 0..3 then move_random\r\n when 4 then move_forward\r\n when 5 then @stop_count = 0\r\n end\r\n end",
"def random(min=0, max=0)\n if(min==0 && max==0)\n rand\n else\n min + rand(1+max-min)\n end\nend",
"def default_timeout\n 60\n end",
"def random_range(low, high)\n return random(high - low) + low\nend",
"def delay(seconds); end"
] | [
"0.78033787",
"0.73239774",
"0.72195065",
"0.71458316",
"0.70204043",
"0.690771",
"0.6897245",
"0.68336684",
"0.6808144",
"0.6771992",
"0.670791",
"0.6695353",
"0.661104",
"0.6572053",
"0.6572053",
"0.656234",
"0.6558265",
"0.6538337",
"0.6526226",
"0.6515465",
"0.64321285",
"0.6385558",
"0.6381695",
"0.6379333",
"0.63776284",
"0.6369287",
"0.63668567",
"0.6345914",
"0.6327826",
"0.62662303",
"0.62470263",
"0.6233699",
"0.6225614",
"0.6216165",
"0.618215",
"0.61781424",
"0.6149975",
"0.6138359",
"0.6100445",
"0.60980713",
"0.6091741",
"0.605996",
"0.6036118",
"0.6035626",
"0.6033538",
"0.60248464",
"0.5994021",
"0.59874403",
"0.5986615",
"0.59801257",
"0.5979396",
"0.59702057",
"0.596955",
"0.5947239",
"0.5946404",
"0.59127456",
"0.5910883",
"0.5904644",
"0.5893383",
"0.588445",
"0.5880876",
"0.58756095",
"0.58324873",
"0.58316845",
"0.58312654",
"0.58172274",
"0.5808686",
"0.5808634",
"0.58044964",
"0.5803958",
"0.5802523",
"0.57993376",
"0.57993376",
"0.57993376",
"0.5794739",
"0.57942533",
"0.57929105",
"0.5783732",
"0.5781002",
"0.5775366",
"0.5764459",
"0.5762581",
"0.5760671",
"0.5754935",
"0.57499975",
"0.57499975",
"0.57499975",
"0.57493246",
"0.57482606",
"0.57448274",
"0.57373184",
"0.573411",
"0.5723109",
"0.5715938",
"0.5704684",
"0.56952524",
"0.5693442",
"0.5686864",
"0.568678",
"0.56848836"
] | 0.84588003 | 0 |
Store the result of a call to this method in a wellnamed variable. | def add_all_numbers(array)
array.inject(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_result(result); end",
"def store_result()\n #This is a stub, used for indexing\n end",
"def result\n @@result\n end",
"def use_result\n store_result\n end",
"def result\n @result\n end",
"def result \n @result\n end",
"def result\n @result ||= calculate_result\n end",
"def store_result\n check_connection\n raise ClientError, 'invalid usage' unless @result_exist\n res = Result.new @fields, @protocol\n @server_status = @protocol.server_status\n @result_exist = false\n res\n end",
"def value(result)\n result\n end",
"def set_result\n @result = Result.new\n end",
"def get_result\n\t\texecute unless @result\n\t\treturn @result\n\tend",
"def get_execution_result\n @result\n end",
"def result\n\t\t@result\n\tend",
"def result\n\n fields['__result__']\n end",
"def return_value\n @return_value\n end",
"def result\n data(\"result\")\n end",
"def result\n end",
"def result(res)\n clear_eval\n puts Debugger::PROMPTS[:result] + res.to_s\n end",
"def result(res)\n clear_eval\n puts Debugger::PROMPTS[:result] + res.to_s\n end",
"def result=(value)\n Namespace.root.add_variable(variable_name, value)\n end",
"def result=(r)\n\n fields['__result__'] = r\n end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result\n self.result_payload[\"result\"] if self.result_payload\n end",
"def getResult\n return @out\n end",
"def result\n @result ||= build\n end",
"def get_result(result_type) ; add_result(result_type, false) ; end",
"def myreturn\n @myreturn\n end",
"def result\n meta.fetch(:result, :one)\n end",
"def set_result\n raw.data.status_code = raw.statusCode\n raw.data.status_text = raw.statusText\n @result = raw.data\n end",
"def result\n @result = yield\n end",
"def value!\n raise Result::Error, 'Failure objects do not have value'\n end",
"def result\n @data['result']\n end",
"def result=(_); end",
"def set_result\n results = result_params\n unless results.nil?\n if results.is_a?(String)\n parts = results.split(\"#\")\n @result = @measurement.results.find(parts[0].to_i)\n end\n end\n end",
"def result()\n end",
"def process(result)\n result\n end",
"def result\n operation.result\n end",
"def call()\r\n @logger.info([@type, \"#{@codeline}(#{@count}) #{@shortdescription} (temporary: #{@result.inspect})\"])\r\n @count += 1\r\n end",
"def record result; @success = true; end",
"def result=(value)\n target_address = @memory[@instruction_pointer + 3]\n @memory[target_address] = value\n end",
"def result\n results[0]\n end",
"def result(output)\n output\n end",
"def call()\n @logger.info([@type, \"#{@codeline}(#{@count}) #{@shortdescription} (temporary: #{@result.inspect})\"])\n @count += 1\n end",
"def value\n if @continuation\n @result = @continuation.call\n @continuation = nil\n end\n @result\n end",
"def process_result\n end",
"def original_result; end",
"def result\n self\n end",
"def result\n self\n end",
"def return_a_value\n name = \"Austin\"\n return name\n name = \"Brian\"\nend",
"def mystery()\n results = { 'sanity' => 'Hello' }\nend",
"def evaluation_result\n return @evaluation_result\n end",
"def process_result(new_result)\n self.result = new_result\n calculate\n end",
"def result?; end",
"def value!\n if ok?\n @value\n else\n raise @error\n end\n end",
"def apply_result\n return @apply_result\n end",
"def result\n @result ||= run_collection_command_or_block\n end",
"def add_result name, res\n \n end",
"def initialize\n @result = result\n end",
"def result\n @buffer\n end",
"def result\n\n end",
"def value\n return @value if defined? @value\n\n result = @future_result.result\n @value = if @block\n @block.call(result)\n else\n result\n end\n end",
"def __proxy_result__\n @proxy_result = @method_call.call unless defined?(@proxy_result)\n @proxy_result\n end",
"def get_data\n\t\texecute unless @result\n\t\treturn get_data_from_result(@result)\n\tend",
"def next_result()\n #This is a stub, used for indexing\n end",
"def assignation(result, var) #method\n var = get_dir(var)\n result = get_dir(result)\n @current_context[var] = get_value(result)\n end",
"def set_result\n @result = Api::V1::Result.find(params[:id])\n end",
"def evaluation_result=(value)\n @evaluation_result = value\n end",
"def return\n @v_return\n end",
"def result\n @result || :no_answer\n end",
"def result\n @result || :no_answer\n end",
"def returns val = nil\n @returns = val\n self\n end",
"def call\n expect :result\n\n self.last\n end",
"def return_value; end",
"def process_result res\n call = res[-1]\n\n check = check_call call\n\n if check and not @results.include? call\n @results << call\n\n if include_user_input? call[3]\n confidence = CONFIDENCE[:high]\n else\n confidence = CONFIDENCE[:med]\n end\n \n warn :result => res, \n :warning_type => \"Mass Assignment\", \n :message => \"Unprotected mass assignment\",\n :line => call.line,\n :code => call, \n :confidence => confidence\n end\n res\n end",
"def get_result(key)\n return @outputs[key]\n end",
"def successful_call\n return @successful_call\n end",
"def result\n Namespace.root.context.instance_variable_get(variable_name)\n end",
"def result(answer)\n puts answer\nend",
"def result(answer)\n puts answer\nend",
"def result(promise)\n @result.call(promise)\n end",
"def result(promise)\n @result.call(promise)\n end",
"def result_of_setting; end",
"def get_return_value exp, env = nil\n process_method exp, env\n value = make_return_value\n value.original_line = exp.line\n value\n end",
"def result\n\t\treturn get_tlv_value(TLV_TYPE_RESULT)\n\tend",
"def result\n\t\treturn get_tlv_value(TLV_TYPE_RESULT)\n\tend",
"def result\n results.first\n end",
"def result\n return @result if defined?(@result)\n @search.populate_hits\n @result\n end",
"def result\n @error = \"Error: the result is not being set!\" if flash[:result].nil?\n end",
"def return_value\n var_name\n end",
"def make_result_info\n end",
"def result_info\n return @result_info\n end",
"def result_info\n return @result_info\n end",
"def cast\n p @result\n end",
"def return_value=(value)\n @return_value = value\n end"
] | [
"0.72776747",
"0.72734886",
"0.71498",
"0.69414014",
"0.6851137",
"0.6845181",
"0.6659066",
"0.6609834",
"0.65169895",
"0.64686984",
"0.6456065",
"0.644434",
"0.6433526",
"0.63321227",
"0.62526274",
"0.6168087",
"0.61555797",
"0.61484444",
"0.61484444",
"0.6140094",
"0.6137905",
"0.6118753",
"0.6118753",
"0.6118753",
"0.6118753",
"0.6118753",
"0.6118753",
"0.6118753",
"0.6118753",
"0.61119676",
"0.611088",
"0.6110323",
"0.6107918",
"0.6089887",
"0.6066405",
"0.6055948",
"0.60321283",
"0.59944564",
"0.59788823",
"0.59726876",
"0.59528774",
"0.5943279",
"0.5941487",
"0.5910617",
"0.59022343",
"0.5857777",
"0.5844337",
"0.58384883",
"0.58263993",
"0.58156145",
"0.58014417",
"0.57968783",
"0.5785618",
"0.57814956",
"0.57814956",
"0.578097",
"0.5772314",
"0.5769987",
"0.5768748",
"0.5749807",
"0.5749331",
"0.5741123",
"0.57394904",
"0.573623",
"0.57358116",
"0.57298875",
"0.57208997",
"0.5711799",
"0.57085574",
"0.56840825",
"0.5681718",
"0.56782997",
"0.56755656",
"0.5666452",
"0.56597096",
"0.5657558",
"0.5657558",
"0.56428075",
"0.56310594",
"0.5612308",
"0.56090367",
"0.56027395",
"0.5597871",
"0.5590385",
"0.5579549",
"0.5579549",
"0.55757576",
"0.55757576",
"0.5574642",
"0.55669135",
"0.55594814",
"0.55594814",
"0.55580753",
"0.55504054",
"0.55455166",
"0.55418813",
"0.55397266",
"0.5536477",
"0.5536477",
"0.5525551",
"0.5524392"
] | 0.0 | -1 |
GET /micgroposts/1 GET /micgroposts/1.xml | def show
@micgropost = Micgropost.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @micgropost }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_posts(api_object)\r\n puts \"Current Post:\"\r\n doc = Nokogiri::XML.parse api_object.read\r\n contents= doc.xpath('posts/post/content').collect {|e| e.text }\r\n puts contents.join(\", \")\r\n puts \"\"\r\nend",
"def rss\n @events = Post.find(:all, {:conditions=> \"status=public\"},:order => \"id DESC\")\n render :layout => false\n headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def rss\n @headers[\"Content-Type\"] = \"application/xml\"\n @articles = Article.find(:all, \n :order => 'created_at DESC',\n :conditions => [\"articles.approved = ?\", true],\n :limit => 10\n )\n render :layout => false\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n end\n end",
"def index\n @posts = Post.limit 50\n @title = \"Weblog - last posts\"\n @updated = @posts.first.created_at unless @posts.empty?\n respond_to do |format|\n format.rss do\n redirect_to feeds_path(format: :atom),\n status: :moved_permanently\n end\n format.atom\n end\n end",
"def feed\r\n @posts = Post.all(:order => \"created_at DESC\")\r\n respond_to do |format|\r\n format.rss\r\n end\r\n end",
"def index\n @posts = Post.find_list(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n end\n end",
"def index\n @mush_crawlers = MushCrawler.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @mush_crawlers }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end",
"def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end",
"def index\n @page = params[:page] || '1'\n @forums = TogForum::Forum.find(:all, :order => 'id ASC').paginate({:page => @page})\n respond_to do |format|\n format.html\n format.rss { render :rss => @forums } \n end\n end",
"def index\n @magazines = Magazine.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @magazines }\n end\n end",
"def rss \n @vote_topics = VoteTopic.rss\n respond_to do |format|\n format.rss\n end\n end",
"def new\n @micgropost = Micgropost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @micgropost }\n end\n end",
"def index\n @posts = Post.find(:all, :order => :created_at)\n\n respond_to do |format|\n format.html # index.rhtml\n# format.xml { render :xml => @posts.to_xml }\n end\n end",
"def index\n @posts = Post.find(:all, :order=>'created_on DESC')\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @posts.to_xml }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n make_rss\n end",
"def rss\n @title = t('titles.news', brand: website.brand_name)\n @description = website.value_for(\"default_meta_tag_description\")\n @news = News.all_for_website(website)\n respond_to do |format|\n format.xml # render rss.xml.builder\n end\n end",
"def show\n @mush_crawler = MushCrawler.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mush_crawler }\n end\n end",
"def show\n @micropst = Micropst.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @micropst }\n end\n end",
"def index \n @kind = 'all'\n @recommands = Recommandation.paginate(:page => params[:page],:order => 'created_at DESC')\n \n respond_to do |format|\n format.html # index.html.erb\n format.rss \n end\n end",
"def index\n @posts = Post.published.page(params[:page]).per(5).ordered\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n end\n end",
"def index\n @mensagens = Mensagem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @mensagens }\n end\n end",
"def index\n @installation = Installation.find(params[:installation_id]) \n @onposts = @installation.onposts \n \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @onposts }\n end\n end",
"def list\r\n @posts = Post.paginate :page => params[:page], :per_page => 24, :order => \"created_at DESC\"\r\n\r\n respond_to do |format|\r\n\r\n format.html # list.html.erb\r\n format.xml { render :xml => @posts }\r\n end\r\n end",
"def index\n @posts = Post.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts,:layout => false }\n end\n end",
"def index\n\n\t\t# GET ALL THE BLOG POSTS\n @posts = Post.find(:all, :limit => 5)\n @downloads = Download.find(:all, :limit => 5, :conditions => {:parent_id => nil})\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n end\n end",
"def index\n @mini_blogs = MiniBlog.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @mini_blogs }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n format.json { render :json => @post }\n format.rss { render :layout => false }\n end\n end",
"def index\n @worldcup2011s = Worldcup2011.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @worldcup2011s }\n format.rss { render :xml => @worldcup2011s.to_rss_feed(\"World Cup 2011\",\"KillerMobi.com\", \"Comment for user\")}\n end\n end",
"def show\n @musica = Musica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @musica }\n end\n end",
"def show\n @post50 = Post50.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post50 }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @feed }\n end\n end",
"def index\n @posts = Mist::Post.recently_published(20, Mist.authorized?(:view_drafts, self))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def index\n @feeds = Feed.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @feeds.to_xml }\n end\n end",
"def show\n @post110 = Post110.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post110 }\n end\n end",
"def show\n @post101 = Post101.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post101 }\n end\n end",
"def rss\n\t\theaders[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\t\trender :layout => false\n\tend",
"def show\n @post75 = Post75.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post75 }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml { render xml: @posts }\n end\n end",
"def show\n @post150 = Post150.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post150 }\n end\n end",
"def show\n @post251 = Post251.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post251 }\n end\n end",
"def show\n @post78 = Post78.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post78 }\n end\n end",
"def index\n @posts = Post.all\n @title=\"All LitwakRecommends Posts\"\n\t@metadescription = \"Listing of all Posts for LitwakRecommends travel blog\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n end\n end",
"def show\n @post77 = Post77.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post77 }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def get_xml(params = {:format => :xml, :action => :query})#TODO put these in so that they're default and not lost when we pass stuff in...\n url = _form_url(params)\n \n #TODO wonder if I should make a generic library for external url requests, to standardize the header/etc?\n #requests without user-agents are refused. See:\n #http://www.mooduino.co.uk/2010/04/wikipedia-api-user-agent-string-in-php.html\n retries = 2\n begin\n http = Net::HTTP.new(WIKI_API_SERVER) #en.wikipedia.org\n resp = http.request_get(WIKI_API_PATH + url, 'User-Agent' => 'WikipediaAntiSpamBot/0.1 (+hincapie.cis.upenn.edu)')\n \n raise \"POST FAILED:\" + resp.inspect unless resp.is_a? Net::HTTPOK or resp.is_a? Net::HTTPFound\n #retry if resp.body.to_s.empty?\n resp.body\n rescue Net::HTTPBadResponse, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ECONNREFUSED, SocketError, \n Timeout::Error, Errno::EINVAL, EOFError, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e\n if retries > 0\n retries -= 1\n retry\n else\n raise Exception.new(\"Connection timed out after more than 3 retries: #{e}\")\n end\n end\nend",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @post.to_xml }\n end\n end",
"def index\n @imagens = Imagen.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @imagens }\n end\n end",
"def retrieve_posts(dir); end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def show\n @feed = Feed.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @feed.to_xml }\n end\n end",
"def show\n @post55 = Post55.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post55 }\n end\n end",
"def index\n @media = Medium.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @media }\n end\n end",
"def show\n @post120 = Post120.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post120 }\n end\n end",
"def rest_get(uri)\n \n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n return doc\n \n end\n \nend",
"def show\n @post306 = Post306.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post306 }\n end\n end",
"def show\n @post57 = Post57.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post57 }\n end\n end",
"def show\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n end \n end",
"def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end",
"def index\n authorize! :read, Post\n @posts = Post.accessible_by(current_ability).order('created_at DESC').paginate(:per_page => 15, :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n format.rss { render :layout => false } \n end\n end",
"def show\n @post231 = Post231.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post231 }\n end\n end",
"def show\n @post99 = Post99.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post99 }\n end\n end",
"def index\n @title = \"Home\"\n @posts = Post.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n format.json { render :json => @posts }\n format.atom # index.atom.builder\n end\n end",
"def index\n @medicamentos = Medicamento.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @medicamentos }\n end\n end",
"def show\n @post253 = Post253.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post253 }\n end\n end",
"def index\n@topic = Topic.find(params[:topic_id], :include => :forum)\n@posts = Post.find(:all, :conditions => ['topic_id = ?', @topic.id])\n@posts_pages = Post.find(:all, :conditions => ['topic_id = ?', @topic.id])\nrespond_to do |format|\nformat.html # index.rhtml\nformat.xml { render :xml => @posts.to_xml }\nend\nend",
"def show\n @post246 = Post246.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post246 }\n end\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @chronopay_links }\n end\n end",
"def index\n @noticias = Noticia.sorted\n respond_to do |format|\n format.html # index.html.erb\n format.rss { render :action => \"index.rxml\", :layout => false }\n format.xml { render :xml => @noticias }\n end\n end",
"def index\n @posts = Post.find(:all,:order => 'created_at DESC').paginate(:per_page => 5, :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n end\n end",
"def show\n @post257 = Post257.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post257 }\n end\n end",
"def show\n @rss_slide = RssSlide.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rss_slide }\n end\n end",
"def show\n @post74 = Post74.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post74 }\n end\n end",
"def show\n @post10 = Post10.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post10 }\n end\n end",
"def show\n @post85 = Post85.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post85 }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n# format.xml { render :xml => @post.to_xml }\n end\n end",
"def index\n @posts = Post.paginate(:page=>params[:page], :order=>'created_at desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @posts }\n end\n end",
"def index\n @titles = @medium.titles.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @titles }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def show\n @post328 = Post328.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post328 }\n end\n end",
"def index\n @posts = Post.all\n\n @title = \"Blog Management\"\n\n respond_to do |format| \n format.html { render :index }\n format.xml { render :xml => @posts.to_xml}\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end",
"def show\n @post109 = Post109.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post109 }\n end\n end",
"def show\n @post260 = Post260.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post260 }\n end\n end",
"def show\n @post181 = Post181.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post181 }\n end\n end",
"def show\n @post154 = Post154.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post154 }\n end\n end",
"def show\n @post81 = Post81.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post81 }\n end\n end",
"def show\n @post168 = Post168.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post168 }\n end\n end",
"def show\n @post134 = Post134.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post134 }\n end\n end",
"def show\n @post54 = Post54.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post54 }\n end\n end",
"def show\n @post107 = Post107.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post107 }\n end\n end",
"def index\n @musicas = Musica.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @musicas }\n end\n end",
"def index\n @jobs = Job.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.rss\n end\n end",
"def show\n @post470 = Post470.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post470 }\n end\n end",
"def show\n provides :xml, :json\n \n @post = Post[params[:id]]\n \n if content_type == :html\n render\n else\n display @post\n end\n end",
"def index\n @pagos = Pago.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pagos }\n end\n end",
"def show\n @post125 = Post125.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post125 }\n end\n end",
"def show\n @post65 = Post65.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post65 }\n end\n end",
"def news\n do_scrape\n @posts = UbuEntry.all(:order => \"id DESC\", :limit => 400)\n render :layout => false, :content_type => Mime::RSS\n end"
] | [
"0.64805603",
"0.6318034",
"0.610561",
"0.6098771",
"0.6098771",
"0.6064818",
"0.60271066",
"0.5996181",
"0.5965618",
"0.5929459",
"0.5924352",
"0.59225595",
"0.59167206",
"0.59113735",
"0.5907472",
"0.5889489",
"0.5881653",
"0.58808565",
"0.5875829",
"0.586296",
"0.58510685",
"0.584193",
"0.5837981",
"0.5834393",
"0.5828737",
"0.58270824",
"0.58126587",
"0.581043",
"0.5807767",
"0.5806749",
"0.58051234",
"0.57977253",
"0.5785419",
"0.57716405",
"0.5769742",
"0.5764729",
"0.57631975",
"0.5762554",
"0.5755899",
"0.5741435",
"0.5739247",
"0.57388395",
"0.57317305",
"0.57304406",
"0.57277715",
"0.572571",
"0.5724185",
"0.5715511",
"0.5713064",
"0.57079685",
"0.57078004",
"0.57050127",
"0.5701555",
"0.5698652",
"0.56964916",
"0.5694431",
"0.56877536",
"0.56861407",
"0.56822544",
"0.5681594",
"0.5677261",
"0.5673827",
"0.56705046",
"0.56695575",
"0.5664632",
"0.5664629",
"0.56628805",
"0.5662485",
"0.5662417",
"0.5660054",
"0.56565475",
"0.5653038",
"0.5651718",
"0.5650868",
"0.5650588",
"0.565018",
"0.5648776",
"0.5646904",
"0.56466275",
"0.564255",
"0.56395394",
"0.563603",
"0.56346583",
"0.56245023",
"0.5624201",
"0.5623664",
"0.5622758",
"0.5622695",
"0.56221175",
"0.56194526",
"0.56132156",
"0.560833",
"0.56057787",
"0.56048363",
"0.5604409",
"0.56032103",
"0.5598961",
"0.5597807",
"0.55962276",
"0.55929095"
] | 0.67286974 | 0 |
GET /micgroposts/new GET /micgroposts/new.xml | def new
@micgropost = Micgropost.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @micgropost }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n make_rss\n end",
"def new\n \n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post50 = Post50.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post50 }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post55 = Post55.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post55 }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post = Post.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @rssnew = Rssnews.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rssnew }\n end\n end",
"def new\n @post = Post.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post101 = Post101.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post101 }\n end\n end",
"def new\n @post78 = Post78.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post78 }\n end\n end",
"def new\n @post57 = Post57.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post57 }\n end\n end",
"def new\r\n @post = Post.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @post }\r\n end\r\n end",
"def new\r\n @post = Post.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @post }\r\n end\r\n end",
"def new\n @post = Post.new\n @publish = false\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post150 = Post150.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post150 }\n end\n end",
"def new\n @posts = Post.find(:all, :order => 'updated_at DESC')\n @post = Post.new\n @post.title = \"Überschrift*\"\n\n respond_to do |format|\n format.html { render :template => \"posts/new\" }\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post54 = Post54.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post54 }\n end\n end",
"def new\n @post328 = Post328.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post328 }\n end\n end",
"def new\n @post110 = Post110.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post110 }\n end\n end",
"def new\n @post253 = Post253.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post253 }\n end\n end",
"def new\n @post10 = Post10.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post10 }\n end\n end",
"def new\n @post306 = Post306.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post306 }\n end\n end",
"def new\n @post99 = Post99.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post99 }\n end\n end",
"def new\n @post305 = Post305.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post305 }\n end\n end",
"def new\n @post246 = Post246.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post246 }\n end\n end",
"def new\n @post120 = Post120.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post120 }\n end\n end",
"def new\n @post75 = Post75.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post75 }\n end\n end",
"def new\n @post = Post.new\n\t@posts = Post.all\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def new\n @post181 = Post181.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post181 }\n end\n end",
"def new\n @post156 = Post156.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post156 }\n end\n end",
"def new\n @post168 = Post168.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post168 }\n end\n end",
"def new\n @post74 = Post74.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post74 }\n end\n end",
"def new\n @post65 = Post65.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post65 }\n end\n end",
"def new\n @post58 = Post58.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post58 }\n end\n end",
"def new\n @post109 = Post109.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post109 }\n end\n end",
"def new\n @post77 = Post77.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post77 }\n end\n end",
"def new\n @post197 = Post197.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post197 }\n end\n end",
"def new\n @post85 = Post85.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post85 }\n end\n end",
"def new\n @post310 = Post310.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post310 }\n end\n end",
"def new\n @post227 = Post227.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post227 }\n end\n end",
"def new\n @post251 = Post251.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post251 }\n end\n end",
"def new\n @post125 = Post125.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post125 }\n end\n end",
"def new\n @post184 = Post184.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post184 }\n end\n end",
"def new\n @post106 = Post106.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post106 }\n end\n end",
"def new\n @post215 = Post215.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post215 }\n end\n end",
"def new\n @post350 = Post350.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post350 }\n end\n end",
"def new\n @post275 = Post275.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post275 }\n end\n end",
"def new\n @post107 = Post107.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post107 }\n end\n end",
"def new\n @post105 = Post105.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post105 }\n end\n end",
"def new\n @post68 = Post68.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post68 }\n end\n end",
"def new\n @post154 = Post154.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post154 }\n end\n end",
"def new\n @post231 = Post231.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post231 }\n end\n end",
"def new\n @post149 = Post149.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post149 }\n end\n end",
"def new\n @post248 = Post248.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post248 }\n end\n end",
"def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @monkey }\n end\n end",
"def new\n @post134 = Post134.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post134 }\n end\n end",
"def new\n @post290 = Post290.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post290 }\n end\n end",
"def new\n @post260 = Post260.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post260 }\n end\n end",
"def new\n @post230 = Post230.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post230 }\n end\n end",
"def new\n @post_o_matic_posting = PostOMaticPosting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post_o_matic_posting }\n end\n end",
"def new\n @post81 = Post81.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post81 }\n end\n end",
"def new\n @post48 = Post48.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post48 }\n end\n end",
"def new\n @post117 = Post117.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post117 }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @mini_blog = MiniBlog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mini_blog }\n end\n end",
"def new\n @post358 = Post358.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post358 }\n end\n end",
"def new\n @post295 = Post295.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post295 }\n end\n end",
"def new\n @post445 = Post445.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post445 }\n end\n end",
"def new\n @press = Press.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @press }\n end\n end",
"def new\n @post133 = Post133.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post133 }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n \n end\n end",
"def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end",
"def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end",
"def new\n @news = News.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @news }\n end\n end",
"def new\n @post453 = Post453.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post453 }\n end\n end",
"def new\n @post342 = Post342.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post342 }\n end\n end"
] | [
"0.76479656",
"0.72440803",
"0.72060794",
"0.7205934",
"0.7177021",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7155967",
"0.7151515",
"0.71405417",
"0.7137923",
"0.713497",
"0.71262324",
"0.7101622",
"0.7093188",
"0.7093188",
"0.7085584",
"0.708268",
"0.70738924",
"0.70717007",
"0.70695764",
"0.7066435",
"0.70622635",
"0.70608145",
"0.7059894",
"0.70593905",
"0.7056845",
"0.7046956",
"0.7042794",
"0.7037962",
"0.7037832",
"0.7031354",
"0.7025511",
"0.7022544",
"0.7018931",
"0.7014795",
"0.7009751",
"0.6998013",
"0.69944906",
"0.6990964",
"0.6986516",
"0.6984553",
"0.69807374",
"0.6980455",
"0.6980303",
"0.6973607",
"0.696865",
"0.69478714",
"0.6940706",
"0.69394696",
"0.6937406",
"0.69357246",
"0.6934111",
"0.69322056",
"0.6931833",
"0.6931484",
"0.69304997",
"0.69218165",
"0.69130504",
"0.6909791",
"0.69078207",
"0.69054526",
"0.69035715",
"0.68962455",
"0.6893016",
"0.6892249",
"0.6887674",
"0.6887674",
"0.6887674",
"0.6887674",
"0.6887674",
"0.6887674",
"0.6887565",
"0.6885575",
"0.68835074",
"0.6883211",
"0.68820566",
"0.6879372",
"0.6877305",
"0.68767977",
"0.68766797",
"0.68766797",
"0.68766797",
"0.6876629",
"0.6876275"
] | 0.7325873 | 1 |
POST /micgroposts POST /micgroposts.xml | def create
@micgropost = Micgropost.new(params[:micgropost])
respond_to do |format|
if @micgropost.save
format.html { redirect_to(@micgropost, :notice => 'Micgropost was successfully created.') }
format.xml { render :xml => @micgropost, :status => :created, :location => @micgropost }
else
format.html { render :action => "new" }
format.xml { render :xml => @micgropost.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def POST; end",
"def post #:doc:\n end",
"def test_should_create_post_via_API_XML\r\n get \"/logout\"\r\n post \"/forum_posts.xml\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n end",
"def post\n Rentlinx.client.post(self)\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def post_stomp(msg,headers)\n \n response_header = {\"Content-type\" => \"text/xml\"}\n response_header.merge headers\n ht =Net::HTTP.start(self.host,self.port)\n url = self.url # + \"/\" + self.topic\n puts \"posting to: #{self.host}: #{self.port} #{url} message: #{msg.to_xml}\"\n r=ht.post(url,msg.to_xml,response_header)\n \n puts \"result: #{r.to_s}\"\n r\n end",
"def send_post(data_xml,url)\r\n result = @client.post(self.target_uri(url), :body => data_xml , :head => {'Content-Type' => 'application/xml'} ) \r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200') \r\n #reply = Reply.from_xml(result.http_body)\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end",
"def post\n resource.post(request, response)\n end",
"def post_headers\n {\"Content-Type\" => 'text/xml; charset=utf-8'}\n end",
"def post; end",
"def create\n @micorpost = Micorpost.new(params[:micorpost])\n\n respond_to do |format|\n if @micorpost.save\n format.html { redirect_to @micorpost, notice: 'Micorpost was successfully created.' }\n format.json { render json: @micorpost, status: :created, location: @micorpost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @micorpost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post\r\n end",
"def post\n doc = Nokogiri::XML(request.body)\n id= (doc/'id').text\n # p = Post.exists?(id) ? Post.find(id) : Post.new\n p= Post.find_or_create_by_intranet_id id\n p.update_attributes :subject => (doc/'subject').text,\n :body => (doc/'body').text, :post_type => (doc/'post-type').text,\n :pic => (doc/'pic') .text, :begin_on=>(doc/'begin-on').text,\n :pic_postimg => (doc/'pic-postimg').text,\n :video => (doc/'video').text, \n :end_on => (doc/'end-on').text, :stick => (doc/'stick').text \n render :text => \"ok\"\n end",
"def post(*args)\n request :post, *args\n end",
"def create\n @micrrapost = Micrrapost.new(params[:micrrapost])\n\n respond_to do |format|\n if @micrrapost.save\n format.html { redirect_to @micrrapost, notice: 'Micrrapost was successfully created.' }\n format.json { render json: @micrrapost, status: :created, location: @micrrapost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @micrrapost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end",
"def post\n end",
"def post_xml(url, ls_data)\n uri = URI.parse(url)\n request = Net::HTTP::Post.new(uri.request_uri, HEADER_XML)\n request.body = ls_data\n request.basic_auth(@nsx_user, @nsx_password)\n response = Net::HTTP.start(uri.host, uri.port, :use_ssl => true,\n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|\n https.request(request)\n end\n return response.body if check_response(response, 201)\n end",
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end",
"def post(*args)\n request(:post, *args)\n end",
"def moip_post\n @nasp_rail = NaspRail.new(params[:nasp_rail])\n\n format.html { redirect_to @nasp_rail, :notice => 'Nova entrada criada com sucesso.' }\n format.json { render :json => @nasp_rail, :status => :created, :location => @nasp_rail }\n end",
"def metaWeblog_newPost(args)\n new_post_params = Hash.from_xml(args.children[3].to_s)['param']['value']['struct']['member']\n # title = new_post_params[0]['value']['string']\n title =''\n body = new_post_params[1]['value']['string']\n categories = []\n # categories = (new_post_params[2]['value']['array']['data']['value'].class == Array ? new_post_params[2]['value']['array']['data']['value'].map { |e| e['string'] } : [new_post_params[2]['value']['array']['data']['value']['string']] )\n tags = (new_post_params[3]['value']['array']['data']['value'].class == Array ? new_post_params[3]['value']['array']['data']['value'].map { |e| e['string'] } : [new_post_params[3]['value']['array']['data']['value']['string']] )\n ifttt_new_post(title, body, categories, tags)\n rpc_response(\"xml.value 'nothing'\")\n end",
"def post_config(url_prefix, xml)\n post_data(url_prefix, xml, 'application/xml;charset=UTF-8')\n end",
"def create\n @content = params[:content]\n uri = URI.parse(\"https://api.renren.com/v2/feed/put\")\n response = Net::HTTP.post_form(uri, {:access_token => get_access_token, :message => @content, :title => \"来自事件侠\" , :description => \".\" , :targetUrl => 'http://www.baidu.com'})\n @rtn = response.body.force_encoding('UTF-8') \n # @rtn = query_renren(\"feed_put\") \n end",
"def post(*args)\n Request.post(*args)\n end",
"def new\n @micgropost = Micgropost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @micgropost }\n end\n end",
"def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end",
"def post(method, params = {})\n url = make_url method, params\n query = url.query\n url.query = nil\n\n req = Net::HTTP::Post.new url.path\n req.body = query\n req.content_type = 'application/x-www-form-urlencoded'\n\n res = Net::HTTP.start url.host, url.port do |http|\n http.request req\n end\n\n xml = Nokogiri::XML(res.body, nil, nil, 0)\n\n check_error xml\n\n parse_response xml\n rescue SystemCallError, SocketError, Timeout::Error, IOError,\n Nokogiri::XML::SyntaxError => e\n raise CommunicationError.new(e)\n rescue Net::HTTPError => e\n xml = Nokogiri::XML(e.res.body) { |cfg| cfg.strict }\n check_error xml\n raise CommunicationError.new(e)\n end",
"def post_page file, token, key, tags, title\n server = Configuration.SERVER\n addr = Configuration.CLIOWL_ADDRESS\n\n # Builds the multipart data\n data = MultipartData.new\n data.add_field 'token', token\n data.add_field 'key', key\n data.add_field 'tags', tags\n data.add_field 'title', title\n \n file_content = File.read(file)\n data.add_file 'file', file, 'text/plain', file_content\n \n HttpHelper.post_multipart \"http://#{server}#{addr}/page\", data\n end",
"def create\n @mircopost = Mircopost.new(mircopost_params)\n\n respond_to do |format|\n if @mircopost.save\n format.html { redirect_to @mircopost, notice: 'Mircopost was successfully created.' }\n format.json { render :show, status: :created, location: @mircopost }\n else\n format.html { render :new }\n format.json { render json: @mircopost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def http_post(request, response)\n path = request.path\n\n # Only handling xml\n content_type = request.header('Content-Type')\n return nil unless content_type.index('application/xml') || content_type.index('text/xml')\n\n # Making sure the node exists\n begin\n node = @server.tree.node_for_path(path)\n rescue Dav::Exception::NotFound\n return nil\n end\n\n request_body = request.body_as_string\n\n # If this request handler could not deal with this POST request, it\n # will return 'null' and other plugins get a chance to handle the\n # request.\n #\n # However, we already requested the full body. This is a problem,\n # because a body can only be read once. This is why we preemptively\n # re-populated the request body with the existing data.\n request.body = request_body\n\n document_type_box = Box.new('')\n message = @server.xml.parse(request_body, request.url, document_type_box)\n document_type = document_type_box.value\n\n case document_type\n # Dealing with the 'share' document, which modified invitees on a\n # calendar.\n when \"{#{Plugin::NS_CALENDARSERVER}}share\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-calendar-share'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.update_shares(message.set, message.remove)\n\n response.status = 200\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n # The invite-reply document is sent when the user replies to an\n # invitation of a calendar share.\n when \"{#{Plugin::NS_CALENDARSERVER}}invite-reply\"\n\n # This only works on the calendar-home-root node.\n return true unless node.is_a?(CalendarHome)\n\n @server.transaction_type = 'post-invite-reply'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n url = node.share_reply(\n message.href,\n message.status,\n message.calendar_uri,\n message.in_reply_to,\n message.summary\n )\n\n response.status = 200\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n if url\n writer = @server.xml.writer\n writer.open_memory\n writer.start_document\n writer.start_element(\"{#{Plugin::NS_CALENDARSERVER}}shared-as\")\n writer.write(Dav::Xml::Property::Href.new(url))\n writer.end_element\n response.update_header('Content-Type', 'application/xml')\n response.body = writer.output_memory\n end\n\n # Breaking the event chain\n return false\n when \"{#{Plugin::NS_CALENDARSERVER}}publish-calendar\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-publish-calendar'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.publish_status = true\n\n # iCloud sends back the 202, so we will too.\n response.status = 202\n\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n when \"{#{Plugin::NS_CALENDARSERVER}}unpublish-calendar\"\n # We can only deal with IShareableCalendar objects\n return true unless node.is_a?(IShareableCalendar)\n\n @server.transaction_type = 'post-unpublish-calendar'\n\n # Getting ACL info\n acl = @server.plugin('acl')\n\n # If there's no ACL support, we allow everything\n acl.check_privileges(path, '{DAV:}write') if acl\n\n node.publish_status = false\n\n response.status = 200\n\n # Adding this because sending a response body may cause issues,\n # and I wanted some type of indicator the response was handled.\n response.update_header('X-Sabre-Status', 'everything-went-well')\n\n # Breaking the event chain\n return false\n end\n end",
"def post_multipart(method, params = {})\n url = make_url method, {}\n url.query = nil\n\n boundary, data = make_multipart params\n\n req = Net::HTTP::Post.new url.path\n req.content_type = \"multipart/form-data; boundary=#{boundary}\"\n req.body = data\n\n res = Net::HTTP.start url.host, url.port do |http|\n http.request req\n end\n\n xml = Nokogiri::XML(res.body, nil, nil, 0)\n\n check_error xml\n\n parse_response xml\n rescue SystemCallError, SocketError, Timeout::Error, IOError,\n Nokogiri::XML::SyntaxError => e\n raise CommunicationError.new(e)\n rescue Net::HTTPError => e\n xml = Nokogiri::XML(e.res.body, nil, nil, 0)\n check_error xml\n raise CommunicationError.new(e)\n end",
"def post_query( xml )\n url = URI.parse( self.url )\n response = self.http.post_form( url, { \"query\" => xml } )\n return response.body\n end",
"def post_data; end",
"def post_data(xml)\n \"load=#{CGI.escape(xml)}\"\n end",
"def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x|\n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x|\n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def post(path, **args); end",
"def post_business(business, location)\n xml = Builder::XmlMarkup.new\n query = xml.tag!(\"BPMSPost\", 'Edition' => \"1.1\") {\n xml.tag!(\"Record\") {\n xml.tag!(\"Phone\", location.phone)\n xml.tag!(\"BusinessName\", location.location_name)\n xml.tag!(\"Address\", location.address)\n xml.tag!(\"City\", location.city)\n xml.tag!(\"State\", location.state)\n xml.tag!(\"Zip\", location.zip)\n xml.tag!(\"URL\", location.website_url)\n xml.tag!(\"TagLine\", location.special_offer)\n #xml.tag!(\"LogoImage\", location.logo)\n xml.tag!(\"Categories\") {\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Primary\")\n xml.tag!(\"Name\", business.industry_primary)\n }\n if business.industry_alt_1.present?\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Alt1\")\n xml.tag!(\"Name\", business.industry_alt_1)\n }\n end\n if business.industry_alt_2.present?\n xml.tag!(\"Category\") {\n xml.tag!(\"Type\", \"Alt2\")\n xml.tag!(\"Name\", business.industry_alt_2)\n }\n end\n }\n }\n }\n body = build_request(3700, 1510, query)\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n xml_doc['Error'] == '0' # success (returns true/false)\n end",
"def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x| \n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x| \n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end",
"def create(name=\"Default name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Post.new(@url)\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n response.body\n end",
"def post(body)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if uri.scheme == 'https'\n\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'text/xml'\n request['Accept-Language'] = locale if locale\n request.body = body\n\n response = http.request(request)\n\n Response.new(response, uri)\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def create\n @miccropost = Miccropost.new(params[:miccropost])\n\n respond_to do |format|\n if @miccropost.save\n format.html { redirect_to @miccropost, notice: 'Miccropost was successfully created.' }\n format.json { render json: @miccropost, status: :created, location: @miccropost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @miccropost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(content)\n post_to(\"/api/v1/messages/\", {:body => content})\n end",
"def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end",
"def remote_create(content)\n content = content.to_xml unless content.kind_of? String\n remote_post content\n 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 post()\n return @http.request(@req)\n end",
"def postSales_logSyndication( action_type, syndication_type, publisher_id, expiry_date, entity_id, group_id, seed_masheryid, supplier_masheryid, country, reseller_masheryid)\n params = Hash.new\n params['action_type'] = action_type\n params['syndication_type'] = syndication_type\n params['publisher_id'] = publisher_id\n params['expiry_date'] = expiry_date\n params['entity_id'] = entity_id\n params['group_id'] = group_id\n params['seed_masheryid'] = seed_masheryid\n params['supplier_masheryid'] = supplier_masheryid\n params['country'] = country\n params['reseller_masheryid'] = reseller_masheryid\n return doCurl(\"post\",\"/sales_log/syndication\",params)\n end",
"def api_post(action, data)\n api_request(action, data, 'POST')\n end",
"def post_http(args)\n\t\t return(Net::HTTP.post_form @uri, args)\t\t\t\n \tend",
"def create\n @micropst = Micropst.new(params[:micropst])\n\n respond_to do |format|\n if @micropst.save\n format.html { redirect_to(@micropst, :notice => 'Micropst was successfully created.') }\n format.xml { render :xml => @micropst, :status => :created, :location => @micropst }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @micropst.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(uri, options = {})\n if options[:multipart]\n form_input = build_multipart_data(options)\n build_response(request.post(uri, build_request_options({\"CONTENT_TYPE\" => \"multipart/form-data, boundary=Mack-boundary\", \"CONTENT_LENGTH\" => form_input.size, :input => form_input})))\n else\n build_response(request.post(uri, build_request_options({:input => options.to_params})))\n end\n end",
"def post(data = \"\")\n submit :Post, data\n end",
"def create\n megam_rest.post_appdefn(to_hash)\n end",
"def post(data)\n uri = URI(@host)\n res = Net::HTTP.post_form(uri, {shell: data})\n # puts res.body\nend",
"def post(content)\n remote_post_to(@uri, content)\n end",
"def create\n @micropost = spree_current_user.microposts.build(micropost_params)\n @micropost.handbag_id = params[:micropost][:handbag_id]\n if @micropost.save\n flash[:success] = \"Post added!\"\n redirect_to :back\n else\n flash[:error] = \"Make sure text is added.\"\n redirect_to :back\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/rewardsaccount/v1\")\n end",
"def post_nodes_with_root\n serialize_service.post_nodes_serialized\n end",
"def test_post_invoices_xml \n Redmine::ApiTest::Base.should_allow_api_authentication(:post,\n '/invoices.xml',\n {:invoice => {:project_id => 1, :number => 'INV/TEST-1'}},\n {:success_code => :created})\n \n assert_difference('Invoice.count') do\n post '/invoices.xml', {:invoice => {:project_id => 1, :number => 'INV/TEST-1', :contact_id => 1, :status_id => 1, :invoice_date => Date.today}}, credentials('admin')\n end\n\n invoice = Invoice.first(:order => 'id DESC')\n assert_equal 'INV/TEST-1', invoice.number\n \n assert_response :created\n assert_equal 'application/xml', @response.content_type\n assert_tag 'invoice', :child => {:tag => 'id', :content => invoice.id.to_s}\n end",
"def post(data = {})\n call data, method: :post\n end",
"def post!\n request! :post\n end",
"def create\n @post_o_matic_posting = PostOMaticPosting.new(params[:post_o_matic_posting])\n\n respond_to do |format|\n if @post_o_matic_posting.save\n flash[:success] = 'Post-O-Matic Posting was successfully created.'\n format.html { redirect_to(admin_post_o_matic_postings_url) }\n format.xml { render :xml => @post_o_matic_posting, :status => :created, :location => @post_o_matic_posting }\n else\n flash[:error] = 'Post-O-Matic Posting could not be created. See errors below.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post_o_matic_posting.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_appreq(to_hash)\n end",
"def post(*args)\n execute(:post, *args)\n end",
"def post(action, **args); end",
"def create\n @medio = Medio.new(params[:medio])\n\n respond_to do |format|\n if @medio.save\n flash[:notice] = 'Medio was successfully created.'\n format.html { redirect_to(@medio) }\n format.xml { render :xml => @medio, :status => :created, :location => @medio }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(body)\n server = XMLRPC::Client.new2('http://www.juggernautguild.com/interface/board/')\n\n response = server.call('postTopic', {\n :api_module => 'ipb',\n :api_key => Juggernaut[:ipb_api_key],\n :member_field => 'id',\n :member_key => 4095, # Attendance\n :forum_id => 10,\n :topic_title => self.to_s,\n :post_content => body\n })\n end",
"def postRelationship(oapID, userPropID)\n toPost = Nokogiri::XML::Builder.new { |xml|\n xml.send('import-relationship', 'xmlns' => \"http://www.symplectic.co.uk/publications/api\") {\n xml.send('from-object', \"publication(source-c-inst-1,pid-#{oapID})\")\n xml.send('to-object', \"user(pid-#{userPropID})\")\n xml.send('type-name', \"publication-user-authorship\")\n }\n }.to_xml\n uri = URI(\"#{$elementsAPI}/relationships\")\n\n # Log what we're about to POST.\n $transLog.write(\"\\n---------------------------------------------------------------\\n\")\n $transLog.write(\"\\nPOST #{uri}\\n\\n\")\n $transLog.write(toPost)\n\n if $testMode\n puts \"(test mode: skipping real put)\"\n return\n end\n\n # And put it\n (1..10).each { |tryNumber|\n\n puts \" Posting relationship for user ID #{userPropID}.\"\n req = Net::HTTP::Post.new(uri)\n req['Content-Type'] = 'text/xml'\n req.basic_auth $apiCred[0], $apiCred[1]\n req.body = toPost\n res = $elementsAPIConn.request(req)\n\n # Log the response\n $transLog.write(\"\\nResponse:\\n\")\n $transLog.write(\"#{res} code=#{res.code} message=#{res.message.inspect}\\n\")\n $transLog.write(\"#{res.body.start_with?('<?xml') ? Nokogiri::XML(res.body, &:noblanks).to_xml : res.body}\\n\")\n\n # HTTPConflict and HTTPGatewayTimeOut happen occasionally, and are likely transitory\n if res.is_a?(Net::HTTPConflict) || res.is_a?(Net::HTTPGatewayTimeOut)\n puts \" Note: failed due to #{res} (likely a transitory concurrency issue).\"\n if tryNumber < 20\n puts \" Will retry after a 30-second pause.\"\n sleep 30\n next\n else\n puts \" Out of retries. Aborting.\"\n end \n end\n\n # Fail if the POST failed.\n res.is_a?(Net::HTTPSuccess) or raise(\"Error: post failed: #{res}\")\n\n # Otherwise, we're done.\n return\n }\nend",
"def post payload, path = \"\" \n make_request(path, \"post\", payload)\n end",
"def save\n self.client.api_post(\"/feed\", self.create_params)\n end",
"def http_post(request, response)\n content_type = request.header('Content-Type')\n content_type = content_type.split(';').first\n\n if content_type != 'application/x-www-form-urlencoded' &&\n content_type != 'multipart/form-data'\n return nil\n end\n\n post_vars = request.post_data\n return nil unless post_vars.key?('sabreAction')\n\n uri = request.path\n\n if @server.emit('onBrowserPostAction', [uri, post_vars['sabreAction'], post_vars])\n\n case post_vars['sabreAction']\n when 'mkcol'\n if post_vars.key?('name') && !post_vars['name'].blank?\n # Using basename because we won't allow slashes\n folder_name = Http::UrlUtil.split_path(post_vars['name'].strip)[1]\n\n if post_vars.key?('resourceType')\n resource_type = post_vars['resourceType'].split(',')\n else\n resource_type = ['{DAV:}collection']\n end\n\n properties = {}\n post_vars.each do |var_name, var_value|\n # Any _POST variable in clark notation is treated\n # like a property.\n next unless var_name[0] == '{'\n var_name = var_name.gsub('*DOT*')\n properties[var_name] = var_value\n end\n\n mk_col = MkCol.new(resource_type, properties)\n @server.create_collection(uri + '/' + folder_name, mk_col)\n end\n when 'put' # FIXME\n # USE server.http_request.post_data (Rack.POST)\n file = nil\n server.http_request.params.each do |_, value|\n if value.is_a?(Rack::Multipart::UploadedFile)\n file = value\n break\n end\n end\n\n if file\n # Making sure we only have a 'basename' component\n new_name = ::File.basename(file.original_filename).strip\n\n if post_vars.key?('name') && !post_vars['name'].blank?\n new_name = ::File.basename(post_vars['name']).strip\n end\n\n # is there a necessary equivalent in ruby?\n # if (is_uploaded_file(file['tmp_name'])) {\n @server.create_file(\"#{uri}/#{new_name}\", ::File.open(file.path), 'r')\n # end\n end\n end\n end\n\n response.update_header('Location', request.url)\n response.status = 302\n false\n end",
"def create\n \n @onpost = Onpost.new(params[:onpost])\n respond_to do |format|\n if @onpost.save\n flash[:notice] = 'Onpost was successfully created.'\n format.html { redirect_to :back }\n format.xml { render :xml => @onpost, :status => :created, :location => @onpost }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @onpost.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n res = self.class.post('/', body: attrs)\n res.created?\n end",
"def create\n @mwod_post = MwodPost.new(params[:mwod_post])\n\n respond_to do |format|\n if @mwod_post.save\n format.html { redirect_to @mwod_post, notice: 'Mwod post was successfully created.' }\n format.json { render json: @mwod_post, status: :created, location: @mwod_post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mwod_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit\n obj = ActiveSupport::Inflector.constantize(self.class.to_s.gsub(/Builder/, ''))\n obj.new(Client.post_xml_request(to_s))\n end",
"def create(input)\n @response = self.request(Net::HTTP::Post.new(\n \"/stikkits.atom?raw_text=#{CGI.escape(input)}\"\n ))\n #-- TODO: This should be processed and useful output presented\n #++\n puts @response.body\n end",
"def post(body)\n request = Net::HTTP::Post.new(bind_uri)\n request.body = body\n request.content_length = request.body.size\n request[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\n Jabber.debug(\"Sending POST request - #{body.strip}\")\n\n response = Net::HTTP.new(domain, port).start { |http| http.request(request) }\n\n Jabber.debug(\"Receiving POST response - #{response.code}: #{response.body.inspect}\")\n\n unless response.is_a?(Net::HTTPSuccess)\n raise Net::HTTPBadResponse, \"Net::HTTPSuccess expected, but #{response.class} was received\"\n end\n\n response\n end",
"def do_submission(path, xml = nil)\n if xml.nil?\n form = create(:form, question_types: %w(integer integer))\n form.publish!\n xml = build_odk_submission(form)\n end\n\n # write xml to file\n require 'fileutils'\n FileUtils.mkpath('test/fixtures')\n fixture_file = Rails.root.join('test/fixtures/', ODK_XML_FILE)\n File.open(fixture_file.to_s, 'w') { |f| f.write(xml) }\n\n # Upload and do request.\n uploaded = fixture_file_upload(fixture_file, 'text/xml')\n post(path, {:xml_submission_file => uploaded, :format => 'xml'}, 'HTTP_AUTHORIZATION' => encode_credentials(@user.login, 'password'))\n assigns(:response)\n end",
"def post(attrs = nil)\n attrs ||= attributes\n\n execute_request('POST') do |uri, headers|\n HTTP.http_client.post(\n uri,\n body: adapter.serialize(attrs),\n header: headers.merge(CONTENT_TYPE_HEADERS)\n )\n end\n end",
"def post(path, data={})\n request(:post, path, data)\n end",
"def api_call(action, xml_data)\n require 'net/http'\n require 'uri'\n current_url = URL;\n if action != 'get-queue'\n get_server(@@_target_type_options[@@_target_type]);\n end\n uri = URI.parse(current_url+\"/\"+action)\n http = Net::HTTP.new(uri.host,uri.port)\n request=Net::HTTP::Post.new(uri.request_uri);\n request.set_form_data({ \"queue\"=> array_to_xml(xml_data,\"\")})\n return http.request(request).body\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def post_request(url,args)\n uri = URI.parse(url)\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data(args)\n request(uri,req)\n end",
"def ems\n GatewayMessage.store( params[:xml] )\n render :text => 'OK'\n end",
"def create\n @post251 = Post251.new(params[:post251])\n\n respond_to do |format|\n if @post251.save\n format.html { redirect_to(@post251, :notice => 'Post251 was successfully created.') }\n format.xml { render :xml => @post251, :status => :created, :location => @post251 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post251.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(path, options={})\n request :post, path, options\n end",
"def create\n @musica = Musica.new(params[:musica])\n\n respond_to do |format|\n if @musica.save\n flash[:notice] = 'Musica was successfully created.'\n format.html { redirect_to(@musica) }\n format.xml { render :xml => @musica, :status => :created, :location => @musica }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @musica.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n @post.update_attribute(:user_id, current_user.id)\n\n respond_to do |format|\n if @post.save\n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to(@post) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n make_rss\n end",
"def post\n _root_document\n end",
"def post(path, params={})\n signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params\n request(:post, path, params.to_xml, signature_params)\n end",
"def create\n @post78 = Post78.new(params[:post78])\n\n respond_to do |format|\n if @post78.save\n format.html { redirect_to(@post78, :notice => 'Post78 was successfully created.') }\n format.xml { render :xml => @post78, :status => :created, :location => @post78 }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post78.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/creditaccount/v1\")\n end",
"def generate_tags\n uri = URI.parse(\"https://api.thomsonreuters.com/permid/calais\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n post_body = []\n post_body << \"<Document><Body>\"\n # stip html\n post_body << ActionView::Base.full_sanitizer.sanitize(params[:desc])\n # no strip\n # post_body << params[:desc]\n post_body << \"</Body></Document>\"\n request = Net::HTTP::Post.new(uri.request_uri)\n request.add_field(\"Content-Type\",\"text/xml\")\n request.add_field(\"outputFormat\",\"application/json\")\n #request.add_field(\"outputFormat\",\"text/n3\") \n request.add_field(\"x-ag-access-token\",\"fY7WUM3GGCXHm9ATOhtzhrvlWX8oPo5X\")\n request.body = post_body.join\n # request[\"Content-Type\"] = \"multipart/form-data, boundary=#{BOUNDARY}\"\n\n render :json => http.request(request).body\n end"
] | [
"0.6155047",
"0.59201044",
"0.5782277",
"0.57359266",
"0.5703269",
"0.56660265",
"0.5655883",
"0.5655153",
"0.5654222",
"0.5651607",
"0.5647657",
"0.56224954",
"0.5619249",
"0.560516",
"0.56026596",
"0.55709404",
"0.554982",
"0.55453354",
"0.5538349",
"0.5529064",
"0.552828",
"0.549966",
"0.54917866",
"0.5488965",
"0.54844725",
"0.54562515",
"0.5452333",
"0.54491776",
"0.54248655",
"0.5418692",
"0.5391321",
"0.5375233",
"0.5356503",
"0.53549457",
"0.5351808",
"0.53110707",
"0.5308671",
"0.52806586",
"0.52627665",
"0.52580297",
"0.5255507",
"0.5252321",
"0.5247835",
"0.5237374",
"0.52250075",
"0.5222902",
"0.51900923",
"0.5186312",
"0.517868",
"0.51634556",
"0.51616234",
"0.51613206",
"0.51523614",
"0.5151814",
"0.5149763",
"0.5143876",
"0.5128066",
"0.51254475",
"0.5123595",
"0.5122187",
"0.51216847",
"0.512066",
"0.5110058",
"0.50896716",
"0.5086695",
"0.5072288",
"0.5066396",
"0.50650746",
"0.50591826",
"0.5056446",
"0.504267",
"0.5037133",
"0.50348437",
"0.5026767",
"0.5023219",
"0.5018543",
"0.500803",
"0.5001529",
"0.49922815",
"0.49805516",
"0.49703664",
"0.49637997",
"0.49483907",
"0.49401793",
"0.49355304",
"0.49295077",
"0.49131685",
"0.49048388",
"0.49026054",
"0.49023655",
"0.4898103",
"0.4895149",
"0.489504",
"0.48942995",
"0.48929882",
"0.48918727",
"0.4891636",
"0.48818228",
"0.48773107",
"0.4868829"
] | 0.6498641 | 0 |
PUT /micgroposts/1 PUT /micgroposts/1.xml | def update
@micgropost = Micgropost.find(params[:id])
respond_to do |format|
if @micgropost.update_attributes(params[:micgropost])
format.html { redirect_to(@micgropost, :notice => 'Micgropost was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @micgropost.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(@post) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n make_rss\n end",
"def post\n doc = Nokogiri::XML(request.body)\n id= (doc/'id').text\n # p = Post.exists?(id) ? Post.find(id) : Post.new\n p= Post.find_or_create_by_intranet_id id\n p.update_attributes :subject => (doc/'subject').text,\n :body => (doc/'body').text, :post_type => (doc/'post-type').text,\n :pic => (doc/'pic') .text, :begin_on=>(doc/'begin-on').text,\n :pic_postimg => (doc/'pic-postimg').text,\n :video => (doc/'video').text, \n :end_on => (doc/'end-on').text, :stick => (doc/'stick').text \n render :text => \"ok\"\n end",
"def put(*args)\n request :put, *args\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 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 update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end",
"def put!\n request! :put\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @magazine = Magazine.find(params[:id])\n\n respond_to do |format|\n if @magazine.update_attributes(params[:magazine])\n flash[:notice] = 'Magazine was successfully updated.'\n format.html { redirect_to(@magazine) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @magazine.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end",
"def update\n @micropst = Micropst.find(params[:id])\n\n respond_to do |format|\n if @micropst.update_attributes(params[:micropst])\n format.html { redirect_to(@micropst, :notice => 'Micropst was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @micropst.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def put(path, collection)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = @media_type\n\n response = case @media_type\n when 'application/occi+json'\n self.class.post(@endpoint + path,\n :body => collection.to_json,\n :headers => headers)\n when 'text/occi'\n self.class.post(@endpoint + path,\n :headers => collection.to_header.merge(headers))\n else\n self.class.post(@endpoint + path,\n :body => collection.to_text,\n :headers => headers)\n end\n\n response_msg = response_message response\n\n case response.code\n when 200, 201\n Occi::Parser.parse(response.header[\"content-type\"].split(\";\").first, response)\n else\n raise \"HTTP POST failed! #{response_msg}\"\n end\n end",
"def put(path, collection)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = @media_type\n\n response = case @media_type\n when 'application/occi+json'\n self.class.post(@endpoint + path,\n :body => collection.to_json,\n :headers => headers)\n when 'text/occi'\n self.class.post(@endpoint + path,\n :headers => collection.to_header.merge(headers))\n else\n self.class.post(@endpoint + path,\n :body => collection.to_text,\n :headers => headers)\n end\n\n response_msg = response_message response\n\n case response.code\n when 200, 201\n Occi::Parser.parse(response.header[\"content-type\"].split(\";\").first, response.body)\n else\n raise \"HTTP POST failed! #{response_msg}\"\n end\n end",
"def put(*args)\n request(:put, *args)\n end",
"def update\n @micorpost = Micorpost.find(params[:id])\n\n respond_to do |format|\n if @micorpost.update_attributes(params[:micorpost])\n format.html { redirect_to @micorpost, notice: 'Micorpost was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @micorpost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @micrrapost = Micrrapost.find(params[:id])\n\n respond_to do |format|\n if @micrrapost.update_attributes(params[:micrrapost])\n format.html { redirect_to @micrrapost, notice: 'Micrrapost was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @micrrapost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(uri, doc = nil, options = {})\n execute(uri, :put, options, doc)\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end",
"def update\n DOCUMENT_PATHS.each do |attr_name, path|\n if path.match(/\\*/)\n instance_variable_get(\"@#{attr_name}\").each do |simple_file_name, contents|\n replace_entry(\"word/#{simple_file_name}.xml\", contents.serialize(save_with: 0))\n end\n else\n xml_document = instance_variable_get(\"@#{attr_name}\")\n replace_entry path, xml_document.serialize(save_with: 0) if xml_document\n end\n end\n end",
"def update\n @onpost = Onpost.find(params[:id])\n\n respond_to do |format|\n if @onpost.update_attributes(params[:onpost])\n flash[:notice] = 'Onpost was successfully updated.'\n format.html { redirect_to(@onpost) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @onpost.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path = '/files/', params = {})\n request :put, path, params\n end",
"def publish\n @page = Page.find(params[:id])\n @page.published_on = Time.now\n @page.save\n\n respond_to do |format|\n format.json {render json: @pages}\n format.xml {render xml: @pages}\n end\n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def update\n @musica = Musica.find(params[:id])\n\n respond_to do |format|\n if @musica.update_attributes(params[:musica])\n flash[:notice] = 'Musica was successfully updated.'\n format.html { redirect_to(@musica) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @musica.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(uri, options = {})\n if options[:multipart]\n form_input = build_multipart_data(options)\n build_response(request.put(uri, build_request_options({\"CONTENT_TYPE\" => \"multipart/form-data, boundary=Mack-boundary\", \"CONTENT_LENGTH\" => form_input.size, :input => form_input})))\n else\n build_response(request.put(uri, build_request_options({:input => options.to_params})))\n end\n end",
"def update\n @post_o_matic_posting = PostOMaticPosting.find(params[:id])\n\n respond_to do |format|\n if @post_o_matic_posting.update_attributes(params[:post_o_matic_posting])\n flash[:success] = 'Post-O-Matic Posting was successfully updated.'\n format.html { redirect_to(admin_post_o_matic_postings_url) }\n format.xml { head :ok }\n else\n flash[:error] = 'Post-O-Matic Posting could not be updated. See errors below.'\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post_o_matic_posting.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_doc\n\t\theaders = {:content_type => 'application/xml'}\n\t\turi = CGI.escape(\"/\" + rand(2).to_s() + \"/\" + rand(10).to_s() + \"/\" + rand(1000000).to_s() + \".xml\")\n\t\tresponse = @resource[\"/documents/\" + uri].put('<stuff xmlns=\"stuff\">' + uri + '</stuff>', headers)\n\t\treturn uri\n\tend",
"def save\n return if @content.nil?\n put_rest \"extra/#{@name}\", @content, :content_type => \"application/octet-stream\"\n end",
"def update\n @opml_metadata = OpmlMetadata.find(params[:id])\n\n respond_to do |format|\n if @opml_metadata.update_attributes(params[:opml_metadata])\n flash[:notice] = 'OpmlMetadata was successfully updated.'\n format.html { redirect_to(@opml_metadata) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @opml_metadata.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @mini_blog = MiniBlog.find(params[:id])\n\n respond_to do |format|\n if @mini_blog.update_attributes(params[:mini_blog])\n flash[:notice] = 'Mini-Blog actualizado exitosamente'\n format.html { redirect_to(@mini_blog) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mini_blog.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post328 = Post328.find(params[:id])\n\n respond_to do |format|\n if @post328.update_attributes(params[:post328])\n format.html { redirect_to(@post328, :notice => 'Post328 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post328.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update\n @post78 = Post78.find(params[:id])\n\n respond_to do |format|\n if @post78.update_attributes(params[:post78])\n format.html { redirect_to(@post78, :notice => 'Post78 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post78.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @xml_sample = XmlSample.find(params[:id])\n \n respond_to do |format|\n format.html do\n @xml_sample = XmlSample.update_attributes(params[:xml_sample])\n if @xml_sample.save\n return redirect_to @xml_sample, notice: 'Xml sample was successfully updated.'\n else\n return render action: \"new\"\n end\n end\n format.xml do\n rexml = REXML::Document.new(params[\"xml\"])\n attr = Hash.from_xml(rexml.to_s)\n if @xml_sample.update_attributes(attr[\"xmlsample\"])\n xml = {msg: \"complete\", status: \"OK\"}.to_xml\n else\n xml = {msg: \"failed\", status: \"NG\"}.to_xml\n end\n return render xml: xml\n end\n end\n end",
"def update\n @microopost = Microopost.find(params[:id])\n\n respond_to do |format|\n if @microopost.update_attributes(params[:microopost])\n format.html { redirect_to @microopost, :notice => 'Microopost was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @microopost.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @matter = Matter.find(params[:id])\n\n respond_to do |format|\n if @matter.update_attributes(params[:matter])\n format.html { redirect_to(@matter, :notice => 'Matter was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @matter.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update\n respond_to do |format|\n if post.update_attributes(params[:post])\n flash[:success] = t('post.updated')\n format.html { redirect_to(polymorphic_path([ postable.container, postable ], :anchor => dom_id(@post))) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @medio = Medio.find(params[:id])\n\n respond_to do |format|\n if @medio.update_attributes(params[:medio])\n flash[:notice] = 'Medio was successfully updated.'\n format.html { redirect_to(@medio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @medio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n replace_entry \"word/document.xml\", doc.serialize(:save_with => 0)\n end",
"def update\n @post156 = Post156.find(params[:id])\n\n respond_to do |format|\n if @post156.update_attributes(params[:post156])\n format.html { redirect_to(@post156, :notice => 'Post156 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post156.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post251 = Post251.find(params[:id])\n\n respond_to do |format|\n if @post251.update_attributes(params[:post251])\n format.html { redirect_to(@post251, :notice => 'Post251 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post251.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post231 = Post231.find(params[:id])\n\n respond_to do |format|\n if @post231.update_attributes(params[:post231])\n format.html { redirect_to(@post231, :notice => 'Post231 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post231.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_update_post\n data = {\n title: \"Roll lemon\",\n content: \"Gingerbread bear claw muffin danish danish marzipan. Toffee lollipop wafer carrot cake dessert.\",\n description: \"Chocolate tootsie roll lemon drops. Chupa chups chocolate bar apple pie\",\n image: \"chocolate.png\",\n status: 1\n }\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\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 test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response 401\r\n end",
"def 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 @miccropost = Miccropost.find(params[:id])\n\n respond_to do |format|\n if @miccropost.update_attributes(params[:miccropost])\n format.html { redirect_to @miccropost, notice: 'Miccropost was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @miccropost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post157 = Post157.find(params[:id])\n\n respond_to do |format|\n if @post157.update_attributes(params[:post157])\n format.html { redirect_to(@post157, :notice => 'Post157 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post157.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end",
"def destroy\n @micgropost = Micgropost.find(params[:id])\n @micgropost.destroy\n\n respond_to do |format|\n format.html { redirect_to(micgroposts_url) }\n format.xml { head :ok }\n end\n end",
"def update\n @photo_set = PhotoSet.find(params[:id])\n\n respond_to do |format|\n if @photo_set.update_attributes(params[:photo_set])\n flash[:notice] = 'PhotoSet was successfully updated.'\n format.html { redirect_to(@photo_set) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @photo_set.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(@post) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_metadata(params)\n @client.put(metadata_path, nil, params, \"Content-Type\" => \"application/json\")\n end",
"def update\n @post253 = Post253.find(params[:id])\n\n respond_to do |format|\n if @post253.update_attributes(params[:post253])\n format.html { redirect_to(@post253, :notice => 'Post253 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post253.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, doc = nil, options = {})\n execute('PUT', path, options, doc)\n end",
"def update\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @atom = Atom.find(params[:id])\n\n respond_to do |format|\n if @atom.update_attributes(params[:atom])\n flash[:notice] = 'Atom was successfully updated.'\n format.html { redirect_to(@atom) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @atom.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def template_update(id, type, filename)\n check_id_or_raise id\n check_template_type_or_raise type\n check_filename_or_raise filename\n response = http_request_multipart :put, @base_url + \"/templates/#{id}.xml\", 200,\n { :provider_key => @provider_key,\n :draft => File.read(filename), \n :multipart => true}\n puts 'at update call'\n _id, _updated_at = parse_response response, type\n response = http_request :put, \"#{@base_url}/templates/#{id}/publish\", 200,\n { :params => { :provider_key => @provider_key } }\n puts 'at publish call'\n parse_response response, 'page'\n end",
"def update\n @post120 = Post120.find(params[:id])\n\n respond_to do |format|\n if @post120.update_attributes(params[:post120])\n format.html { redirect_to(@post120, :notice => 'Post120 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post120.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end",
"def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to(@premio, :notice => 'Premio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(\"/#{@post.url}\", :notice => t('controller.updated')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end",
"def persist_in_xml\n\nend",
"def update_content(params)\n put(set_path(params[:id]), params) if validate_params(params)\n end",
"def update\n @post150 = Post150.find(params[:id])\n\n respond_to do |format|\n if @post150.update_attributes(params[:post150])\n format.html { redirect_to(@post150, :notice => 'Post150 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post150.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @mazo = Mazo.find(params[:id])\n\n respond_to do |format|\n if @mazo.update_attributes(params[:mazo])\n format.html { redirect_to(@mazo, :notice => 'Mazo was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mazo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post85 = Post85.find(params[:id])\n\n respond_to do |format|\n if @post85.update_attributes(params[:post85])\n format.html { redirect_to(@post85, :notice => 'Post85 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post85.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post246 = Post246.find(params[:id])\n\n respond_to do |format|\n if @post246.update_attributes(params[:post246])\n format.html { redirect_to(@post246, :notice => 'Post246 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post246.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n @post = Post.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @post81 = Post81.find(params[:id])\n\n respond_to do |format|\n if @post81.update_attributes(params[:post81])\n format.html { redirect_to(@post81, :notice => 'Post81 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post81.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @image_set = ImageSet.find(params[:id])\n\n respond_to do |format|\n if @image_set.update_attributes(params[:image_set])\n flash[:notice] = 'ImageSet was successfully updated.'\n format.html { redirect_to(@image_set) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @image_set.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def update\n @post = Post.find(params[:id])\n\t@posts = Post.all\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_attr\n #sanity checks \n @persona = current_persona\n @mediaset = @persona.mediasets.find(params[:id])\n \n respond_to do |format|\n @mediaset.update_attributes( params[:mediaset] )\n format.json{ respond_with_bip(@mediaset) }\n end\n end",
"def update\n @micsropost = Micsropost.find(params[:id])\n\n respond_to do |format|\n if @micsropost.update_attributes(params[:micsropost])\n format.html { redirect_to @micsropost, notice: 'Micsropost was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @micsropost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n params[:post][:picture_id] = nil if params[:post][:picture_id].to_i == 0\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n process_file_uploads\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(@post) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ministerio = Ministerio.find(params[:id])\n\n respond_to do |format|\n if @ministerio.update_attributes(params[:ministerio])\n format.html { redirect_to(@ministerio, :notice => 'Ministerio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ministerio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update_attributes(params[:post])\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n fn = params[:id].gsub('DOTDOT','.').gsub('SLASHSLASH','/')\n File.open(fn,'w+') { |f| \n f.puts params[:content]\n }\n respond_to do |format|\n format.json { render json: { success: true} }\n end\n end",
"def test_should_create_post_via_API_XML\r\n get \"/logout\"\r\n post \"/forum_posts.xml\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n end",
"def put(path, params={})\n RestClient.put request_base+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.65979344",
"0.6386905",
"0.5944032",
"0.5832561",
"0.5784904",
"0.57095796",
"0.5648733",
"0.5559411",
"0.55315036",
"0.5522774",
"0.5519452",
"0.5389559",
"0.53839856",
"0.53803235",
"0.53702414",
"0.5341423",
"0.5325147",
"0.52990663",
"0.5298956",
"0.5296068",
"0.52956945",
"0.5295644",
"0.528438",
"0.527999",
"0.5246992",
"0.5239694",
"0.5232384",
"0.5223873",
"0.52200294",
"0.5216066",
"0.5214169",
"0.52043027",
"0.52018136",
"0.519753",
"0.5196551",
"0.51878655",
"0.51822066",
"0.5180523",
"0.5164013",
"0.5137478",
"0.5120772",
"0.51146096",
"0.50993174",
"0.5098992",
"0.5095587",
"0.50948584",
"0.5093282",
"0.5092975",
"0.50923836",
"0.5087167",
"0.50864816",
"0.5075089",
"0.50732577",
"0.5072783",
"0.5070835",
"0.5061739",
"0.506091",
"0.5058472",
"0.50577587",
"0.5052401",
"0.50515246",
"0.50475883",
"0.504756",
"0.5035039",
"0.50343895",
"0.5034327",
"0.5033545",
"0.50296193",
"0.5020781",
"0.50194806",
"0.5018157",
"0.5016544",
"0.5015191",
"0.50131005",
"0.5008375",
"0.50071734",
"0.5005999",
"0.500528",
"0.500198",
"0.4996006",
"0.4994526",
"0.49884892",
"0.498736",
"0.4986966",
"0.4986557",
"0.49837068",
"0.4978627",
"0.49760503",
"0.4975047",
"0.4975047",
"0.4975047",
"0.4975047",
"0.49746445",
"0.49717152",
"0.497166",
"0.49698356",
"0.49641478",
"0.49626353",
"0.49626353",
"0.49626353"
] | 0.6216489 | 2 |
DELETE /micgroposts/1 DELETE /micgroposts/1.xml | def destroy
@micgropost = Micgropost.find(params[:id])
@micgropost.destroy
respond_to do |format|
format.html { redirect_to(micgroposts_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.deleted = 1\n @post.save\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n make_rss\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end",
"def delete_post\n\t \n \tend",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @mensagem = Mensagem.find(params[:id])\n api_client.delete_object(@mensagem.post_id)\n @mensagem.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.js { head :ok }\n end\n end",
"def destroy\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n r.delete @post\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def delete(*uris); end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def delete\n request(:delete)\n end",
"def delete\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete\n\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(root_path, :notice => t('controller.deleted')) }\n format.xml { head :ok }\n end\n end",
"def deletepublish\n @question = Publishquiz.find(:all, :conditions=>\"question_id=\"+params[:question]+\" and quiz_id=\"+session[:quizid])\n @question[0].destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end",
"def delete\n delete_from_server single_url\n end",
"def destroy\n @massmail = Massmail.find(params[:id])\n @massmail.destroy\n\n respond_to do |format|\n format.html { redirect_to(massmails_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 @post150 = Post150.find(params[:id])\n @post150.destroy\n\n respond_to do |format|\n format.html { redirect_to(post150s_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n \n end",
"def destroy\n @post48 = Post48.find(params[:id])\n @post48.destroy\n\n respond_to do |format|\n format.html { redirect_to(post48s_url) }\n format.xml { head :ok }\n end\n end",
"def remove_content(id)\n delete(\"/#{id}\")\n end",
"def destroy\n @post154 = Post154.find(params[:id])\n @post154.destroy\n\n respond_to do |format|\n format.html { redirect_to(post154s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @prestamo = Prestamo.find(params[:id])\n @prestamo.destroy\n\n respond_to do |format|\n format.html { redirect_to(prestamos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @svgpost = Svgpost.find(params[:id])\n @svgpost.destroy\n\n respond_to do |format|\n format.html { redirect_to svgposts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post413 = Post413.find(params[:id])\n @post413.destroy\n\n respond_to do |format|\n format.html { redirect_to(post413s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mensagem = Mensagem.find(params[:id])\n @mensagem.destroy\n\n respond_to do |format|\n format.html { redirect_to(mensagens_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n\n\tend",
"def destroy\n @micrrapost = Micrrapost.find(params[:id])\n @micrrapost.destroy\n\n respond_to do |format|\n format.html { redirect_to micrraposts_url }\n format.json { head :no_content }\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def destroy\n @post50 = Post50.find(params[:id])\n @post50.destroy\n\n respond_to do |format|\n format.html { redirect_to(post50s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @reclamo = Reclamo.find(params[:id])\n @reclamo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reclamos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @medio = Medio.find(params[:id])\n @medio.destroy\n\n respond_to do |format|\n format.html { redirect_to(medios_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @entrada = @mini_blog.entradas.find(params[:id])\n @entrada.destroy\n\n respond_to do |format|\n format.html { redirect_to(mini_blog_path(@mini_blog)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @photo_set = PhotoSet.find(params[:id])\n @photo_set.destroy\n\n respond_to do |format|\n format.html { redirect_to(photo_sets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mini_blog = MiniBlog.find(params[:id])\n @mini_blog.destroy\n\n respond_to do |format|\n format.html { redirect_to(mini_blogs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post328 = Post328.find(params[:id])\n @post328.destroy\n\n respond_to do |format|\n format.html { redirect_to(post328s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post451 = Post451.find(params[:id])\n @post451.destroy\n\n respond_to do |format|\n format.html { redirect_to(post451s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.xml { head :ok }\n end\n end",
"def delete\n \n end",
"def destroy\n @omatsuri = Omatsuri.find(params[:id])\n @omatsuri.destroy\n\n respond_to do |format|\n format.html { redirect_to(omatsuris_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @musica = Musica.find(params[:id])\n @musica.destroy\n\n respond_to do |format|\n format.html { redirect_to(musicas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @magazine = Magazine.find(params[:id])\n @magazine.destroy\n\n respond_to do |format|\n format.html { redirect_to(magazines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @alfresco = Alfresco.find(params[:id])\n @alfresco.destroy\n\n respond_to do |format|\n format.html { redirect_to(alfrescos_url) }\n format.xml { head :ok }\n end\n 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 delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @post55 = Post55.find(params[:id])\n @post55.destroy\n\n respond_to do |format|\n format.html { redirect_to(post55s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post251 = Post251.find(params[:id])\n @post251.destroy\n\n respond_to do |format|\n format.html { redirect_to(post251s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @related_content = RelatedContent.find(params[:id])\n @related_content.destroy\n dirname = \"#{RelatedContent::UPLOAD_DIR}/#{@related_content.id}\"\n FileUtils.rm_rf dirname\t\n redirect_to @related_content.node\t \n\nend",
"def destroy\n @monkey = Monkey.find(params[:id])\n @monkey.destroy\n\n respond_to do |format|\n format.html { redirect_to(monkeys_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post78 = Post78.find(params[:id])\n @post78.destroy\n\n respond_to do |format|\n format.html { redirect_to(post78s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post445 = Post445.find(params[:id])\n @post445.destroy\n\n respond_to do |format|\n format.html { redirect_to(post445s_url) }\n format.xml { head :ok }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @domino = Domino.find(params[:id])\n @domino.destroy\n\n respond_to do |format|\n format.html { redirect_to(dominos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mush_crawler = MushCrawler.find(params[:id])\n @mush_crawler.destroy\n\n respond_to do |format|\n format.html { redirect_to(mush_crawlers_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @mazo = Mazo.find(params[:id])\n @mazo.destroy\n\n respond_to do |format|\n format.html { redirect_to(mazos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n client = Connection::MarkLogic.new.client\n client.send_corona_request(\"/v1/documents?uri=/amandments/amandment_#{@amandment.id}.xml\", :delete)\n @amandment.destroy\n respond_to do |format|\n format.html { redirect_to home_meeting_path, notice: 'Amandman was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @micropst = Micropst.find(params[:id])\n @micropst.destroy\n\n respond_to do |format|\n format.html { redirect_to(micropsts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post75 = Post75.find(params[:id])\n @post75.destroy\n\n respond_to do |format|\n format.html { redirect_to(post75s_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @medicamento = Medicamento.find(params[:id])\n @medicamento.destroy\n\n respond_to do |format|\n format.html { redirect_to(medicamentos_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end",
"def destroy\n @nom = Nom.find(params[:id])\n @nom.destroy\n\n respond_to do |format|\n format.html { redirect_to(noms_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @offpost = Offpost.find(params[:id])\n @offpost.destroy\n\n respond_to do |format|\n format.html { redirect_to(offposts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post54 = Post54.find(params[:id])\n @post54.destroy\n\n respond_to do |format|\n format.html { redirect_to(post54s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy; delete end",
"def destroy\n @post246 = Post246.find(params[:id])\n @post246.destroy\n\n respond_to do |format|\n format.html { redirect_to(post246s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(root_url, :notice => 'Post was successfully removed.') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pic.destroy\n\n notifications = Notification.find(:all, :conditions => ['notification_type = ? and object_id = ?', \"comment\", @pic.id])\n notifications.each do |n|\n n.destroy\n end\n respond_to do |format|\n format.html { redirect_to(root_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def delete(path)\n\t\trequest(path, :delete)\n\tend",
"def destroy\n @mircopost.destroy\n respond_to do |format|\n format.html { redirect_to mircoposts_url, notice: 'Mircopost was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post470 = Post470.find(params[:id])\n @post470.destroy\n\n respond_to do |format|\n format.html { redirect_to(post470s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post446 = Post446.find(params[:id])\n @post446.destroy\n\n respond_to do |format|\n format.html { redirect_to(post446s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n@post = Post.find(params[:id])\n@post.destroy\nrespond_to do |format|\nformat.html { redirect_to posts_path(:forum_id => params[:forum_id],\n:topic_id => params[:topic_id]) }\nformat.xml { head :ok }\nend\nend",
"def destroy\n @post447 = Post447.find(params[:id])\n @post447.destroy\n\n respond_to do |format|\n format.html { redirect_to(post447s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post57 = Post57.find(params[:id])\n @post57.destroy\n\n respond_to do |format|\n format.html { redirect_to(post57s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n #@post = @contest.posts.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(posts_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @matter = Matter.find(params[:id])\n @matter.destroy\n\n respond_to do |format|\n format.html { redirect_to(matters_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end"
] | [
"0.7028965",
"0.66621494",
"0.6616252",
"0.65773576",
"0.6575671",
"0.6520314",
"0.6482652",
"0.6482505",
"0.644823",
"0.63628",
"0.6312437",
"0.6298924",
"0.6296919",
"0.6296919",
"0.6296785",
"0.6293241",
"0.62746847",
"0.62592196",
"0.6258334",
"0.6256671",
"0.6255685",
"0.6248812",
"0.62458897",
"0.62457526",
"0.6244227",
"0.6229594",
"0.6229594",
"0.6229594",
"0.6229594",
"0.6229594",
"0.6229594",
"0.6229594",
"0.62292814",
"0.6225075",
"0.6222678",
"0.62106425",
"0.62066334",
"0.6194852",
"0.6190935",
"0.6190126",
"0.618957",
"0.61872685",
"0.6185524",
"0.618518",
"0.61828655",
"0.61821884",
"0.61798465",
"0.6179763",
"0.6175987",
"0.61745447",
"0.61680096",
"0.61671925",
"0.616226",
"0.6156941",
"0.6153327",
"0.6152518",
"0.61515015",
"0.6150798",
"0.6149931",
"0.614717",
"0.614717",
"0.614717",
"0.614717",
"0.61464185",
"0.61419153",
"0.6141505",
"0.6139971",
"0.6135041",
"0.6134859",
"0.6128217",
"0.61257565",
"0.6125273",
"0.6121107",
"0.612041",
"0.6119981",
"0.6119874",
"0.6118575",
"0.61184525",
"0.6117461",
"0.6117461",
"0.61154205",
"0.61100703",
"0.6109907",
"0.61085945",
"0.61062884",
"0.61048186",
"0.6101447",
"0.60987765",
"0.6098641",
"0.6098428",
"0.6098248",
"0.6097513",
"0.6097166",
"0.60942066",
"0.6093041",
"0.60929865",
"0.6090511",
"0.6090132",
"0.6088122",
"0.60834366"
] | 0.72923744 | 0 |
puts str.ljust linewidth + str.rjust linewidth | def remember(&a_block)
@block = a_block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ljust(p0, padstr=\"\") end",
"def ljust(width, padstr = \" \") # from Rubinius\n justified = dup\n justified.justify(width, :left, padstr)\n end",
"def rjust(p0, padstr=\"\") end",
"def rjust(label)\n label = label.to_s\n if label.size > 20\n \"#{label}\\n#{' ' * 20}\"\n else\n label.rjust(20)\n end\n end",
"def two_columns(str1, str2)\n puts \"#{str1}\".ljust(40) + \"#{str2}\"\nend",
"def justify(str, size)\n if str.include?('-')\n # ' - ' => ' --- '\n str = ('-' * size).center(size + 2, ' ')\n elsif str.include?('|')\n # put _size_ spaces in between bars\n # Use indexes to grab leftmost/rightmost chars. Each may be a bar, may be a\n # space.\n str = str[0,1] + ' ' * (size) + str[-1,1]\n else\n # Blank strings are always lines that would have dashes (line 0, 2, or 4)\n str = ' ' * (size + 2)\n end\n return str\nend",
"def justify\n lineWidth = 40\n puts (\"Table of Contents\".center(lineWidth))\n puts (\"Chapter 1: Numbers\".ljust(lineWidth/2) + \"page 1\".rjust(lineWidth/2))\n puts (\"Chapter 2: Letters\".ljust(lineWidth/2) + \"page 72\".rjust(lineWidth/2))\n puts (\"Chapter 3: Variables\".ljust(lineWidth/2) + \"page 118\".rjust(lineWidth/2))\nend",
"def print_in_box(str)\n str_length = str.length\n puts first_horizontal_line = \"+ #{\"-\" * str_length} +\"\n puts second_horizontal_line = \"| #{\" \" * str_length} |\"\n puts third_horizontal_line = \"| #{str} |\"\n puts fourth_horizontal_line = \"| #{\" \" * str_length} |\"\n puts fifth_horizontal_line = \"+ #{\"-\" * str_length} +\"\nend",
"def print_in_box(str)\n width = str.length + 2\n \n puts \"+#{'-'*width}+\"\n puts \"|#{' '*width}|\"\n puts \"| #{str} |\"\n puts \"|#{' '*width}|\"\n puts \"+#{'-'*width}+\"\nend",
"def ljust_term(num)\n padding = (num - length_term)\n return self if padding <= 0\n self + ' ' * padding\n end",
"def print_horizontal_line(length)\n print '+'\n (length - 2).times do |index|\n print '-'\n end\n print '+'\n print \"\\n\"\n end",
"def print_output\n output.map { |line| (line =~ /^\\-$/) ? ('-' * total_width) : line.rjust(total_width) }\n end",
"def align(num)\n if num < 10\n \" #{num}\"\n else\n \" #{num}\"\n end\n end",
"def print_in_box(string)\n horizontal_rule = \"+#{'-' * (string.length + 2)}+\"\n empty_line = \"|#{' ' * (string.length + 2)}|\"\n puts horizontal_rule\n puts empty_line\n puts \"| #{string} |\"\n puts empty_line\n puts horizontal_rule\nend",
"def left_justify(val, length)\n val.ljust(length)\n end",
"def format_text(text, ljust_prop)\n \"#{text}\".ljust(ljust_prop)\n end",
"def justify_again\n content = ['Table of Contents', 'Chapter 1: Numbers', 'page 1', 'Chapter 2: Letters', 'page 72', 'Chapter 3: Variables', 'page 118']\n lineWidth = 40\n puts (content[0].center(lineWidth))\n puts (content[1].ljust(lineWidth/2) + content[2].rjust(lineWidth/2))\n puts (content[3].ljust(lineWidth/2) + content[4].rjust(lineWidth/2))\n puts (content[5].ljust(lineWidth/2) + content[6].rjust(lineWidth/2))\nend",
"def print(string, width = self.width)\n w = width == 0? Ncurses.COLS : width\n waddnstr(string.to_s, w) # changed 2011 dts \n end",
"def wrap(s, width=80)\n s.gsub(/(.{1,#{width}})(\\s+|\\Z)/, \"\\\\1\\n\")\nend",
"def pad(s)\n s.to_s.rjust(3,\"0\")\nend",
"def print_in_box(str)\n width = str.size\n puts '+' + '-' * (width + 2) + '+'\n puts '|' + ' ' * (width + 2) + '|'\n puts '|' + ' ' + str + ' ' + '|'\n puts '|' + ' ' * (width + 2) + '|'\n puts '+' + '-' * (width + 2) + '+'\nend",
"def format_text(info, size)\n info.to_s.gsub(\"\\n\", ' ')[0, size-1].ljust(size)\n end",
"def underline(str)\n str += \"\\n\" + \"-\"*str.length\n end",
"def print_in_box(str)\n dash_inserts = '-' * str.length\n horiz_border = '+-' + dash_inserts + '-+'\n space_inserts = ' ' * str.length\n padding_border = '| ' + space_inserts + ' |'\n puts horiz_border\n puts padding_border\n puts '| ' + str + ' |'\n puts padding_border\n puts horiz_border\nend",
"def center_with_strlen(strlen)\n linefill_length = TermInfo.screen_size[1]\n len = linefill_length - strlen\n len = 0 if len < 0\n \" \" * (len / 2) + self\n end",
"def console_header(str)\n width = 20\n delimiter = '-' * width\n puts delimiter\n puts str.center(width)\n puts delimiter\nend",
"def adjust_string(string, direction, string_size)\n case direction\n when 'left'\n string.ljust(string_size)\n when 'right'\n string.rjust(string_size)\n end\n end",
"def format_line(arr)\n x = TTY::Screen.width - 2\n small_items = 12\n first_item = x - 5 * small_items\n\n output = \"\"\n arr.each_with_index do |l, i|\n if i == 0\n output << l.to_s[0..first_item].ljust(first_item)\n else\n output << l.to_s[0..small_items].ljust(small_items)\n end\n end\n output\n end",
"def pad(string, length, align=:left)\n\t\t\tif string == nil\n\t\t\t\treturn ' ' * length\n\t\t\telsif string.length >= length\n\t\t\t\treturn string\n\t\t\telse\n\t\t\t\tdifference = (length - string.length).to_f\n\t\t\t\tcase align\n\t\t\t\twhen :left\n\t\t\t\t\treturn string + ' ' * difference\n\t\t\t\twhen :right\n\t\t\t\t\treturn ' ' * difference + string\n\t\t\t\twhen :center\n\t\t\t\t\treturn ' '*(difference/2).floor + string + ' '*(difference/2).ceil\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def string_in_line(string, length)\r\n puts '-'*((length/2)-(string.length/2))+\" #{string} \"+'-'*((length/2)-(string.length/2))\r\n end",
"def printStrings strArr, maxLength\n strArr.each_with_index do |str, i|\n # center strings, add spaces on left to add shifting effect\n puts ' ' * i * 2 + str.center(maxLength)\n end\nend",
"def ralign(a, b, length=CONSOLE_WIDTH)\n p = length-a.length-b.length\n a + (\" \"*p) + b\n end",
"def print_header(string)\n puts '*'.white * 80\n puts string.center(80)\n puts '*'.white * 80\nend",
"def pad(s)\n s.rjust(2, '0')\n end",
"def center(width)\n spaces_needed = width - self.print_width\n left_side = spaces_needed / 2\n right_side = spaces_needed - left_side\n (\" \" * left_side) << self << (\" \" * right_side)\n end",
"def staircase(n)\n for i in 1..n do\n puts (\"#\" * i).rjust(n)\n end\n\nend",
"def formatting(str)\n puts str * 80\nend",
"def format_ouput(str1,str2)\n len = 50 - str1.length\n space = \"#{'-' * len}\".to_s\n str1.concat(space)\n str1.concat(str2.to_s)\n str1\nend",
"def draw(text)\n printf \"%s %-#{(columns / 3) - 5}s \" % [V_SEP, text]\n end",
"def print_in_box(string)\n length = string.length\n upper_lower_box = \"\"\n top_bottom = \"+-\" + multi_char(length, \"-\") + \"-+\"\n padding = \"| \" + multi_char(length, \" \") + \" |\"\n line = \"| \" + string + \" |\"\n puts top_bottom, padding, line, padding, top_bottom\nend",
"def print(string, _width = @content_cols)\n #return unless visible?\n w = _width == 0? Ncurses.COLS : _width\n FFI::NCurses.waddnstr(@pad,string.to_s, w) # changed 2011 dts \n end",
"def LeftJustify(text, len)\r\n \r\n #prevent text bigger then len\r\n newtext = text.to_s[0..len - 1]\r\n \r\n\t#left justify\r\n newtext = newtext.to_s.ljust(len)\r\n \r\n return newtext\r\nend",
"def print_in_box(str)\n border = '+' + ('-' * (str.size + 2)) + '+'\n padding = '|' + (' ' * (str.size + 2)) + '|'\n text = '| ' + str + ' |'\n puts border, padding, text, padding, border\nend",
"def print_line(line)\n @maxlinelength = line.length if line.length > @maxlinelength\n print line.ljust(@maxlinelength) << \"\\r\"\n $stdout.flush\nend",
"def triangle(rows)\n 1.upto(rows) { |num| puts \"#{\"*\" * num}\".rjust(rows)}\nend",
"def print_in_box(string)\n lines = string.scan(/.{1,76}/)\n width = lines.first.to_s.size + 2\n top_bot = \"+#{'-' * width}+\"\n padding = \"|#{' ' * width}|\"\n text = lines.map { |line| \"| #{line.ljust(width - 2)} |\" }\n puts [top_bot, padding, text, padding, top_bot]\nend",
"def horizontalSpacer(n , text)\n n.times {print \" \"}\n puts text\nend",
"def echo(text, fill, default='')\n text = default unless text\n (text.length > fill) ? text[0, fill] : text.ljust(fill, ' ')\nend",
"def greet\n puts \"Welcome to Stock Trader\".rjust(65)\nend",
"def log(str, newline = true)\n return puts(str) if newline\n\n print str.ljust(60, ' ')\n STDOUT.flush\nend",
"def rPad!(thePad = '')\n len = @theLines.length\n padArray = Array.new(len, thePad)\n padTR = TextRect.new(padArray)\n self.join!(padTR)\n end",
"def print_in_box(str)\n dashes = '+' + '-' * (str.length + 2) + '+'\n spaces = '|' + ' ' * (str.length + 2) + '|'\n\n puts dashes\n puts spaces\n puts '| ' + str + ' |'\n puts spaces\n puts dashes\nend",
"def print_array(a, word_length)\r\n a.each{|x|\r\n x.each{|y| print y.to_s.rjust(word_length)}\r\n puts \r\n }\r\n puts\r\nend",
"def triangle(num)\n 1.upto(num) { |n| puts \"#{\"*\" * n}\".rjust(num) }\nend",
"def tab(str, n=1, chr=' ')\n chr * n + str\nend",
"def align; end",
"def align; end",
"def print_in_box(text)\n horizontal = \"+\" + \"-\" * (text.length + 2) + \"+\"\n text_line = \"| \" + text + \" |\"\n vertical = \"|\" + \" \" * (text.length + 2) + \"|\"\n\n puts horizontal\n puts vertical\n puts text_line\n puts vertical\n puts horizontal\nend",
"def print_in_box(string)\r\n print \"+\" + (\"-\" * (string.length + 4)) + \"+\" + \"\\n\"\r\n print \"|\" + (\" \" * (string.length + 4)) + \"|\" + \"\\n\"\r\n print \"|\" + (\" \" * (string.length + 4)) + \"|\" + \"\\n\"\r\n print \"|\" + (\" \" * 2) + string + (\" \" * 2) + \"|\" + \"\\n\"\r\n print \"|\" + (\" \" * (string.length + 4)) + \"|\" + \"\\n\"\r\n print \"|\" + (\" \" * (string.length + 4)) + \"|\" + \"\\n\"\r\n print \"+\" + (\"-\" * (string.length + 4)) + \"+\" + \"\\n\"\r\nend",
"def print_line(nlen, n, clen, c)\n puts \"%-#{nlen}s | %-#{clen}s \" % [n, c]\n end",
"def print_in_box(text)\n text = text[0, MAX_SIZE]\n pad1 = ''.center(text.size, '-')\n pad2 = ''.center(text.size, ' ')\n\n puts(\"+-#{pad1}-+\n| #{pad2} |\n| #{text} |\n| #{pad2} |\n+-#{pad1}-+\")\nend",
"def equal_spaced_output\n\n\t\tputs \"Type an integer to set column spacing\"\n\t\tspacing = gets.chomp.to_i\n\t\tlargest_word = find_largest_word\n\n\t\tspacing += largest_word.length\n\n\t\tcounter = 0\n\t\t@stringArray.each do |x|\n\n\t\t\tfinished = nil\t\t\t\n\n\t\t\tloop do \n\n\t\t\t\tlength = x.length\n\n\n\t\t\t\tif length <= spacing\n\t\t\t\t\tx << ' '\n\t\t\t\telse\n\t\t\t\t\tx << '|'\n\t\t\t\t\tbreak\n\t\t\t\tend\n\n\n\t\t\tend\n\n\t\t\tputs x\n\n\t\tend #end string each\n\n\n\tend",
"def lPad!(thePad = '')\n @theLines.collect! { |l| thePad + l }\n return self\n end",
"def wrap_width(width)\n gsub(/([^\\n\\r]{1,#{width}})/,\"\\\\1\\n\")\n end",
"def print_in_box(str)\n size = str.size\n border_line = '+-' + ('-' * size) + '-+'\n empty_line = '| ' + (' ' * size) + ' |'\n text_line = '| ' + str + ' |'\n \n puts border_line\n puts empty_line\n puts text_line\n puts empty_line\n puts border_line\nend",
"def format_key(key)\n @string_size = [@string_size.to_i, key.length + 2].max\n key.ljust(@string_size, \" \")\nend",
"def line(length)\r\n puts '-'*length\r\n end",
"def pad(line, l, tw)\n # FIXME: Probably more efficient to pre-create\n # one. Wont this pass through the ANSI parser?\n # FIXME: The + 1 obscures cutoff indicators.\n c = tw - l + 1 #text_width #@out.w-line.length-6\n if c > 0\n line << \"\\e[48m\"+\" \"*c\n end\n end",
"def triangle(int)\n for i in (0..int)\n puts (\"*\"*i).rjust(int) \n end\nend",
"def aligned\n case align\n when :right then text.rjust(width, ' ')\n when :centre then text.center(width, ' ')\n else text.ljust(width, ' ')\n end\n end",
"def spacer\n puts \"\\n----------------------------\\n\"\nend",
"def Columnize( text, width, indent )\n\treturn indent + text.scan(/(.{1,#{width}})(?: |$)/).join(\"\\n#{indent}\")\nend",
"def print_in_box(text)\n width = text.size\n result = <<EOS\n+-#{'-' * width}-+\n| #{' ' * width} |\n| #{text} |\n| #{' ' * width} |\n+-#{'-' * width}-+\nEOS\n result\nend",
"def linebreak(char='')\n puts \"#{char*50}\"\n end",
"def triangle(int)\n star_chars = '*'\n int.times do\n puts star_chars.rjust(int, ' ')\n star_chars << '*'\n end\nend",
"def line(text, length=20)\n puts \"-\" * length\n puts text \nend",
"def pad(v, l, c = '0')\n v.rjust(l, c) if v.present? && v.class == String && v.downcase != 'none'\n end",
"def puts_labels(columns)\n\tlabels = \" \"*4\n 1.upto(columns) do |i|\n \tlabels += i.to_s.rjust(5)\n end\n puts \"\\n#{labels}\"\nend",
"def lPad(thePad = '')\n theCopy = TextRect.new(@theLines)\n theCopy.lPad!(thePad)\n end",
"def padded_line(iteration, elapsed_time)\n meter_line = line(iteration, elapsed_time)\n pad_size = [@last_printed_length - meter_line.size, 0].max\n @last_printed_length = meter_line.size\n meter_line + ' ' * pad_size\n end",
"def decoration(number, line_length)\n (\"=\" * number * (line_length+1)) << \"\\n\"\nend",
"def print_in_box(text)\n\n text_length = text.size + 2\n\n line_one_five = puts '+' + '-'* text_length + '+'\n line_two_four = puts '|' + ' '* text_length + '|'\n line_three = puts '| ' + text + ' |'\n line_two_four = puts '|' + ' '* text_length + '|'\n line_one_five = puts '+' + '-'* text_length + '+'\n\n\nend",
"def output_line(line)\n output = line[:mode] + ' '\n output << line[:repl] + ' '\n output << line[:owner].ljust(@alignment[:owner]) + ' '\n output << line[:group].ljust(@alignment[:group]) + ' '\n output << line[:size].rjust(@alignment[:size]) + ' '\n output << line[:time] + ' '\n output << line[:name] + \"\\n\"\n puts output\n end",
"def word_wrap(width=60)\n lines = []\n line = \"\"\n self.split(/\\s+/).each do |word|\n if line.size + word.size >= width\n lines << line\n line = word\n elsif line.empty?\n line = word\n else\n line << \" \" << word\n end\n end\n lines << line if line\n return lines.join \"\\n\"\n end",
"def print_in_box(str)\n length = str.size\n print \"+-#{\"-\" * length}-+\\n\"\n print \"| #{\" \" * length} |\\n\"\n print \"| #{str} |\\n\"\n print \"| #{\" \" * length} |\\n\"\n print \"+-#{\"-\" * length}-+\\n\"\nend",
"def align(addr, width)\n\treturn addr + pad_length(addr, width)\nend",
"def indent_string\n s = \"\"\n @indentCount += 1\n s += \" \" * @indentCount\n end",
"def right\n value.rjust(width, options[:pad])\n end",
"def padded_aligned_data(data)\n string_repr = @data_to_s.call(data)\n\n string_repr = case @alignment\n when :left\n string_repr.ljust(@width)\n when :center\n string_repr.center(@width)\n when :right\n string_repr.rjust(@width)\n else\n string_repr\n end\n\n @padding ? @padding + string_repr + @padding : string_repr\n end",
"def pad_record(text_line)\n flow_type = Inflector.underscore(self.class.to_s).split(\"_\")[0].upcase()\n record_type = text_line.slice(0..1).upcase()\n\n\n #remove x-tra spaces to right, i.e where the passed in text-line > schema required length\n if text_line.length() > RecordPadder.required_record_length(flow_type, record_type, text_line.length)\n text_line.slice!(RecordPadder.required_record_length(flow_type, record_type, text_line.length)..text_line.length())\n return text_line\n else\n text_line.ljust(RecordPadder.required_record_length(flow_type, record_type, text_line.length))\n\n end\n\n\n\n end",
"def join(addend, padChar=' ', separator = nil)\n theCopy = TextRect.new(@theLines)\n theCopy.join!(addend, padChar, separator)\n end",
"def p( colsizes, align = nil, padding = 3 )\n\t\t\t\tprint \"#{@color}\"\n\t\t\t\tidx = 0\n\t\t\t\t@cols.each do |item|\n\t\t\t\t\tif align and align[idx] == \"r\"\n\t\t\t\t\t\tprint \" \" * ( colsizes[ idx ] - item.to_s.length_utf8 )\n\t\t\t\t\tend\n\t\t\t\t\tprint item\n\t\t\t\t\tif align==nil or (align and align[idx] == \"l\")\n\t\t\t\t\t\tprint \" \" * ( colsizes[ idx ] - item.to_s.length_utf8 )\n\t\t\t\t\tend\n\t\t\t\t\tprint \" \"*padding if idx < colsizes.length - 1\n\t\t\t\t\tidx += 1\n\t\t\t\tend\n\t\t\t\tputs \"\\033[0m\"\n\t\t\tend",
"def set_string(row: 0, string:, align: \"left\")\n column = 0\n str = case align\n when \"left\" then string[0, @max_column].ljust(@max_column)\n when \"right\" then string[0, @max_column].rjust(@max_column)\n when \"center\" then string[0, @max_column].center(@max_column)\n else string[0, @max_column].ljust(@max_column)\n end\n\n str.chars do |chr|\n set_character(row: row, column: column, character: chr)\n column += 1\n end\n end",
"def indent(str, amount=2)\n i = (\" \"*amount)\n (i + str.gsub(/\\n/, \"\\n#{i}\")).rstrip\n end",
"def encode(width=nil)\n width = 75 unless width\n l = @line\n # Wrap to width, unless width is zero.\n if width > 0\n l = l.gsub(/.{#{width},#{width}}/) { |m| m + \"\\n \" }\n end\n # Make sure it's terminated with no more than a single NL.\n l.gsub(/\\s*\\z/, '') + \"\\n\"\n end",
"def row(*cols)\n justified_cols = cols.zip(@widths).map do |c, w|\n (c || '<nil>').to_s.ljust(w)[0...w]\n end\n \"| #{justified_cols.join(' | ')} |\"\n end",
"def underline(string)\n '-' * string.size\n end",
"def row(*cols)\n '| ' + cols.zip(@widths).map do |c,w|\n (c || '<nil>').to_s.ljust(w)[0...w]\n end.join(' | ') + ' |'\n end",
"def liner box_char=@box_char, box_size=@box_size\n self.puts( box_char * box_size ) if self.debug?\n end",
"def surround(word, pad_width=word.length/2)\n \"[\" * pad_width + word + \"]\" * pad_width\nend",
"def draw_text_indent(line, string, additional=0)\n return if line <= 0\n y = 32 * line - 32\n self.contents.draw_text(35+additional, y, @width, 32, string)\n end"
] | [
"0.7495089",
"0.7381788",
"0.7337256",
"0.7309876",
"0.7139323",
"0.70947397",
"0.69415736",
"0.69296736",
"0.692405",
"0.68075776",
"0.67884874",
"0.6783697",
"0.67781276",
"0.67634505",
"0.6727334",
"0.67118645",
"0.6709737",
"0.67047983",
"0.66916734",
"0.66885495",
"0.6687215",
"0.668251",
"0.6662322",
"0.6654773",
"0.6650153",
"0.66496605",
"0.65948963",
"0.65782654",
"0.65731126",
"0.65564185",
"0.65494287",
"0.6548805",
"0.65479094",
"0.6542856",
"0.6539078",
"0.6534688",
"0.6533902",
"0.65250915",
"0.65220046",
"0.6476044",
"0.6469592",
"0.64541197",
"0.64523596",
"0.64457977",
"0.6440582",
"0.6429754",
"0.64169127",
"0.64143217",
"0.64120436",
"0.6401531",
"0.6391853",
"0.63904506",
"0.638295",
"0.638138",
"0.6332628",
"0.63277143",
"0.63277143",
"0.6314939",
"0.631406",
"0.6310657",
"0.6309051",
"0.63056517",
"0.6301314",
"0.6287188",
"0.6270897",
"0.6266917",
"0.6261185",
"0.6256953",
"0.62392646",
"0.6236094",
"0.62229633",
"0.6221459",
"0.62075037",
"0.61843777",
"0.6178397",
"0.61639214",
"0.61535585",
"0.6148503",
"0.612976",
"0.61153024",
"0.6108669",
"0.6095069",
"0.6087142",
"0.607303",
"0.6061153",
"0.6057198",
"0.60565734",
"0.60563236",
"0.60531366",
"0.6053041",
"0.60421854",
"0.6035937",
"0.6032129",
"0.60320455",
"0.6028032",
"0.6022064",
"0.6016464",
"0.6009272",
"0.6005144",
"0.6003021",
"0.60006666"
] | 0.0 | -1 |
=> "Hello, Jon!" currying: create a more specific version of a generalized function | def div_gen(x)
return lambda {|y| return y/x}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def friendly_parrot (name, age)\n \"You are called #{name} and you are #{age}\"\nend",
"def greeter(name)\n return \"hello \" + name + \" its nice to see you.\"\nend",
"def greet(folks); \"Hi, #{folks}!\"; end",
"def greet(person)\n \"Hello, #{person}!\"\nend",
"def greet(name)\n \"Hello #{name.capitalize}!\"\nend",
"def greet(name)\n \"Hello #{name.capitalize}!\"\nend",
"def say_hello(name)\n \"Hi #{name}!\"\nend",
"def hello_world(first_name_or_anything_you_want)\n puts \"Hello #{first_name_or_anything_you_want}\"\nend",
"def name(name)\n return \"Hello, #{name}!\"\nend",
"def friendly_parrot(name, age)\n \"Hello #{name} you are #{age}\"\nend",
"def hello(name)\n return \"Hello, \" + name.to_s\nend",
"def hello(name)\n return \"Hello, \" + name.to_s\nend",
"def greet person\n\t'Hello, ' + person + '!'\nend",
"def say_hello(name)\n return \"Hi, #{name}. Have a good day.\"\nend",
"def greeter(name)\n return \"Hello #{name}!\"\nend",
"def say_hello(name)\n \"Hello, \" + name\nend",
"def greet(name)\n \"Hi, #{name}.\"\nend",
"def friendly_parrot(name, age)\n \"Hi, Are you #{name}? You're #{age} years old.\"\nend",
"def greet (name)\n \"Hello, #{name}!\"\nend",
"def greeter(name)\n return \"Hello, #{name}!\"\nend",
"def greeting(name)\n \"Hi my name is #{name}, nice to meet you!\"\nend",
"def greet\n \"#{hello} #{world}\"\nend",
"def greeting(name)\n \"Good to see you #{name}\"\nend",
"def say_hello(name)\n return \"Hello, \" + name\nend",
"def friendly_parrot(name, age)\n \"Hi #{name}, you're #{age} years old.\"\nend",
"def greet(who)\n\t\"Hello, #{who}!\"\nend",
"def greet(who)\n\t\"Hello, #{who}!\"\nend",
"def greet(who)\n\t\"Hello, #{who}!\"\nend",
"def hello(name)\n \"Hello #{name}\"\nend",
"def hello1(name)\n 'Hello ' + name\nend",
"def hello1(name)\n 'Hello ' + name\nend",
"def greet(name)\n return \"Hello, #{name}!\"\nend",
"def hello1 (name)\n 'Hello ' + name\nend",
"def say_hi(name)\n return \"Bonjour #{name.capitalize}.\"\n # string\nend",
"def hello1(name)\n 'halo ' + name\nend",
"def sayHello( name=\"Stranger\", adjective=\"stinky\" )\n puts \"Hello #{ adjective } #{ name }\"\n \"hotdogs hotdogs hotdogs\"\nend",
"def say_hello name1=\"Oscar\", name2=\"Shane\"\n \"hello, #{name1} and #{name2}\"\nend",
"def greeting(name)\n \"Hello #{name.capitalize}!\"\nend",
"def say_hello name\n \"Hello, #{name}!\"\nend",
"def hello(name) #\n \"Hello, #{name}!\" #\nend",
"def hello(name) \n\t\"hello #{name}\"\nend",
"def say_hello thing_to_say\n puts \"Hello \"+thing_to_say\nend",
"def greet(person)\n puts \"Hello, \" + person\nend",
"def greet(person)\n puts \"Hello, \" + person\nend",
"def say_hello name\n return \"Hello, #{name}!\"\nend",
"def say_hello_3 name1=\"Bill\", name2=\"Ted\"\n \"hello, #{name1} and #{name2}\"\nend",
"def greeter(name)\n puts \"Hello #{name}! How are you today?\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def greet(name)\nreturn \"Hello, #{name}!\"\nend",
"def greeting_a_person(name)\n puts \"Hello #{name}\"\nend",
"def greeting(name='John Doe')\n \"Hello, #{name}. \" + \"How are you doing?\"\nend",
"def greeter (name)\n return \"Hello #{name}\"\n end",
"def hello(name)\n return 'Hello, ' + name\nend",
"def hello d\n 'hello ' + d\nend",
"def hello(name)\n \"Hello, \".concat(name)\nend",
"def hello1(name)\n 'Hello ' + name \nend",
"def say(something)\n \"Say #{something}\"\n end",
"def say_goodnight(name)\r\n \"Dobranoc #{ name.capitalize }\"\r\nend",
"def greet(name)\n\t\"Hello, #{name}!\"\nend",
"def hello(name)\n \"Hello, \" << name\nend",
"def mothers_day(name)\n \"Happy Mother's Day, #{name}!\"\nend",
"def foo_greeting(recipient = \"you\")\n puts \"Hello there, #{recipient.upcase}!\"\nend",
"def hello2 (name2)\n 'Hello ' + name2\nend",
"def greeting(name)\n \"Hello \" + name.capitalize + \"!\"\nend",
"def hello(who)\n puts \"Hello, #{who}\"\nend",
"def hello (name)\n return \"Hello, \" + name\nend",
"def say_hello(statement)\n 'We have important information! ' + statement.to_s\nend",
"def greet person\n puts \"Hello, #{person}!\"\nend",
"def hello2 name2\n 'Hello ' + name2\nend",
"def hello2 name2\n 'Hello ' + name2\nend",
"def helloPerson(name)\n puts \"hello #{name.capitalize}!\"\nend",
"def greeting(name)\n \"Hello #{name}!\"\nend",
"def greeting(name)\n \"Hello #{name}!\"\nend",
"def hello2 name2\n 'good day ' + name2\nend",
"def say_hello(name)\n puts \"Hello #{name}!\"\nend",
"def greetings(name)\n puts \"Hello #{name.capitalize}\"\nend",
"def greeting(person)\n puts \"Hello, \" + person\nend",
"def say_hello3(name1=\"oscar\", name2=\"shane\")\n \"hello, #{name1} and #{name2}\"\nend",
"def hello2 name2 \r\n 'Hello ' + name2 \r\nend",
"def say_hello name1=\"oscar\", name2=\"shane\"\n\t\"hello, #{name1} and #{name2}\"\nend",
"def hello(name)\n return \"Hello, #{name}\"\nend",
"def hello(name)\n return \"Hello, #{name}\"\nend",
"def hello(name)\n return \"Hello, #{name}\"\nend",
"def hello(name)\n return \"Hello, #{name}\"\nend",
"def hello(name)\n return \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, \" + name\nend",
"def hello(name)\n \"Hello, \" + name\nend",
"def hello(name)\n \"Hello, \" + name\nend",
"def hello(name)\n \"Hello, \" + name\nend",
"def greet(name)\n puts \"hello \" + name\nend",
"def say_happy_birthday_to(name)\n puts \"Happy Birthday #{name}!\"\nend"
] | [
"0.639262",
"0.6346197",
"0.63045764",
"0.6295016",
"0.62318534",
"0.62318534",
"0.62265164",
"0.6224741",
"0.6180392",
"0.61452633",
"0.6131682",
"0.6131682",
"0.6124345",
"0.6120646",
"0.6108782",
"0.6095991",
"0.6083754",
"0.6067132",
"0.6065615",
"0.60551375",
"0.6052666",
"0.60487485",
"0.6043654",
"0.6039659",
"0.60357165",
"0.6023793",
"0.6023793",
"0.6023793",
"0.60113144",
"0.59967846",
"0.59967846",
"0.5985996",
"0.59788054",
"0.59763443",
"0.59747785",
"0.59741235",
"0.5963956",
"0.5954229",
"0.59501195",
"0.59477377",
"0.59473175",
"0.5946833",
"0.5935901",
"0.5935901",
"0.59341455",
"0.59288365",
"0.59251386",
"0.59235203",
"0.59235203",
"0.59235203",
"0.59235203",
"0.59235203",
"0.59235203",
"0.59235203",
"0.59235203",
"0.59235203",
"0.59235203",
"0.59235203",
"0.59176743",
"0.5912652",
"0.59092706",
"0.5906866",
"0.59060454",
"0.5901693",
"0.590074",
"0.589868",
"0.58976924",
"0.5888745",
"0.588701",
"0.5877956",
"0.5877075",
"0.58687496",
"0.58636713",
"0.5862155",
"0.5856852",
"0.58566827",
"0.5841243",
"0.5840544",
"0.58296883",
"0.5828869",
"0.5823793",
"0.5823281",
"0.5823281",
"0.5823088",
"0.58205694",
"0.58161926",
"0.5808161",
"0.5807864",
"0.5804481",
"0.57989794",
"0.57969993",
"0.57969993",
"0.57969993",
"0.57969993",
"0.57969993",
"0.5786064",
"0.5786064",
"0.5786064",
"0.5786064",
"0.5782059",
"0.5781897"
] | 0.0 | -1 |
the notions of an anonymous function (lambda), first class function and closure revolve around an unique capability of a functional programming language: that of dynamic code generation. a language supports first class functions if it has the builtin capabilities to construct a function dynamically, store it in memory, pass it as an argument to another function and return it as a value from a function. all of the above capabilities are natively available in a moduler programming language like C, via the use of a 'function pointer' or 'function reference'; except that of construction of a function dynamically. support for a first class function is usually built on top of the following builtin primitives of a functional programming language: 1. anonymous function aka a function literal 2. a closure which is an enclosed function object, which contains the function text and the storage for the private state the body of the function has references to. a closure may be viewed as a specific instance of a generic (parameterized) function, with the values of the parameters fully specified. parameters refer to the private state of the function. 3. an operator to construct a closure from an anonymous function (lambda is viewed both as an operator to construct a closure as well as the anonymous function itself) 4. a function variable aka a variable which holds a reference to a closure a language with first class functions offer a distinct way of 1. designing software and 2. expressing a program though they have the exactly same overall capability as that of a moduler programming language like C. i.e. anything that can be achieved using first class functions can be achieved using a moduler programming language, and vice versa, albeit the design and look and feel of the code will be different. why is this interesting? in web programming, a server often generates code which is sent to the client side and client executes the code. this is considered better than client invoking an API function on the server side over a remote procedule call mechanics, since it avoids the compatibility issue between the client and the server. so a language with built in support for code generation fits more naturally into this requirement. without this support, the server side program will use of the following: 1. code templates which are viewed as texts. these don't benefit from compilation / syntax check / other code analysis tooling. 2. server side program generates a call to a generic API function, where the generic function resides on server side. the code snippet sent to client essentially calls the generic server side function with specific parameters. this can lead to greater network traffic and loss of efficiency and reliability. 3. the server side may send the code for the generic function along with the private state such that the client invokes a specific instance of the generic function. this is what is made implicit and done automatically by a language which supports first class functions. deaf grandma program | def yell(words)
return lambda {puts words.upcase}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lambda; end",
"def compile_lambda(scope, args, body)\n compile_defun(scope, @e.get_local, args,body)\n end",
"def lambda_demo(a_lambda)\n puts \"I'm the method!\"\n a_lambda.call\nend",
"def lambda_demo(a_lambda)\n puts \"I'm the method!\"\n a_lambda.call\nend",
"def lambda_demo(a_lambda)\n puts \"I'm the method!\"\n a_lambda.call\nend",
"def compile_lambda(scope, args=nil, body=nil)\n e = @e.get_local\n body ||= []\n args ||= []\n # FIXME: Need to use a special scope object for the environment,\n # including handling of self. \n # Note that while compiled with compile_defun, the calling convetion\n # is that of a method. However we have the future complication of\n # handling instance variables in closures, which is rather painful.\n r = compile_defun(scope, e, [:self,:__closure__]+args,[:let,[]]+body)\n r\n end",
"def lambda_demo_method\n lambda_demo = lambda { return \"Will I print?\" }\n lambda_demo.call\n \"Sorry - it's me that's printed.\"\nend",
"def eval_lambda(exp, env)\n make_closure(exp, env)\nend",
"def closureasaurus( n )\n\tlambda {|val| val*n }\nend",
"def eval_lambda(exp, env)\n make_closure_from_lambda(exp, env)\n end",
"def lambda_math\n math = lambda do\n return 1 + 1\n end\n math.call\n return \"hey\"\nend",
"def lambda=(_); end",
"def lambda_demo_method\n lambda_demo = lambda { return \"Will I print?\" }\n lambda_demo.call\n \"Sorry - it's me that's printed.\"\n end",
"def closure! \n end",
"def method_name\n :lambda\n end",
"def create_lambda(arg)\n case arg\n when Proc then arg\n when Symbol then lambda { |request| request[arg] }\n else raise \"Canot create a lambda expression from this argument: #{arg.inspect}!\"\n end\n end",
"def create_lambda(arg)\n case arg\n when Proc then arg\n when Symbol then lambda { |request| request[arg] }\n else raise \"Canot create a lambda expression from this argument: #{arg.inspect}!\"\n end\n end",
"def test_lambda\n (->(){return \"Game Over\"}).call()\n puts \"Despues de la lambda\"\nend",
"def batman_ironman_lambda\n victor = lambda { return \"Batman will win!\" }\n victor.call\n \"Iron Man will win!\"\nend",
"def batman_ironman_lambda\n victor = lambda { return \"Batman will win!\" }\n victor.call\n \"Iron Man will win!\"\nend",
"def batman_ironman_lambda\n victor = lambda { return \"Batman will win!\" }\n victor.call\n \"Iron Man will win!\"\nend",
"def lambdaTest\n fun = lambda { |x| x += 10; return x }\n puts \"---------- lambdaTest ----------\"\n puts fun.call(10).to_s\nend",
"def eval_lambda(node, env, stack_trace)\n\treturn Closure.new(node.line, node.col, node.args, env.clone, node.body), env\t\t\nend",
"def exec_lambda expr\n wolfram_result expr\n end",
"def wrapper\n -> fn { -> { fn } }\n end",
"def anonymous_function(block)\n lambda do |*args|\n # args: (this, node) v8 >= 0.10, otherwise (node)\n raise ArgumentError, \"missing node\" if args.empty?\n @tree[:Anonymous].new block.call(@tree, args.last)\n end\n end",
"def make_lambda(filter)\n case filter\n when Symbol\n lambda { |target, _, &blk| target.send filter, &blk }\n when Conditionals::Value then filter\n when ::Proc\n if filter.arity > 1\n return lambda { |target, _, &block|\n raise ArgumentError unless block\n target.instance_exec(target, block, &filter)\n }\n end\n\n if filter.arity <= 0\n lambda { |target, _| target.instance_exec(&filter) }\n else\n lambda { |target, _| target.instance_exec(target, &filter) }\n end\n else\n scopes = Array(chain_config[:scope])\n method_to_call = scopes.map{ |s| public_send(s) }.join(\"_\")\n\n lambda { |target, _, &blk|\n filter.public_send method_to_call, target, &blk\n }\n end\n end",
"def create_function( db, name, args, text, cookie, func, step, final )\n if func || ( step && final )\n cb = CallbackData.new\n cb.proc = cb.proc2 = nil\n cb.data = cookie\n end\n\n if func\n cb.proc = func\n step = final = nil\n elsif step && final\n cb.proc = step\n cb.proc2 = final\n\n func = nil\n end\n\n result = CSSQLite.sqlite3_create_function( db, name, args, text, cb, func, step, final )\n\n # see comments in busy_handler\n if cb\n @callback_data[ name ] = cb\n else\n @callback_data.delete( name )\n end\n\n return result\n end",
"def batman_ironman_lambda #checks number of arguments\n victor = lambda { return \"Batman will win!\" }\n victor.call\n \"Iron Man will win!\"\nend",
"def lambdaBuilder(message)\r\n lambda{puts message; return}\r\nend",
"def to_lambda(source_proc)\n return source_proc if source_proc.lambda?\n\n unbound_method = Module.new.module_eval do\n instance_method(define_method(:_, &source_proc))\n end\n\n lambda do |*args, &block|\n unbound_method.bind(self).call(*args, &block)\n end\n end",
"def lambda_literal?\n true\n end",
"def invoke_lambda(lambda, binding_, *context)\n if lambda.arity.zero?\n binding_.instance_exec(&lambda)\n else\n binding_.instance_exec(*context, &lambda)\n end\n end",
"def adder(a, b)\n lambda { a + b }\nend",
"def lambdaa\n var = lambda{return 'Amit'}\n #call the lambda from here\n 'Kamal'\n end",
"def lambda?\n true\n end",
"def lambda_vs_proc\n my_lam = lambda { return puts \"Hi, I'm your lambda!\" }\n my_lam.call\n puts 'Returned from lambda!'\n my_proc = Proc.new { return puts 'Hello from proc!' }\n my_proc.call\n puts 'The proc will not allow this to be seen!'\nend",
"def eClosure(ss)\n end",
"def add_function(name, &block)\n functions[name] = anonymous_function(block)\n end",
"def lambda_method\n my_lambda = lambda {return \"I'm a lambda\"}\n my_lambda.call\n return \"I'm the last line of the method!\"\nend",
"def apply_lambda(closure, values)\n names, body, env = extract_closure_exp(closure)\n new_env = extend_env(names, values, env)\n _eval(body, new_env)\n end",
"def lambda_function(handler:,\n code_bucket: nil,\n code_key: nil,\n runtime:)\n fn_resource = {\n 'Type' => 'AWS::Lambda::Function',\n 'Properties' => {\n 'Handler' => handler,\n 'Role' => { 'Fn::GetAtt' => %w[FunctionNameRole Arn] },\n 'Runtime' => runtime\n }\n }\n lambda_function_code(fn_resource, code_bucket, code_key)\n end",
"def another_lambda\n l = lambda {return 1}\n l.call\n puts \"After Lambda\"\nend",
"def diet_lambda\n status = -> { return 'You gave in' }\n status.call\n 'you completed the diet!'\nend",
"def lamda_method\n l = lambda { return \"\\nreturning from lamda\\n\"}\n l.call\n print \"\\nStatement after lamda\\n\"\nend",
"def my_lambda\n\n\tputs \"first lambda\"\n\n\tproc1 = lambda {\n\n\t\tputs \"second lambda\"\n\t\t#breaak or return\n\n\t}\n\n\tproc1.call\n\tputs \"last lambda\"\nend",
"def run(ast)\n map_tree_with ast, lambda: ->(lmb) {\n mklambda(parmlist_of_lambda(lmb), handle_block(block_of_lambda(lmb)))\n }\n end",
"def on_iter( node )\n descend( node )\n target, args, block = node\n \n func = build_function( args, block )\n block.delete!\n \n case target.type\n when CALL, NEW\n arg_node = target.last\n if placeholder = arg_node.find { | child | child.type == FUNC_ARG }\n placeholder.replace!( func )\n else\n append_argument( arg_node, func )\n end\n else\n if target.type == ID and target.text == 'eval'\n node.replace!( \"(#{ func })()\" )\n else\n target.append!( '( ' << func << ' )' )\n end\n end\n end",
"def lambdasaurus(some_code)\n\tputs \"I am a header\"\n\tsome_code.call\n\tputs \"I am a footer\"\nend",
"def lambda_inside\n return_lambda = lambda { return }\n return_lambda.call\n puts \"In Method! (Lambda)\"\nend",
"def lambda_tester\n puts \"To string: #{self}\"\n puts \"kind: #{self.kind}\"\n case self.kind\n when :variable\n puts \"value: #{self.value}\"\n when :abstraction\n puts \"bound_var: #{self.bound_var}\"\n puts \"body: #{self.body}\"\n when :application\n puts \"function: #{self.function}\"\n puts \"argument: #{self.argument}\"\n end\n end",
"def another_lambda\n\tl = lambda {return}\n\tl.call\n\tputs \"After Lambda\"\nend",
"def subtractClosure(num)\n return lambda {|x| num - x}\nend",
"def diet_lambda\n status = lambda { return \"You gave in\"}\n status.call\n \"You completed the diet\"\nend",
"def lambda_stack; end",
"def lambda_stack; end",
"def lambda_stack; end",
"def initialize(logging_lambda, page_add_lambda, page_remove_lambda, collection_by_name_lambda)\r\n @logging_lambda = logging_lambda\r\n @page_add_lambda = page_add_lambda\r\n @page_remove_lambda = page_remove_lambda\r\n @collection_by_name_lambda = collection_by_name_lambda\r\n end",
"def compile_callback(meth, args = {})\n code( js_repl meth, js_json_parms(args) )\n\n self._compiled = <<\"JAVASCRIPT\"\n(function(repl) {\n try {\n #{code.join(' ')}\n } catch(e) {\n repl.rc_fail(e.name, e.message ? e.message : e);\n };\n})(#{replid});\nJAVASCRIPT\n\n self._code = []\n end",
"def create_function(params={})\n runtime = params.delete('Runtime') || 'nodejs'\n code = params.delete('Code')\n function_name = params.delete('FunctionName')\n handler = params.delete('Handler')\n role = params.delete('Role')\n\n data = {\n 'Runtime' => runtime,\n 'Code' => code,\n 'FunctionName' => function_name,\n 'Handler' => handler,\n 'Role' => role\n }\n\n description = params.delete('Description')\n data.merge!('Description' => description) if description\n\n memory_size = params.delete('MemorySize')\n data.merge!('MemorySize' => memory_size) if memory_size\n\n timeout = params.delete('Timeout')\n data.merge!('Timeout' => timeout) if timeout\n\n request({\n :method => 'POST',\n :path => '/functions',\n :expects => 201,\n :body => Fog::JSON.encode(data),\n :parser => Fog::AWS::Parsers::Lambda::Base.new\n }.merge(params))\n end",
"def to_proc\n lambda { |x| }\n end",
"def demonstrate_block(number)\n yield(number) #yield keyword calls the single lambda that has been implicitly passed to a method without using the parameter list\nend",
"def output_functions\n # This is a bit ugly, but handles the case of lambdas or inner\n # functions being added during the compilation... Should probably\n # refactor.\n while f = @global_functions.shift\n name = f[0]\n func = f[1]\n # create a function scope for each defined function and compile it appropriately.\n # also pass it the current global scope for further lookup of variables used\n # within the functions body that aren't defined there (global variables and those,\n # that are defined in the outer scope of the function's)\n\n fscope = FuncScope.new(func)\n\n pos = func.body.respond_to?(:position) ? func.body.position : nil\n fname = pos ? pos.filename : nil\n\n @e.include(fname) do\n # We extract the usage frequency information and pass it to the emitter\n # to inform the register allocation.\n varfreq = func.body.respond_to?(:extra) ? func.body.extra[:varfreq] : []\n @e.func(name, pos, varfreq) do\n minargs = func.minargs\n\n compile_if(fscope, [:lt, :numargs, minargs],\n [:sexp,[:call, :printf, \n [\"ArgumentError: In %s - expected a minimum of %d arguments, got %d\\n\",\n name, minargs - 2, [:sub, :numargs,2]]], [:div,1,0] ])\n\n if !func.rest?\n maxargs = func.maxargs\n compile_if(fscope, [:gt, :numargs, maxargs],\n [:sexp,[:call, :printf, \n [\"ArgumentError: In %s - expected a maximum of %d arguments, got %d\\n\",\n name, maxargs - 2, [:sub, :numargs,2]]], [:div,1,0] ])\n end\n\n if func.defaultvars > 0\n @e.with_stack(func.defaultvars) do \n func.process_defaults do |arg, index|\n @e.comment(\"Default argument for #{arg.name.to_s} at position #{2 + index}\")\n @e.comment(arg.default.inspect)\n compile_if(fscope, [:lt, :numargs, 1 + index],\n [:assign, (\"#\"+arg.name.to_s).to_sym, arg.default],\n [:assign, (\"#\"+arg.name.to_s).to_sym, arg.name])\n end\n end\n end\n\n compile_eval_arg(fscope, func.body)\n\n @e.comment(\"Reloading self if evicted:\")\n # Ensure %esi is intact on exit, if needed:\n reload_self(fscope)\n end\n end\n end\n end",
"def eval_lambda(args, current_cont)\n\t\t\tlambda, arg_ast, eval_env = args[:lambda], args[:arg_ast], args[:env]\n\t\t\t\n\t\t\t# First eval the arguments in the current eval environment\n\t\t\tunless args[:evaled_args]\n\t\t\t\tunevaled_args = lisp_list_to_array(arg_ast)\n\t\t\t\tunless lambda.arg_names.size == unevaled_args.size\n\t\t\t\t\treturn current_cont.heap[:error_handler].with message:\n\t\t\t\t\t\t\"Lambda requires #{lambda.arg_names.size} arguments but #{unevaled_args.size} were given\",\n\t\t\t\t\t\tast: LispPair.new(lambda, arg_ast), backtrace: caller(0)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn current_cont.create_before method(:eval_function_args), unevaled_args: unevaled_args, env: eval_env\n\t\t\tend\n\t\t\t\n\t\t\t# We got all arguments evaled, now build a new environment with them and execute the lambda in there\n\t\t\tevaled_args = args[:evaled_args]\n\t\t\texecution_env = Environment.new lambda.env\n\t\t\tevaled_args.each_with_index do |evaled_arg, index|\n\t\t\t\texecution_env[lambda.arg_names[index].to_sym] = evaled_arg\n\t\t\tend\n\t\t\t\n\t\t\treturn current_cont.create_after method(:eval), ast: lambda.body, env: execution_env\n\t\tend",
"def arel_fn(name, *args)\n Arel::Nodes::NamedFunction.new(name, args)\n end",
"def parse_lambda cur_tok\n\t\targs = splitter(\"(\", \")\", \",\")\n\t\tbody = splitter(\"{\", \"}\", nil)\n\t\tLambda.new(cur_tok.line, cur_tok.col, args, Program.new(cur_tok.line, cur_tok.col, body))\n\tend",
"def exec_lambda expr\n uri = URI.parse(INTERPRETER)\n # TODO: error handling\n response = Net::HTTP.post_form uri, \"expr\" => expr\n\n begin\n body = JSON.parse(response.body)\n if body[\"Success\"]\n JSON.parse body[\"Result\"]\n else\n @errors << \"wolfram syntax error: #{body['MessagesText'].join(\"\\n\")}\"\n return false\n end\n rescue JSON::ParserError => e\n raise Card::Error, \"failed to parse wolfram result: #{expr}\"\n end\n end",
"def make_function(exp, register = true)\n name = map_name exp.shift\n args = exp.shift\n ruby_args = args.deep_clone\n ruby_args.shift # :args\n\n @method_name = name\n @c_method_name = \"rrc_c#{@c_klass_name}_#{normal_to_C name}\"\n\n @env.scope do\n c_args = check_args args, register # registered methods get self\n @methods[name] = ruby_args if register\n\n body = process exp.shift\n\n if name == :initialize then\n body[-1] = \"return self;\\n}\"\n end\n\n return \"static VALUE\\n#{@c_method_name}#{c_args} #{body}\"\n end\n end",
"def accept(evaluator)\n evaluator.lambda_expr(self)\n end",
"def test_can_pass_a_lambda_to_lambda_indexed_in_a_list\n result = interpret <<-EOC\na=~{callme: ->(fn) { %fn }}\n%a[callme:](->() {4})\nEOC\n assert_eq result, 4\n end",
"def function(*args)\n Function.new(self, *args)\n end",
"def function(*args)\n Function.new(self, *args)\n end",
"def source\n @callable\n end",
"def source\n @callable\n end",
"def named_function(name, expression, function_alias = nil)\n Arel::Nodes::NamedFunction.new(name, expression, function_alias)\n end",
"def fn(name, &block)\n if block_given?\n @fns[name] = block\n else\n @fns[name]\n end\n end",
"def fn(name, &block)\n if block_given?\n @fns[name] = block\n else\n @fns[name]\n end\n end",
"def visitFunction func,args=nil\n type=func.type.accept(self)\n name=func.name.accept(self)\n args=func.args.collect{|arg| arg.accept(self)}\n body=func.body.accept(self)\n Function.new(name,type,args,body)\n end",
"def get_lambda(sexp)\n l=nil\n visit_tree(sexp, lambda: ->(x) { l=x})\n l\nend",
"def prepare_lambda given\n case given\n when String\n if given['%s']\n ->(x){ eval(given % x) }\n else\n ->(x){ eval given }\n end\n else\n given\n end\n end",
"def stringify_lambda(lambda)\n lambda.source.scan(LAMBDA_PROC_REGEX).flatten.compact.first\n end",
"def fn\n Fn\n end",
"def anonymous?; end",
"def define_functional_variable(name, &block)\n functional_variables[name.to_sym] = block\n nil\n end",
"def to_php\n body = children? ? ('{ ' << children.map(&:to_php).join('; ') << ' }') : '{}'\n if anonymous?\n \"function(#{parameters.join(', ')}) \" << body # FIXME\n else\n \"function #{name}(#{parameters.join(', ')}) \" << body # FIXME\n end\n end",
"def function(*code)\n Function.new(*code)\nend",
"def lambda?\n block_literal? && method?(:lambda)\n end",
"def test_can_call_lambda_in_list_indexed_w_fn_return\n result = interpret 'defn foo() {0}; a=[->() {9}]; %a[foo()]'\n assert_eq result, 9\n end",
"def to_proc\n lambda{ call }\n end",
"def wrap_with_function_pointer(func_pointer)\n Logger.info \"Building callback wrapper for #{self.code.qualified_name}\"\n\n base_name = self.code.qualified_name.as_variable\n return_type = func_pointer.return_type.to_cpp\n proxy_method_name = \"do_yield_on_#{base_name}\"\n\n callback_arguments = []\n callback_values = [func_pointer.arguments.length]\n\n func_pointer.arguments.each_with_index do |arg, i|\n callback_arguments << \"#{arg.to_cpp} arg#{i}\"\n callback_values << \"to_ruby(arg#{i}).value()\"\n end\n\n # Build the method that acts as the Proc -> C func pointer proxy (the callback)\n block_var_name = \"_block_for_#{base_name}\"\n declarations << \"VALUE #{block_var_name};\"\n declarations << \"#{return_type} #{proxy_method_name}(#{callback_arguments.join(\", \")}) {\"\n\n funcall = \"rb_funcall(#{block_var_name}, rb_intern(\\\"call\\\"), #{callback_values.join(\", \")})\"\n if return_type == \"void\"\n declarations << \"\\t#{funcall};\"\n else\n declarations << \"\\treturn from_ruby<#{return_type} >(#{funcall});\"\n end\n\n declarations << \"}\"\n\n if self.parent.is_a?(ClassNode)\n arg = \"#{self.parent.qualified_name} *self\"\n callee = \"self->#{self.code.qualified_name}\"\n else\n arg = \"\"\n callee = \"#{self.code.qualified_name}\"\n end\n\n wrapper_func = \"wrap_for_callback_#{base_name}\"\n\n # Build the wrapper method that gets exposed to Ruby\n declarations << \"VALUE #{wrapper_func}(#{arg}) {\"\n declarations << \"\\t#{block_var_name} = rb_block_proc();\"\n declarations << \"\\trb_gc_register_address(&#{block_var_name});\"\n declarations << \"\\t#{callee}(&#{proxy_method_name});\"\n declarations << \"\\treturn Qnil;\"\n declarations << \"}\"\n\n registrations << \"\\t#{self.prefix}#{self.rice_method}(\\\"#{@ruby_name + self.suffix}\\\", &#{wrapper_func});\"\n end",
"def add(f)\n @lambdas.push(f)\n end",
"def curry fn,*a\r\n return lambda { |*b|\r\n fn.call(*(a + b))\r\n }\r\nend",
"def to_s\n l = \" (lambda)\" if lambda?\n \"#<#{self.class}:0x#{self.object_id.to_s(16)}@#{@block.file}:#{@block.line}#{l}>\"\n end",
"def process_defn(exp)\n make_function exp\n end",
"def visitFunction func,args=nil\n code=Code.new\n tname=func.type.accept(self)\n fname=func.name.accept(self)\n args=func.args.collect{|arg| arg.accept(self)}\n args=args.join(\",\")\n code << \"\\n#{tname} #{fname}(#{args})\"\n code.indent=2\n code << func.body.accept(self)\n code.indent=0\n return code\n end",
"def closure\n n = -25\n return Proc.new { \"n was #{n}, n is now #{n += 1}\"}\n end",
"def test_returnfrom_lambda\n result = interpret 'lm=->() { return 99; 2 };%lm()'\n assert_eq result, 99\n end",
"def logic name, lambda = nil, success: true, fail: false, &block\n # TODO: 控制器划分\n MakeSure.logics[name] = { block: block, lambda: lambda, success: success, fail: fail }\n end",
"def function_literal\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 70 )\n return_value = FunctionLiteralReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal333 = nil\n string_literal337 = nil\n variable_name334 = nil\n function_parameters335 = nil\n statement_block336 = nil\n variable_name338 = nil\n function_parameters339 = nil\n statement_block340 = nil\n\n tree_for_string_literal333 = nil\n tree_for_string_literal337 = nil\n\n begin\n # at line 715:3: ( 'function' ( variable_name )? function_parameters statement_block | '->' ( variable_name )? ( function_parameters )? statement_block )\n alt_86 = 2\n look_86_0 = @input.peek( 1 )\n\n if ( look_86_0 == FUNCTION )\n alt_86 = 1\n elsif ( look_86_0 == ARROW )\n alt_86 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 86, 0 )\n end\n case alt_86\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 715:5: 'function' ( variable_name )? function_parameters statement_block\n string_literal333 = match( FUNCTION, TOKENS_FOLLOWING_FUNCTION_IN_function_literal_5064 )\n if @state.backtracking == 0\n\n tree_for_string_literal333 = @adaptor.create_with_payload( string_literal333 )\n root_0 = @adaptor.become_root( tree_for_string_literal333, root_0 )\n\n end\n # at line 715:17: ( variable_name )?\n alt_83 = 2\n look_83_0 = @input.peek( 1 )\n\n if ( look_83_0 == GET || look_83_0 == SET || look_83_0 == MACRO || look_83_0 == EACH || look_83_0.between?( DEF, OBJECT_DEF ) || look_83_0 == ID || look_83_0.between?( T__148, T__150 ) )\n alt_83 = 1\n end\n case alt_83\n when 1\n # at line 715:17: variable_name\n @state.following.push( TOKENS_FOLLOWING_variable_name_IN_function_literal_5067 )\n variable_name334 = variable_name\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, variable_name334.tree )\n end\n\n end\n @state.following.push( TOKENS_FOLLOWING_function_parameters_IN_function_literal_5070 )\n function_parameters335 = function_parameters\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, function_parameters335.tree )\n end\n @state.following.push( TOKENS_FOLLOWING_statement_block_IN_function_literal_5072 )\n statement_block336 = statement_block\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, statement_block336.tree )\n end\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 716:5: '->' ( variable_name )? ( function_parameters )? statement_block\n string_literal337 = match( ARROW, TOKENS_FOLLOWING_ARROW_IN_function_literal_5078 )\n if @state.backtracking == 0\n\n tree_for_string_literal337 = @adaptor.create_with_payload( string_literal337 )\n root_0 = @adaptor.become_root( tree_for_string_literal337, root_0 )\n\n end\n # at line 716:11: ( variable_name )?\n alt_84 = 2\n look_84_0 = @input.peek( 1 )\n\n if ( look_84_0 == GET || look_84_0 == SET || look_84_0 == MACRO || look_84_0 == EACH || look_84_0.between?( DEF, OBJECT_DEF ) || look_84_0 == ID || look_84_0.between?( T__148, T__150 ) )\n alt_84 = 1\n end\n case alt_84\n when 1\n # at line 716:11: variable_name\n @state.following.push( TOKENS_FOLLOWING_variable_name_IN_function_literal_5081 )\n variable_name338 = variable_name\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, variable_name338.tree )\n end\n\n end\n # at line 716:26: ( function_parameters )?\n alt_85 = 2\n look_85_0 = @input.peek( 1 )\n\n if ( look_85_0 == LPAREN )\n alt_85 = 1\n end\n case alt_85\n when 1\n # at line 716:26: function_parameters\n @state.following.push( TOKENS_FOLLOWING_function_parameters_IN_function_literal_5084 )\n function_parameters339 = function_parameters\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, function_parameters339.tree )\n end\n\n end\n @state.following.push( TOKENS_FOLLOWING_statement_block_IN_function_literal_5087 )\n statement_block340 = statement_block\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, statement_block340.tree )\n end\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 70 )\n\n end\n \n return return_value\n end",
"def transforming_body_expr=(_); end",
"def stabby_lambda?\n target.type.equal?(:lambda)\n end"
] | [
"0.6354189",
"0.6065641",
"0.5721369",
"0.5721369",
"0.5721369",
"0.5705837",
"0.5681615",
"0.5620382",
"0.55595595",
"0.5537422",
"0.54664105",
"0.546107",
"0.5458064",
"0.5449111",
"0.5443965",
"0.54267263",
"0.54267263",
"0.5374135",
"0.5336062",
"0.5336062",
"0.5336062",
"0.53072405",
"0.52879983",
"0.52417505",
"0.5213835",
"0.5175788",
"0.5171465",
"0.5108893",
"0.50668454",
"0.5044986",
"0.50436676",
"0.49983293",
"0.4972679",
"0.49648628",
"0.49125403",
"0.48885012",
"0.48844123",
"0.48797783",
"0.48695254",
"0.48563498",
"0.48360988",
"0.48344806",
"0.48308006",
"0.4814793",
"0.47393388",
"0.472836",
"0.46996146",
"0.46663454",
"0.46495172",
"0.46474218",
"0.46226135",
"0.46115434",
"0.46049407",
"0.4597701",
"0.45949045",
"0.45949045",
"0.45949045",
"0.45890474",
"0.45839298",
"0.45774823",
"0.45548195",
"0.45508277",
"0.45479017",
"0.45452696",
"0.4533406",
"0.45205763",
"0.4506331",
"0.44965076",
"0.44867417",
"0.44694412",
"0.44540974",
"0.44540974",
"0.44529143",
"0.44529143",
"0.44516453",
"0.44390455",
"0.44390455",
"0.44387782",
"0.44354844",
"0.4429736",
"0.44221616",
"0.44063777",
"0.43946314",
"0.43908197",
"0.43887848",
"0.43820196",
"0.4378887",
"0.43476477",
"0.43465596",
"0.43345824",
"0.43288437",
"0.4321409",
"0.43186295",
"0.4307288",
"0.42965534",
"0.42949888",
"0.4294647",
"0.42842",
"0.42789277",
"0.4276596",
"0.42703354"
] | 0.0 | -1 |
euler020 6/22/12 Find the sum of the digits in the number 100! ============================================================================ | def euler020
def fact(x)
ans = x.downto(1).reduce(:*)
end
fact(100).to_s.split('').map { |x| x.to_i}.reduce(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euler_sum \n\tnums = (1...999).select { |n| n % 3 === 0 || n % 5 === 0 }\n\n\tnum_sum = nums.inject(0) {|s, n| s += n }\nend",
"def euler_sum\n sum = (0..999).select {|n| n%3==0 || n%5==0}.inject(0) {|s,n| s+=n}\n sum\nend",
"def euler016\n (2 ** 1000).to_s.split('').map { |x| x.to_i }.reduce(:+)\nend",
"def sum_of_digits(number)\n\treturn (number/100)+((number/10)%10)+(number%10)\nend",
"def euler006\n square_of_sum = (1..100).reduce(:+) ** 2\n sum_of_squares = (1..100).inject { |sum, n| sum + n*n }\n\n return square_of_sum - sum_of_squares\nend",
"def problem_80b(size = 100)\n total = 0\n (2..100).each do |n|\n r = n.sqrt_digits(size+1)\n next if r.length == 1\n r = r[0,size].reduce(&:+)\n total += r\n# puts \"#{n} #{r.inspect}\"\n end\n total\nend",
"def checksum\n (10 - (digits.each_with_index.inject(0) do |sum, (digit, index)|\n sum + (digit * (index.even? ? 1 : 3))\n end % 10)) % 10\n end",
"def problem_80a(size = 100)\n require 'bigdecimal'\n ((1..100).inject(0) do |sum,num|\n if !(Math.sqrt(num)%1==0)\n digits = BigDecimal.new(num.to_s).sqrt(size).to_s[2,size]\n sum += digits.split(//).inject(0) do |digsum,n|\n digsum + n.to_i\n end\n end\n sum\n end)\nend",
"def digits_sum\n self.split('').map {|x| x.to_i}.inject(0) do |res,elt|\n res += elt\n res\n end\n end",
"def sum_digits\n self.to_s.split('').inject(0) { |memo, c| memo + c.to_i }\n end",
"def euler1\n sum = 0;\n 1..1000.times do |x|\n y = x + 1\n if (x % 3).zero? || (x % 5).zero?\n sum = sum + x\n end\n end\n p sum\nend",
"def euler001\n (1...1000).select { |i| i % 3 == 0 or i % 5 == 0 }.reduce(:+)\nend",
"def digits_sum(n)\n n.to_s.split('').inject(0){|a,b|a+=b.to_i}\nend",
"def sum_of_digits(n)\n sum = 0\n n.each_char {|digit| sum += digit.to_i}\n\n puts sum\nend",
"def sum_digits( i )\n sum = 0\n\n i.to_s.split( // ).each do |d|\n sum += d.to_i\n# sum += $a_to_i[d.ord]\n end\n\n sum\nend",
"def euler_1\n number = 1\n sum = 0\n while number < 1000\n if (number % 3 == 0 || number % 5 == 0)\n sum += number \n end\n number += 1\n end\n p sum\nend",
"def euler65\n vec = []\n val = tmp = den = num = 0 \n (0..98).each do |i|\n val = i%3==1 ? 2*(i/3+1) : 1\n vec.push(val)\n\n den = 1 \n num = vec.last\n vec.reverse.drop(1).each do |r| \n tmp = num;\n num = num * r + den; \n den = tmp;\n end\n \n den = 2 * num + den;\n $ans = den.to_s.split(//).inject(0){|sum,x| sum+x.to_i}\n end\nend",
"def sum(n)\n n.digits.sum\nend",
"def brut_force_solution\n (1...1000).inject(0){|sum, digit| ((digit % 3 == 0) || (digit % 5 == 0)) ? sum += digit : sum}\nend",
"def suma(num)\n\t\ttotal =0\n\t\t((num*2).to_s.chars.map(&:to_i)).each{|x| total+=x}\n\t\treturn total\n\tend",
"def digit_sum (number)\n sum = 0\n base = 10\n while number > 0 do\n sum += number % base\n number /= base\n end\n return sum\nend",
"def sum_of_factorial_digits(factorial)\r\n\tthe_factorial = (1..factorial).inject(1){ |milti, i| milti * i }\r\n\r\n\treturn the_factorial.to_s.split('').inject(0){ |sum, i| sum + i.to_i }\r\nend",
"def sum(num)\n digits = []\n sum = 0\n digits = num.digits\n sum = digits.sum\n return sum\nend",
"def sumDigits(number)\n sol = 0\n number.abs.to_s.each_char do |x|\n sol += x.to_i\n end\n print sol\n\nend",
"def digit_factorial_sum(num)\n sum = 0\n num.to_s.split(//).each do |digit|\n sum += factorial(digit.to_i)\n end\n return sum\nend",
"def sum_of_digits(n)\n digits = n.to_s.split(//).map(&:to_i)\n digits.inject(0) { |sum, digit| sum + digit}\nend",
"def euler048\n (1..1000).each.reduce { |a,i| a + i**i }.to_s.slice(-10, 10).to_i\nend",
"def sum(num)\n digits = num.to_s.chars.map(&:to_i) # Get an array of ints\n digits.reduce(:+) # Return sum of digits\nend",
"def euler001(max)\n\ti = 1\n\tsum = 0\n\tmax.times do |i|\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tsum += i\n\t\tend\n\tend\n\tprint(sum, \"\\n\")\nend",
"def problem_80(size = 100)\n total = 0\n (2..100).each do |n|\n n,d = n.sqrt_frac(2*size)\n next unless n\n r = n * (10 ** (size * 1.1).to_i) / d\n r = r.to_s[0,size].split(//).map(&:to_i).reduce(&:+)\n total += r\n# puts r.inspect\n end\n total\nend",
"def digital_root(n)\n p '--- Jan-09-2017 problem2 --- '\n n = n.to_s.chars.map(&:to_i).reduce(:+) until n < 10\n n\nend",
"def sum_digits(n)\n remaining = n\n sum = 0\n while remaining > 0\n sum += remaining % 10\n remaining = remaining / 10\n end\n sum\nend",
"def sum_of_even_digits(n) #adds every even digit\n n = n.to_s.split(//)\n reverse_cc = n.reverse.values_at(1,3,5,7,9,11,13,15).compact\n sum_evens = 0\n reverse_cc.each do |cc_number|\n doubled = cc_number.to_i * 2\n sum_evens += get_digit(doubled)\n end\n return sum_evens\nend",
"def sum_of_digit(n)\n sum = 0\n n.to_s.each_char {|i| sum = sum + i.to_i}\n puts sum\nend",
"def sumaint(digitos)\n suma = 0\n if digitos.to_i < 0\n digitos = digitos.to_i\n digitos*= -1\n negativo = true\n end\n arreglo = digitos.to_s.chars\n for digito in arreglo\n dig = digito.to_i\n suma += dig\n end\n if negativo == true\n suma *= -1\n end\n return suma\nend",
"def sum(number)\r\n number.digits.sum\r\nend",
"def sumdig_i(n)\n nums = n.to_s.chars.map(&:to_i).inject(:+)\nend",
"def sum(i)\n sum = i.digits.reduce(:+)\n sum\nend",
"def sum_of_digits(num)\n\tsum = 0\n\tnum.to_s.each_char { |x| sum = sum + x.to_i}\n\tputs sum\nend",
"def sum(number)\n sum = 0\n str_digits = number.to_s.chars\n\n str_digits.each do |str_digit|\n sum += str_digit.to_i\n end\n\n sum\nend",
"def numsum(n)\n result = 0\n while n >= 1\n digit = (n % 10).floor\n result += digit\n (n /= 10).floor\n end\n puts result\nend",
"def sum(number)\n number.digits.sum\nend",
"def sum(number)\n number.digits.sum\nend",
"def digit_sum(int)\n return int.digits.sum\nend",
"def sum_digits(num)\n\nend",
"def digit_sum(num, digits)\n if digits == 1\n num\n else\n num % 10 + digit_sum(num / 10, digits - 1)\n end\nend",
"def sum_of_digits(number)\n sum = 0\n digits = number.to_s\n digits.each_char { |c| sum += c.to_i }\n sum\nend",
"def value_of_summed_digits_of_this_less_than_100_number( number )\n\n raise ArgumentError \"number must be two digits\" unless number < 100\n\n sum = 0\n\n if number >= 10\n sum = number / 10 \n end\n \n sum += number % 10\n\n sum\nend",
"def sum(num)\n num.digits.sum\nend",
"def sum(num)\n num.digits.sum\nend",
"def sum(num)\n num.digits.sum\nend",
"def sum(num)\n num.digits.sum\nend",
"def intSumOfDigitsInt2 i\n result = 0\n i.to_s.bytes.each do |i|\n result += i - 48\n end\n result\nend",
"def sum_of_digits(number)\n split_to_array(number).inject(:+)\n end",
"def sum(num)\n num.to_s.chars.map(&:to_i).sum\nend",
"def digit_factorials\r\n\tanswer = 0\r\n\t# Find upper bound for calculations. Since 9!*7 has seven digits and 9!*8 has seven digits, we use 9!*7\r\n\tlimit = (1..9).inject(:*)*7\r\n\t(10..limit).each do |x|\r\n\t\tputs x\r\n\t\tsum = 0\r\n\t\tnumber = x\r\n\t\t# Cycle through all digits of the number\r\n\t\twhile number > 0\r\n\t\t\t# Add factorial of digit to sum unless digit is 0, then add 1 because 0! is 1\r\n\t\t\tnumber%10 == 0 ? sum += 1 : sum += (1..number%10).inject(:*) \r\n\t\t\tnumber /= 10\r\n\t\tend\r\n\t\t# Add sum to answer if sum is equal to number\r\n\t\tanswer += sum if sum == x\r\n\tend\r\n\tputs answer\r\nend",
"def sum_digits(n)\n return n if n <= 9\n n % 10 + sum_digits(n / 10)\nend",
"def sumDigits(number)\n number.to_s.chars.map(&:to_i).reduce\nend",
"def solve\n sum = 0\n (1..999).each do |n|\n if n % 3 == 0 or n % 5 == 0\n sum += n\n end\n end\n sum\nend",
"def sum(int)\n int.digits.sum\nend",
"def twenty\n sum_of_digits(factorial(100))\nend",
"def sum(num)\n num.to_s.chars.map(&:to_i).reduce(:+)\nend",
"def sum(num)\n num.to_s.chars.map(&:to_i).reduce(:+)\nend",
"def sum(number)\n number.to_s.chars.map(&:to_i).reduce(:+)\nend",
"def sum(number)\n number.to_s.chars.map(&:to_i).reduce(:+)\nend",
"def sum(number)\n number.to_s.chars.map(&:to_i).reduce(:+)\n \nend",
"def sum(integer)\n digits = integer.to_s.chars.map {|x|x.to_i}\n total = digits.reduce(0) {|sum,x| sum += x}\n #integer.to_s.chars.map(&:to_i).reduce(&:+)\nend",
"def sum(num)\n\n\tarray_of_digits = num.digits\n\n\tarray_of_digits.sum\n\nend",
"def solve\n 1.upto(100).inject(:*).to_s.split('').map{|x| x.to_i}.inject(:+)\nend",
"def digital_root(n)\r\n digits = n.digits\r\n \r\n counter = digits.length\r\n\r\nuntil counter.size == 1\r\np sum = digits.sum\r\np sum.digits.sum\r\np counter -= 1\r\n end \r\n\r\nend",
"def super_digit(n)\n return n if n <= 9\n \n until n < 10\n sum = 0\n sum += (n % 10)\n sum += (n / 10)\n n = sum\n end\n\n return sum\nend",
"def sumDig(n)\n sum=0\n n.downto(1).inject(:*).to_s.each_char { |x| sum=sum+x.to_i }\n puts sum\nend",
"def digital_sum(int)\n\tif int.div(10) == 0\n\t\treturn int.modulo(10)\n\telse\n\t\treturn int.modulo(10) + digital_sum(int.div(10))\n\tend\nend",
"def sum(number)\n numbers = number.to_s.chars\n\n numbers.reduce {|sum, i| sum.to_i + i.to_i }\nend",
"def sum(number)\n sum = number.to_s.chars\n total = sum.map {|num| num.to_i }\n total.reduce(:+)\nend",
"def sum_dig(nu)\n if nu < 0\n nu *= -1\n end\n n = 0\n sum = 0\n nu.digits.each do |n|\n sum += n\n end\n return sum\n end",
"def sum(int)\n digits = int.to_s.split('')\n digits.map!(&:to_i)\n digits.reduce(:+)\nend",
"def digital_root(n)\r\n while n > 9\r\n n = n.digits.inject(:+)\r\n end\r\n n\r\nend",
"def sum(integer)\n integer.digits.sum\nend",
"def power_digit_sum(num)\n x = num.to_s\n index = 0\n total = 0\n while index < x.length\n total += x[index].to_i\n index += 1\n end\n print total\nend",
"def digital_root(n)\n arr = n.to_s.split('')\n if arr.length != 1\n tot = arr.inject(0){|sum,x| sum.to_i + x.to_i }\n while (tot >= 10)\n tot = tot.to_s.split('').inject(0){|sum,x| sum.to_i + x.to_i }\n end\n else \n return arr[0].to_i\n end\n return tot\n end",
"def sumdigit_r(num)\n if num < 10\n num\n else\n sumdigit_r(num/10) + num % 10\n end\nend",
"def digit_sum_old(int)\n return int.to_s.split('').map(&:to_i).sum\nend",
"def modulo(digit_sum)\n digit_sum % 10 == 0\n end",
"def euler028 n\n (4*n**3 + 3*n**2 + 8*n - 9) / 6\nend",
"def sumdig_i(num)\n num.to_s.split('').map(&:to_i).reduce(:+)\nend",
"def sumDigits(number)\n number.to_s.chars.map(&:to_i).reduce { |accum, n| accum.abs + n.abs }\nend",
"def sum_of_digits(number)\n digits = number.to_s.split(\"\")\n sum = 0\n digits.each do |digit|\n sum += digit.to_i\n end\n return sum\nend",
"def add_nums number\n i = number.digits.count - 1\n j = 0\n sum = 0\n array = number.digits\n p i\n loop do\n p array[i]\n sum += array[i]\n i -= 1\n j += 1\n break if i < 0 || j == 2\n end\n sum\nend",
"def sum_of_digit_squares(number)\n\tdigits = number.to_s.split(//)\n\tsum = 0\n\tdigits.each do |digit|\n\t\tsum += (digit.to_i)**2\n\tend\n\tsum\nend",
"def final_chain_num(n)\n while n != 1 and n != 89\n n = sum_squares_of_digit(n)\n end\n n\nend",
"def AdditivePersistence(num)\n addv_pers = 0\n until num < 10\n num = num.digits.sum\n addv_pers += 1\n end\n addv_pers\nend",
"def super_digit(n)\n return n if n < 10\n sum = n.to_s.chars.map(&:to_i).sum\n return super_digit(sum)\nend",
"def sum(num)\na_num = []\nnum_split_string = num.to_s.split('')\n \n while a_num.count < num do\n a_num.push(num_split_string)\n a_num.count\n break\n end\n a_num.flatten!.map! do |e|\n e.to_i\n end\n a_num.sum\nend",
"def problem10()\n\tsum = 0; Prime.each(2000000) {|i| sum += i}; return sum\nend",
"def sumdig_r(n)\n return n if n < 10\n (n%10) + sumdig_r(n/10)\nend",
"def digital_root(n)\n arr = n.to_s.split(\"\")\n total = []\n val, answer = 0, 0\n arr.each {|x| val += x.to_i}\n if val <= 9\n return val\n elsif val > 9\n total = val.to_s.split(\"\")\n total.each {|s| answer += s.to_i }\n return answer\n end\nend",
"def sum(num)\n sum = 0\n num.to_s.chars.each do |ch|\n sum += ch.to_i\n end\n sum\nend",
"def digit_sum(array)\n array.map { |n| n >= 10 ? n / 10 + n % 10 : n }\n end",
"def sum(numbers)\n string = numbers.digits.reverse\n string.reduce(:+)\nend"
] | [
"0.720517",
"0.71016836",
"0.70384014",
"0.7019401",
"0.70184284",
"0.7007637",
"0.7004722",
"0.692449",
"0.6918288",
"0.69061327",
"0.68916255",
"0.6877606",
"0.6876679",
"0.6847596",
"0.6837302",
"0.68242794",
"0.6805717",
"0.6804139",
"0.67985547",
"0.6796361",
"0.6770783",
"0.6764871",
"0.67608905",
"0.67516446",
"0.6719219",
"0.6695646",
"0.6691749",
"0.668422",
"0.6677394",
"0.667459",
"0.6664819",
"0.6663171",
"0.6661239",
"0.66567105",
"0.66472715",
"0.6627194",
"0.66132677",
"0.66024804",
"0.65999085",
"0.6580104",
"0.6577531",
"0.65700847",
"0.65700847",
"0.6564819",
"0.65381527",
"0.6534959",
"0.652989",
"0.65202904",
"0.6518334",
"0.6518334",
"0.6518334",
"0.6518334",
"0.65151346",
"0.65132457",
"0.6505944",
"0.65019095",
"0.65006554",
"0.6481568",
"0.6468109",
"0.64625514",
"0.64419377",
"0.64406776",
"0.64406776",
"0.6439228",
"0.6439228",
"0.64368904",
"0.64364874",
"0.6430761",
"0.642829",
"0.6425044",
"0.64102256",
"0.640752",
"0.6403256",
"0.63996875",
"0.6394052",
"0.6377952",
"0.6377918",
"0.63731354",
"0.6372646",
"0.63516694",
"0.6349217",
"0.63472325",
"0.63466436",
"0.6341365",
"0.63402045",
"0.6324454",
"0.632085",
"0.6319849",
"0.6309332",
"0.63023895",
"0.6300468",
"0.6300405",
"0.62895745",
"0.6278705",
"0.6278531",
"0.62756103",
"0.6271361",
"0.6266792",
"0.6266724",
"0.62631285"
] | 0.7129993 | 1 |
inside the function the variable is temoporary, when you return it then it can be assigned to a variable for lateer | def secret_formula(started)
jelly_beans = started * 500
jars = jelly_beans / 1000
crates = jars / 100
return jelly_beans, jars, crates
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variable; end",
"def variable; end",
"def get_it\n @myvar\n end",
"def return_a_value\n name = \"Austin\"\n return name\n name = \"Brian\"\nend",
"def create_var \n b = 12\n return b \n end",
"def l_variable (str)\nb = str\n\nend",
"def main_variable ; end",
"def result=(_); end",
"def a\r\n test = 123\r\nend",
"def myreturn\n @myreturn\n end",
"def local_variables() end",
"def method\n asdf = 10\nend",
"def getlocal() end",
"def result_of_setting; end",
"def blah()\n my_var = \"my var has been defined\"\nend",
"def data= a; @data = a ;end",
"def assignation(result, var) #method\n var = get_dir(var)\n result = get_dir(result)\n @current_context[var] = get_value(result)\n end",
"def a\n @a\nend",
"def some_method\n\ta = 3\nend",
"def temp\n @temp\n end",
"def some_method\n a = 4\nend",
"def return_value; end",
"def a\n return @a\n end",
"def current_value=(_arg0); end",
"def return_me(value)\n scoped_value = value\nend",
"def storage=(_arg0); end",
"def some_method(number)\n number = 7 # this is implicitly returned by the method\nend",
"def get_local_var\n p $local_var #this is different than...\n local_var = \"Local Var\"\n p local_var #...this.\nend",
"def engine\n return @my_variable\n end",
"def some_method(number)\n\tnumber = 7 # this is implicitly returned by the method\nend",
"def read; @my_var; end",
"def returns val = nil\n @returns = val\n self\n end",
"def returns; end",
"def method(a, b)\n c=a\n a=b\n b=c\n return a,b\nend",
"def variables; end",
"def variables; end",
"def temporary?; self.temporary; end",
"def get_assign_variable(code)\n return code[1][1]\n end",
"def return_value=(_arg0); end",
"def some_method(number)\n number = 7 # this is implicitly returned by the method\nend",
"def value=(_); end",
"def some_method(number)\n number = 7 # this is implicitly returned by the method\nend",
"def some_method(number)\n number = 7 # this is implicitly returned by the method\nend",
"def some_method(number)\n number = 7 # this is implicitly returned by the method\nend",
"def some_method(number)\n number = 7 # this is implicitly returned by the method\nend",
"def original_result; end",
"def store=(_arg0); end",
"def old_value=(_arg0); end",
"def write; @my_var = 2; end",
"def temp\n return $game_variables[VAR_TEMP]\nend",
"def method\n local_variable = \"Hi, I'm local only to this method\"\nend",
"def y=(_); end",
"def y=(_); end",
"def value!\n\t\t@mutex.synchronize {\n\t\t\t@old = true\n\n\t\t\t@value unless @exception\n\t\t}\n\tend",
"def cala\n @prueba = \"esto es una variable\"\n end",
"def just_assignment(number)\r\n foo = number + 3\r\nend",
"def just_assignment(number)\n foo = number + 3 \nend",
"def prep_variables\n end",
"def doubleit num\n num = num * 2\n return num\n num = 3 #this line won't ever run\nend",
"def some_method\n a = 3 # variable inside the scope cannot change the variable outside.\nend",
"def method(a,b)\ntemp=a\na=b\nb=temp\nputs \"a = #{a}\"\nputs \"b = #{b}\"\nend",
"def make_placeholder()\n value = @value\n @key = nil\n @value = nil\n return value\n end",
"def return_something\n x = 100\n y = 101\n z = 110\nend",
"def parent_variable; end",
"def littlePest var\n var = nil\n puts 'HAHA! I ruined your variable!'\nend",
"def var\n\t\t@var ||= \"aljfhnkjlngdkjfj\" #ekvivalen na konstruktor po podrazbirane\n\tend",
"def variable\n @variable ||= \"@#{@name}\"\n end",
"def returns=(_arg0); end",
"def exMethod\r\n # explicitly the last line will be the return\r\n\t# return var is also allowed but this also works\r\n $var\r\nend",
"def add_three_again(x)\r\n new_value = x + 3\r\n puts new_value # prints returned value\r\n new_value # == return new_value; implicitly returns\r\nend",
"def put_var_scope\nend",
"def bil\n v=1\n end",
"def just_assignment(number)\n foo = number + 3\nend",
"def just_assignment(number)\n foo = number + 3\nend",
"def a \n return 1\nend",
"def engine=(e)\n return @my_variable = e\n end",
"def f4(x)\n y = 100\n z = x + y\n return z\nend",
"def myMethod var\n var = var + var\n var = var * 4\nend",
"def return\n @v_return\n end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def value=(_arg0); end",
"def littlePest var\n\tvar = nil\n\tputs \"HA HA! I ruined your variable!\"\nend",
"def return_a_value\n \"Nice\"\nend",
"def set_temp(v)\n $game_variables[VAR_TEMP] = v\n return $game_variables[VAR_TEMP]\nend",
"def global_var\n $global_var \nend",
"def suivre; end",
"def return_value\n var_name\n end",
"def method(obj)\n a = 1\n obj\nend",
"def cache_value?; end",
"def strict_variables=(_arg0); end",
"def x \n @x \n end",
"def _get_var(name)\n\t\treturn @replace_vars[name]\n\tend",
"def value_read=(_arg0); end",
"def my_method\n greeting = \"hello\"\nend",
"def ass(ex, val)\n begin\n ex.varStore.set @rname, val\n rescue => e\n raise #e.message.chomp+' at line '+@code_line.to_s\n end\n return nil\n end"
] | [
"0.6768195",
"0.6768195",
"0.67202",
"0.6718758",
"0.67071587",
"0.66429394",
"0.6627469",
"0.65924567",
"0.6552105",
"0.6520936",
"0.6464326",
"0.64508367",
"0.6390428",
"0.62934333",
"0.6234716",
"0.6216517",
"0.61608136",
"0.61434084",
"0.6136857",
"0.6129941",
"0.61031073",
"0.6087997",
"0.60855037",
"0.6072341",
"0.60713696",
"0.6009324",
"0.600214",
"0.60021085",
"0.5996232",
"0.59773684",
"0.5970823",
"0.5963606",
"0.59610033",
"0.5958379",
"0.5919035",
"0.5919035",
"0.5917051",
"0.58967245",
"0.5888649",
"0.5876786",
"0.58701766",
"0.58683306",
"0.58683306",
"0.58683306",
"0.58683306",
"0.58646524",
"0.58639705",
"0.58569264",
"0.5851941",
"0.58344",
"0.5825297",
"0.58177507",
"0.58177507",
"0.5809896",
"0.580585",
"0.58034945",
"0.58000183",
"0.579986",
"0.5798548",
"0.5789292",
"0.5784576",
"0.57839733",
"0.57835114",
"0.5739013",
"0.5737574",
"0.5733913",
"0.57138777",
"0.57122505",
"0.5709887",
"0.57095206",
"0.57082844",
"0.57038754",
"0.56980824",
"0.56980824",
"0.56904185",
"0.56869",
"0.56843317",
"0.5684162",
"0.567783",
"0.56720054",
"0.56720054",
"0.56720054",
"0.56720054",
"0.56720054",
"0.56720054",
"0.56720054",
"0.56720054",
"0.56680644",
"0.566542",
"0.5664078",
"0.56622785",
"0.5658271",
"0.56460196",
"0.5636625",
"0.5628864",
"0.5628469",
"0.56170183",
"0.5615052",
"0.5603542",
"0.560071",
"0.55871147"
] | 0.0 | -1 |
TODO follow redirect to get live apple message | def not_registered
error_msg "Please validate your product's purchase date. Apple is unable to provide information about your service coverage."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_app_links\n # https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/PromotingAppswithAppBanners/PromotingAppswithAppBanners.html\n if element = @server.response.doc.at_xpath(\"//meta[@name='apple-itunes-app']\")\n result = element.attributes['content'].value.split(\",\").each_with_object({}) {|pair, res| key, value = pair.split('='); res[key.strip]=value.strip }\n shop_link = \"https://itunes.apple.com/app/id#{result['app-id']}?mt=8\" if result.keys.include?('app-id')\n if result.keys.include?('affiliate-data')\n @result.passed \"HTML: iOS app link includes affilaite id\"\n else\n @result.warned \"HTML: iOS app link found\" \n #@result.warned \"HTML: No Affiliate link for iOS Smart App Banner\" \n end\n else\n @result.info \"HTML: No iOS app link\"\n end\n end",
"def create\n @message = Message.new(params[:message])\n @message.sender = \"cmu3071\" #THIS NEEDS TO BE CHANGED WHEN OAF RECEIVES THEIR OWN SHORTCODE\n @message.time = Time.now\n \n body = @message.body\n phones = Message.split_numbers(@message.recipient)\n\n phones.each do |ph|\n phone = Message.reformat_phone(ph)\n puts \"PHONE: #{phone}\"\n url = Message.text_to(phone,body)\n puts \"URL: #{url}\"\n newUrl = URI.parse(URI.encode(url.strip))\n http = Net::HTTP.new(newUrl.host,443)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n @data = http.get(newUrl.request_uri)\n puts \"STATUS: #{@data.code}\"\n puts \"BODY: #{@data.body}\"\n puts \"RESPONSE: #{@data}\"\n end\n \n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: 'Message was successfully created.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def url_mobile_talk\n\t\t\t@data[\"content_urls\"][\"mobile\"][\"talk\"]\n\t\tend",
"def show\n whatsapp = WhatsApp.new\n whatsapp.line = @message.sender\n whatsapp.url = @message.url\n whatsapp.appname = @message.appname\n whatsapp.token = @message.token\n whatsapp.messageSearch(@message.id, @message.protocol)\n #whatsapp.questionSearch(@message.id, @message.protocol)\n end",
"def url_desktop_talk\n\t\t\t@data[\"content_urls\"][\"desktop\"][\"talk\"]\n\t\tend",
"def determine_response body\n body = body.downcase.strip \n media = nil\n session[:intent] ||= nil\n message = \"\"\nend",
"def not_clarified_alert(info_request, incoming_message)\n respond_url = show_response_url(:id => info_request.id, :incoming_message_id => incoming_message.id)\n respond_url = respond_url + \"#followup\" \n\n post_redirect = PostRedirect.new(\n :uri => respond_url,\n :user_id => info_request.user.id)\n post_redirect.save!\n url = confirm_url(:email_token => post_redirect.email_token)\n\n @from = contact_from_name_and_email\n headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken\n 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834\n @recipients = info_request.user.name_and_email\n @subject = \"Clarify your FOI request - \" + info_request.title\n @body = { :incoming_message => incoming_message, :info_request => info_request, :url => url }\n end",
"def show\n @subject = subject\n @live_link = get_live_link(subject)\n @session_code\n end",
"def email_server\n\n user_agent = request.env['HTTP_USER_AGENT'].downcase\n request.user_agent =~ /Mobile|webOS/\n\n if(params['app'].present?)\n\n if(user_agent.include?\"android\")\n\n redirect_to \"https://play.google.com/store/apps/details?id=co.foodcircles\"\n\n elsif (user_agent.include?\"iphone\")\n redirect_to \"http://itunes.apple.com/us/app/foodcircles/id526107767\"\n elsif !((request.user_agent =~ /Mobile/).nil?)\n redirect_to root_path\n else\n\n redirect_to \"http://www.foodcircles.net/app\"\n\n end\n else\n\n prepare_for_mobile\n\n end\n\n end",
"def thanks(application)\n load_resources(application)\n @title = 'New Hire'\n mail( subject: 'Application Received', to: @application.email, track_opens: 'true' )\n end",
"def show_message_request(text, type, actions, &block); end",
"def visit_inbox\n get '/messages'\n end",
"def say(payload)\n {\n action: 'say',\n options: {\n payload: payload,\n voice: 'male',\n language: 'en-US'\n }\n }\nend",
"def alert msg\n document.get_default_view.alert(msg)\n end",
"def show\n render text: @system_message.content.html_safe\n end",
"def show\n @admin = current_admin\n @business = @admin.business\n @agents = @business.agents\n @phrases = @business.phrases\n\n messages_array = Message.for_business(@business.id)\n\n @messages_array = messages_array\n \n messages_text_block = String.new\n\n messages_array.each { |msg|\n if msg.message\n if !msg.message.to_s.include? \"has left the conversation.\"\n messages_text_block += \" \"+msg.message\n end\n end\n }\n\n messages_text_block.gsub!(/(?:f|ht)tps?:\\/[^\\s]+/, '')\n\n post_args = {\n 'height' => \"500\",\n 'textblock' => messages_text_block,\n 'width' => \"500\",\n 'config' => \"n/a\"\n }\n\n client = WordCloudMaker.new\n\n @data = client.makeWordCloud(post_args['height'], post_args['textblock'], post_args['width'])\n\n #----------------\n\n @link = root_url + \"customers/new/?business=\" + @business.biz_url\n\n\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin }\n end\n end",
"def send_new_listing_notification(merchant)\n @merchant = merchant\n mail to: \"sales@halalfoodhunt.com\", subject: \"A New Merchant has Subscribed!\"\n end",
"def message\n fetch_response.message\n end",
"def notice_from_objective_auth\n\n @auth = User.find(params[:auth_id])\n user_mail = User.find(params[:user_id]).email\n @url = params[:url]\n mail(to: user_mail, subject:'承認されました。')\n \n end",
"def index\n @user_agent = UserAgent.parse(request.user_agent)\n if @user_agent.mobile?\n redirect_to relay_mobile_path\n else\n redirect_to FACEBOOK_CONFIG[:relay][:app_address]\n end\n end",
"def status\n @app = ThirdpartyService.get_app(@url, AUTH, @http, @body)\n if @app['code'] != nil\n session[:toast_type] = 'error'\n session[:toast_message] = @app['errors'][0]['message']\n redirect_to app_list_path\n return\n end\n # Display success message\n session[:toast_type] = 'status'\n session[:toast_message] = 'App ' + params[:status] + 'ed successfully'\n end",
"def apple\r\n @category = DownloadCategory.find :first, :conditions => ['code = ?', 'quicktime_plugin']\r\n @page_title = 'RED.com / ' + @category.title\r\n render :layout => 'static_pages'\r\n end",
"def application_request\n\t\tPony.mail(to: params[:email], from: \"bradwflint@gmail.com\", subject: \"Email application\", body: \"Here is the rental application!\", :attachments => {\"rentalapp.pdf\" => File.read(Rails.root.to_s + \"/public/rentalapp.pdf\")} )\n\t # Pony.mail(to: \"bradwflint@gmail.com\", from: \"bradwflint@gmail.com\", subject: \"Email application\", body: \"Here is the rental application!\", :attachments => {\"rentalapp.pdf\" => File.read(Rails.root.to_s + \"/public/rentalapp.pdf\")} )\n\t\tredirect_to properties_apply_path\n\tend",
"def message\n \n end",
"def message\n response.body.match(/\"message\":\"(.*)\"/)[1]\n end",
"def ack_receipt\n Net::HTTP.get(URI(params[:response_url]))\n end",
"def payload_link(payload)\n if payload[:alert][:version] == 2\n \"https://#{ENV['APPOPTICS_APP_URL']}/metrics/\"\n else\n metric_link(payload[:metric][:type], payload[:metric][:name])\n end\n end",
"def index\n @feedbacks = current_user.given_feedbacks # feedbacks given as a guest\n @user = current_user\n gon.push fb_app_id: ( ENV['APP_ID'] || '363405197161579' )\n render :layout => \"new_application\"\n end",
"def show\n render json: get_message()\n end",
"def hockey_message(title, link, version)\n\n message = \"\\n++++++++++++++++++++++++++++++++\\n\" +\n title + \" \\n\" +\n \"Ссылка: \" + link + \" \\n\" +\n \"Версия: \" + version +\n \" \\n++++++++++++++++++++++++++++++++\"\n\nend",
"def show\n @text_message = @profile.text_messages.find(params[:id])\n\n respond_to do |format|\n format.mobile\n format.html # show.html.erb\n format.xml { render :xml => @text_message }\n end\n end",
"def getAppRetCode\n \"appid=#{appid}\"\n end",
"def index\n @client_name = nil\n if session[:cos_session_id]\n if @application_session = Session.find_by_id(session[:cos_session_id])\n @client_name = Client.find_by_id(@application_session.client_id).name\n end\n end\n unless @client_name == nil\n http = get_http_connection()\n path = '/messages/in.json?name='+@pysmsd_config.app_name+'&password='+@pysmsd_config.app_password+'&keyword='+@client_name\n resp = http.get(path)\n json = JSON.parse(resp.body)\n json['messages'].each do | message |\n @person = Person.find_by_phone_number(message['number'])\n if @person\n message['user_id'] = @person.guid\n end\n end\n\n render_json :entry => json and return\n end\n render_json :status => :bad_request, :messages => \"No matching application ID was found, cannot proceed to fetch SMS from server.\" and return\n end",
"def new_place_notification (merchant)\n @merchant = merchant\n mail to: \"sales@halalfoodhunt.com\", subject: \"A Place Has Been Listed\"\n end",
"def whatsapp_click_to_chat_url(phone)\n \"https://api.whatsapp.com/send?phone=#{whatsapp_format(phone)}&text&source&data&&lang=#{current_user.language}\"\n end",
"def follow_up_alert(email, name, body, body_part2, location_link)\n @name = name \n @body = body\n @body_part2 = body_part2\n @location_link = location_link\n\n mail to: email, subject: \"Follow-up info from Grapevine\", from: \"erik@pickgrapevine.com\", reply_to: \n \"erik@pickgrapevine.com\"\n\n end",
"def new_response_reminder_alert(info_request, incoming_message)\n # Make a link going to the form to describe state, and which logs the\n # user in.\n post_redirect = PostRedirect.new(\n :uri => main_url(request_url(info_request)) + \"#describe_state_form_1\",\n :user_id => info_request.user.id)\n post_redirect.save!\n url = confirm_url(:email_token => post_redirect.email_token)\n\n @from = contact_from_name_and_email\n headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken\n 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834\n @recipients = info_request.user.name_and_email\n @subject = \"Was the response you got to your FOI request any good?\"\n @body = { :incoming_message => incoming_message, :info_request => info_request, :url => url }\n end",
"def admin_open_request_success(place) #when the admin user makes an open request successfully\n self.message = \"SUCCESS ! You requested to open -> #{place.nickname}\"\n end",
"def perform\n Kublog.facebook_client.link! :link => @url, :message => @message\n end",
"def hand_over_to_office_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.hand_over_to_office_mail(Petition.live.first)\n end",
"def msg_arnoldbot\n uri = URI(\"https://arnoldbot-api.herokuapp.com/talk?msg=\"+params[:msg])\n resp = Net::HTTP.get(uri)\n render json: resp\n end",
"def voicemail\n request = @browser.get(\"#{VoipfoneClient::API_GET_URL}?vm_view\")\n parse_response(request)[\"vm_view\"].first[\"voicemail\"]\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 food_mail(email)\n\n @url = 'http://foodcircles.net/?app=mobile_email'\n mail(:to => email, :reply_to => 'jk@joinfoodcircles.org', :subject => \"Your appetite is powerful.\")\n end",
"def message\n \"#{super}: #{response.body}\"\n end",
"def show_url(receiver)\n receiver.external_service_receiver.response_data\n end",
"def message_on_slack\n\n if !HackumassWeb::Application::SLACK_ENABLED\n flash[:alert] = \"Slack integration disabled. Please enable Slack integration to use this feature.\"\n return\n end\n\n request = MentorshipRequest.find(params[:mentorship_request])\n usr = User.find(request.user_id)\n slack_id = usr.get_slack_id\n if slack_id\n request.status = \"Contacted\"\n request.save\n if HackumassWeb::Application::SLACK_MESSAGE_URL_PREFIX\n redirect_to HackumassWeb::Application::SLACK_MESSAGE_URL_PREFIX + \"/\" + slack_id\n else\n redirect_to usr.get_slack_message_link\n end\n else\n redirect_to request, alert: 'This user is not signed up on slack.'\n end\n end",
"def personal_message(msg, cl, state)\n respond(msg, cl, \"Hi. Your message was: #{msg.inspect}\")\n respond(msg, cl, \"Body: #{msg.body.to_s}\")\nend",
"def payment_received_through_credit_card_notification(application)\n subject \"Your deposit has been received\"\n @payment_token = application.payment_token\n from \"Boxyroom <app@boxyroom.com>\"\n recipients application.user.email\n sent_on Time.now\n body :application => application, :link => my_application_url(application), :my_dashboard_my_account_url => my_dashboard_my_account_url\n end",
"def show\n img = @device.get_snapshot\n\n File.open('/tmp/image.jpg', 'wb') do|f|\n f.write(Base64.decode64(img))\n end\n\n fqdn = 'https://api.att.com'\n\n clientcred = Auth::ClientCred.new(fqdn,\n 'hw3jjqqx24o16vkwi3ljza6hpuwykgyj',\n 'vycosunsgooofdjy4d01cpynupvcitbo')\n\n token = clientcred.createToken('MMS')\n\n mms = Service::MMSService.new(fqdn, token)\n response = mms.sendMms('3035137428', \"Your guest has arrived\", '/tmp/image.jpg')\n\n send_data File.open('/tmp/image.jpg', 'r').read, type: 'image/jpg', disposition: 'inline'\n end",
"def trigger_on_message(msg); @app.on_message(msg); end",
"def receipt\n mail(\n to: \"smnrwebster5@gmail.com\",\n subject: \"New for review for your commute\"\n )\n end",
"def message\n self.description = self.description + merchant_store.store_regards\n end",
"def application_received(application)\n @application = application\n mail to: \"to@example.org\"\n end",
"def show\n @message = Message.find(params[:id])\n @redirect = false\n if (!(@message.user.group.messages_released) && !(@message.from == current_user.name))\n @redirect = true\n elsif not((@message.user == current_user) || (@message.from == current_user.name))\n @redirect = true\n end\n respond_to do |format|\n if @redirect\n \tformat.html { redirect_to :action => \"index\", notice: 'You may not view that.' }\n \tformat.json { render json: @message.errors, status: :unprocessable_entity }\n else\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end\n end",
"def send_artists_reviews_details(session, sender)\n context = session.context\n a = Mechanize.new { |agent|\n agent.user_agent_alias = 'Mac Safari'\n }\n if context[\"intent\"] == \"reviews\"\n reviews = []\n a.get(context[\"artist_url\"]) do |page|\n page.search(\".artist-reviews ul li\")[0..5].each do |review|\n reviews << review.search(\".review-content p\").first.text\n end\n end\n if reviews.empty?\n sender.reply({text: \"Sorry there aren't any reviews yet :( \"})\n else\n reviews.each do |review|\n sender.reply({text: review})\n end\n end\n elsif context[\"intent\"] == \"details\"\n a.get(context[\"artist_url\"]) do |page|\n bio = page.search(\"#biography .standfirst p\").text\n if bio.empty?\n sender.reply({text: \"Sorry this artists biography hasn't been added yet :(\"})\n else\n sender.reply({text: bio})\n end\n end\n end\nend",
"def ios; end",
"def shout\n 'Yay!'\n end",
"def listen(m)\n if /#([0-9]*)/.match(m.message)\n ticket = /#([0-9]*)/.match(m.message)[1]\n m.reply \"Did someone mention ticket ##{ticket}? Here's a link: \" + \"https://transmit.codebasehq.com/projects/brand-regard/tickets/\" + ticket\n end\n end",
"def on_message data\n\t\t# broadcast sends an asynchronous message to all sibling instances, but not to self.\n\t\tdata = ERB::Util.html_escape data\n\t\tbroadcast :_print_out, data\n\t\tresponse << \"You said: #{data}\"\n\t\tresponse << (request.ssl? ? \"FYI: Yes, This is an SSL connection...\" : \"FYI: Nope, this isn't an SSL connection (clear text).\") if data.match /ssl\\?/i\nend",
"def getvid\n #system(\"pkill ffserver\") or raise \"Something went wrong.\"\n @email = params[:u_email]\n \tsystem(\"sendemailvid \" + @email + \"\") or raise \"Something went wrong.\"\n \tredirect_to :back\n end",
"def echo\n render json: {\n :message => params[:message],\n :timestamp => Time.current,\n }\n end",
"def say_hi(medium)\n @medium = medium\n\n mail(to: '446146366@qq.com' , subject: \"视频#{@medium.subject}更新通知\")\n mail(to: 'mwang@jingqi100.com' , subject: \"视频#{@medium.subject}更新通知\")\n mail(to: 'hhuang@jingqi100.com' , subject: \"视频#{@medium.subject}更新通知\")\n mail(to: 'mwu@jingqi100.com' , subject: \"视频#{@medium.subject}更新通知\").deliver\n end",
"def show\n respond_to do |format|\n if @message.save\n # flash[:success] = '<i class=\"fa fa-paper-plane\"></i>Thanks for your message. We will review your request and be in touch soon.'\n flash[:success] = ' Thanks for your message. We will review your request and be in touch soon.'\n format.html { redirect_to Song }\n end\n end\n end",
"def send_app_notification\n if message.present?\n message.receipts.unread.each do |receipt|\n user = receipt.receiver\n if user.is_a?(User) #&& user.user_setting.\n user_setting = user.user_setting\n allow_push = false\n if message.message_type == 'user_messages' && user_setting.allow_user_messages?\n allow_push = true\n end\n if message.message_type == 'clan_messages' && !(user_setting.allow_clan_messages.include?(message.notified_object_id.to_s))\n allow_push = true\n end\n if allow_push && (user_setting.android? || user_setting.iphone? ) && user_setting.fcm_token.present?\n # sky start\n\n # fcm = FCM.new(\"AIzaSyCHC77aETrtuaAvNTQQqvnLhjFf6zHOSPc\")\n # options = {data: {message: \"#{sender.username}: #{subject}\", url: nil, id: receipt.id, type: :usermessages}, collapse_key: :updated_score}\n # registration_ids = [user_setting.fcm_token]\n # response = fcm.send(registration_ids, options)\n\n # sky end\n\n fcm = FCM.new(\"AAAAqD6vl5g:APA91bEE1FUBihFLdW6kO9XpN-srDxlama2BzzjimePRN-kBlfq0tKMsblhNPW7a2_CeM1J0Pz7SMAYx4c_notZMCx2schfCDYvizOW6EYWAhnUsYA10azWOenextxFiUaFotLT8Z8er\")\n if user_setting.android?\n options = { data: { title: sender.username, message: subject, url: nil, id: receipt.id, type: message.message_type}, collapse_key: :updated_score}\n else\n options = {notification: {title: sender.username, body: subject, icon: \"myicon\", sound: \"notificationRoster.wav\", url: nil, id: receipt.id, type: message.message_type}, priority: \"high\"}\n end\n\n registration_ids = [user_setting.fcm_token]\n response = fcm.send(registration_ids, options)\n\n end\n end\n end\n end\n end",
"def messaging\n end",
"def receive\n items = @purchase.receive!\n redirect_to purchase_path(@purchase), :notice => [t(:received) ,items ,t(:items)].join(\" \")\n end",
"def match(track, alert)\n @user = alert.soundcloud_user\n @track = track\n @alert = alert\n\n mail(to: \"test@tester.com\", subject: \"New Match Found!\")\n #mail(to: \"#{@user.name} <#{@user.email}>\", subject: \"New Match Found!\")\n end",
"def show\n @wr_log = WrLog.find(params[:id])\n @email = Email.find(@wr_log.email_id)\n @receiver = User.find_by_id(@wr_log.receiver_id) \n @sender = User.find_by_id(@wr_log.sender_id)\n \n if params[:token_identifier] != @wr_log.token_identifier\n redirect_to root_path, \n flash: { error: \"I'm sorry you are not allowed to access that page\"}\n end\n\n\n if params[:forward]\n @wr_log.action = \"forward\"\n @wr_log.forwarded = Time.now\n @wr_log.save\n UserMailer.alert_change_in_wr_log(@wr_log)\n @to = @receiver.subscribers.map{|id| User.find(id)}.\n map{|user| '\"' + user.name + '\"<' + user.email + '>'}.join(', ')\n @subject = @email.subject\n @body = @email.body\n render 'forward_new'\n elsif params[:more]\n @wr_log.action = \"more\"\n @wr_log.email_part = params[:more].to_i + 1 #updated_at will show last time accessed\n @wr_log.save\n UserMailer.alert_change_in_wr_log(@wr_log)\n @message = @wr_log.abstract_message\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @wr_log }\n end\n else\n redirect_to root_path, flash: { error: \"Unknown request\" }\n end\n end",
"def message\n info['Message']\n end",
"def food_mail(email)\n\n @url = 'http://foodcircles.net/?app=mobile_email'\n mail(:to => email, :reply_to => 'jk@joinfoodcircles.org', :subject => \"Your hunger is powerful.\")\n end",
"def get_messages\n %{\n <script>\n if (navigator.appName!=\"Microsoft Internet Explorer\") {\n #{Sinatra::Messages.get}\n #{@console}\n }\n </script>\n }\n end",
"def preview_msg(msg_params_with_name)\n uri = 'cgi-bin/operate_appmsg?sub=preview&t=ajax-appmsg-preview'\\\n \"&type=10&token=#{@token}&lang=zh_CN\"\n headers = {\n referer: 'https://mp.weixin.qq.com/cgi-bin/appmsg?t=media/appmsg_edit'\\\n \"&action=edit&type=10&isMul=0&isNew=1&lang=zh_CN&token=#{@token}\",\n host: 'mp.weixin.qq.com',\n x_requested_with: 'XMLHttpRequest'\n }\n resource = RestClient::Resource.new(@home_url, headers: headers, cookies: @cookies)\n\n res = resource[uri].post msg_params_with_name\n # \"ret\":\"0\", \"msg\":\"preview send success!\", \"appMsgId\":\"201796045\", \"fakeid\":\"\"\n JSON.parse res.to_s\n end",
"def show\n @system_message = SystemMessage.find(params[:id])\n @type = @system_message.message_type \n @return_url = \"/pcbtr/system_messages\"\n \n if params[:url_return] != nil\n @return_url = params[:url_return]\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system_message }\n end\n end",
"def application_help\n UserMailer.application_help\n end",
"def twitter_publish_message\n \"#NoAgenda show ##{number} attack vectors now at http://noagendadashboard.com\"\n end",
"def catch_up_link(person_full_name)\n if message_id = last_message_id(person_full_name)\n return \"#{bot.base_uri}/room/#{bot.room.id}/transcript/message/#{message_id}\"\n end\n end",
"def send_moola!\n # @todo\n end",
"def send_magic_link(email, redirect_url = '', life_time = 24)\n data = {\n email: email,\n redirectUrl: redirect_url,\n lifeTime: life_time\n }\n @client.raw('post', '/users/magic-link', nil, { data: data }, '/api/v1')\n end",
"def incoming \n response.headers[\"Content-Type\"] = \"text/plain; charset=utf-8\"\n #Read params from the text message\n \n if (params[:uid] && params[:body])\n @userid = params[:uid]\n @body = params[:body] \n \n sms = Sms.new(:raw => @body, :login => @userid)\n \n sms.parse\n \n user = User.find_by_login(sms.login)\n \n if user.nil?\n render :text => \"User #{sms.login} couldn't be found, have you signed up at #{AZIMUTH_DOMAIN}?\" \n else\n hunt = user.hunt\n if hunt.nil?\n render :text => \"User #{sms.login} doesn't appear to have signed up for a hunt. Please sign up for one at #{AZIMUTH_DOMAIN}.\"\n else\n if hunt.aasm_current_state == :hunting\n discovery = Discovery.new(:treasure => user.current_treasure, :key => sms.key, :lat => sms.lat, :lng => sms.lng, :hunt => hunt, :user => user)\n hunt.attempt_open_treasure_chest(discovery, user)\n user.save!\n hunt.save!\n discovery.save!\n \n if discovery.success?\n render :text => \"\" # don't send extra texts since the hunt will do it for us...\n else\n render :text => \"What you texted didn't open the treasure chest :-(. Coords: #{sms.lat} #{sms.lng}. Key: #{sms.key}\"\n end\n else\n render :text => \"The hunt #{hunt.name} is currently in #{hunt.state.humanize} state. Please wait for the hounds to be released to get your first clue.\"\n end\n end\n end\n else\n render :text => \"\"\n end\n \n end",
"def XOrecordAppMsg( errFlag, msg)\n\t\t$pfd.calcApplRes( errFlag, msg, @wwBrws.url.to_s)\n\t\tif !errFlag\n\t\t\tself.XOtakeScreenShot\n\t\tend\n\t\treturnRes (errFlag ? OK : CRITICAL)\n\tend",
"def ezm_link_to_send_message\r\n link_to \"Write\", compose_url\r\n end",
"def launch_email_client()\n destination = \"mailto:#{@@item.chair_email}\" +\n \"?cc=private@#{@@item.mail_list}.apache.org,board@apache.org\"\n\n if @@item.missing\n subject = \"Missing #{@@item.title} Board Report\"\n body = %{\n Dear #{@@item.owner},\n\n The board report for #{@@item.title} has not yet been submitted for\n this month's board meeting. If you or another member of the PMC are\n unable to get it in by twenty-four hours before meeting time, please\n let the board know, and plan to report next month.\n\n https://www.apache.org/foundation/board/reporting#how\n\n Thanks,\n\n #{Pending.username}\n\n (on behalf of the ASF Board)\n }\n\n # strip indentation; concatenate lines within a paragraph\n indent = body[/^\\s*/]\n body = body.strip().gsub(/#{indent}/, \"\\n\").gsub(/(\\S)\\n(\\S)/, \"$1 $2\")\n else\n subject = \"#{@@item.title} Board Report\"\n body = @@item.comments\n end\n\n window.location = destination +\n \"&subject=#{encodeURIComponent(subject)}\" +\n \"&body=#{encodeURIComponent(body)}\"\n end",
"def show\n @message = current_user.messages.find(params[:id])\n respond_to do |format|\n format.any(:html, :wml)\n end\n end",
"def flash\n (JSON.parse(Base64.decode64(page.response_headers['Test-Bot-Flash'])) rescue {})\n end",
"def show\n # notification_email\n end",
"def show\r\n #this redirect is for unfixed legacy links, because artist see inquiries\r\n #not prefixed with gig in the url\r\n return Event::Read.emit(:inquiry, @inquiry.id) unless current_profile.artist?\r\n redirect_to inquiry_path(@inquiry.id)\r\n end",
"def webhook\n\t\t# 學說話\n\t\tbegin\n\t\t\treply_text = command_trigger(channel_id, received_text)\n\t\trescue\n\t\t\tnil\n\t\tend\n\t\t# 關鍵字回覆\n\t\treply_text = keyword_reply(channel_id, received_text) if reply_text.nil?\n\n\t\t# 傳送訊息到 line\n\t\tresponse = reply_to_line(reply_text)\n\n\t\t# 回應 200\n\t\thead :ok\n\tend",
"def message() end",
"def ezm_link_to_outbox\r\n link_to \"Sent\", outbox_url\r\n end",
"def page(message, url)\n recipients message.recipients\n from ADMIN_EMAIL\n subject message.subject\n body :message => message, :url => url\n end",
"def show\n respond_with(@alarm_notification)\n end",
"def message\n notifications = current_user.notifications\n has_message = false\n has_request = false\n notifications.each do |notification|\n if notification.classification == 'message'\n has_message = true\n end\n if notification.classification == 'request'\n has_request = true\n end\n end\n if has_request && has_message\n return \"You have some friend requests and new messages. #{link_to 'Requests', profile_path} #{link_to 'Dialogs', dialogs_user_path(current_user.id)}\"\n\n elsif has_request\n return \"You have some friend #{link_to 'Requests', profile_path}.\"\n elsif has_message\n return \"You have some new messages #{link_to 'Dialogs', dialogs_user_path(current_user.id)}\"\n end\n end",
"def response_message\n parsed_response['message']\nend",
"def ciao\n redirect_to '/' && return if params[:url].blank?\n @ua = {:action => UserAction.id_for('external_url'), :data => {:source => params[:source]}}\n url = Base64.decode64(params[:url])\n url = \"http://#{url}\" unless url.match(/https?:\\/\\//) != nil\n redirect_to url\n end",
"def follow_redirect?; end",
"def mail\n flash[:notice] = \"Sorry, that page is not available.\"\n redirect_to alerts_path\n end",
"def play_voicemail_greeting\n user = locate_user(rdnis)\n if user\n play_greeting(user)\n record_voicemail_message(user)\n else\n play \"invalid\"\n end\n end",
"def send_push\n ensure_transac_campaign(params[:app_identifier])\n send_transac_push(params[:message], params[:customer_ids])\n redirect_to \"/\", flash: { error_message: @error_message, info: @info }\n end",
"def index\n @referrer=\"\"\n @format=request.format\n @ticket=params[:ticket]\n if request.env[\"HTTP_REFERER\"]\n @referrer=URI(request.env[\"HTTP_REFERER\"]).host\n end\n @host= URI(\"http://\"+Pref.host_url).host\n if (@ticket) and (@referrer==@host or @referrer==\"www.\"+@host or @format==\"text/xml\")\n redirect_to :action => \"show\", :id => @ticket\n else\n\n respond_to do |format|\n format.html{}\n format.iphone {render :layout=> 'layouts/application.iphone.erb'}# index.iphone.erb \n end\n end\n end",
"def show\n @user = current_user\n @message = current_user.extension.messages.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @message }\n end\n end"
] | [
"0.6168524",
"0.5863048",
"0.581914",
"0.580315",
"0.5654492",
"0.5644574",
"0.5558355",
"0.5549997",
"0.5535184",
"0.54709387",
"0.5455786",
"0.54317904",
"0.53893983",
"0.5368947",
"0.5346848",
"0.53368884",
"0.5334694",
"0.5332596",
"0.5328089",
"0.53263944",
"0.53177816",
"0.5310974",
"0.53098816",
"0.5304621",
"0.5292067",
"0.5288154",
"0.5278349",
"0.5274844",
"0.5241504",
"0.52362883",
"0.5232576",
"0.5226287",
"0.5224987",
"0.5204824",
"0.52047443",
"0.52035683",
"0.51997507",
"0.51979005",
"0.51891875",
"0.5178243",
"0.517462",
"0.51729804",
"0.51726604",
"0.5162636",
"0.51544213",
"0.51481146",
"0.51407266",
"0.514055",
"0.51363",
"0.51355684",
"0.5135279",
"0.5131689",
"0.51279634",
"0.51275045",
"0.5124497",
"0.5124333",
"0.51239014",
"0.51180995",
"0.51027423",
"0.51004213",
"0.509936",
"0.50963414",
"0.50948095",
"0.50945574",
"0.5090607",
"0.5087625",
"0.5082896",
"0.5081563",
"0.5081352",
"0.50792533",
"0.50685257",
"0.50644916",
"0.5064318",
"0.506427",
"0.50622654",
"0.5060734",
"0.5060383",
"0.5057827",
"0.5051185",
"0.50491357",
"0.50481963",
"0.5046093",
"0.50460184",
"0.5044663",
"0.5043653",
"0.5040284",
"0.5038154",
"0.50371635",
"0.5031713",
"0.502921",
"0.5027821",
"0.5023716",
"0.502288",
"0.50188285",
"0.5012903",
"0.5011429",
"0.50110424",
"0.5010179",
"0.5007426",
"0.5005093",
"0.50027394"
] | 0.0 | -1 |
endregion region Password reset | def send_password_reset
self.reset_token = Token.random
update_columns(reset_digest: Token.digest(reset_token), reset_sent_at: Time.zone.now)
UserMailer.password_reset(self).deliver_now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password_reset_request\n end",
"def reset_password(new_password, new_password_confirmation); end",
"def forgot_password\n\t\tend",
"def send_reset_password_instructions; 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 new_reset_password\n end",
"def send_reset_password_instructions\n end",
"def set_password_reset\n self.make_password_reset_code\n end",
"def forgot_password\n end",
"def password_reset\n account = Account.first\n account.reset_token = Account.new_token\n AccountMailer.password_reset(account)\n end",
"def forgot_password\n\t\t\n\tend",
"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 password_reset\n player = Player.first\n player.reset_token = Player.new_token\n PlayerMailer.password_reset(player)\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 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 owner = Owner.first\n owner.reset_token = Owner.new_token\n Owner::UserMailer.password_reset(owner)\n end",
"def reset_password!\n reset_password\n save_without_session_maintenance(validate: false)\n end",
"def password_reset\n gamer = Gamer.first\n gamer.reset_token = Gamer.new_token\n GamerMailer.password_reset(gamer)\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 PenggunaMailer.password_reset\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 password_reset\n member = Member.first\n member.reset_token = Member.new_token\n MemberMailer.password_reset(member)\n end",
"def clear_reset_password_token; 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 \tuser = User.first\n user.reset_token = User.new_token\n UserMailer.password_reset(user)\n end",
"def password_reset\n tester = Tester.first\n tester.reset_token = Tester.new_token\n TesterMailer.password_reset(tester)\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 reset_password!\n @session.nickserv.resetpass(self.name)\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 UserMailMailer.password_reset\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 = 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 participant = Participant.first\n participant.reset_token = Participant.new_token\n ParticipantMailer.password_reset(participant)\n end",
"def password_reset\n AccountMailer.password_reset\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 MailerMailer.password_reset\n end",
"def password_reset\n StudentEmailConfirmation.password_reset\n end",
"def reset_password! \n\t\t\treset_perishable_token! \n\t\t\tNotifier.reset_password(self).deliver \n\t\tend",
"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 user = User.first\n user.create_reset_digest\n UserMailer.password_reset(user.id, user.reset_token)\n end",
"def after_password_reset; end",
"def reset_password\n update_attribute(:password_reset_code, nil)\n @reset_password = true\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 reset_password!\n reset_password\n save_without_session_maintenance(false)\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 password_reset\n ClientMailer.password_reset\n end",
"def reset!\n self.password_cost = 9\n end",
"def reset_password() \n self.password_confirmation = self.password = self.login\n \n self.save\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 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\t token = params.first[0]\n\t @user = User.find_by_confirm_token(token)\n\n\t if @user.nil?\n\t flash[:error] = 'You have not requested a password reset.'\n\t return redirect_to :root\t \n\t end\n\n\t if @user.password_expires_after < DateTime.now\n\t clear_password_reset(@user)\n\t @user.save\n\t flash[:error] = 'Password reset has expired. Please request a new password reset.'\n\t redirect_to :forgot_password\n\t end\n\tend",
"def password_reset\n MemberMailer.password_reset\n end",
"def password_reset\n @errors = Array.new\n if params[:method]==\"post\"\n #password length Validation.\n if params[:password].empty?\n @errors.push(\"Password is empty\")\n elsif params[:password].length < 3\n @errors.push(\"Insufficient password's length\")\n end\n #password_confirm Validation.\n if params[:password_confirm].empty?\n @errors.push(\"You need to repeat the password\")\n else\n unless params[:password_confirm].eql?(params[:password])\n @errors.push(\"Password's don't match\")\n end\n end\n if @errors.count==0\n #no errors, save the data and redirect to singup_complete\n sql=\"UPDATE organizations SET password ='?', random_token = null WHERE organizations.random_token = '?'\"\n result = execute_query(sql, params[:password], params[:token])\n redirect_to '/login', :alert => \"you can now login\"\n end\n else\n sql=\"select email FROM organizations WHERE random_token = '?'\"\n result = execute_query(sql, params[:id])\n if result.rows.length==0\n redirect_to '/forgot_password', :alert => \"unknown one time password\"\n else\n @user_password_reset = result.rows.first[:email]\n render :template => 'signup/password_reset'\n end\n end\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\n\t\t# find user using the reset code specified\n @user = User.find_by_reset_code(params[:reset_code]) unless params[:reset_code].nil?\n if request.post?\n\t\t\t\t# update user's password\n \tif @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])\n\t\t\t\t\t# delete the code \n\t self.current_user = @user\n @user.delete_reset_code\n\t\t\t\t\t# flash notice regarading successfull reset\n gflash :success => \"Password reset successfully for #{@user.email}\"\n redirect_back_or_default('/')\n else\n render :action => :reset\n end\n end\n\tend",
"def reset_password(password)\n self.termpassword = password\n save\n end",
"def reset_password\n if params[:form_reset_password]\n passcode = params[:form_reset_password][:passcode]\n new_password = params[:form_reset_password][:new_password]\n\n response = Password.update(\"testuser@cloudspokes.com.dev091\",passcode,new_password)\n\n if response.message == \"password changed successfully.\"\n flash[:notice] = \"Your password has been updated. Please connect.\"\n redirect_to url_for(:controller => 'content', :action => 'show') and return\n else\n flash[:notice] = \"Error when trying to update your password. Please check your passcode and password.\"\n redirect_to '/reset_password' and return\n end\n end\n 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_reset\n doctor = Doctor.first\n doctor.reset_token = Doctor.new_token\n DoctorMailer.password_reset(doctor)\n end",
"def reset_password\n\t\t#Is user logged in?\n\t\trender :json=>{:success=>false, :msg=>'User not logged in.'} and return if @user.nil?\n\t\t\n\t\t@user.set_temp_password()\n\t\t\n\t\trender :json=>{:success=>true, :msg=>'Temporary password mailed to '+@user.email} and return\n\tend",
"def password_reset\n user = Investor.first\n user.activation_token = Investor.new_token\n NemabollonMailer.password_reset(user)\n end",
"def reset_password\n @user.send_reset_pass_email\n head :no_content\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 password_reset\n user = Volunteer.first\n user.reset_token = Volunteer.new_token\n VolunteerMailer.password_reset(user)\n end",
"def reset_password\n redirect_to :action => 'login' && return if params[:id].to_s.blank?\n @user = User.find_by_password_reset_code(params[:id])\n return unless request.post? && @user\n\n @user.password = params[:password]\n @user.password_confirmation = params[:password_confirmation]\n @user.reset_password\n @user.save!\n flash[:notice] = \"Your password has been changed. You may now log in.\"\n redirect_to :action => 'login'\n rescue ActiveRecord::RecordInvalid\n end",
"def password_reset\r\n token = params.first[0]\r\n @person = Person.find_by_password_reset_token(token)\r\n\r\n if @person.nil?\r\n flash[:error] = 'You have not requested a password reset.'\r\n redirect_to :root\r\n return\r\n end\r\n\r\n if @PERSON.password_expires_after < DateTime.now\r\n clear_password_reset(@person)\r\n @person.save\r\n flash[:error] = 'Password reset has expired. Please request a new password reset.'\r\n redirect_to :forgot_password\r\n end\r\n end",
"def reset_password\n @user = User.find_by_password_reset_code(params[:id]) or raise\n return if request.get?\n\n if (params[:password] == params[:password_confirmation])\n self.current_user = @user #for the next two lines to work\n current_user.password_confirmation = params[:password_confirmation]\n current_user.password = params[:password]\n if current_user.valid? && !params[:password].blank?\n current_user.reset_password\n current_user.save\n flash[:notice] = \"Password reset\"\n redirect_to user_path(current_user)\n else\n flash.now[:notice] = \"Password too short\"\n end\n else\n flash.now[:notice] = \"Password mismatch\"\n end\n\n rescue\n logger.error \"Invalid Reset Code entered\"\n flash[:notice] = \"Sorry - That is an invalid password reset code. Please check your code and try again. (Perhaps your email client inserted a carriage return?)\"\n redirect_to '/'\n end",
"def reset_password\n\t\tself.password_reset_token = User.new_token\n\t\tupdate_columns(password_reset_digest: User.digest(self.password_reset_token), password_reset_sent_at: Time.zone.now)\n\tend",
"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 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 || Lecturer.first\n user.reset_token = User.new_token || Lecturer.new_token\n UserMailer.password_reset(user)\n end",
"def reset_password\n \n # We're coming from a reset_password link\n # TODO: (Since we're checking the in the application controller for this param and logging in, we prob don't need this check anymore)\n #if params.has_key?(:t)\n #logger.info(\"**** looking for secret_token #{params[:t]}\")\n #if @user = User.find_by_secret_token(params[:t])\n # self.current_user = @user\n #else\n # flash[:notice] = \"The link you have is invalid.\"\n # redirect_to :action=>'forgot_password'\n #end \n\n # We're coming from the new password submission page\n # TODO: Remove this logic. We no longer have a new password submission page. This is now done when creating the user\n #else\n #redirect_to :action=>'forgot_password' unless request.post? or params[:user][:plain_password].blank?\n if request.post? and params[:user] and params[:user][:plain_password] and !params[:user][:plain_password].blank? \n @user.plain_password = params[:user][:plain_password]\n @user.plain_password_confirmation = params[:user][:plain_password_confirmation]\n if @user.save(false)\n flash[:notice] = \"Your password has been updated\"\n redirect_to :controller=>'manuscripts', :id=>@user.id\n else\n flash[:now] = 'There was a problem updating your password' \n end\n end\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 change_temp_password\n\tend",
"def reset_password\n if user.reset_password params\n flash[:notice] = \"reset password success\" \n redirect_to settings_url\n else\n flash[:error] = \"reset password error:#{user.errors.full_messages.join}\" \n redirect_to settings_url\n end\n end",
"def password_reset\n #@greeting = \"Pershendetje\"\n\n #mail to: \"to@example.org\"\n end",
"def password_reset\r\n if request.post? && params[:email_address]\r\n flash[:success] = \"Your password has been reset, and emailed to #{params[:email_address]}\"\r\n user = User.find_by_email_address(params[:email_address])\r\n if user\r\n new_password = user.reset_password\r\n email = Emailer.create_password_reset(user, new_password)\r\n Emailer.deliver(email)\r\n end\r\n redirect_to :action => :index\r\n return\r\n end\r\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 public_forgot_password_send\n if params[:form_forgot_password]\n results = CsApi::Account.reset_password(params[:form_forgot_password][:username])\n logger.info \"[SessionsController][DEBUG]==== reset results: #{results}\"\n if results['success'].eql?('true')\n flash[:notice] = results[\"message\"]\n redirect_to reset_password_url\n else \n flash[:error] = results[\"message\"]\n redirect_to forgot_password_url\n end\n end\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 reset_password\n @user = User.find_by_password_reset_code(params[:id]) if params[:id]\n render :layout => 'minimal' and return if @user && request.get?\n flash.clear\n if (params[:password] == params[:password_confirmation])\n self.current_user = @user #for the next two lines to work\n current_user.password_confirmation = params[:password_confirmation]\n current_user.password = params[:password]\n @user.reset_password\n if current_user.save\n flash[:notice] = \"Password reset\"\n redirect_back_or_default(user_path(@user))\n end\n else\n flash[:notice] = \"Password mismatch\" \n render :layout => 'minimal'\n end \n rescue\n logger.error \"Invalid Reset Code entered for: \" + (@user ? @user.email : \"none found\") \n flash[:notice] = \"Sorry - That is an invalid password reset code. Please check your code and try again. (Perhaps your email client inserted a carriage return?)\" \n redirect_back_or_default(user_path(@user))\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 change_password\r\n \r\n end",
"def reset_password\n Notifier.reset_password\n end",
"def restore_password\n UserMailer.restore_password\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 reset_password\n @user = User.find_by_forgot_password_token(params[:forgot_password_token])\n raise_404 unless good_password_change_request?\n\n @user.reset_password!\n end",
"def forgot_password\n if request.post?\n @user=User.find(:first, :conditions => [\"email=? AND system_role=?\", params[:user][:email], User::SYSTEM_ROLE_USER])\n if @user.present?\n o = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten;\n newpass = (0..6).map{ o[rand(o.length)] }.join;\n #newpass = (1..7).map{ (0..?z).map(&:chr).grep(/[a-z\\d]/i)[rand(62)]}.join\n @user.encrypted_password = newpass\n \n Notifier.send_password(@user, newpass).deliver if @user.save\n flash[:notice] = \"New password is sent to your email id.\"\n else\n flash[:forget_pw__error] = \"Error\"\n flash[:notice] = \"Email is not registered.\"\n end\n redirect_to :action => \"home\"\n end\n end",
"def reset_password\n response = invoke_webservice method: 'post', action: 'resetPassword',\n data: { userId: params[:user_name],\n oldPassword: params[:current_password],\n newPassword1: params[:new_password],\n newPassword2: params[:confirm_password],\n pswdChangeFlag:\"1\",\n uidCheckFlag: \"1\" }\n if response\n if response[\"errMsg\"].blank? && !response[\"successMsg\"].blank?\n reset_session\n flash.now[:notice] = I18n.t(response[\"successMsg\"],:scope => \"user_session\",:default => response[\"successMsg\"] )\n render :login\n else\n flash.now[:error] = I18n.t(response[\"errMsg\"],:scope => \"user_session\",:default => response[\"errMsg\"] )\n render 'new_reset_password'\n end\n else\n flash.now[:error] = I18n.t(\"no_service\",:scope => \"user_session\" )\n end\n end",
"def forgot_password\n self.password_reset_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n end"
] | [
"0.8061012",
"0.8041453",
"0.79405916",
"0.79004973",
"0.7897919",
"0.788152",
"0.78813016",
"0.78371173",
"0.7831085",
"0.78106433",
"0.7778985",
"0.7727934",
"0.7721441",
"0.76651764",
"0.76651764",
"0.7659376",
"0.76574594",
"0.76537377",
"0.7644679",
"0.7637372",
"0.7627573",
"0.76255506",
"0.7604664",
"0.7600486",
"0.7598728",
"0.7597562",
"0.7595334",
"0.7572552",
"0.7556495",
"0.7554262",
"0.75177056",
"0.7515674",
"0.75024545",
"0.75024545",
"0.75024545",
"0.75024545",
"0.75024545",
"0.75024545",
"0.75024545",
"0.75012034",
"0.75005144",
"0.7498212",
"0.74933535",
"0.7491941",
"0.74891",
"0.7485536",
"0.7484003",
"0.74733555",
"0.74673873",
"0.7457422",
"0.7456272",
"0.7456272",
"0.74542886",
"0.744704",
"0.7438558",
"0.74353236",
"0.7419958",
"0.740273",
"0.7396159",
"0.73908544",
"0.73875016",
"0.7384841",
"0.73801655",
"0.7371184",
"0.7356153",
"0.7352124",
"0.73510313",
"0.73281485",
"0.73238325",
"0.73237973",
"0.73222876",
"0.7318306",
"0.7317776",
"0.7302678",
"0.72937083",
"0.7292758",
"0.72880083",
"0.72796106",
"0.72780114",
"0.72780114",
"0.72780114",
"0.7276335",
"0.72711486",
"0.7263993",
"0.7263262",
"0.72619647",
"0.7232563",
"0.72287357",
"0.7225983",
"0.7225397",
"0.72142404",
"0.7212974",
"0.72092223",
"0.72016615",
"0.7200387",
"0.71919346",
"0.71912384",
"0.71830285",
"0.71826327",
"0.716713",
"0.71479726"
] | 0.0 | -1 |
Right now the wording of this message is the same as for enrollment | def assessment_sms_weblink(patient)
if patient&.primary_telephone.blank?
add_fail_history_blank_field(patient, 'primary phone number')
return
end
if patient.blocked_sms
TwilioSender.handle_twilio_error_codes(patient, TwilioSender::TWILIO_ERROR_CODES[:blocked_number][:code])
return
end
# Cover potential race condition where multiple messages are sent for the same monitoree.
return unless patient.last_assessment_reminder_sent_eligible?
messages_array = []
sms_lang = patient.select_language(:sms)
web_lang = patient.select_language(:email)
patient.active_dependents.uniq.each do |dependent|
url = new_patient_assessment_jurisdiction_lang_initials_url(dependent.submission_token, dependent.jurisdiction.unique_identifier, web_lang&.to_s,
dependent&.initials_age)
contents = I18n.t('assessments.twilio.sms.weblink.intro', locale: sms_lang, initials_age: dependent&.initials_age('-'), url: url)
# Update last send attempt timestamp before Twilio call
patient.last_assessment_reminder_sent = DateTime.now
patient.save(touch: false)
threshold_hash = dependent.jurisdiction[:current_threshold_condition_hash]
message = { prompt: contents, patient_submission_token: dependent.submission_token,
threshold_hash: threshold_hash }
messages_array << message
end
patient.active_dependents_and_self.each { |pat| add_success_history(pat) } if TwilioSender.send_sms(patient, messages_array)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message\n return MSG_NOT_ENROLLED unless enrolled?\n return MSG_FULL_ACCESS if registered?\n return MSG_LIMITED_ACCESS if twenty_percent_cnp_exception?\n MSG_FEES_UNPAID\n end",
"def meme_phrase; end",
"def whine msg\n logger.error(\"Synfeld laments: \" + msg)\n return msg\n end",
"def wookie_sentence; end",
"def educational_attainment; end",
"def create_first_text_message\n%(Today, I want to feel:\nPassionate\nEnergized\nConnected\nHopeful\nAligned\n)\n end",
"def message_template; end",
"def m2_message\n [\n \"Super fedt at du gerne vil hjælpe os, med at planlægge Spejdernes Lejr 2017!\",\n \"\\n\\nUd fra dine fantastiske kompetencer, har vi videregivet dine kontaktoplysninger til {{udvalg}}. Hvis du ikke hører fra {{udvalg}}, eller hvis I ikke fandt noget du var interesseret i, så er du mere end velkommen til at kontakte os på job@sl2017.dk. Så hjælper vi dig videre til et andet spændende lejrjob!\",\n \"\\n\\n_De fedeste Spejdernes Lejr 2017 hilsener_ \\n\",\n \"{{bruger}}, Jobcenteret SL2017\"\n ].join()\n end",
"def liner_note\n info = \"(authorized accounts: #{@groups.keys.join(', ')})\" \n info = '' if @groups.empty?\n \"%s %s\" % [@name.bright, info]\n end",
"def invitee_string\n\t\n\tend",
"def m4_message\n [\n \"Tak for din interesse for at være **{{jobnavn}}** på Spejdernes Lejr 2017.\",\n \"\\n\\nVi har sendt dine kontaktoplysninger videre til {{kontaktperson}}, som er kontaktperson for denne opgave. Hvis du ikke hører fra {{kontaktperson}}, eller hvis jobbet ikke passede til dig alligevel, så er du velkommen til at kontakte os på job@sl2017.dk, så hjælper vi dig med at finde et andet fantastisk lejrjob!\",\n \"\\n\\n_De fedeste Spejdernes Lejr 2017 hilsener_ \\n\",\n \"{{bruger}}, Jobcenteret SL2017\"\n ].join()\n end",
"def invite_subject\n \"Your invitation to #{org_name.possessive} Creative Difference Dashboard\"\n end",
"def create_second_text_message(first_response)\n%(When I feel #{first_response}, I will also feel:\nCarefree\nPeaceful \nRelieved\nMellow\nRelaxed)\n end",
"def message\n self.description = self.description + merchant_store.store_regards\n end",
"def embargo_message\n message = []\n\n message << if @purl_object.stanford_only_unrestricted?\n 'Access is restricted to Stanford-affiliated patrons'\n else\n 'Access is restricted'\n end\n\n message << pretty_embargo_date\n message.compact.join(' until ')\n end",
"def wookiee_sentence; end",
"def message(message) end",
"def message\n t(\".message\")\n end",
"def ezm_subject_and_status(message)\r\n if message.receiver_deleted?\r\n message.subject + \" (Deleted)\" \r\n elsif message.read_at.nil?\r\n message.subject + \" (Unread)\" \r\n else \r\n message.subject\r\n end\r\n end",
"def body\n (answers['transcription'] || answers['1']).to_s\n end",
"def gradebookMessage\n \" \"\nend",
"def attribute_to_check_message_against; end",
"def message; end",
"def message; end",
"def message; end",
"def message; end",
"def message; end",
"def message; end",
"def message() end",
"def alert_preamble\n text = user ? user.email : ''\n text += \" [#{company.name}]\" if company\n text\n end",
"def message\n \n end",
"def sms_tpl\n \"Hi it's #{pastor_name || '(name of pastor)'}. I'm personally inviting you to join #{user_group.name} online via LoveRealm. All church materials, schedules, counseling have been put there. You will also make friends and grow there. It's free. Join here: www.loverealm.com/dl\"\n end",
"def reason\n RichText.new(self[:reason_format], self[:reason])\n end",
"def symptom\n WellBeing::SYMPTOM\n end",
"def alt_message_id\n 'login_alt_message_textView'\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def blurb_win\n case self.type\n when 'test'\n \"Thanks for using this service.\"\n when 'left'\n\"Please contact #{self.email_from} if you have any queries regarding the analysis or the output and one of the team will respond.\n\nBest regards,\nThe LEFT development team.\"\n\n end\n end",
"def foorth_message\r\n \"#{self.foorth_code} #{self.message}\"\r\n end",
"def mk_sender\n [\"-- \", \"Med kærlig hilsen, \", \"Med venlig hilsen, \", \"MVH, \", \"Hilsen \"].sample + \"Nikolaj Lepka\\n\" +\n \"Telefon: 25 14 66 83\\n\" +\n \"Email: slench102@gmail.com\\n\" +\n \"Github: https://github.com/ElectricCoffee\\n\" +\n \"Twitter: https://twitter.com/Electric_Coffee\\n\\n\"\n end",
"def next_message; end",
"def next_message; end",
"def standard_message\n \"#{current_player.name}'s pending words: #{pending_result}\"\n end",
"def message( message )\n\tend",
"def message\n unregistered = \"\"\n if self.status == STATES[:unregistered]\n unregistered = \"and unregistered #{self.updated_at.strftime(\"on %d.%m.%Y at %H:%M Uhr\")}\"\n end\n\n \"#{self.user.name} has enrolled to #{self.course.title} #{unregistered}\"\n end",
"def twitter_publish_message\n \"#NoAgenda show ##{number} attack vectors now at http://noagendadashboard.com\"\n end",
"def user_message\n return _translate if description.present? || tkey.present?\n return \"#{_translate} (#{user_digests})\" unless defined?(@coaster)\n message\n rescue => e\n \"#{message} (user_message_error - #{e.class.name} #{e.message})\"\n end",
"def acknowledgement_reference_id\r\n\t\tacknowledgement_message.split(\":\")[1].gsub(/\\s/,\"\")\r\n\tend",
"def get_message # 優惠訊息\n\t\tif self.range == 'all'\n msg1 = '全館'\n elsif self.range == 'price'\n msg1 = '全館滿' + self.range_price.to_s + '元'\n elsif self.range == 'product'\n if self.range_quantity == 1\n msg1 = '本商品每件'\n else\n msg1 = '本商品' + self.range_quantity.to_s + '件'\n end\n end\n\n if self.offer == 'freight'\n if self.offer_freight == 'all'\n msg2 = '免運費'\n elsif self.offer_freight == 'CVS'\n msg2 = '超商取貨免運費'\n elsif self.offer_freight == 'Home'\n msg2 = '宅配免運費'\n end\n elsif self.offer == 'price'\n msg2 = '折' + self.offer_price.to_s + '元'\n elsif self.offer == 'discount'\n msg2 = '打' + self.offer_discount.to_s + '折'\n end\n\n msg1 + msg2\n\tend",
"def message\n t(\".message\")\n end",
"def message\n t(\".message\")\n end",
"def subject_and_status(message)\n tag = ''\n if message.receiver_deleted?\n tag = \" (Deleted)\"\n elsif message.read_at.nil? and params[:action] != \"outbox\"\n \"· <strong>#{message.subject}</strong>\".html_safe\n else\n message.subject\n end\n end",
"def translators_note # :nologin:\n end",
"def description\n self[:message]\n end",
"def hermes_catchphrase; end",
"def mess\r\n\t\t@usr_mess\r\n\tend",
"def message_text\n clear_default_fields\n result = self.message\n reset_default_fields\n result\n end",
"def build_email_content\n txt = I18n.t(\"estimate_request.fltk.email_content\", :origin => self.origin_port.name, :destination => destination_port.name, :count => self.estimate_items.first.number_of_items, :description => self.estimate_items.first.description)\n txt\n end",
"def message\n @_message\n end",
"def message\n @_message\n end",
"def message\n end",
"def heading_message\n return I18n.t('application.my_dashboard') if any_courses?\n return I18n.t('application.greeting2')\n end",
"def lookup_message(name)\n\t\tend",
"def headers\n {\n :subject => \"澄清:對於#{candidate_name}的#{record_type}\",\n # :to => \"wevote@watchout.tw\",\n :to => Setting.email.clarify,\n :from => %(\"#{name}\" <#{email}>)\n }\n end",
"def subject_name\n subject_full_name\n end",
"def email_body\n sponsor_name = @config.plan.sponsor_name\n message = 'Hi there!'\\\n '<br />'\\\n '<br />'\\\n \"#{sponsor_name} has run their payroll. Please download the relevant reports below.\"\\\n '<br />'\\\n '<br />'\n message\n end",
"def conversation_title_about(product, buyer)\n \"Inquiry about #{product.name} between #{product.seller.profile.first_name} and #{buyer.profile.first_name}\"\n end",
"def data_for_role_general_mailing\n {}\n end",
"def all_authorized_message\n %(\n Hi. Your friendly Curry bot here. Just letting you know that all\n commit authors have become authorized to contribute.\n\n I have added the \"#{ENV['CURRY_SUCCESS_LABEL']}\" label to\n this issue so it can easily be found in the\n future.\n ).squish\n end",
"def indefinite_personal_subjective_pronoun\n return \"it\"\n end",
"def GetMessages(w, e, m, ynm)\n richtext = \"\"\n\n if w\n # translators: warnings summary header\n richtext = Ops.add(\n Ops.add(Ops.add(richtext, \"<P><B>\"), _(\"Warning:\")),\n \"</B><BR>\"\n )\n\n Builtins.foreach(@warnings) do |s|\n strs = Builtins.splitstring(s, \"\\n\")\n Builtins.foreach(strs) do |line|\n richtext = Ops.add(Ops.add(richtext, line), \"<BR>\")\n end\n end \n\n\n richtext = Ops.add(richtext, \"</P>\")\n end\n\n if e\n # translators: errors summary header\n richtext = Ops.add(\n Ops.add(Ops.add(richtext, \"<P><B>\"), _(\"Error:\")),\n \"</B><BR>\"\n )\n\n Builtins.foreach(@errors) do |s|\n strs = Builtins.splitstring(s, \"\\n\")\n Builtins.foreach(strs) do |line|\n richtext = Ops.add(Ops.add(richtext, line), \"<BR>\")\n end\n end \n\n\n richtext = Ops.add(richtext, \"</P>\")\n end\n\n if m\n # translators: message summary header\n richtext = Ops.add(\n Ops.add(Ops.add(richtext, \"<P><B>\"), _(\"Message:\")),\n \"</B><BR>\"\n )\n\n Builtins.foreach(@messages) do |s|\n strs = Builtins.splitstring(s, \"\\n\")\n Builtins.foreach(strs) do |line|\n richtext = Ops.add(Ops.add(richtext, line), \"<BR>\")\n end\n end \n\n\n richtext = Ops.add(richtext, \"</P>\")\n end\n\n if ynm\n # translators: message summary header\n richtext = Ops.add(\n Ops.add(Ops.add(richtext, \"<P><B>\"), _(\"Message:\")),\n \"</B><BR>\"\n )\n\n Builtins.foreach(@yesno_messages) do |s|\n strs = Builtins.splitstring(s, \"\\n\")\n Builtins.foreach(strs) do |line|\n richtext = Ops.add(Ops.add(richtext, line), \"<BR>\")\n end\n end \n\n\n richtext = Ops.add(richtext, \"</P>\")\n end\n richtext\n end",
"def get_subject\n\t\tend",
"def check_education_message\n return if @topic&.private_message?\n\n if creating_topic?\n count = @user.created_topic_count\n education_key = 'education.new-topic'\n else\n count = @user.post_count\n education_key = 'education.new-reply'\n end\n\n if count < SiteSetting.educate_until_posts\n return {\n id: 'education',\n templateName: 'education',\n wait_for_typing: true,\n body: PrettyText.cook(\n I18n.t(\n education_key,\n education_posts_text: I18n.t('education.until_posts', count: SiteSetting.educate_until_posts),\n site_name: SiteSetting.title,\n base_path: Discourse.base_path\n )\n )\n }\n end\n\n nil\n end",
"def full_message\n if @model\n if field\n if i18n_set? \"#{i18n_scope}.models.#{@model}.#{field}.#{code}\", t\n I18n.t(\"#{i18n_scope}.models.#{@model}.#{field}.#{code}\", t)\n elsif i18n_set?(\"#{i18n_scope}.field.#{code}\", t)\n I18n.t(\"#{i18n_scope}.field.#{code}\", t)\n elsif i18n_set? \"#{i18n_scope}.#{code}\", t\n I18n.t(\"#{i18n_scope}.#{code}\", t)\n else\n code.to_s\n end\n else\n if i18n_set? \"#{i18n_scope}.models.#{@model}.#{code}\", t\n I18n.t(\"#{i18n_scope}.models.#{@model}.#{code}\", t)\n elsif i18n_set? \"#{i18n_scope}.#{code}\", t\n I18n.t(\"#{i18n_scope}.#{code}\", t)\n else\n code.to_s\n end\n end\n elsif @controller && @action\n if field && i18n_set?(\"#{i18n_scope}.controllers.#{@controller}.#{@action}.#{field}.#{code}\", t)\n I18n.t(\"#{i18n_scope}.controllers.#{@controller}.#{@action}.#{field}.#{code}\", t)\n elsif i18n_set?(\"#{i18n_scope}.controllers.#{@controller}.#{@action}.#{code}\", t)\n I18n.t(\"#{i18n_scope}.controllers.#{@controller}.#{@action}.#{code}\", t)\n elsif i18n_set? \"#{i18n_scope}.#{code}\", t\n I18n.t(\"#{i18n_scope}.#{code}\", t)\n else\n code.to_s\n end\n elsif field && i18n_set?(\"#{i18n_scope}.field.#{code}\", t)\n I18n.t(\"#{i18n_scope}.field.#{code}\", t)\n elsif i18n_set? \"#{i18n_scope}.#{code}\", t\n I18n.t(\"#{i18n_scope}.#{code}\", t)\n else\n code.to_s\n end\n end",
"def status_text\n\t s = Enrollment::STATUS_NAMES[self.enrollment_status]\n\t \n\t if [Enrollment::STATUS_CLOSED,Enrollment::STATUS_FINALIZED].include? self.enrollment_status\n\t s += \"-#{Enrollment::COMPLETION_NAMES[self.completion_status]}\"\n\t end\n\t s\n\tend",
"def message\n MESSAGE\n end",
"def message\n MESSAGE\n end",
"def message\n MESSAGE\n end",
"def message\n MESSAGE\n end",
"def customized_message_body\n return @customized_message_body\n end",
"def to_s()\r\n\t\treturn 'en action...'\r\n\tend",
"def login_message\n \"You need to be logged in to edit one of these documents.\"\n end",
"def subject; @message_impl.getSubject; end",
"def message\n\t\t@message \n\tend",
"def generate_message(prev_user, next_user)\n text = \"<@#{next_user}> you can now use the laundry machine <@#{prev_user}> is done using it.\"\n return text\n end",
"def to_s\n\t\t\tstr = super() + \"\\n\"\n\t\t\tstr += \"\\tAppaleable? #{appaleable}\\n\" if appaleable\n\t\t\tstr += \"\\tDisapproved text: #{disapproved_text}\\n\" if disapproved_text\n\t\t\tstr += \"\\tLocation: #{location}\\n\" if location\n\t\t\tstr += \"\\tDisapproved text: #{disapproved_text}\\n\" if disapproved_text\n\t\t\tstr += \"\\tReason code: #{reason_code} (see: http://msdn.microsoft.com/en-US/library/bing-ads-editorialfailurereasoncodes.aspx)\\n\" if reason_code\n\n\t\tend",
"def admin_proofread_final_manuscript_list\n %w( tt_proofed_manuscript_list@booktrope.com )\n end",
"def marketing_name\n super\n end",
"def subject\n message.subject\n end",
"def message\n @name\n end",
"def mk_email\n ps = \"P.S. Jeg har vedhæftet relevante dokumenter, så som eksamensbevis og CV i mailen.\"\n ps += \"\\nP.P.S Denne email var genereret med, og sendt fra et Ruby script :)\" if @skills and @skills.include? \"Ruby\"\n \"#{mk_intro}\\n#{mk_body}#{mk_outro}#{mk_sender}#{ps}\"\n end",
"def generate_message(user, drain_status)\n message = ''\n clean_keywords = ['msafi', 'Msafi', 'clean', 'Clean'].map(&:downcase)\n dirt_keywords = ['mchafu', 'Mchafu', 'dirty', 'Dirty',\n 'not clean', 'Not clean'].map(&:downcase)\n need_help_keywords = ['msaada','Msaada', 'need help', 'Need help'].map(&:downcase)\n\n if user\n drain_status = categorize_sms_content(drain_status)\n if(drain_status.instance_of?(Array))\n drain_id = drain_status[1]\n drain_status = drain_status[0]\n drain_claim = DrainClaim.find_by_user_id_and_gid(user.id, drain_id)\n else\n drain_claim = DrainClaim.where(:user_id => user.id)\n if (drain_claim)\n if (!drain_claim.instance_of?(DrainClaim))\n #TODO function to determine user language\n I18n.locale = 'sw'\n message = I18n.t('messages.many_drains')\n I18n.locale = 'en'\n message = message + \" \" + I18n.t('messages.many_drains')\n return message\n end\n else\n I18n.locale = 'sw'\n message = I18n.t('messages.drain_unknown')\n I18n.locale = 'en'\n message = message + \" \" + I18n.t('messages.drain_unknown')\n return message\n end\n end\n drain_status = drain_status.downcase\n\n if (clean_keywords.include? drain_status)\n change_locale(clean_keywords, drain_status)\n if (drain_claim)\n drain_claim.shoveled = true\n end\n drain = Drain.find_by_gid(drain_id)\n if(updates_authentication(user, drain))\n drain.cleared = true\n drain.save(validate: false)\n message = I18n.t('messages.drain_cleaned')\n else\n if (drain_claim)\n if (drain_claim.save(validate: false))\n message = I18n.t('messages.thanks')\n else\n message = I18n.t('messages.error')\n end\n else\n message = I18n.t('messages.drain_unknown')\n end\n end\n # drain.need_help = false\n\n elsif (dirt_keywords.include? drain_status)\n change_locale(dirt_keywords, drain_status)\n if (drain_claim)\n drain_claim.shoveled = false\n end\n\n drain = Drain.find_by_gid(drain_id)\n if(updates_authentication(user, drain))\n drain.cleared = false\n drain.save(validate: false)\n message = I18n.t('messages.drain_dirty')\n else\n if (drain_claim)\n if (drain_claim.save(validate: false))\n message = I18n.t('messages.thanks')\n else\n message = I18n.t('messages.error')\n end\n else\n message = I18n.t('messages.drain_unknown')\n end\n end\n else\n message = I18n.t('messages.unknown')\n end\n\n if (need_help_keywords.include? drain_status)\n change_locale(need_help_keywords, drain_status)\n \n # drain_claim.shoveled = false\n # drain.need_help = true\n drain = Drain.find_by_gid(drain_id)\n puts updates_authentication(user, drain);\n if(updates_authentication(user, drain))\n need_help = {\n 'help_needed': '',\n 'need_help_category_id': 4,\n 'user_id': user.id,\n 'gid': drain.id\n }\n @need_help = NeedHelp.new(need_help)\n if (@need_help.save(validate: true))\n drain.need_help = true\n drain.save(validate: false)\n message = I18n.t('messages.need_help_thanks')\n else\n message = I18n.t('messages.need_help_error')\n end\n else\n message = I18n.t('messages.need_help_user_error')\n end\n end\n else\n message = I18n.t('messages.user_not_found', :site => I18n.t('defaults.site'));\n end\n\n return message\n end",
"def raw_message\n @raw_message ||= @md[FIELDS.index('raw_message') + 1].strip\n end",
"def curate_text\n notification_type = get_nagios_var('NAGIOS_NOTIFICATIONTYPE')\n if notification_type.eql?('ACKNOWLEDGEMENT')\n @text += self.content[:short_text][:ack_info] unless self.content[:short_text][:ack_info].empty?\n else\n [:host_info, :state_info, :additional_info, :additional_details].each do |info|\n @text += self.content[:short_text][info] unless self.content[:short_text][info].empty?\n end\n end\n end",
"def message text\n $status_message.value = text # trying out 2011-10-9 \n end",
"def get_text_for_indexing\n text = self.body.strip\n text.sub!(/Dear .+,/, \"\")\n text.sub!(/[^\\n]+1049\\/2001[^:\\n]+:? ?/, \"\") # XXX: can't be more specific without locale\n self.remove_privacy_sensitive_things!(text)\n return text\n end",
"def message=(_); end",
"def computer_message\n computer_msg.text\n end",
"def computer_message\n computer_msg.text\n end",
"def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end",
"def approved_by\n t(:message_0, :scope => [:model, last_approver.to_s.underscore])\n end",
"def expand_text_ci(candidate)\n subject_message = \"#{Visitor.home_parish} website for Confirmation Candidates - User Verification instructions\"\n expand_text(candidate,\n MailPart.new_subject(subject_message),\n MailPart.new_body(''),\n conf_insts_call)\n end"
] | [
"0.6435627",
"0.6350415",
"0.62496716",
"0.6249376",
"0.62021154",
"0.6194348",
"0.6101234",
"0.60801",
"0.606815",
"0.6033377",
"0.5987189",
"0.5954343",
"0.5950888",
"0.5948497",
"0.59480274",
"0.5932388",
"0.5901886",
"0.5899486",
"0.58897847",
"0.5883906",
"0.587001",
"0.58443433",
"0.58434874",
"0.58434874",
"0.58434874",
"0.58434874",
"0.58434874",
"0.58434874",
"0.5829836",
"0.5825687",
"0.5813977",
"0.58105785",
"0.58059293",
"0.579401",
"0.57912886",
"0.5783984",
"0.57828397",
"0.5768832",
"0.57578486",
"0.5756172",
"0.5756172",
"0.5740622",
"0.57386655",
"0.57356286",
"0.57282573",
"0.5725511",
"0.57231724",
"0.5707599",
"0.57030547",
"0.57030547",
"0.5698123",
"0.56932074",
"0.5677317",
"0.56757927",
"0.5671053",
"0.5640429",
"0.563348",
"0.56246805",
"0.56246805",
"0.56237924",
"0.5620735",
"0.56190187",
"0.5615908",
"0.56126446",
"0.5609695",
"0.5597489",
"0.5580283",
"0.5578264",
"0.55753154",
"0.5571603",
"0.5569132",
"0.55627936",
"0.5554765",
"0.5553546",
"0.55531853",
"0.55531853",
"0.55531853",
"0.55531853",
"0.5545492",
"0.5541603",
"0.55352366",
"0.5534025",
"0.5532136",
"0.5527144",
"0.55249864",
"0.5520513",
"0.55192786",
"0.5507606",
"0.5507554",
"0.5505754",
"0.5502801",
"0.54906744",
"0.54902905",
"0.5481415",
"0.5481211",
"0.54726136",
"0.5472048",
"0.5472048",
"0.5466043",
"0.54584455",
"0.54522586"
] | 0.0 | -1 |
This returns the API user being used for calls | def api_user
@user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user\n conf['api']['user']\n end",
"def current_user\r\n api_key = ApiKey.active.where(access_token: token).first\r\n if api_key\r\n return api_key.user\r\n else\r\n return nil\r\n end\r\n end",
"def user\n @user ||= @uri && client.user(@uri.split(':')[2])\n end",
"def current_user\n api_key = ApiKey.active.where(access_token: token).first\n if api_key\n return api_key.user\n else\n return nil\n end\n end",
"def api_user\n token = request.headers['Authorization']\n return @current_user ||= User.find_by_api_token(token) if token\n end",
"def user()\n return @data[\"access\"][\"user\"]\n end",
"def current_user\n get(\"/v1/users/me\")\n end",
"def get_current_user\n request(Route.new(:GET, '/users/@me'))\n end",
"def current_user\n\t\tif session[:user_id]\n\t\t\t@current_user = User.find(session[:user_id])\n\t\telse\n\t\t\tapi_key = ApiKey.where(access_token: token_and_options(request)).first\n\t\t\t@current_user = User.find(api_key.user_id) if api_key\n\t\tend\n\tend",
"def current_user\n user = FastlaneCI::Services.user_service.find_user(id: env[:user])\n if user.nil?\n halt 500\n else\n return user\n end\n end",
"def current_user\n api_key = APIKey.active.where(access_token: token).first\n if api_key\n return api_key.usuario\n else\n return nil\n end\n end",
"def current_user\n get_from_options_or_controller(:current_user)\n end",
"def user\n Thread.current[\"current_user\"] \n end",
"def user_id\n payload = authenticate!(via: :jwt)\n return payload[\"user\"]\n end",
"def user\n return Etc.getlogin\n end",
"def get_user_info\n userTokenInfo = request.env['oauth.token']\n @user = userTokenInfo.user\n end",
"def user\n user_id.get_object\n end",
"def hubssolib_current_user\n hubssolib_get_user_data\n end",
"def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end",
"def api_user\n user = active_user\n user.enable_api! if user.valid?\n user\n end",
"def current_user() # :doc:\n @current_user ||= begin\n if api_request?\n UserSession.find.full?(&:user) ||\n authenticate_by_api_key_in_params || \n authenticate_by_api_key_in_http_auth\n else\n UserSession.find.full?(&:user)\n end\n end\n end",
"def remote_user\n endpoint.remote_user\n end",
"def human_user\n # If we have a doorkeeper_token, derive the User from it.\n # If not, we're in case #1 above and the User should be\n # retrieved from the non_doorkeeper_user_proc.\n @user ||= @doorkeeper_token ? \\\n USER_CLASS.where(id: @doorkeeper_token.try(:resource_owner_id)).first : \\\n @non_doorkeeper_user_proc.call\n end",
"def user\n authentication.user\n end",
"def getUser()\n\t\treturn @user\n\tend",
"def user_info\n auth_hash['user_info']\n end",
"def user\n metadata&.dig('event', 'user')\n end",
"def current_user\n @user || @api_user || @social_user\n end",
"def get_current_user\n return if !bearer_token\n decoded_jwt = decode_token(bearer_token)\n User.find(decoded_jwt[0][\"user\"][\"id\"])\n end",
"def user\n return @user ? @user : Dotfu.config_user\n end",
"def current_user\n authentication.account\n end",
"def user_method\n current_user\n end",
"def current_api_user\n @current_api_user ||= stub_model(Refinery::Api.user_class, email: \"refinery@example.com\")\n end",
"def current_api_user\n api_access_token = extract_bearer_token(request)\n if api_access_token.present?\n user = User.find_by('api_access_token.access_token' => api_access_token)\n if user.nil?\n # extract user info from access_token\n begin\n token_url = \"https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=#{api_access_token}\"\n response = RestClient.get token_url\n credentials = JSON.parse response.body\n now = Time.zone.now\n token_values = {\n 'access_token' => api_access_token,\n 'expires_in' => credentials['expires_in'],\n 'expires_at' => now + credentials['expires_in'].to_i,\n 'last_access_at' => now\n }\n email = credentials['email']\n user = User.find_by(email: email)\n if user.present?\n # store api_access_token to speed up retrieval next time\n user.update(api_access_token: token_values)\n else\n Rails.logger.error \"Unable to retrieve user info from access token: #{api_access_token}\"\n end\n rescue => e\n error_context = {\n auth_response_body: response.present? ? response.body : nil,\n auth_response_code: response.present? ? response.code : nil,\n auth_response_headers: response.present? ? response.headers : nil\n }\n ErrorTracker.report_exception(e, user, error_context)\n Rails.logger.error \"Error retrieving user api credentials: #{e.class.name}: #{e.message}\"\n end\n end\n # check for token expiry and unset user && api_access_token if expired/timed out\n # unsetting token prevents downstream FireCloud API calls from using an expired/invalid token\n if user.api_access_token_expired? || user.api_access_token_timed_out?\n user.update(api_access_token: nil)\n nil\n else\n # update last_access_at\n user.update_last_access_at!\n user\n end\n elsif controller_name == 'search' && action_name == 'bulk_download'\n Rails.logger.info \"Authenticating user via auth_token: #{params[:auth_code]}\"\n user = User.find_by(totat: params[:auth_code].to_i)\n user.update_last_access_at!\n user\n end\n end",
"def call\n user\n end",
"def user\r\n return for_context(nil, false) { |c| c.user }\r\n end",
"def current_user\n User.all(public_key: security.public_key).first\n end",
"def user\n @user ||= OctocatHerder::User.fetch(@raw['user'], connection)\n end",
"def get_user\n @user\n end",
"def get_user\n @user\n end",
"def user\n\t\t\treturn nil if ! logged_in?\n\n\t\t\tPicombo::Session.instance.get('user')\n\t\tend",
"def getUser\n current_company.user\n end",
"def get_user_info\n get(\"/api/v1/oauth_user_info.json\")\n end",
"def current_user\n payload = TokiToki.decode(bearer_token)\n @current_user ||= User.find_by :github_name => payload[0]['sub']\n end",
"def get_current_user_api\n $SDK_API\nend",
"def getUser\n render json: @current_user, status: 200\n end",
"def current_user\n @current_user ||= fetch_user_from_request\n end",
"def auth_user_id\n auth[:user_id]\n end",
"def current_user\n if decoded_token\n user_id = decoded_token[0]['user_id']\n @user = User.find_by(id: user_id)\n # Returns nil if not found\n end\n end",
"def current_user\n current_login_credential\n end",
"def user\n return ENV['USER']\n end",
"def get_userid()\n user_info = call_myspace_api(:user_info, :v1_json => true)\n user_info['userId'].to_s\n end",
"def get_userid()\r\n user_info = @context.call_myspace_api(:user_info, :v1_json => true)\r\n user_info['userId'].to_s\r\n end",
"def current_api_user\n @current_api_user ||= stub_model(User, email: \"tester@example.com\")\n end",
"def me\n context[:current_user]\n end",
"def current_user\n @req.env['REMOTE_USER']\n end",
"def current_user_id\n info['user']['id']\n end",
"def user\n @user ||= opts.fetch(:user, parsed_opt('user'))\n end",
"def user(user_name)\n OctocatHerder::User.fetch(user_name, connection)\n end",
"def user\r\n return @user\r\n end",
"def user_info\n response = from_server \"api/user.json\"\n response.data\n end",
"def current_user\n return @current_user\n end",
"def set_api_user\n RequestStore.store[:current_user] = User.system_user\n end",
"def get_user_name(user_id)\n if self.is_api then\n user = begin \n HuiMain.plugin_data.find_one(\"_id\" => BSON::ObjectId(user_id))\n rescue BSON::InvalidObjectId\n nil\n end\n if user then \n user[\"name\"]\n else\n nil\n end\n else # not api\n session[:current_user_name]\n end\n end",
"def current_user\n if Rails.application.config.use_omniauth\n return nil unless session[:user_info]\n @current_user ||= User.find_user_from_omniauth(session[:user_info])\n else\n @current_user ||= User.where(username: request.env['aker.check'].user.username).first\n end\n end",
"def find_current_user\n user = nil\n unless api_request?\n if session[:user_id]\n # existing session\n user = (User.active.find(session[:user_id]) rescue nil)\n elsif cookies[Redmine::Configuration['autologin_cookie_name']] && Setting.autologin?\n # auto-login feature starts a new session\n user = User.try_to_autologin(cookies[Redmine::Configuration['autologin_cookie_name']])\n session[:user_id] = user.id if user\n user\n elsif params[:format] == 'atom' && params[:key] && accept_key_auth_actions.include?(params[:action])\n # RSS key authentication does not start a session\n user = User.find_by_rss_key(params[:key].to_s)\n end\n end\n if user.nil? && Setting.rest_api_enabled? && api_request?\n if (key = api_key_from_request) && accept_key_auth_actions.include?(params[:action])\n # Use API key\n user = User.find_by_api_key(key.to_s)\n else\n # HTTP Basic, either username/password or API key/random\n authenticate_with_http_basic do |username, password|\n user = User.try_to_login(username, password) || User.find_by_api_key(username)\n end\n end\n # Switch user if requested by an admin user\n if user && user.admin? && (username = api_switch_user_from_request)\n su = User.find_by_login(username)\n if su && su.active?\n logger.info(\" User switched by: #{user.login} (id=#{user.id})\") if logger\n user = su\n else\n render_error :message => 'Invalid X-ChiliProject-Switch-User header', :status => 412\n end\n end\n end\n user\n end",
"def get_current_user_name\n return @name if @name\n name = get_current_user_meta\n name = name['query']['userinfo']['name'] if name\n\n name\n end",
"def authz_user\n send(Authz.current_user_method)\n end",
"def get_user_info user\n unless user.known_user.nil?\n known_user = user.known_user\n is_me = known_user.is_current_user || false\n return is_me ? \"people/me\" : known_user.person_name\n end\n get_one_of user\nend",
"def user\n JenkinsApi::Client::User.new(self)\n end",
"def user\n User.where(id: object.user_id)[0]\n end",
"def user\n return @user\n end",
"def user\n return @user\n end",
"def authenticated_user\n @user ||= client.user\n end",
"def current_user(**args)\n params = parameters(args) do\n optional_params\n end\n request(:get, 'users/me', params)\n end",
"def current_user\n unless request.format.json?\n @current_user ||= User.find_by_auth_token(cookies[:auth_token]) if cookies[:auth_token]\n end\n @current_user\n end",
"def user_requested_by\n response = get(\"users/self/requested-by\")\n response\n end",
"def current_user\n session.user\n end",
"def user\n return @user\n end",
"def user\n @user\n end",
"def user\n {user_id: self.object.user.id,\n user_name: self.object.user.name\n }\n end",
"def current_api_user\n @current_api_user ||= stub_model(Spree::User, :email => \"spree@example.com\")\n end",
"def actual_user\n User.find_by_id(session[:user_id])\n end",
"def user_id\n raise \"Implement in Client or Advocate\"\n end",
"def user\n @user ||= Innsights::Fetchers::User.new(@user_object) if @user_object\n end",
"def current_user\n User.current\n end",
"def current_user\n appctrl_set_user()\n return @current_user\n end",
"def me\n object_from_response(self, Artsy::Client::Domain::User, :get, \"/api/v1/me\", {})\n end",
"def user\n User.get(contact, client: @client)\n end",
"def current_user\n session[:user]\n end",
"def user(id = 'self')\n get(\"users/#{id}\").user\n end",
"def current_user\n @current_user\n end",
"def current_user\n @current_user\n end",
"def current_user\n current_account\n end",
"def get_user\n\t\treturn Account.find(self.account_id)\n\tend",
"def current_user\n session[:usr_id]\n end",
"def current_user\n @current_user\n end",
"def admin_http_auth_user\n # This needs special magic in mongrel: http://www.ruby-forum.com/topic/83067\n # Hence the second clause which reads X-Forwarded-User header if available.\n # See the rewrite rules in conf/httpd.conf which set X-Forwarded-User\n if request.env[\"REMOTE_USER\"]\n return request.env[\"REMOTE_USER\"]\n elsif request.env[\"HTTP_X_FORWARDED_USER\"]\n return request.env[\"HTTP_X_FORWARDED_USER\"]\n else\n return \"*unknown*\";\n end\n end",
"def call\n fetch_user_from_auth_token\n end",
"def hubssolib_get_user_name\n user = self.hubssolib_current_user\n user ? user.user_real_name : nil\n end"
] | [
"0.79773635",
"0.76724285",
"0.76404595",
"0.76386076",
"0.7634918",
"0.76042706",
"0.7556157",
"0.7521312",
"0.74474907",
"0.72893983",
"0.72706825",
"0.7225416",
"0.7210287",
"0.7199154",
"0.7179509",
"0.7175929",
"0.71632904",
"0.7133719",
"0.7117078",
"0.7113061",
"0.7102108",
"0.7076041",
"0.7056715",
"0.7042749",
"0.70417935",
"0.7039698",
"0.7034262",
"0.70275515",
"0.70082015",
"0.69981253",
"0.6996421",
"0.6985467",
"0.69810414",
"0.6975092",
"0.6970254",
"0.6969242",
"0.69681823",
"0.6967739",
"0.6952077",
"0.6952077",
"0.6941495",
"0.6937469",
"0.6934056",
"0.69293165",
"0.692118",
"0.69176465",
"0.69055486",
"0.6902282",
"0.6890335",
"0.68802965",
"0.6863319",
"0.68552977",
"0.68405306",
"0.68400365",
"0.683368",
"0.68330646",
"0.68256754",
"0.6824237",
"0.68231744",
"0.68119955",
"0.6809139",
"0.6801885",
"0.68000925",
"0.6778516",
"0.6770586",
"0.6742448",
"0.6741311",
"0.67409545",
"0.67357624",
"0.6729691",
"0.67252433",
"0.67221224",
"0.67221224",
"0.6721617",
"0.67160493",
"0.6714",
"0.67117923",
"0.6703472",
"0.6703263",
"0.6683447",
"0.66765845",
"0.6671601",
"0.6670695",
"0.6670447",
"0.6670002",
"0.6669621",
"0.6661474",
"0.66507584",
"0.66500425",
"0.664944",
"0.6649118",
"0.66458666",
"0.66458666",
"0.6645815",
"0.6644503",
"0.6641774",
"0.6636937",
"0.66276926",
"0.66267776",
"0.6625593"
] | 0.8331093 | 0 |
This returns the API key being used for calls | def api_key
@key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_key\n key\n end",
"def me_api_key\n api_key = ApiKey.find(me.api_key_id) if auth?\n api_key.api_key || ''\n end",
"def api_key\n configuration.api_key\n end",
"def api_key\n config.api_key\n end",
"def api_key\n config.api_key\n end",
"def api_key\n @key\n end",
"def api_key\n token = self.api_token || self.create_api_token(:action => 'api')\n token.value\n end",
"def api_key\n @api_key\n end",
"def api_key\n @@api_key\n end",
"def api_key\n @@api_key\n end",
"def api_key\n @@api_key\n end",
"def api_key email = nil\n account(email)[:api_key]\n end",
"def api_key\n ENV['UNLEASHED_API_KEY']\n end",
"def api_key; end",
"def api_key; end",
"def api_key\n # We are not lazy loading the @api_key in order to preserve the\n # distinction between it and the default (class) key.\n @api_key || self.class.api_key\n end",
"def api_key\n @@api_key ||= ''\n end",
"def api_key\n ENV['IPLOCATOR_API_KEY']\n end",
"def api_key\n\t\t\t@username || 'unknown'\n\t\tend",
"def api_key\n @api_key ||= config_value.split('-')[1].chomp\n end",
"def api_key_id\n @attributes[:api_key_id]\n end",
"def api_key\n request.headers['HTTP_AUTHORIZATION']\n end",
"def apikey\n @apikey ||= ENV['WORDHOP_API_KEY']\n end",
"def api_key\n ENV['GOOGLE_API_KEY'] || options[:api_key]\n end",
"def apikey\n @apikey ||= ENV['JANIS_API_KEY']\n end",
"def key\n ENV[\"CHEF_API_KEY\"] || config[\"CHEF_API_KEY\"]\n end",
"def generate_api_key\n SecureRandom.random_number(2 ** 256).to_s(36)\n end",
"def generate_api_key\n @url = 'https://ericssonbasicapi2.azure-api.net/v1_0/apiuser/' +\n @uuid + '/apikey'\n response = Faraday.post(@url) do |req|\n req.headers['Ocp-Apim-Subscription-Key'] = @key\n end\n\n unless response.status == 201\n raise Momoapi::Error.new(response.body, response.status)\n end\n\n key = JSON.parse(response.body)\n puts \"\\n User ID: #{@uuid} \\n API key: #{key['apiKey']} \\n\\n\"\n end",
"def api_key\n ApiKey.find_by(manager_id: id)\n end",
"def get_api_key\n if api_key = params[:auth_token].blank? && request.headers[\"X-API-KEY\"]\n params[:auth_token] = api_key\n end\n #Rails.logger.debug params #.to_yaml\n #Rails.logger.debug \"API KEY passed is #{request.headers['X-API-KEY']}\"\n end",
"def current_auth_api_key\n @current_auth_api_key ||= lambda do\n authenticate_knox_api_key!\n api_key\n end.call\n end",
"def get_api_key\n @api = Hash.new\n if authenticate!\n if current_user.api_key.nil?\n current_user.generate_new_api_key!\n end\n @api = {:api_key => current_user.api_key}\n else\n @api = {:error => \"The combination of login and password is invalid.\"}\n end\n respond_to do |format|\n format.json do\n render :json => @api.as_json, :callback => params[:jsoncallback]\n end\n end\n end",
"def api_key\n api_key_div.text.gsub(/API Key:/,'').gsub(/\\(create\\)/,'').gsub(/\\(delete\\)/,'').strip\n end",
"def api_key\n 'your_api_key'\nend",
"def api_key\n # First read in ENV\n return ENV['ALGOLIA_API_KEY'] if ENV['ALGOLIA_API_KEY']\n\n # Otherwise from file in source directory\n key_file = File.join(@config['source'], '_algolia_api_key')\n if File.exist?(key_file) && File.size(key_file) > 0\n return File.open(key_file).read.strip\n end\n nil\n end",
"def access_key\n Settings.cybersource.access_key\n end",
"def api_key\n # First read in ENV\n return ENV['ALGOLIA_API_KEY'] if ENV['ALGOLIA_API_KEY']\n\n # Otherwise from file in source directory\n key_file = '_algolia_api_key'\n if File.exist?(key_file) && File.size(key_file) > 0\n return File.open(key_file).read.strip\n end\n nil\n end",
"def api_key\n @api_key || ENV['OMDB_API_KEY']\n end",
"def generate_api_key\n key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12345678).to_s)[1..10]\n self.api_key = self._id.to_s + key\n end",
"def generate_api_key\n key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12345678).to_s)[1..10]\n self.api_key = self._id.to_s + key\n end",
"def key\n Net::HTTP.get(@uri.host, \"#{@uri.request_uri}key\", @uri.port)\n end",
"def generate_api_key\n generate_uuid\nend",
"def apiKey()\n return ENV['HOMEBREW_PIPELINE_API_TOKEN']\n end",
"def apikey(username, password)\n md5 = Digest::MD5.new\n digest = md5.update(password).hexdigest\n\n query = { action: 'apikey', userName: username, password: digest }\n get('apikey', query) { |x| x['apikey'] }\n end",
"def api_key; @opts[:api_key]; end",
"def weather_api_key #method for accessing weather_api_key\n\t\t@@weather_api_key\n\tend",
"def generate_api_key\n self.api_key = SecureRandom.hex(16)\n end",
"def api_key\n '' \nend",
"def google_api_key\n ENV['GOOGLE_API_KEY'] or google_config(:google_api_key)\n end",
"def api_key=(val)\n @api_key = val\n end",
"def api_key\n @@api_key || ENV['CV_API_KEY']\n end",
"def get_api_key(key, request_options = {})\n client.get(Protocol.index_key_uri(name, key), :read, request_options)\n end",
"def access_key_id\n credentials['access_key']\n end",
"def generate_api_key(id)\n response = request(:post, \"/users/#{id}/make_new_api_key.json\")\n response[\"user\"]\n end",
"def api_key\n Rails.application.secrets.google_geocode_key\n end",
"def access_key\n ENV['RANCHER_CLIENT_ID']\n end",
"def api_key\n api_key = request.headers['X-ApiKey']\n return true\n end",
"def get_access_key\n return \"AIzaSyBUKwL2ClTAaKwn1csWuOOhNgKj5kv3QeA\"\nend",
"def generate_api_key!\n\t\t@api_key = Digest::SHA1.hexdigest((Time.now.to_f + rand(100) * rand()).to_s) \n\tend",
"def access_key\n credentials['access_key']\n end",
"def gen_api_key\n u = UUID.new\n self.api_key = u.generate\n end",
"def api_key=(_arg0); end",
"def api_key=(_arg0); end",
"def api_key=(_arg0); end",
"def generate_api_key\n digest = Digest::SHA2.new(512)\n # generate a unique token\n unique_seed = SecureRandom.hex(20)\n digest.update(\"#{unique_seed} SECRET! #{Time.current.to_f}\").to_s\n end",
"def generate_api_key\n digest = Digest::SHA2.new(512)\n # generate a unique token\n unique_seed = SecureRandom.hex(20)\n digest.update(\"#{unique_seed} SECRET! #{Time.current.to_f}\").to_s\n end",
"def secretkey(apikey)\n get 'secretkey', {apikey: apikey} { |x| x['secretkey'] }\n end",
"def get_api_key_code(storage_type)\n case storage_type\n when :environment\n \"ENV['TIMBER_API_KEY']\"\n when :inline\n \"'#{api.api_key}'\"\n else\n raise ArgumentError.new(\"API key storage type not recognized! \" \\\n \"#{storage_type.inspect}\")\n end\n end",
"def api_key(value)\n @api_key = value unless value.nil?\n @headers['api-key'] = @api_key\n @api_key\n end",
"def api_key\n ENV[\"API_KEY\"] || raise(StandardError, \"Please provide a Quandl API key via the env var: API_KEY\")\n end",
"def api_key(sending_object = nil, opts = {})\n return opts[:api_key] if opts[:api_key]\n return sending_object[:api_key] if sending_object && sending_object[:api_key]\n\n Settings.default.web_object.api_key\nend",
"def api_key=(key)\n @@api_key = key\n end",
"def generate_api_key(id)\n request(:post, \"/users/#{id}/make_new_api_key.json\")\n end",
"def get_api_key(key_id, opts = {})\n @transporter.read(:GET, path_encode('/1/keys/%s', key_id), {}, opts)\n end",
"def facebook_api_key\n raise APIKeyNeededException\n end",
"def facebook_api_key\n raise APIKeyNeededException\n end",
"def apikey(site_url, username, password) \n site_url = CGI.escape(site_url)\n self.class.basic_auth username, password\n response = CreateSend.get(\"/apikey.json?SiteUrl=#{site_url}\")\n # Revert basic_auth to use @@api_key, 'x'\n self.class.basic_auth @@api_key, 'x'\n Hashie::Mash.new(response)\n end",
"def inspect\n \"API key hidden for protection. Using the target URL #{@base_url}\"\n end",
"def api_key_header\n {'X-API-KEY' => 'some_api_key'}\n end",
"def retrieve_api_key(token)\n raise ConfigurationError, \"You must have a provider key to retrieve API keys\" if provider_key.nil?\n perform(\"retrieve/apikey\", { :providerkey => provider_key, :token => token }, :get, ApiKey)\n end",
"def key(api, opts={})\n time = Exchange::Helper.assure_time(opts[:at], :default => :now)\n [ 'exchange',\n api.to_s, \n time.year.to_s, \n time.yday.to_s, \n Exchange::Configuration.update == :hourly ? time.hour.to_s : nil,\n *(opts[:key_for] || [])\n ].compact.join('_')\n end",
"def set_api_key\n @api_key = ApiKey.find(params[:id])\n end",
"def set_api_key\n @api_key = ApiKey.find(params[:id])\n end",
"def set_api_key\n @api_key = ApiKey.find(params[:id])\n end",
"def api_keys\n rest_query(:api_key)\n end",
"def generate_api_key\n @user.api_key = BCrypt::Engine.generate_salt\n end",
"def api_id\n ENV['UNLEASHED_API_ID']\n end",
"def show_api_key\n if @current_user.api_key != nil\n # If the user already has an api key, return it\n render json: { api_key: @current_user.api_key }, status: :ok\n else\n head :not_found\n end\n end",
"def key_info\n authenticated_post(\"key_info\").body\n end",
"def api_key_param_name\n nil\n end",
"def app_key \n 'app-id-9bb5f1c77f0df722a9b1bc650a41988a'\n end",
"def env_var_to_hold_api_client_primary_key\n @env_var_to_hold_api_client_primary_key.to_s\n end",
"def toggl_api_key\n toggl_source[\"access_token\"] #|| toggl_source -> Necessary?\n end",
"def api_key=(key)\n\t\t\t\t\t@@api_key = key\n\t\t\t\tend",
"def generate_api_key\n api_key = new_token\n if AppSettings[:authentication][:key_based]\n Rails.cache.write( User.cached_api_key(api_key), self.authentication_token,\n expires_in: AppSettings[:authentication][:session_expiry] )\n api_key\n else\n secure_api_key = secured_key(api_key)\n update_hash = {}\n update_hash[:activation_digest] = User.digest(User.cached_api_key(secure_api_key))\n update_hash[:activated_at] = Time.now if self.activated_at < Time.now - 24.hours\n self.update(update_hash)\n secure_api_key\n end\n end",
"def set_api_key\n\t\tself.api_key = ApiKey.create()\n\tend",
"def client_key\n @client_key ||= CredentialCache.cache(cache_key(:client_key)) do\n hmac(salted_password, 'Client Key')\n end\n end",
"def fetch_api_key(username, password, opts = {})\n data, _status_code, _headers = fetch_api_key_with_http_info(username, password, opts)\n data\n end",
"def generate_api_key\n loop do\n token = SecureRandom.base64.tr('+/=', 'Qrt')\n break token unless self.class.exists?(api_key: token)\n end\n end",
"def generate_api_key(length = 20)\n self.api_secret_key = SecureRandom.hex(length)\n end"
] | [
"0.8371249",
"0.83074266",
"0.81852305",
"0.8054933",
"0.8054933",
"0.8046503",
"0.8010114",
"0.7981128",
"0.7968959",
"0.7968959",
"0.79372025",
"0.7876118",
"0.7792502",
"0.77100605",
"0.77100605",
"0.76793605",
"0.7674456",
"0.7651613",
"0.7636844",
"0.757416",
"0.7506866",
"0.7492784",
"0.7486742",
"0.74313706",
"0.7415768",
"0.7412421",
"0.741226",
"0.739803",
"0.7382969",
"0.7362519",
"0.73476684",
"0.7291405",
"0.721976",
"0.7209753",
"0.71912175",
"0.719042",
"0.7184577",
"0.718383",
"0.7148404",
"0.7148404",
"0.714223",
"0.71371",
"0.71102816",
"0.71098584",
"0.707992",
"0.70628625",
"0.70566255",
"0.7040592",
"0.7028594",
"0.700396",
"0.6999454",
"0.69846225",
"0.6973891",
"0.69705194",
"0.696925",
"0.69648147",
"0.6951249",
"0.69431305",
"0.6930911",
"0.6927914",
"0.6912537",
"0.69097346",
"0.69097346",
"0.69097346",
"0.6907029",
"0.6907029",
"0.6808974",
"0.6795375",
"0.67912024",
"0.6788765",
"0.67856354",
"0.6782727",
"0.6781331",
"0.6757585",
"0.6742806",
"0.6742806",
"0.6735243",
"0.67258495",
"0.6711331",
"0.6705841",
"0.6704002",
"0.6701883",
"0.6701883",
"0.6701883",
"0.6676109",
"0.6659943",
"0.6659793",
"0.66564834",
"0.6649552",
"0.6647399",
"0.6638951",
"0.6611446",
"0.6607699",
"0.660526",
"0.6600803",
"0.65982574",
"0.6581499",
"0.6580031",
"0.65701383",
"0.65582085"
] | 0.83176166 | 1 |
This returns the API version being used for calls | def api_version
@version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_version\n request('getAPIVersion')\n end",
"def version\n raise InvalidRequestException unless defined?(API_VERSION)\n API_VERSION\n end",
"def get_api_version()\n return API_VERSION\n end",
"def get_api_version\n _make_request(:types)['version'].to_s\n end",
"def api_version\n self.class.get('/api')['api_ver']\n end",
"def get_api_version\n :v201502\n end",
"def get_api_version()\n return :v201502\n end",
"def version\n api_execute('/version', :get).body\n end",
"def api_version\n Gandi.call('version.info')['api_version']\n end",
"def get_api_version\n response = send_api_request(:index)\n response[:returncode] ? response[:version].to_s : \"\"\n end",
"def api_version\n @api_version || :latest\n end",
"def api_version\n @api_version ||= begin\n pool = self.pool.get_all[0]\n host = self.pool.get_master(pool)\n major = self.host.get_API_version_major(host)\n minor = self.host.get_API_version_minor(host)\n \"#{major}.#{minor}\"\n end\n end",
"def API_version(options={})\n return \"#{@major}.#{@minor}\"\n end",
"def get_api_version\n response = send_api_request(:index)\n if response[:returncode]\n response[:version].to_s\n else\n \"\"\n end\n end",
"def current_api_version\n JSON.parse(get('/api').to_s)['currentVersion'] rescue 1\n end",
"def api_version\n self.class.api_version\n end",
"def api_version\n @api_version || \"2011-02-01\"\n end",
"def api_version\n @api_version ||= \"v4.2\"\n end",
"def api_version\n self.class.superclass.name.to_s.split('::').second.sub('V', '').to_i\n end",
"def version; env['api.version'] end",
"def appliance_api_version\n options = { 'Content-Type' => :none, 'X-API-Version' => :none, 'auth' => :none }\n response = rest_api(:get, '/rest/version', options)\n version = response_handler(response)['currentVersion']\n raise ConnectionError, \"Couldn't get API version\" unless version\n version = version.to_i if version.class != Integer\n version\n rescue ConnectionError\n @logger.warn \"Failed to get OneView max api version. Using default (#{OneviewSDK::DEFAULT_API_VERSION})\"\n OneviewSDK::DEFAULT_API_VERSION\n end",
"def get_version\n request('getVersion')\n end",
"def api_version\n 'v2'\n end",
"def get_version\n prepare\n @api.get_api_version\n end",
"def formatted_version\n self.api_version.presence || DEFAULT_API_VERSION\n end",
"def version\n response = get('/getVersion', {}, false)\n ApiVersion.new(response.body['version'], response.body['builddate'])\n end",
"def get_api_version_string(api_version)\n \"?api-version=#{api_version}\"\n end",
"def version\n self.class.get(\"/get/version\")\n end",
"def api_version; config[:api_version]; end",
"def version\n endpoint.config.version\n end",
"def to_s\n self.api_version\n end",
"def api_version\n :v2\n end",
"def best_request_version\n klass = get_class_for(:max_server_version)\n klass.minimum_api_version.to_s\n end",
"def last_api_version\n @last_api_version\nend",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def getVersion()\n return \"client \" + CLIENT_VERSION + \", API v2, converter \" + @helper.getConverterVersion()\n end",
"def appliance_i3s_api_version\n options = { 'Content-Type' => :none, 'X-API-Version' => :none, 'auth' => :none }\n response = rest_api(:get, '/rest/version', options)\n version = response_handler(response)['currentVersion']\n raise ConnectionError, \"Couldn't get API version\" unless version\n version = version.to_i if version.class != Integer\n version\n rescue ConnectionError\n @logger.warn \"Failed to get Image Streamer max api version. Using default (#{OneviewSDK::ImageStreamer::DEFAULT_API_VERSION})\"\n OneviewSDK::ImageStreamer::DEFAULT_API_VERSION\n end",
"def swagger_apiVersion\n if app.respond_to?(:swagger_apiVersion)\n app.swagger_apiVersion\n else\n '0.1.0'\n end\n end",
"def version\n @version_obj ||= fetcher.get(Fastly::Version, service_id, version_number)\n end",
"def version\n @version_obj ||= fetcher.get(Fastly::Version, service_id, version_number)\n end",
"def api_version\n dataset_version ? dataset_version.version : nil\n end",
"def current_version\n @retries = 1\n begin\n @api_client.get_entity_request(@id)\n rescue StandardError => e\n # Periodically, these requests will fail with \"Unknown mime type: text/plain\"\n if @retries < 3\n @retries += 1\n current_version\n else\n puts e.inspect\n puts e.backtrace\n end\n end\n end",
"def http_major; end",
"def version\n return @discovery_document['version']\n end",
"def version\n VERSION\n end",
"def get_version\n\t\tend",
"def engine_version\n endpoint.engine_version\n end",
"def version\n 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 return @version\n end",
"def version\n @version\n end",
"def http_version\n \"%d.%d\" % [self[:http_major], self[:http_minor]]\n end",
"def api_version_negotiated\n client_api_versions.reverse. # choose the last API version listed\n detect { |v| @server_api_versions.include? v }\n end",
"def api_version\n JIRA_API_VERSION\n end",
"def client_version\n ClientVersion\n end",
"def get_version()\n\t\tend",
"def version\n VERSION\n end",
"def version\n VERSION\n end",
"def version\n VERSION\n end",
"def version\n @context[:version]\n end",
"def current_version\n @version\n end",
"def server_version\n request(auth: false, expects: 200)['version']\n rescue => ex\n error { \"Server version exception\" }\n error { ex }\n nil\n end",
"def http_version\n @parser.http_version\n end",
"def get_version()\n # TODO Nothing implemented yet for GetVersion call\n raise OMF::SFA::AM::Rest::BadRequestException.new \"getversion NOT YET IMPLEMENTED\"\n end",
"def version\n return last_version if versionable?\n version_number\n end",
"def version\n ret = @client.call('Bugzilla.version')\n handle_faults(ret)\n ret['version']\n end",
"def get_version()\n\t\t\tkparams = {}\n\t\t\tclient.queue_service_action_call('system', 'getVersion', 'string', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend",
"def version_number\n @version\n end",
"def apiversion\n @attributes.fetch('apiversion', nil)\n end",
"def version\n @grpc.attributes[\"x-goog-version\"]\n end",
"def protocol\n response = get(:protocol)\n version = response.body\n version.to_i rescue 0\n end",
"def version\n (version_from_class.to_f / 10).to_s\n end",
"def version\n 1\n end",
"def best_api_version\n @api_version ||= begin\n logger.trace(\"Mixin EC2: Fetching http://#{EC2_METADATA_ADDR}/ to determine the latest supported metadata release\")\n response = http_client.get(\"/\", { 'X-aws-ec2-metadata-token': v2_token })\n if response.code == \"404\"\n logger.trace(\"Mixin EC2: Received HTTP 404 from metadata server while determining API version, assuming 'latest'\")\n return \"latest\"\n elsif response.code != \"200\"\n raise \"Mixin EC2: Unable to determine EC2 metadata version (returned #{response.code} response)\"\n end\n # NOTE: Sorting the list of versions may have unintended consequences in\n # non-EC2 environments. It appears to be safe in EC2 as of 2013-04-12.\n versions = response.body.split(\"\\n\").sort\n until versions.empty? || EC2_SUPPORTED_VERSIONS.include?(versions.last)\n pv = versions.pop\n logger.trace(\"Mixin EC2: EC2 lists metadata version: #{pv} not yet supported by Ohai\") unless pv == \"latest\"\n end\n logger.trace(\"Mixin EC2: Latest supported EC2 metadata version: #{versions.last}\")\n if versions.empty?\n raise \"Mixin EC2: Unable to determine EC2 metadata version (no supported entries found)\"\n end\n\n versions.last\n end\n end",
"def requested_access_token_version\n return @requested_access_token_version\n end",
"def version\n @version ||= __determine_version\n end",
"def version\n LOG_STAT()\n id = id_gen()\n LOG_CALL(id, true, __method__)\n defer { LOG_CALL(id, false, 'version') }\n return VERSION\n end",
"def version\n resolved_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 getVersion\r\n\t\t\t\t\treturn @version\r\n\t\t\t\tend",
"def version\n @version_helper.to_s\n end",
"def version\n @version_helper.to_s\n end",
"def version\n \"0.2.0\"\n end",
"def version\n name.split('_')[1]\n end",
"def version\n fetch('vehicle.version')\n end",
"def version\n send_command(:getinfo, 'version')\n reply = read_reply.split('=').last\n read_reply # skip \"250 OK\"\n reply\n end",
"def version_number\n return @version_number\n end",
"def version\n 1\n end"
] | [
"0.88588905",
"0.8724628",
"0.85719347",
"0.8535282",
"0.842111",
"0.83159876",
"0.8304739",
"0.82623535",
"0.8196698",
"0.81932366",
"0.81587267",
"0.8142436",
"0.81376165",
"0.8110708",
"0.8070393",
"0.79920065",
"0.79788274",
"0.7851303",
"0.7807265",
"0.7783084",
"0.77316475",
"0.7716565",
"0.7662464",
"0.7640482",
"0.76127",
"0.7597904",
"0.75838786",
"0.74819416",
"0.7447769",
"0.74449474",
"0.7408858",
"0.7396006",
"0.7353818",
"0.73482424",
"0.7332317",
"0.7332317",
"0.7332317",
"0.7332317",
"0.7332317",
"0.7332317",
"0.7332317",
"0.7195807",
"0.71640056",
"0.7103873",
"0.7103873",
"0.7066236",
"0.6998513",
"0.69967294",
"0.6991111",
"0.69876593",
"0.6978267",
"0.6977067",
"0.69522965",
"0.6951295",
"0.6951295",
"0.6951295",
"0.6951295",
"0.6951295",
"0.6951295",
"0.6951295",
"0.6951295",
"0.6951295",
"0.6928918",
"0.6923878",
"0.69107085",
"0.6897319",
"0.6886692",
"0.6885763",
"0.68722725",
"0.68722725",
"0.68722725",
"0.68576175",
"0.6848698",
"0.6828496",
"0.6816365",
"0.6812188",
"0.6805247",
"0.6798766",
"0.6796739",
"0.67782223",
"0.6774319",
"0.6769096",
"0.67612183",
"0.6760247",
"0.6749774",
"0.67483634",
"0.6739814",
"0.67100036",
"0.6686145",
"0.6683101",
"0.6681578",
"0.66798645",
"0.6669202",
"0.6669202",
"0.66662747",
"0.66625667",
"0.66558063",
"0.66532344",
"0.6650626",
"0.6650331"
] | 0.8421387 | 4 |
This returns whether or not we've been initialized yet | def initialized?
@initialized || false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialized?\n @initialized ||= false\n end",
"def initialized?\n @initialized ||= false\n end",
"def initialized?\n end",
"def initialized?\n !!@initialized\n end",
"def init?\n @init\n end",
"def initialized?\n !@data.nil?\n end",
"def initialized\n @initialized ||= false\n end",
"def initialized?\n @state == STATE_INITIALIZED\n end",
"def initted?\n @initted\n end",
"def initted?\n @initted\n end",
"def init?\n status == :init\n end",
"def is_initialized?; @is_initialized; end",
"def initialized?\n defined?(@state) && @state\n end",
"def initialized\n @initialized\n end",
"def initialized?; end",
"def initialized?; end",
"def initialized?; end",
"def initialized?; end",
"def initialized?\n !(version.zero?)\n end",
"def initialized?\n !!get_main_hub\n end",
"def initialized?\n raise RuntimeError, \"You probably forgot to call #content or give the :from option when instantiating the object.\" if @content.nil?\n @content.initialized?\n end",
"def initiative_started?\n find_init.present?\n end",
"def initialized?\n server.present? && username.present? && api_token.present?\n end",
"def _ready?\n true\n end",
"def ready?\n return _ready?\n rescue\n return false\n end",
"def initialized?\r\n if ENV[\"RAILS_ENV\"] == \"test\" || !User.table_exists? || $setup_disabled \r\n return false\r\n else \r\n $tmp_env = ENV[\"RAILS_ENV\"] || \"development\"\r\n return true\r\n end \r\n end",
"def loaded?\n @loaded ||= false\n end",
"def loaded?\n @loaded ||= false\n end",
"def loaded?\n not @hash.nil?\n end",
"def loaded?\n not @hash.nil?\n end",
"def initialize_state?(object); end",
"def ready?\n raise 'Not implemented!'\n end",
"def initialized?\n\t\t\t@movies_dataset.first\n\t\tend",
"def ready?\n @ready == true\n end",
"def ready?\n\t\t\t\t\tfalse\n\t\t\t\tend",
"def loaded?\n !!@loaded\n end",
"def is_ready?\n return @ready\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?\n !!@loaded\n end",
"def ready?\n !!defined? @result\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n !!@loaded\n end",
"def loaded?\n return @loaded\n end",
"def loaded?\n true\n end",
"def ready?\n true\n end",
"def loaded?\n @loaded\n end",
"def loaded?\n @loaded\n end",
"def incomplete?\n running? || pending? || initialized?\n end",
"def ready?\n @is_ready\n end",
"def ready?\n raise NotImplementedError\n end",
"def loaded?\n !!@data\n end",
"def init\n @state = :initializing if @state == :created\n true\n end",
"def defined?\n false\n end",
"def ready?\n\t\t$stderr.puts \"#{@name}: ready? not overridden!\"\n\tend",
"def loaded?\n !!self.loaded\n end",
"def ready?\n !@needs_reset && @start && @end\n end",
"def loaded?\n self.response_data.present?\n end",
"def loaded?\n !! @data\n end",
"def loaded?\n !! @data\n end",
"def previously_defined?\n @previously_defined\n end",
"def loaded?\n @data\n end",
"def loaded?\n @data\n end",
"def ready?\n raise(\"Called #{self.class.name}.ready?\")\n end",
"def engine_initialized?\n\t\t\t\t\tsuper && sass_functions_initialized?\n\t\t\t\tend",
"def loaded?\n\t\treturn @entry ? true : false\n\tend",
"def shouldReInitialize\n return(false)\n end",
"def loading?\n !load_stack.empty?\n end",
"def nil?\n @nil or (not @loaded and load.nil?)\n end",
"def usable?\n false\n end",
"def instantiated\n return !component_id.nil? && component_id != 0\n end",
"def loaded?\n !@all.nil?\n end",
"def nil?\n loaded_members.blank?\n end",
"def ready?\n state == :READY\n end",
"def ready?\n state == :READY\n end",
"def ready?\n state == :READY\n end",
"def ready?\n state == :READY\n end",
"def ready?\n state == :READY\n end",
"def uninitialized?; end",
"def is_game_time_initialized()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.Timer_is_game_time_initialized(@handle.ptr)\n result\n end",
"def setup?\n @setup\n end",
"def reader_ready?\n @session.reader_ready?\n end",
"def ready?\n !@values.any? { |observable, value| value.nil? }\n end",
"def ready?\n `#@native.readyState === \"complete\" || #@native.readyState === \"interactive\"`\n end",
"def instance_variable_defined?(p0) end",
"def fully_instanciated?\n if arguments.static?\n @fully_instanciated ||= list_unset_arguments.empty?\n else\n list_unset_arguments.empty?\n end\n end",
"def doc_ready?\n @doc_ready\n end",
"def ready?\n end",
"def ready?\n !@values.any? { |observable, value| value.nil? }\n end",
"def ready?\n self.state == :ready\n end",
"def set_yet?\n !!@resource_lock.synchronize { defined? @resource }\n end",
"def is_loaded\n\t\tend",
"def fully_instanciated?\n if arguments.static?\n @fully_instanciated ||= list_unset_arguments.empty?\n else\n list_unset_arguments.empty?\n end\n\tend",
"def metadata_loaded?\n @metadata.to_bool\n end",
"def ready?\n true\n end",
"def started?\n self.class.data_attributes.any?{|a| send(:\"#{a}?\")}\n end"
] | [
"0.8766324",
"0.8766324",
"0.86628884",
"0.8427186",
"0.8331638",
"0.82875085",
"0.8215806",
"0.81125915",
"0.80918264",
"0.80918264",
"0.7978551",
"0.7940297",
"0.77771693",
"0.7610409",
"0.75859493",
"0.75859493",
"0.75859493",
"0.75859493",
"0.7559332",
"0.7464577",
"0.7322176",
"0.7173548",
"0.7144171",
"0.71427226",
"0.7138189",
"0.71062535",
"0.70005715",
"0.6981766",
"0.6918514",
"0.6918514",
"0.6889323",
"0.6883255",
"0.68668175",
"0.68216074",
"0.680651",
"0.67989075",
"0.6791323",
"0.6790219",
"0.6790219",
"0.6782023",
"0.67681104",
"0.67681104",
"0.67681104",
"0.67681104",
"0.67681104",
"0.67681104",
"0.67680436",
"0.6759211",
"0.67542154",
"0.673229",
"0.6709053",
"0.6709053",
"0.66971964",
"0.6671601",
"0.6648032",
"0.66467625",
"0.6643366",
"0.6634005",
"0.6616001",
"0.6611664",
"0.65859914",
"0.6580991",
"0.6579201",
"0.6579201",
"0.6557202",
"0.6554795",
"0.6554795",
"0.6534149",
"0.6522602",
"0.6518835",
"0.6509661",
"0.6507665",
"0.6500842",
"0.646743",
"0.64673746",
"0.64259154",
"0.6424379",
"0.64156264",
"0.64156264",
"0.64156264",
"0.64156264",
"0.64156264",
"0.64108235",
"0.6409564",
"0.6406072",
"0.6399255",
"0.6396102",
"0.6390121",
"0.6383763",
"0.637818",
"0.6377108",
"0.63650954",
"0.63610166",
"0.6359869",
"0.6359196",
"0.6356892",
"0.63413787",
"0.63196015",
"0.62974536",
"0.6295118"
] | 0.8758801 | 2 |
This authenticates with Rackspace and returns the information necessary to make subsequent authenticated calls to the API | def authenticate
raise Rackspace::NotInitialized unless self.initialized?
headers = RestClient::Request.execute(:method => :get, :url => "#{AUTH_URL}/#{self.api_version}", :headers => {"X-Auth-User" => self.api_user, "X-Auth-Key" => self.api_key}, :raw_response => true).headers
{:auth_token => headers[:x_auth_token], :storage_url => headers[:x_storage_url], :server_management_url => headers[:x_server_management_url], :cdn_management_url => headers[:x_cdn_management_url]}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate\n # :x_amee_source = \"X-AMEE-Source\".to_sym\n request = Typhoeus::Request.new(\"#{protocol}#{@server}/auth/signIn\", \n :method => \"post\",\n :verbose => DEBUG,\n :headers => {\n :Accept => content_type(:xml),\n },\n :body => form_encode(:username=>@username, :password=>@password)\n )\n\n hydra.queue(request)\n hydra.run\n response = request.response\n\n @auth_token = response.headers_hash['AuthToken']\n d {request.url}\n d {response.code}\n d {@auth_token}\n\n connection_failed if response.code == 0\n\n unless authenticated?\n raise AMEE::AuthFailed.new(\"Authentication failed. Please check your username and password. (tried #{@username},#{@password})\")\n end\n # Detect API version\n if response.body.is_json?\n @version = JSON.parse(response.body)[\"user\"][\"apiVersion\"].to_f\n elsif response.body.is_xml?\n @version = REXML::Document.new(response.body).elements['Resources'].elements['SignInResource'].elements['User'].elements['ApiVersion'].text.to_f\n else\n @version = 1.0\n end\n end",
"def login_0\n\n #definde needed header\n headers = {'Authorization' => \"Basic \" + @base_user_string}\n\n #Login\n response = request({:method => \"POST\", :url => @host + \"login\", :headers => headers})\n\n #Get organisation link\n @org_link = parse_content(response.body, '//Org')[0].attribute('href').to_s\n\n #Get authentication header key\n @auth_key = response.headers[:x_vcloud_authorization]\n\n end",
"def basic_auth\n {\n username: @username,\n password: @password\n }\n end",
"def authenticate\n res = HTTParty.post(\n authenticate_url,\n body: body.to_json,\n headers: { 'Content-Type' => 'application/json' }\n )\n\n check_for_error(res)\n\n res.parsed_response\n end",
"def authenticate\n response = post('login')\n @access_token = response['access-token']\n @client_id = response['client-id']\n end",
"def http_auth_hash; end",
"def authenticate\n token = CrownAuthenticate.new().token\nend",
"def authentication\n {:username => @username, :password => @password}\n end",
"def auth\n {}\n end",
"def authenticate\n json_response(\n auth_token: AuthenticateUser.new(\n auth_params[:username],\n auth_params[:password]\n ).call\n )\n end",
"def authenticate\n raise 'Sierra API key not present' unless ENV['SIERRA_API_KEY']\n raise 'Sierra API secret not present' unless ENV['SIERRA_API_SECRET']\n\n if authentication_expired?\n credentials = Base64.strict_encode64(ENV['SIERRA_API_KEY'] + ':' + ENV['SIERRA_API_SECRET'])\n # throw error if api key or secret key is missing.\n\n response = Faraday.post(API_BASE + '/token') do |req|\n req.headers['Host'] = 'catalog-lib.dartmouth.edu'\n req.headers['Authorization'] = \"Basic #{credentials}\"\n req.headers['Content-Type'] = 'application/x-www-form-urlencoded'\n req.body { 'grant_type=client_credentials' }\n end\n body = JSON.parse(response.body)\n\n # if response is sucessful\n @access_token = body['access_token']\n @expires_in = Time.now + (body['expires_in'] - 10)\n # return true\n # else return false\n\n end\n end",
"def authenticate\n env = Figaro.env\n\n head :unauthorized unless auth_configured?(env)\n\n authenticate_or_request_with_http_basic do |username, password|\n # This comparison uses & so that it doesn't short circuit and\n # uses `secure_compare` so that length information\n # isn't leaked.\n ActiveSupport::SecurityUtils.secure_compare(\n username, env.twilio_http_basic_auth_username\n ) & ActiveSupport::SecurityUtils.secure_compare(\n password, env.twilio_http_basic_auth_password\n )\n end\n end",
"def authenticate(email, api)\nuri = URI('https://device.pcloudy.com/api/access')\n\nNet::HTTP.start(uri.host, uri.port,\n :use_ssl => uri.scheme == 'https', \n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n request = Net::HTTP::Get.new uri.request_uri\n request.basic_auth email,api\n response = http.request request # Net::HTTPResponse object\n #puts response\n #puts response.body\n authresponce = JSON.parse(response.body)\n token = authresponce[\"result\"][\"token\"]\n puts token\n return token\nend \nend",
"def authenticate\n @apikey = request.headers[:apikey]\n if @apikey==nil || @apikey!= APIKEY\n json_response={\n error: 'autorization error'\n }\n respond_with json_response, location: nil\n end\n end",
"def auth\n { \"username\" => @username }\n end",
"def authenticate\n @shoonga = authenticate_or_request_with_http_basic do |username, password|\n username == \"4vght\" && password == \"we8vds\"\n end\nend",
"def authenticate_with_basic_auth\n name, token = ActionController::HttpAuthentication::Basic.user_name_and_password(request)\n @api_client = ApiClient.find_by(name: name)\n\n render(json: { errors: [{ detail: \"Access Denied\" }] }, status: 401) unless valid_key(token)\n end",
"def Authentication\n call('', '')\n end",
"def authenticate_api!\n Rails.logger.info(\"Enter Authenticate Api\")\n \n # just to test we are using HTTP_HOST in test mode as HTTP_ORIGIN cant be set\n Rails.env == \"test\" ? origin = request.env['HTTP_HOST'] : origin = request.env['HTTP_ORIGIN']\n\n if !params[\"token\"].blank? and origin.blank? # API Access\n\n account_id = AccountsCache.access_token(params[\"token\"])\n\n raise et(\"application.unauthorized\") if account_id.blank?\n \n # set account_id in params\n if params[:controller] == \"accounts\" and current_account\n params[:id] = current_account._id.to_s if params[:id].blank?\n else\n params[:account_id] = current_account._id.to_s if params[:account_id].blank?\n end\n\n # set the request type\n params[:request_type] = AppConstants.request_type_api\n\n # mark already authenticated\n set_authenticated\n\n # make api request synchronous as of now\n make_sync_request\n end\n rescue => e \n Rails.logger.error(\"**** ERROR **** #{er(e)}\")\n head :unauthorized\n end",
"def authenticate!\n error!(\"401 Unauthorized\", 401) unless check_auth_token \n end",
"def auth\n {:basic_auth => {:username => id, :password => password}}\n end",
"def authenticate!\n\t\t@current_user = AuthorizeApiRequest.call(request.headers).result\n\t\t# If unauthorized return an error to the front end\n\t\trender json: {error: 'Not Authorized'}, status: 401 unless @current_user\n\tend",
"def auth\n if configuration.api_key\n { :key => configuration.api_key, :sign => 'true' }\n elsif configuration.access_token\n { :access_token => configuration.access_token }\n end\n end",
"def authenticate\n RestClient::Request.execute(:method => :post,\n :url => @oauth_request,\n :headers => {\n \"Content-Type\" => \"application/json; charset=UTF8\",\n \"X-Accept\" => \"application/json\"\n },\n :payload => {\n :consumer_key => ENV['POCKET_CONSUMER_KEY'],\n :redirect_uri => ENV['REDIRECT_URI']\n })\n end",
"def authenticate\n uri = create_uri(\"#{@server_url}api/authenticate\")\n h = Net::HTTP.new uri.host, uri.port\n req = Net::HTTP::Get.new uri.request_uri\n res = h.request req\n @digest_auth = Net::HTTP::DigestAuth.new\n @header = res['www-authenticate']\n unless @header\n raise 'No [www-authenticate] header in the server\\'s response'\n end\n end",
"def authenticate\n end",
"def api_auth\n # output the APIkey from the header\n # puts request.headers[\"X-APIkey\"];\n creator = Creator.find_by(creator: request.headers[:creator])\n if creator && creator.authenticate(request.headers[:password])\n render json: { auth_token: encodeJWT(creator), id: creator.id}\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end",
"def auth\n build_response(\"token\") do\n connection.post do |req|\n req.headers.delete(\"Authorization\")\n req.url \"auth/\"\n req.body = { username: username, password: password }.to_json\n end\n end\n end",
"def authenticate\n authenticate_or_request_with_http_basic do |username, password|\n self.username == username && self.password == password\n end\n end",
"def auth\n end",
"def auth\n end",
"def authentication_headers\n {\n \"authenticate\" => {\n \"username\" => @username,\n \"apiKey\" => @api_key\n }\n }\n end",
"def authenticate_with_api_key!\n \t\t@current_bearer = authenticate_or_request_with_http_token &method(:authenticator)\n \tend",
"def authenticate!\n # if the authentication header is an acceptible value\n if @env['HTTP_X_MY_API'] == 'foobar'\n user = { :id => 1, :name => \"some user\" }\n # warden doesn't care what the user is, so long as it's not nil.\n success! user, \"success\"\n end\n end",
"def auth(key)\n\t\t#TODO\n\t\t#return response\n\t\tstatus 201\n\tend",
"def authenticate\n authenticate_or_request_with_http_basic do |username, password|\n username == ENV['USERNAMEV'] && password == ENV['PASSWORDV'] \n end \n end",
"def auth\n @auth ||= Savon.client(\n wsdl: AUTH_WSDL,\n headers: { 'Authorization' => \"Basic #{@auth_code}\", 'SOAPAction' => [''] },\n env_namespace: :soapenv,\n logger:,\n log: true,\n log_level: @log_level,\n pretty_print_xml: true\n )\n end",
"def authenticate_with_api_key\n\t @current_bearer = authenticate_with_http_token &method(:authenticator)\n\t end",
"def authenticate\n authenticate_or_request_with_http_basic do |user_name, password|\n # Change these to username and password required\n user_name == \"shitlister\" && password == \"letmein\"\n end\n end",
"def authenticate!\n response = connection.post '/oauth2/v1/tokens/bearer' do |req|\n req.headers['Authorization'] = 'Basic ' + Base64.strict_encode64(@options[:client_id] + \":\" + @options[:client_secret])\n req.body = encode_www_form(params)\n end\n\n if response.status >= 500\n raise QuickbooksOnlineRuby::ServerError, error_message(response)\n elsif response.status != 200\n raise QuickbooksOnlineRuby::AuthenticationError, error_message(response)\n end\n\n @options[:access_token] = response.body['access_token']\n @options[:refresh_token] = response.body['refresh_token']\n\n if @options[:authentication_callback]\n @options[:authentication_callback].call(response.body)\n end\n\n response.body\n end",
"def authenticate\n\t\tauth_token =\n\t\t\tAuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n\t\tjson_response(auth_token: auth_token)\n\tend",
"def get_rest_authentication()\n reader = CSV.open('keys/sf_key.csv')\n client_id = reader.shift[0]\n client_secret = reader.shift[0]\n username = reader.shift[0]\n password = reader.shift[0]\n auth_payload = \"grant_type=password&client_id=#{client_id}\" \\\n \"&client_secret=#{client_secret}\" \\\n \"&username=#{username}&password=#{password}\"\n params = {:accept => 'application/json'}\n @auth_response = RestClient.post $oauth_token_endpoint, auth_payload, params\n auth_json = JSON.parse(@auth_response)\n auth_vals = {\"access_token\" => auth_json[\"access_token\"],\n \"instance_url\" => auth_json[\"instance_url\"]}\n end",
"def authenticate(uri)\n request = Net::HTTP::Get.new(uri)\n request['Accept'] = 'application/json'\n request['Authorization'] = \"Bearer #{@session_token}\"\n request\n end",
"def authenticate\n authenticate_or_request_with_http_basic do |username, password|\n self.username == username && self.password == password\n end\n end",
"def authenticate_request\n auth_header_token = request.headers[\"Authorization\"]\n @current_user = AuthorizeApiRequest.new(auth_header_token).call\n render json: { error: \"Not Authorized\" }, status: 401 unless @current_user\n end",
"def authenticate\n authed = true\n if(resource.respond_to?(:authenticate, true))\n authed = false\n uname = nil\n password = nil\n if(request.env['HTTP_AUTHORIZATION'])\n auth = Rack::Auth::Basic::Request.new(request.env)\n if(auth.basic? && auth.credentials)\n uname = auth.credentials[0]\n password = auth.credentials[1]\n end\n end\n authed = resource.send(:authenticate, uname, password)\n end\n raise Unauthorized unless authed\n end",
"def authenticate!\n response = self.AuthenticateUser(\n { :username => config[:username], :password => config[:password] },\n :is_authenticate => true,\n :allow_reauthenticate => false)\n\n auth_data = {\n :retailer_guid => response['RetailerGuid'],\n :authenticated => response['Authenticated'],\n :token => response['Token'],\n :ics_user_id => response['ICSUserID']\n }\n\n if !auth_data[:authenticated]\n raise AuthenticationError, 'authentication failed'\n end\n\n self.retailer_guid = auth_data[:retailer_guid]\n\n self.auth_header = {\n \"wsdl:AuthenticationResult\" => {\n \"wsdl:RetailerGuid\" => auth_data[:retailer_guid],\n \"wsdl:Authenticated\" => auth_data[:authenticated],\n \"wsdl:Token\" => auth_data[:token],\n \"wsdl:ICSUserID\" => auth_data[:ics_user_id],\n }\n }\n\n @authenticated = true\n end",
"def credentials\n authenticating_with_api? ? {:api_key => api_key} : super\n end",
"def auth\n StockQuote::Stock.new(api_key: 'pk_8dd852fe4adb468dbee87c0459e0b83a')\n end",
"def authenticate\n auth_response =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_response[:token], user_name: auth_response[:user_name])\n end",
"def authenticate\n\t\tusername = \"akiro.nakamura@pronto-hw.com\" \n\t\tpassword = \"1234\"\n\t\t\n\t\toauth = 'http://localhost:9001/rest/oauth/token?client_id=mobile_android&client_secret=secret&grant_type=password&username=' + username + '&password=' + password\n\t\tclient = RestClient::Resource.new(oauth,:verify_ssl => OpenSSL::SSL::VERIFY_NONE)\n\t\tresponse = client.get();\n\t\t@doc = Nokogiri::XML(response)\n\t\ttoken = \"Bearer \" + @doc.at_css(\"access__token\").content\n\n\tend",
"def rackspace_api_key\n Fog.credentials[:rackspace_api_key] || get_user_input(\"Enter Rackspace API key\")\nend",
"def rackspace_api_key\n Fog.credentials[:rackspace_api_key] || get_user_input(\"Enter Rackspace API key\")\nend",
"def rackspace_api_key\n Fog.credentials[:rackspace_api_key] || get_user_input(\"Enter Rackspace API key\")\nend",
"def rackspace_api_key\n Fog.credentials[:rackspace_api_key] || get_user_input(\"Enter Rackspace API key\")\nend",
"def rackspace_api_key\n Fog.credentials[:rackspace_api_key] || get_user_input(\"Enter Rackspace API key\")\nend",
"def rackspace_api_key\n Fog.credentials[:rackspace_api_key] || get_user_input(\"Enter Rackspace API key\")\nend",
"def rackspace_api_key\n Fog.credentials[:rackspace_api_key] || get_user_input(\"Enter Rackspace API key\")\nend",
"def rackspace_api_key\n Fog.credentials[:rackspace_api_key] || get_user_input(\"Enter Rackspace API key\")\nend",
"def rackspace_api_key\n Fog.credentials[:rackspace_api_key] || get_user_input(\"Enter Rackspace API key\")\nend",
"def basic_auth(opts); end",
"def api_auth\n creator = Creator.find_by(username: request.headers[:username])\n if creator && creator.authenticate(request.headers[:password])\n render json: { auth_token: encodeJWT(creator) }\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end",
"def authenticate\n authenticated_user = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n response = { message: Message.logged_in, auth_token: authenticated_user[:auth_token], is_doctor: authenticated_user[:is_doctor], doctor_id: authenticated_user[:doctor_id], fullname: authenticated_user[:fullname], date_of_birth: authenticated_user[:date_of_birth] }\n json_response(response)\n end",
"def authenticate_request\n @current_user = AuthorizeApiRequest.call(request.headers).result\n render json: { error: 'Not Authorized' }, status: 401 unless @current_user\n end",
"def basic_auth\n \"#{username}:#{access_token}\"\n end",
"def auth\n StockQuote::Stock.new(api_key: 'pk_8dd852fe4adb468dbee87c0459e0b83a')\n end",
"def authenticate_request\n @current_user = AuthorizeApiRequest.call(request.headers).result\n render json: { error: 'Not Authorized' }, status: 401 unless @current_user\n end",
"def authenticate\n auth.call(:authenticate)\n end",
"def retrieve_auth_token\n http = Net::HTTP.new(auth_endpoint.host, auth_endpoint.port)\n\n request = Net::HTTP::Post.new(auth_endpoint.request_uri)\n\n request.basic_auth(\n TodoableApi.configuration.username,\n TodoableApi.configuration.password\n )\n\n handle_auth_response(http.request(request))\n end",
"def login_5\n\n #definde needed header\n headers = {'Authorization' => \"Basic \" + @base_user_string, 'Accept' => 'application/*+xml;version=1.5'}\n\n #Login\n response = request({:method => \"POST\", :url => @host + \"session\", :headers => headers})\n\n #Get authentication header key\n @auth_key = response.headers[:x_vcloud_authorization]\n\n\n #Get organisation link\n parse_content(response.body, '//Session/Link').each do |org|\n\n if org.attribute('type')==\"application/vnd.vmware.vcloud.orgList+xml\"\n res = request({:url => org.attribute('href').to_s})\n @org_link = parse_content(res, '//OrgList/Org')[0].attribute('href').to_s\n end\n\n end\n\n end",
"def authenticate(username, password)\n\n @username = username\n @password = password\n\n auth_request = if on_premise?\n build_on_premise_request(username, password, region, login_url)\n else\n build_ocp_request(username, password, region, login_url)\n end\n\n soap_response = post(login_url, auth_request)\n\n document = REXML::Document.new(soap_response)\n # Check for Fault\n fault_xml = document.get_elements(\"//[local-name() = 'Fault']\")\n raise XML::Fault.new(fault_xml) if fault_xml.any?\n\n if on_premise?\n @security_token0 = document.get_elements(\"//e:CipherValue\").first.text.to_s\n @security_token1 = document.get_elements(\"//xenc:CipherValue\").last.text.to_s\n @key_identifier = document.get_elements(\"//o:KeyIdentifier\").first.text\n @cert_issuer_name = document.get_elements(\"//X509IssuerName\").first.text\n @cert_serial_number = document.get_elements(\"//X509SerialNumber\").first.text\n @server_secret = document.get_elements(\"//trust:BinarySecret\").first.text\n\n @header_current_time = get_current_time\n @header_expires_time = get_current_time_plus_hour\n @timestamp = '<u:Timestamp xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" u:Id=\"_0\"><u:Created>' + @header_current_time + '</u:Created><u:Expires>' + @header_expires_time + '</u:Expires></u:Timestamp>'\n @digest_value = Digest::SHA1.base64digest @timestamp\n @signature = '<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></CanonicalizationMethod><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#hmac-sha1\"></SignatureMethod><Reference URI=\"#_0\"><Transforms><Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></Transform></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></DigestMethod><DigestValue>' + @digest_value + '</DigestValue></Reference></SignedInfo>'\n @signature_value = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), Base64.decode64(@server_secret), @signature)).chomp\n else\n cipher_values = document.get_elements(\"//CipherValue\")\n\n if cipher_values && cipher_values.length > 0\n @security_token0 = cipher_values[0].text\n @security_token1 = cipher_values[1].text\n # Use local-name() to ignore namespace.\n @key_identifier = document.get_elements(\"//[local-name() = 'KeyIdentifier']\").first.text\n else\n raise RuntimeError.new(soap_response)\n end\n end\n\n\n true\n end",
"def authenticate(request)\n\n # Get the account information out of the request\n account_id = request.env[\"HTTP_X_CLIENT_ACCOUNT_IDENTIFIER\"]\n account_token = request.env[\"HTTP_X_CLIENT_ACCOUNT_TOKEN\"]\n device_id = request.env[\"HTTP_X_DEVICE_IDENTIFIER\"]\n\n auth = {:device_id => device_id}\n\n if (!account_id.nil? && !account_id.empty?) && (!account_token.nil? && !account_token.empty?)\n\n # Get the person\n person = Person.get(account_id)\n\n # Validate the person\n if !person\n return auth.merge({:authenticated => false, :error => true, :description => \"Person identifier not recognized.\", :status => 400})\n end\n\n # Validate the token\n if person.user.password != account_token\n return auth.merge({:authenticated => false, :error => true, :description => \"Invalid authorization token.\", :status => 400})\n end\n\n return auth.merge({:authenticated => true, :person => person})\n\n else\n\n # Unable to authenticate\n return auth.merge({:authenticated => false})\n\n end\n\n end",
"def auth_credentials\n auth = Rack::Auth::Basic::Request.new(request.env)\n auth.provided? && auth.basic? ? auth.credentials : [nil,nil]\n end",
"def credentials; end",
"def credentials; end",
"def credentials; end",
"def credentials; end",
"def credentials; end",
"def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_token)\n end",
"def http_auth_login\n # FIXME: Implement\n end",
"def auth\n Hash['type' => @auth_type,\n 'username' => @user,\n 'password' => @password]\n end",
"def call env\n # => Ruby 1.8.7 does not support Base64.strict_encode64\n auth_enc = Base64.encode64(formatted_login).gsub(\"\\n\", '')\n env.request_headers['Authorization'] = \"Basic #{auth_enc}\"\n @app.call(env)\n end",
"def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_token)\n end",
"def authenticate(request)\n return unless request['Authorization'].nil?\n\n confkey = credential_config_key\n\n token = config(\"#{confkey}.token\")\n user = config(\"#{confkey}.user\")\n pass = config(\"#{confkey}.password\")\n\n if token\n request['Authorization'] = \"token #{token}\"\n elsif user\n begin\n if $stdin.tty?\n pass = ask(\"Enter your password for #{api_url}: \") { |q| q.echo = '*' } if !pass\n else\n $stderr.puts \"STDIN not a TTY - cannot query for missing password.\"\n $stderr.puts \"Please add #{confkey}.password or #{confkey}.token to your gitconfig\"\n exit 1\n end\n rescue Interrupt\n warn \"attempting connection without authorization..\"\n return\n end\n request.basic_auth(user, pass)\n else\n $stderr.puts \"No currently configured username/password or token set for this API Provider.\"\n exit 1 unless $stdin.tty? && setup_credentials\n authenticate(request)\n end\n end",
"def authentication_request\n self.request authentication_request_hash(self.patron_barcode, self.patron_library_symbol)\n end",
"def get_authentications\r\n # the base uri for api requests\r\n query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n query_builder << '/authentications'\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'accept' => 'application/json',\r\n 'X-Auth-Token' => Configuration.x_auth_token\r\n }\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.get query_url, headers: headers\r\n\r\n # Error handling using HTTP status codes\r\n if response.code == 401\r\n raise APIException.new 'You are not authenticated', 401, response.raw_body\r\n elsif response.code == 403\r\n raise APIException.new 'This action needs a valid WSSE header', 403, response.raw_body\r\n elsif response.code == 400\r\n raise APIException.new 'Http bad request', 400, response.raw_body\r\n elsif !response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body\r\n end\r\n\r\n response.body\r\n end",
"def authenticate_shopify_request\n unless hmac_valid?()\n unauthorized() and return\n end\n end",
"def auth\n cfg_get(:auth)\n end",
"def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n # kindly refactor and add more keys to the response object when needed\n response = { \n status: Message.success,\n data: {\n token: auth_token\n } \n }\n json_response(response, 200)\n end",
"def check_authn\n response = self.class.head @endpoint\n\n return true if response.success?\n\n if response.code == 401 && response.headers[\"www-authenticate\"]\n if response.headers[\"www-authenticate\"].start_with? \"Keystone\"\n keystone_uri = /^Keystone uri='(.+)'$/.match(response.headers[\"www-authenticate\"])[1]\n\n if keystone_uri\n if @auth_options[:type] == \"x509\"\n body = { \"auth\" => { \"voms\" => true } }\n else\n body = {\n \"auth\" => {\n \"passwordCredentials\" => {\n \"username\" => @auth_options[:username],\n \"password\" => @auth_options[:password]\n }\n }\n }\n end\n\n headers = self.class.headers.clone\n headers['Content-Type'] = \"application/json\"\n headers['Accept'] = headers['Content-Type']\n\n response = self.class.post(keystone_uri + \"/v2.0/tokens\", :body => body.to_json, :headers => headers)\n\n if response.success?\n self.class.headers['X-Auth-Token'] = response['access']['token']['id']\n return true\n end\n end\n end\n end\n\n false\n end",
"def basic_auth(*args, &block); end",
"def authenticate\n api_key = parse_auth_token(request.headers['HTTP_AUTHORIZATION'])\n return user_not_authorized if api_key.nil?\n @real_user = User.find_by(api_key: parse_auth_token(request.headers['HTTP_AUTHORIZATION']))\n user_not_authorized if @real_user.nil?\n end",
"def auth\n @auth ||= Hash.new\n\n if !@auth[:username] && @headers['Authorization']\n str = Base64.decode64 @headers['Authorization'].split[1]\n username, password = str.split(\":\", 2)\n @auth = {:username => username, :password => password}.merge @auth\n end\n\n @auth\n end",
"def credentials\n auth_hash['credentials']\n end",
"def auth_connection(method, url, xml = '')\n res = nil\n begin \n if @auth_connection\n case method\n when \"GET\"\n res = @auth_connection.get url\n when \"POST\"\n if xml and xml.length > 0\n res = @auth_connection.post url, xml,\n { 'Content-Type' => 'application/xml' }\n else\n res = @auth_connection.post url\n end\n when \"PUT\"\n if xml and xml.length > 0\n res = @auth_connection.put url, xml,\n { 'Content-Type' => 'application/xml' }\n else \n res = @auth_connection.put url\n end\n when \"DELETE\"\n if xml and xml.length > 0\n res = @auth_connection.delete url, xml,\n { 'Content-Type' => 'application/xml' }\n else\n res = @auth_connection.delete url\n end\n else\n unknown_method\n end\n case res.code\n when HTTP_OK\n yield res.body if block_given?\n when HTTP_CREATED \n yield res.body if block_given?\n when HTTP_BAD_GATEWAY\n handle_exception 'server_not_responding'\n else\n handle_exception 'not_authorized'\n end\n else\n handle_exception 'authorization_info_not_provided'\n end\n rescue Exception => e\n raise e if e.is_a? VzaarError\n handle_exception 'unknown', e.message\n end\n res\n end",
"def vcd_session(vcd, username, password)\n vcd_session_link = RestClient::Resource.new(vcd + '/api/sessions', username, password )\n vcd_session_response = vcd_session_link.post({'Accept' => 'application/*+xml;version=5.5'})\n myvar = 'x_vcloud_authorization'\n @mysession = vcd_session_response.headers[myvar.to_sym]\nend",
"def authenticate!\n if !authenticated?\n response = request_token\n\n @token = response[\"token\"]\n @expires_at = DateTime.parse(response[\"expires_at\"])\n end\n\n [@token, @expires_at]\n end",
"def authenticate_request!\n return render_unauthorized unless request.headers['Authorization'].present?\n\n @token ||= AuthenticateRequest.get(User, request.headers['Authorization'].split(' ').last)\n @current_user = @token[:user]\n end",
"def authenticate\n #Hace el llamado de la clase AuthenticaUser, manda los parametros de :username y :password\n #Realiza el metodo call para obtener el Token del user_id\n #Arroja el token como Json_response\n auth_token = AuthenticateUser.new(auth_params[:username], auth_params[:password]).call \n json_response(auth_token: auth_token)\n end",
"def request\n endpoint = \"https://galaxy.ansible.com/api/v1/#{__callee__}/\"\n request = Typhoeus::Request.new(endpoint, userpwd: @auth)\n request.run\n JSON.parse(request.response.body).tap do |response|\n fail AuthenticationError, response['detail'] if response['detail']\n end\n end"
] | [
"0.68515164",
"0.67352784",
"0.6707994",
"0.6640942",
"0.6632217",
"0.65311235",
"0.6514519",
"0.6512263",
"0.6510728",
"0.64858323",
"0.64855963",
"0.64813614",
"0.6442701",
"0.64391893",
"0.64357597",
"0.64333266",
"0.6425217",
"0.6417281",
"0.64149237",
"0.6414572",
"0.641109",
"0.6403356",
"0.6396927",
"0.6394956",
"0.63827574",
"0.6382228",
"0.6375361",
"0.635334",
"0.63041455",
"0.630181",
"0.630181",
"0.62979287",
"0.6290517",
"0.6275722",
"0.6271536",
"0.6270521",
"0.6269898",
"0.6269826",
"0.62679636",
"0.6251404",
"0.62500346",
"0.62340593",
"0.622922",
"0.6223967",
"0.62212574",
"0.62084055",
"0.6201349",
"0.61999977",
"0.61847323",
"0.61842984",
"0.618313",
"0.6175158",
"0.6175158",
"0.6175158",
"0.6175158",
"0.6175158",
"0.6175158",
"0.6175158",
"0.6175158",
"0.6175158",
"0.6174154",
"0.61675435",
"0.61603236",
"0.6160209",
"0.61580336",
"0.6152473",
"0.61507607",
"0.6149459",
"0.61466575",
"0.61393696",
"0.6139195",
"0.6137243",
"0.6136891",
"0.6134137",
"0.6134137",
"0.6134137",
"0.6134137",
"0.6134137",
"0.61338454",
"0.6124555",
"0.6111581",
"0.6103205",
"0.6093905",
"0.6086909",
"0.60868984",
"0.6086319",
"0.60849786",
"0.60841894",
"0.607575",
"0.6075003",
"0.6073712",
"0.60705787",
"0.6064455",
"0.6052297",
"0.6051148",
"0.60510373",
"0.60506827",
"0.6048006",
"0.6045442",
"0.603484"
] | 0.8480711 | 0 |
These are default headers we need to use on all requests | def default_headers
{:accept => "application/json", :content_type => "application/json"}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_headers\n {\n user_agent: \"Unloq ruby gem #{Unloq::VERSION}\"\n }\n end",
"def default_headers\n @default_headers ||= {}\n {\n 'user-agent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1',\n 'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'accept-language' => 'en-us,en;q=0.5',\n 'accept-charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',\n 'keep-alive' => 300,\n 'connection' => 'keep-alive'\n }.each { |k,v| @default_headers[k] ||= v }\n @default_headers['accept-encoding'] = 'gzip,deflate' if @accept_compressed\n @default_headers\n end",
"def default_headers\n @default_headers ||= {\n 'accept': 'json',\n 'content-type': 'application/json',\n 'Api-Token': api_key\n }\n end",
"def default_http_header; end",
"def default_headers\n {\n 'User-Agent' => ProxyFetcher.config.user_agent\n }\n end",
"def default_headers(current_time)\n {}.tap do |def_headers|\n def_headers['User-Agent'] = Azure::Core::Default::USER_AGENT\n def_headers['x-ms-date'] = current_time\n def_headers['x-ms-version'] = '2014-02-14'\n def_headers['DataServiceVersion'] = '1.0;NetFx'\n def_headers['MaxDataServiceVersion'] = '3.0;NetFx'\n def_headers['Content-Type'] = 'application/atom+xml; charset=utf-8'\n end\n end",
"def default_headers\n {\n \"User-Agent\" => ProxyFetcher.config.user_agent\n }\n end",
"def default_headers\n salt = Time.now.strftime(\"%Y%m%d%H%M%S\")\n digest = Digest::SHA1.hexdigest(salt + @secret)\n app_secret = salt + \":\" + digest\n\n {\n \"User-Agent\" => \"SampleAPI Client; en\",\n \"X-Ubiregi-Auth-Token\" => @token,\n \"X-Ubiregi-App-Secret\" => app_secret,\n }\n end",
"def default_headers\n {\n :content_type => :json,\n :accept => :json\n }\n end",
"def default_http_headers\n { \"Agent-Hostname\" => context.environment.hostname,\n \"Content-Type\" => \"application/octet-stream\",\n \"Agent-Version\" => ScoutApm::VERSION,\n }\n end",
"def default_headers\n headers = { 'Content-Type': 'application/json; charset=utf-8' }\n\n headers['Cookie'] = \"ap_session=#{@session.session_id}\" if @session\n\n headers\n end",
"def default_headers\n {\n \"User-Agent\" => \"MediaControl/1.0\",\n \"X-Apple-Session-ID\" => persistent.session,\n \"X-Apple-Device-ID\" => persistent.mac_address\n }\n end",
"def request_headers\n {}\n end",
"def default_headers\n description_look_up do |metadata|\n metadata[:headers] if metadata[:headers]\n end\n end",
"def request_headers; end",
"def request_headers; end",
"def connection_headers\n {\n \"User-Agent\" => \"Montage Ruby v#{Montage::VERSION}\",\n \"Content-Type\" => \"application/json\",\n \"Accept\" => \"*/*\",\n \"Authorization\" => \"Token #{token}\",\n \"Referer\" => \"#{default_url_prefix}/\"\n }\n end",
"def headerprep(headers = {}) # :nodoc:\n default_headers = {}\n default_headers[\"X-Auth-Token\"] = @authtoken if (authok? && @account.nil?)\n default_headers[\"X-Storage-Token\"] = @authtoken if (authok? && !@account.nil?)\n default_headers[\"Connection\"] = \"Keep-Alive\"\n default_headers[\"User-Agent\"] = \"OpenStack::Compute Ruby API #{VERSION}\"\n default_headers[\"Accept\"] = \"application/json\"\n default_headers.merge(headers)\n end",
"def default_headers(arg=nil)\n set_headers\n end",
"def headerprep(headers = {}) # :nodoc:\n default_headers = {}\n default_headers[\"X-Auth-Token\"] = @authtoken if (authok? && @account.nil?)\n default_headers[\"X-Storage-Token\"] = @authtoken if (authok? && !@account.nil?)\n default_headers[\"Connection\"] = \"Keep-Alive\"\n default_headers[\"User-Agent\"] = \"CloudServers Ruby API #{VERSION}\"\n default_headers[\"Accept\"] = \"application/json\"\n default_headers.merge(headers)\n end",
"def standard_headers\n {\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json',\n 'User-Agent' => 'chef-pedant rspec tests',\n 'X-Chef-Version' => KNIFE_VERSION\n }\n end",
"def headerprep(headers = {}) # :nodoc:\n default_headers = {}\n default_headers[\"X-Auth-Token\"] = @authtoken if (authok? && @account.nil?)\n default_headers[\"X-Storage-Token\"] = @authtoken if (authok? && !@account.nil?)\n default_headers[\"Connection\"] = \"Keep-Alive\"\n default_headers[\"Accept\"] = \"application/json\"\n default_headers[\"Content-Type\"] = \"application/json\"\n default_headers.merge(headers)\n end",
"def headers(headers = {})\n @default_headers = headers if @default_headers.nil? || !headers.blank?\n @default_headers\n end",
"def include_default_headers\n\t\t\tapi_header\n\t\t\tapi_response_format\n\t\tend",
"def default_headers(options)\n {\n 'Accept' => 'application/json',\n 'Ocp-Apim-Subscription-Key' => @consumer_primary_token\n }.merge(options)\n end",
"def headers; return {}; end",
"def headers; return {}; end",
"def defaultHeaders(token)\n { 'Accept' => '*/*',\n 'Content-Type' => 'application/json',\n 'Authorization' => 'Bearer ' + token }\nend",
"def headers\n {}\n end",
"def headers\n {}\n end",
"def headers\n {}\n end",
"def default_header\n {\n \"User-Agent\" => user_agent\n }\n end",
"def headerprep(headers = {}) # :nodoc:\n default_headers = {}\n default_headers[\"X-Auth-Token\"] = @authtoken if (authok? && @account.nil?)\n default_headers[\"X-Storage-Token\"] = @authtoken if (authok? && !@account.nil?)\n default_headers[\"Connection\"] = \"Keep-Alive\"\n default_headers[\"Accept\"] = \"application/json\"\n default_headers[\"Content-Type\"] = \"application/json\"\n default_headers[\"User-Agent\"] = \"Cloud Databases Ruby API #{CloudDB::VERSION}\"\n default_headers.merge(headers)\n end",
"def http_headers\n {\n 'Content-Type' => 'application/json',\n 'Accept' => 'application/json',\n 'User-Agent' => \"resque-exceptional/#{Version}\"\n }\n end",
"def headers\n @headers ||= {}\n end",
"def headers\n @headers ||= {}\n end",
"def request_headers\n headers = {'Content-Type' => 'application/json'}\n headers[:user_agent] = @client.user_agent\n headers[:authorization] = auth_header\n headers\n end",
"def headers\n @headers ||= {\n \"Content-Type\" => \"application/json\",\n \"Authorization\" => \"Bearer #{@token}\",\n }\n end",
"def headers\n base_headers = {\n 'Content-Type' => 'application/json',\n 'Accept' => 'application/json',\n 'Sovren-AccountId' => @account_id,\n 'Sovren-ServiceKey' => @service_key\n }\n\n @additional_parse_request_headers.merge(base_headers)\n end",
"def headers\n super\n @headers['User-Agent'] = \"Recurly Ruby Client v#{VERSION}\"\n @headers\n end",
"def headers\n @headers ||={}\n end",
"def headers(request)\n raise NotImplementedError\n end",
"def headers\n {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'}\n end",
"def headers\n [\n { :key => \"User-Agent\", :value => user_agent},\n { :key => \"Content-Type\", :value => \"application/json; charset=utf-8\" },\n { :key => \"Accept\", :value => \"application/json\"}\n ]\n end",
"def headers\n headers = {}\n headers['Content-Type'] = 'application/x-www-form-urlencoded'\n headers['X-SILENCE-LOGGER'] = 'true'\n headers['Dont-Chunk'] = 'true' unless self.class.long_polling\n\n headers\n end",
"def headers\n {\n \"Authorization\" => basic_auth,\n \"Content-Type\" => \"application/json\",\n \"Accept\" => \"application/json\"\n }\n end",
"def headers\n { 'User-Agent' => user_agent }\n end",
"def headers\n {\n 'Host' => host,\n 'Content-Type' => 'application/json',\n api_key => settings.api_key\n }\n end",
"def request_headers(headers = {}, auth: true, gzip: true)\n headers = default_headers.merge(headers)\n headers.merge!(bearer_authorization_header) if auth\n headers[ACCEPT_ENCODING] = GZIP if gzip\n headers.reject{|_,v| v.nil? || (v.respond_to?(:empty?) && v.empty?)}\n end",
"def default_header\n if @access_token.present?\n {\n \"Authorization\" => \"Bearer #{@access_token.token}\",\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\"\n }\n else\n {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\"\n }\n end\n end",
"def set_headers # :nodoc:\n {\n 'User-Agent' => \"twm-ruby-#{VERSION}\",\n 'Content-Type' => 'application/json; charset=utf-8',\n 'Accept' => 'application/json'\n }\n end",
"def request_headers\n { 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}\n end",
"def headers(_context)\n {}\n end",
"def _initialize_headers\n {}\n end",
"def default_octokit_headers\n {\n :accept => ::Octokit::Default.default_media_type,\n :content_type => \"application/json\",\n :user_agent => ::Octokit::Default.user_agent\n # :accept_encoding => \"gzip;q=1.0,deflate;q=0.6,identity;q=0.3\"\n }\n end",
"def headers\n call_once\n @headers\n end",
"def headers\n end",
"def default_headers\n headers[\"X-UA-Compatible\"] = \"IE=edge\"\n end",
"def headers\n headers = {}\n headers[:accept] = '*/*'\n headers[:content_type] = 'Application/json;charset=UTF-8'\n headers[:Authorization] = encode_credentials\n headers\n end",
"def default_header\n headers['Cache-Control'] = 'no-cache'\n headers['P3P'] = \"CP='UNI CUR OUR'\"\n end",
"def headers\n h = {\n 'X-Api-Version' => @api_version,\n :accept => :json,\n }\n\n if @account_id\n h['X-Account'] = @account_id\n end\n\n if @access_token\n h['Authorization'] = \"Bearer #{@access_token}\"\n elsif @cookies\n h[:cookies] = @cookies\n end\n\n if @local_token\n h['X-RLL-Secret'] = @local_token\n end\n\n h\n end",
"def default_headers=(hash)\n if hash\n raise 'You must pass a hash to default_headers=' unless hash.is_a?(Hash)\n @default_headers = hash\n else\n @default_headers = nil\n end\n end",
"def headers\r\n # give access to helpers to opts with a different name\r\n @opts\r\n end",
"def headers\n if self.middleware.to_sym == :reso_api\n reso_headers\n else\n spark_headers\n end\n end",
"def headers\n @headers ||= self.class.beautify_headers(@net_http_res.to_hash)\n end",
"def default_headers\n headers = [\"Variables\"]\n @filenames.each do |fname|\n headers << fname\n end\n headers\n end",
"def base_headers\n self.class.base_headers\n end",
"def headers\n {\n # Declare that you expect response in XML after a _successful_\n # response.\n \"Accept\" => \"application/xml\",\n\n # Promise to send XML.\n \"Content-Type\" => \"application/xml; charset=utf-8\",\n\n # All requests will be authenticated using HTTP Basic Auth, as\n # described in rfc2617. Your library probably has support for\n # basic_auth built in, I've passed the Authorization header\n # explicitly here only to show what happens at HTTP level.\n \"Authorization\" => \"Basic #{auth_string}\",\n\n # Tell Harvest a bit about your application.\n \"User-Agent\" => HarvestConfig.attrs[:user_agent]\n }\n end",
"def default_headers(value)\n @configuration[:default_headers] = value\n end",
"def headers\n {\n 'Authorization' => \"key=#{@server_key}\",\n 'Content-Type' => 'application/json'\n }\n end",
"def headers\n @headers ||= rack_environment.select{|k,v| k.start_with? 'HTTP_'}\n end",
"def headers\n @headers.tap do |headers|\n headers[:algorithm] = configuration.algorithm if verification?\n case configuration.claim\n when CLAIM_EXPIRATION_TIME\n headers.merge!(exp_headers)\n when CLAIM_NOT_BEFORE_TIME\n headers.merge!(nbf_headers)\n end\n end\n end",
"def default_headers_obj(*args)\n Headers.new(*args).extend(RequestHeaders)\n end",
"def headers\n {\n 'Accept' => 'application/json',\n 'Content-type' => 'application/json',\n 'Authorization' => \"Basic #{Base64.strict_encode64(@options[:api_key].to_s).strip}\",\n 'User-Agent' => \"Netbanx-Paysafe v1.0/ActiveMerchant #{ActiveMerchant::VERSION}\"\n }\n end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def add_headers; end",
"def request_headers=(_arg0); end",
"def content_headers\n { 'User-Agent' => \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.7) Gecko/2009021906 Firefox/3.0.7\",\n 'Accept-language' => 'enUS' }\n end",
"def dynamic_headers\n {\n 'Authorization' => token,\n 'RequestID' => request_id,\n }\n end",
"def web_proxy_headers\n { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'cookie' => @cookie }\n end",
"def web_proxy_headers\n { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'cookie' => @cookie }\n end",
"def headers\n request.headers\n end",
"def set_request_headers!(request); end",
"def get_headers\n @headers = headers\n @headers\n end",
"def headers(header = nil)\n @response.headers.merge!(header) if header\n @response.headers\n end",
"def headers\n @request_headers\n end",
"def headers\n\t\t\tuser = \"#{config[:oauth_key]}|#{config[:fingerprint]}\"\n\t\t\tgateway = \"#{config[:client_id]}|#{config[:client_secret]}\"\n\t\t\theaders = {\n\t\t\t\tcontent_type: :json,\n\t\t\t\taccept: :json,\n\t\t\t\t'X-SP-GATEWAY' => gateway,\n\t\t\t 'X-SP-USER' => user,\n\t\t\t 'X-SP-USER-IP' => config[:ip_address],\n\t\t\t}\n if config[:idemopotency_key]\n headers['X-SP-IDEMPOTENCY-KEY'] = config[:idemopotency_key]\n end\n headers\n\t\tend",
"def get_headers\n # the base uri for api requests\n _query_builder = Configuration.base_uri.dup\n\n # prepare query string for API call\n _query_builder << '/response/headers'\n\n # validate and preprocess url\n _query_url = APIHelper.clean_url _query_builder\n\n # prepare headers\n _headers = {\n 'user-agent' => 'Stamplay SDK'\n }\n\n # Create the HttpRequest object for the call\n _http_request = @http_client.get _query_url, headers: _headers\n \n # Call the on_before_request callback\n @http_call_back.on_before_request(_http_request) if @http_call_back\n\n # Invoke the API call and get the response\n _response = @http_client.execute_as_string(_http_request)\n\n # Call the on_after_response callback\n @http_call_back.on_after_response(_response) if @http_call_back\n\n # Global error handling using HTTP status codes.\n validate_response(_response)\n end",
"def headers\n hash = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'User-Agent': \"#{app_name} (#{app_email})\"\n }\n hash.merge({ Host: URI(api_base_url).hostname.to_s })\n rescue URI::InvalidURIError => e\n handle_uri_failure(method: \"BaseService.headers #{e.message}\",\n uri: api_base_url)\n hash\n end",
"def headers\n @headers ||= HeaderHash.new(@http_response.to_hash)\n end",
"def headers(new_headers = {})\n (@headers ||= {}).merge!(new_headers)\n end"
] | [
"0.8268056",
"0.82457113",
"0.8192051",
"0.8154548",
"0.8131782",
"0.8094137",
"0.8090789",
"0.8024158",
"0.7980696",
"0.78547084",
"0.78031284",
"0.774329",
"0.77422446",
"0.7722451",
"0.7664412",
"0.7664412",
"0.7647234",
"0.7623513",
"0.76214886",
"0.76133907",
"0.75683606",
"0.7539666",
"0.7504177",
"0.7503475",
"0.74681515",
"0.74607104",
"0.74607104",
"0.74541366",
"0.7452067",
"0.7452067",
"0.7452067",
"0.7438929",
"0.74061733",
"0.73548335",
"0.73522455",
"0.73434633",
"0.7326496",
"0.7305378",
"0.7249477",
"0.7242169",
"0.72066915",
"0.71992457",
"0.7173711",
"0.7153543",
"0.7146588",
"0.7139863",
"0.71344763",
"0.71268016",
"0.7120129",
"0.7097743",
"0.70892775",
"0.7089149",
"0.70844674",
"0.7067685",
"0.7055235",
"0.7053858",
"0.70257694",
"0.70249623",
"0.70124584",
"0.6996736",
"0.6966337",
"0.6961379",
"0.69481206",
"0.69467443",
"0.69440275",
"0.69401574",
"0.6939431",
"0.69391435",
"0.6928635",
"0.6922959",
"0.69212687",
"0.68761367",
"0.6857128",
"0.68543226",
"0.6852193",
"0.6852193",
"0.6852193",
"0.6852193",
"0.6852193",
"0.6852193",
"0.6852193",
"0.6852193",
"0.6852193",
"0.6852193",
"0.68371725",
"0.6827864",
"0.68095917",
"0.6804101",
"0.6781228",
"0.6781228",
"0.6767192",
"0.6764517",
"0.67640865",
"0.6758499",
"0.67560935",
"0.6754633",
"0.6733953",
"0.6727541",
"0.67221797",
"0.6715712"
] | 0.80758214 | 7 |
This returns the available versions of the API | def versions
JSON.parse(RestClient.get("#{VERSION_URL}/.json", self.default_headers))["versions"].collect { |v| v["id"] }.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_versions\n raise \"available_versions API is only available for Artifactory backend.\"\n end",
"def versions\n info[:versions]\n end",
"def get_all_versions\n []\n end",
"def fetch_versions\n http_get(\"#{host}/#{Configuration.versions_file}\").body\n end",
"def get_all_versions()\n return []\n end",
"def versions\n registered_versions.keys\n end",
"def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend",
"def versions\n Version.all\n end",
"def available_versions\n Mixlib::Install.available_versions(project, channel)\n end",
"def available_versions\n Mixlib::Install.new(\n product_name: project_name,\n channel: channel_name.to_sym,\n user_agent_headers: ['omnitruck']\n ).available_versions\n rescue Mixlib::Install::Backend::ArtifactsNotFound\n # Return an empty array if no artifacts are found\n []\n end",
"def api_version\n request('getAPIVersion')\n end",
"def versions\n versions = Backlogjp.base._command \"getVersions\", self.id\n versions.map {|hash| Version.new(hash)}\n end",
"def getVersions\r\n\t\t\t\t\treturn @versions\r\n\t\t\t\tend",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def api_info(req)\n client.request(req) do |response|\n json_response = ::RHC::Json.decode(response.content)\n [ json_response['supported_api_versions'], json_response['api_version'] || json_response['version'].to_f, json_response['data'] ]\n end\n end",
"def versions(resource_uri, format = \"text/turtle\")\n log \"versions for #{resource_uri}\"\n get \"#{resource_uri}/fcr:versions\", format\n end",
"def api_version_negotiated\n client_api_versions.reverse. # choose the last API version listed\n detect { |v| @server_api_versions.include? v }\n end",
"def available_versions\n return unless @version\n the_gem_line = gem_remote_list_output.scan(/^#{name}\\s.*$/).first\n the_gem_line.scan /\\d+\\.\\d+\\.\\d+/\n end",
"def available_versions\n the_gem_line = gem_remote_list_output.scan(/^#{name}\\s.*$/).first\n the_gem_line.scan /\\d+\\.\\d+\\.\\d+/\n end",
"def get_alchemy_versions\n # first we try rubygems.org\n response = query_rubygems\n if response.code == \"200\"\n alchemy_versions = JSON.parse(response.body)\n alchemy_versions.collect { |h| h[\"number\"] }.sort\n else\n # rubygems.org not available?\n # then we try github\n response = query_github\n if response.code == \"200\"\n alchemy_tags = JSON.parse(response.body)\n alchemy_tags.collect { |h| h[\"name\"].tr(\"v\", \"\") }.sort\n else\n # no luck at all?\n raise UpdateServiceUnavailable\n end\n end\n end",
"def listversions(project=self.project)\n get('listversions.json', project: project)['versions']\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 versions(module_name)\n path = \"/v3/modules/#{module_name.tr('/','-')}\"\n response = @conn.get(path)\n\n if response.status != 200\n raise R10K::Error.new(\"Request to Puppet Forge '#{path}' failed. Status: #{response.status}\")\n end\n\n releases = response.body['releases'].reject { |r| r['deleted_at'] }\n releases = releases.map do |version_info|\n version_info['version']\n end\n releases.reverse\n end",
"def stable_gem_versions(http_response)\n http_response.blank? ? [] : http_response.select { |val| val['prerelease'] == false }\n end",
"def installed_versions; end",
"def build_current_versions\n version_list = []\n new_resource.package_name.each_with_index do |name, index|\n version = if new_resource.version && !new_resource.version[index].nil?\n powershell_exec(build_powershell_package_command(\"Get-Package '#{name}'\", new_resource.version[index]), timeout: new_resource.timeout).result\n else\n powershell_exec(build_powershell_package_command(\"Get-Package '#{name}'\"), timeout: new_resource.timeout).result\n end\n if version.empty?\n version = nil\n end\n version = version.strip if version.respond_to?(:strip)\n version_list.push(version)\n end\n version_list\n end",
"def stable_gem_versions(http_response)\n http_response.blank? ? [] : http_response.select { |val| val['prerelease'] == false }\nend",
"def versions\n self.apar_defect_version_maps.map { |m| m.version }\n end",
"def versions\n @versions ||= json_dir_names.sort_by { |v| Gem::Version.new(v) }.reverse!\n end",
"def api_version\n self.class.get('/api')['api_ver']\n end",
"def remote_versions_for(name)\n require 'json'\n\n client.url = \"https://rubygems.org/api/v1/versions/#{name}.json\"\n client.follow_location = true\n client.http_get\n json = JSON.parse(client.body_str)\n json.collect { |version| version['number'] }\n end",
"def get_api_version\n :v201502\n end",
"def version\n api_execute('/version', :get).body\n end",
"def available_versions\n command = resource_or_provider_command\n self.class.validate_command(command)\n\n command_version = self.class.pip_version(command)\n if self.class.compare_pip_versions(command_version, '1.5.4') == -1\n available_versions_with_old_pip\n else\n available_versions_with_new_pip(command_version)\n end\n end",
"def index\n @api_versions = ApiVersion.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end",
"def versions\n @versions ||= run( :versions, '--bare' ).lines.map( &:chomp )\n end",
"def staging_versions\n possible_versions = [1, 2]\n @versions ||= []\n possible_versions.each do |version|\n @conn.get \"/api/v#{version}/stage\"\n @versions.push version\n rescue SFRest::InvalidResponse\n nil\n end\n @versions\n end",
"def versions(sku, offer, location = @location, publisher = @publisher)\n raise ArgumentError, \"No location specified\" unless location\n raise ArgumentError, \"No publisher specified\" unless publisher\n\n url = build_url(\n location, 'publishers', publisher, 'artifacttypes', 'vmimage',\n 'offers', offer, 'skus', sku, 'versions'\n )\n\n JSON.parse(rest_get(url)).map{ |element| element['name'] }\n end",
"def connect_versions\n if @connect_versions.nil?\n api_connect_cdn=Rest.new({:base_url=>CONNECT_WEB_URL})\n javascript=api_connect_cdn.call({:operation=>'GET',:subpath=>CONNECT_VERSIONS})\n # get result on one line\n connect_versions_javascript=javascript[:http].body.gsub(/\\r?\\n\\s*/,'')\n Log.log.debug(\"javascript=[\\n#{connect_versions_javascript}\\n]\")\n # get javascript object only\n found=connect_versions_javascript.match(/^.*? = (.*);/)\n raise CliError,'Problen when getting connect versions from internet' if found.nil?\n alldata=JSON.parse(found[1])\n @connect_versions=alldata['entries']\n end\n return @connect_versions\n end",
"def list_all_aos_version_boxes(args = {}) \n get(\"/aosversions.json/aosversionbox\", args)\nend",
"def versions\n service_config.keys\n end",
"def api_version\n @version\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 versions_for(name, &bl)\n # koji xmlrpc call\n versions = tagged_versions_for(name).values.flatten.uniq\n bl.call(:koji, name, versions) unless bl.nil?\n versions\n end",
"def versions\n authorize @page\n @versions = @page.versions\n status = params[:by_status] && Page.statuses[params[:by_status]]\n if status\n @versions = @versions.where_object(status: status)\n end\n @versions = @versions.reorder(created_at: :desc, id: :desc).page params[:page]\n end",
"def index\n @api_versions = ApiVersion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end",
"def versions\n versions = {}\n versions['All Versions'] = 'all'\n versions[self.version + ' (Current Version)'] = 'current'\n MapRating.where(map_slug: self.slug).select(:map_version).map(&:map_version).uniq.sort_by {|ver| ver}.reverse!.each do |version|\n versions[version] = version.downcase.gsub('.', '_') unless version == self.version\n end\n versions\n end",
"def discovery_versions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DiscoveryApi.discovery_versions ...'\n end\n # resource path\n local_var_path = '/../'\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(['text/plain; charset=utf-8'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DiscoveryApi#discovery_versions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_versions(project_id_or_key)\n get(\"projects/#{project_id_or_key}/versions\")\n end",
"def versions(browser, min_usage = 0)\n assert_valid_browser browser\n versions = browser_data(browser)[\"versions\"].compact\n return versions if min_usage == 0\n versions.select {|v| browser_data(browser)[\"usage_global\"][v] > min_usage }\n end",
"def get_version\n prepare\n @api.get_api_version\n end",
"def get_api_version\n response = send_api_request(:index)\n response[:returncode] ? response[:version].to_s : \"\"\n end",
"def api_version\n @api_version || :latest\n end",
"def get_api_version()\n return :v201502\n end",
"def test_get_versions\n puts \"## get api server version ##\"\n resp = Salesforce::Rest::AsfRest.xget_version()\n\n counter = 0\n resp.each do |row|\n puts '-' * 36 + \" row: #{counter} \" + '-' * 36\n row.keys.each do |key|\n pp key + \" => \" + row[key]\n end\n puts '-' * 80\n counter = counter + 1\n end\n assert !resp.nil?\n end",
"def version_nodes\n design_response.map do |response|\n response.dig('node', 'versions', 'edges')\n end\n end",
"def versions\n authorize @page\n @versions = @page.versions\n status = params[:by_status] && Page.statuses[params[:by_status]]\n if status\n @versions = @versions.where_object(status: status)\n end\n @versions = @versions.reorder(created_at: :desc, id: :desc).page params[:page]\n end",
"def api_version\n @api_version ||= begin\n pool = self.pool.get_all[0]\n host = self.pool.get_master(pool)\n major = self.host.get_API_version_major(host)\n minor = self.host.get_API_version_minor(host)\n \"#{major}.#{minor}\"\n end\n end",
"def build_candidate_versions\n versions = []\n new_resource.package_name.each_with_index do |name, index|\n version = if new_resource.version && !new_resource.version[index].nil?\n powershell_exec(build_powershell_package_command(\"Find-Package '#{name}'\", new_resource.version[index]), timeout: new_resource.timeout).result\n else\n powershell_exec(build_powershell_package_command(\"Find-Package '#{name}'\"), timeout: new_resource.timeout).result\n end\n if version.empty?\n version = nil\n end\n version = version.strip if version.respond_to?(:strip)\n versions.push(version)\n end\n versions\n end",
"def versions(include_current = false)\n query = {}\n version = self.class.const_get(\"Version\")\n self.class.key.zip(self.key) { |property, value| query[property.name] = value }\n query.merge(:order => version.key.collect { |key| key.name.desc })\n result = version.all(query)\n end",
"def versions()\n return MicrosoftGraph::Shares::Item::List::Items::Item::Versions::VersionsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def get_api_version\n response = send_api_request(:index)\n if response[:returncode]\n response[:version].to_s\n else\n \"\"\n end\n end",
"def versions\n\t\tObjectVersion.where(\n\t\t\t:format => 1,\n\t\t\t:model_id => self.id, \n\t\t\t:inki_model_name => self.class.to_s, \n\t\t).order(\"created_at DESC\")\n\tend",
"def supported_versions\n raise NotImplementedError\n end",
"def get_cookbook_chef_versions ()\n cookbooks = rest.get_rest(\"/cookbooks/#{@cookbook_name}?num_version=all\")\n cookbooks[@cookbook_name]['versions'].each do |v|\n @versions.push v['version']\n end\n end",
"def remote_versions\n Setting.upyun.images.versions\n end",
"def versions\n installs.map { |i| i['version'] }.uniq\n end",
"def versions\n installs.map { |i| i['version'] }.uniq\n end",
"def versions\n installs.map { |i| i['version'] }.uniq\n end",
"def get_repo_list\n Chef::Log.debug(\n \"Fetching all versions of #{new_resource.module_name} \" +\n \"from #{new_resource.repository}.\",\n )\n latest = powershell_out!(\n <<-EOH,\n $splat = @{\n Name = \"#{new_resource.module_name}\"\n Repository = \"#{new_resource.repository}\"\n AllVersions = $True\n }\n (Find-Module @splat).Version.ForEach({$_.ToString()})\n EOH\n ).stdout.to_s.chomp.split(\"\\r\\n\")\n Chef::Log.debug(\"Available versions: #{latest.join(', ')}\")\n\n return latest.map { |v| Gem::Version.new(v) }\n end",
"def check_versions\n if @version\n unless supported_version_numbers.include?(@version.to_s)\n raise UnsupportedVersion.new(\"#{@version} is not supported by the server.\")\n end\n unless supporting_versions.include?(@version.to_s)\n raise UnsupportedVersion.new(\"#{@version} is not supported by #{self.class}\")\n end\n else\n unless @version = (supported_version_numbers & supporting_versions).sort.first\n raise UnsupportedVersion.new(\"\\nService @ #{@versions_uri} supports: #{supported_version_numbers.join(', ')}\\n\" +\n \"#{self.class} supports: #{supporting_versions.join(', ')}\")\n end\n end\n end",
"def page_versions\n list_versions_for(latest_version_of(@item.path))\n end",
"def api_version\n Gandi.call('version.info')['api_version']\n end",
"def fetch_versions\n html = Nokogiri::HTML(open('https://bitnami.com/stack/elasticsearch/cloud/amazon'))\n raw_entries = html.xpath('//td[@class=\"instance_id\"]')\n entries = raw_entries.xpath('a')\n raw_entries.xpath('strong/a').each { |sa| entries << sa }\n raw_versions = entries.map do |i|\n [\n i.xpath('@href').first.value.split('/').last,\n i.children.first.text\n ]\n end.to_h\n parse_versions(raw_versions)\n end",
"def versions\n link = data.xpath(\"at:link[@rel = 'version-history']/@href\", NS::COMBINED)\n if link = link.first\n Collection.new(repository, link) # Problem: does not in fact use self\n else\n # The document is not versionable\n [self]\n end\n end",
"def list_versions 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_list_versions_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::ArtifactRegistry::V1beta2::ListVersionsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def appliance_api_version\n options = { 'Content-Type' => :none, 'X-API-Version' => :none, 'auth' => :none }\n response = rest_api(:get, '/rest/version', options)\n version = response_handler(response)['currentVersion']\n raise ConnectionError, \"Couldn't get API version\" unless version\n version = version.to_i if version.class != Integer\n version\n rescue ConnectionError\n @logger.warn \"Failed to get OneView max api version. Using default (#{OneviewSDK::DEFAULT_API_VERSION})\"\n OneviewSDK::DEFAULT_API_VERSION\n end",
"def versions\n @versions ||= Versions.new(self)\n end",
"def versions\n @versions ||= Versions.new(self)\n end",
"def get_versions(versions)\n versions.map {|v| [v,get_version(v)] }\n end",
"def get_versions\r\n versions_nodes = BankNodestructure.version_gather(params[:subject], params[:grade])\r\n render json: versions_nodes.to_json\r\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 check_versions\n super\n unless (supported_version_ids & Versions::SUPPORTED).length > 0\n raise UnsupportedVersion.new(\"\\nService @ #{@versions_uri} supports: #{supported_version_ids.join(', ')}\\n\" +\n \"Fog::Vcloud::Terremark::Vcloud supports: #{Versions::SUPPORTED.join(', ')}\")\n end\n unless supported_version_ids.include?(@version)\n @version = (supported_version_ids & Versions::SUPPORTED).sort.first\n end\n end",
"def appliance_i3s_api_version\n options = { 'Content-Type' => :none, 'X-API-Version' => :none, 'auth' => :none }\n response = rest_api(:get, '/rest/version', options)\n version = response_handler(response)['currentVersion']\n raise ConnectionError, \"Couldn't get API version\" unless version\n version = version.to_i if version.class != Integer\n version\n rescue ConnectionError\n @logger.warn \"Failed to get Image Streamer max api version. Using default (#{OneviewSDK::ImageStreamer::DEFAULT_API_VERSION})\"\n OneviewSDK::ImageStreamer::DEFAULT_API_VERSION\n end",
"def get_api_version()\n return API_VERSION\n end",
"def all_versions\n [document.version, *all_preceding_versions]\n end",
"def index\n @manage_app_versions = Manage::AppVersion.all\n end",
"def check_versions\n super\n unless (supported_version_ids & Versions::SUPPORTED).length > 0\n raise UnsupportedVersion.new(\"\\nService @ #{@versions_uri} supports: #{supported_version_ids.join(', ')}\\n\" +\n \"Fog::Vcloud::Terremark::Ecloud supports: #{Versions::SUPPORTED.join(', ')}\")\n end\n unless supported_version_ids.include?(@version)\n @version = (supported_version_ids & Versions::SUPPORTED).sort.first\n end\n end",
"def versions\n @page = Comatose::Page.find_is_snippet params[:id]\n @version_num = (params[:version] || @page.versions.length).to_i\n @version = @page.find_version(@version_num)\n end",
"def versions\n self.class.where(id: self._id)\n end",
"def current_api_version\n JSON.parse(get('/api').to_s)['currentVersion'] rescue 1\n end",
"def api_version\n 'v2'\n end",
"def versions\n @page = ComatosePage.find params[:id]\n @version_num = (params[:version] || @page.versions.length).to_i\n @version = @page.find_version(@version_num)\n end",
"def api_version\n @api_version || \"2011-02-01\"\n end",
"def versions(expand = {})\n if @versions.nil? || !expand.empty?\n @versions = self.class.verions(self.key, expand)\n end\n @versions\n end",
"def version; env['api.version'] end",
"def get_api_version\n _make_request(:types)['version'].to_s\n end",
"def extract_versions(infos)\n end",
"def get_resource_descriptions(resource)\n available_versions.map do |version|\n get_resource_description(resource, version)\n end.compact\n end",
"def api_version\n :v2\n end"
] | [
"0.7911649",
"0.74483323",
"0.7420273",
"0.73977816",
"0.7392916",
"0.722803",
"0.72215706",
"0.7192871",
"0.7157209",
"0.71292275",
"0.7113218",
"0.70429564",
"0.7028521",
"0.7021907",
"0.7003831",
"0.6946998",
"0.6926113",
"0.6875869",
"0.68436795",
"0.6833199",
"0.6830812",
"0.68270975",
"0.67821914",
"0.6714309",
"0.67140365",
"0.67021054",
"0.6701934",
"0.667682",
"0.6651695",
"0.66311955",
"0.6627521",
"0.66269714",
"0.6615975",
"0.6615919",
"0.65572315",
"0.65549314",
"0.65539616",
"0.6551359",
"0.654872",
"0.6543188",
"0.65377617",
"0.6519167",
"0.6509878",
"0.6506271",
"0.65031064",
"0.6488462",
"0.6488227",
"0.64738226",
"0.6472584",
"0.6454171",
"0.64382267",
"0.64300483",
"0.64294386",
"0.6424535",
"0.64169794",
"0.64152193",
"0.6405677",
"0.63873124",
"0.63821256",
"0.6372259",
"0.6371398",
"0.6350963",
"0.6347603",
"0.63441336",
"0.6325756",
"0.6312619",
"0.63035876",
"0.63035876",
"0.63035876",
"0.62975496",
"0.62843883",
"0.6282844",
"0.6276148",
"0.62717164",
"0.6239081",
"0.6234548",
"0.6234469",
"0.6234243",
"0.6234243",
"0.6209656",
"0.61957204",
"0.6185915",
"0.61838794",
"0.61751515",
"0.616079",
"0.614513",
"0.6142688",
"0.6129328",
"0.6128596",
"0.6127964",
"0.6123705",
"0.611324",
"0.6107897",
"0.60980815",
"0.6094661",
"0.6093156",
"0.60869294",
"0.6076969",
"0.60719866",
"0.6070741"
] | 0.7814768 | 1 |
This caches the authentication response for subsequent usage | def auth_response
@auth_response ||= self.authenticate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate!\n if !authenticated?\n response = request_token\n\n @token = response[\"token\"]\n @expires_at = DateTime.parse(response[\"expires_at\"])\n end\n\n [@token, @expires_at]\n end",
"def retry_with_auth(response)\n @already_tried_with_auth = true\n logger.info(\"Authentication Required. Retrying with auth info\")\n accessor.auth_manager.associate_auth_info(response)\n add_credentials!\n @body.rewind if @body # Its a stringIO, and we already fed it to the adapter once, so rewind it when we try again\n response = fetch_response\n end",
"def cached_session_data\n Authentication::RedisStore.instance.json_get(auth_token)\n end",
"def cache_token(auth_token)\n @api.set_auth_token(auth_token)\n @auth_token = auth_token\n end",
"def handle_auth_response(response)\n @auth_token = {}\n\n # TODO: Fix this to handle error cases\n begin\n response = JSON.parse(response.body)\n @auth_token[:token] = response[\"token\"]\n @auth_token[:expires_at] = DateTime.parse(response[\"expires_at\"])\n rescue JSON::ParserError, TypeError\n @auth_token = {}\n end\n end",
"def authentication_response\n if authenticate_user.success?\n { :token => authenticate_user.result }\n else\n { :error => :unauthorized }\n end\n end",
"def authenticate_once_state\n super\n end",
"def auth\n {}\n end",
"def cache_response(token_response)\n @cache_driver.add(token_response)\n token_response\n end",
"def authenticate\n if session.expired?\n @session = get_session\n @session.save\n end\n self\n end",
"def http_auth_hash; end",
"def authenticate_request\n return unless authorization_token_valid?\n\n @current_user = User.find_by_id authorization_token_content.id\n\n @current_user.last_request_ip = request.remote_ip\n @current_user.touch :last_request_at\n\n @current_user\n end",
"def authenticate!\n response = self.AuthenticateUser(\n { :username => config[:username], :password => config[:password] },\n :is_authenticate => true,\n :allow_reauthenticate => false)\n\n auth_data = {\n :retailer_guid => response['RetailerGuid'],\n :authenticated => response['Authenticated'],\n :token => response['Token'],\n :ics_user_id => response['ICSUserID']\n }\n\n if !auth_data[:authenticated]\n raise AuthenticationError, 'authentication failed'\n end\n\n self.retailer_guid = auth_data[:retailer_guid]\n\n self.auth_header = {\n \"wsdl:AuthenticationResult\" => {\n \"wsdl:RetailerGuid\" => auth_data[:retailer_guid],\n \"wsdl:Authenticated\" => auth_data[:authenticated],\n \"wsdl:Token\" => auth_data[:token],\n \"wsdl:ICSUserID\" => auth_data[:ics_user_id],\n }\n }\n\n @authenticated = true\n end",
"def challenge(request, response)\n auth = Http::Auth::Bearer.new(\n @realm,\n request,\n response\n )\n auth.require_login\n end",
"def authenticate_request!\n return render_unauthorized unless request.headers['Authorization'].present?\n\n @token ||= AuthenticateRequest.get(User, request.headers['Authorization'].split(' ').last)\n @current_user = @token[:user]\n end",
"def authenticate\n json_response(\n auth_token: AuthenticateUser.new(\n auth_params[:username],\n auth_params[:password]\n ).call\n )\n end",
"def auth_store; end",
"def authenticate\n self.get && true\n end",
"def auth\n @auth ||= Hash.new\n\n if !@auth[:username] && @headers['Authorization']\n str = Base64.decode64 @headers['Authorization'].split[1]\n username, password = str.split(\":\", 2)\n @auth = {:username => username, :password => password}.merge @auth\n end\n\n @auth\n end",
"def authenticate\n authenticate_token || render_unauthorized\n end",
"def auth_cache(&block)\n return @authorization if @authorization\n @authorization ||= OperatorCache.new(self.class)\n @authorization.instance_eval(&block) if block_given?\n @authorization\n end",
"def authenticate\n authenticated_session || render_unauthorized\n end",
"def authenticate\n authenticate_token || render_unauthorized\n end",
"def authenticate\n\t\tauthenticate_token || render_unauthorized\n\tend",
"def authenticate\n result=\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response({\n auth_token: result[:token],\n email: result[:user].email,\n current_member_id: result[:user].member.id,\n current_member_name: result[:user].member.full_name\n })\n end",
"def fetch\n @lock.synchronize do\n @credentials = yield if @credentials.nil? || @credentials.expired?\n @credentials\n end\n end",
"def caching\n unless @caching\n conf = Grape::Jwt::Authentication.configuration\n return conf.rsa_public_key_caching\n end\n @caching\n end",
"def authenticate\n raise Rackspace::NotInitialized unless self.initialized?\n headers = RestClient::Request.execute(:method => :get, :url => \"#{AUTH_URL}/#{self.api_version}\", :headers => {\"X-Auth-User\" => self.api_user, \"X-Auth-Key\" => self.api_key}, :raw_response => true).headers\n {:auth_token => headers[:x_auth_token], :storage_url => headers[:x_storage_url], :server_management_url => headers[:x_server_management_url], :cdn_management_url => headers[:x_cdn_management_url]}\n end",
"def login_from_basic_auth\n <%= singular_name %>name, passwd = get_auth_data\n self.current_<%= singular_name %> = <%= class_name %>.authenticate(<%= singular_name %>name, passwd) if <%= singular_name %>name && passwd\n end\n\n # Called from #current_<%= singular_name %>. Finaly, attempt to login by an expiring token in the cookie.\n def login_from_cookie \n <%= singular_name %> = cookies[:auth_token] && <%= class_name %>.find_authenticated_model_with_remember_token(cookies[:auth_token])\n if <%= singular_name %> && <%= singular_name %>.remember_token?\n <%= singular_name %>.remember_me\n cookies[:auth_token] = { :value => <%= singular_name %>.remember_token, :expires => <%= singular_name %>.remember_token_expires_at }\n self.current_<%= singular_name %> = <%= singular_name %>\n end\n end\n \n def reset_session\n session.data.each{|k,v| session.data.delete(k)}\n end\n\n private\n @@http_auth_headers = %w(Authorization HTTP_AUTHORIZATION X-HTTP_AUTHORIZATION X_HTTP_AUTHORIZATION REDIRECT_X_HTTP_AUTHORIZATION)\n\n # gets BASIC auth info\n def get_auth_data\n auth_key = @@http_auth_headers.detect { |h| request.env.has_key?(h) }\n auth_data = request.env[auth_key].to_s.split unless auth_key.blank?\n return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil] \n end\n end\nend",
"def authenticate\n auth_token = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n user = User.find_by(email: auth_params[:email])\n # HTTP-only cookie stored with refresh_token\n # Note - May be needed before launching production: SameSite: \"Strict\"\n # cookies.signed[:jwt] = {value: auth_token, httponly: true, same_site: :none, expires: 2.hours.from_now}\n response.set_header('Authorization', auth_token)\n json_response(user, :ok, user_options)\n # render json: user, include: user_options\n # json_response(message: \"Successfully authenticated.\" , user_role: user.role,user_id: user.id)\n end",
"def check_authentication_info(res, opts)\n\n return if no_digest_auth\n # not using digest authentication\n\n return unless @challenge\n # not yet authenticated\n\n authinfo = AuthInfo.new res\n @challenge.nonce = authinfo.nextnonce\n end",
"def authenticate_request\n if auth_token_expired?\n fail AuthenticationTimeoutError\n elsif !@current_user\n render json: { error: \"401\" }, status: :unauthorized\n end\n end",
"def authenticate\n\t\tauth_token =\n\t\t\tAuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n\t\tjson_response(auth_token: auth_token)\n\tend",
"def cache\n @cache[:user] ||= get 'user'\n end",
"def authenticate\n \n authenticate_token || render_unauthorized\n end",
"def profile cached_token=token\n uri = URI.parse(\"https://anypoint.mulesoft.com/accounts/api/me\")\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = true\n\n request = Net::HTTP::Get.new(uri.request_uri)\n request.add_field(\"Authorization\", \"Bearer #{cached_token}\")\n\n response = client.request(request)\n\n return JSON.parse(response.body)\n end",
"def from_authentication_data response\n load_attributes_from_response(response)\n end",
"def update_auth_header\n # cannot save object if model has invalid params\n # @resource should == current_user\n return unless @resource && @resource.valid? && @client_id\n\n # Generate new client_id with existing authentication\n @client_id = nil unless @used_auth_by_token\n\n if @used_auth_by_token &&\n @resource.try(:tokens).present? &&\n ENV['ACCESS_TOKEN_LIFETIME'].to_i > 0\n\n # Get the token we are working with before reload (a simultaneous request could alter the valid token)\n original_token = @resource.tokens[@client_id].try(:fetch, 'token')\n\n @resource.reload\n\n # should not append auth header if @resource related token was\n # cleared by sign out in the meantime.\n return if @resource.tokens[@client_id].nil?\n\n token_created_at = Time.zone.at(@resource.tokens[@client_id]['created_at'])\n\n # If the token has not expired or changed and this is not a batch request, return it as a valid token.\n if @request_started_at < token_created_at + Integer(ENV['ACCESS_TOKEN_LIFETIME']) &&\n original_token == @resource.tokens[@client_id]['token'] &&\n !is_batch_request?(@resource, @client_id)\n\n return response.headers.merge!(@resource.build_auth_header(@token, @client_id))\n end\n end\n\n super\n end",
"def auth\n Hash['type' => @auth_type,\n 'username' => @user,\n 'password' => @password]\n end",
"def twitter_auth_cache\n self.auth_profiles.where(provider: 'twitter').first\n end",
"def session\n refreshed = Requests::AuthSession.new(request)\n .fetch\n .as_model\n\n response.headers['Access-Control-Expose-Headers'] = Models::AuthToken::SESSION_HEADER_NAME\n response.headers[Models::AuthToken::SESSION_HEADER_NAME] = refreshed.session\n\n 204\n end",
"def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n # kindly refactor and add more keys to the response object when needed\n response = { \n status: Message.success,\n data: {\n token: auth_token\n } \n }\n json_response(response, 200)\n end",
"def temp_auth\n response = get \"authenticate/#{config['lims_default_user']}/#{config['lims_default_password']}\"\n\n @connection = OpenStruct.new(user: config['lims_default_user'], token: response['token'])\n end",
"def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_token)\n end",
"def authenticate\n auth_response =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_response[:token], user_name: auth_response[:user_name])\n end",
"def auth_token\n return regenerate_auth_token if expired?\n\n authentication.auth_token\n end",
"def auth\n build_response(\"token\") do\n connection.post do |req|\n req.headers.delete(\"Authorization\")\n req.url \"auth/\"\n req.body = { username: username, password: password }.to_json\n end\n end\n end",
"def password_auth\n\n service_response = AdminManagement::Login::PasswordAuth.new(\n params.merge(mfa_session_cookie_value: cookies.encrypted[GlobalConstant::Cookie.mfa_session_cookie_name.to_sym],\n ip_address: ip_address,\n browser_user_agent: http_user_agent)\n ).perform\n\n if service_response.success?\n # Set cookie\n set_cookie(\n GlobalConstant::Cookie.admin_cookie_name,\n service_response.data[:admin_auth_cookie_value],\n service_response.data[:admin_auth_cookie_value_expiry_time].from_now\n )\n\n if service_response.data[:mfa_session_cookie_value].present?\n set_cookie(\n GlobalConstant::Cookie.mfa_session_cookie_name,\n service_response.data[:mfa_session_cookie_value],\n GlobalConstant::Cookie.mfa_session_expiry.from_now,\n true\n )\n else\n delete_cookie(GlobalConstant::Cookie.mfa_session_cookie_name)\n end\n\n\n # Remove sensitive data\n service_response.data.delete(:admin_auth_cookie_value)\n service_response.data.delete(:admin_auth_cookie_value_expiry_time)\n service_response.data.delete(:mfa_session_cookie_value)\n end\n\n render_api_response(service_response)\n\n end",
"def mock_defective_auth_hash\n nil\n end",
"def authenticate\n user = User.find_by_email(auth_params[:email])\n return json_response({message: 'Invalid credentials'}, :unauthorized) if !user.present?\n user.last_login = Time.now\n user.save!\n auth_token = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n render json: { auth_token: auth_token}\n end",
"def fetch_response\n if cached_response\n if needs_revalidation?(cached_response)\n logger.info(\" Cache needs revalidation\")\n set_validation_headers!(cached_response)\n else\n # We're done!\n return cached_response\n end\n end\n\n response = perform!\n\n response = revalidate_cached_response(response) if cached_response && response.not_modified?\n response = follow_redirect(response) if should_be_redirected?(response)\n response = retry_with_auth(response) if needs_authorization?(response)\n\n raise UnsuccessfulHttpRequestError.new(self, response) if response.error?\n\n if cacheable?(response)\n store_in_cache(response)\n elsif invalidates_cache?\n invalidate_cache\n end\n\n return response\n end",
"def authentication\n {:username => @username, :password => @password}\n end",
"def auth_process\n\t\tif @auth_file.authorization.nil?\n \t\t\tmake_auth\n\t\telse\n\t\t\t@client.authorization = @auth_file.authorization\n\t\tend\n\tend",
"def authentication_hash=(_arg0); end",
"def authenticate_with_response\n render nothing: true, status: 401 if current_user.nil?\n end",
"def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_token)\n end",
"def authenticate\n authenticate_token || render_unauthorized\nend",
"def authenticate\n authenticated_user = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n response = { message: Message.logged_in, auth_token: authenticated_user[:auth_token], is_doctor: authenticated_user[:is_doctor], doctor_id: authenticated_user[:doctor_id], fullname: authenticated_user[:fullname], date_of_birth: authenticated_user[:date_of_birth] }\n json_response(response)\n end",
"def recreate_authentication_with_hash auth\n recreate_authentication auth[:provider], uid: auth[:uid] unless identity?(auth)\n self\n end",
"def complete_authentication(token)\n raise \"This object is no longer usable because its resources have been freed.\" if @cleaned_up\n\n # Nil token OK, just set it to empty string\n token = \"\" if token.nil?\n\n if token.include? \"Negotiate\"\n # If the Negotiate prefix is passed in, assume we are seeing \"Negotiate <token>\" and get the token.\n token = token.split(\" \").last\n end\n\n if token.include? B64_TOKEN_PREFIX\n # indicates base64 encoded token\n token = token.strip.unpack(\"m\")[0]\n end\n\n outputBuffer = SecurityBuffer.new\n result = SSPIResult.new(API::InitializeSecurityContext.call(@credentials.to_p, @context.to_p, nil,\n REQUEST_FLAGS, 0, SECURITY_NETWORK_DREP, SecurityBuffer.new(token).to_p, 0,\n @context.to_p,\n outputBuffer.to_p, @contextAttributes, TimeStamp.new.to_p))\n\n if result.ok? then\n @auth_successful = true\n return encode_token(outputBuffer.token)\n else\n raise \"Error: #{result.to_s}\"\n end\n ensure\n # need to make sure we don't clean up if we've already cleaned up.\n # XXX - clean up later since encrypt/decrypt needs this\n # clean_up unless @cleaned_up\n end",
"def get(resource)\n uri = URI.parse resource\n\n # If credentials were stored, use them. Otherwise do a normal get\n credentials = @cache.get_credentials\n if credentials.nil?\n response = @client.get resource\n else\n puts \"sending credentials: #{credentials.to_header}\"\n response = @client.get resource, :head => {'Authorization' => credentials.to_header}\n end\n # If response was 401, retry with authentication\n if response.http_status == '401' && !response['WWW_AUTHENTICATE'].nil?\n puts \"got challenge: #{response['WWW_AUTHENTICATE']}\"\n challenge = Challenge.from_header(response['WWW_AUTHENTICATE'])\n (stale = challenge.stale) rescue NoMethodError\n if stale\n username = credentials.username\n password = credentials.password\n else\n username, password = get_credentials_from_user\n end\n credentials = Credentials.from_challenge(challenge,\n :uri => resource, :username => username, :password => password, :method => 'GET'\n )\n puts \"sending credentials: #{credentials.to_header}\"\n @cache.set_credentials_for uri.path, credentials\n response = @client.get resource, :head => {'Authorization' => credentials.to_header}\n end\n # If the server sends authentication info use the information for the next request\n if response['AUTHENTICATION_INFO']\n puts \"got authentication-info: #{response['AUTHENTICATION_INFO']}\"\n auth_info = AuthenticationInfo.from_header(response['AUTHENTICATION_INFO'])\n @cache.update_usage_for uri.path, auth_info.h[:nextnonce]\n else\n @cache.update_usage_for uri.path\n end\n response\n end",
"def reauthenticate \n\t\t\tself.login(@email, @password)\n\t\tend",
"def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_token, config: get_current_configuration, provider: 'email')\n end",
"def cache_key(env)\n super(env) + env[:request_headers][Restforce::Middleware::Authorization::AUTH_HEADER].gsub(/\\s/, '')\n end",
"def authenticate!\n resource = mapping.to.where(:username => authentication_hash[:email]).first if authentication_hash\n resource ||= mapping.to.new if resource.nil?\n\n username = authenticate_against_ebay(authentication_hash[:email], password)\n\n if username\n resource.username = username\n resource.password = password\n resource.password_confirmation = password\n resource.save if resource.changed?\n end\n\n return fail(:invalid) unless username and resource\n\n if validate(resource) { not resource.nil? }\n success!(resource)\n end\n end",
"def respond\n if http_auth?\n http_auth\n else\n redirect\n end\n end",
"def respond\n if http_auth?\n http_auth\n else\n redirect\n end\n end",
"def auth_token\n self.auth_response[:auth_token]\n end",
"def authenticate!\n\t\t@current_user = AuthorizeApiRequest.call(request.headers).result\n\t\t# If unauthorized return an error to the front end\n\t\trender json: {error: 'Not Authorized'}, status: 401 unless @current_user\n\tend",
"def authenticate!\n\n # mapping comes from devise base class, \"mapping.to\" is the class of the model\n # being used for authentication, typically the class \"User\". This is set by using\n # the `devise` class method in that model\n klass = mapping.to\n\n if request.headers['HTTP_X_MY_API'].present?\n # the returned user object will be saved and serialised into the session\n user = klass.find_or_initialize_by_email(request.headers['HTTP_X_MY_API'])\n success! user\n end\n\n # if we wanted to stop other strategies from authenticating the user\n end",
"def get_responses_json_from_memory_cache\n Rails.cache.fetch(\"responses/#{self.id}\", expires_in: 12.hours) do\n if self.id == 1\n self.responses_json_obama_approval\n else\n self.responses_json\n end\n end\n end",
"def respond_to_challenge(request, response)\n authenticate_header = response['www-authenticate'].downcase\n authenticate_header.sub!(/^digest /, '')\n\n @authentication_params = authenticate_header.split(\", \").inject({}) { |h, field|\n key, value = field.split(\"=\")\n h[key] = value.gsub(/^\"|\"$/, '') # strip quotes.\n \n h\n }\n add_cookies!(request)\n authenticate_request!(request)\n request.each{|k,v| puts \"#{k}: #{v}\" }\n # Resend the request\n @client.request(request)\n end",
"def authentication_succeed(oidresp)\n end",
"def auth\n if (!@auth || !@auth[:username]) && @headers['Authorization'] &&\n @headers['Authorization'] !~ /^OAuth\\s/\n\n str = Base64.decode64 @headers['Authorization'].split[1]\n username, password = str.split(\":\", 2)\n @auth = {\n :username => username,\n :password => password\n }.merge(@auth || {})\n end\n\n @auth\n end",
"def challenge(req, res)\n res[@response_field] = \"#{@auth_scheme} realm=\\\"#{@realm}\\\"\"\n raise @auth_exception\n end",
"def set_session_details\n session = Authentication::Session.active_token_session(auth_token)\n session && set_account_cache(session.account, auth_token)\n end",
"def get_auth_response(uri)\n url = BASE_URL + uri\n @uri = URI.parse(url)\n build_request()\n req = Net::HTTP::Get.new(@uri.request_uri)\n response = @http.request(req)\n\n return response\n end",
"def authenticate!\n user = Oath::Lockdown::Rememberable.serialize_from_cookie(remember_cookie)\n\n if user\n success!(user)\n else\n cookies.delete(remember_key)\n pass\n end\n end",
"def auth_hash\n @auth_hash ||= request.env['omniauth.auth']\n end",
"def cache_key(env)\n super(env) + env[:request_headers][Force::Middleware::Authorization::AUTH_HEADER].gsub(/\\s/, '')\n end",
"def omniauth\n Hashie::Mash.new auth_hash\n end",
"def authenticate_request\n begin\n uid = JWT.decode(request.headers['Authorization'], Rails.application.secrets.secret_key_base)[0]['uid']\n @current_user = User.find_by(uid: uid)\n rescue JWT::DecodeError\n render json: 'authentication failed', status: 401\n end\n end",
"def check_access\n @response = Response.new\n \n check_hash()\n \n if @response.error?\n access_denied\n return\n end\n end",
"def authenticate_request!\n\t\t# unless is if in reverse. If user_id_in_token == false then render error\n\t unless user_id_in_token?\n\t render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n\t return\n\t end\n\t @current_user = User.find(auth_token[:user_id])\n\trescue JWT::VerificationError, JWT::DecodeError\n\t render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n\tend",
"def initialize_auth\n @conf[:use_user_pool_cache] = false\n end",
"def auth_hash\n @auth_hash ||= request.env['omniauth.auth']\n end",
"def http_cache\n response.headers['Cache-Control'] = 'public, max-age=300'\n end",
"def process_auth str\n if @state.include?(:auth)\n send_data \"503 auth already issued\\r\\n\"\n elsif str =~ /\\APLAIN\\s?/i\n if $'.length == 0\n # we got a partial response, so let the client know to send the rest\n @state << :auth_incomplete\n send_data(\"334 \\r\\n\")\n else\n # we got the initial response, so go ahead & process it\n process_auth_line($')\n end\n #elsif str =~ /\\ALOGIN\\s+/i\n else\n send_data \"504 auth mechanism not available\\r\\n\"\n end\n end",
"def authenticate\n \n authenticate_or_request_with_http_token do |token|\n begin\n decoded = decode(token)\n @current_user = User.find_by(id: decoded[0][\"user_id\"]) \n \n rescue JWT::DecodeError\n render json: {authorized: false }, status: 401 \n end\n end \n end",
"def return_handshake\n YoolkAuth::ConnectionMock::HTTPResponseMock.new(yoolk_auth_config.merge(logged_in: yoolk_auth_logged_in?).to_json, yoolk_auth_handshake_response_code)\n end",
"def token\n Rails.cache.read(AUTH_TOKEN_CACHE_KEY) || retrieve_token!\n end",
"def process_auth str\n if respond_to?(:authenticate)\n if @state.include?(:auth)\n reply 503, \"auth already issued\"\n elsif str =~ /\\APLAIN\\s?/i\n if $'.length == 0\n # we got a partial response, so let the client know to send the rest\n # There is a common misconception that the data has to be sent with the AUTH command\n @state << :auth_plain_incomplete\n reply 334, \"\"\n else\n # we got the initial response, so go ahead & process it\n process_auth_plain_line($')\n end\n elsif str =~ /\\ALOGIN\\s?/i\n if $'.length == 0\n @state << :auth_login_incomplete\n reply 334, \"VXNlcm5hbWU6\" # 'Username:' in Base64\n else\n process_auth_login_line($')\n end\n #elsif str =~ /\\ACRAM-MD5/i\n else\n reply 504, \"auth mechanism not available\"\n end\n else\n process_unknown\n end\n end",
"def authenticate_user!\n # check for API/signed requests\n if request.headers.env[\"HTTP_AUTHORIZATION\"] || request.headers.env[\"Authorization\"] then\n agent = Agent.where(:access_key => ApiAuth.access_id(request)).first\n begin\n if not(agent and ApiAuth.authentic?(request, agent.secret_key)) then\n return render :text => Bixby::JsonResponse.new(\"fail\", \"authentication failed\", nil, 401).to_json, :status => 401\n end\n rescue ApiAuth::ApiAuthError => ex\n return render :text => Bixby::JsonResponse.new(\"fail\", ex.message, nil, 401).to_json, :status => 401\n end\n @current_user = agent # TODO hrm.. hack much?\n return false\n end\n\n # authenticate a request from a browser session\n super\n end",
"def authenticate_request!\n # raise request.inspect\n #Rails.logger.info \"Headers #{request.headers.inspect}\"\n #Rails.logger.info \"Device Id: #{request.headers[\"HTTP_AUTH_TOKEN\"]}, Hello #{request.headers[\"HTTP_DEVICE_ID\"]}\"\n\n # puts request.headers[\"HTTP_AUTH_TOKEN\"].inspect\n # puts request.headers[\"HTTP_DEVICE_TOKEN\"].inspect\n\n\n if request.headers[\"HTTP_DEVICE_ID\"].present?\n client_id = request.headers[\"HTTP_DEVICE_ID\"]\n token = request.headers[\"HTTP_AUTH_TOKEN\"]\n device_type = request.headers[\"HTTP_DEVICE_TYPE\"]\n puts \"--------------------------------------------------------------\"\n # Rails.logger.info \"#{request.headers[\"HTTP_AUTH_TOKEN\"]}\"\n refresh_token_hash = $redis.hgetall(token)\n Rails.logger.info\"client_id==============#{client_id}\"\n Rails.logger.info \"token=================#{token}\"\n Rails.logger.info \"device_type===============#{device_type}\"\n Rails.logger.info \"refresh_token_hash ===========#{refresh_token_hash}\"\n\n if refresh_token_hash && client_id && device_type && refresh_token_hash[\"client_id\"] == client_id && refresh_token_hash[\"device_type\"] == device_type\n user = User.find_by_id(refresh_token_hash[\"user_id\"])\n @current_user = user\n # role = user.role.name.downcase\n # user = { id: user.id, email: user.email, avatar: (user.photos.last.present? ? {url: user.photos.last.profile_medium_url,profile_url: user.photos.last.profile_thumb_url} : {url: \"\",profile_url: \"\"}),full_name: user.full_name,last_sign_in_at: user.last_sign_in_at }\n response_token = { :user => user, :role=> role }\n session[:response_token] = response_token\n return session[:response_token]\n # Rails.logger.info \"mobile request==============#{device_type}====== #{Time.zone.now}====================================\"\n else\n render json: { error: \"Session expired!\" }\n end\n\n\n\n # if request.headers[\"HTTP_DEVICE_ID\"].present?\n\n # secret_token = SecretToken.where(token: request.headers[\"HTTP_AUTH_TOKEN\"], client_id: request.headers[\"HTTP_DEVICE_ID\"],device_type: request.headers[\"HTTP_DEVICE_TYPE\"]).first\n # if secret_token.present?\n # user = secret_token.user\n # @current_user = user\n # response_token = { :success => true, :user => user, :role => user.user_role }\n # session[:response_token] = response_token\n # else\n # render json: { error: \"Session expired!\" }\n # end\n else\n\n Rails.logger.info \"web request======================#{request.headers[\"HTTP_DEVICE_ID\"]}======== #{Time.zone.now}==========================\"\n begin\n puts request.headers[\"HTTP_REFRESH_TOKEN\"]\n if request.headers[\"HTTP_REFRESH_TOKEN\"].present?\n\n refresh_token = request.headers[\"HTTP_REFRESH_TOKEN\"]\n client_id = request.headers[\"REMOTE_ADDR\"]\n # puts \"-------------------------------------------------#{request.headers[\"HTTP_REFRESH_TOKEN\"]}-------------\"\n secret_token = $redis.hgetall(request.headers[\"HTTP_REFRESH_TOKEN\"])\n # secret_token = SecretToken.where(token: refresh_token, client_id: client_id).first\n puts secret_token.inspect\n\n\n if secret_token.present?\n # user = secret_token.user\n\n user = User.find_by_id(secret_token[\"user_id\"])\n refresh_token = Digest::MD5.hexdigest(Time.now.to_s + user.email)\n response_token = authentication_payload(user, refresh_token)\n $redis.del(request.headers[\"HTTP_REFRESH_TOKEN\"])\n $redis.srem(user.id, request.headers[\"HTTP_REFRESH_TOKEN\"])\n $redis.hmset(response_token[:refresh_token], \"client_id\", request.headers[\"REMOTE_ADDR\"], \"user_id\", user.id,\"device_type\",\n request.headers[\"HTTP_USER_AGENT\"],\"is_mobile\", false)\n $redis.expire refresh_token, 1800\n $redis.sadd(user.id, refresh_token)\n $redis.hset(response_token[:auth_token].split(\".\").last, \"client_id\", request.headers[\"REMOTE_ADDR\"])\n # secret_token.update token: refresh_token, client_id: request.headers[\"REMOTE_ADDR\"], device_type: request.headers[\"HTTP_USER_AGENT\"], is_mobile: false\n session[:response_token] = response_token\n @current_user = user\n session[:response_token]\n else\n render json: { error: \"Session expired!\" }\n end\n else\n @current_user = User.find(decoded_auth_token[:user_id])\n if @current_user.present? && !@current_user.active?\n render json: { error: \"Session expired!\" , message: \"account is suspended\" }\n else\n @current_user\n end\n\n end\n\n # fail NotAuthenticatedError unless user_id_included_in_auth_token?\n\n rescue JWT::ExpiredSignature\n $redis.hdel(request.headers[\"HTTP_AUTH_TOKEN\"].split(\".\").last, \"client_id\")\n raise AuthenticationTimeoutError\n rescue JWT::VerificationError, JWT::DecodeError\n raise NotAuthenticatedError\n end\n end\n end",
"def initialize cache = nil\n if cache.is_a? String\n @cache = FileCache.new(cache)\n elsif cache\n @cache = cache\n else\n @cache = NilCache.new\n end\n\n # initialize default #when_auth\n @get_auth_details = lambda do |abs_url, realm|\n if @user and @pass\n [@user, @pass]\n else\n nil\n end\n end\n end",
"def authenticate_request\n service_response = UserManagement::VerifyCookie.new(\n client: params[:client],\n cookie_value: cookies[GlobalConstant::Cookie.user_cookie_name.to_sym],\n browser_user_agent: http_user_agent\n ).perform\n\n if service_response.success?\n # Update Cookie, if required\n extended_cookie_value = service_response.data[:extended_cookie_value]\n set_cookie(\n GlobalConstant::Cookie.user_cookie_name,\n extended_cookie_value,\n GlobalConstant::Cookie.user_expiry.from_now\n ) if extended_cookie_value.present?\n\n # Set user id\n params[:user_id] = service_response.data[:user_id]\n\n # Remove sensitive data\n service_response.data = {}\n else\n # Clear cookie\n delete_cookie(GlobalConstant::Cookie.user_cookie_name)\n render_api_response(service_response)\n end\n end",
"def authenticate\n @retval=Hash.new\n unless params[:api_username].blank?\n unless params[:api_password].blank?\n @employee = EmployeAccount.find_by_employe_username_and_password(params[:api_username],params[:api_password], :conditions => \"status='unblock'\")\n if @employee\n return true\n else\n @retval['status'] = false\n @retval['message'] = 'invalid api credentials'\n end\n else\n @retval['status'] = false\n @retval['message'] = 'api password is required'\n end\n else\n @retval['status'] = false\n @retval['message'] = 'api username is required'\n end\n render :xml => @retval.to_xml({:root=>'response',:dasherize =>false})\n end",
"def cached(key)\n return nil unless cache?(key)\n auth_objects_cache[key]\n end",
"def successfully_authenticated\n unless self.ok == true\n self.errors.add(:ok, \"Response must include ok true!\")\n end\n end",
"def client_redirect_auth\n\t\t# Since the :restrict_access method is called whenever this method is called, that will take care of unauthenticated users (will return a 404 before this method is even run)\n\t\tapi_key = ApiKey.find_by_access_token(params[:access_token])\n\t\tusr = User.find(api_key.user_id)\n\t\trole = usr.role\n\t\ttimeUntilExp = ''\n\n\t\tmsg = \"UNAUTHORIZED\"\n\t\tif params[:authorize]\n\t\t\tif params[:role] == usr.role\n\t\t\t\t# Roles match and user is authorized\n\t\t\t\tmsg = \"AUTHORIZED\"\n\t\t\tend\n\t\telse\n\t\t\t# User is authenticated (logged in) but is not authorized\n\t\t\tmsg = \"AUTHENTICATED\"\n\t\tend\n\n\t\tif api_key\n\t\t\tputs \"WHY DOESNT THIS WORK? #{distance_of_time_in_words(Time.now, api_key.expires_at)}\"\n\t\t\tputs \"SECONDS #{((api_key.expires_at - Time.now).seconds).round}\"\n\t\t\ttimeUntilExp = ((api_key.expires_at - Time.now).seconds).round\n\t\tend\n\t\trespond_to do |format|\n \t\tformat.json { render :json => { :msg => msg, :role => role, :timeUntilExp => timeUntilExp } } \t\t\n \t\tend\n\tend"
] | [
"0.6387723",
"0.63305163",
"0.6312613",
"0.61748326",
"0.6147414",
"0.6122541",
"0.6114287",
"0.6111199",
"0.6104289",
"0.6092938",
"0.6068579",
"0.6054741",
"0.60148",
"0.600937",
"0.6008093",
"0.59659064",
"0.593324",
"0.5898481",
"0.5878535",
"0.5873972",
"0.5870065",
"0.5863201",
"0.58571607",
"0.5832829",
"0.5816652",
"0.5813772",
"0.5811192",
"0.58110976",
"0.5802461",
"0.5799458",
"0.5777668",
"0.57760084",
"0.5773514",
"0.5767589",
"0.57612187",
"0.5747407",
"0.57470155",
"0.5743781",
"0.5727238",
"0.5720018",
"0.57165724",
"0.5715598",
"0.57049763",
"0.5704913",
"0.56998485",
"0.56920266",
"0.56879234",
"0.568295",
"0.5677561",
"0.5677143",
"0.5672655",
"0.5668282",
"0.5666393",
"0.56581986",
"0.5649155",
"0.5649105",
"0.5645579",
"0.56428015",
"0.5634052",
"0.5634052",
"0.56160635",
"0.5610917",
"0.5600743",
"0.5600182",
"0.5594799",
"0.5594675",
"0.5594675",
"0.5593095",
"0.5592353",
"0.55838996",
"0.5553477",
"0.5552652",
"0.55476606",
"0.554726",
"0.554572",
"0.5540008",
"0.55399185",
"0.55393004",
"0.5537979",
"0.55349654",
"0.5530222",
"0.5529496",
"0.552525",
"0.55249333",
"0.5524186",
"0.5523157",
"0.5521274",
"0.55190194",
"0.55140513",
"0.5510979",
"0.5505787",
"0.5503626",
"0.5502935",
"0.55022985",
"0.55003464",
"0.54954314",
"0.54924655",
"0.54884243",
"0.5483581",
"0.5482034"
] | 0.7530714 | 0 |
This is the auth token provided by Rackspace after a successful authentication | def auth_token
self.auth_response[:auth_token]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth_token\n @@auth_token\n end",
"def auth_token\n @auth_token ||= request.headers.fetch('Authorization', '').split(' ').last\n end",
"def authentication_token\n generate_token(:authentication_token)\n end",
"def auth_token\n\t\trequest.headers['X-AUTH-TOKEN']\n\tend",
"def auth_token\n auth_token_for(DEFAULT_AUTH_TOKEN_KEY)\n end",
"def auth_token\n request.env['HTTP_X_GEOTIX_AUTH_TOKEN']\n end",
"def token\n authenticated\n end",
"def http_auth_token\n request.headers['Authorization']&.split(' ')&.last\n end",
"def auth_token\n Auth.decode(header_token)\n end",
"def auth_token\n @auth_token ||= ActionController::HttpAuthentication::Token.token_and_options(request)\n end",
"def auth_header\n { :token => @token, :seq => @seqid }\n end",
"def http_auth_token\n @http_auth_token ||= if request.headers['Authorization'].present?\n request.headers['Authorization'].split(' ').last\n end\n end",
"def auth_token\n TokenProvider.issue_token(\n first_name: object.first_name,\n last_name: object.last_name,\n username: object.username,\n user_id: object.id,\n role: object.role\n )\n end",
"def token\n request.headers['Authorization']\n end",
"def auth_token\n curtime = Time.now.utc.strftime '%Y%m%d%H' # yyyymmddhh. hh is 24 hour 0 padded\n token = \"#{@user}-#{@pass}-#{curtime}-#{@service_tag}\"\n puts \"----> Generated auth token: #{token}\"\n Digest::MD5.hexdigest(token).upcase\n end",
"def http_auth_token\n @http_auth_token ||= if request.headers['Authorization'].present?\n request.headers['Authorization'].split(' ').last\n end\n end",
"def authentication_token\n if env && env['HTTP_AUTHORIZATION']\n env['HTTP_AUTHORIZATION'].split(\" \").last\n end\n end",
"def token\n request.headers[\"Authorization\"]\n end",
"def auth_token\n return regenerate_auth_token if expired?\n\n authentication.auth_token\n end",
"def authorization_token\n @authorization_token ||= request.headers['Authorization']&.split(' ')&.last\n end",
"def authentication_token\n @authentication_token ||= authorization_header.gsub(BEARER_PATTERN, '')\n end",
"def token(auth_code = T.unsafe(nil), headers = T.unsafe(nil)); end",
"def http_auth_hash; end",
"def token_auth\n Hash['type' => 'token',\n 'token' => @token,]\n end",
"def authentication_token\n @authentication_token ||= JWT.encode(payload, secret, algorithm)\n end",
"def token\n authenticate_username_password || render_unauthorized\n end",
"def get_authentication_header\n acquire_token if token_expired\n \"#{token_type} #{token}\"\n end",
"def get_token\n request.headers[\"Authorization\"]\n end",
"def auth_token(auth)\n validate_auth(auth, %i[token])\n auth[:token]\n end",
"def http_token\n @http_token ||= if request.headers['Authorization'].present?\n request.headers['Authorization'].split(' ').last\n end\n end",
"def http_auth_token\n\n @http_auth_token ||= if request.headers.present?\n request.headers[\"HTTP_AUTH_TOKEN\"]\n end\n end",
"def retrieve_auth_token\n http = Net::HTTP.new(auth_endpoint.host, auth_endpoint.port)\n\n request = Net::HTTP::Post.new(auth_endpoint.request_uri)\n\n request.basic_auth(\n TodoableApi.configuration.username,\n TodoableApi.configuration.password\n )\n\n handle_auth_response(http.request(request))\n end",
"def auth\n build_response(\"token\") do\n connection.post do |req|\n req.headers.delete(\"Authorization\")\n req.url \"auth/\"\n req.body = { username: username, password: password }.to_json\n end\n end\n end",
"def token_auth(*args, &block); end",
"def authentication_token\n @authentication_token ||= OohAuth::Token.first(:token_key=>token)\n end",
"def get_authentication_header\n acquire_token if token_expired?\n \"#{token_type} #{token}\"\n end",
"def auth_param; end",
"def auth_header\n @token.empty? ? '' : \"cobSession=#{@cobrand_session.token},userSession=#{@token}\"\n end",
"def get_authentication_header\n \"#{token_type} #{token}\"\n end",
"def generate_auth_token\n self.auth_token = SecureRandom.hex\n end",
"def header_token\n request.headers['Authorization'].split(' ').last\n end",
"def auth_token \n JWT.encode({id: self.id}, \"9885ea7895518eaf88c4a8a2e8f62c82\")\n end",
"def generate_authentication_token\n self.auth_token = User.new_token\n\t\t\tself.auth_expires_at = Time.now + 240.hours\n\tend",
"def token\n authenticate_username_password || render_unauthorized\n end",
"def grab_auth_token\n return @authToken if @authToken\n home_page = get_page(HOME_URL)\n @authToken = home_page.forms.first['authenticity_token']\n STDERR.puts \"FOUND AUTH TOKEN #{@authToken}\" if DEBUG\n end",
"def authToken(secretkey)\n # get 'authToken', {secretkey: secretkey} { |x| x['authToken'] }\n new_auth_token\n end",
"def token\n configuration.token\n end",
"def auth_token\n JWT.encode({ id: self.id }, '65bc368fbc69306')\n end",
"def get_token\n LastFM.get( \"auth.getToken\", {}, :secure )\n end",
"def auth_token\n AuthToken.new payload: { sub: user.id }\n end",
"def api_token\n if @token.nil?\n raise ArgumentError, 'username is missing' if username.blank?\n raise ArgumentError, 'password is missing' if password.blank?\n response = connection.post do |req|\n req.url '/Authentication/V2.0'\n req.headers['x-dnb-user'] = username\n req.headers['x-dnb-pwd'] = password\n end\n @token = response.headers['Authorization']\n end\n @token\n end",
"def make_auth_token\n Carto::Common::EncryptionService.make_token(length: 64)\n end",
"def auth(value); end",
"def http_auth_token\n auth_token = request.env[\"HTTP_AUTHORIZATION\"]\n auth_token.split(\" \").last if auth_token.present? && auth_token.split(\" \").first.downcase == \"bearer\"\n end",
"def authorization\n @token.nil? ? nil : Base64.encode64(@key + ':' + @token).strip\n end",
"def token(request)\n end",
"def token\r\n bearer = request.headers[\"HTTP_AUTHORIZATION\"]\r\n\r\n # allows our tests to pass\r\n bearer ||= request.headers[\"rack.session\"].try(:[], 'Authorization')\r\n\r\n if bearer.present?\r\n bearer.split.last\r\n else\r\n nil\r\n end\r\n end",
"def token\n Rails.cache.read(AUTH_TOKEN_CACHE_KEY) || retrieve_token!\n end",
"def generate_auth_token\n\t token = SecureRandom.hex\n\t #self.update_columns(token_key: token)\n\t token\n\t end",
"def auth_header\n\t\t# { Authorization: 'Bearer <token>' }\n\t\trequest.headers['Authorization']\n\tend",
"def token\n bearer = request.headers[\"HTTP_AUTHORIZATION\"]\n\n # allows our tests to pass\n bearer ||= request.headers[\"rack.session\"].try(:[], 'Authorization')\n\n if bearer.present?\n bearer.split.last\n else\n nil\n end\n end",
"def token\n bearer = request.headers[\"HTTP_AUTHORIZATION\"]\n\n # allows our tests to pass\n bearer ||= request.headers[\"rack.session\"].try(:[], 'Authorization')\n\n if bearer.present?\n bearer.split.last\n else\n nil\n end\n end",
"def auth_token\n response_hash[:ebay_auth_token]\n end",
"def auth_token_param\n params[:auth_token]\n end",
"def set_auth_token(token)\n @auth_token = token.to_s\n end",
"def create_auth_token(key)\n\t\tself.auth_token = Digest::SHA1.hexdigest(\"#{random_string}--#{Time.now}---#{key}\")\n\tend",
"def authenticate\n raise Rackspace::NotInitialized unless self.initialized?\n headers = RestClient::Request.execute(:method => :get, :url => \"#{AUTH_URL}/#{self.api_version}\", :headers => {\"X-Auth-User\" => self.api_user, \"X-Auth-Key\" => self.api_key}, :raw_response => true).headers\n {:auth_token => headers[:x_auth_token], :storage_url => headers[:x_storage_url], :server_management_url => headers[:x_server_management_url], :cdn_management_url => headers[:x_cdn_management_url]}\n end",
"def set_auth_token\n return if auth_token.present?\n self.auth_token = generate_auth_token\n end",
"def auth_code\n @connection.auth_code\n end",
"def auth_token_for(key)\n @username_auth_tokens[secure_auth_token_key(key)]\n end",
"def auth_header\n # { Authorization: 'Bearer <token>' }\n request.headers['Authorization']\n end",
"def bearer_token\n \"Bearer #{verification_token}\"\n end",
"def twilio_token\n capability = Twilio::Util::Capability.new ACCOUNT_SID, AUTH_TOKEN\n capability.allow_client_outgoing APP_SID\n capability.allow_client_incoming DEFAULT_CLIENT\n self.token = capability.generate\n end",
"def token\n client.token if client\n end",
"def get_token\n session[:token] if authorized?\n end",
"def http_auth_header\n\t \tif headers['Authorization'].present?\n\t \t\treturn headers['Authorization'].split(' ').last\n\t \tend\n\t \traise MissingToken.new(message:\"Missing token. Please provide a security token.\")\n\tend",
"def get_current_token\n if request.headers['Authorization'].present?\n return request.headers['Authorization'].split(' ').last\n end\n raise(ExceptionHandler::MissingToken, Message.missing_token)\n end",
"def build_auth_header\n \"BoxAuth api_key=#{@api_key}&auth_token=#{@auth_token}\"\n end",
"def token_auth_hash\n request.env['devise.token_options'] = auth_token.last\n { authentication_keys.first => auth_token.first }\n end",
"def token\n if request.headers[\"Authorization\"].present?\n if !login_from_authorization(request.headers['Authorization'].split(\" \")[1])\n response.set_header('WWW-Authenticate', \"Basic realm=\\\"red\\\"\")\n render json: {\"errors\":[{\"code\":\"UNAUTHORIZED\"}]} , status: 401\n return\n end\n else\n render json: {}, status: 401\n return\n end\n\n token = Portus::JwtToken.new(params[:account], params[:service], authorize_scopes)\n logger.tagged(\"jwt_token\", \"claim\") { logger.debug token.claim }\n render json: token.encoded_hash\n end",
"def connect!\n retrieve_auth_token unless connected?\n auth_token[:token]\n end",
"def token\n @token ||= \"%x-%s\" % [ Time.now.to_i, SecureRandom::hex(4) ]\n end",
"def auth_header\n request.headers['Authorization']\n end",
"def token_secret; end",
"def token_secret; end",
"def token_secret; end",
"def token\n unless defined?(@token)\n @token = {\n 'id' => self.catalog['token']['id'],\n 'expires' => Time.parse(self.catalog['token']['expires'])\n }\n @token['tenant'] = self.catalog['token']['tenant']['id'] if self.catalog['token']['tenant']\n end\n @token\n end",
"def demo_auth_token\n demo_account = Account.find_by_subdomain('demo')\n demo_user = demo_account.employees.find_by_user_name('demo.user')\n demo_user.ensure_authentication_token!\n demo_user.authentication_token\n end",
"def authentication_token\n object.authentication_token if !current_user || object.id == current_user.id\n end",
"def access_token; self; end",
"def bearer_token\n \"Bearer #{token}\"\n end",
"def token_hash(auth_code = T.unsafe(nil), headers = T.unsafe(nil)); end",
"def auth\n {}\n end",
"def authenticate\n token = CrownAuthenticate.new().token\nend",
"def aquire_token\n token_data = server.call(\"acquire_token\", @config['account_code'], @config['password'], @config['provider_key'])\n status = token_data[0]\n @token = token_data[1]\n if (is_error(status)) \n error_message = decode_error(status)\n raise \"Unable to aquire token. Reason: #{error_message}\"\n end\n @token\n end",
"def token; config[:token]; end",
"def ensure_authentication_token\n self.authentication_token ||= generate_authentication_token\n end",
"def generate_auth_token\n token = SecureRandom.hex\n self.update_columns(auth_token: token)\n token\n end",
"def auth\n { \"username\" => @username }\n end",
"def auth\n { \"Authorization\" => \"Bearer #{auth_token}\" }\n end"
] | [
"0.7818504",
"0.7591694",
"0.75749207",
"0.7430305",
"0.73680997",
"0.73346734",
"0.7299858",
"0.72879374",
"0.72694427",
"0.7249586",
"0.72470814",
"0.7172336",
"0.7171656",
"0.7168374",
"0.71476907",
"0.71431357",
"0.714131",
"0.71393925",
"0.71087384",
"0.70409703",
"0.70338064",
"0.69414943",
"0.6934146",
"0.6928498",
"0.6905294",
"0.689447",
"0.6882263",
"0.6872737",
"0.6870213",
"0.6854185",
"0.68518096",
"0.6832603",
"0.68266207",
"0.6823041",
"0.6815395",
"0.6811188",
"0.6803439",
"0.68012947",
"0.67849565",
"0.67697513",
"0.6765197",
"0.6757937",
"0.67236745",
"0.6710867",
"0.6709097",
"0.6706092",
"0.669248",
"0.66899186",
"0.668153",
"0.6663751",
"0.66586125",
"0.6653782",
"0.6649554",
"0.664372",
"0.6630815",
"0.6621542",
"0.6613273",
"0.661271",
"0.6589363",
"0.65739673",
"0.65673",
"0.65673",
"0.6554512",
"0.65536624",
"0.65474665",
"0.653741",
"0.6537319",
"0.65297186",
"0.65223354",
"0.6504036",
"0.64878845",
"0.6463183",
"0.64617926",
"0.6454161",
"0.64492756",
"0.64492166",
"0.6447526",
"0.6442313",
"0.6429874",
"0.64226717",
"0.64176834",
"0.6413765",
"0.6413697",
"0.6411828",
"0.6411828",
"0.6411828",
"0.64110804",
"0.6410679",
"0.6405847",
"0.6401803",
"0.6392082",
"0.63866496",
"0.63858813",
"0.6384443",
"0.6380226",
"0.6375907",
"0.63754135",
"0.63567966",
"0.63564074",
"0.6355631"
] | 0.7663875 | 1 |
This returns the root URL for Cloud Files API queries (not yet implemented) | def storage_url
self.auth_response[:storage_url]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url; \"file:#{@root}\"; end",
"def url\n host = @uploader.ucloud_cdn_host || @uploader.ucloud_bucket_host\n return nil unless host\n [host, @path].join(\"/\")\n end",
"def root_url\n '.'\n end",
"def directory_uri\n template = Addressable::Template.new(\n \"https://{host}/discovery/v1/apis\"\n )\n return template.expand({\"host\" => self.host})\n end",
"def upload_url\n _get(\"/files/upload_url\") { |json| json }\n end",
"def root_path\n Pathname.new(upload_path_value).join(search_directory)\n end",
"def root_url\n @response.env[:url].to_s if @response\n end",
"def root_uri_path\n @options[:root_uri_path]\n end",
"def root_url_path\r\n root_url.to_s.gsub(/^:.+:\\d*/, '')\r\n end",
"def root_url\n url '/'\n end",
"def api_root_url path_info, query = {}\n root_url :api, path_info, query\n end",
"def url\n URL(@site.url).join(attributes[\"RootFolder\"]).to_s\n # # Dirty. Used to use RootFolder, but if you get the data from the bulk calls, RootFolder is the empty\n # # string rather than what it should be. That's what you get with web services as an afterthought I guess.\n # view_url = ::File.dirname(attributes[\"DefaultViewUrl\"])\n # result = URL(@site.url).join(view_url).to_s\n # if ::File.basename(result) == \"Forms\" and dir = ::File.dirname(result) and dir.length > @site.url.length\n # result = dir\n # end\n # result\n end",
"def base_uri\n ary = contents_uri.to_s.split(\"/\")\n ary.pop if ary[-1].blank?\n ary.pop\n ary.join(\"/\") + \"/\"\n end",
"def base_url\n File.join(host, path)\n end",
"def root_uri\n uri = URI.parse request.url\n uri.path = \"\"\n uri.query = nil\n uri.to_s\n end",
"def base_request_path\n Merb.dir_for(:public) / slice_url(:external_delete_all)\n end",
"def url\n return nil unless @uploader.upyun_bucket_host\n\n [@uploader.upyun_bucket_host, @path].join(\"/\")\n end",
"def path\n '/c/document_library/get_file?folderId=%i&name=%s' % [self.folderid, self.name]\n end",
"def uri\n params = {\n center: location,\n size: size,\n zoom: zoom,\n format: file_format,\n sensor: sensor.to_s\n }\n Addressable::URI.parse(api_endpoint).tap do |uri|\n uri.query_values = params\n end.to_s\n end",
"def root_url\n \"#{@env['rack.url_scheme']}://#{@env['HTTP_HOST']}\"\n end",
"def response_uri(file)\n file.base_uri\n end",
"def url\n ::File.join \"/\", path.to_s\n end",
"def path_root\n base_uri ? base_uri : path_to( '/' )\n end",
"def base_request_path\n Merb.dir_for(:public) / slice_url(:images_delete_all)\n end",
"def api_root\n root_url << '/api'\n end",
"def url\n storage.url_for(path_with_query)\n end",
"def root_url(opts={})\n \"#{opts[:protocol] || @protocol}://#{opts[:domain] || @domain}\"\n end",
"def auth_url\n CloudFiles.const_get(\"AUTH_#{self.auth_location.upcase}\")\n end",
"def base_url\n GlobalConstant::Base.cms[:url] + \"api/preview/\"\n end",
"def base_url\n URI::HTTPS.build(host: @server, port: @port, path: @api)\n end",
"def file_url\n resource.send(mount_point).url\n end",
"def url\n [\"http://\" + @uploader.couch_host + \":\" + @uploader.couch_port, model.database.name , model.id, @path].join(\"/\")\n end",
"def base_url(operation = nil)\n index = server_operation_index.fetch(operation, server_index)\n return \"#{scheme}://#{[host, base_path].join('/').gsub(/\\/+/, '/')}\".sub(/\\/+\\z/, '') if index == nil\n\n server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])\n end",
"def base_request_path\n Merb.dir_for(:public) / slice_url(:textim_delete_all)\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def server_image_url(filename)\n uri = \"#{@api_url}/#{@project_id}/images/get_upload_url?filename=#{filename}&access_token=#{@access_token}\"\n get uri\n end",
"def solr_root\n url = URI.parse(search_engine_url)\n host = url.scheme + '://' + url.host\n if url.port\n host += ':' + url.port.to_s\n end\n host\n end",
"def flickr_url\n get_url(:flickr)\n end",
"def api_url\n base_url.concat api_query_parameter\n end",
"def api_url\n base_url.concat api_query_parameter\n end",
"def url\n File.join(server.url, path)\n end",
"def base_url\n @url.to_s.split('?').first\n end",
"def root_file_path; end",
"def url\n URI.parse(endpoint).join(path.to_s).to_s\n end",
"def base_url(operation = nil)\n index = server_operation_index.fetch(operation.to_sym, server_index)\n return \"#{scheme}://#{[host, base_path].join('/').gsub(/\\/+/, '/')}\".sub(/\\/+\\z/, '') if index == nil\n\n server_url(index, server_operation_variables.fetch(operation.to_sym, server_variables), operation_server_settings[operation.to_sym])\n end",
"def core_url\n @blacklight_context.default_index.connection.uri.to_s.gsub(%r{^.*\\/solr}, '/solr')\n end",
"def urlpath\n path = cleanpath\n path.blank? ? '/root' : '/' + path\n end",
"def server_url\n @uri\n end",
"def url\n [ Configuration.url, @path ].join\n end",
"def compose_url(url)\n abort \"Invalid URL: #{url}\" unless validate_url(url)\n\n query = {}\n query['map'] = 'true' if options['map']\n query['api_key'] = options['key'] if options['key']\n query['compression'] = options['compress'] if options['compress']\n\n uri = URI(url)\n uri.path = '/files'\n uri.query = URI.encode_www_form(query)\n uri.to_s\n end",
"def rest_url\n # Transifex API doc says always use a trailing slash even if the last element is a slug\n build_nodes_url.to_s + '/'\n end",
"def redmine_url\n rootUrl = ActionController::Base.relative_url_root\n\n return rootUrl+'/' if rootUrl != nil\n\n return '/'\n end",
"def relative_url_root; end",
"def relative_url_root; end",
"def relative_url_root; end",
"def api_url\n \"/api/projects/#{self.api_key}/files/#{self.id}/locales/#{self.locale}\"\n end",
"def file_url\n return nil if target_item.files.empty?\n target_item.files.last.uri.to_s\n end",
"def base_url_path; end",
"def get_url_root(url)\n url.split('/')[0..2].join('/')\n end",
"def base_url\n \"#{scheme}://#{host}\"\n end",
"def path\r\n url.gsub(/https?:\\/\\/[^\\/]+\\//i, '').scan(/([^&]+)/i).first().first()\r\n end",
"def url\n @url = \"#{@http_mode}://#{self.config.servers[0]}\"\n @url << \"/#{self.config.context}\" if(!self.config.context.empty?)\n #self.config.log.debug_msg(\"Request base URL: #{@url}\")\n @url\n end",
"def local_uri\n\n return nil unless self.uri\n u = full_uri\n u[0, 1] == '/' ? \"#{RAILS_ROOT}/public#{u}\" : u\n end",
"def base_uri\t\t\t\n\t\tURI.parse( \"http://\" + @factory.site_name + \".\" + @factory.api_host_base + @path )\n\tend",
"def api_uri\n options.endpoint\n end",
"def _base_url\n r = @_request\n scheme = r.scheme\n port = r.port\n \"#{scheme}://#{r.host}#{\":#{port}\" unless DEFAULT_PORTS[scheme] == port}\"\n end",
"def public_uri\n @public_uri ||= begin\n path = @rack_context.getInitParameter('public.root') || '/'\n path = \"/#{path}\" if path[0, 1] != '/'\n path.chomp!('/') unless path == '/'\n path\n end\n end",
"def url\n base = [FilestackConfig::CDN_URL]\n if @transform_tasks.include? 'debug'\n @transform_tasks.delete('debug')\n base.push('debug')\n end\n base.push(@apikey) if @apikey && @external_url\n if @security\n policy = @security.policy\n signature = @security.signature\n security_string = \"security=policy:#{policy},signature:#{signature}\"\n base.push(security_string)\n end\n base += @transform_tasks\n base.push(@handle || @external_url)\n base.join('/')\n end",
"def url(options = {})\n file.path\n end",
"def endpoint\n \"#{base_url}#{base_url =~ /\\/$/ ? '' : '/'}/api/v3\"\n end",
"def uri_host; end",
"def api_url\n @api_url ||= URI.parse(\"#{super}?#{URI.encode_www_form(query_params)}\")\n end",
"def url\n url_path = destination_path\n if app.config[:strip_index_file]\n url_path = url_path.sub(/(^|\\/)#{Regexp.escape(app.config[:index_file])}$/,\n app.config[:trailing_slash] ? '/' : '')\n end\n File.join(app.config[:http_prefix], url_path)\n end",
"def base_uri\n url = URI.parse( @config[\"portal_url\"] )\n if url.path === \"/\"\n return \"\"\n else\n return url.path\n end\n end",
"def url\n ''\n end",
"def uri_base\n \"http#{'s' if @options[:ssl]}://#{@options[:host]}\"\n end",
"def request_uri\n return nil if absolute? && scheme !~ /^https?$/\n res = path.to_s.empty? ? \"/\" : path\n res += \"?#{self.query}\" if self.query\n return res\n end",
"def root\n '../' * file.count('/')\n end",
"def base_url\n return url\n end",
"def api_url\n @api_url ||= URI.parse(::File.join(base_url, endpoint))\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 direct_uri\n container_parent = container.parent_item\n return unless container_parent\n\n return if respond_to?(:archive_file) && archive_file&.include?('/')\n\n parent_id = container_parent.secondary_key || container_parent.id\n\n enc_path_parts = []\n enc_path_parts << archive_file if respond_to?(:archive_file) && archive_file.present?\n enc_path_parts << path if path.present?\n enc_path_parts << file_name\n enc_path = enc_path_parts.join('/')\n\n enc_path = URI::Parser.new.escape(enc_path)\n\n \"/nfs_store/downloads/in/#{container_parent.resource_item_name}/#{parent_id}/#{enc_path}\"\n end",
"def generate_api_url(workspace_bucket_id, filename)\n file = self.get_workspace_file(workspace_bucket_id, filename)\n if file\n file.api_url + '?alt=media'\n else\n ''\n end\n end",
"def url\n @url ||= GeoIQ.base_uri + \"#{path}.json\"\n end",
"def base_uri\n\t\t\t\"#{server}/api/v4\"\n\t\tend",
"def url\n @url || File.join(host, \"v1\")\n end",
"def file_url\n end",
"def scope_url\n File.dirname(@url)\n end",
"def host\n local_file? ? \"file://\" : split_url[1]\n end",
"def api_url\n ensure_full_data!\n @gapi[\"selfLink\"]\n end",
"def zip_url\n #TODO Pretty sure that will break in production (since root_url isn't set)\n root_url[0..-2] + self.zip_file.url if self.zip_file.file\n end",
"def url\n endpoint+'?'+query_string\n end",
"def base_url\n BASE_URL.dup % [\"%s\", \"%s\", @api_key, \"%s\"] \n end",
"def endpoint_url\n # @@api_base + @request.endpoint\n ApiBase + @endpoint\n end",
"def base_url\n @is_sub_env_specific ? \"#{GlobalConstant::CompanyApi.root_url}#{GlobalConstant::Environment.url_prefix}/api/\"\n : \"#{GlobalConstant::CompanyApi.root_url}api/\"\n end",
"def full_url\n [ self.class.base, normalize_uri ].join('')\n end",
"def base_url\n GlobalConstant::Base.aml_config[:search][:base_url]\n end",
"def upload_file_url\n \"file://#{upload_full_path}\"\n end",
"def infrastructures_base_url\n \"#{configuration[:on_prem_api_endpoint]}/infrastructures\"\n end"
] | [
"0.714462",
"0.686621",
"0.6836571",
"0.67245674",
"0.6688671",
"0.6663328",
"0.6582323",
"0.6576267",
"0.6560481",
"0.6519834",
"0.6501415",
"0.64614016",
"0.64230025",
"0.6402665",
"0.63983446",
"0.63536304",
"0.6327349",
"0.63083935",
"0.6307807",
"0.63065314",
"0.6289053",
"0.62828",
"0.62583035",
"0.62273693",
"0.62184113",
"0.62073815",
"0.6179509",
"0.6177531",
"0.614262",
"0.6140877",
"0.6115979",
"0.60692877",
"0.60622334",
"0.6055971",
"0.6055551",
"0.6055551",
"0.6055551",
"0.6044057",
"0.6042504",
"0.60246503",
"0.6018361",
"0.6018361",
"0.60152966",
"0.600849",
"0.5995428",
"0.5994971",
"0.5991961",
"0.5987541",
"0.59848213",
"0.59700394",
"0.5968441",
"0.5966166",
"0.5951116",
"0.595",
"0.59488684",
"0.59488684",
"0.59488684",
"0.5948047",
"0.5946783",
"0.5942382",
"0.5936079",
"0.59344274",
"0.5920006",
"0.5918727",
"0.5918004",
"0.5915803",
"0.5912818",
"0.58981895",
"0.5895498",
"0.5886988",
"0.58814085",
"0.58740395",
"0.5868417",
"0.5860179",
"0.5857203",
"0.58531415",
"0.5850225",
"0.5843451",
"0.5838733",
"0.5837928",
"0.5837741",
"0.58377135",
"0.583563",
"0.58331525",
"0.58305025",
"0.58208376",
"0.5820227",
"0.5819705",
"0.5818784",
"0.5818676",
"0.5816904",
"0.58133197",
"0.58068043",
"0.5804286",
"0.58038414",
"0.58028036",
"0.5796398",
"0.5786731",
"0.57865936",
"0.57842135",
"0.57841074"
] | 0.0 | -1 |
This returns the root URL for Cloud Servers API queries | def server_management_url
self.auth_response[:server_management_url]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_url\n @response.env[:url].to_s if @response\n end",
"def root_url\n \"#{@env['rack.url_scheme']}://#{@env['HTTP_HOST']}\"\n end",
"def root_url\n '.'\n end",
"def base_url\n URI::HTTPS.build(host: @server, port: @port, path: @api)\n end",
"def api_root\n root_url << '/api'\n end",
"def root_url\n url '/'\n end",
"def api_root_url path_info, query = {}\n root_url :api, path_info, query\n end",
"def base_url\n @is_sub_env_specific ? \"#{GlobalConstant::CompanyApi.root_url}#{GlobalConstant::Environment.url_prefix}/api/\"\n : \"#{GlobalConstant::CompanyApi.root_url}api/\"\n end",
"def base_url\n \"http#{configuration[:secure] ? 's' : ''}://#{configuration[:api_url]}/v#{configuration[:api_version]}\"\n end",
"def base_url\n \"http#{configuration[:secure] ? 's' : ''}://#{configuration[:api_url]}/v#{configuration[:api_version]}\"\n end",
"def root_url_path\r\n root_url.to_s.gsub(/^:.+:\\d*/, '')\r\n end",
"def app_root_url\n root_url(host: Rails.configuration.x.app_host)\n end",
"def base\n\t\t\t\tif @api\n\t\t\t\t\treturn @api.base_url\n\t\t\t\telse\n\t\t\t\t\treturn 'http://masterserver.hon.s2games.com/'\n\t\t\t\tend\n\t\t\tend",
"def api_url\n \"#{protocol}://api:#{api_key}@#{host}/#{api_version}\"\n end",
"def uri\n URI.parse(\"#{@host || DEFAULT_HOST}:#{@port || DEFAULT_PORT}/api\")\n end",
"def server_url\n @uri\n end",
"def root_url(opts={})\n \"#{opts[:protocol] || @protocol}://#{opts[:domain] || @domain}\"\n end",
"def api_url\n @api_url ||= URI.parse(\"#{super}?#{URI.encode_www_form(query_params)}\")\n end",
"def api_url\n base_url.concat api_query_parameter\n end",
"def api_url\n base_url.concat api_query_parameter\n end",
"def url\n @url = \"#{@http_mode}://#{self.config.servers[0]}\"\n @url << \"/#{self.config.context}\" if(!self.config.context.empty?)\n #self.config.log.debug_msg(\"Request base URL: #{@url}\")\n @url\n end",
"def api_host #:nodoc:\n API_URI\n end",
"def server_url\n url\n end",
"def apiv2_base_url(opts)\n root_url = service_root_url(opts)\n \"#{root_url}/api/v2\"\n end",
"def endpoint\n \"#{base_url}#{base_url =~ /\\/$/ ? '' : '/'}/api/v3\"\n end",
"def solr_root\n url = URI.parse(search_engine_url)\n host = url.scheme + '://' + url.host\n if url.port\n host += ':' + url.port.to_s\n end\n host\n end",
"def root_uri_path\n @options[:root_uri_path]\n end",
"def url\n @url || File.join(host, \"v1\")\n end",
"def base_url(operation = nil)\n index = server_operation_index.fetch(operation, server_index)\n return \"#{scheme}://#{[host, base_path].join('/').gsub(/\\/+/, '/')}\".sub(/\\/+\\z/, '') if index == nil\n\n server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])\n end",
"def root_uri\n uri = URI.parse request.url\n uri.path = \"\"\n uri.query = nil\n uri.to_s\n end",
"def base_uri\n\t\t\t\"#{server}/api/v4\"\n\t\tend",
"def base_path\n \"/api/v1\"\n end",
"def endpoint_url\n # @@api_base + @request.endpoint\n ApiBase + @endpoint\n end",
"def api_url(url)\n uri = URI(url.to_s)\n\n uri.scheme = server_uri.scheme if uri.scheme.nil?\n uri.host = server_uri.host if uri.host.nil?\n\n # prepend '/api/<version>/' to path if not provided\n unless uri.path =~ /^\\/api\\/\\d+\\//\n uri.path = File.join('/api', version.to_s, uri.path)\n end\n\n uri.to_s\n end",
"def api_url\n api_key? ? base_url.concat(api_query_parameter) : base_url\n end",
"def base_url(operation = nil)\n index = server_operation_index.fetch(operation.to_sym, server_index)\n return \"#{scheme}://#{[host, base_path].join('/').gsub(/\\/+/, '/')}\".sub(/\\/+\\z/, '') if index == nil\n\n server_url(index, server_operation_variables.fetch(operation.to_sym, server_variables), operation_server_settings[operation.to_sym])\n end",
"def infrastructures_base_url\n \"#{configuration[:on_prem_api_endpoint]}/infrastructures\"\n end",
"def full_url\n char = (api_env('URL') =~ /\\?/).nil? ? '?' : '&'\n api_env('URL') + \"#{char}#{api_env('PARAM')}=#{login}\"\n end",
"def api_base_url(environment)\n GlobalConstant::KycApiBaseDomain.get_base_domain_url_for_environment(environment)\n end",
"def directory_uri\n template = Addressable::Template.new(\n \"https://{host}/discovery/v1/apis\"\n )\n return template.expand({\"host\" => self.host})\n end",
"def uri_base\n \"http#{'s' if @options[:ssl]}://#{@options[:host]}\"\n end",
"def rest_url\n # Transifex API doc says always use a trailing slash even if the last element is a slug\n build_nodes_url.to_s + '/'\n end",
"def api_url\n @api_url ||=\"#{base_url}#{@options['api_url']}\"\n end",
"def api_host\n uri = api_uri\n host, port = uri.host, uri.port\n\n port == 80 ? uri.host : \"#{uri.host}:#{uri.port}\"\n end",
"def server_url\n \"http://#{server_host}:#{server_port}\"\n end",
"def base_url\n \"#{scheme}://#{host}\"\n end",
"def base_url\n BASE_URL.dup % [\"%s\", \"%s\", @api_key, \"%s\"] \n end",
"def get_url\n URI.parse(\"#{@server}#{URL}\")\n end",
"def base_href\n '/api/v1'\n end",
"def base_url\n service.base_url\n end",
"def _base_url\n r = @_request\n scheme = r.scheme\n port = r.port\n \"#{scheme}://#{r.host}#{\":#{port}\" unless DEFAULT_PORTS[scheme] == port}\"\n end",
"def raplet_base_url\n \"#{request.scheme}://#{request.host}:#{request.port}\"\n end",
"def api_uri\n options.endpoint\n end",
"def base_url\n GlobalConstant::Base.cms[:url] + \"api/preview/\"\n end",
"def url\n return @url if @url\n\n case environment\n when :production\n PRODUCTION_API_ENDPOINT\n when :sandbox\n SANDBOX_API_ENDPOINT\n end\n end",
"def url\n endpoint+'?'+query_string\n end",
"def base_url\n GlobalConstant::CompanyOtherProductUrls.kit_root_url\n end",
"def site_url(full: true)\n full ? root_url : \"#{request.host}:#{request.port}/\"\n end",
"def service_root_url(**opts)\n MCB::Azure.get_urls(**opts)\n .grep(%r{^https://.*\\.(education|service)\\.gov\\.uk$})\n .first\n end",
"def get_server_path\n @host=request.host.to_s\n @port=request.port.to_s\n @serverURL=\"http://#{@host}\"\n @serverURL = @serverURL + \":#{@port}\" unless @port == \"80\"\n end",
"def api_url(url = '')\n configuration.api_base + url\n end",
"def api_url\n @api_url ||= URI.parse(::File.join(base_url, endpoint))\n end",
"def base_url\n 'http://ow.ly/api/1.1/url/shorten'\n end",
"def baseURL\n Rails.env.development? ? GeventAnalysis::Application::CONSTS[:dev_host] : GeventAnalysis::Application::CONSTS[:app_host]\n end",
"def api_url\n ensure_full_data!\n @gapi[\"selfLink\"]\n end",
"def core_url\n @blacklight_context.default_index.connection.uri.to_s.gsub(%r{^.*\\/solr}, '/solr')\n end",
"def base_uri\t\t\t\n\t\tURI.parse( \"http://\" + @factory.site_name + \".\" + @factory.api_host_base + @path )\n\tend",
"def base_url\n @client.instance_variable_get(:@base_url)\n end",
"def getServerUrl\n puts \"******* getServerUrl \" + \"*\" * 21\n reqUrl = request.original_url\n puts \" ** reqUrl \" + reqUrl\n gon.currentServerUrl = reqUrl\n end",
"def url\n if @service_url.nil?\n @service_url = @protocol + '://' + @host + '/' +\n (@path_prefix.empty? ? '' : (@path_prefix + '/')) + @key + '/'\n end\n @service_url\n end",
"def endpoint\n connection.url_prefix\n end",
"def api_uri\n raise Exceptions::BadlyConfigured.new if @api_uri.empty? || @api_uri.nil? || @api_uri == '/'\n @api_uri\n end",
"def kube_url\n \"http://#{node['kubernetes']['master']['ip']}:#{node['kubernetes']['master']['port']}/api\"\n end",
"def base_uri\n if mode == 'sandbox'\n @base_uri = 'https://sandbox.fundamerica.com/api/'\n else\n @base_uri = 'https://apps.fundamerica.com/api/'\n end\n end",
"def service_url(svc)\n \"#{@host}#{SERVICES[svc]}\"\n end",
"def url\n \"http://#{host}:#{port}/\"\n end",
"def endpoint\n \"#{@scheme}://#{@host}#{@path}\"\n end",
"def base_url\n \"http://#{@host}:#{@port}\"\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def uri_host; end",
"def get_base_uri(server = Server::DEFAULT)\r\n parameters = {\r\n 'base_url' => { 'value' => base_url, 'encode' => false }\r\n }\r\n APIHelper.append_url_with_template_parameters(\r\n ENVIRONMENTS[environment][server], parameters\r\n )\r\n end",
"def url\n api_url\n end",
"def url\n URL(@site.url).join(attributes[\"RootFolder\"]).to_s\n # # Dirty. Used to use RootFolder, but if you get the data from the bulk calls, RootFolder is the empty\n # # string rather than what it should be. That's what you get with web services as an afterthought I guess.\n # view_url = ::File.dirname(attributes[\"DefaultViewUrl\"])\n # result = URL(@site.url).join(view_url).to_s\n # if ::File.basename(result) == \"Forms\" and dir = ::File.dirname(result) and dir.length > @site.url.length\n # result = dir\n # end\n # result\n end",
"def service_uri\n \"#{host}#{service_path}\"\n end",
"def redmine_url\n rootUrl = ActionController::Base.relative_url_root\n\n return rootUrl+'/' if rootUrl != nil\n\n return '/'\n end",
"def application_url\n tenant = use_shared_configservers ? @tenant_name : \"default\"\n application = use_shared_configservers ? @application_name : \"default\"\n \"https://#{vespa.nodeproxies.first[1].addr_configserver[0]}:#{19071}/application/v2/tenant/#{tenant}/application/#{application}/environment/prod/region/default/instance/default/\"\n end",
"def sub_url (p)\n res = (p != \"\") ? \"http://\" + request.host + \":3000\" + p.sub(\"/execute/\", \"/rest2/\") : p\n end",
"def url\n @url || API_ENDPOINT\n end",
"def path_root\n base_uri ? base_uri : path_to( '/' )\n end",
"def url\n url = \"#{config.url[config.env]}/#{@path}\"\n url = \"#{url}?#{@params.to_param}\" unless @params.empty?\n url\n end",
"def endPoint(path='')\n parts = ['https:/', $cfg['net.host'], 'api:1'] + @uriparts\n s = parts.map{|v| v.to_s}.join('/')\n URI(s + path.to_s)\n end",
"def base_url\n GlobalConstant::Base.aml_config[:search][:base_url]\n end",
"def url\n URI.parse(endpoint).join(path.to_s).to_s\n end",
"def get_root\n http = Net::HTTP.start(@server_ip, @server_port)\n request = Net::HTTP::Get.new(\"/\")\n request.basic_auth @username, @password\n http.request(request)\n end",
"def get_url_root(url)\n url.split('/')[0..2].join('/')\n end",
"def host\n conf['api']['host']\n end",
"def server_url\n \"#{ROCCI_SERVER_CONFIG.common.protocol || 'http'}://\" \\\n \"#{ROCCI_SERVER_CONFIG.common.hostname || 'localhost'}:\" \\\n \"#{ROCCI_SERVER_CONFIG.common.port.to_s || '3000'}\"\n end",
"def api_path\n @api_path ||= find_api_path(base_uri)\n end",
"def main_url(secure)\n url = \"http#{secure ? \"s\" : \"\"}://#{secure ? \"book.\" : \"\"}\"\n url += (Configuration.hostname ||= \"api.ean.com\") + \"/ean-services/rs/hotel/v3/\"\n url\n end"
] | [
"0.75165474",
"0.74742705",
"0.7467842",
"0.73292",
"0.72943676",
"0.725942",
"0.72557974",
"0.7066603",
"0.70543814",
"0.70543814",
"0.7001407",
"0.6977074",
"0.6972126",
"0.69707954",
"0.69157064",
"0.68690205",
"0.6844724",
"0.68437684",
"0.6837551",
"0.6837551",
"0.6821138",
"0.67916596",
"0.6773232",
"0.67602044",
"0.6759434",
"0.67247456",
"0.66893643",
"0.66668046",
"0.66656786",
"0.66573405",
"0.6642654",
"0.6640501",
"0.6623175",
"0.6616623",
"0.66103727",
"0.6609012",
"0.6592534",
"0.65922666",
"0.6578579",
"0.65712076",
"0.654608",
"0.6535429",
"0.65261537",
"0.65254676",
"0.6523911",
"0.6516965",
"0.64908844",
"0.6487131",
"0.64864177",
"0.64781505",
"0.64750314",
"0.64669263",
"0.6461185",
"0.6458977",
"0.6457306",
"0.6450936",
"0.64507574",
"0.64376897",
"0.6433478",
"0.64330846",
"0.64330673",
"0.64249015",
"0.64230466",
"0.63995844",
"0.63948154",
"0.6381628",
"0.6381518",
"0.63793033",
"0.6370208",
"0.636576",
"0.6347261",
"0.63317543",
"0.6328766",
"0.63285416",
"0.6315474",
"0.6311018",
"0.63056564",
"0.63043696",
"0.6295401",
"0.6295401",
"0.6295401",
"0.62855756",
"0.62825894",
"0.6272983",
"0.6255255",
"0.62437403",
"0.6242177",
"0.6239527",
"0.62390155",
"0.62251645",
"0.62227696",
"0.62186265",
"0.6212287",
"0.6203762",
"0.61972654",
"0.61958826",
"0.61902726",
"0.6187428",
"0.61845106",
"0.61816806",
"0.6181609"
] | 0.0 | -1 |
This returns the root URL for CDN Cloud Files API queries (not yet implemented) | def cdn_management_url
self.auth_response[:cdn_management_url]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url\n host = @uploader.ucloud_cdn_host || @uploader.ucloud_bucket_host\n return nil unless host\n [host, @path].join(\"/\")\n end",
"def url; \"file:#{@root}\"; end",
"def root_url\n '.'\n end",
"def url\n base = [FilestackConfig::CDN_URL]\n if @transform_tasks.include? 'debug'\n @transform_tasks.delete('debug')\n base.push('debug')\n end\n base.push(@apikey) if @apikey && @external_url\n if @security\n policy = @security.policy\n signature = @security.signature\n security_string = \"security=policy:#{policy},signature:#{signature}\"\n base.push(security_string)\n end\n base += @transform_tasks\n base.push(@handle || @external_url)\n base.join('/')\n end",
"def directory_uri\n template = Addressable::Template.new(\n \"https://{host}/discovery/v1/apis\"\n )\n return template.expand({\"host\" => self.host})\n end",
"def url\n UploadUtils.get_url(\n FilestackConfig::CDN_URL, handle: handle, security: security\n )\n end",
"def base_url\n File.join(host, path)\n end",
"def root_url\n @response.env[:url].to_s if @response\n end",
"def base_request_path\n Merb.dir_for(:public) / slice_url(:external_delete_all)\n end",
"def response_uri(file)\n file.base_uri\n end",
"def base_uri\n ary = contents_uri.to_s.split(\"/\")\n ary.pop if ary[-1].blank?\n ary.pop\n ary.join(\"/\") + \"/\"\n end",
"def root_uri_path\n @options[:root_uri_path]\n end",
"def url\n return nil unless @uploader.upyun_bucket_host\n\n [@uploader.upyun_bucket_host, @path].join(\"/\")\n end",
"def root_path\n Pathname.new(upload_path_value).join(search_directory)\n end",
"def upload_url\n _get(\"/files/upload_url\") { |json| json }\n end",
"def neofiles_file_url(*args)\n neofiles_cdn_prefix(*args) + neofiles_file_path(*args)\n end",
"def root_url_path\r\n root_url.to_s.gsub(/^:.+:\\d*/, '')\r\n end",
"def absolute_url(request, opts={})\n cdn_url(opts) || (request.protocol + request.host_with_port + public_filename)\n end",
"def base_request_path\n Merb.dir_for(:public) / slice_url(:images_delete_all)\n end",
"def root_url\n url '/'\n end",
"def file_url\n resource.send(mount_point).url\n end",
"def cname_url\n URI.escape(\"#{protocol}#{name}/#{key}\") if bucket.vhost?\n end",
"def url\n URL(@site.url).join(attributes[\"RootFolder\"]).to_s\n # # Dirty. Used to use RootFolder, but if you get the data from the bulk calls, RootFolder is the empty\n # # string rather than what it should be. That's what you get with web services as an afterthought I guess.\n # view_url = ::File.dirname(attributes[\"DefaultViewUrl\"])\n # result = URL(@site.url).join(view_url).to_s\n # if ::File.basename(result) == \"Forms\" and dir = ::File.dirname(result) and dir.length > @site.url.length\n # result = dir\n # end\n # result\n end",
"def root_url\n \"#{@env['rack.url_scheme']}://#{@env['HTTP_HOST']}\"\n end",
"def get_cloud_href\n @api_client.get_instance.links.detect { |link| link['rel'] == 'cloud' }['href']\n end",
"def auth_url\n CloudFiles.const_get(\"AUTH_#{self.auth_location.upcase}\")\n end",
"def api_root_url path_info, query = {}\n root_url :api, path_info, query\n end",
"def root_url(opts={})\n \"#{opts[:protocol] || @protocol}://#{opts[:domain] || @domain}\"\n end",
"def cdn_url\n unless defined?(@cdn_url)\n self.cdn_url = DEFAULT_CDN_URL\n end\n\n @cdn_url\n end",
"def url\n ::File.join \"/\", path.to_s\n end",
"def base_url\n URI::HTTPS.build(host: @server, port: @port, path: @api)\n end",
"def base_request_path\n Merb.dir_for(:public) / slice_url(:textim_delete_all)\n end",
"def root_uri\n uri = URI.parse request.url\n uri.path = \"\"\n uri.query = nil\n uri.to_s\n end",
"def path_root\n base_uri ? base_uri : path_to( '/' )\n end",
"def path\n '/c/document_library/get_file?folderId=%i&name=%s' % [self.folderid, self.name]\n end",
"def zip_url\n #TODO Pretty sure that will break in production (since root_url isn't set)\n root_url[0..-2] + self.zip_file.url if self.zip_file.file\n end",
"def neofiles_cdn_prefix(*args)\n cdns = Rails.application.config.neofiles.cdns || []\n cdns << root_url unless cdns.any?\n\n if cdns.count > 1\n some_file = args.first\n if some_file.is_a? Neofiles::File\n gen_time = some_file.id.generation_time.sec\n elsif some_file.is_a? Hash\n tmp = some_file[:id] || some_file['id'] || some_file[:_id] || some_file['_id'] || \"\"\n gen_time = BSON::ObjectId.legal?(tmp) ? BSON::ObjectId.from_string(tmp).generation_time.sec : Time.now.strftime('%U').to_i\n elsif some_file.is_a? String\n gen_time = BSON::ObjectId.legal?(some_file) ? BSON::ObjectId.from_string(some_file).generation_time.sec : Time.now.strftime('%U').to_i\n else\n gen_time = Time.now.strftime('%U').to_i\n end\n\n cdn = cdns[gen_time % cdns.count]\n else\n cdn = cdns.first\n end\n\n cdn.sub! /\\/\\z/, ''\n cdn = 'http://' + cdn unless cdn =~ /\\Ahttp[s]?:\\/\\//\n cdn\n end",
"def base_url\n @url.to_s.split('?').first\n end",
"def cdn_url(opts={})\n S3Buckets::MediaBucket.url(s3_key, opts) if s3_key\n end",
"def public_url\n self.container.public? ? self.container.cdn_url + \"/#{URI.encode(@name)}\" : nil\n end",
"def url\n storage.url_for(path_with_query)\n end",
"def direct_uri\n container_parent = container.parent_item\n return unless container_parent\n\n return if respond_to?(:archive_file) && archive_file&.include?('/')\n\n parent_id = container_parent.secondary_key || container_parent.id\n\n enc_path_parts = []\n enc_path_parts << archive_file if respond_to?(:archive_file) && archive_file.present?\n enc_path_parts << path if path.present?\n enc_path_parts << file_name\n enc_path = enc_path_parts.join('/')\n\n enc_path = URI::Parser.new.escape(enc_path)\n\n \"/nfs_store/downloads/in/#{container_parent.resource_item_name}/#{parent_id}/#{enc_path}\"\n end",
"def url\n Blobs::URI.blob(container.name, name)\n end",
"def scope_url\n File.dirname(@url)\n end",
"def get_url_root(url)\n url.split('/')[0..2].join('/')\n end",
"def base_url\n @is_sub_env_specific ? \"#{GlobalConstant::CompanyApi.root_url}#{GlobalConstant::Environment.url_prefix}/api/\"\n : \"#{GlobalConstant::CompanyApi.root_url}api/\"\n end",
"def base_url\n GlobalConstant::Base.cms[:url] + \"api/preview/\"\n end",
"def api_root\n root_url << '/api'\n end",
"def solr_root\n url = URI.parse(search_engine_url)\n host = url.scheme + '://' + url.host\n if url.port\n host += ':' + url.port.to_s\n end\n host\n end",
"def relative_url_root; end",
"def relative_url_root; end",
"def relative_url_root; end",
"def root_file_path; end",
"def server_image_url(filename)\n uri = \"#{@api_url}/#{@project_id}/images/get_upload_url?filename=#{filename}&access_token=#{@access_token}\"\n get uri\n end",
"def url(options = {})\n if file.respond_to?(:url)\n tmp_url = file.method(:url).arity.zero? ? file.url : file.url(options)\n return tmp_url if tmp_url.present?\n end\n\n if file.respond_to?(:path)\n path = encode_path(file.path.sub(File.expand_path(root), ''))\n\n if (host = asset_host)\n if host.respond_to? :call\n \"#{host.call(file)}#{path}\"\n else\n \"#{host}#{path}\"\n end\n else\n (base_path || \"\") + path\n end\n end\n end",
"def host\n local_file? ? \"file://\" : split_url[1]\n end",
"def final_url\n return @final_url if !@final_url.nil?\n location = final_location(FaviconParty::HTTPClient.head(@query_url))\n if !location.nil?\n if location =~ /\\Ahttp/\n @final_url = WEBrick::HTTPUtils.escape location\n else\n uri = URI @query_url\n root = \"#{uri.scheme}://#{uri.host}\"\n @final_url = WEBrick::HTTPUtils.escape URI.join(root, location).to_s\n end\n end\n if !@final_url.nil?\n if %w( 127.0.0.1 localhost ).any? {|host| @final_url.include? host }\n # TODO Exception for invalid final urls\n @final_url = @query_url\n end\n return @final_url\n end\n @final_url = @query_url\n end",
"def base_url\n \"#{scheme}://#{host}\"\n end",
"def core_url\n @blacklight_context.default_index.connection.uri.to_s.gsub(%r{^.*\\/solr}, '/solr')\n end",
"def asset_base_uri\n \"/#{File.basename(Engines.public_dir)}/#{name}\"\n end",
"def local_uri\n\n return nil unless self.uri\n u = full_uri\n u[0, 1] == '/' ? \"#{RAILS_ROOT}/public#{u}\" : u\n end",
"def path\r\n url.gsub(/https?:\\/\\/[^\\/]+\\//i, '').scan(/([^&]+)/i).first().first()\r\n end",
"def get_corresponding_file_base_name\n return File.basename(@URL)\n end",
"def base_url\n return url\n end",
"def flickr_url\n get_url(:flickr)\n end",
"def endpoint\n \"#{base_url}#{base_url =~ /\\/$/ ? '' : '/'}/api/v3\"\n end",
"def url\n if @uploader.upyun_bucket_domain\n \"http://\" + @uploader.upyun_bucket_domain + '/' + @path\n else\n nil\n end\n end",
"def uri\n params = {\n center: location,\n size: size,\n zoom: zoom,\n format: file_format,\n sensor: sensor.to_s\n }\n Addressable::URI.parse(api_endpoint).tap do |uri|\n uri.query_values = params\n end.to_s\n end",
"def public_uri\n @public_uri ||= begin\n path = @rack_context.getInitParameter('public.root') || '/'\n path = \"/#{path}\" if path[0, 1] != '/'\n path.chomp!('/') unless path == '/'\n path\n end\n end",
"def file_url\n end",
"def base_url_path; end",
"def url\n File.join(server.url, path)\n end",
"def file_set_url(file_set_id)\n \"https://#{ENV['SERVER_NAME']}/downloads/#{file_set_id}\"\n end",
"def url(options = {})\n file.path\n end",
"def url\n [\"http://\" + @uploader.couch_host + \":\" + @uploader.couch_port, model.database.name , model.id, @path].join(\"/\")\n end",
"def server_url\n @uri\n end",
"def service_root_url(**opts)\n MCB::Azure.get_urls(**opts)\n .grep(%r{^https://.*\\.(education|service)\\.gov\\.uk$})\n .first\n end",
"def public_url(options = {})\n url = URI.parse(bucket.url(options))\n url.path += '/' unless url.path[-1] == '/'\n url.path += key.gsub(/[^\\/]+/) { |s| Seahorse::Util.uri_escape(s) }\n url.to_s\n end",
"def api_url\n base_url.concat api_query_parameter\n end",
"def api_url\n base_url.concat api_query_parameter\n end",
"def base_url\n service.base_url\n end",
"def root_uri\n attributes.fetch(:rootUri)\n end",
"def root_path\n RUBYCOCOA_ROOT.to_s\n end",
"def base_url\n GlobalConstant::CompanyOtherProductUrls.kit_root_url\n end",
"def compose_url(url)\n abort \"Invalid URL: #{url}\" unless validate_url(url)\n\n query = {}\n query['map'] = 'true' if options['map']\n query['api_key'] = options['key'] if options['key']\n query['compression'] = options['compress'] if options['compress']\n\n uri = URI(url)\n uri.path = '/files'\n uri.query = URI.encode_www_form(query)\n uri.to_s\n end",
"def static_root\n \"https://s3-eu-west-1.amazonaws.com/bibliocloudimages/static\"\n end",
"def generate_api_url(workspace_bucket_id, filename)\n file = self.get_workspace_file(workspace_bucket_id, filename)\n if file\n file.api_url + '?alt=media'\n else\n ''\n end\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def host()\n \"https://#{self.bucket}.commondatastorage.googleapis.com/\"\n end",
"def uri_base\n \"http#{'s' if @options[:ssl]}://#{@options[:host]}\"\n end",
"def root\n '../' * file.count('/')\n end",
"def url\n Djatoka.resolver.region(filename).scale(1800).url\n end",
"def infrastructures_base_url\n \"#{configuration[:on_prem_api_endpoint]}/infrastructures\"\n end",
"def base_uri\n @options[:base_uri]\n end",
"def base_uri\n @options[:base_uri]\n end",
"def base_uri\n url = URI.parse( @config[\"portal_url\"] )\n if url.path === \"/\"\n return \"\"\n else\n return url.path\n end\n end",
"def to_s\n cdn_url\n end",
"def base_url\n \"http#{configuration[:secure] ? 's' : ''}://#{configuration[:api_url]}/v#{configuration[:api_version]}\"\n end"
] | [
"0.7293536",
"0.6621153",
"0.6544243",
"0.6485726",
"0.64530295",
"0.64487547",
"0.6266853",
"0.62627476",
"0.62618876",
"0.6252516",
"0.6242374",
"0.62102807",
"0.6187452",
"0.61778116",
"0.61629",
"0.6151417",
"0.6140029",
"0.6137985",
"0.6112066",
"0.6063998",
"0.60424966",
"0.60084337",
"0.6004262",
"0.5989873",
"0.5926254",
"0.5917644",
"0.5906827",
"0.5893918",
"0.5889708",
"0.5881178",
"0.5871942",
"0.5855584",
"0.5838598",
"0.5833324",
"0.58230495",
"0.582004",
"0.58189136",
"0.5816045",
"0.58114904",
"0.57922506",
"0.57894087",
"0.5771778",
"0.5769382",
"0.57626617",
"0.5761444",
"0.5758914",
"0.5756987",
"0.57511514",
"0.5747088",
"0.5746517",
"0.5746517",
"0.5746517",
"0.5741846",
"0.57329047",
"0.5727943",
"0.57183814",
"0.57093257",
"0.5703947",
"0.57033545",
"0.569996",
"0.56974816",
"0.5691773",
"0.5682083",
"0.5678941",
"0.5677542",
"0.56649005",
"0.56641984",
"0.5655987",
"0.5651442",
"0.56499827",
"0.5646112",
"0.5643752",
"0.56323284",
"0.5624876",
"0.5624819",
"0.56247455",
"0.5623441",
"0.56140083",
"0.56134087",
"0.56134087",
"0.5613333",
"0.5612615",
"0.5610683",
"0.5608993",
"0.5607799",
"0.5607565",
"0.5607167",
"0.5605783",
"0.5605783",
"0.5605783",
"0.5600663",
"0.55978066",
"0.5597329",
"0.5592935",
"0.55927515",
"0.5592681",
"0.5592681",
"0.55914956",
"0.5588015",
"0.5587648"
] | 0.5993882 | 23 |
This performs a basic GET request using the supplied URL and headers | def get(url, headers = {})
http :get, "#{url}.json", headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(url, headers = {})\n do_request Net::HTTP::Get, url, headers\n end",
"def get(url, headers={})\n do_request(\"get\", url, nil, headers)\n end",
"def get(url, headers = {})\n request(:get, url, headers)\n end",
"def get(url, headers = {})\n request(:get, url, headers)\n end",
"def make_get_request url, headers = []\n make_request url, headers: headers\n end",
"def get(url, headers={})\n RestClient.get url, headers\n end",
"def get(url, headers: {}, params: {}, options: {}, &block)\n url = encode_query(url, params)\n\n request = Net::HTTP::Get.new(url, @default_headers.merge(headers))\n\n execute_streaming(request, options: options, &block)\n end",
"def http_get(url, headers = nil)\r\n if @debug\r\n puts \"Url:\"\r\n puts url\r\n puts \"Headers:\"\r\n puts headers\r\n puts \"Method: get\"\r\n end\r\n return headers ? HTTParty.get(url, :headers => headers) : HTTParty.get(url)\r\n end",
"def get(url, query = nil, headers = nil)\n headers = headers ? @headers.merge(headers) : @headers\n #Log.t(\"GET: #{url}\\n#{query.inspect}\\n#{headers.inspect}\")\n content = @client.get_content(URI.join(@base, url), query, headers) rescue ''\n Nokogiri::HTML(content)\n end",
"def get(uri, request_headers)\n request('get', uri, request_headers)\n end",
"def get(url, headers)\n conn = create_connection_object(url)\n\n http = conn.get(:head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end",
"def get(query_url,\r\n headers: {})\r\n HttpRequest.new(HttpMethodEnum::GET,\r\n query_url,\r\n headers: headers)\r\n end",
"def request_with_headers(url, headers = {}, https = false)\n uri = URI.parse(url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = https\n\n request = Net::HTTP::Get.new(uri.path)\n\n headers.each do |header|\n request[header[0].to_s] = header[1]\n end\n\n response = http.request(request)\n\n return response\n end",
"def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client.get(\n uri,\n follow_redirect: true,\n header: headers\n )\n end\n end",
"def get(path, headers = {})\n request = Net::HTTP::Get.new(path)\n @default_headers.merge(headers).each do |key, value|\n request[key] = value\n end\n @http.request(request)\n end",
"def get(url, options)\n headers = options[:headers] || {}\n params = options[:params] || {}\n url = url_with_params(url, params)\n req = Net::HTTP::Get.new(url)\n request_with_headers(req, headers)\n end",
"def do_get url\n\t\turi = URI.parse(url)\n\t\tNet::HTTP.get_response(uri)\n\tend",
"def get(url, params=nil, headers={})\n if params and params.count > 0\n params.keys.to_a.each {|k|\n params.delete(k) if params[k].nil?\n }\n query_string = Util.query_params(params)\n url += \"?#{query_string}\"\n end\n request(:get, url, nil, headers)\n end",
"def get(uri, request_headers)\n raise NotImplementedError\n end",
"def get(url)\n request(:get, url, {}, nil)\n end",
"def get(path, headers = {})\n process :get, path, headers\n end",
"def get(resource, headers = {})\n prepare_request(:get, resource, nil, headers)\n end",
"def make_request(url,headers,query)\n c = HTTPClient.new\n c.get_content(url,query,headers)\nend",
"def get path, header={}, body_string_or_hash=\"\"\n env.http 'GET', path, header, body_string_or_hash\n end",
"def http_get(path, headers = { })\n clear_response\n path = process_path(path)\n @success_code = 200\n @response = http.get(path, headers)\n parse_response? ? parsed_response : response.body\n end",
"def get(headers = {}, path = '', parameters = {})\n full_path = [path, URI.encode_www_form(parameters)].join(PARAM_STARTER)\n uri = URI.parse(\"#{@url}#{full_path}\")\n request = Net::HTTP::Get.new(uri.request_uri)\n request.body = nil\n send_request(uri, request, headers)\n end",
"def get(path: nil, headers: {}, query: {}, auth_method: nil)\n execute(method: :get, path: path, query: query, headers: headers, auth_method: auth_method)\n end",
"def get(url, args = {})\r\n make_request(:get, url, args)\r\n end",
"def get(url='/', vars={})\n send_request url, vars, 'GET'\n end",
"def get(url); end",
"def get url, params={}, headers={}\n uri = URI.parse(url)\n path = uri.path + \"?\" + query_string(default_params.merge(params))\n response = http(uri.host, uri.port).get(path, default_headers.merge(headers))\n JSON.parse(response.body)\n end",
"def get(uri)\r\n request(Net::HTTP::Get.new(uri)) \r\n end",
"def get(params = {})\n response = prepare_response(make_url(params).open('User-Agent' => USER_AGENT).read)\n check_error(response)\n return parse_response(response)\n rescue OpenURI::HTTPError => e\n check_error(prepare_response(e.io.read))\n raise\n end",
"def fetch(url, headers={})\n @url_cache ||= Hash.new\n return @url_cache[url] if @url_cache.has_key?(url)\n\n uri = URI.parse(url)\n\n path = uri.path == \"\" ? \"/\" : uri.path\n\n req = Net::HTTP::Get.new(path)\n res = Net::HTTP.start(uri.host, uri.port) {|http|\n http.request(req)\n }\n\n @url_cache[url] = res\n \n return res\n end",
"def get url\n url = URI url\n request = HTTP::Get.new url.path\n\n dispatch request, to: url\n end",
"def http_get(url)\n response = client.get(url, follow_redirect: true)\n\n raise HTTPClient::BadResponseError, response.reason unless HTTP::Status.successful?(response.status)\n\n response\n end",
"def get(url)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n\n response = http.get(\"#{uri.path}?auto\")\n\n unless response.code == \"200\"\n puts \"Failed to retrieve #{url}: #{response.code}\"\n exit 3\n end\n\n response.body\nend",
"def http_get(url)\n require \"open-uri\"\n URI.parse(url).read\n end",
"def get(path, options = {})\n request(:get, parse_query_and_convenience_headers(path, options))\n end",
"def get(params = {})\n request! do\n api[url.path + to_query(params)].get(API_HEADERS)\n end\n end",
"def get(path, query = { }, headers = { })\n clear_response\n path = process_path(path, query)\n @success_code = 200\n @response = http.get(path, headers)\n parse_response? ? parsed_response : response.body\n end",
"def get(url, options = {}, &block)\n options = treat_params_as_query(options)\n request HttpGetWithEntity, url, options, &block\n end",
"def get(url)\n uri = URI(url)\n Net::HTTP.get(uri)\nend",
"def do_get\n Net::HTTP.get(URI.parse(api_url))\n end",
"def httpget(url, corpNum, userID = '')\n headers = {\n \"x-pb-version\" => KAKAOCERT_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n if corpNum.to_s != ''\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n end\n\n if userID.to_s != ''\n headers[\"x-pb-userid\"] = userID\n end\n\n uri = URI(getServiceURL() + url)\n request = Net::HTTP.new(uri.host, 443)\n request.use_ssl = true\n\n Net::HTTP::Get.new(uri)\n\n res = request.get(uri.request_uri, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise KakaocertException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end",
"def get(path, options={})\n url = build_url path, options\n headers = options[:headers] || {}\n Response.new(@client[url].get headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end",
"def get\n execute_request { faraday_connection.get(href || '') }\n end",
"def get(url)\n call(url: url)\n end",
"def get(url, params={})\n @agent.get(url,params)\n end",
"def send_get(uri)\n _send_request('GET', uri, nil)\n end",
"def http_get(curl, data, url)\n\n # Define the url we want to hit\n curl.url=url\n\n # Specify the headers we want to hit\n curl.headers = data['header']\n\n # perform the call\n curl.http_get\n\n # Set headers to nil so none get reused elsewhere\n curl.headers = nil\n\n # return the curl object\n return curl\nend",
"def do_get(uri = \"\", query: {}, headers: {}, n_http: false)\n url_query = query.size > 0 ? \"?\" + query.map {|k, v| \"#{k}=#{v}\"}.join(\"&\") : \"\"\n Timeout.timeout(@timeout) do\n con = n_http ? @connection_net_http : @connection\n con.get do |req|\n req.url(uri + url_query)\n headers.map { |key, value| req.headers[key] = value }\n end\n end\n rescue Faraday::Error::ConnectionFailed, Timeout::Error => e\n msg = \"Error trying to send a GET to #{uri + url_query} \"\\\n \"the reason: #{e.message}\"\n $lxca_log.error(HEADER_MESSAGE + ' do_get', msg)\n Faraday::Response.new\n end",
"def get(path)\n req = Net::HTTP::Get.new(@base_url + path)\n response = handle_request(req)\n response.each {|k,v| puts \"#{k}: #{v}\"}\n response\n end",
"def get(path, options = {})\n request = Net::HTTP::Get.new(request_uri(path))\n make_request(request, options.merge(no_callbacks: true))\n end",
"def get(url)\n uri = normalize_url(url)\n\n # Ensure the parsed URL is an HTTP one\n raise HTTPError::ClientError.new(\"Invalid URL #{url}\") unless uri.is_a?(URI::HTTP)\n\n req = Net::HTTP::Get.new(uri.request_uri)\n handle_request(uri, req)\n end",
"def get(uri, parameters = T.unsafe(nil), referer = T.unsafe(nil), headers = T.unsafe(nil)); end",
"def get(uri, params = {})\n send_request(uri, :get, params)\n end",
"def get\n @response = Net::HTTP.get_response(URI(@url))\n end",
"def get(url, version: nil, locale: nil)\n @client.get(url, headers: headers(version: version, locale: locale))\n end",
"def request_get(path)\n\ttimestamp = Time.now.utc.iso8601\n\tauth = create_hmac_auth(\"GET\", path, timestamp)\n\t\n\turi = URI($baseUrl + path)\n\n\trequest = Net::HTTP::Get.new(uri)\n\trequest.add_field(\"x-hp-hmac-authentication\", auth)\n\trequest.add_field(\"x-hp-hmac-date\", timestamp)\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend",
"def http_get(url)\n opts = {\n followlocation: false,\n timeout: @time_out,\n accept_encoding: 'gzip',\n headers: {\n 'User-Agent' => \"wgit/#{Wgit::VERSION}\",\n 'Accept' => 'text/html'\n }\n }\n\n # See https://rubydoc.info/gems/typhoeus for more info.\n Typhoeus.get(url, opts)\n end",
"def perform_request url\n response = self.class.get(url)\n raise NotFound.new(\"404 Not Found\") if response.respond_to?(:code) && response.not_found?\n raise InvalidAPIResponse.new(response[\"status\"][\"message\"]) if response.is_a?(Hash) && response[\"status\"]\n\n response\n end",
"def get_response(url = nil, headers = nil)\n options = {:headers => headers}.merge(ssl_option)\n Typhoeus::Request.get(url || default_url, options)\n end",
"def fetch()\n @result = open(@url,@headers)\n end",
"def get(path, options={}, &block)\n uri = URI.join(@endpoint, path)\n headers = options.delete(:headers)\n query = options.delete(:query)\n\n if query\n uri.query = URI.encode_www_form(query)\n end\n\n request = Net::HTTP::Get.new uri.request_uri, headers\n @http.request request, &block\n end",
"def get\n RestClient.get(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def get(path, params = {}, headers = {})\n request(:get, path, params, headers).body\n end",
"def get_file(url, filename, headers = {})\n request(:get, url, headers, :file => filename)\n end",
"def get_file(url, filename, headers = {})\n request(:get, url, headers, :file => filename)\n end",
"def head(query_url,\r\n headers: {})\r\n HttpRequest.new(HttpMethodEnum::HEAD,\r\n query_url,\r\n headers: headers)\r\n end",
"def http_fetch(url)\n uri = URI.parse url\n http = Net::HTTP.new(uri.host, uri.port)\n\n # Unfortunately the net/http(s) API can't seem to do this for us,\n # even if we require net/https from the beginning (ruby 1.8)\n if uri.scheme == \"https\"\n require 'net/https'\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n res = http.start { |http|\n req = Net::HTTP::Get.new uri.request_uri\n cred = netrc_credentials uri.host\n req.basic_auth *cred if cred\n http.request req\n }\n end",
"def get(path)\n request = Net::HTTP::Get.new @uri.path+'/'+path\n request.basic_auth @api_key, ''\n request['User-Agent'] = USER_AGENT\n response = @https.request request\n JSON.parse response.body\n end",
"def get(uri, request_headers)\n request('get', uri, request_headers) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end",
"def get(url, options = {})\n self.class.default_params.merge!(options)\n response = self.class.get(url)\n handle_response(response)\n end",
"def httpget(url, corpNum, userID = '')\n headers = {\n \"x-pb-version\" => BaseService::POPBILL_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n if corpNum.to_s != ''\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n end\n\n if userID.to_s != ''\n headers[\"x-pb-userid\"] = userID\n end\n\n uri = URI(getServiceURL() + url)\n\n request = Net::HTTP.new(uri.host, 443)\n request.use_ssl = true\n\n Net::HTTP::Get.new(uri)\n\n res = request.get(uri.request_uri, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise PopbillException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end",
"def get(url, options={})\n rest_connection.get do |req|\n req.url build_url(url)\n req.headers['Content-Type'] = 'application/json'\n req.headers['Accept'] = 'application/json'\n req.params = options[:params] if options.has_key?(:params) && !options[:params].empty?\n req.options.timeout = config.rest_timeout\n req.options.open_timeout = config.rest_open_timeout\n end\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get(path, params: {}, headers: nil)\n response = conn.get do |req|\n build_request(req, path: path, params: params, headers: headers)\n end\n response\n rescue StandardError => e\n puts e.inspect\n raise\n end",
"def get(url, key)\n _request(url, :GET, key)\n end",
"def http( *args )\n p http_get( *args )\n end",
"def get(path, options={})\n send_request 'get', path, options\n end",
"def request(url, token)\n headers = { \"Authorization\" => \"Splunk #{token}\" }\n Net::HTTP::Get.new(url, headers)\n end",
"def fetch_from_url url\n require \"net/http\"\n\n uri = URI.parse(url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n\n request['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 OPR/36.0.2130.46'\n \n response = http.request(request)\n \n return response.body # => The body (HTML, XML, blob, whatever)\n end",
"def do_get(uri = \"\", query = {})\n url_query = query.size > 0 ? \"?\" + query.map {|k, v| \"#{k}=#{v}\"}.join(\"&\") : \"\"\n @connection.get(uri + url_query)\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase connection\", \"Error trying to send a GET to #{uri + url_query}\"\n Faraday::Response.new\n end",
"def perform_get(path, options = {})\n perform_request(:get, path, options)\n end",
"def get(url, params = {})\n client.get(url, params).body\n end",
"def get(path, options = {})\n uri = build_uri(path, options)\n\n request = Net::HTTP::Get.new(uri.request_uri)\n set_authorisation_header(request)\n\n response = https_client(uri).request(request)\n end",
"def http_get(url)\n FaviconParty::HTTPClient.get(url)\n end",
"def get url\n RestClient::Request.execute(:method => :get, :url => url, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end",
"def get(path, params, connection = CONNECTION)\n request = Net::HTTP::Get.new(to_url(path, params))\n process_request(request, connection)\nend",
"def fetch(url)\n # TODO: support HTTPS too\n @open_params ||= begin\n u = URL(@root_url)\n [u.host, u.port]\n end\n Net::HTTP.start(*@open_params) do |http|\n request = Net::HTTP::Get.new(URL(url).full_path.gsub(/ /, \"%20\"))\n with_sts_auth_retry do\n authenticate(request, {:is_request => true})\n http.request(request)\n end\n end\n end",
"def head(url, headers = {})\n request(:head, url, headers)\n end",
"def head(url, headers = {})\n request(:head, url, headers)\n end",
"def get(uri, query = {}, &block) \n request(:get, uri, query, &block)\n end",
"def get(url, params={}, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n # add URL parameters\n uri.query = URI.encode_www_form(params)\n\n debug(\"GET #{uri} #{headers.inspect}\")\n\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Get.new(uri.request_uri, headers)\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n get_raw(response['location'], params, headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end",
"def get url, options={}\n response = self.class.get(url, {:query => options}).parsed_response\n raise Skydrive::Error.new(response[\"error\"]) if response[\"error\"]\n response[\"data\"] ? response[\"data\"] : response\n end",
"def get(path, params = {})\n request = HTTPI::Request.new(build_url(path, params))\n request.proxy = proxy unless proxy.nil?\n parse_response(HTTPI.get(request))\n end",
"def get(url, params = nil, headers = nil)\n faraday_response = faraday.get(url, params, headers) do\n _1.options[:proxy] = random_proxy\n end\n Response.new(faraday_response)\n end",
"def get(path = nil)\n url = URI.parse(@url.scheme + '://' + @url.host + ':' + @url.port.to_s + path.to_s)\n headers = { \"Authorization\" => \"Basic \" + [@user + \":\" + @password].pack(\"m\") } if @user\n \n server = Net::HTTP.new(@url.host, @url.port)\n server.read_timeout = @timeout\n server.use_ssl = url.scheme == 'https'\n server.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n res, data = server.get(url.request_uri, headers)\n \n case res\n when Net::HTTPSuccess\n # OK\n else\n raise res.inspect\n end\n [res, data]\n end"
] | [
"0.85870266",
"0.85305065",
"0.83588445",
"0.83588445",
"0.8213956",
"0.7912093",
"0.79002655",
"0.7849229",
"0.7670843",
"0.76333576",
"0.76230216",
"0.761041",
"0.74752575",
"0.74572265",
"0.7432885",
"0.7385609",
"0.72676575",
"0.7248267",
"0.7227382",
"0.7164586",
"0.71449566",
"0.710442",
"0.7101061",
"0.7090816",
"0.7079389",
"0.7023921",
"0.69694364",
"0.6957263",
"0.69553196",
"0.69393194",
"0.69267935",
"0.6925638",
"0.6921529",
"0.6911486",
"0.68781906",
"0.6869972",
"0.6869219",
"0.6852524",
"0.6836569",
"0.6832898",
"0.6828942",
"0.68230164",
"0.6807097",
"0.6804186",
"0.6801051",
"0.67809165",
"0.67747515",
"0.6773539",
"0.677058",
"0.6754628",
"0.6751301",
"0.6742818",
"0.67317325",
"0.67106164",
"0.6698199",
"0.6695532",
"0.6683807",
"0.66781706",
"0.66729957",
"0.6669132",
"0.6666635",
"0.6662206",
"0.664878",
"0.66429883",
"0.65990615",
"0.65911746",
"0.6574881",
"0.6571837",
"0.6571837",
"0.6570731",
"0.6562684",
"0.6559162",
"0.65532506",
"0.655078",
"0.65460014",
"0.6543123",
"0.6539586",
"0.6539586",
"0.6538821",
"0.65308946",
"0.65275127",
"0.65180767",
"0.65098614",
"0.64939356",
"0.6491024",
"0.6488324",
"0.64844966",
"0.6481034",
"0.64729685",
"0.64642066",
"0.6459966",
"0.6451707",
"0.64453095",
"0.64453095",
"0.6435171",
"0.6433128",
"0.64310974",
"0.642848",
"0.6427014",
"0.6421257"
] | 0.7834818 | 8 |
This performs a basic POST request using the supplied URL, payload and headers | def post(url, payload = {}, headers = {})
http :post, "#{url}.json", payload.to_json, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(url, payload, headers: {}, options: {})\n request_with_payload(:post, url, payload, headers, options)\n end",
"def post(url, payload, headers={})\n payload = MultiJson.encode(payload)\n headers = headers.merge({:content_type => 'application/json'})\n request(:post, url, payload, headers)\n end",
"def send_post_request(url, payload, content_type = 'application/json')\n # set the uri\n url = URI(url)\n\n # set http settings\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n # set request\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = content_type\n request[\"cache-control\"] = 'no-cache'\n\n # set the payload\n request.body = payload\n\n # send the request and get whatever is the response\n response = http.request(request)\n\n # return the response by reading the body\n return response.read_body\n end",
"def post url, body, headers = {}\n http_request(url, Net::HTTP::Post, body, headers)\n end",
"def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end",
"def post(url, headers, body)\n request(:post, url, headers, body)\n end",
"def post(url, body, headers = {})\n do_request Net::HTTP::Post, url, headers, body\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 post(url, data, headers = {})\n request(:post, url, headers, :data => data)\n end",
"def post(payload = {})\n request! do\n api[url.path].post(to_payload(payload), API_HEADERS)\n end\n end",
"def post(url, query = {}, payload = {})\n restclient({\n method: :post,\n url: \"#{@scheme}://#{@host}/#{url}\",\n timeout: Timeout,\n open_timeout: OpenTimeout,\n payload: payload.to_json,\n headers: {\n authorization: @auth,\n content_type: :json,\n accept: :json,\n params: query\n }\n })\n end",
"def post(payload)\n post_like payload, Net::HTTP::Post.new(@uri.path)\n end",
"def post(url, post_vars={})\n send_request url, post_vars, 'POST'\n end",
"def http_post(payload)\n LOGGER.info(\"Sending POST request to #{@collector_uri}...\")\n LOGGER.debug(\"Payload: #{payload}\")\n destination = URI(@collector_uri)\n http = Net::HTTP.new(destination.host, destination.port)\n request = Net::HTTP::Post.new(destination.request_uri)\n if destination.scheme == 'https'\n http.use_ssl = true\n end\n request.body = payload.to_json\n request.set_content_type('application/json; charset=utf-8')\n response = http.request(request)\n LOGGER.add(is_good_status_code(response.code) ? Logger::INFO : Logger::WARN) {\n \"POST request to #{@collector_uri} finished with status code #{response.code}\"\n }\n\n response\n end",
"def dropbox_post(url, headers: {}, payload: nil)\n raise ArgumentError, \"missing keyword: payload\" unless payload\n\n require \"net/https\"\n require \"uri\"\n\n headers = {\n \"Authorization\" => \"Bearer #{config[\"token\"]}\",\n \"Content-Type\" => \"application/json\"\n }.merge(headers)\n\n unless payload.nil? || payload.is_a?(String)\n payload = JSON.generate(payload)\n end\n\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n\n http.post(uri.path, payload, headers).tap do |response|\n log { \"POST #{url}\" }\n\n unless payload.nil? || payload.is_a?(String)\n log { \" PAYLOAD --> #{payload}\" }\n end\n\n log { \" RESPONSE --> #{response.body}\" }\n\n return yield response\n end\n end",
"def post(query_url,\r\n headers: {},\r\n parameters: {})\r\n HttpRequest.new(HttpMethodEnum::POST,\r\n query_url,\r\n headers: headers,\r\n parameters: parameters)\r\n end",
"def post(url, payload, options={}, &block)\n http_options = options.merge(@basic_options)\n if block_given?\n RestClient.post(url, payload, http_options, &block)\n else\n RestClient.post(url, payload, http_options)\n end\n end",
"def post(url, options = {}, &block)\n run! Request.new(url, :post, options.slice(:headers, :params, :payload), &block)\n end",
"def post payload, path = \"\" \n make_request(path, \"post\", payload)\n end",
"def post(path, payload)\n req = Net::HTTP::Post.new(path)\n action(req, payload)\n end",
"def post(url, body, headers: {}, params: {}, options: {}, &block)\n raise ArgumentError, \"'post' requires a string 'body' argument\" unless body.is_a?(String)\n url = encode_query(url, params)\n\n request = Net::HTTP::Post.new(url, @default_headers.merge(headers))\n request.body = body\n request.content_length = body.bytesize\n\n raise ArgumentError, \"'post' requires a 'content-type' header\" unless request['Content-Type']\n\n execute_streaming(request, options: options, &block)\n end",
"def post(uri, request_headers, body)\n request('post', uri, request_headers, body)\n end",
"def post(url, options)\n headers = options[:headers] || {}\n params = options[:params] || {}\n req = Net::HTTP::Post.new(url)\n req = request_with_headers(req, headers)\n request_with_params(req, params)\n end",
"def post url, object = nil\n request url, HTTP::Post, object\n end",
"def post(url, payload)\n options = {body: payload}\n res = HTTParty.post(ROOT + url, options)\n ap res\n raise PushTransactionFailed.new(res.body, options.merge!({\"status\" => res.code})) if res.code >= 400\n res.body\n end",
"def post(object, url, headers={})\n do_request(\"post\", url, object, headers)\n end",
"def simple_post(plain_url, params, user_headers)\n url = URI.parse(plain_url)\n\n headers = self.class.default_headers.merge(user_headers)\n\n req = Net::HTTP::Post.new(url.path, headers)\n req.set_form_data(params)\n\n if DEBUG_REQ\n puts \"=== Debug Http Request\"\n puts \"url => #{url}\"\n puts \"body => #{req.body}\"\n puts \"=== Fim Debug Http Request\"\n end\n\n res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n else\n res.error!\n end\n\n plain_html = res.body\n if DEBUG_REQ\n puts \"=== Debug Http Response Body\"\n puts plain_html\n puts \"=== Fim Debug Http Response Body\"\n end\n plain_html\n end",
"def http_post(url, hash=nil, _port=nil, headers=nil)\n \n resp, data = http_request(url, \"post\", hash, _port, headers)\n\treturn [resp, data]\nend",
"def post(url, req_hash={})\n res = nil\n res = perform_op(:post, req_hash) do\n res = @wrapper.post(url, req_hash)\n end\n return res\n end",
"def post(url, body, headers)\n conn = create_connection_object(url)\n\n http = conn.post(:body => body,\n :head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end",
"def post(path: nil, payload: nil, headers: {}, query: {}, auth_method: nil)\n execute(\n method: :post,\n path: path,\n headers: headers,\n query: query,\n payload: payload,\n auth_method: auth_method\n )\n end",
"def send_post(endpoint, payload = {})\n payload['token'] = @token unless payload['token']\n http = Net::HTTP.new(@root_uri.host, @root_uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @test_environment\n request = Net::HTTP::Post.new(\"#{@root_uri}#{endpoint}\")\n request.set_form_data(payload)\n process_response(http.request(request))\n end",
"def post(url, data, headers = {})\n if data.is_a?(Hash)\n data = data.map {|k,v| urlencode(k.to_s) + '=' + urlencode(v.to_s) }.join('&')\n headers['Content-Type'] = 'application/x-www-form-urlencoded'\n end\n request(:post, url, headers, :data => data)\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def post(url, payload)\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Post.new(url.path+'?access_token=verysecret')\n request.content_type = 'application/json'\n request.body = JSON.generate(payload)\n response = http.start {|http| http.request(request) }\n begin\n return JSON.parse(response.body)\n rescue\n # Log as a problematic case with rule number and line\n $problems.write \"#{$index}, #{payload}, #{response.body}\\n\"\n return nil\n end\nend",
"def post(url, token, params, headers)\n puts \"post to #{url}\"\n uri = URI.parse(url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n req = Net::HTTP::Post.new(uri.path, headers)\n req['Authorization'] = \"token #{token}\" if token\n\n return http.request(req, params)\nend",
"def post(body = nil, headers = {}, path = '')\n uri = URI.parse(\"#{@url}#{path}\")\n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = body\n send_request(uri, request, headers)\n end",
"def post(url, body = {})\n call(url: url, action: :post, body: body)\n end",
"def post(uri, query = T.unsafe(nil), headers = T.unsafe(nil)); end",
"def run_request(method, url, body, headers); end",
"def post(path, payload={})\n request(:post, path, payload)\n end",
"def post(url, post_data, custom_headers = {})\n headers = @default_headers.merge(custom_headers)\n # slow down the request rate! otherwise you will get blocked\n sleep 1\n return @agent.post(url, post_data, headers)\n end",
"def post(url, args = {})\r\n make_request(:post, url, args)\r\n end",
"def httppost(url, corpNum, postData, action = '', userID = '', contentsType = '')\n\n headers = {\n \"x-pb-version\" => BaseService::POPBILL_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n if contentsType == ''\n headers[\"Content-Type\"] = \"application/json; charset=utf8\"\n else\n headers[\"Content-Type\"] = contentsType\n end\n\n if corpNum.to_s != ''\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n end\n\n if userID.to_s != ''\n headers[\"x-pb-userid\"] = userID\n end\n\n if action.to_s != ''\n headers[\"X-HTTP-Method-Override\"] = action\n end\n\n uri = URI(getServiceURL() + url)\n\n https = Net::HTTP.new(uri.host, 443)\n https.use_ssl = true\n Net::HTTP::Post.new(uri)\n\n res = https.post(uri.request_uri, postData, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise PopbillException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end",
"def post(url, body = nil, headers = nil)\n faraday_response = faraday.post(url, body, headers) do\n _1.options[:proxy] = random_proxy\n end\n Response.new(faraday_response)\n end",
"def post_with_app(url, payload = '')\n github_api_conn.post do |request|\n request.url url\n\n request.headers['Authorization'] = \"Token #{access_token}\"\n request.headers['Accept'] = accept_header\n request.body = payload\n end\n end",
"def post(uri, params = {})\n send_request(uri, :post, params)\n end",
"def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def post(resource_url, params, data=nil)\n headers = {'Authorization' => authorization('POST', resource_url, params)}\n url = resource_url + '?' + URI.encode_www_form(params)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n res = http.request_post(url, data, headers)\n Response.new(res)\n end",
"def post(url, options = {}, &block)\n request HttpPost, url, options, &block\n end",
"def make_post_request(route:, headers: nil, body: nil)\n post route, params: body, headers: headers\nend",
"def http_post(url, data)\n\turi = URI(url)\n\treq = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})\n req.body = data.to_json\n response = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }\n return response\nend",
"def post(url, params = {})\n client.post(url, params).body\n end",
"def post url, params={}, postdata={}, headers={}\n uri = URI.parse(url)\n p = postdata.to_json\n h = default_headers.merge(headers)\n path = uri.path + \"?\" + query_string(default_params.merge(params))\n response = http(uri.host, uri.port).post(path, p, h)\n\n if (response.code.to_i) == 200 && (response.content_type == \"text/json\")\n hash = JSON.parse(response.body)\n\n else\n raise StandardError.new(\n \"Request:\\n\" +\n \"path: #{path}\\n\" +\n \"headers: #{h}\\n\" +\n \"#{p}\\n\" +\n \"Response:\\n\" +\n \"--\\n\" +\n \"Response:\\n\" +\n \"status: #{response.code}\\n\" +\n \"content-type: #{response.content_type}\\n\" +\n response.body)\n end\n\n # If this response contains a changeset, apply it.\n if hash.include?(\"ChangeSet\")\n apply_changeset(hash[\"ChangeSet\"])\n end\n\n hash\n end",
"def post(uri, request_headers, body)\n raise NotImplementedError\n end",
"def http_post_request(url, body = nil)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = body || ''\n response = http.request(request)\n return response.body\n end",
"def signed_post_request url, body\n body_json= body.to_json\n token = jwt_post_signature url, body_json\n HTTParty.post('http://localhost:5000'+url,\n {headers:{\n \"Authorization\"=>\"JWT token=\\\"#{token}\\\"\",\n \"Content-Type\"=> \"application/json;charset=utf-8\",\n },\n body: body_json}\n )\n\n end",
"def post\n uri = URI.parse(self.url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.open_timeout = 10\n http.read_timeout = 10\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n data = self.params.collect { |k, v| \"#{k}=#{CGI.escape(v.to_s)}\" }.join(\"&\")\n Freemium.log_test_msg(\"POST\\n url: #{self.url}\\n query: #{data}\")\n http.post(uri.request_uri, data).body\n end",
"def http_post(uri, data)\n RestClient.post uri, data\n end",
"def post url, parameters = {}, headers = {}\n @request_meter.mark\n\n try_n_times do\n @current_url = url\n escaped_url = URI.escape url\n\n GapCrawler.logger.debug \"POST: #{escaped_url}\\nParameters: #{parameters}\\nCustom Headers: #{headers}\"\n\n fetcher { @agent.post url, parameters, headers }\n end\n end",
"def http_post(curl, data, url)\n\n # Define the post data\n data2 = ''\n\n # Loop through the data[\"post_data\"] passed in to build up the post data string\n data[\"post_data\"].each do |key, value|\n if (data2 != '') then\n data2 = data2 + '&'\n end\n # If the value is null we don't just want it to look like: item=\n if (value.nil?) then\n data2 = data2 + CGI::escape(key.to_s) + '='\n else\n data2 = data2 + CGI::escape(key.to_s) + '=' + CGI::escape(value.to_s)\n end\n end\n\n # Define the url we want to hit\n curl.url = url\n # Specify the headers we want to hit\n curl.headers = data['header']\n\n # perform the call\n curl.post(data2)\n\n curl.headers = nil\n\n # Set headers to nil so none get reused elsewhere\n curl.headers = nil\n\n # return the curl object\n return curl\n\nend",
"def POST(data=nil, headers=nil)\n\n\t\tif not data.nil? #if request data passed in, use it.\n\t\t\t@data = data\n\t\tend\n\n\t\turi = URI(@url)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\thttp.use_ssl = true\n\t\trequest = Net::HTTP::Post.new(uri.path)\n\t\trequest.body = @data\n\n\t\tif @search_type == 'premium'\n\t\t\trequest['Authorization'] = \"Bearer #{@app_token}\"\n\t\telse\n\t\t\trequest.basic_auth(@app_token, @password)\n\t\tend\n\n\t\tbegin\n\t\t\tresponse = http.request(request)\n\t\trescue\n\t\t\tlogger()\n\t\t\tsleep 5\n\t\t\tresponse = http.request(request) #try again\n\t\tend\n\n\t\treturn response\n\tend",
"def post(endpoint, url, args, version = 'v1')\n qs = build_qs(args)\n req_url = \"#{url}/api/#{version}/#{endpoint}?#{qs}\"\n\n request(req_url, :POST)\n end",
"def execute(url, method, options = {}, payload = nil)\n request, parser = prepare_and_split_options(url, method, options)\n # Prepare the payload if it is provided\n request[:payload] = payload_from_doc(payload, parser) if payload\n begin\n parse_response(RestClient::Request.execute(request), parser)\n rescue Exception => e\n if $DEBUG\n raise \"Error while sending a #{method.to_s.upcase} request #{uri}\\noptions: #{opts.inspect}\\n#{e}\"\n else\n raise e\n end\n end\n end",
"def request(method, url, payload, format)\n opts = {\n :method => method,\n :url => url,\n :payload => payload,\n :headers => {:content_type => CONTENT_TYPES[format]},\n :timeout => TIMEOUT,\n :open_timeout => OPEN_TIMEOUT\n }\n \n RestClient::Request.execute(opts)\n end",
"def post(params)\n self.class.post(url, body: params)\n end",
"def post\n @response_body = make_request(\"#{api_url}#{endpoint}\", request_body.to_json)\n puts \"GLIMR POST: #{endpoint} - #{request_body.to_json}\" if ENV.key?('GLIMR_API_DEBUG')\n end",
"def http_post(uri:, additional_headers: {}, data: {}, basic_auth: nil, debug: false)\n return nil if uri.blank?\n\n opts = options(additional_headers: additional_headers, debug: debug)\n opts[:body] = data\n opts[:basic_auth] = basic_auth if basic_auth.present?\n HTTParty.post(uri, opts)\n rescue URI::InvalidURIError => e\n handle_uri_failure(method: \"BaseService.http_post #{e.message}\", uri: uri)\n nil\n rescue HTTParty::Error => e\n handle_http_failure(method: \"BaseService.http_post #{e.message}\", http_response: nil)\n nil\n end",
"def httppost(url, corpNum, postData, action = '', userID = '', contentsType = '')\n\n headers = {\n \"x-lh-version\" => KAKAOCERT_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n apiServerTime = @linkhub.getTime(@useStaticIP, @useGAIP)\n\n hmacTarget = \"POST\\n\"\n hmacTarget += Base64.strict_encode64(Digest::SHA256.digest(postData)) + \"\\n\"\n hmacTarget += apiServerTime + \"\\n\"\n\n hmacTarget += KAKAOCERT_APIVersion + \"\\n\"\n\n key = Base64.decode64(@linkhub._secretKey)\n\n data = hmacTarget\n digest = OpenSSL::Digest.new(\"sha256\")\n hmac = Base64.strict_encode64(OpenSSL::HMAC.digest(digest, key, data))\n\n headers[\"x-kc-auth\"] = @linkhub._linkID+' '+hmac\n headers[\"x-lh-date\"] = apiServerTime\n\n if contentsType == ''\n headers[\"Content-Type\"] = \"application/json; charset=utf8\"\n else\n headers[\"Content-Type\"] = contentsType\n end\n\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n\n\n uri = URI(getServiceURL() + url)\n\n https = Net::HTTP.new(uri.host, 443)\n https.use_ssl = true\n Net::HTTP::Post.new(uri)\n\n res = https.post(uri.request_uri, postData, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise KakaocertException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end",
"def request(post_body, headers)\n request = Net::HTTP::Post.new(endpoint_uri.path, headers)\n authenticate(request) if username\n request.body = post_body\n response = @client.request(request)\n { status: response.code.to_i, body: response.body, content_type: response.content_type }\n end",
"def post(url, data={}, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n\n debug(\"POST #{uri} #{headers.inspect}\")\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Post.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n post_raw(response['location'], data, headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end",
"def post_request(uri, body, token = nil, manage_errors = true)\n request = Net::HTTP::Post.new(uri.request_uri, initheader = build_headers(token))\n request.body = body.to_json\n return do_request(uri, request, manage_errors) \n end",
"def post_request(path, params={}, options={})\n request(:post, path, params, options)\n end",
"def post_json(endpoint, payload, username = nil, password = nil, endpoint_stub = API_ENDPOINT)\n uri = URI(\"#{endpoint_stub}#{endpoint}\")\n\n res = ''\n Net::HTTP.start(uri.host, uri.port,\n :use_ssl => uri.scheme == 'https', \n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n req = Net::HTTP::Post.new(uri.request_uri)\n req.basic_auth(username, password) if username && password\n req['Content-Type'] = 'application/json'\n req.body = payload.to_json\n\n res = http.request(req)\n end\n\n JSON.parse(res.body.to_s)\nend",
"def post(endpoint, params = {})\n\n path = build_connect_url(endpoint)\n headers = build_headers(endpoint, 'POST', params)\n\n log \"POST \" + path + \" \" + params.to_s\n log headers.to_s\n\n begin\n response = RestClient::Request.execute(method: :post, url: path, payload: params.to_json, headers: headers, timeout: 15)\n rescue RestClient::ExceptionWithResponse => e\n log e.http_code.to_s + \" \" + e.response.to_s\n return e.response\n end\n\n log response.code.to_s + \" \" + response.to_s\n\n response\n\n end",
"def post(path, params = nil)\n response = @connection.post do |req|\n req.headers = generate_headers\n req.url path\n req.body = params.to_json\n end\n Arke::Log.fatal(build_error(response)) if response.env.status != 201\n response\n end",
"def post(path, query, headers, body)\n http = EventMachine::HttpRequest.new(url, http_options).post :head => headers, :path => path, :query => query, :body => body\n http.callback { puts \"forward url -> #{url}\" }\n http.errback { puts \"ERROR: failed forward to url #{url}\" }\n end",
"def post(endpoint, body, headers = {})\n headers = { accept: :json, content_type: :json }.merge(headers)\n @rest_resource[endpoint].post body, headers\n end",
"def post(url, json_body)\n setup_or_refresh_rest_session\n @session.post(url: url, json_body: json_body)\n end",
"def post_response(url, body, headers = {})\n logger.debug \"POST (response) #{url}\"\n uri = normalize_url(url)\n\n req = Net::HTTP::Post.new(uri.request_uri)\n headers.each {|k,v| req.add_field k, v}\n assign_body(req, body)\n\n http = authenticate_request(uri, req)\n response = http.request(req)\n logger.debug \"POSTED (#{response.code}) #{url}\"\n response\n end",
"def post_with_curl\n url = @settings.webhook_url\n `curl -is -X POST -H \"Content-Type:application/json\" -d '#{get_body}' '#{url}'`\n end",
"def post(path, headers, body, &callback)\n request('POST', path, headers, body, &callback)\n end",
"def http_request(params)\n Net::HTTP::Post.new(endpoint.request_uri).tap do |request|\n request.body = URI.encode_www_form params\n request.content_type = 'application/x-www-form-urlencoded; charset=utf-8'\n end\n end",
"def post(url, query = nil, headers = nil)\n headers = headers ? @headers.merge(headers) : @headers\n #Log.t(\"POST: #{url}\\n#{query.inspect}\\n#{headers.inspect}\")\nres = @client.post(URI.join(@base, url), query, headers) rescue nil\n\t#puts \"*******************************************\"\n\t#puts res.inspect\n if res != nil\n\t@responseHeaders = res.header\n Nokogiri::HTML(res.body)\n else\n Nokogiri::HTML('')\n end\n end",
"def send_request\n if payload\n payload_type = payload.is_a?(String) ? :body : :form\n\n @http.public_send(method, url, payload_type => payload, ssl_context: ssl_options)\n else\n @http.public_send(method, url, ssl_context: ssl_options)\n end\n end",
"def post query=nil, content_type='application/x-www-form-urlencoded'\n\t\treq = Net::HTTP::Post.new(@uri.path)\n\n\t\treq.body= make_query query if query\n\t\treq.content_type=content_type if query\n\t\treq.content_length=query ? req.body.length : 0\n\n\t\tdo_http req\n\tend",
"def post(action, params = T.unsafe(nil), header = T.unsafe(nil), query = T.unsafe(nil)); end",
"def http_post(url, params, json = false)\n content_type = {}\n if json && params\n params = params.to_json\n content_type['Content-Type'] = 'application/json'\n end\n headers = @auth_headers.merge(content_type)\n exponential_backoff do\n @mutex.synchronize do\n begin\n response = @agent.post(url, params, headers)\n return JSON.parse(response.body)\n rescue Net::HTTP::Persistent::Error\n reset_http_agent\n response = @agent.post(url, params, headers)\n return JSON.parse(response.body)\n end\n end\n end\n end",
"def post(href, additional_parameters = {})\n rest_connect do |base_uri, headers|\n href = \"#{base_uri}/#{href}\" unless begins_with_slash(href)\n res = Net::HTTP::Post.new(href , headers)\n unless additional_parameters.empty?\n res.set_content_type('application/json')\n res.body = additional_parameters.to_json\n end\n #res.set_form_data(additional_parameters, '&')\n res\n end\n end",
"def post(api_version, resource, payload, query_parameters = nil,\n headers = nil)\n make_rest_call(:post, uri_builder(api_version, resource,\n query_parameters), payload, headers)\n end",
"def post_request(url,args)\n uri = URI.parse(url)\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data(args)\n request(uri,req)\n end",
"def http_post\n req = Net::HTTP::Post.new @uri.request_uri, request_headers\n req.set_form_data params\n req.basic_auth @proxy_user, @proxy_pass if @proxy_pass && @proxy_user\n req\n end",
"def post(url)\n response = RestClient::Request.new(\n method: :post,\n url: \"#{ENDPOINT_URL}/#{url}\",\n verify_ssl: false,\n headers: {\n 'Content-Type' => 'application/json',\n 'Authorization' => \"Basic #{authorization_hash}\"\n },\n payload: {user: user, pwd: password}.to_json\n ).execute\n\n # Parse the response to Ruby objects\n JSON.parse(response)\n end",
"def make_rest_call(method, url, payload = nil, headers = nil)\n options = call_options_builder(method, url, payload, headers)\n RestClient::Request.execute(options)\n rescue => e\n raise e\n end",
"def post(api_route, url_params_hash)\n @request_class = Net::HTTP::Post\n set_api_url(api_route, url_params_hash)\n send\n end",
"def post_request(secureNetId, secureKey, url)\n uri = URI.parse(url) # Parse the URI\n http = Net::HTTP.new(uri.host, uri.port) # New HTTP connection\n http.use_ssl = true # Must use SSL!\n req = Net::HTTP::Post.new(uri.request_uri) # HTTP POST request \n body = {} # Request body hash\n yield body # Build body of request\n req.body = body.to_json # Convert hash to json string\n req[\"Content-Type\"] = 'application/json' # JSON body\n req[\"Origin\"] = 'worldpay.com' # CORS origin\n req.basic_auth secureNetId, secureKey # HTTP basic auth\n res = http.request(req) # Make the call\n return JSON.parse(res.body) # Convert JSON to hashmap\nend",
"def post(uri, options = T.unsafe(nil)); end",
"def post(url, params = {})\n post_auth_hash = {\n \"oauth_consumer_key\" => \"#{@consumer_key}\",\n \"oauth_token\" => \"#{@access_token[\"oauth_token\"]}\",\n \"oauth_signature_method\" => \"HMAC-SHA1\",\n \"oauth_timestamp\" => timestamp,\n \"oauth_nonce\" => nonce,\n \"oauth_version\" => \"1.0\",\n }\n\n # set signature\n post_auth_hash[\"oauth_signature\"] = generate_access_signature(generate_signature_base_string(\"POST\", url, post_auth_hash, params))\n\n # post with auth header\n return MyHttp.post(url, params, {\n \"Authorization\" => \"OAuth #{generate_auth_header(post_auth_hash)}\",\n \"Content-Type\" => \"application/x-www-form-urlencoded\",\n })\n end",
"def post_json(url, body = nil, headers = nil)\n body = body.to_json\n headers = (headers || {}).merge('Content-Type' => 'application/json')\n post(url, body, headers)\n end",
"def post(resource, body = \"\", headers = {})\n prepare_request(:post, resource, body, headers)\n end"
] | [
"0.84302634",
"0.80263704",
"0.7911639",
"0.77735686",
"0.7758614",
"0.7733568",
"0.7709064",
"0.73818666",
"0.73346424",
"0.7326004",
"0.7272792",
"0.72559726",
"0.7231427",
"0.7212969",
"0.7157233",
"0.71504617",
"0.70935875",
"0.70628935",
"0.7015264",
"0.70148796",
"0.69810295",
"0.69570214",
"0.69344693",
"0.69303846",
"0.69203955",
"0.68985426",
"0.68972516",
"0.6859896",
"0.68553436",
"0.68522775",
"0.6843133",
"0.68400836",
"0.6822451",
"0.6813498",
"0.6808976",
"0.68033475",
"0.67975515",
"0.67495185",
"0.6725787",
"0.66963995",
"0.66923475",
"0.66823345",
"0.6681162",
"0.65932727",
"0.6588858",
"0.6583508",
"0.6583303",
"0.65683275",
"0.6551732",
"0.65345335",
"0.65310687",
"0.6512625",
"0.6488432",
"0.64719474",
"0.6455558",
"0.6450738",
"0.64495",
"0.6409223",
"0.64007425",
"0.6389273",
"0.63891447",
"0.63830763",
"0.63798696",
"0.6374154",
"0.63672215",
"0.6363139",
"0.63597363",
"0.63510936",
"0.6328541",
"0.63262606",
"0.6310213",
"0.6301934",
"0.62975425",
"0.62869906",
"0.6284293",
"0.62841755",
"0.62408876",
"0.623677",
"0.6233334",
"0.62323177",
"0.6231785",
"0.62297827",
"0.6210563",
"0.62100685",
"0.61893016",
"0.6178118",
"0.6177794",
"0.6168753",
"0.61565185",
"0.61494404",
"0.6143928",
"0.6134889",
"0.6134779",
"0.61232513",
"0.61175746",
"0.61078393",
"0.6107156",
"0.61057526",
"0.6104663",
"0.60986435"
] | 0.8125234 | 1 |
This performs a basic PUT request using the supplied URL, payload and headers | def put(url, payload = {}, headers = {})
http :put, "#{url}.json", payload.to_json, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(url, payload, headers: {}, options: {})\n request_with_payload(:put, url, payload, headers, options)\n end",
"def put(url, payload, headers={})\n RestClient.put url, payload, headers\n end",
"def put(url, payload, headers={})\n payload = MultiJson.encode(payload)\n headers = headers.merge({:content_type => 'application/json'})\n request(:put, url, payload, headers)\n end",
"def put url, body, headers = {}\n http_request(url, Net::HTTP::Put, body, headers)\n end",
"def put url, payload\n RestClient::Request.execute(:method => :put, :url => url, :payload => payload, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end",
"def put(payload = {})\n request! do\n api[url.path].put(to_payload(payload), API_HEADERS)\n end\n end",
"def put(url, payload, options={}, &block)\n http_options = options.merge(@basic_options)\n if block_given?\n RestClient.put(url, payload, http_options, &block)\n else\n RestClient.put(url, payload, http_options)\n end\n\n end",
"def put(url, options = {}, &block)\n run! Request.new(url, :put, options.slice(:headers, :params, :payload), &block)\n end",
"def put(url, data, headers = {})\n request(:put, url, headers, :data => data)\n end",
"def put(url, data, headers = {})\n request(:put, url, headers, :data => data)\n end",
"def put(path: nil, payload:, headers: {}, query: {}, auth_method: nil)\n execute(\n method: :put,\n path: path,\n headers: headers,\n query: query,\n payload: payload,\n auth_method: auth_method\n )\n end",
"def put(object, url, headers={})\n do_request(\"put\", url, object, headers)\n end",
"def put(url, body = {})\n call(url: url, action: :put, body: body)\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def put(url, vars={})\n send_request url, vars, 'PUT'\n end",
"def put url, object = nil\n request url, HTTP::Put, object\n end",
"def put(url, body, headers: {}, params: {}, options: {})\n raise ArgumentError, \"'put' requires a string 'body' argument\" unless body.is_a?(String)\n url = encode_query(url, params)\n\n request = Net::HTTP::Put.new(url, @default_headers.merge(headers))\n request.body = body\n request.content_length = body.bytesize\n\n raise ArgumentError, \"'put' requires a 'content-type' header\" unless request['Content-Type']\n\n execute_streaming(request, options: options)\n end",
"def put(path, payload)\n req = Net::HTTP::Put.new(path)\n action(req, payload)\n end",
"def put(uri, request_headers, body)\n request('put', uri, request_headers, body)\n end",
"def put(url, payload)\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n request = Net::HTTP::Put.new(url.path+'?access_token=verysecret')\n request.content_type = 'application/json'\n request.body = JSON.generate(payload)\n begin\n response = http.start {|http| http.request(request) }\n rescue\n puts url\n end\n begin\n return JSON.parse(response.body)\n rescue\n # Log as a problematic case with rule number and line\n $problems.write \"#{$index}, #{payload}, #{response.body}\\n\"\n return nil\n end\nend",
"def put(query_url,\r\n headers: {},\r\n parameters: {})\r\n HttpRequest.new(HttpMethodEnum::PUT,\r\n query_url,\r\n headers: headers,\r\n parameters: parameters)\r\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def put(body = nil, headers = {}, path = '')\n uri = URI.parse(\"#{@url}#{path}\")\n request = Net::HTTP::Put.new(uri.request_uri)\n request.body = body\n send_request(uri, request, headers)\n end",
"def put(uri, params = {})\n send_request(uri, :put, params)\n end",
"def http_put(url, params, &request_modifier)\n uri = URI.parse url\n req = Net::HTTP::Put.new uri.path\n req.set_form_data(params)\n request_modifier && (request_modifier.call req)\n\n session = (Net::HTTP.new uri.host, uri.port)\n case res = session.start { |http| http.request req }\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n else\n res.error!\n end\n end",
"def put(uri, request_headers, body)\n raise NotImplementedError\n end",
"def put endpoint, data\n do_request :put, endpoint, data\n end",
"def do_put(uri = '', body = '')\n build_request(:put, uri, body)\n end",
"def put(url, options = {}, &block)\n request HttpPut, url, options, &block\n end",
"def update(uri, payload)\n url = \"#{@config[:base_url]}#{@config[:rest_path]}/#{extract_pid(uri)}\"\n request = Request.new(\n \"Put\", url, payload.to_s, {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => \"nnnn\",\n @auth_header => @token\n }\n )\n response = request.perform\n response\n end",
"def make_put_request(url, data)\n headers = {\n \"Content-Type\" => \"application/json\",\n }\n\n response = HTTParty.put(url, body: data.to_json, headers: headers)\n\n if response.success?\n response\n else\n puts \"Request failed with response code: #{response.code}\"\n puts \"Response message: #{response.message}\"\n nil\n end\nend",
"def put(href, additional_parameters = {})\n rest_connect do |base_uri, headers|\n href = \"#{base_uri}/#{href}\" unless begins_with_slash(href)\n new_path = URI.escape(href)\n req = Net::HTTP::Put.new(new_path, headers) \n req.set_content_type('application/json')\n req.body = additional_parameters.to_json\n req\n end\n end",
"def put(endpoint, params = {})\n\n path = build_connect_url(endpoint)\n headers = build_headers(endpoint, 'PUT', params)\n\n log \"PUT \" + path + \" \" + params.to_s\n log headers.to_s\n\n begin\n response = RestClient::Request.execute(method: :put, url: path, payload: params.to_json, headers: headers, timeout: 15)\n rescue RestClient::ExceptionWithResponse => e\n log e.http_code.to_s + \" \" + e.response.to_s\n return e.response\n end\n\n log response.code.to_s + \" \" + response.to_s\n\n response\n\n end",
"def send_put_request endpoint, params={}, api_key=nil, ssl=false\n uri = URI.parse(endpoint)\n\n Net::HTTP.start(uri.host, uri.port) do |http|\n http.use_ssl = true if ssl\n request = Net::HTTP::Put.new(uri.request_uri)\n request['authorization'] = \"Token token=#{api_key}\" if api_key\n request.set_form_data(params)\n http.request request\n end\n end",
"def put(params)\n self.class.put(url, body: params)\n end",
"def put_request(path, params={}, options={})\n request(:put, path, params, options)\n end",
"def put(api_version, resource, payload, query_parameters = nil,\n headers = nil)\n make_rest_call(:put, uri_builder(api_version, resource,\n query_parameters), payload, headers)\n end",
"def put(url, data={}, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n\n debug(\"PUT #{uri} #{headers.inspect}\")\n\n # unless the data is already a string, assume JSON and convert to string\n data = data.to_json unless data.is_a? String\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Put.new(uri.request_uri, headers)\n request.body = data\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n put_raw(response['location'], data, headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end",
"def http_put(uri:, additional_headers: {}, data: {}, basic_auth: nil, debug: false)\n return nil if uri.blank?\n\n opts = options(additional_headers: additional_headers, debug: debug)\n opts[:body] = data\n opts[:basic_auth] = basic_auth if basic_auth.present?\n HTTParty.put(uri, opts)\n rescue URI::InvalidURIError => e\n handle_uri_failure(method: \"BaseService.http_put #{e.message}\", uri: uri)\n nil\n rescue HTTParty::Error => e\n handle_http_failure(method: \"BaseService.http_put #{e.message}\", http_response: nil)\n nil\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def put(path, headers: {}, query: {}, payload: {})\n (headers, query, payload) = preprocess(headers, query, payload)\n respond_with super(path, headers: headers, query: query, payload: payload)\n end",
"def do_put(uri = \"\", body = \"\")\n @connection.put do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n req.body = body\n end\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase do_put\", \"Error trying to send a PUT to #{uri}\"\n $lxca_log.error \"XClarityClient::XclarityBase do_put\", \"Request sent: #{body}\"\n Faraday::Response.new\n end",
"def put(resource, body = \"\", headers = {})\n prepare_request(:put, resource, body, headers)\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end",
"def put(path, body = '', headers = {})\n with_auth { request(:put, path, body.to_s, build_request_headers(headers, :put, build_uri(path))) }\n end",
"def put(path, params={})\n RestClient.put request_base+path, params\n end",
"def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend",
"def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend",
"def put(uri, request_headers, body)\n request('put', uri, request_headers, body) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end",
"def perform_put(path, options = {})\n perform_request(:put, path, options)\n end",
"def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end",
"def put_request(uri, body, token = nil, manage_errors = true)\n request = Net::HTTP::Put.new(uri.request_uri, initheader = build_headers(token))\n request.body = body.to_json\n return do_request(uri, request, manage_errors) \n end",
"def put(path, options = {})\n request(:put, parse_query_and_convenience_headers(path, options))\n end",
"def put(path, params={}, options={})\n request(:put, api_path(path), params, options)\n end",
"def put(url, resource_name, options = {})\n build_response(resource_name) do\n connection.put do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end",
"def put(uri, params = {}, env = {}, &block)\n super(uri, params, env, &block).tap do |response|\n record_request_response_pair!('put')\n end\n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def put(path, headers = {})\n process :put, path, headers\n end",
"def put(*args)\n request :put, *args\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, options={})\n request :put, path, options\n end",
"def put(*args)\n request(:put, *args)\n end",
"def put(uri, parameters)\n response = Unirest.put uri, parameters: parameters\n response.body\n end",
"def put(url, params)\n params = convert_hash_keys(params)\n @access_token = params.delete('access_token') if params['access_token']\n return connection.put(url, params)\n end",
"def request_put(path)\n\ttimestamp = Time.now.utc.iso8601\n\tauth = create_hmac_auth(\"PUT\", path, timestamp)\n\t\n\turi = URI($baseUrl + path)\n\n\trequest = Net::HTTP::Put.new(uri)\n\trequest.add_field(\"x-hp-hmac-authentication\", auth)\n\trequest.add_field(\"x-hp-hmac-date\", timestamp)\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend",
"def put(path_part, payload, additional_headers = {}, &block)\n api_request { @rest.put('/REST/' + path_part, payload.to_json, additional_headers, &block) }\n end",
"def api_put_request(url_prefix, data, raw_response = false)\n to_put = URI.escape(url_prefix)\n request = Net::HTTP::Put.new(to_put)\n request.body = data\n @logger.info \"PUT #{to_put}\"\n exec_request(request, raw_response, data)\n end",
"def put(resource_path, body:, headers: {}, prefix: API_PREFIX)\n request(method: :put, resource_path: resource_path, headers: headers, body: body, prefix: prefix)\n end",
"def 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_request(uri, body, token)\n http = build_http(uri)\n request = Net::HTTP::Put.new(uri.request_uri, initheader = build_headers(token))\n request.body = body\n return http.request(request)\t\t\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(request)\n do_request(request) { |client| client.http_put request.body }\n end",
"def put(path, options={})\n response = request(path, :put, options)\n validate response\n responsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end",
"def put(path, data, params = {}, request_options = {})\n request(:put, path, data, params)\n end",
"def put(endpoint)\n respond_with(\n connection(endpoint).put(prepare(endpoint.uri), custom_dump(endpoint.req_params)),\n endpoint\n )\n end",
"def put_json(endpoint, payload, username = nil, password = nil, endpoint_stub = API_ENDPOINT)\n uri = URI(\"#{endpoint_stub}#{endpoint}\")\n\n res = ''\n Net::HTTP.start(uri.host, uri.port,\n :use_ssl => uri.scheme == 'https', \n :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n req = Net::HTTP::Put.new(uri.request_uri)\n req['Content-Type'] = 'application/json'\n req.basic_auth(username, password) if username && password\n req.body = payload.to_json\n\n res = http.request(req)\n end\n\n JSON.parse(res.body.to_s)\nend",
"def put(path, options={})\n send_request 'put', path, options\n end",
"def put(path, body: {}, headers: nil)\n response = conn.put do |req|\n build_request(req, path: path, body: body, headers: headers)\n end\n puts response.body\n response.body unless response.blank?\n end",
"def put!\n request! :put\n end",
"def put(path, opts = {})\n request(:put, path, opts).body\n end",
"def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end",
"def put(request_uri, data = nil)\n url = base_uri + request_uri\n logger.debug(\"PUT #{url}\")\n\n uri = URI.parse(url)\n\n response = http_request(:put, uri, data)\n\n parse_body(response)\n end",
"def put(path, body_params = {})\n debug_log \"PUT #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def put(path, params)\n request(:put, path, params)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options={}, format=format)\n request(:put, path, options, format)\n end",
"def put_file(url, filename, headers = {})\n request(:put, url, headers, :file => filename)\n end"
] | [
"0.86669135",
"0.8494346",
"0.84635204",
"0.8019125",
"0.7994147",
"0.7935481",
"0.7834837",
"0.7747173",
"0.7729944",
"0.7729944",
"0.7715607",
"0.7689188",
"0.76714534",
"0.7645712",
"0.76046675",
"0.759969",
"0.7553415",
"0.7545826",
"0.751816",
"0.7448072",
"0.74445117",
"0.7412571",
"0.7402463",
"0.7365993",
"0.72615767",
"0.71962315",
"0.71845925",
"0.7152751",
"0.7148195",
"0.71052665",
"0.7079384",
"0.7052886",
"0.70504844",
"0.7024515",
"0.70057636",
"0.6989511",
"0.6968453",
"0.69583005",
"0.694122",
"0.6939993",
"0.6913642",
"0.6890222",
"0.6877651",
"0.68670744",
"0.6840809",
"0.68394065",
"0.68369496",
"0.68106085",
"0.6810338",
"0.68090343",
"0.67905694",
"0.67795193",
"0.6770003",
"0.6752513",
"0.6740774",
"0.67384326",
"0.67200595",
"0.6717887",
"0.6717053",
"0.6701137",
"0.6693296",
"0.6684644",
"0.6684644",
"0.6684644",
"0.6684644",
"0.6684644",
"0.6684644",
"0.6684644",
"0.6684644",
"0.6678147",
"0.6657545",
"0.6657543",
"0.664974",
"0.66402787",
"0.66382986",
"0.66382915",
"0.66284376",
"0.66160715",
"0.66160715",
"0.66160715",
"0.6615528",
"0.6611787",
"0.6611787",
"0.6608658",
"0.6593388",
"0.65813535",
"0.6562301",
"0.65619063",
"0.6560128",
"0.65592366",
"0.65539914",
"0.6532641",
"0.65254444",
"0.6519625",
"0.65100586",
"0.65091634",
"0.6507778",
"0.6507778",
"0.65024287",
"0.6500319"
] | 0.86126524 | 1 |
This performs a basic DELETE request using the supplied URL and headers | def delete(url, headers = {})
http :delete, "#{url}.json", headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(url, headers = {})\n request(:delete, url, headers)\n end",
"def delete(url, headers = {})\n request(:delete, url, headers)\n end",
"def delete(url, headers: {}, params: {}, options: {})\n url = encode_query(url, params)\n\n request = Net::HTTP::Delete.new(url, @default_headers.merge(headers))\n\n execute_streaming(request, options: options)\n end",
"def delete(url, headers: {}, options: {})\n request_without_payload(:delete, url, headers, options)\n end",
"def delete(url, headers={})\n RestClient.delete url, headers\n end",
"def delete(url, headers)\n conn = create_connection_object(url)\n\n http = conn.delete(:head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end",
"def delete(query_url,\r\n headers: {},\r\n parameters: {})\r\n HttpRequest.new(HttpMethodEnum::DELETE,\r\n query_url,\r\n headers: headers,\r\n parameters: parameters)\r\n end",
"def delete(url, headers={})\n begin\n request(:delete, url, nil, headers)\n rescue VeritableError => e\n if not e.respond_to? :http_code or not e.http_code == \"404 Resource Not Found\"\n raise e\n end\n end\n end",
"def delete(uri, request_headers)\n request('delete', uri, request_headers)\n end",
"def delete(url)\n do_request(\"delete\", url)\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def delete(uri, request_headers)\n raise NotImplementedError\n end",
"def delete(url, vars={})\n send_request url, vars, 'DELETE'\n end",
"def delete(url = nil, params = nil, headers = nil)\n run_request(:delete, url, nil, headers) { |request|\n # Original line from Faraday::Connection#delete method\n # request.params.update(params) if params\n\n # Monkey patch\n request.body = params if params\n\n yield(request) if block_given?\n }\n end",
"def delete(uri)\r\n request(Net::HTTP::Delete.new(uri)) \r\n end",
"def delete(url, options = {}, &block)\n options = treat_params_as_query(options)\n request HttpDeleteWithEntity, url, options, &block\n end",
"def delete(url, options = {}, &block)\n run! Request.new(url, :delete, options.slice(:headers, :params, :payload), &block)\n end",
"def do_delete(uri = '')\n build_request(:delete, uri)\n end",
"def delete(uri, params = {})\n send_request(uri, :delete, params)\n end",
"def delete(headers = {}, path = '', parameters = {})\n full_path = [path, URI.encode_www_form(parameters)].join(PARAM_STARTER)\n uri = URI.parse(\"#{@url}#{full_path}\")\n request = Net::HTTP::Delete.new(uri.request_uri)\n request.body = nil\n send_request(uri, request, headers)\n end",
"def delete(path, headers = {})\n request(:delete, path, nil, merge_default_headers(headers))\n end",
"def delete(uri = nil)\n requestor(Net::HTTP::Delete.new(build_uri(uri)))\n end",
"def delete(path, headers: {}, query: {})\n headers = @default_headers.merge(headers)\n\n response = @http.delete(full_path(path, query: query), headers)\n ensure_success!(response)\n parse_response(response)\n end",
"def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def http_delete(path, headers = {})\n clear_response\n path = process_path(path)\n @success_code = 204\n @response = http.delete(path, headers)\n parse_response? ? parsed_response : response.body\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete(path, options={})\n url = build_url path, options\n headers = options[:headers] || {}\n # nothing returned in response body for DELETE\n Response.new(@client[url].delete headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end",
"def delete(path, headers = {})\n with_auth { request(:delete, path, nil, build_request_headers(headers, :delete, build_uri(path))) }\n end",
"def delete(url, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n\n debug(\"DELETE #{uri} #{headers.inspect}\")\n\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Delete.new(uri.request_uri, headers)\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n delete_raw(response['location'], headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end",
"def delete(url)\n call(url: url, action: :delete)\n end",
"def delete(uri, request_headers)\n request('delete', uri, request_headers) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n client.delete(url)\n @deleted = true\n end",
"def delete(uri, options = {})\n build_response(request.delete(uri, build_request_options({:input => options.to_params})))\n end",
"def delete(request)\n do_request(request) { |client| client.http_delete }\n end",
"def delete(path, options = {})\n request = Net::HTTP::Delete.new(request_uri(path))\n make_request(request, options.merge(no_callbacks: true))\n end",
"def delete(uri, options = {})\n execute(uri, :delete, options)\n end",
"def delete(path)\n uri = build_uri(path)\n\n request = Net::HTTP::Delete.new(uri.request_uri)\n set_authorisation_header(request)\n\n response = https_client(uri).request(request)\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end",
"def delete(path, params = {}, request_options = {})\n request(:delete, path, params)\n end",
"def delete_request(uri)\n http = build_http(uri)\n request = Net::HTTP::Delete.new(uri.request_uri, initheader = build_headers())\n return http.request(request)\n end",
"def delete(uri, parameters)\n response = Unirest.delete uri, parameters: parameters\n response.body\n end",
"def delete(payload = {})\n request! do\n options = {payload: to_payload(payload)}\n api(options)[url.path].delete(API_HEADERS)\n end\n end",
"def delete\n api_client.delete(url)\n end",
"def delete(path, headers = {})\n process :delete, path, headers\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def delete\n request(:delete)\n end",
"def delete(url, resource_name, options = {})\n build_response(resource_name) do\n connection.delete do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end",
"def delete(url, options={}, &block)\n http_options = options.merge(@basic_options)\n if block_given?\n RestClient.delete(url, http_options, &block)\n else\n RestClient.delete(url, http_options)\n end\n end",
"def delete(path, query = { }, headers = {})\n clear_response\n path = process_path(path, query)\n @success_code = 204\n @response = http.delete(path, headers)\n parse_response? ? parsed_response : response.body\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def delete(url, params)\n params = convert_hash_keys(params)\n @access_token = params.delete('access_token') if params['access_token']\n return connection.delete(url)\n end",
"def delete(path, headers: {}, query: {})\n (headers, query) = preprocess(headers, query)\n respond_with super(path, headers: headers, query: query)\n end",
"def delete(resource)\n headers = base_headers.merge('Content-Type' => 'application/json')\n url = \"#{@base_url}/#{resource}\"\n\n @logger.debug(\"DELETE request Url: #{url}\")\n @logger.debug(\"-- Headers: #{headers}\")\n\n x = HTTParty.delete(url, headers: headers)\n puts x.inspect\n x\n end",
"def DELETE(uri, credentials)\n delete = Net::HTTP::Delete.new(uri.path)\n\n response = submit(delete, uri, credentials)\n\n case response\n when Net::HTTPNoContent\n # Success, carry on...\n true\n else\n report_error(\"DELETE\", uri.path, response, credentials)\n end\n end",
"def delete(params = {})\n Client.current.delete(resource_url, params)\n end",
"def delete(path, options = {})\n request(:delete, parse_query_and_convenience_headers(path, options))\n end",
"def delete(path, options={})\n response = request(path, :delete, options)\n validate response\n parsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end",
"def delete(name)\n request(uri = uri(name), Net::HTTP::Delete.new(uri.request_uri))\n end",
"def delete(uri, params = {}, env = {}, &block)\n super(uri, params, env, &block).tap do |response|\n record_request_response_pair!('delete')\n end\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete_request(uri, token = nil, manage_errors = true)\n request = Net::HTTP::Delete.new(uri.request_uri, initheader = build_headers(token))\n return do_request(uri, request, manage_errors)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params={}, options={})\n request(:delete, api_path(path), params, options)\n end",
"def delete(params: {}, headers: {})\n self.class.delete(id, params: params, headers: headers)\n true\n end",
"def delete(payload)\n post_like payload, Net::HTTP::Delete.new(@uri.path)\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def delete(url, headers={}, http_options={})\n # determine the http options\n redirect_limit = http_options[:max_redirects] || max_redirects\n gateway_retries = http_options[:gateway_retry_limit] || gateway_retry_limit\n gateway_delay = http_options[:gateway_retry_delay] || gateway_retry_delay\n\n # parse the URL\n uri = URI.parse(url)\n\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Delete.new(uri.request_uri, headers)\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n # handle 302\n when Net::HTTPRedirection then\n if redirect_limit == -1\n HttpResponse.new(response)\n elsif redirect_limit == 0\n raise Net::HTTPFatalError.new(\"Too many redirects\", response)\n else\n delete(response['location'], headers, http_options.merge({\n :max_redirects => redirect_limit - 1\n }))\n end\n # handle 502, 503, 504\n when Net::HTTPBadGateway, Net::HTTPServiceUnavailable, Net::HTTPGatewayTimeOut then\n if gateway_retries == -1\n HttpResponse.new(response)\n elsif gateway_retries == 0\n Kinetic::Platform.logger.info(\"HTTP response: #{response.code} #{response.message}\")\n raise Net::HTTPFatalError.new(\"#{response.code} #{response.message}\", response)\n else\n Kinetic::Platform.logger.info(\"#{response.code} #{response.message}, retrying in #{gateway_delay} seconds\")\n sleep(gateway_delay)\n delete(url, headers, http_options.merge({\n :gateway_retry_limit => gateway_retries - 1\n }))\n end\n when Net::HTTPUnknownResponse, NilClass then\n Kinetic::Platform.logger.info(\"HTTP response code: 0\")\n e = Net::HTTPFatalError.new(\"Unknown response from server\", response)\n HttpResponse.new(e)\n else\n Kinetic::Platform.logger.info(\"HTTP response code: #{response.code}\")\n HttpResponse.new(response)\n end\n rescue Net::HTTPBadResponse => e\n Kinetic::Platform.logger.info(\"HTTP bad response: #{e.inspect}\")\n HttpResponse.new(e)\n rescue StandardError => e\n Kinetic::Platform.logger.info(\"HTTP error: #{e.inspect}\")\n HttpResponse.new(e)\n end\n end",
"def delete(request)\n _request(request) { |client, options| client.delete options }\n end",
"def http_delete(opts={})\n ret=http_delete_low(opts)\n if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then\n\tauthdefault\n\tret=http_delete_low(opts)\n\treturn ret\n else\n\treturn ret\n end\n end",
"def delete(*args)\n request(:delete, *args)\n end",
"def delete\n request('delete').auth_required!\n end",
"def delete(path, payload = nil)\n req = Net::HTTP::Delete.new(path)\n action(req, payload)\n end",
"def delete(path: nil, payload: nil, headers: {}, query: {}, auth_method: nil)\n execute(\n method: :delete,\n path: path,\n headers: headers,\n query: query,\n payload: payload,\n auth_method: auth_method\n )\n end",
"def delete(path, params = {})\n debug_log \"DELETE #{@host}#{path} params:#{params}\"\n res = connection.delete path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def delete(endpoint, params = {})\n\n path = build_connect_url(endpoint)\n headers = build_headers(endpoint, 'DELETE', params)\n\n log \"DELETE \" + path + \" \" + params.to_s\n log headers.to_s\n\n begin\n response = RestClient::Request.execute(method: :delete, url: path, payload: params.to_json, headers: headers, timeout: 15)\n rescue RestClient::ExceptionWithResponse => e\n log e.http_code.to_s + \" \" + e.response.to_s\n return e.response\n end\n\n log response.code.to_s + \" \" + response.to_s\n\n response\n\n end",
"def delete(path, params)\n request(:delete, path, {})\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"
] | [
"0.8734279",
"0.8734279",
"0.8568862",
"0.85250336",
"0.8518292",
"0.8287435",
"0.81405973",
"0.8140373",
"0.8117444",
"0.8078875",
"0.80540323",
"0.7873519",
"0.78500545",
"0.77670527",
"0.7726931",
"0.7718208",
"0.769285",
"0.76708657",
"0.76698923",
"0.7657206",
"0.7651639",
"0.7627197",
"0.76254797",
"0.76152974",
"0.75810766",
"0.7572451",
"0.7564794",
"0.74922514",
"0.74922514",
"0.7459468",
"0.74149376",
"0.7410419",
"0.74030536",
"0.7388438",
"0.73740876",
"0.73740876",
"0.7339542",
"0.7331267",
"0.73018515",
"0.72840977",
"0.7253987",
"0.72312987",
"0.7216487",
"0.7195566",
"0.71941036",
"0.7193004",
"0.71915185",
"0.7175523",
"0.7172792",
"0.7162953",
"0.71608293",
"0.71608293",
"0.71608293",
"0.71608293",
"0.71536213",
"0.71453136",
"0.71372795",
"0.7130527",
"0.71091986",
"0.7107851",
"0.710612",
"0.7104779",
"0.7088969",
"0.708688",
"0.70855796",
"0.70706075",
"0.70606303",
"0.7023224",
"0.70117676",
"0.7010294",
"0.70078486",
"0.7007583",
"0.7001492",
"0.7001492",
"0.7001492",
"0.7001492",
"0.7001492",
"0.7001492",
"0.7001492",
"0.70002013",
"0.70002013",
"0.70002013",
"0.6988472",
"0.6982986",
"0.6982986",
"0.6967192",
"0.69481266",
"0.69336",
"0.6925539",
"0.692095",
"0.6902818",
"0.6882786",
"0.68801796",
"0.6878392",
"0.68761593",
"0.6863623",
"0.6857804",
"0.6857768",
"0.68253225",
"0.6820097"
] | 0.845824 | 5 |
This will perform an HTTP call with the specified method, and arguments It will also pick up if the response is that the request was unauthorized, and will attempt the same request again after reauthenticating (in case the auth token has expired) | def http(method, *args)
args.last.merge!(self.default_headers).merge!("X-Auth-Token" => self.auth_token)
response = RestClient.send(method, *args)
@retried = false
response
rescue RestClient::Unauthorized
@auth_response = nil
if @retried
raise
else
@retried = true
retry
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute(method, path, **options)\n uri = URI(\"#{@base_url}/#{path}\")\n\n case method.to_sym\n when :get\n req = Net::HTTP::Get.new(uri)\n when :post\n req = Net::HTTP::Post.new(uri)\n when :put\n req = Net::HTTP::Put.new(uri)\n when :delete\n req = Net::HTTP::Delete.new(uri)\n else\n raise ARestException, \"Unknown method: #{method}\"\n end\n\n req.form_data = options[:form_data] if options[:form_data]\n\n headers = options[:headers] || @headers \n headers.each { |k,v| req[k] = v } if headers\n\n auth_user = options[:auth_user] || @auth_user\n auth_password = options[:auth_password] || @auth_password\n req.basic_auth auth_user, auth_password if auth_user && auth_password\n\n token = options[:token] || @auth_token\n if token\n req[\"Authorization\"] = \"Token token=#{token}\"\n end\n\n res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|\n http.request(req)\n end\n res\n end",
"def call_api(http_method, path, opts = {})\n response = call_api_method(http_method, path, opts)\n if @config.debugging\n @config.logger.debug \"HTTP response\\nHeaders: #{response.headers}\\nStatus: #{response.status}\\nBody: #{response.body}\\n\"\n end\n\n if (response.status == 401 || (response.status == 500 && response.body.length == 0)) and @config.access_token\n @config.access_token = nil\n return repeat_call_api(http_method, path, opts)\n end\n\n return process_response(response, opts)\n end",
"def api_execute(path, method, options = {})\n params = options[:params]\n case method\n when :get\n req = build_http_request(Net::HTTP::Get, path, params)\n when :post\n req = build_http_request(Net::HTTP::Post, path, nil, params)\n when :put\n req = build_http_request(Net::HTTP::Put, path, nil, params)\n when :delete\n req = build_http_request(Net::HTTP::Delete, path, params)\n else\n fail \"Unknown http action: #{method}\"\n end\n timeout = options[:timeout] || @read_timeout\n http = Net::HTTP.new(host, port)\n http.read_timeout = timeout\n setup_https(http)\n req.basic_auth(user_name, password) if [user_name, password].all?\n Log.debug(\"Invoking: '#{req.class}' against '#{path}\")\n res = http.request(req)\n Log.debug(\"Response code: #{res.code}\")\n process_http_request(res, req, params)\n end",
"def invoke_method\n unless check_preconditions\n return send_response(status: :precondition_failed)\n end\n\n method = request.request_method.downcase\n status, body = make_request method\n\n send_response status: status, body: body\n end",
"def call(method, *args)\n return send_request(method, args)\n end",
"def call(method, params={})\n if using_oauth? && params[:auth]\n params[:format] = 'json'\n params[:nojsoncallback] = '1'\n params.delete :auth\n \n if params[:post]\n params['method'] = method\n rsp = FlickrResponse.new @access_token.post(@rest_endpoint, params, {}).body\n else\n rsp = FlickrResponse.new @access_token.get(method_url(method, params, false)).body\n end\n else\n if params && params[:post]\n rsp = FlickrResponse.new Net::HTTP.post_form(URI.parse(@rest_endpoint), post_params(method, params)).body\n else\n url = method_url(method, params)\n rsp = FlickrResponse.new Net::HTTP.get(URI.parse(url))\n end\n end\n \n if @options[:raise_exception_on_error] && rsp.error?\n raise RuntimeError, rsp\n end\n \n rsp\n end",
"def execute_request(method, url, opts = {})\n server.execute_request(\n method,\n [name, url.sub(/^\\//, '')].join('/'),\n opts.merge(username: username, password: password))\n end",
"def http_call( opts )\n # [review] - Don't use DEBUG inside Remote class but pull from calling method's class?\n # [review] - Not sure if this is the best/proper way to do things but it works...\n\n # Identify method entry\n debug_print \"#{ self.class } : #{ __method__ }\\n\"\n\n # Merge default options with those passed in by user to form complete opt list\n opts = HTTP_opts.merge(opts)\n\n\n # Check URL in hash and get URI from it, then set up HTTP connection\n if opts[:url] =~ /^#{URI::regexp}$/\n _uri = URI(opts[:url])\n else\n debug_print \"No URL specified in input opts, exiting HTTP call\\n\"\n return false\n end\n\n _http = Net::HTTP.new(_uri.host, _uri.port)\n\n # Print out verbose HTTP request if :verbose is set\n # For hardcore debugging when shit really doesn't work\n _http.set_debug_output $stderr if opts[:verbose] == true\n\n # If SSL is set in hash, set HTTP connection to use SSL\n _http.use_ssl = true if opts[:ssl] == true\n\n # Create request based on HTTP method\n # [review] - Not sure if to fail with no method or default to GET?\n case opts[:method].upcase\n when \"GET\"\n _req = Net::HTTP::Get.new(_uri.request_uri)\n\n when \"POST\"\n _req = Net::HTTP::Post.new(_uri.request_uri)\n\n else\n debug_print \"No method specified, cannot make HTTP request\\n\"\n return false\n end\n\n # Check for basic authentication key in hash\n if opts[:basic_auth].size == 2\n _req.basic_auth(opts[:basic_auth][0], opts[:basic_auth][1])\n end\n\n # Check for Authentication token key in hash to be used in header\n # I think this is pretty universal, but specifically works for GitHub\n # This is standard for OAuth I think...\n if opts[:auth]\n _req[\"Authorization\"] = \"token #{ opts[:auth] }\"\n end\n\n # But sometimes we need we need other headers\n # Set specific header (GitLab requires PRIVATE_TOKEN)\n opts[:headers].each do |header|\n _req[\"#{ header[:field] }\"] = header[:value]\n end\n\n\n # [review] - Add :data_format to use set_form_data vs json body?\n # For now, use Hash or Array, this is to differentiate between\n # putting post data in body vs putting it in the form\n\n # If a POST method, :data is present, and is a Hash, fill request body with data\n if opts[:method].upcase == \"POST\" && opts[:data] && opts[:data].is_a?(Hash)\n _req.body = opts[:data].to_json\n end\n\n # If a POST method, :data is present, and is an Array, use set_form_data\n if opts[:method].upcase == \"POST\" && opts[:data] && opts[:data].is_a?(Array)\n _req.set_form_data(opts[:data][0])\n end\n\n # Make HTTP request\n _resp = _http.request(_req)\n\n # Debug prints for status and message\n debug_print \"HTTP Response Code: #{ _resp.code }\\n\"\n debug_print \"HTTP Response Msg: #{ _resp.message }\\n\"\n\n # [fix] - Not sure if 401 is the only code that gives nonparseable body?\n # Figure out what other response codes are bad news for JSON.parse\n _json = _resp.code == \"401\" ? Hash.new : JSON.parse(_resp.body)\n debug_print \"JSON: \\n #{ _json }\\n\"\n\n # [review] - Returning hash of json + response the right thing to do?\n # return {:json => _json, :resp => _resp}\n return _json, _resp\n end",
"def request(method, path, *arguments)\n logger.info \"#{method.to_s.upcase} #{site.scheme}://#{site.host}:#{site.port}#{path}\" if logger\n logger.info arguments.inspect if logger\n result = nil\n ms = Benchmark.ms { result = http.send(method, path, *arguments) }\n logger.info \"--> %d %s (%d %.0fms)\" % [result.code, result.message, result.body ? result.body.length : 0, ms] if logger\n handle_response(result)\n rescue Timeout::Error => e\n raise TimeoutError.new(e.message)\n rescue OpenSSL::SSL::SSLError => e\n raise SSLError.new(e.message)\n end",
"def request(method, path, *arguments)\n result = ActiveSupport::Notifications.instrument(\"request.active_resource\") do |payload|\n payload[:method] = method\n payload[:request_uri] = \"#{site.scheme}://#{site.host}:#{site.port}#{path}\"\n payload[:request_arguments] = arguments\n payload[:result] = http.send(method, path, *arguments)\n end\n handle_response(result)\n rescue Timeout::Error => e\n raise TimeoutError.new(e.message)\n rescue OpenSSL::SSL::SSLError => e\n raise SSLError.new(e.message)\n end",
"def execute(http_method, path, params = nil, data = nil, headers = nil)\n # Prepare URL and params\n url = _make_url(path, params)\n if [:get, :delete].include? http_method\n unless data.nil?\n puts \"WARNING: #{http_method.to_s.upcase} method does not pass any data. Path '#{path}'\"\n data = nil\n end\n end\n\n # Setup the request\n rest_client_args = {}\n rest_client_args[:method] = http_method\n rest_client_args[:url] = url\n rest_client_args[:payload] = data\n rest_client_args[:user] = @user\n rest_client_args[:password] = @password\n rest_client_args[:headers] = _get_headers(headers)\n\n # Execute\n # TODO: add logger\n begin\n ::RestClient::Request.execute(rest_client_args)\n rescue => e\n raise @exc_class.new(e)\n end\n end",
"def call\n conn = http_setup\n res = set_up_response(method.to_sym, uri, conn, headers ,body)\n\n response = HttpResponse.new(res)\n response.uri = uri\n raise response.error if !response.success? && !@has_retry_filter\n response\n end",
"def request(http_method: :get, path:'/', body: nil, query: {}, headers: {}, response_block: nil, expects: [200, 201, 204], host: nil, port: nil, auth: true, gzip: true)\n\n retried ||= false\n\n if auth && token_expired?\n raise Excon::Error::Unauthorized, \"Token expired or not valid, you need to login again, use: kontena #{token_is_for_master? ? \"master\" : \"cloud\"} login\"\n end\n\n request_headers = request_headers(headers, auth: auth, gzip: gzip)\n\n if body.nil?\n body_content = ''\n request_headers.delete(CONTENT_TYPE)\n else\n body_content = encode_body(body, request_headers[CONTENT_TYPE])\n request_headers.merge!('Content-Length' => body_content.bytesize)\n end\n\n uri = URI.parse(path)\n host_options = {}\n\n if uri.host\n host_options[:host] = uri.host\n host_options[:port] = uri.port\n host_options[:scheme] = uri.scheme\n path = uri.request_uri\n else\n host_options[:host] = host if host\n host_options[:port] = port if port\n end\n\n request_options = {\n method: http_method,\n expects: Array(expects),\n path: path_with_prefix(path),\n headers: request_headers,\n body: body_content,\n query: query\n }.merge(host_options)\n\n request_options.merge!(response_block: response_block) if response_block\n\n # Store the response into client.last_response\n @last_response = http_client.request(request_options)\n\n parse_response(@last_response)\n rescue Excon::Error::Unauthorized\n if token\n debug { 'Server reports access token expired' }\n\n if retried || !token || !token['refresh_token']\n raise Kontena::Errors::StandardError.new(401, 'The access token has expired and needs to be refreshed')\n end\n\n retried = true\n retry if refresh_token\n end\n raise Kontena::Errors::StandardError.new(401, 'Unauthorized')\n rescue Excon::Error::HTTPStatus => error\n if error.response.headers['Content-Encoding'] == 'gzip'\n error.response.body = Zlib::GzipReader.new(StringIO.new(error.response.body)).read\n end\n\n debug { \"Request #{error.request[:method].upcase} #{error.request[:path]}: #{error.response.status} #{error.response.reason_phrase}: #{error.response.body}\" }\n\n handle_error_response(error.response)\n end",
"def method_request( method, params )\n #merge auth params into our request querystring\n querystring = @auth.merge( params.is_a?(Hash) ? params : {} )\n resp = self.class.get(\"/#{@data_type}/#{method.to_s}\",{:query => querystring})\n if resp['error'] \n raise RuntimeError, resp['error']['error_message'], caller[1..-1]\n end\n return resp\n end",
"def run_request(method, url, body, headers); end",
"def request(method, path, params = {}, body = {}, headers = {})\n meta_headers = { authorization: decide_authorization(params), user_agent: request_user_agent }\n headers = if !headers.is_a?(Hash)\n meta_headers\n else\n headers.merge(meta_headers)\n end\n\n @transport.perform_request(method.to_s.upcase, path, params, body, headers)\n end",
"def call\n access = RIGHTS[method] # Checking access permissions for perform corresponding ACTION\n raise NoAccessError.new(access) unless @permissions[access] # Raising Custom error if no access granted\n\n send(@method) # Calling method from @method\n end",
"def call\n access = RIGHTS[method] # Checking access permissions for perform corresponding ACTION\n raise NoAccessError.new(access) unless @permissions[access] # Raising Custom error if no access granted\n\n send(@method) # Calling method from @method\n end",
"def request(method, path, opts = {})\n raise ClientError, 'Access token missing' unless @access_token\n\n opts[:headers] = {} if opts[:headers].nil?\n opts[:headers]['Accept'] = 'application/json'\n opts[:headers]['Content-Type'] = 'application/json' unless method == :get\n opts[:headers]['User-Agent'] = user_agent\n opts[:headers]['Authorization'] = \"Bearer #{@access_token}\"\n\n if !opts[:data].nil?\n opts[:body] = opts[:data].to_param\n\n puts \"SETTING BODY #{opts[:body]}\"\n\n opts[:headers]['Content-Type'] = 'application/x-www-form-urlencoded' # sob sob\n end\n\n path = URI.encode(path)\n\n resp = connection.run_request(method, path, opts[:body], opts[:headers]) do |req|\n req.params = opts[:params] if !opts[:params].nil?\n end\n\n response = Response.new(resp)\n\n case response.status\n when 301, 302, 303, 307\n # TODO\n when 200..299, 300..399\n # on non-redirecting 3xx statuses, just return the response\n response\n when 400..599\n error = ApiError.new(response)\n raise(error, \"Status code #{response.status}\")\n else\n error = ApiError.new(response)\n raise(error, \"Unhandled status code value of #{response.status}\")\n end\n end",
"def run_request(verb, method, options={})\n self.class.send(verb, \"/#{method}\", :query => authorization_params.merge(options))\n end",
"def ident_http_request(method, uri_string, credentials=nil, headers={}, data=nil, limit = 3, open_timeout=15, read_timeout=15)\n\n response = nil\n begin\n\n # set user agent\n user_agent = \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36\"\n headers[\"User-Agent\"] = user_agent\n\n attempts=0\n max_attempts=limit\n found = false\n timeout = false\n\n uri = URI.parse uri_string\n\n # keep track of redirects\n response_urls = [\"#{uri}\"]\n\n unless uri\n _log error \"Unable to parse URI from: #{uri_string}\"\n return\n end\n\n until( found || attempts >= max_attempts)\n @task_result.logger.log \"Getting #{uri}, attempt #{attempts}\" if @task_result\n attempts+=1\n\n if $global_config\n if $global_config.config[\"http_proxy\"]\n proxy_config = $global_config.config[\"http_proxy\"]\n proxy_addr = $global_config.config[\"http_proxy\"][\"host\"]\n proxy_port = $global_config.config[\"http_proxy\"][\"port\"]\n proxy_user = $global_config.config[\"http_proxy\"][\"user\"]\n proxy_pass = $global_config.config[\"http_proxy\"][\"pass\"]\n end\n end\n\n # set options\n opts = {}\n if uri.instance_of? URI::HTTPS\n opts[:use_ssl] = true\n opts[:verify_mode] = OpenSSL::SSL::VERIFY_NONE\n end\n\n http = Net::HTTP.start(uri.host, uri.port, proxy_addr, proxy_port, opts)\n http.open_timeout = open_timeout\n http.read_timeout = read_timeout\n\n path = \"#{uri.path}\"\n path = \"/\" if path==\"\"\n\n # add in the query parameters\n if uri.query\n path += \"?#{uri.query}\"\n end\n\n ### ALLOW DIFFERENT VERBS HERE\n if method == :get\n request = Net::HTTP::Get.new(uri)\n elsif method == :post\n # see: https://coderwall.com/p/c-mu-a/http-posts-in-ruby\n request = Net::HTTP::Post.new(uri)\n request.body = data\n elsif method == :head\n request = Net::HTTP::Head.new(uri)\n elsif method == :propfind\n request = Net::HTTP::Propfind.new(uri.request_uri)\n request.body = \"Here's the body.\" # Set your body (data)\n request[\"Depth\"] = \"1\" # Set your headers: one header per line.\n elsif method == :options\n request = Net::HTTP::Options.new(uri.request_uri)\n elsif method == :trace\n request = Net::HTTP::Trace.new(uri.request_uri)\n request.body = \"blah blah\"\n end\n ### END VERBS\n\n # set the headers\n headers.each do |k,v|\n request[k] = v\n end\n\n # handle credentials\n if credentials\n request.basic_auth(credentials[:username],credentials[:password])\n end\n\n # USE THIS TO PRINT HTTP REQUEST\n #request.each_header{|h| _log_debug \"#{h}: #{request[h]}\" }\n # END USE THIS TO PRINT HTTP REQUEST\n\n # get the response\n response = http.request(request)\n\n if response.code==\"200\"\n break\n end\n\n if (response.header['location']!=nil)\n newuri=URI.parse(response.header['location'])\n if(newuri.relative?)\n newuri=URI.parse(\"#{uri}#{response.header['location']}\")\n end\n response_urls << ident_encode(newuri.to_s)\n uri=newuri\n\n else\n found=true #resp was 404, etc\n end #end if location\n end #until\n\n final_url = uri\n\n ### TODO - create a global $debug config option\n \n rescue ArgumentError => e\n #puts \"Unable to connect #{uri}: #{e}\"\n rescue Net::OpenTimeout => e\n #puts \"Unable to connect #{uri}: #{e}\"\n timeout = true\n rescue Net::ReadTimeout => e\n #puts \"Unable to connect #{uri}: #{e}\"\n timeout = true\n rescue Errno::ENETDOWN => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Errno::ETIMEDOUT => e\n #puts \"Unable to connect #{uri}: #{e}\" \n timeout = true\n rescue Errno::EINVAL => e\n #puts \"Unable to connect #{uri}: #{e}\"\n rescue Errno::ENETUNREACH => e\n #puts \"Unable to connect #{uri}: #{e}\"\n rescue Errno::EHOSTUNREACH => e\n #puts \"Unable to connect #{uri}: #{e}\"\n rescue URI::InvalidURIError => e\n #\n # XXX - This is an issue. We should catch this and ensure it's not\n # due to an underscore / other acceptable character in the URI\n # http://stackoverflow.com/questions/5208851/is-there-a-workaround-to-open-urls-containing-underscores-in-ruby\n #\n #puts \"Unable to connect #{uri}: #{e}\"\n rescue OpenSSL::SSL::SSLError => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Errno::ECONNREFUSED => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Errno::ECONNRESET => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Net::HTTPBadResponse => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Zlib::BufError => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Zlib::DataError => e # \"incorrect header check - may be specific to ruby 2.0\"\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue EOFError => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue SocketError => e\n #puts \"Unable to connect #{uri}: #{e}\" \n rescue Encoding::InvalidByteSequenceError => e\n #puts \"Encoding issue #{uri}: #{e}\" \n rescue Encoding::UndefinedConversionError => e\n #puts \"Encoding issue #{uri}: #{e}\" \n end\n\n # generate our output\n out = {\n :timeout => timeout,\n :start_url => uri_string,\n :final_url => final_url.to_s,\n :request_type => :ruby,\n :request_method => method,\n :request_credentials => credentials,\n :request_headers => headers,\n :request_data => data,\n :request_attempts_limit => limit,\n :request_attempts_used => attempts,\n :request_user_agent => user_agent,\n :request_proxy => proxy_config,\n :response_urls => response_urls,\n :response_object => response\n }\n\n # verify we have a response before adding these\n if response\n out[:response_headers] = response.each_header.map{|x| ident_encode \"#{x}: #{response[x]}\" }\n out[:response_body] = ident_encode(response.body)\n end\n\n out\n end",
"def call(method, path, params = {}, parse_response_as_json = true, with_auth_token = true)\n\n # path must begin with slash\n uri = URI(@end_point + path)\n\n if @proxy_url\n # p_scheme, p_username, p_password, p_host, p_port = @proxy_url.gsub(/(:|\\/|@)/,' ').squeeze(' ').split§\n # net_http_arguments += [phost, p_port, p_username, p_password]\n proxy_uri = URI(@proxy_url)\n proxy_args = [proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password]\n end\n\n # Build the connection\n http = Net::HTTP.new(uri.host, uri.port, *proxy_args)\n\n if uri.scheme == 'https'\n http.use_ssl = true\n end\n\n request = case method\n when :get\n uri.query = URI.encode_www_form(params) unless params.empty?\n Net::HTTP::Get.new(uri.request_uri)\n when :post\n Net::HTTP::Post.new(uri.request_uri)\n when :delete\n Net::HTTP::Delete.new(uri.request_uri)\n when :put\n Net::HTTP::Put.new(uri.request_uri)\n else\n raise ApiError, \"Unsupported request method #{method.inspect}\"\n end\n\n request.body = params.to_json unless method == :get\n\n # Set JSON body\n request.add_field('Content-Type', 'application/json')\n\n # Add authentication header\n if with_auth_token == true && @session_token.nil? == false\n request.add_field('Authorization', 'Bearer ' + @session_token)\n end\n\n response = http.request(request)\n\n\n if parse_response_as_json == true\n json_resp = nil\n begin\n\n json_resp = JSON.parse(response.body)\n\n rescue => ex\n\n message = \"Error Parsing Bitgo's response as JSON: #{ex.inspect}\"\n\n case response.code.to_s\n when /^2\\d\\d/\n raise ApiError.new(\"#{message} Bitgo response: #{response.code} #{response.message} #{response.body}\", response)\n else\n raise ApiError.new(\"#{message} BiGo did not return a HTTP 2xx code: #{response.code} #{response.message} #{response.body}\", response)\n end\n\n end\n\n if json_resp.kind_of?(Hash) && json_resp[\"error\"].nil? == false\n raise ApiError.new(json_resp[\"error\"], response)\n end\n\n return json_resp\n else\n return response.body\n end\n end",
"def call_api method, arguments = {}, &block\n # Ensures only a valid DataContext is used\n unless @context.is_a? DataContext\n block.call nil, 'A context object was not provided.'\n return\n end\n \n unless @context.valid?\n block.call nil, 'A valid context object was not provided.'\n return\n end\n \n # Ensures only valid arguments are used\n query = []\n arguments.each_pair do |key, value|\n if API_VALID_ARGUMENTS.member? key.to_s\n query << \"$#{key}=#{URI.escape value.to_s}\"\n else\n query << \"#{key}=#{URI.escape value.to_s}\"\n end\n end\n \n # Generates timestamp and url\n timestamp = DOL.timestamp\n url = URI.parse [\"#{@context.host}/#{@context.url}/#{method}\", query.join('&')].join '?'\n \n # Creates a new thread, creates an authenticaed request, and requests data from the host\n @mutex.synchronize do\n @active_requests << Thread.new do\n request = Net::HTTP::Get.new [url.path, url.query].join '?'\n request.add_field 'Authorization', \"Timestamp=#{timestamp}&ApiKey=#{@context.key}&Signature=#{signature timestamp, url}\"\n request.add_field 'Accept', 'application/json'\n result = Net::HTTP.start url.host, url.port do |http|\n http.request request\n end\n \n if result.is_a? Net::HTTPSuccess\n \n #Cleanup jsonresult.\n result = result.body.gsub(/\\\\+\"/, '\"')\n result = result.gsub /\\\\+n/, \"\"\n result = result.gsub /\\\"\\\"\\{/, \"{\"\n result = result.gsub /}\\\"\\\"/, \"}\"\n\n result = JSON.parse(result)['d']\n \n if (result.include?'results')\n result = result['results'] if result.is_a? Hash\n end\n\n block.call result, nil\n \n else\n block.call nil, \"Error: #{result.message}\"\n end\n \n @mutex.synchronize do\n @active_requests.delete Thread.current\n end\n end\n end\n end",
"def request(method, path, *arguments)\n method = method.to_s.upcase\n result = ActiveSupport::Notifications.instrument(\"request.active_resource\") do |payload|\n payload[:method] = method\n payload[:request_uri] = \"#{site.scheme}://#{site.host}:#{site.port}#{path}\"\n arguments.unshift(nil) if arguments.length == 1\n payload[:body] = arguments[0]\n payload[:result] = http.send_request(method, path, *arguments)\n end\n handle_response(result)\n rescue Timeout::Error => e\n raise TimeoutError.new(e.message)\n rescue OpenSSL::SSL::SSLError => e\n raise SSLError.new(e.message)\n end",
"def request(method, args = {})\n params = args.merge({@method_param => method})\n params = params.merge(@default_params)\n endpoint = api_endpoint ? api_endpoint.base_url : @endpoint\n url = endpoint + URI.encode_www_form( params.reject{ |k,v| k == :force_update } )\n request_uri = URI.parse(url)\n response = nil\n begin\n MetaService.fetch_request_uri(args.merge(request_uri: request_uri, timeout: @timeout,\n api_endpoint: api_endpoint,\n user_agent: \"#{Site.default.name}/#{self.class}/#{SERVICE_VERSION}\"))\n rescue Timeout::Error\n raise Timeout::Error, \"#{@service_name} didn't respond within #{@timeout} seconds.\"\n end\n end",
"def request(method, path, params)\n when_debugging do\n puts '---'\n puts \"#{method.to_s.upcase} #{path}\"\n puts params.inspect\n puts\n end\n\n response = @access_token.send(method, path, params)\n\n when_debugging do\n puts response.status\n puts response.body\n puts\n end\n\n checked_response(response)\n end",
"def execute_http_request (method, url, args)\n @http_request = method, url.clone, args.clone\n self.http_response = HTTParty.send method, url, args\n Log.debug \"#{@http_response.request.http_method.to_s.split('::').last.upcase} - URL: #{@http_response.request.last_uri}\"\n Log.debug 'HEADER:'\n Log.debug http_response.request.options[:headers]\n # Log.debug @http_response.request.options[:body] if @http_response.request.options[:body]\n Log.debug 'BODY:' if http_response\n Log.debug http_response if http_response\n http_response\n end",
"def send_request(method, path, options={}) #:nodoc:\n raise ArgumentError, 'only get, post, put and delete methods are supported' unless %w[get post put delete].include?(method.to_s)\n raise ArgumentError, ':headers must be a hash' if options[:headers] && !options[:headers].is_a?(Hash)\n raise ArgumentError, ':basic_auth must be a hash' if options[:basic_auth] && !options[:basic_auth].is_a?(Hash)\n uri = URI.parse(\"#{base_uri}#{path}\")\n existing_query = uri.query ? \"#{uri.query}&\" : ''\n uri.query = if options[:query].blank?\n existing_query + default_params.to_query\n else\n existing_query + (options[:query].is_a?(Hash) ? default_params.merge(options[:query]).to_query : options[:query])\n end\n klass = Net::HTTP.const_get method.to_s.downcase.capitalize\n request = klass.new(uri.request_uri)\n request.body = options[:body].is_a?(Hash) ? options[:body].to_query : options[:body] unless options[:body].blank?\n basic_auth = options.delete(:basic_auth) || @auth\n request.initialize_http_header headers.merge(options[:headers] || {})\n # note to self: self, do not put basic auth above headers because it removes basic auth\n request.basic_auth(basic_auth[:username], basic_auth[:password]) if basic_auth\n response = http(uri).request(request)\n @format ||= format_from_mimetype(response['content-type'])\n \n case response\n when Net::HTTPSuccess\n parse_response(response.body)\n else\n response.instance_eval { class << self; attr_accessor :body_parsed; end }\n begin; response.body_parsed = parse_response(response.body); rescue; end\n response.error! # raises exception corresponding to http error Net::XXX\n end\n\n end",
"def perform(arguments = {})\n case type.to_sym\n when :post, :get\n api.public_send(type, path, @arguments.merge(arguments))\n else\n raise ArgumentError, \"Unregistered request type #{request_type}\"\n end\n end",
"def method_missing(method_name, *args)\n payload = Kauplus::Client.authenticate_payload(args.first)\n if method_name.match(/(get|post|multipart_post|put|delete|head)_(.*)/)\n Kauplus::Client.send($1, \"#{@resource}/#{$2}\", payload)\n else\n Kauplus::Client.get(\"#{@resource}/#{method_name}\", payload)\n end\n end",
"def call_api_method(http_method, path, opts = {})\n connection = Faraday.new(:url => @config.base_path, ssl: { verify: @config.verify_ssl })\n case http_method\n when :GET\n response = connection.get do |req|\n build_request(req, http_method, path, opts)\n end\n when :POST\n response = connection.post do |req|\n build_request(req, http_method, path, opts)\n end\n when :PUT\n response = connection.put do |req|\n build_request(req, http_method, path, opts)\n end\n when :DELETE\n response = connection.delete do |req|\n build_request(req, http_method, path, opts)\n end\n end\n response\n end",
"def send_auth_request \n request = AuthorizeRequest.new(:get, action_to_call) do |req|\n req.request_params = params\n end\n request.send_request(Config.url)\n end",
"def _http_request(method, url, *args)\n request_args = get_hash_args(*args)\n url = get_url url unless url.to_s.start_with?('http://')\n request_args[:header] = @head\n request_args[:body] = \\\n JSON.dump(request_args[:body]) if request_args[:body]\n\n res = @http_session.request(method, url, request_args)\n status = res.status\n raise HTTPError, 'HTTPError: %s %s'\\\n % [status, (JSON.load(res.content)['message'] rescue res.reason)]\\\n if status >= 400 && status < 600\n res\n end",
"def request(method, path, options, temp_api_endpoint=nil)\n if credentials?\n authentication = auth_query_hash\n connection.params.merge!(authentication)\n end\n\n connection.url_prefix = temp_api_endpoint || @endpoint\n response = connection.send(method) do |request|\n convert_hash_filter_params!(options)\n case method.to_sym\n when :get, :delete\n request.url(path, options)\n when :post, :put\n request.path = path\n request.body = options unless options.empty?\n end\n end\n\n response.body\n end",
"def do_it(http_method, url:, **options)\n err = nil\n timing = {}\n timing[:start] = Time.now\n begin\n faraday_init = {url: url}\n faraday_init[:ssl] = {verify: false} if options[:https_allow_unverified]\n faraday_init[:request] = {timeout: options[:timeout]} if options[:timeout]\n conn = Faraday.new(faraday_init) do |faraday|\n # Request encoders are relatively safe, as they have built-in checks for suitability.\n # faraday.request(:multipart) # multipart first, takes priority over url_encoded.\n faraday.request(:url_encoded)\n # faraday.response(:logger, nil, bodies: {response: true}) if Rails.env.development?\n faraday.proxy = options[:proxy] if options[:proxy]\n faraday.adapter(Faraday.default_adapter) # must be after middlewares\n faraday.basic_auth(options[:basic_auth][:username], options[:basic_auth][:password]) if options[:basic_auth]\n end\n timing[:start] = Time.now\n response = conn.run_request(http_method, nil, options[:body], options[:headers])\n rescue => e\n err = e\n end\n timing[:end] = Time.now\n timing[:duration] = timing[:end] - timing[:start]\n log_url = options[:log_url] || url\n if err\n Rails.logger.error(http_method.to_s.upcase+\" #{log_url} ERROR (#{(timing[:duration]*1000).round}ms): #{err.class}: #{err.message}\")\n raise err.class, err.message, caller(2)\n else\n Rails.logger.info(http_method.to_s.upcase+\" #{log_url} response (#{(timing[:duration]*1000).round}ms): #{response.status} \"+response.body.inspect.truncate(350, omission: \"... (#{response.body.to_s.length} total)\\\"\")) #\"\n end\n unless options[:return_failed_response] || response.success?\n err = ResponseError.new_from_response(response)\n err.set_backtrace(caller(2))\n raise err\n end\n {success: response.success?, status: response.status, body: response.body, headers: response.headers.to_h, timing: timing}\n end",
"def call(api_method, *args) # :nodoc:\n response = @client.request api_method.to_sym do |soap|\n # Add authentication header (if needed)\n soap.header = {\"ins0:Authentication\" => {\"ins0:User\" => @username, \"ins0:Password\" => @password}} if defined?(@username) and defined?(@password)\n body_hash = {}\n # Add access key (if needed)\n body_hash.merge!({:accessKey => @access_key}) if defined?(@access_key)\n body_hash.merge!(*args) unless args.empty?\n soap.body = body_hash\n end\n if defined?(@username) and defined?(@password)\n # (MailUp::Import)\n xml = Nokogiri::XML(response.body[\"#{api_method}_response\".to_sym][\"#{api_method}_result\".to_sym])\n rc = xml.xpath('//ReturnCode').first.content.to_i\n raise SoapError.new(rc, MailUp::Import::ERRORS[rc]) if rc != 0\n response.body[\"#{api_method}_response\".to_sym][\"#{api_method}_result\".to_sym]\n else\n # (MailUp::Manage, MailUp::Report, MailUp::Send)\n xml = Nokogiri::XML(response[\"#{api_method}_response\".to_sym][\"#{api_method}_result\".to_sym])\n ec, em = xml.xpath('//errorCode').first.content.to_i, xml.xpath('//errorDescription').first.content\n raise SoapError.new(ec, em) if ec != 0\n response[\"#{api_method}_response\".to_sym][\"#{api_method}_result\".to_sym]\n end\n end",
"def perform_request(method, path, params={}, body=nil, headers=nil)\n client.perform_request method, path, params, body, headers\n end",
"def call(method, params=nil)\n if params && params[:post]\n rsp = FlickrResponse.new Net::HTTP.post_form(URI.parse(@rest_endpoint), post_params(method, params)).body\n else\n url = method_url(method, params)\n rsp = FlickrResponse.new Net::HTTP.get(URI.parse(url))\n end\n \n if @options[:raise_exception_on_error] && rsp.error?\n raise RuntimeError, rsp\n end\n \n rsp\n end",
"def request(*args)\n authenticated_request(*args)\n end",
"def csreq(method,server,path,port,scheme,headers = {},data = nil,attempts = 0) # :nodoc:\n start = Time.now\n hdrhash = headerprep(headers)\n start_http(server,path,port,scheme,hdrhash)\n request = Net::HTTP.const_get(method.to_s.capitalize).new(path,hdrhash)\n request.body = data\n response = @http[server].request(request)\n if @is_debug\n puts \"REQUEST: #{method} => #{path}\"\n puts data if data\n puts \"RESPONSE: #{response.body}\"\n puts '----------------------------------------'\n end\n raise OpenStack::Compute::Exception::ExpiredAuthToken if response.code == \"401\"\n response\n rescue Errno::EPIPE, Timeout::Error, Errno::EINVAL, EOFError\n # Server closed the connection, retry\n raise OpenStack::Compute::Exception::Connection, \"Unable to reconnect to #{server} after #{attempts} attempts\" if attempts >= 5\n attempts += 1\n @http[server].finish if @http[server].started?\n start_http(server,path,port,scheme,headers)\n retry\n rescue OpenStack::Compute::Exception::ExpiredAuthToken\n raise OpenStack::Compute::Exception::Connection, \"Authentication token expired and you have requested not to retry\" if @retry_auth == false\n OpenStack::Compute::Authentication.init(self)\n retry\n end",
"def execute_http_request(http_method, path, payload = nil)\n response = RestClient::Request.execute(method: http_method, url: path, payload: payload, headers: DEFAULT_HEADERS)\n # handle response using helper\n handle_response(response)\n end",
"def request(method, *args)\n path, resource, options = extract_request_args!(*args)\n\n # Do we need the session endpoint?\n url = path =~ /^\\/?sessions/ ? session_endpoint : endpoint\n\n response = connection(url, resource).send(method) do |request|\n case method\n when :get, :delete\n request.url(path, options)\n when :post, :put\n request.path = path\n request.body = options unless options.empty?\n end\n end\n response.body\n end",
"def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n req = HTTParty::Request.new http_method, path, req_options\n\n begin\n response = req.perform\n rescue => ex\n raise RequestError.new req, ex\n end\n \n if defined?(Rails.logger)\n Rails.logger.info req.to_curl\n else\n puts req.to_curl\n end\n \n if !response.parsed_response.is_a?(Hash)\n raise ResponseParseError.new req, response\n elsif response[\"errors\"]\n raise ResponseError.new req, response[\"errors\"], response\n elsif response[\"message\"] && response[\"message\"] == \"Invalid Token or Expired\"\n raise InvalidAuthToken.new\n else\n return CityGrid::API::Response.new response\n end\n \n rescue => ex\n raise ex if CityGrid.raise_errors?\n end",
"def repeat_call_api(http_method, path, opts = {})\n response = call_api_method(http_method, path, opts)\n if @config.debugging\n @config.logger.debug \"HTTP response\\nHeaders: #{response.headers}\\nStatus: #{response.status}\\nBody: #{response.body}\\n\"\n end\n\n return process_response(response, opts)\n end",
"def send_request method, params = {}\n uri = URI.parse(@api_url)\n if Time.now.to_i > @exp + 3600\n get_acces_token\n @exp = Time.now.to_i\n end\n required = { 'access_token' => @access_token, 'method' => method }\n params = required.merge(params)\n params = URI.escape(params.collect{ |k,v| \"#{k}=#{v}\"}.join('&'))\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.request_uri)\n req['User-Agent'] = \"zhzhussupovkz pleer.com-ruby-api\"\n req.body = params\n res = http.request(req)\n if res.code == \"200\"\n data = res.body\n result = JSON.parse(data)\n else\n puts \"Invalid getting data from server\"\n exit\n end\n end",
"def request(method, path, *arguments)\n puts \"REQUEST #{path} #{arguments.inspect}\"\n uri = URI.parse( path )\n request_http = http\n if uri.host\n path = uri.request_uri #includes params unlike path()\n request_http = Net::HTTP.new(uri.host, uri.port) #ignores @timeout and @proxy\n else\n uri = site\n end\n puts \"URI #{uri.inspect}\"\n result = ActiveSupport::Notifications.instrument(\"request.active_resource\") do |payload|\n payload[:method] = method\n payload[:request_uri] = \"#{uri.scheme}://#{uri.host}:#{uri.port}#{path}\"\n payload[:result] = request_http.send(method, path, *arguments)\n end\n handle_response(result)\n rescue Timeout::Error => e\n raise TimeoutError.new(e.message)\n rescue OpenSSL::SSL::SSLError => e\n raise SSLError.new(e.message)\n end",
"def do_request(request, response)\n if request.request_method != 'GET'\n response.status = 405\n LOG.error \"Unsupported request method #{request.request_method}\"\n return\n end\n\n do_get(request, response)\n end",
"def authenticated_request(method, url, requestor, opts={}, &validator)\n headers, payload = construct_request(method, url, requestor, opts)\n do_request(method, url, headers, payload, &validator)\n end",
"def request(method, uri, options={})\n options.deep_merge!(@auth_options)\n\n puts \"* requesting #{method.upcase} #{uri}\"\n response = self.class.send(method, uri, options)\n json = JSON.parse(response.body)\n\n while response.code.to_s !~ /^2/\n # if error other than 503, log and move on\n if response.code.to_s !~ /^503/\n puts \"* error: #{json['errorCode']}: #{json['message']}\"\n break \n end\n \n # if 503 (exceeded rate limit), wait and try again\n puts \"* waiting 60 seconds due to an error: #{json['errorCode']}: #{json['message']}\"\n sleep(60)\n puts \"* retrying #{method.upcase} #{uri}\"\n response = self.class.send(method, uri, options)\n json = JSON.parse(response.body)\n end\n\n return json, response.code\n end",
"def run_request(method, url, body, headers)\n original_run_request(method, url, \"\", headers)\n end",
"def request(method)\n unless ::HTTP::Request::METHODS.include? method\n raise NotSupportedError, \"http.rb does not support custom HTTP methods\"\n end\n response = begin\n @client.send(method, @request.url, :body => @request.body)\n rescue OpenSSL::SSL::SSLError\n raise SSLError\n end\n\n Response.new(response.code, response.headers.to_h, response.body.to_s)\n end",
"def request(method, path, opts)\n response = connection.send(method) do |request|\n request.url(path, opts)\n request.options[:timeout] = timeout\n request.options[:open_timeout] = open_timeout\n\n unless client_id.nil?\n request.headers['Authorization'] = \"Client #{client_id}\"\n end\n end\n\n response.body\n end",
"def perform(method, path, body=nil, header=nil)\n req = Net::HTTPGenericRequest.new(method, !body.nil?, true, path)\n req['Content-Type'] = header['Content-Type'] if header['Content-Type']\n req['Authorization'] = header['Authorization'] if header['Authorization']\n req['Content-length'] = body.length.to_s if body\n resp = @http_connection.request(req, body)\n return resp\n end",
"def request(method, url = nil, options = {})\n options[:headers] = {'Content-Type' => 'application/json'}.merge(options[:headers] || {})\n options[:body] = options[:body].to_json if options[:body].is_a?(Hash)\n\n # Adopt Google's API erorr handling recommendation here:\n # https://developers.google.com/drive/handle-errors#implementing_exponential_backoff\n #\n # In essence, we try 5 times to perform the request. With each subsequent request,\n # we wait 2^n seconds plus a random number of milliseconds (no greater than 1 second)\n # until either we receive a successful response, or we run out of attempts.\n # If the Retry-After header is in the error response, we use whichever happens to be\n # greater, our calculated wait time, or the value in the Retry-After header.\n #\n # If development_mode is set to true, we only run the request once. This speeds up\n # development for those using this gem.\n attempt = 0\n max_attempts = GoogleAPI.development_mode ? 1 : 5\n while attempt < max_attempts\n response = access_token.send(method.to_sym, url, options)\n seconds_to_wait = [((2 ** attempt) + rand), response.headers['Retry-After'].to_i].max\n attempt += 1\n break if response.status < 400 || attempt == max_attempts\n GoogleAPI.logger.error \"Request attempt ##{attempt} to #{url} failed for. Trying again in #{seconds_to_wait} seconds...\"\n sleep seconds_to_wait\n end\n\n response.parsed || response\n end",
"def request(method, path, options)\n if credentials?\n connection.params.merge! api_key: credentials[:api_key]\n end\n\n connection.url_prefix = endpoint\n response = connection.send(method) do |request|\n case method.to_sym\n when :get, :delete\n request.url path, options\n when :post, :put\n request.path = path\n request.body = options\n end\n end\n\n response.body\n # It seems like Faraday should have a way to handle this. Oh, well.\n rescue Faraday::ParsingError\n raise Error.new(\"Server Error\", \"Unable to parse JSON response\")\n end",
"def perform(method, path, body=nil, header=nil)\n\t\t\treq = Net::HTTPGenericRequest.new(method, !body.nil?, true, path)\n\t\t\treq['Content-Type'] = header['Content-Type'] if header['Content-Type']\n\t\t\treq['Authorization'] = header['Authorization'] if header['Authorization']\n\t\t\treq['Content-length'] = body.length.to_s if body\n\t\t\tresp = @http_connection.request(req, body)\n\t\t\treturn resp\n\t\tend",
"def perform_request(request_method, path, options = {})\n Teamsupport::REST::Request.new(self, request_method, path, options).perform\n end",
"def request(method, status, headers, env)\n raise Gone if destroyed?\n begin\n send(method.to_sym.downcase, status, headers, env)\n rescue NotImplementedError => e\n raise MethodNotAllowed, method \n end\n end",
"def request(params)\n unless @cookie\n do_login\n end\n begin\n do_request(params)\n rescue Excon::Errors::Unauthorized\n do_login\n do_request(params)\n end\n end",
"def execute_manual_request\n http_method = params[:http_method]\n path = params[:path]\n headers = params[:headers]\n body = params[:body]\n params.each do |key, value|\n if key.start_with?(\"replace_\") && !key.end_with?(\"_by\")\n path.gsub!(\"XXX#{value}XXX\",params[key + \"_by\"]) if params[key + \"_by\"] != \"\"\n headers.gsub!(\"XXX#{value}XXX\",params[key + \"_by\"]) if params[key + \"_by\"] != \"\"\n body.gsub!(\"XXX#{value}XXX\",params[key + \"_by\"]) if params[key + \"_by\"] != \"\"\n end\n end\n if params[:task_id]\n @task = Task.find(params[:task_id])\n @regexpressions = @task.regexpressions\n end\n begin\n if @cloud\n if @cloud.api == \"Atmos\"\n @response, @headers, @url = atmos_request(http_method, path, headers, body)\n elsif @cloud.api == \"Amazon\"\n @response, @headers, @url = amazon_request(http_method, path, headers, body)\n elsif @cloud.api == \"Swift\"\n @response, @headers, @url = swift_request(http_method, path, headers, body)\n end\n else\n url = path\n uri = URI.parse(url)\n headers_to_send = Hash.new\n headers.split(\"\\n\").each do |row|\n hash = eval(row)\n headers_to_send[hash.keys.first.downcase] = hash.values.first.to_s\n end\n if params[:user] != \"\" && params[:password] != \"\"\n login = Base64.urlsafe_encode64(\"#{params[:user]}:#{params[:password]}\")\n headers_to_send[\"Authorization\"] = \"Basic #{login}\"\n end\n @response = http_request(url, uri.port, http_method, headers_to_send, body)\n @headers = headers_to_send\n end\n rescue Exception => e\n @exception = e\n end\n respond_to do |format|\n format.js { render 'shared/execute_manual_request' }\n end\n end",
"def request(method, path, params, options)\n params = params.billyfy_keys!\n auth = {username: api_key, password: \"\"}\n case method.to_sym\n when :get\n response = HTTParty.get(endpoint + path, :query => params, :basic_auth => auth)\n when :post\n response = HTTParty.post(endpoint + path, :body => MultiJson.encode(params), :basic_auth => auth)\n when :delete\n response = HTTParty.delete(endpoint + path, :query => params, :basic_auth => auth)\n when :put\n response = HTTParty.put(endpoint + path, :body => MultiJson.encode(params), :basic_auth => auth)\n else\n end\n\n options[:raw] ? response : response.parsed_response.rubyify_keys!\n end",
"def request(params)\n unless @cookie\n do_login\n end\n begin\n do_request(params)\n rescue Excon::Errors::Unauthorized => e\n do_login\n do_request(params)\n end\n end",
"def run_request(verb, method, options={})\n access_token.send(verb, method, :params => authorization_params.merge(options), :parse => :json)\n end",
"def call(method, params={})\n # Build path\n params[:apikey] = @api_key\n params = params.map { |p| p.join('=') }.join('&').gsub(/\\s/, '%20')\n path = [@uri.path, API_VERSION, method].compact.join('/') << '?' << params\n # Send request\n get = Net::HTTP::Get.new(path)\n response = @http.request(get)\n handleResult response.body\n end",
"def invoke(options = {})\n defaults = { method: 'get'}\n options = defaults.merge(options)\n\n connection.send(options[:method].to_s.downcase) do |req|\n req.url options[:url]\n req.body = options[:body] if options.has_key?(:body)\n options[:params].each { |k,v| req.params[k] = v } if options.has_key?(:params)\n options[:headers].each { |k,v| req.headers[k] = v } if options.has_key?(:headers)\n end\n end",
"def call(path, headers: nil, options: nil, payload: nil, auth: true, expand_path: true, **params)\n\n # Set the REST client headers\n rest_headers = {}.merge(headers || {})\n rest_headers[:params] = params if params && !params.empty?\n\n # Set the REST client options\n rest_options = {\n headers: rest_headers,\n url: expand_path ? url(path) : path,\n }\n rest_options[:payload] = payload if payload\n rest_options[:timeout] = self.timeout > 0 ? self.timeout : nil\n rest_options.merge(options) if options\n rest_options[:method] ||= payload ? :post : :get\n\n data = nil\n refresh_token = false\n response = nil\n\n if auth\n loop do\n rest_headers['Authorization'] = \"Bearer #{api_token(refresh_token)}\"\n response, data = call_api(**rest_options)\n if response && response.code == 401 && !refresh_token\n # The API token may have expired, try one more time with a new token\n refresh_token = true\n else\n break\n end\n end\n else\n response, data = call_api(**rest_options)\n end\n\n yield(response, data) if block_given?\n\n data\n\n end",
"def call(method, params = {})\n params[:call_id] = Time.now.tv_sec.to_s if params.delete(:call_id)\n params[:session_key] = @session.session_key if params[:session_key] == true && !!@session.session_key\n \n p = Api.default_params.merge(:method => method, :api_key => @session.api_key)\n p.merge!(params)\n \n Response.new(Api.post(API_SERVER_URL, :body => generate_signature(p, @session.secret_key)))\n end",
"def raw_request(method, path, headers = {}, data = false)\n url = create_url(path)\n method, url, headers, data = Chef::HTTP::Authenticator.new(options).handle_request(method, url, headers, data)\n method, url, headers, data = Chef::HTTP::RemoteRequestID.new(options).handle_request(method, url, headers, data)\n response, rest_request, return_value = send_http_request(method, url, headers, data)\n response.error! unless success_response?(response)\n return_value\n rescue Exception => exception\n log_failed_request(response, return_value) unless response.nil?\n raise\n end",
"def api_call path, request, options = {}\n raw_request = request.to_json\n authenticity_token = options[:authenticity_token] || request[:authenticity_token]\n\n headers = {}\n # it's actually a 'Authorization: ' header that gets mapped internally by rack to HTTP_AUTHORIZATION\n authorizer_helper_options = {}\n if options[:secret]\n authorizer_helper_options[:secret] = options[:secret]\n authorizer_helper_options[:authenticity_token] = authenticity_token\n end\n headers['HTTP_AUTHORIZATION'] = InfoSig::Authorizer.mock_authorization_header(authenticity_token, path, raw_request, authorizer_helper_options)\n\n response = post path, raw_request, headers\n\n rv = nil\n begin\n rv = JSON.parse(response.body)\n rescue Exception\n fail \"expected to see a JSON body, got #{response.inspect}\"\n end\n\n rv.symbolize_keys\n end",
"def send_request(method, options = {}, http_method = :get, endpoint = REST_ENDPOINT)\n options.merge!(:api_key => @api_key, :method => method)\n sign_request(options)\n \n rsp = request_over_http(options, http_method, endpoint)\n \n rsp = '<rsp stat=\"ok\"></rsp>' if rsp == \"\"\n xm = XmlMagic.new(rsp)\n \n if xm[:stat] == 'ok'\n xm\n else\n raise Flickr::Errors.error_for(xm.err[:code].to_i, xm.err[:msg])\n end\n end",
"def request(method, path, params = {}, options = {})\n\n raise AirbrakeError.new('API Token cannot be nil') if @auth_token.nil?\n raise AirbrakeError.new('Account cannot be nil') if @account.nil?\n\n response = connection(options).run_request(method, nil, nil, nil) do |request|\n case method\n when :delete, :get\n request.url(path, params.merge(:auth_token => @auth_token))\n when :post, :put\n request.url(path, :auth_token => @auth_token)\n request.body = params unless params.empty?\n end\n end\n response.body\n end",
"def process(request, response)\n indirection, method, key, params = uri2indirection(http_method(request), path(request), params(request))\n\n check_authorization(indirection, method, key, params)\n\n send(\"do_#{method}\", indirection, key, params, request, response)\n rescue SystemExit,NoMemoryError\n raise\n rescue Exception => e\n return do_exception(response, e)\n end",
"def call_api(http_method, path, opts = {})\n request = build_request(http_method, path, opts)\n response = request.run\n\n if @config.debugging\n @config.logger.debug \"HTTP response body ~BEGIN~\\n#{response.body}\\n~END~\\n\"\n end\n\n unless response.success?\n if response.timed_out?\n fail ApiError.new('Connection timed out')\n elsif response.code == 0\n # Errors from libcurl will be made visible here\n fail ApiError.new(:code => 0,\n :message => response.return_message)\n else\n fail ApiError.new(:code => response.code,\n :response_headers => response.headers,\n :response_body => response.body),\n response.status_message\n end\n end\n\n if opts[:return_type]\n data = deserialize(response, opts[:return_type])\n else\n data = nil\n end\n return data, response.code, response.headers\n end",
"def call_api(http_method, path, opts = {})\n request = build_request(http_method, path, opts)\n response = request.run\n\n if @config.debugging\n @config.logger.debug \"HTTP response body ~BEGIN~\\n#{response.body}\\n~END~\\n\"\n end\n\n unless response.success?\n if response.timed_out?\n fail ApiError.new('Connection timed out')\n elsif response.code == 0\n # Errors from libcurl will be made visible here\n fail ApiError.new(:code => 0,\n :message => response.return_message)\n else\n fail ApiError.new(:code => response.code,\n :response_headers => response.headers,\n :response_body => response.body),\n response.status_message\n end\n end\n\n if opts[:return_type]\n data = deserialize(response, opts[:return_type])\n else\n data = nil\n end\n return data, response.code, response.headers\n end",
"def call_api(http_method, path, opts = {})\n request = build_request(http_method, path, opts)\n response = request.run\n\n if @config.debugging\n @config.logger.debug \"HTTP response body ~BEGIN~\\n#{response.body}\\n~END~\\n\"\n end\n\n unless response.success?\n if response.timed_out?\n fail ApiError.new('Connection timed out')\n elsif response.code == 0\n # Errors from libcurl will be made visible here\n fail ApiError.new(:code => 0,\n :message => response.return_message)\n else\n fail ApiError.new(:code => response.code,\n :response_headers => response.headers,\n :response_body => response.body),\n response.status_message\n end\n end\n\n if opts[:return_type]\n data = deserialize(response, opts[:return_type])\n else\n data = nil\n end\n return data, response.code, response.headers\n end",
"def call_api(http_method, path, opts = {})\n request = build_request(http_method, path, opts)\n response = request.run\n\n if @config.debugging\n @config.logger.debug \"HTTP response body ~BEGIN~\\n#{response.body}\\n~END~\\n\"\n end\n\n unless response.success?\n if response.timed_out?\n fail ApiError.new('Connection timed out')\n elsif response.code == 0\n # Errors from libcurl will be made visible here\n fail ApiError.new(:code => 0,\n :message => response.return_message)\n else\n fail ApiError.new(:code => response.code,\n :response_headers => response.headers,\n :response_body => response.body),\n response.status_message\n end\n end\n\n if opts[:return_type]\n data = deserialize(response, opts[:return_type])\n else\n data = nil\n end\n return data, response.code, response.headers\n end",
"def perform(action, method = :get, payload = {})\n payload.merge!(username: self.username, password: self.password)\n\n headers = { 'User-Agent' => DeathByCaptcha::API_VERSION }\n\n if method == :post\n uri = URI(\"http://#{self.hostname}/api/#{action}\")\n req = Net::HTTP::Post.new(uri.request_uri, headers)\n req.set_form_data(payload)\n\n elsif method == :post_multipart\n uri = URI(\"http://#{self.hostname}/api/#{action}\")\n req = Net::HTTP::Post.new(uri.request_uri, headers)\n boundary, body = prepare_multipart_data(payload)\n req.content_type = \"multipart/form-data; boundary=#{boundary}\"\n req.body = body\n\n else\n uri = URI(\"http://#{self.hostname}/api/#{action}?#{URI.encode_www_form(payload)}\")\n req = Net::HTTP::Get.new(uri.request_uri, headers)\n end\n\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(req)\n end\n\n case res\n when Net::HTTPSuccess, Net::HTTPSeeOther\n Hash[URI.decode_www_form(res.body)]\n when Net::HTTPForbidden\n raise DeathByCaptcha::APIForbidden\n when Net::HTTPBadRequest\n raise DeathByCaptcha::APIBadRequest\n when Net::HTTPRequestEntityTooLarge\n raise DeathByCaptcha::APICaptchaTooLarge\n when Net::HTTPServiceUnavailable\n raise DeathByCaptcha::APIServiceUnavailable\n else\n raise DeathByCaptcha::APIResponseError.new(res.body)\n end\n end",
"def request(method, *args)\n public_send(method, *args)\n end",
"def send_request(method, path, fields = {})\n response = send_logged_request(URI(base_url + path), method, request_data(fields))\n fail UnexpectedHttpResponse, response unless response.is_a? Net::HTTPSuccess\n JSON.parse(response.body)\n end",
"def do_request(uri, parse, method = \"GET\", args = {})\n uri = URI(uri)\n\n case method\n when \"POST\"\n req = Net::HTTP::Post.new(uri.request_uri)\n when \"PATCH\"\n req = Net::HTTP::Post.new(uri.request_uri)\n else\n req = Net::HTTP::Get.new(uri.request_uri)\n end\n\n if not args.empty?\n req.body = args.to_json\n end\n\n req.basic_auth AUTH[\"user\"], AUTH[\"pw\"]\n\n http = Net::HTTP.new(uri.host, uri.port)\n if uri.scheme.eql? \"https\"\n http.use_ssl = true\n end\n res = http.start do |http| http.request(req) end\n if parse\n res = JSON.parse(res.body)\n else\n res = res.body\n end\n res\n end",
"def send_request(method: required('method'), path: nil, url: nil, body: nil,\n content_type: nil, encoding: nil, auth_type: :basic)\n req_type = case method\n when 'GET'\n :get\n when 'POST'\n :post\n when 'PUT'\n :put\n when 'DELETE'\n :delete\n else\n fail 'Method was not \"GET\" \"POST\" \"PUT\" or \"DELETE\"'\n end\n\n raise ArgumentError.new(\"path and url can't be both nil\") if path.nil? && url.nil?\n\n headers = {'User-Agent' => 'UARubyLib/' + Urbanairship::VERSION + ' ' + @key}\n headers['Accept'] = 'application/vnd.urbanairship+json; version=3'\n headers['Content-Type'] = content_type unless content_type.nil?\n headers['Content-Encoding'] = encoding unless encoding.nil?\n\n if @token != nil\n auth_type = :bearer\n end\n\n if auth_type == :bearer\n raise ArgumentError.new('token must be provided as argument if auth_type=bearer') if @token.nil?\n headers['X-UA-Appkey'] = @key\n headers['Authorization'] = \"Bearer #{@token}\"\n end\n\n url = \"https://#{@server}/api#{path}\" unless path.nil?\n\n debug = \"Making #{method} request to #{url}.\\n\"+ \"\\tHeaders:\\n\"\n debug += \"\\t\\tcontent-type: #{content_type}\\n\" unless content_type.nil?\n debug += \"\\t\\tcontent-encoding: gzip\\n\" unless encoding.nil?\n debug += \"\\t\\taccept: application/vnd.urbanairship+json; version=3\\n\"\n debug += \"\\tBody:\\n#{body}\" unless body.nil?\n\n logger.debug(debug)\n\n params = {\n method: method,\n url: url,\n headers: headers,\n payload: body,\n timeout: Urbanairship.configuration.timeout\n }\n\n if auth_type == :basic\n raise ArgumentError.new('secret must be provided as argument if auth_type=basic') if @secret.nil?\n params[:user] = @key\n params[:password] = @secret\n end\n\n response = RestClient::Request.execute(params)\n\n logger.debug(\"Received #{response.code} response. Headers:\\n\\t#{response.headers}\\nBody:\\n\\t#{response.body}\")\n Response.check_code(response.code, response)\n\n self.class.build_response(response)\n end",
"def execute(method,\n url,\n body: nil,\n headers: {},\n redirect_limit: @redirect_limit)\n raise ArgumentError, 'HTTP redirect too deep' if redirect_limit.zero?\n\n # setup our HTTP class\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == 'https'\n http.verify_mode = @ssl_verify\n\n # create our request\n request = net_http_request_class(method).new(uri)\n # copy headers into the request\n headers.each { |k, v| request[k] = v }\n # set body on the request\n if body\n request.content_type = 'application/json'\n request.body = body.to_json\n end\n\n # execute\n resp = http.request(request)\n\n # check response for success, redirect or error\n case resp\n when Net::HTTPSuccess then\n body = resp.body\n if body\n JSON.parse(body)\n else\n resp\n end\n when Net::HTTPRedirection then\n execute(method, resp['location'],\n body: body, headers: headers,\n redirect_limit: redirect_limit - 1)\n else\n Puppet.debug(\"throwing HTTP error: request_method=#{method} request_url=#{url} request_body=#{body} response_http_code=#{resp.code} resp_message=#{resp.message} resp_body=#{resp.body}\")\n stack_trace = caller.join(\"\\n\")\n Puppet.debug(\"Raising exception: #{resp.error_type.name}\")\n Puppet.debug(\"stack trace: #{stack_trace}\")\n message = 'code=' + resp.code\n message += ' message=' + resp.message\n message += ' body=' + resp.body\n raise resp.error_type.new(message, resp)\n end\n end",
"def do_request(verb, entity=nil, url_args=nil, post_args=nil)\n should_parse_xml = true\n url = URI(@api_url)\n if ['/oauth/request_token', '/oauth/access_token'].include?(verb)\n should_parse_xml = false\n url.path = verb\n else\n if not entity.nil?\n url.path = ['', API_VERSION, verb, entity].join('/')\n else\n url.path = ['', API_VERSION, verb].join('/')\n end\n end\n\n args = nil\n if not url_args.nil?\n args = url_args\n url.query = TripIt.urlencode_args(url_args)\n end\n\n request = nil\n if not post_args.nil?\n args = post_args\n request = Net::HTTP::Post.new(url.path)\n request.set_form_data(post_args)\n else\n request = Net::HTTP::Get.new(url.request_uri)\n end\n\n @credential.authorize(request, url, args)\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n if @verify_ssl\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n end\n response = http.start do\n http.request(request)\n end\n\n if response.code == '200'\n if should_parse_xml\n parse_xml(response.body)\n else\n response.body\n end\n else\n response.error!\n end\n end",
"def send_request(api_method, opts = {}, action = :get, endpoint = self.endpoint)\n\n opts.merge! method: api_method, api_key: key\n\n case action\n when :get\n url_string = endpoint + \"?\" + opts.collect{|k,v| \"#{k}=#{CGI.escape(v.to_s)}\"}.join('&')\n url = URI.parse(url_string)\n req = Net::HTTP::Get.new url.request_uri\n\n Net::HTTP.start(url.host, url.port, use_ssl: url.scheme == 'https') do |http|\n http.request req\n end\n when :post\n Net::HTTP.post_form URI.parse(endpoint), opts\n end\n end",
"def call(method, url, data = nil, options = nil)\n if NO_BODY.include?(method)\n options ||= data\n data = nil\n end\n\n if data\n data = data.is_a?(String) ? data : encode_body(data)\n end\n\n options ||= {}\n url = expand_url(url, options[:uri])\n @adapter.request(self, method, url, data, options)\n end",
"def call_method(method, *args)\n @api_client.public_send(method, *args)\n end",
"def rest_call(url, method, options = {})\n methods = %w{get post put}\n result = {\"status\" => \"ERROR\", \"response\" => \"\", \"message\" => \"\"}\n method = method.downcase\n verbose = get_option(options, \"verbose\") == \"yes\" or get_option(options, \"verbose\")\n headers = get_option(options, \"headers\", {:accept => :json, :content_type => :json})\n return result[\"message\"] = \"ERROR - #{method} not recognized\" unless methods.include?(method)\n log \"Rest URL: #{url}\" if verbose\n begin\n data = get_option(options, \"data\")\n rest_params = {}\n rest_params[:url] = url\n rest_params[:method] = method.to_sym\n rest_params[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE if url.start_with?(\"https\")\n rest_params[:payload] = data.to_json unless data == \"\"\n if options.has_key?(\"username\") && options.has_key?(\"password\")\n rest_params[:user] = options[\"username\"]\n rest_params[:password] = options[\"password\"]\n end\n rest_params[:headers] = headers\n log \"RestParams: #{rest_params.inspect}\" if verbose\n if %{put post}.include?(method)\n return result[\"message\"] = \"ERROR - no data param for post\" if data == \"\"\n response = RestClient::Request.new(rest_params).execute\n else\n response = RestClient::Request.new(rest_params).execute\n end\n rescue Exception => e\n result[\"message\"] = e.message\n raise \"RestError: #{result[\"message\"]}\" unless get_option(options, \"suppress_errors\") == true\n return result\n end\n log \"Rest Response:\\n#{response.inspect}\" if verbose\n if headers[:accept] == :json\n parsed_response = JSON.parse(response) rescue nil\n else\n parsed_response = response\n end\n parsed_response = {\"info\" => \"no data returned\"} if parsed_response.nil?\n result[\"code\"] = response.code\n if response.code < 300\n result[\"status\"] = \"success\"\n result[\"data\"] = parsed_response\n elsif response.code == 422\n result[\"message\"] = \"REST call returned code 422 usually a bad token\"\n else\n result[\"message\"] = \"REST call returned HTTP code #{response.code}\"\n end\n if result[\"status\"] == \"ERROR\"\n raise \"RestError: #{result[\"message\"]}\" unless get_option(options, \"suppress_errors\") == true\n end\n result\n end",
"def request(method)\n setup_client\n respond_with @client.request(method, @request.url, nil, @request.body, @request.headers, &@request.on_body)\n rescue OpenSSL::SSL::SSLError\n raise SSLError\n rescue Errno::ECONNREFUSED # connection refused\n $!.extend ConnectionError\n raise\n end",
"def make_request url, parameters={}, method=:get, settings={}\n raise 'not implemented'\n end",
"def request(method, path, options)\n connection_method = if options.present? && options.delete(:request_token)\n token_connection(options.delete(:params) || {})\n else\n connection\n end\n http_response = connection_method.send(method) do |request|\n case method\n when :get\n formatted_options = format_options(options)\n request.url(path, formatted_options)\n when :post, :put\n request.headers['Content-Type'] = 'application/json'\n request.body = options.to_json unless options.empty?\n request.url(path)\n end\n request.options.timeout = 120 # read timeout\n request.options.open_timeout = 300 # connection timeout\n end\n\n data = Response.create(http_response.body)\n response = {}\n\n response['data'] = data\n response\n end",
"def request_double(url: 'http://example.com', method: 'get')\n instance_double('RestClient::Request',\n url: url, uri: URI.parse(url), method: method, user: nil, password: nil,\n cookie_jar: HTTP::CookieJar.new, redirection_history: nil,\n args: {url: url, method: method})\n end",
"def call_rest(action, url, auth_cert, auth_key, ref, content_type, body = nil)\n begin\n # change url based on if we have a ref or not\n if ref.nil?\n url = url\n else\n url = url + \"/\" + ref\n end\n\n # set params for api call\n params = {\n :method => action,\n :url => url,\n :ssl_client_cert => OpenSSL::X509::Certificate.new(auth_cert),\n :ssl_client_key => OpenSSL::PKey::RSA.new(auth_key),\n :verify_ssl => false,\n :headers => { :content_type => content_type, :accept => content_type }\n }\n\n # generate payload data\n content_type == :json ? (params[:payload] = JSON.generate(body) if body) : (params[:payload] = body if body)\n log(:info, \"call_rest: Request: #{url} action: #{action} payload: #{params[:payload]}\")\n\n # execute the request\n RestClient::Request.new(params).execute\n rescue => err\n # log and backtrace the error\n log(:error, \"[#{err}]\\n#{err.backtrace.join(\"\\n\")}\")\n log(:error, \"call_rest: #{err}. Returning nil.\")\n return nil\n end\nend",
"def csreq(method,server,path,port,scheme,headers = {},data = nil,attempts = 0) # :nodoc:\n start = Time.now\n if data\n headers['Content-Type'] ||= 'application/json'\n end\n hdrhash = headerprep(headers)\n start_http(server,path,port,scheme,hdrhash)\n request = Net::HTTP.const_get(method.to_s.capitalize).new(path,hdrhash)\n request.body = data\n response = @http[server].request(request)\n raise CloudServers::Exception::ExpiredAuthToken if response.code == \"401\"\n raise CloudServers::Exception::CloudServersFault.new( \"Server fault! / #{response.body}\", response.code, response.body ) if response.code == \"500\"\n raise CloudServers::Exception::ServiceUnavailable.new( \"Service Unavailable\", response.code, response.body ) if response.code == \"503\"\n raise CloudServers::Exception::OverLimit.new( \"Service Unavailable\", response.code, response.body ) if response.code == \"413\"\n response\n rescue Errno::EPIPE, Timeout::Error, Errno::EINVAL, EOFError\n # Server closed the connection, retry\n raise CloudServers::Exception::Connection, \"Unable to reconnect to #{server} after #{attempts} attempts\" if attempts >= 5\n attempts += 1\n @http[server].finish if @http[server].started?\n start_http(server,path,port,scheme,headers)\n retry\n rescue CloudServers::Exception::ExpiredAuthToken\n raise CloudServers::Exception::Connection, \"Authentication token expired and you have requested not to retry\" if @retry_auth == false\n CloudServers::Authentication.new(self)\n retry\n end",
"def run_request(method, path, body, headers)\n klass = Net::HTTP.const_get(method.to_s.capitalize)\n req.klass.new(path, headers)\n req.body = body if body\n request(req)\n end",
"def userauth_request(username, next_service, auth_method, *others); end",
"def execute(http_method, path, request_body = {})\n Connection.send(http_method, path, :body => request_body)\n end",
"def request(method, path, params = nil)\n uri = URI.parse(url_for(path))\n\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = uri.kind_of?(URI::HTTPS)\n client.verify_mode = OpenSSL::SSL::VERIFY_PEER\n client.ca_file = CA_FILE\n\n request = net_class(method).new(uri.request_uri)\n request.basic_auth Codeplane.username, Codeplane.api_key\n request[\"Content-Type\"] = \"application/x-www-form-urlencoded\"\n request[\"User-Agent\"] = \"Codeplane/#{Codeplane::Version::STRING}\"\n request.body = params.to_param if request.request_body_permitted? && params\n\n response = client.request(request)\n\n case response.code\n when \"401\"\n raise Codeplane::UnauthorizedError, \"Double check you username and API key\"\n when \"404\"\n raise Codeplane::NotFoundError\n else\n Codeplane::Response.new(response)\n end\n end",
"def request(\n method,\n path,\n headers = nil,\n body = nil,\n api_version = EasyPost::InternalUtilities::Constants::API_VERSION\n )\n # Remove leading slash from path.\n path = path[1..] if path[0] == '/'\n\n uri = URI.parse(\"#{@base_url}/#{api_version}/#{path}\")\n headers = @config[:headers].merge(headers || {})\n serialized_body = JSON.dump(EasyPost::InternalUtilities.objects_to_ids(body)) if body\n open_timeout = @config[:open_timeout]\n read_timeout = @config[:read_timeout]\n request_timestamp = Time.now\n request_uuid = SecureRandom.uuid\n\n if EasyPost::Hooks.any_subscribers?(:request)\n request_context = EasyPost::Hooks::RequestContext.new(\n method: method,\n path: uri.to_s,\n headers: headers,\n request_body: body,\n request_timestamp: request_timestamp,\n request_uuid: request_uuid,\n )\n EasyPost::Hooks.notify(:request, request_context)\n end\n\n # Execute the request, return the response.\n\n response = if @custom_client_exec\n @custom_client_exec.call(method, uri, headers, open_timeout, read_timeout, serialized_body)\n else\n default_request_execute(method, uri, headers, open_timeout, read_timeout, serialized_body)\n end\n response_timestamp = Time.now\n\n if EasyPost::Hooks.any_subscribers?(:response)\n response_context = {\n http_status: nil,\n method: method,\n path: uri.to_s,\n headers: nil,\n response_body: nil,\n request_timestamp: request_timestamp,\n response_timestamp: response_timestamp,\n client_response_object: response,\n request_uuid: request_uuid,\n }\n\n # If using a custom HTTP client, the user will have to infer these from the raw\n # client_response_object attribute\n if response.is_a?(Net::HTTPResponse)\n response_body = begin\n JSON.parse(response.body)\n rescue JSON::ParseError\n response.body\n end\n response_context.merge!(\n {\n http_status: response.code.to_i,\n headers: response.each_header.to_h,\n response_body: response_body,\n },\n )\n end\n\n EasyPost::Hooks.notify(:response, EasyPost::Hooks::ResponseContext.new(**response_context))\n end\n\n response\n end",
"def request(method, path, options, headers)\n headers.merge!({\n 'User-Agent' => user_agent\n })\n\n options.merge!({\n :api_key => api_key\n })\n\n response = connection.send(method) do |request|\n request.url \"#{endpoint}#{path}\", options\n request.body = options\n request.headers = headers\n end\n Shirtsio::Utils.handle_api_error(response) if response.status != 200\n\n Shirtsio::Utils.parse_json(response.body)[:result]\n end",
"def make_http_request( url, options, auth_info = {} )\n try_count = 0\n \n begin\n request = Net::HTTP::Post.new(url.path)\n request.basic_auth auth_info[:hapi_username], auth_info[:hapi_password] unless auth_info.empty?\n request.set_form_data(options)\n request.add_field('User-Agent', USER_AGENT)\n \n http = Net_HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.request(request)\n rescue Errno::ECONNREFUSED\n if try_count < 2\n try_count += 1\n sleep 1\n retry\n else\n raise Backend, \"Connection refused trying to contact hAPI at #{@hapi_hostname}\"\n end\n end\n end"
] | [
"0.7433135",
"0.71996975",
"0.7114339",
"0.69521403",
"0.6861476",
"0.6836841",
"0.6722458",
"0.6681006",
"0.6672767",
"0.66568345",
"0.66376173",
"0.6632255",
"0.6590535",
"0.6588767",
"0.6573776",
"0.65652335",
"0.6552048",
"0.6552048",
"0.6551272",
"0.6548551",
"0.6546658",
"0.6541526",
"0.6540652",
"0.653181",
"0.65151584",
"0.64884824",
"0.6481788",
"0.6471701",
"0.64601946",
"0.6450313",
"0.6424133",
"0.6415249",
"0.6390434",
"0.6385039",
"0.6382285",
"0.63820887",
"0.6373864",
"0.637161",
"0.637103",
"0.6365924",
"0.63585275",
"0.6357686",
"0.6351205",
"0.63480383",
"0.63437",
"0.6335496",
"0.6330508",
"0.6328004",
"0.6315016",
"0.63132",
"0.6309141",
"0.62966985",
"0.6280616",
"0.6277695",
"0.62610215",
"0.62606174",
"0.62573075",
"0.6236259",
"0.62319964",
"0.62310565",
"0.62186426",
"0.62091017",
"0.6192406",
"0.6183315",
"0.61723113",
"0.61581606",
"0.6154644",
"0.6133113",
"0.6132062",
"0.61303645",
"0.6126518",
"0.61156446",
"0.6108764",
"0.6108764",
"0.6108764",
"0.6108764",
"0.6106816",
"0.61041796",
"0.60899866",
"0.60888463",
"0.6082817",
"0.60785556",
"0.6070293",
"0.6060828",
"0.6052507",
"0.60439444",
"0.6032155",
"0.6031237",
"0.602414",
"0.60237473",
"0.60205114",
"0.6011937",
"0.60078573",
"0.600288",
"0.60022944",
"0.5989315",
"0.59889156",
"0.5986196",
"0.5980256",
"0.59772086"
] | 0.78931975 | 0 |
create command for add helm repository =============================================================== | def do_add_repo(repository,mirror_enabled,mirror_url,mirror_ca_cert)
name = repository['name']
url = repository['url']
if !mirror_enabled
cmd = "helm repo add #{name} #{url} "
else
if mirror_ca_cert == ""
cmd = "helm repo add #{name} #{mirror_url} "
else
cmd = "helm repo add --ca-file=/var/vcap/store/action/config/mirror_ca_cert.pem #{name} #{mirror_url} "
end
end
"#{cmd};helm repo update"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_command\n command = ['helm', 'upgrade', name, chart] +\n install_flag +\n reset_values_flag +\n optional_tls_flags +\n optional_version_flag +\n rbac_create_flag +\n namespace_flag +\n value_flag\n\n command.shelljoin\n end",
"def add_repo(pkg)\n if pkg[:repo] != nil\n if pkg[:repo].match(/^deb/)\n if pkg[:key] != nil\n # download and add key, add repo\n script \"add_repository\" do\n interpreter \"bash\"\n user \"root\"\n cwd \"/tmp\"\n code <<-EOS\n wget -q #{pkg[:key]} -O- | apt-key add -\n mkdir -p /etc/apt/sources.list.d\n echo \"#{pkg[:repo]}\" > /etc/apt/sources.list.d/virtualbox.list\n EOS\n end\n end\n elsif pkg[:repo].match(/^ppa/)\n # don't care about :key, add repo\n script \"add_repository\" do\n interpreter \"bash\"\n user \"root\"\n cwd \"/tmp\"\n code \"add-apt-repository #{pkg[:repo]}\"\n end\n end\n end\nend",
"def create\n display 'Create a new Unfuddle repository'\n \n repo = Unfuddle::Resources::Repository.create(\n :repository => {\n :title => ask('Name', :required => true),\n :abbreviation => ask('Slug', :required => true),\n :system => 'git',\n :projects => {\n :project => {\n :id => 24468 \n }\n }\n }\n )\n end",
"def create(project_name, repo_name, description) ; end",
"def add_repository(name)\n system(\"#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects add-project #{name}.git\")\n end",
"def install_repo!\n package 'apt-transport-https'\n include_recipe \"apt-chef::#{new_resource.channel}\"\n package 'chefdk' do\n version new_resource.version unless new_resource.version == 'latest'\n end\n end",
"def git_add\n `git add package.json npm-shrinkwrap.json`\n end",
"def add_command(*args)\n case args.size\n when 1 # Hash initializer\n args = args[0]\n cat = args[:category] ? args[:category] : :main\n content = {\n :name => args[:name],\n :symbol => args[:symbol],\n :enabled => args[:enabled].nil? ? true : args[:enabled],\n :ext => args[:ext],\n :help => args[:help],\n :child => args[:child],\n }\n else\n name = args[0]; symbol = args[1]; \n enabled = args[2].nil? ? true : args[2];\n ext = args[3]\n help = args[4]\n cat = args[5].nil? ? :main : args[5];\n child = args[6]\n content = {:name=>name, :symbol=>symbol, :enabled => enabled,\n :ext=>ext, :help => help, :child => child}\n end\n (@list[cat] ||= []) << content\n end",
"def create\n response.add(exec: \"kubectl create ns #{namespace}\", env: kube_env)\n response.add(exec: \"kubectl label namespace #{namespace} istio-injection=enabled --overwrite\", env: kube_env)\n # errors.add(:kubectl_label_namespace, stderr) if exit_code.positive? and stderr.index('AlreadyExists').nil?\n\n # deploy helm into namespace\n # TODO: Need to generate tiller-rbac\n response.add(exec: kubectl(\"apply -f #{target.write_path}/tiller-k8s-ns.yml\"), env: kube_env)\n response.add(exec: 'helm init --upgrade --wait --service-account tiller', env: kube_env)\n end",
"def add_repo (repository_name)\n \"add-apt-repository -y #{repository_name} >/dev/null 2>/dev/null\"\n end",
"def add_repository!\n apt_repository 'partner' do\n uri 'http://archive.canonical.com'\n components %w(partner)\n distribution node['lsb']['codename']\n action :add\n end\n end",
"def action_create\n\n install_prerequisites\n\n node.set['pedant'][new_resource.variant]['etc_dir'] = new_resource.config_dir\n\n directory new_resource.config_dir do\n owner new_resource.user\n group new_resource.group\n mode \"0755\"\n recursive true\n end\n\n source_dir = \"#{new_resource.checkout_dir}/#{new_resource.variant}\"\n\n git new_resource.variant do\n destination source_dir\n repository \"git@github.com:opscode/#{new_resource.variant}.git\"\n revision new_resource.revision\n user new_resource.git_user\n end\n\n node.set['pedant'][new_resource.variant]['dir'] = \"/srv/#{new_resource.variant}\"\n\n link node['pedant'][new_resource.variant]['dir'] do\n to source_dir\n end\n\n template \"#{new_resource.config_dir}/pedant_config.rb\" do\n source new_resource.config_template\n owner new_resource.user\n group new_resource.group\n mode \"0644\"\n variables(new_resource.variables)\n end\n\n execute \"bundle install\" do\n cwd node['pedant'][new_resource.variant]['dir']\n # user \"opscode\"\n end\n\nend",
"def install_repo!\n if new_resource.version != 'latest'\n raise(Chef::Exceptions::UnsupportedAction,\n 'A version property cannot be used with the :repo source')\n end\n if new_resource.channel != :stable\n raise(Chef::Exceptions::UnsupportedAction,\n 'A channel property cannot be used with the :repo source')\n end\n include_recipe 'homebrew'\n homebrew_cask 'chefdk'\n end",
"def install_repo!\n if new_resource.channel != :stable\n raise(Chef::Exceptions::UnsupportedAction,\n 'A channel property cannot be used with the :repo source')\n end\n include_recipe 'chocolatey'\n chocolatey_package 'chefdk' do\n unless [nil, 'latest'].include?(new_resource.version)\n version new_resource.version\n end\n end\n end",
"def repo_make(name)\n path = repo_path(name)\n path.mkpath\n Dir.chdir(path) do\n Pod::Executable.capture_command!('git', %w(init))\n Pod::Executable.capture_command!('git', %w(checkout -b main))\n repo_make_readme_change(name, 'Added')\n Pod::Executable.capture_command!('git', %w(add .))\n Pod::Executable.capture_command!('git', %w(commit -nm Initialized.))\n end\n path\n end",
"def create_ips_repo\n shellout!(\"pkgrepo create #{repo_dir}\")\n log.info(log_key) { \"Created IPS repo: #{repo_dir}\" }\n end",
"def monitoring_repository(action)\n # call with :add or :remote, defaults to :add\n action ||= 'add'\n\n case node['platform_family']\n when 'debian'\n apt_repository 'rackspace_monitoring' do\n uri \"https://stable.packages.cloudmonitoring.rackspace.com/#{node['platform']}-#{node['lsb']['release']}-x86_64\"\n distribution 'cloudmonitoring'\n components ['main']\n key \"https://monitoring.api.rackspacecloud.com/pki/agent/#{node['platform']}-#{node['platform_version'][0]}.asc\"\n action action\n end\n when 'rhel'\n yum_repository 'rackspace_monitoring' do\n description 'Rackspace Monitoring Agent package repository'\n baseurl \"https://stable.packages.cloudmonitoring.rackspace.com/#{node['platform']}-#{node['platform_version'][0]}-x86_64\"\n gpgkey \"https://monitoring.api.rackspacecloud.com/pki/agent/#{node['platform']}-#{node['platform_version'][0]}.asc\"\n enabled true\n gpgcheck true\n action action\n end\n end\nend",
"def stage\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_add_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} add -A\"\n log.info(x) { \"[git] add command => #{git_add_cmd}\" }\n %x[#{git_add_cmd}];\n log.info(x) { \"[git] has recursively added resources to version management.\" }\n\n end",
"def create\n execute ['cmd', '/c', INSTALLUTIL, @resource[:arguments], @resource[:path]].flatten.compact.join(' ')\n end",
"def create_label_if_missing(label:, colour:, description:)\n Octokit.label(ENV.fetch(\"GITHUB_REPO\"),label)\nrescue Octokit::NotFound\n Octokit.add_label(ENV.fetch(\"GITHUB_REPO\"), label, colour, description: description)\nend",
"def repo; end",
"def repo; end",
"def repo; end",
"def repo; end",
"def add(hash, opts = {})\n uuid = opts[:id] || SecureRandom.uuid\n thash = Treet::Hash.new(hash)\n repos[uuid] = thash.to_repo(\"#{root}/#{uuid}\", opts.merge(:repotype => repotype))\n end",
"def create_managed_repository\n OpenProject::Revisions::Git::GitoliteWrapper.update(:add_repository, self)\n rescue => e\n Rails.logger.error(\"Error while adding repository #{repository_identifier}: #{e.message}\")\n raise OpenProject::Scm::Exceptions::RepositoryBuildError.new(\n I18n.t('repositories.gitolite.cannot_add_repository')\n )\n end",
"def plugin(name, repo)\n desc \"install #{name} plugin\"\n local(\"plugin:#{name}\" => :setup) do\n log \"\\e[36m## Installing plugin %s\\e[0m\" % name\n Dir.mkdir(DO_PATH) unless File.exist?(DO_PATH)\n sh \"curl --location --progress-bar #{repo} > #{File.join(DO_PATH, '%s.rake' % name)}\"\n end\n end",
"def add_commands\n end",
"def use_git(opts)\n # The Deploy resources assumes you have already created the 'shared' directories\n FileUtils.mkdir_p File.join(opts[:destination], 'shared', 'log')\n\n # setup the optional action and revision\n rev = \"\"\n rev = \"revision \\\"#{opts[:revision]}\\\"\" if opts[:revision]\n action = \"\"\n action = \"action :rollback\" if opts[:rollback]\n action = \"action :force_deploy\" if opts[:force]\n\n @cookbook =<<EOBOOK\n deploy_revision \"#{opts[:destination]}\" do\n repo \"#{opts[:repository]}\"\n #{rev}\n shallow_clone true\n symlinks Hash.new\n symlink_before_migrate Hash.new\n create_dirs_before_symlink Array.new\n purge_before_symlink Array.new\n #{action}\n end\nEOBOOK\n end",
"def install_engine\n generate 'hydra:head -f'\n end",
"def install_node_repos(config)\n\n config.vm.provision \"shell\", inline: <<-SHELL\n sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM\n[google-cloud-sdk]\nname=Google Cloud SDK\nbaseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg\n https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg\nEOM\n SHELL\n \n end",
"def add(label, path, options={})\n if path.is_a?(Array)\n path.each{|p| add label, p, options} \n else\n repository_class = options[:class] || Qwandry::FlatRepository\n label = label.to_s\n @repositories[label] << repository_class.new(label, File.expand_path(path), options)\n end\n end",
"def install_hyrax\n generate 'hyrax:install -f'\n end",
"def install\n bin.install \"git-subtree.sh\" => \"git-subtree\"\n end",
"def add(command_line)\n subcommand, rest = command_line.split(/ /, 2)\n #checking wether the second word after command 'add' is 'project' || 'task'\n if subcommand == 'project'\n add_project rest\n elsif subcommand == 'task'\n project, description, deadline = rest.split(/ /, 3)\n add_task project, description, deadline\n end\n end",
"def create_command_help\n puts \"The Ruby Farm - a simple command line animals app\"\n puts\n puts \"Command Usage:\"\n puts \" [create | c] <name=> <type=> creates a animal with name\"\n puts \"\"\n puts \"Examples:\"\n puts \" bin/run [create | c] name=my_animal_name\"\n puts \" bin/run [create | c] name=my_animal_name type=pig\"\n end",
"def repository=(value)\n # directory creation should be handled by the repository\n veeamconfig('job', 'edit', '--repoName', \"#{value}\", 'for', '--name', \"#{@resource[:name]}\")\n end",
"def autorun_cmd(repo_name)\n [\"cp -Rf #{STARTDIR}/components/autogen/#{repo_name}/* .\",\n \"touch Makefile\"]\nend",
"def create_repository_from_template(repo, name, options = {})\n options.merge! :name => name\n options = ensure_api_media_type(:template_repositories, options)\n post \"#{Repository.path repo}/generate\", options\n end",
"def add_master_repo\n cmd = ['master', url, 'master', '--progress']\n Repo::Add.parse(cmd).run\n end",
"def register_psrepository_scriptblock\n return if config[:register_repository].nil?\n\n info(\"Registering a new PowerShellGet Repository\")\n Array(config[:register_repository]).map do |psrepo|\n # Using Set-PSRepo from ../../*/*/*/PesterUtil.psm1\n debug(\"Command to set PSRepo #{psrepo[:Name]}.\")\n <<-PS1\n Write-Host 'Registering psrepo #{psrepo[:Name]}...'\n ${#{psrepo[:Name]}} = #{ps_hash(psrepo)}\n Set-PSRepo -Repository ${#{psrepo[:Name]}}\n PS1\n end\n end",
"def add!()\n git \"add #{@path}\"\n end",
"def create_standalone_remote_tag tag_name\n in_secondary_repository do\n run 'git checkout -b temp'\n run 'touch a.txt'\n run 'git add -A'\n run 'git commit -m \"temp\"'\n run \"git tag -a #{tag_name} -m '#{tag_name}'\"\n run 'git push --tags'\n end\nend",
"def commit_changes(description)\n git :add => '-A'\n git :commit => %Q(-qm \"thegarage-template: [#{@current_recipe}] #{description}\")\nend",
"def new_public_app_with_repo ( type=\"repo\")\r\n puts \"+<repo_type> is #{type.upcase}\"\r\n puts \"+ <action> New public app with github repo --- begin\"\r\n make_sure_apps_page unless @driver.current_url =~ /.*apps.*/\r\n # Selenium::WebDriver::Wait.new(:timeout => 120).until { new_app_btn }\r\n sleep 10\r\n if new_app_btn_display?\r\n new_app_locator(:new_app_btn).click\r\n end\r\n new_app_locator(:opensource_repo_tab).click\r\n new_app_locator(:paste_git_repo_input).clear\r\n if type.upcase==\"REPO\"\r\n new_app_locator(:paste_git_repo_input).send_keys $data[:app][:new_app][:by_repo] + \"\\n\"\r\n elsif type.upcase==\"PLUGIN_REPO\"\r\n new_app_locator(:paste_git_repo_input).send_keys $data[:app][:new_app][:by_with_plugin_repo1] + \"\\n\"\r\n elsif type.upcase==\"LARGE_REPO\"\r\n new_app_locator(:paste_git_repo_input).send_keys $data[:app][:new_app][:by_with_large_repo] + \"\\n\"\r\n else\r\n raise \"Not supported repo.\"\r\n end\r\n sleep 10\r\n puts \"+ <action> New public app with github repo --- end\"\r\n end",
"def cloud_metadata_generation_command\n ruby_path = File.normalize_path(AgentConfig.ruby_cmd)\n rs_cloud_path = File.normalize_path(Gem.bin_path('right_link', 'cloud'))\n return \"#{ruby_path} #{rs_cloud_path} --action write_cloud_metadata\"\nend",
"def rhel_init_db_command(new_resource)\n cmd = new_resource.source.eql?(:repo) ? \"/usr/pgsql-#{new_resource.version}/bin/initdb\" : '/usr/bin/initdb'\n cmd << \" --locale '#{new_resource.initdb_locale}'\" if new_resource.initdb_locale\n cmd << \" -E '#{new_resource.initdb_encoding}'\" if new_resource.initdb_encoding\n cmd << \" #{new_resource.initdb_additional_options}\" if new_resource.initdb_additional_options\n cmd << \" -D '#{data_dir}'\"\n end",
"def install\n end",
"def install\n end",
"def build_repo(uri, distribution, components, trusted, arch, add_deb_src)\n components = components.join(' ') if components.respond_to?(:join)\n repo_options = []\n repo_options << \"arch=#{arch}\" if arch\n repo_options << 'trusted=yes' if trusted\n repo_options = '[' + repo_options.join(' ') + ']' unless repo_options.empty?\n repo_info = \"#{uri} #{distribution} #{components}\\n\"\n repo_info = \"#{repo_options} #{repo_info}\" unless repo_options.empty?\n repo = \"deb #{repo_info}\"\n repo << \"deb-src #{repo_info}\" if add_deb_src\n repo\nend",
"def repo!(name='blah')\n path = File.join(PATH, name.to_s)\n FileUtils::mkdir_p(path)\n delete!(name)\n\n @repos ||= {}\n @current_repo = name.to_sym\n @repos[@current_repo] = SvnRepos.create(path)\n end",
"def install\n bin.install \"iloops\"\n end",
"def initial_push_command\n \"git remote add origin git@github.com:#{owner.login}/#{name}.git &&\\n\" +\n \"git push origin master &&\\n\" +\n \"git config --add branch.master.remote origin &&\\n\" +\n \"git config --add branch.master.merge refs/heads/master\" \n end",
"def create_kubernetes_addon_repository_with_http_info(kubernetes_addon_repository, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.create_kubernetes_addon_repository ...'\n end\n # verify the required parameter 'kubernetes_addon_repository' is set\n if @api_client.config.client_side_validation && kubernetes_addon_repository.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_addon_repository' when calling KubernetesApi.create_kubernetes_addon_repository\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/AddonRepositories'\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_addon_repository)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesAddonRepository'\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_addon_repository\",\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_addon_repository\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend",
"def rhel_init_db_command(new_resource)\n cmd = if platform_family?('amazon')\n '/usr/bin/initdb'\n else\n \"/usr/pgsql-#{new_resource.version}/bin/initdb\"\n end\n cmd << \" --locale '#{new_resource.initdb_locale}'\" if new_resource.initdb_locale\n cmd << \" -E '#{new_resource.initdb_encoding}'\" if new_resource.initdb_encoding\n cmd << \" -D '#{data_dir(new_resource.version)}'\"\n end",
"def create\n @repository = @project.repositories.new(params[:repository])\n @repository.path = '/home/git/repositories'\n @repository.repo_name = @repository.name.downcase.gsub(\" \",\"_\")\n respond_to do |format|\n if @repository.save\n flash[:notice] = 'Repository was successfully created.'\n format.html { redirect_to([@project,@repository]) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def pkg_cmd; \"#{pkg_binary}\" end",
"def install\n libexec.install \"networking-swagger-java.sh\"\n bin.install_symlink libexec/\"networking-swagger-java.sh\" => \"networking-swagger-java\"\n end",
"def repo=(_arg0); end",
"def repo=(_arg0); end",
"def repo=(_arg0); end",
"def repo=(_arg0); end",
"def create\n commands = fetch_commands\n Puppet.debug(\"Commands: #{commands}\")\n\n commands.each do |message, command|\n bring_up(message, command)\n end\n end",
"def install\n end",
"def create_pool\n cmd_text = \"ceph osd pool create #{new_resource.name} #{new_resource.pg_num} #{new_resource.pgp_num} #{new_resource.type}\"\n cmd_text << \" #{new_resource.profile}\" if new_resource.profile\n cmd_text << \" #{new_resource.crush_ruleset_name}\" if new_resource.crush_ruleset_name\n cmd_text << \" #{new_resource.options}\" if new_resource.options\n\n puts \"\\nRunning... #{cmd_text}\"\n\n cmd = Mixlib::ShellOut.new(cmd_text)\n cmd.run_command\n cmd.error!\n Chef::Log.debug \"Pool created: #{cmd.stderr}\"\nend",
"def create(label, name, summary, arch, parent)\n @connection.call('channel.software.create', @sid, label, name, summary, arch, parent)\n end",
"def setup debian_repository\n write_config debian_repository\n restart\n end",
"def gitrepo(repo, name, ref = 'master')\n mod name.split('/').join('-'),\n :git => \"https://#{repo}/#{name}.git\",\n :ref => ref\nend",
"def install\n \n end",
"def generate_commands\n \n create = CmdParse::Command.new('create', false)\n create.short_desc = 'Creates the folders and files for a given project name.'\n create.description = 'This command creates all the folders and files '\n create.description << 'for the given project name. You can specify the '\n create.description << 'project type and main language with the -t '\n create.description << 'and -l switches. By default -t is web and -l is html.'\n \n create.options = CmdParse::OptionParserWrapper.new do |opt|\n opt.on('-t', '--type TYPE',\n 'Create project files of type TYPE') { |type| @type = type }\n opt.on('-l', '--language LANGUAGE',\n 'Create main project files with the LANGUAGE extension'\n ) { |language| @language = language }\n opt.on('-d', '--doctype DOCTYPE',\n 'Create main project markup files with chosen DOCTYPE. Only for web projects'\n ) { |doctype| @doctype = doctype }\n end\n \n create.set_execution_block do |args|\n \n # should this be the desired behavior? Maybe exit if not valid\n @language = VALID_LANGUAGES[0] unless VALID_LANGUAGES.include?(@language)\n @type = VALID_TYPES[0] unless VALID_TYPES.include?(@type)\n @doctype = VALID_DOCTYPES[0] unless VALID_DOCTYPES.include?(@doctype)\n \n puts \"Type: #{@type}\"\n puts \"Main Language: #{@language}\"\n self.create(args[0])\n end\n \n @cmd.add_command(create)\n @cmd.add_command(CmdParse::HelpCommand.new, true)\n @cmd.add_command(CmdParse::VersionCommand.new)\n end",
"def add_specs_to_repo\n UI.puts \"Adding the #{'spec'.pluralize(podspec_files.count)} to repo `#{@repo}'\\n\"\n podspec_files.each do |spec_file|\n spec = Pod::Specification.from_file(spec_file)\n output_path = File.join(repo_specs_dir, spec.name, spec.version.to_s)\n UI.puts \" --> #{get_message(output_path, spec)}\"\n if @local_only\n create_json_in_path(output_path, spec)\n else\n # TODO push to local disabled until virtual repo support\n raise Informative, 'Pushing specs to Artifactory is currently disabled'\n=begin\n begin\n podspec_json_tmp_path = create_json_in_path(output_path, spec)\n rescue => e\n FileUtils.remove(output_path, :force => true)\n raise Informative, \"Error writing spec file in target path '#{output_path}': #{e.message}\"\n end\n\n begin\n push_to_remote(spec, podspec_json_tmp_path)\n rescue => e\n FileUtils.remove(output_path, :force => true)\n raise Informative, \"Error pushing to remote '#{@repo}': #{e.message}\"\n end\n FileUtils.remove(podspec_json_tmp_path, :force => true)\n=end\n end\n end\n end",
"def add_master_repo\n cmd = ['master', url, 'master']\n cmd << '--shallow' if @shallow\n Repo::Add.parse(cmd).run\n end",
"def plugin(name, repo)\n desc \"install #{name} plugin\"\n namespace :plugin do\n task(name => 'setup') do\n log \"\\e[36m## Installing plugin %s\\e[0m\" % name\n Dir.mkdir(DO_PATH) unless File.exist?(DO_PATH)\n path = File.join(DO_PATH, '%s.rake' % name)\n sh :curl, '--location', '--progress-bar', repo, '>', path\n load_recipe(path)\n end\n end\n end",
"def packages_upload_helm_with_http_info(owner, repo, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PackagesApi.packages_upload_helm ...\"\n end\n # verify the required parameter 'owner' is set\n if @api_client.config.client_side_validation && owner.nil?\n fail ArgumentError, \"Missing the required parameter 'owner' when calling PackagesApi.packages_upload_helm\"\n end\n # verify the required parameter 'repo' is set\n if @api_client.config.client_side_validation && repo.nil?\n fail ArgumentError, \"Missing the required parameter 'repo' when calling PackagesApi.packages_upload_helm\"\n end\n # resource path\n local_var_path = \"/packages/{owner}/{repo}/upload/helm/\".sub('{' + 'owner' + '}', owner.to_s).sub('{' + 'repo' + '}', repo.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\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(opts[:'data'])\n auth_names = ['apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AlpinePackageUpload')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PackagesApi#packages_upload_helm\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def bootstrap\n write_repo_file('bootstrap.h',<<EOF)\n#!/bin/sh\n\nphp_version=$(php -v | head -1 | awk '{print $2}' | sed 's/\\\\.//g')\ncomposer_version=5320\n\nif [[ $php_version -gt $composer_version ]]; then\n curl -sS https://getcomposer.org/installer | php\n mv composer.phar composer\n chmod 755 composer\n ./composer install\n export PATH=vendor/bin:$PATH\nelse\n curl -O https://phar.phpunit.de/phpunit.phar\n mv phpunit.phar phpunit\n chmod 755 phpunit\nfi\nEOF\n end",
"def install\n yaourt('--noconfirm', '-Sy', @resource[:name])\n end",
"def github(name, *args)\n options ||= if args.last.is_a? Hash\n args.last\n else\n {}\n end\n\n if path = options.delete(:path)\n mod name, :path => path\n else\n version = args.first\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend\nend",
"def configure_command(cmd)\n end",
"def install\n bin.install \"bin/vh-config\"\n end",
"def addon name,version=@@latest_version\n config = get_config(self._version)\n addon_author,addon_name = name.split(\"/\")\n if File.exists?(\"#{config[\"dirname\"]}/addons/#{addon_name}\")\n puts \"update #{name}\"\n `cd #{config[\"dirname\"]}/addons/#{addon_name} && git pull` \n else\n puts \"clone #{name}\"\n `cd #{config[\"dirname\"]}/addons && git clone https://github.com/#{name}.git` \n end\n end",
"def add_specs_to_repo\n UI.puts \"\\nAdding the #{'spec'.pluralize(count)} to the `#{@repo}' repo\\n\".yellow\n podspec_files.each do |spec_file|\n spec = Pod::Specification.from_file(spec_file)\n output_path = @source.pod_path(spec.name) + spec.version.to_s\n message = if @message && !@message.empty?\n @message\n elsif output_path.exist?\n \"[Fix] #{spec}\"\n elsif output_path.dirname.directory?\n \"[Update] #{spec}\"\n else\n \"[Add] #{spec}\"\n end\n\n if output_path.exist? && !@allow_overwrite\n raise Informative, \"#{spec} already exists and overwriting has been disabled.\"\n end\n\n FileUtils.mkdir_p(output_path)\n\n if @use_json\n json_file_name = \"#{spec.name}.podspec.json\"\n json_file = File.join(output_path, json_file_name)\n File.open(json_file, 'w') { |file| file.write(spec.to_pretty_json) }\n else\n FileUtils.cp(spec_file, output_path)\n end\n\n # only commit if modified\n if repo_git('status', '--porcelain').include?(spec.name)\n UI.puts \" - #{message}\"\n repo_git('add', spec.name)\n repo_git('commit', '--no-verify', '-m', message)\n else\n UI.puts \" - [No change] #{spec}\"\n end\n end\n end",
"def install_git\n begin\n run_context.resource_collection.include(package: 'git')\n rescue\n git_package = Chef::Resource::Package.new('git', run_context)\n git_package.name 'git'\n git_package.run_action :install\n end\n end",
"def create_pr\n ErrorEmittingExecutor.execute(\"hub pull-request -f -m '#{COMMIT_DESCRIPTION}'\")\nend",
"def push(cmd); end",
"def writable_create_project(dashboard_name) \n\tscript \"create_dashing_project\" do\n\t\tinterpreter \"bash\"\n\t\tuser \"root\"\n\t\tcwd \"/home\"\n\t\tcode <<-EOH\n\t\tdashing new \"#{dashboard_name}\"\n\t\tchmod 777 \"#{dashboard_name}\"\n\t\tcd \"#{dashboard_name}\"\n\t\tEOH\n\tend\n\tChef::Log.info \"#{dashboard_name} dashboard project created\"\n\nend",
"def create_repo\n # update gitolite-admin/conf/gitolite.conf file ...\n # but only if there is NOT already an entry for this repo \n # ... to avoid duplicating the entry\n conf_entry = File.read(@@gitolite_conf_file_path).slice(@gitolite_conf_entry)\n if (conf_entry == nil)\n File.open(@@gitolite_conf_file_path, \"a\") { |f| f.write @gitolite_conf_entry}\n # push updates to gitolite-admin repo to create new project repo\n git_push @@gitolite_admin_path, \"Added repo #{@project_label} with users: #{@users}\"\n return true\n else\n LOGGER.error \"Existing gitolite config file entry found for project #{@project_label}, skipping repo creation\"\n return false\n end\n \n end",
"def create_git_tag\n assignment_repository.write do |git|\n git.add_tag git_tag\n end\n end",
"def cli_install(executable_path)\n puts \"Creating symlinks at the Smuxi plugin hook locations…\"\n puts\n\n install(executable_path) do |hook_executable_file|\n puts \"Creating `#{hook_executable_file}`\"\n end\n\n puts\n puts \"Plugin `#{name}` installed.\"\n\n exit\n end",
"def create\n\n # Let's get a few things straight\n @work_dir = \"#{@resource[:cache_dir]}/#{@resource[:extension]}\"\n @php_version_prefix = \"#{@resource[:phpenv_root]}/versions/#{@resource[:php_version]}\"\n @resource[:compiled_name] ||= \"#{@resource[:extension]}.so\"\n\n # Update the repository\n fetch @resource[:version], @resource[:extension]\n\n # Prepare for building\n prep_build @resource[:version]\n\n # PHPize, build & install\n phpize\n configure\n make\n install\n end",
"def setup\n @commit_data = {\n :id => \"a-real-deal-id-#{get_iterator}\",\n :commit_message => 'Creating Git Resource',\n :author_name => 'Collin',\n :author_email => 'collin@quickleft.com',\n :attributes => \"{ \\\"title\\\" : \\\"test #{get_iterator}\\\" }\",\n :rendered => \"<h1>Test #{get_iterator}</h1>\"\n }\n @commit_sha = Regulate::Git::Interface.save(@commit_data)\n end"
] | [
"0.6459812",
"0.6439818",
"0.6429886",
"0.62147754",
"0.6172976",
"0.60509694",
"0.6036178",
"0.6035579",
"0.5994835",
"0.5986173",
"0.5948862",
"0.5840109",
"0.58038956",
"0.57848525",
"0.5752091",
"0.5746584",
"0.5734534",
"0.5638456",
"0.5586727",
"0.5563567",
"0.5563039",
"0.5563039",
"0.5563039",
"0.5563039",
"0.5554519",
"0.55329305",
"0.5532465",
"0.5527966",
"0.5492388",
"0.5491794",
"0.5466007",
"0.5445384",
"0.5441314",
"0.5440174",
"0.54390997",
"0.5431361",
"0.5427218",
"0.54269654",
"0.54125035",
"0.5411364",
"0.5409817",
"0.5399717",
"0.539537",
"0.53936887",
"0.5376244",
"0.53702044",
"0.5349511",
"0.5348777",
"0.5348777",
"0.5347146",
"0.5345838",
"0.5339439",
"0.5329342",
"0.53253245",
"0.5314594",
"0.5314594",
"0.5314594",
"0.5314594",
"0.5314594",
"0.5314594",
"0.5314594",
"0.5314594",
"0.5314594",
"0.5314594",
"0.53075385",
"0.5303483",
"0.5300531",
"0.5299009",
"0.52945495",
"0.52945495",
"0.52945495",
"0.52945495",
"0.52931154",
"0.529212",
"0.5287263",
"0.52847457",
"0.52786875",
"0.5276593",
"0.52730674",
"0.5268726",
"0.52607006",
"0.52593046",
"0.52589595",
"0.5256626",
"0.52565336",
"0.52511287",
"0.52493006",
"0.52315813",
"0.5218418",
"0.5217844",
"0.5216707",
"0.52144635",
"0.52056485",
"0.5201463",
"0.51984537",
"0.5195417",
"0.5189048",
"0.5179604",
"0.5174238",
"0.51651937"
] | 0.76771754 | 0 |
more tests more more mroe | def create
upload = Upload.find(params[:upload_id])
comment_params = Hash.new
comment_params[:upload_id] = params[:upload_id]
comment_params[:description] = params[:description]
comment_params[:user_id] = params[:user_id]
#comment params need to change to whatever we pass in the text box
comment = upload.comments.create(comment_params)
comment_params[:user_name] = User.find(params[:user_id]).email
if comment.save
# redirect_to main_path
respond_to do |format|
format.json { render json: comment_params}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tests; end",
"def tests; end",
"def testing\n # ...\n end",
"def test_cases; end",
"def test \n end",
"def test\n\n end",
"def test_case; end",
"def my_tests\n end",
"def generate_alltest\n\n end",
"def test_method\n end",
"def test\n end",
"def test\n end",
"def test\n end",
"def test_setup\r\n \r\n end",
"def default_test\r\n end",
"def test_0_dummy\n\t\tend",
"def running_test_case; end",
"def stest_method_1(test); end",
"def graffiti_test\n end",
"def tests=(_arg0); end",
"def tests=(_arg0); end",
"def self_test; end",
"def self_test; end",
"def spec; end",
"def spec; end",
"def test_steps; end",
"def test_steps; end",
"def test_001\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n # #Find a PU\n #Pu created\n pu_name = 'pu'\n register_pu(pu_name)\n @@pu = Pu.find(:last)\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n pj_name = 'pj'\n register_pj(pj_name)\n @@pj = Pj.find(:last)\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n #Click Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n @@pu.destroy\n # logout\n logout\n\n end",
"def test_suma\n \t\tassert_equal(@mr,(@mq+@mp)) #dispersas\n \t\tassert_equal(@c,(@a+@b)) #fraccionales\n\t\tassert_equal(@md,(@ma+@mz)) #densa\n \tend",
"def testloop\n \n end",
"def test_truth\n end",
"def test_005\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n # #Find a PU\n #Pu created\n pu_name = 'pu'\n register_pu(pu_name)\n @@pu = Pu.find(:last)\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n pj_name = 'pj'\n register_pj(pj_name)\n @@pj = Pj.find(:last)\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # Below \"selection of the upload method of an individual analysis file\" is displayed.\n assert is_text_present(_(\"Select a master\"))\n assert is_text_present(_(\"Master\"))\n assert is_text_present(_(\"Select the upload method of individual analysis files\"))\n assert is_text_present(_(\"Upload of individual analysis files\"))\n\n @@pu.destroy\n # logout\n logout\n\n end",
"def test_008\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n @@pj = Pj.find_by_name('SamplePJ1')#\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n # test for value of master into combobox in master tab\n assert_equal [\"sample_c_cpp\"], get_select_options(\"master_id\")\n assert is_text_present(_(\"Optional setting\"))\n\n click $xpath[\"task\"][\"registration_task_button\"]\n sleep 2\n #assert !60.times{ break if (is_text_present(\"解析ツール未選択 入力内容に問題があるためタスクを登録できません。\") rescue false); sleep 2 }\n\n\n # logout\n logout\n\n end",
"def test_step; end",
"def test_truth\n april = riders(:rider_1)\n assert_equal \"April Jones\", april.name\n trigger = horses(:horse_1)\n assert_equal \"Trigger\", trigger.name\n event2 = events(:event_2)\n assert_equal \"5 Horse Scramble\", event2.name\n \n end",
"def test_004\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n # #Find a PU\n #Pu created\n pu_name = 'pu'\n register_pu(pu_name)\n @@pu = Pu.find(:last)\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n pj_name = 'pj'\n register_pj(pj_name)\n @@pj = Pj.find(:last)\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 全体解析 (Analysis of all)\n select \"analyze_type\", \"label=#{@overall}\"\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n #There is no display below \"selection of the upload method of an individual analysis file.\"\n assert !is_text_present(_(\"Select the upload method of individual analysis files\"))\n\n @@pu.destroy\n # logout\n logout\n\n end",
"def default_test\n end",
"def generate_alltestc\n\n end",
"def before_test(test); end",
"def before_test(test); end",
"def test_resta\n \t\tassert_equal(@ma, (@md-@mz)) #densa\n \t\tassert_equal(@a, (@c-@b)) #fraccionales\n\t\tassert_equal(@mp, (@mr-@mq)) #dispersa\n \tend",
"def tests\n parser.flow_items\n end",
"def test_order; end",
"def test_037\n\n login\n\n #Create some PUs\n\n for i in 0..2\n create_pu('sample_pu'+i.to_s)\n end\n\n pus = Pu.find_all_by_name('sample_pu1')\n pu = pus.last\n pu.created_at =\"2009-05-08 11:30:50\"\n pu.save\n pus = Pu.find_all_by_name('sample_pu2')\n pu = pus.last\n pu.created_at =\"2008-05-08 14:30:50\"\n pu.save\n @@year = \"2009\"\n @@hour = \"14\"\n\n # Open PU management page\n open_pu_management_page_1\n\n # Arbitrary filtering is performed to PU name.\n assert_equal _(\"PU name\"), get_selected_label(\"find_box\")\n\n\n # you have no relevance\n filtering('3')\n assert !is_text_present('sample_pu1')\n assert !is_text_present('sample_pu2')\n assert is_text_present(_('A PU does not exist.'))\n sleep 2\n\n # Delete created data\n @@pu= Pu.find_by_name('sample_pu1')\n @@pu2= Pu.find_by_name('sample_pu2')\n @@pu.destroy\n @@pu2.destroy\n logout\n end",
"def __dummy_test__\n end",
"def love_test\nend",
"def default_test; end",
"def run_fe_tests\n end",
"def default_test\n end",
"def default_test\n end",
"def compare_tests(test_a, test_b); end",
"def compare_tests(test_a, test_b); end",
"def test_espresso_more_effective\n hipster = Human.new \"Hipster\"\n espresso = Espresso.new \"Espresso\"\n\n hipster.buy espresso\n assert espresso.drinks_before_empty == 1\n\n hipster.drink!\n assert (hipster.alertness > 0.4)\n\n end",
"def default_test\n end",
"def test_006\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n #A task type is changed into \"individual analysis\"\n # with a \"general control\" tab.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析 (Individual Analysis)\n select \"analyze_type\", \"label=#{@individual}\"\n #Click Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n assert is_text_present(\"qac\")\n #An option setup of \"master: A qac\" subwindow is displayed.\n click $xpath[\"task\"][\"option_setup_link\"]\n # click \"link=設定する\"\n sleep 3\n # #wait for loading page\n wait_for_condition(\"Ajax.Request\",\"30000\")\n\n assert !60.times{ break if (@selenium.is_text_present(_(\"Optional setting\")+\":qac\") rescue false); sleep 2 }\n sleep 2\n\n # logout\n logout\n\n end",
"def test_002\n\n # login\n login\n @@pu = 1\n @@pj = 1\n open\"/devgroup/pj_index/#{@@pu}/#{@@pj}\"\n wait_for_page_to_load \"30000\"\n\n # test for individual analysis task\n open(\"/task/index2/#{@@pu}/#{@@pj}\")\n #The contents of a display of a \"master\" tab become\n # a thing for individual analysis task registration.\n click $xpath[\"task\"][\"main_area_td4\"]\n wait_for_page_to_load \"30000\"\n assert is_text_present(_(\"Registration of an Analysis Task\"))\n # select analyze type: 個人解析\n select \"analyze_type\", \"label=#{@individual}\"\n #Click Master tab\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n #Select \"uploading a file individually\"\n click \"file_upload_upload_way_upload_each\"\n assert is_text_present(_(\"Uploaded individually.\"))\n click $xpath[\"task\"][\"read_tree\"]\n\n assert !60.times{ break if (is_text_present(_(\"Directory structure\")) rescue false); sleep 2 }\n # logout\n logout\n\n end",
"def test_next_song\n \n \n assert true\n end",
"def test_total_turns_1\n \tpro = Prospector.new(1)\n \tpro.prospect_move(1)\n \tassert pro.total_rubies == 0\n \tassert pro.total_fake_rubies == 0\n end",
"def test_007\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n @@pu = Pu.find_by_name('SamplePU1')\n\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n @@pj = Pj.find_by_name('SamplePJ1')\n\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n # test for value of master into combobox in master tab\n assert_equal [\"sample_c_cpp\"], get_select_options(\"master_id\")\n assert is_text_present(_(\"Optional setting\"))\n # click link setup QAC\n assert is_text_present(\"qac\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link\"]\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n # click link setup QAC++\n assert is_text_present(\"qacpp\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link2\"]\n sleep 2\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n\n\n # logout\n logout\n\n end",
"def test_nothing\n end",
"def test_m_greater_1\n assert_not_nil \"troubles\" =~ PorterStemmer::Porter1::MGR1\n assert_not_nil \"private\" =~ PorterStemmer::Porter1::MGR1\n assert_not_nil \"oaten\" =~ PorterStemmer::Porter1::MGR1\n assert_not_nil \"orrery\" =~ PorterStemmer::Porter1::MGR1\n assert_not_nil \"crepuscular\" =~ PorterStemmer::Porter1::MGR1\n end",
"def test_010\n\n # login\n login\n\n # Open PU management page\n open_pu_management_page_1\n\n #Find a PU\n #Pu created\n\n\n @@pu = Pu.find_by_name('SamplePU1')\n open \"/devgroup/pu_index/#{@@pu.id}\"\n wait_for_page_to_load \"30000\"\n\n sleep 2\n\n #Find a PJ of PU\n open_pj_management_page(@@pu.id)\n\n @@pj = Pj.find_by_name('SamplePJ1')\n open\"/devgroup/pj_index/#{@@pu.id}/#{@@pj.id}\"\n wait_for_page_to_load \"30000\"\n\n #Open \"Registration of analysis task\" page\n open(\"/task/index2/#{@@pu.id}/#{@@pj.id}\")\n # test master of PJ is not registered\n assert is_text_present(_(\"Details of an analysis task\"))\n click $xpath[\"task\"][\"main_area_td4\"]\n assert !60.times{ break if (is_text_present(_(\"Registration of an Analysis Task\")) rescue false); sleep 2 }\n\n click $xpath[\"task\"][\"general_control_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Basic Setting\")) rescue false); sleep 2 }\n sleep 3\n select \"analyze_type\", \"label=#{@individual}\"\n sleep 3\n click $xpath[\"task\"][\"master_tab\"]\n assert !60.times{ break if (is_text_present(_(\"Select a master\")) rescue false); sleep 2 }\n\n # click link setup QAC\n assert is_text_present(\"qac\")\n sleep 3\n click $xpath[\"task\"][\"option_setup_link\"]\n # check log in the navigation bar\n assert !60.times{ break if (is_text_present(_(\"It returns to the state before a save.\")) rescue false); sleep 2 }\n run_script \"destroy_subwindow()\"\n\n\n # logout\n logout\n\n end",
"def test_intialize\r\n\tassert_equal 0, @test_prospector.current_gold\r\n\tassert_equal 0, @test_prospector.current_silver\r\n\tassert_equal 0, @test_prospector.total_gold\r\n\tassert_equal 0, @test_prospector.total_silver\r\n\tassert_equal 0, @test_prospector.move_count\r\n\tassert_nil @test_prospector.previous_location\r\n\tassert_equal 0, @test_prospector.num_days\r\n\tassert_equal 'Sutter Creek', @test_prospector.current_location\r\n end",
"def after_test(_test); end",
"def after_test(_test); end",
"def after_test(_test); end",
"def testing_end\n end",
"def test_028\n\n # login\n login\n # Open PU management page\n open_pu_management_page\n # Get total rows in PU table\n total_rows = get_xpath_count($xpath[\"pu\"][\"pu_list_row\"])\n # delete pu\n row_xpath = $xpath[\"pu\"][\"pu_list_row\"] + \"[#{total_rows}]\"\n result_link_xpath = row_xpath + \"/td[5]/a[2]\"\n result_name_xpath = row_xpath + \"/td[2]\"\n # clicks on link to delete PU\n click(result_link_xpath)\n # The dialog which checks deletion comes out.\n pj_name = get_text(result_name_xpath)\n strmsg1 = _(\"All information of \")\n strmsg2 = _(\" will be deleted.\\n<PJ,master, analysis task, analysis result, analysis log>\\n\")\n strmsg3 = _(\"Really\")\n strmsg4 = _(\"Are you sure you want to delete\")\n strmsg = ''\n if $lang == 'ja'\n strmsg = \"#{pj_name}\" +strmsg1 + strmsg2 + strmsg3 + \"#{pj_name}\" + strmsg4 +\"?\"\n else\n strmsg = strmsg1 + \"#{pj_name}\" + strmsg2 + strmsg4 + \" #{pj_name}\" +\"?\"\n end\n assert_equal(strmsg , get_confirmation)\n # logout\n logout\n make_original_pus\n end",
"def ptest_method_1(test); end",
"def test_035\n\n login\n\n # Create some PUs\n\n for i in 0..2\n create_pu('sample_pu'+i.to_s)\n end\n\n pus = Pu.find_all_by_name('sample_pu1')\n pu = pus.last\n pu.created_at =\"2009-05-08 11:30:50\"\n pu.save\n pus = Pu.find_all_by_name('sample_pu2')\n pu = pus.last\n pu.created_at =\"2008-05-08 14:30:50\"\n pu.save\n @@year = \"2009\"\n @@hour = \"14\"\n\n # Open PU management page\n open_pu_management_page_1\n\n # Selection for filtering\n assert_equal [_(\"PU name\"), _(\"Registration date\")], get_select_options(\"find_box\")\n\n # Delete created data\n @@pu= Pu.find_by_name('sample_pu1')\n @@pu2= Pu.find_by_name('sample_pu2')\n @@pu.destroy\n @@pu2.destroy\n logout\n\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 self_test(switches)\n #Visual test to see if we loaded data correctly.\n switches.each do |s|\n pp s\n end\nend",
"def run_app_tests\n end",
"def test_fake_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.fake_rubies_found(7)\n\t\ttest_main.fake_rubies_found(7)\n\t\tassert test_main.num_fake_rubies, 14\n\tend",
"def test_a\n end",
"def test_index\n get :index\n assert_response :success\n\n assert assigns(:best_songs)\n assert_equal 3, assigns(:best_songs).size\n \n assert assigns(:most_used_tracks)\n assert_equal 3, assigns(:most_used_tracks).size\n\n assert assigns(:newest)\n assert_equal 5, assigns(:newest).size\n \n assert assigns(:genre_chars)\n assert assigns(:genres)\n assert assigns(:genres).all? { |g| g.name.first.upcase == assigns(:genre_chars).first }\n assert assigns(:genres).all? { |g| g.published_songs.count > 0 }\n end",
"def test_contains_13_eachsuit\n assert true == false\n end",
"def message_for(test); end",
"def message_for(test); end",
"def test_otro_programa\r\n aspirantesOtro = 6\r\n tot = ReservarOtroPrograma(1)\r\n assert_equal(tot, aspirantesOtro)\r\n end",
"def test_results_victory\r\n assert_output(\"Going home victorious!\\n\") { @g.results(10) }\r\n end",
"def test_contains_four_eachface\n assert true == false\n end",
"def running_test_step; end"
] | [
"0.7541602",
"0.7541602",
"0.7440775",
"0.72041845",
"0.68698335",
"0.6840051",
"0.67955905",
"0.6787085",
"0.6777833",
"0.6738014",
"0.6735499",
"0.6735499",
"0.6735499",
"0.66692215",
"0.6647514",
"0.6634424",
"0.66192096",
"0.6598048",
"0.65607285",
"0.6555865",
"0.6555865",
"0.6520406",
"0.6520406",
"0.6520216",
"0.6520216",
"0.64963716",
"0.64963716",
"0.6483385",
"0.6462881",
"0.6452084",
"0.6447397",
"0.6444241",
"0.64312184",
"0.64221746",
"0.6411497",
"0.6363936",
"0.63538355",
"0.63502246",
"0.6348264",
"0.6348264",
"0.6336489",
"0.6335077",
"0.6317457",
"0.6303563",
"0.6302128",
"0.6296254",
"0.6283375",
"0.6263582",
"0.62542045",
"0.62542045",
"0.6220427",
"0.6220427",
"0.62198544",
"0.6196165",
"0.61872476",
"0.61794406",
"0.6162911",
"0.61553955",
"0.6152458",
"0.61518514",
"0.61501175",
"0.6147332",
"0.6146172",
"0.6125072",
"0.6125072",
"0.6125072",
"0.61098963",
"0.6106314",
"0.6104278",
"0.6099399",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.6084927",
"0.60835224",
"0.6081503",
"0.60789335",
"0.6076871",
"0.6076731",
"0.60727996",
"0.6069092",
"0.6069092",
"0.60567546",
"0.60532844",
"0.6051502",
"0.60484505"
] | 0.0 | -1 |
Register the global meter provider. | def meter_provider=(provider)
@mutex.synchronize do
if @meter_provider.instance_of? Internal::ProxyMeterProvider
logger.debug("Upgrading default proxy meter provider to #{provider.class}")
@meter_provider.delegate = provider
end
@meter_provider = provider
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_meter( name )\n @metrics.meter( name )\n end",
"def register_gauge(type, &block)\n register_metric( Drone::Metrics::Gauge.new(type, &block) )\n end",
"def initialize(...)\n @metrics = {}\n register(...)\n end",
"def register_metric(metric)\n @metrics << metric\n metric\n end",
"def register!\n # Register the plugin.\n @manager.register_plugin! self\n end",
"def register\n @typeperf = TypeperfWrapper.new(PerfmonProcGetter.new, @interval)\n @counters.each { |counter| @typeperf.add_counter(counter) }\n end",
"def register_gauge( name, gauge = nil, &block )\n if gauge and not block_given? and gauge.respond_to? :call\n @metrics.register( name, Gauge.new( gauge ) ) \n elsif gauge.nil? and block_given?\n @metrics.register( name, Gauge.new( block ) )\n else\n raise 'needs either a block and object with call method'\n end\n end",
"def register_metrics!\n return if @registered\n @registered = true\n with_instance do |t|\n # Worker related\n t.add_gauge :dynflow_active_workers, 'The number of currently busy workers',\n [:queue, :world]\n t.add_counter :dynflow_worker_events, 'The number of processed events',\n [:queue, :world, :worker]\n\n # Execution plan related\n t.add_gauge :dynflow_active_execution_plans, 'The number of active execution plans',\n [:action, :world, :state]\n t.add_gauge :dynflow_queue_size, 'Number of items in queue',\n [:queue, :world]\n t.add_counter :dynflow_finished_execution_plans, 'The number of execution plans',\n [:action, :world, :result]\n\n # Step related\n # TODO: Configure buckets in a sane manner\n t.add_histogram :dynflow_step_real_time, 'The time between the start end end of the step',\n [:action, :phase]\n t.add_histogram :dynflow_step_execution_time, 'The time spent executing a step',\n [:action, :phase]\n\n # Connector related\n t.add_counter :dynflow_connector_envelopes, 'The number of envelopes handled by a connector',\n [:world, :direction]\n\n # Persistence related\n t.add_histogram :dynflow_persistence, 'The time spent communicating with the database',\n [:world, :method]\n end\n end",
"def define_gauge(name, opts = {}, &block)\n define_metric(:gauge, name, opts, &block)\n end",
"def registered(mon)\n @monitor = mon\n @config = EzNemo.config[:monitor][:ping] if EzNemo.config[:monitor]\n @config ||= {}\n @config[:path] ||= 'ping'\n @config[:min_interval] ||= DEFAULT_MIN_INTERVAL\n @config[:timeout] ||= DEFAULT_TIMEOUT\n EzNemo.logger.info 'Ping plugin registered.'\n end",
"def register_counter(type)\n register_metric( Drone::Metrics::Counter.new(type) )\n end",
"def set_meter\n @meter = Meter.find(params[:id])\n end",
"def set_meter\n @meter = Meter.find(params[:id])\n end",
"def register_timer(name)\n register_metric( Drone::Metrics::Timer.new(name) )\n end",
"def register(name, &plugin_block)\n define_method(name) do |*args, **kwargs, &block|\n t1 = Time.now\n\n data = plugin_block.call(*args, **kwargs, &block)\n\n # If the plugin is just setting the store key\n return nil if data.nil? || !data.key?(:ok)\n\n data[:name] = name\n data[:duration_seconds] = Time.now - t1\n\n Utils.task_and_line(data)\n Utils.node_or_container_label(data)\n data[:task_number] = Store.inc(:count)\n Utils.response(data)\n end\n end",
"def register_counter( name )\n @metrics.counter( name )\n end",
"def registry\n UnicornMetrics::Registry\n end",
"def meters \n metrics(Meter)\n end",
"def setup_metrics\n end",
"def setup_metrics\n end",
"def setup_metrics\n end",
"def defMeasurement(name,&block)\n mp = {:mp => name, :fields => []}\n @fields = []\n # call the block with ourserlves to process its 'defMetric' statements\n block.call(self) if block\n @fields.each { |f| mp[:fields] << f }\n define_measurement_point(mp)\n end",
"def register(*metrics)\n begin\n metrics.each do |metric|\n @registry.register(metric)\n end\n rescue Prometheus::Client::Registry::AlreadyRegisteredError\n end\n end",
"def register\n end",
"def register_provider(name, klass)\n @providers[name] = klass\n end",
"def register_provider( name, provider )\n @providers ||= Hash.new\n name = name.to_s\n\n unless provider.respond_to?(:logger)\n raise Polylog::InvalidProvider, \"`logger` method not found for provider #{name.inspect}\"\n end\n\n arity = provider.method(:logger).arity\n unless 1 == arity\n raise Polylog::InvalidProvider, \"`logger` method arity must be 1; arity is #{arity} for provider #{name.inspect}\"\n end\n\n @providers[name] = provider\n end",
"def register\n end",
"def register\n end",
"def register\n end",
"def register name = \"temp\"\n Registers::Temp.new name, \"r64\"\n end",
"def reg(&block)\n r = Registrar.new\n Signal.add_trap(0) { r.safe_release! }\n r.logger = opt.logger if opt.logger\n r.config.instance_eval(&block)\n registrars[r.config.device] = r\n end",
"def register(name, &blk)\n name = name.to_sym\n\n @__storage__[name] = blk\n end",
"def register(setting, params)\n @registers[setting] << params\n end",
"def set_measurement(name, value, unit = \"\")\n @measurements[name] = { value: value, unit: unit }\n end",
"def create\n @meter = Meter.new(meter_params)\n\n respond_to do |format|\n if @meter.save\n format.html { redirect_to admin_meter_path(@meter), notice: 'Meter was successfully created.' }\n format.json { render :show, status: :created, location: admin_meter_path(@meter) }\n else\n format.html { render :new }\n format.json { render json: @meter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def register(&block)\n extend Module.new(&block)\n end",
"def register\r\n \r\n end",
"def set_energy_meter\n @energy_meter = EnergyMeter.find(params[:id])\n end",
"def register(*args)\n registry.register(*args)\n end",
"def register(type_name, klass = nil, **options, &block)\n registry.register(type_name, klass, **options, &block)\n end",
"def metrics\n manager_instance(MetricManager)\n end",
"def register_plugin_for(plugin_name,value,callback_type,default=nil,callback_fct=nil,&block)\n current_loader_instance.register_plugin_for(plugin_name,value,callback_type,default,callback_fct,&block)\n end",
"def register_memory\n @register_memory ||= Memory.new(256, \"Register Memory\")\n end",
"def register_node\n @registered = @registry.register_node(system)\n end",
"def register_timer( name )\n Timer.new( @metrics.timer( name ) )\n end",
"def inherited(base)\n Rally.register_provider(base)\n end",
"def register(name, type)\n registry[name] = type\n end",
"def register\n @is_registered = true\n self\n end",
"def system_register_worker # :nodoc\n self.class.with_global_lock do\n workers = self.class.system_registered_workers.push(self.id)\n self.class.store_global_property(WORKERS_KEY, workers.join(','))\n end\n end",
"def registered\n\t\t\tself\n\t\tend",
"def meter_params\n params.fetch(:meter, {})\n end",
"def set_register\n # set config registers\n config_reg = 0xF5 # Register address for config settings\n t_sb = 0b000 # Standby time = 0.5ms (0b000)\n filter = 0b100 # filter coefficient = 16\n spi3w_en = 0 # Disable SPI\n config_val = (t_sb << 5) | (filter << 2) | spi3w_en\n write(config_reg, config_val)\n\n # set ctrl_meas registers\n tp_reg = 0xF4 # Register address for temperature/pressure settings\n osrs_t = 0b010 # Temperature oversampling = x2 (0b010)\n osrs_p = 0b101 # Pressure oversampling = x16 (0b101)\n mode = 0b11 # Normal mode (0b11)\n tp_val = (osrs_t << 5) | (osrs_p << 2) | mode\n write(tp_reg, tp_val)\n\n # set ctrl_hum registers \n hum_reg = 0xF2 # Register address for humidity settings \n osrs_h = 0b001 # Humidity oversampling = x1 (0b001)\n hum_val = osrs_h\n write(hum_reg, hum_val)\n end",
"def register\n \n end",
"def register_default\n register( configured_default ) if configured_default\n end",
"def register\n\n\tend",
"def register(klass)\n Globot.logger.debug \"Registered plugin: #{klass}\"\n @plugins << klass\n end",
"def register(plugin, id); end",
"def add_measure(measure_id, importer)\n @measure_importers[measure_id] = importer\n end",
"def set_data_gatherer\n @data_gatherer = AdminOnly::DataGatherer.new\n end",
"def add_measure(measure_id, importer)\n @measure_importers[measure_id] = importer\n end",
"def register_method(method, &block)\n self.class.register_method(method, &block)\n end",
"def register\n ModelAdapter.adapters ||= []\n ModelAdapter.adapters << Kernel.const_get(self.to_s)\n end",
"def push_metrics!\n metrics = Prometheus::Client.registry\n url = Rails.application.secrets.prometheus_push_gateway_url\n\n Prometheus::Client::Push.new(\"push-gateway\", nil, url).add(metrics)\n end",
"def default_reg_metadata\n Origen::Registers.reg_metadata[:global] ||= {}\n if block_given?\n collector = Origen::Utility::Collector.new\n yield collector\n Origen::Registers.reg_metadata[:global].merge!(collector.to_h)\n end\n Origen::Registers.reg_metadata[:global]\n end",
"def registry\n\t\tbrand(Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Registry)\n\tend",
"def register(type, cls); end",
"def register\n plugin_set.register(self) do |p|\n yield p if block_given?\n end\n end",
"def custom_metrics\n @custom_metrics ||= {}\n end",
"def use_provider( name )\n name = name.to_s\n raise Polylog::UnknownProvider, \"unknown provider: #{name.inspect}\" unless @providers.key? name\n\n @provider = @providers[name]\n end",
"def set_gauge(gauge_name, value, tags = {})\n @drivers.each { |d| d.set_gauge(gauge_name.to_s, value, tags) }\n nil\n end",
"def meter_params\n params.require(:meter).permit(:customer_id, :meter_number, :latitude, :longitude, :posting_group,\n :status, :serial_number, :quantity, :zone_id, :route_id)\n end",
"def add(location)\n $LOAD_MANAGER.add(location)\n end",
"def metric(name,type,value)\n @metrics[name] = {\n :type => type,\n :value => value\n }\nend",
"def register(*tracker)\n @trackers += tracker\n end",
"def register_global_listeners\n Wisper.clear\n Wisper.subscribe(AdminNotifier.new)\n Wisper.subscribe(SlackNotifications.new)\n Wisper.subscribe(UserEmails.new)\n end",
"def with_register name = \"temp\"\n reg = register(name)\n yield reg\n release_register reg\n end",
"def fetch_gauge(name, opts = {}, &block)\n fetch_metric(:gauge, name, opts, &block)\n end",
"def register_for id\n @plugin_id = id\n plugin_host.register self, id\n end",
"def register(object); end",
"def set_parking_meter\n @parking_meter = ParkingMeter.find(params[:id])\n end",
"def register\n puts \"register\"\n ApiBase.client.put(\"/device/#{self.id}\", self.to_json)\n end",
"def register(*plugins)\n @@plugins += plugins\n end",
"def stub_gauge(registry, instance = spy('Prometheus::Client::Gauge'))\n allow(registry).to receive(:gauge).and_return(instance)\n\n instance\n end",
"def power_supply_metrics\n super\n end",
"def load_used_providers\n Vmpooler::Providers.load_by_name(used_providers)\n end",
"def register(name, klass)\n @registry[name] = klass\n end",
"def gauge(stat, value, sample_rate=1)\n send_stats stat, value, :g, sample_rate\n end",
"def meter_params\n params.require(:meter).permit(:mid, :bluetooth_mac, :display_name, :model)\n end",
"def my_provider\n self.class.my_provider\n end",
"def register(mutex)\n locks.add(mutex)\n end",
"def initialize(reg_param: 1.0)\n super()\n @params = {\n reg_param: reg_param\n }\n end",
"def method_missing(method, *args, &block)\n @registry << [method, args, block]\n self\n end",
"def method_missing(method, *args, &block)\n @registry << [method, args, block]\n self\n end",
"def register(context)\n @context = context\n end",
"def set_meter_record\r\n @meter_record = MeterRecord.find(params[:id])\r\n end",
"def gauge(stat, value)\n send stat, value, 'g'\n end",
"def device(name, params = {})\n Celluloid::Logger.info \"Registering device '#{name}'...\"\n self.device_types ||= []\n self.device_types << {:name => name}.merge(params)\n end",
"def register_service( name, &block )\n EXTERNAL_SERVICES[ name ] = block\n end",
"def register\n self.class.definitions[name] = self\n self\n end",
"def register_plugin(name, &block)\n plugin = Plugin.new\n plugin.instance_eval(&block)\n @plugins[name] = plugin\n end"
] | [
"0.70266426",
"0.6072285",
"0.59438455",
"0.57787174",
"0.5660892",
"0.56036025",
"0.55297095",
"0.5477177",
"0.539635",
"0.5387235",
"0.53433156",
"0.5310754",
"0.5310754",
"0.5224658",
"0.5131831",
"0.51292706",
"0.5122979",
"0.51195997",
"0.50732994",
"0.50732994",
"0.50732994",
"0.5052443",
"0.50438523",
"0.5021936",
"0.50141406",
"0.49877396",
"0.49448255",
"0.49448255",
"0.49448255",
"0.49322334",
"0.49187437",
"0.4895669",
"0.48778802",
"0.48696098",
"0.48690844",
"0.48665795",
"0.4842883",
"0.48346525",
"0.48285797",
"0.4814938",
"0.4808758",
"0.4800681",
"0.47924003",
"0.47836414",
"0.47793418",
"0.47529906",
"0.47485667",
"0.47352037",
"0.4725477",
"0.47227278",
"0.47216687",
"0.47002426",
"0.46903676",
"0.46815565",
"0.46791482",
"0.46556193",
"0.465123",
"0.46512014",
"0.46357593",
"0.4628491",
"0.4623668",
"0.4622549",
"0.45995954",
"0.45905426",
"0.4588779",
"0.45841604",
"0.45824856",
"0.45798868",
"0.4570876",
"0.45703608",
"0.4562278",
"0.45463008",
"0.45392248",
"0.45382443",
"0.45378548",
"0.4535573",
"0.45349762",
"0.45333394",
"0.4525219",
"0.45224944",
"0.45206517",
"0.4516524",
"0.4515831",
"0.4506111",
"0.4502545",
"0.4498165",
"0.44968766",
"0.4485686",
"0.4474872",
"0.4473145",
"0.4472043",
"0.44697413",
"0.44697413",
"0.4467301",
"0.44651192",
"0.44648495",
"0.44492173",
"0.44468558",
"0.44383737",
"0.44370282"
] | 0.6006363 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_property_image
@property_image = PropertyImage.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def property_image_params
params.require(:property_image).permit(:image_url, :property_id)
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 |
note An instance of `Gitlab::GithubImport::Representation::Note`. project An instance of `Project`. client An instance of `Gitlab::GithubImport::Client`. | def initialize(note, project, client)
@note = note
@project = project
@client = client
@user_finder = GithubImport::UserFinder.new(project, client)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_project_note\n @project_note = ProjectNote.find(params[:id])\n end",
"def note(note)\n\t\t@note = note\n\tend",
"def create\n @project_note = ProjectNote.new(project_note_params(params[:project_note]))\n\n if @project_note.save\n render json: @project_note, status: :created, location: @project_note\n else\n render json: @project_note.errors, status: :unprocessable_entity\n end\n end",
"def create\n @project_note = ProjectNote.new(project_note_params)\n\n respond_to do |format|\n if @project_note.save\n format.html { redirect_to @project_note, notice: 'Project note was successfully created.' }\n format.json { render :show, status: :created, location: @project_note }\n else\n format.html { render :new }\n format.json { render json: @project_note.errors, status: :unprocessable_entity }\n end\n end\n end",
"def note_create_params\n params.require(:note).permit(:project_id, :id, :title, :type, :description, :show)\n end",
"def note(notebook)\n @note = Note.new(notebook, @@auth_store) if @note.nil?\n @note\n end",
"def set_note\n begin\n @note = Note.find(params[:id])\n @project = Project.find(@note.project_id)\n if (@project.user_id!=current_user.id)\n render json: {error: \"\"}, status: :unauthorized and return\n end\n rescue Mongoid::Errors::DocumentNotFound\n render json: {error: \"note not found with id \"+params[:id]}, status: :not_found and return\n rescue Exception => e\n render json: {error: e.message}, status: :unprocessable_entity and return\n end\n end",
"def note\n DBC.require( bu?, \"Vin non bu: La note n'est pas definie\" )\n\n @note\n end",
"def project_note_params\n params.require(:project_note).permit(:project_id, :project_notes, :project_note_date, :project_note_owner)\n end",
"def note note, preview=nil\n preview ||= note[0..64]\n params = {\n contact_ids: [ self.id ],\n note: note,\n note_preview: preview\n }\n @nimble.post \"contacts/notes\", params\n end",
"def import(client, project)\n waiter = Importer::NotesImporter\n .new(project, client)\n .execute\n\n AdvanceStageWorker.perform_async(\n project.id,\n { waiter.key => waiter.jobs_remaining },\n :lfs_objects\n )\n end",
"def initialize(issue, project, client)\n @issue = issue\n @project = project\n @client = client\n end",
"def add_note_with_http_info(id, api_note, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProjectsApi#add_note ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling add_note\" if id.nil?\n \n # verify the required parameter 'api_note' is set\n fail \"Missing the required parameter 'api_note' when calling add_note\" if api_note.nil?\n \n # resource path\n path = \"/Projects/{id}/Notes\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'text/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\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(api_note)\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'APINote')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#add_note\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def note_params\n params.require(:note).permit(:text, :note_object_id, :note_object_type, :note_object_attribute, :created_by_id, :updated_by_id, :project_id)\n end",
"def update_client_id_for_note\n self.client_id = Client.current_client_id\n end",
"def initialize(project, client: GitlabClient)\n @project = project\n @client = client\n end",
"def create_notes\n end",
"def initialize(project, client)\n @project = project\n @client = client\n end",
"def noteable\n if for_commit?\n project.commit(noteable_id)\n else\n super\n end\n # Temp fix to prevent app crash\n # if note commit id doesnt exist\n rescue\n nil\n end",
"def create\n @note = current_user.notes.new(params[:note])\n @note.note = view_context.markdown(@note.note).gsub(\"\\n\",\"\").gsub(\"\\r\",\"\")\n @note.save\n $statsd.increment 'animal.note.created'\n respond_with(@note)\n end",
"def create_note(issue)\n Note.create_status_change_note(issue, issue.project, current_user, issue.state, current_commit)\n end",
"def show\n @project_note = ProjectNote.find(params[:id])\n\n render json: @project_note\n end",
"def add(args)\n return @client.api_helper.add(args, \"note_add\")\n end",
"def new\n @note = Note.new\n @options.merge!({url: [@project, @item, :notes]})\n\n respond_to do |format|\n format.html { render action: 'new', layout: @options[:layout] }\n format.json { render json: @note }\n end\n end",
"def update\n @project_note = ProjectNote.find(params[:id])\n\n if @project_note.update(project_note_params(params[:project_note]))\n head :no_content\n else\n render json: @project_note.errors, status: :unprocessable_entity\n end\n end",
"def new\n @client = Client.new\n 1.times { @client.projects.build }\n 1.times { @client.notes.build }\n respond_with(@client)\n end",
"def update\n respond_to do |format|\n if @project_note.update(project_note_params)\n format.html { redirect_to @project_note, notice: 'Project note was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_note }\n else\n format.html { render :edit }\n format.json { render json: @project_note.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize_note(user_id,note)\n \tself.notes.new(user_id: user_id, description: note)\n end",
"def delete(note)\n args = {id: note.id}\n return @client.api_helper.command(args, \"note_delete\")\n end",
"def show_notes\n info \"showing notes\"\n res = run(\"git notes --ref #{refname} show\")\n if res[:val] == 0\n info \"existing note: #{res[:out].strip}\"\n else\n info \"no existing note\"\n end\n end",
"def set_api_note\n @api_note = Note.find(params[:id])\n end",
"def set_notebook_note\n @notebook_note = Notebook::Note.find(params[:id])\n end",
"def buildnote\n @buildnote ||= BuildNote.new\n end",
"def new_note(content)\n note = Note.new({:type_id => self.id,\n :owner => 'bill',\n :content => content})\n note.save\n end",
"def create\n respond_with :api, :v1, Note.create(note_params)\n end",
"def set_note\n @note = Note.find(params[:id])\n @description = @note.overview\n end",
"def create\n params[:note][:project_id] = @project.id\n saved = false\n\n begin\n Note.transaction do\n @note = Note.create!(params[:note])\n item_note_class.create!(item_id: @item.id, note_id: @note.id)\n saved = true\n end\n rescue Exception => e\n Rails.logger.warn \"note not added\\n#{e.message}\"\n Rails.logger.debugger e.backtrace\n end\n\n respond_to do |format|\n if saved\n notice = \"#{Note.name} was successfully created.\"\n\n format.html { \n if(@options[:render_as_partial])\n render partial: 'notes/show_note_log_item', locals: {project: @project, item: @item, note: @note}\n else\n redirect_to [@project, @item, @note], notice: notice \n end\n }\n format.json { render json: {note: @note, msg: notice}, status: :created, location: [@project, @item, @note] }\n else\n format.html { render action: \"new\" }\n format.json { render json: @note.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_note(note)\n notes << note\n end",
"def add_note(note)\n notes << note\n end",
"def note_params\n params.require(:note).permit(:title, :content, :notebook_id)\n end",
"def github_client\n p = Project.find(params[:id])\n if p.github_token\n github = Github.new :oauth_token => p.github_token\n else\n github = Github.new :client_id => GITHUB_CLIENT_ID , :client_secret => GITHUB_CLIENT_SECRET\n end\n end",
"def project_params\n params.require(:project).permit(:name, :note)\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def add_note # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity\n @bib.biblionote.each do |n|\n case n.type\n when \"annote\" then @item.annote = n.content\n when \"howpublished\" then @item.howpublished = n.content\n when \"comment\" then @item.comment = n.content\n when \"tableOfContents\" then @item.content = n.content\n when nil then @item.note = n.content\n end\n end\n end",
"def noter( note, commentaire )\n # A COMPLETER.\n DBC.require( !bu?, \"Vin bu: Le commentaire ou la note ne peut plus etre change\" )\n\n @note = note\n @commentaire = commentaire\n end",
"def note\n @attributes[:note]\n end",
"def create_note(contents, title = nil, description = nil)\n Dropio::Resource.client.create_note(self, contents, title, description)\n end",
"def note_params\n params.require(:note).permit(:title, :content, :cover, :shared, :user_id )\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\r\n @note = Note.find(params[:id])\r\n end",
"def make_note (notes_hash, framework=self.framework)\n\t\t\tprint_deb \"Attempting to create note with #{notes_hash.inspect}\"\n\t\t\t# check the required hash elements for a good note\n\t\t\t\n\t\t\t# <-- start weird bug work around\n\t\t\trequired_elements = [:data]\n\t\t\t#required_elements = [:data,:type]\n\t\t\tnotes_hash[:type] = \"db_fun\"\n\t\t\t# --> end weird bug work around\n\t\t\t\n\t\t\trequired_elements.each do |elem|\n\t\t\t\traise ArgumentError.new \"Missing required element (#{elem}) \" +\n\t\t\t\t\"for the note\" unless notes_hash[elem]\n\t\t\tend\n\t\t\tprint_deb \"Sending note to db with #{notes_hash.inspect}\"\n\t\t\tframework.db.report_note(notes_hash)\n\t\t\t\t\n\t\t\t#\n\t\t\t# Report a Note to the database. Notes can be tied to a Workspace, Host, or Service.\n\t\t\t#\n\t\t\t# opts MUST contain\n\t\t\t# +:data+:: whatever it is you're making a note of\n\t\t\t# +:type+:: The type of note, e.g. smb_peer_os\n\t\t\t#\n\t\t\t# opts can contain\n\t\t\t# +:workspace+:: the workspace to associate with this Note\n\t\t\t# +:host+:: an IP address or a Host object to associate with this Note\n\t\t\t# +:service+:: a Service object to associate with this Note\n\t\t\t# +:port+:: along with :host and proto, a service to associate with this Note\n\t\t\t# +:proto+:: along with :host and port, a service to associate with this Note\n\t\t\t# +:update+:: what to do in case a similar Note exists, see below\n\t\t\t#\n\t\t\t# The +:update+ option can have the following values:\n\t\t\t# +:unique+:: allow only a single Note per +:host+/+:type+ pair\n\t\t\t# +:unique_data+:: like +:uniqe+, but also compare +:data+\n\t\t\t# +:insert+:: always insert a new Note even if one with identical values exists\n\t\t\t#\n\t\t\t# If the provided +:host+ is an IP address and does not exist in the\n\t\t\t# database, it will be created. If +:workspace+, +:host+ and +:service+\n\t\t\t# are all omitted, the new Note will be associated with the current\n\t\t\t# workspace.\n\t\t\t#\n\t\tend",
"def set_note\n\t\t@note = Note.find(params[:id])\n\tend",
"def notes; end",
"def notes; end",
"def notes; end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def create_note(note, topics, attachments)\n click_create_new_note\n enter_new_note_subject note\n enter_note_body note\n add_attachments_to_new_note(note, attachments)\n add_topics(note, topics)\n click_save_new_note\n set_new_note_id note\n end",
"def createNote(noteText)\n refreshToken\n path = \"/api/note?auth=#{@token}\\&email=#{@email}&modify=#{ERB::Util.url_encode(Time.now.strftime(\"%Y-%m-%d %H:%M:%S\"))}\"\n data = noteText\n payload = Base64.encode64(data)\n response, data = agent.post(path,payload)\n unless response.code.to_i == 200\n raise \"Failed to create new note\"\n end\n response.body\n end"
] | [
"0.6556374",
"0.6367514",
"0.61506945",
"0.6062631",
"0.60564697",
"0.6053366",
"0.599303",
"0.59807014",
"0.58403254",
"0.58266973",
"0.58240813",
"0.5815559",
"0.5804585",
"0.5754971",
"0.56971043",
"0.5668589",
"0.5639272",
"0.56191605",
"0.56188077",
"0.5612311",
"0.56039983",
"0.55943906",
"0.5571438",
"0.5560681",
"0.5541878",
"0.55272543",
"0.5488844",
"0.54689264",
"0.54495454",
"0.54475504",
"0.54385114",
"0.5435285",
"0.5410887",
"0.53938156",
"0.5393122",
"0.5386572",
"0.5381776",
"0.5371454",
"0.53702545",
"0.5360779",
"0.5348617",
"0.53472495",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.5346078",
"0.53365517",
"0.53351945",
"0.533453",
"0.5323821",
"0.53226805",
"0.5320994",
"0.5320994",
"0.5320994",
"0.5320994",
"0.5320994",
"0.5320994",
"0.5320994",
"0.53131247",
"0.53117543",
"0.53085375",
"0.5302545",
"0.5302545",
"0.5302545",
"0.53019834",
"0.53019834",
"0.5300068",
"0.5278959"
] | 0.6835686 | 1 |
Returns the ID of the issue or merge request to create the note for. | def find_noteable_id
GithubImport::IssuableFinder.new(project, note).database_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changelog_notes_id\n IssueCustomField.find_by_name('Changelog Note').id\n end",
"def find_merge_request_id\n GithubImport::IssuableFinder.new(project, note).database_id\n end",
"def identifier\n issue.identifier\n end",
"def create_note(issue)\n Note.create_status_change_note(issue, issue.project, current_user, issue.state, current_commit)\n end",
"def set_new_note_id(note)\n new_note_subject_input_element.when_not_visible Utils.short_wait\n id = ''\n start_time = Time.now\n wait_until(10) { (id = BOACUtils.get_note_id_by_subject note) }\n logger.debug \"Note ID is #{id}\"\n logger.warn \"Note was created in #{Time.now - start_time} seconds\"\n note.created_date = note.updated_date = Time.now\n id\n rescue\n logger.debug 'Timed out waiting for note ID'\n fail\n end",
"def request_id\n if metadata = @body[@body.keys.first][\"ResponseMetadata\"]\n metadata[\"RequestId\"]\n elsif id = @body[@body.keys.first][\"requestId\"]\n id\n else\n nil\n end\n end",
"def id_for(request)\n raise NotImplementedError\n end",
"def issue_id\n return @issue_id if defined?(@issue_id)\n\n @issue_id = nil\n\n @issue_id = issue.id if issue\n end",
"def notification_id\n @id\n end",
"def request_id; end",
"def generate_identifier\n self.identifier = Digest::MD5.hexdigest(\"NoteRecordIdentifier#{commit_token}#{Rails.application.config.try(:hash_salt)}\")[0..254]\n end",
"def noteable\n if for_commit?\n project.commit(noteable_id)\n else\n super\n end\n # Temp fix to prevent app crash\n # if note commit id doesnt exist\n rescue\n nil\n end",
"def newid( work )\n url = \"#{self.url}/dois\"\n payload = self.construct_payload( work )\n status, response = rest_post( url, payload )\n\n new_doi = response.dig('data', 'id')\n return status, \"doi:#{new_doi}\" if ok?( status ) && new_doi\n return status, ''\n end",
"def get_request_id\n request_id = ''\n @id_lock.synchronize do\n request_id = @@current_request_id += 1\n end\n request_id\n end",
"def get_request_id\n request_id = ''\n @id_lock.synchronize do\n request_id = @@current_request_id += 1\n end\n request_id\n end",
"def request_id\n @rid ||= Jabber::Generators.request\n end",
"def newid( work )\n url = \"#{self.url}/dois\"\n payload = self.construct_payload( work )\n status, response = rest_post( url, payload )\n #puts \"==> #{status}: #{response}\"\n new_doi = response.dig('data', 'id')\n return status, \"doi:#{new_doi}\" if ok?( status ) && new_doi\n return status, ''\n end",
"def get_doc_id(notification)\n notification[\"id\"]\nend",
"def createNote(noteText)\n refreshToken\n path = \"/api/note?auth=#{@token}\\&email=#{@email}&modify=#{ERB::Util.url_encode(Time.now.strftime(\"%Y-%m-%d %H:%M:%S\"))}\"\n data = noteText\n payload = Base64.encode64(data)\n response, data = agent.post(path,payload)\n unless response.code.to_i == 200\n raise \"Failed to create new note\"\n end\n response.body\n end",
"def create_note(note, topics, attachments)\n click_create_new_note\n enter_new_note_subject note\n enter_note_body note\n add_attachments_to_new_note(note, attachments)\n add_topics(note, topics)\n click_save_new_note\n set_new_note_id note\n end",
"def create\n params[:request][:issue_ids] ||= []\n params[:request][:email] ||= current_user.email\n params[:request][:name] ||= current_user.name\n @request = Request.new(request_params)\n @request.created_by_user = current_user.id\n\n respond_to do |format|\n\n if @request.save\n add_issues_to_request\n @request.newrequest!\n @request.approver!\n\n\n if !params[:request][:comment].empty?\n comment = @request.comments.create\n comment.comment = params[:request][:comment]\n comment.user_id = current_user.id\n comment.save\n end\n\n RequestMailer.notification_email(@request).deliver_later\n\n format.html { redirect_to @request, notice: 'Request was successfully created.' }\n format.json { render :show, status: :created, location: @request }\n\n else\n \n @comments = @request.comments.recent.limit(10).all\n @issues = Issue.all\n format.html { render :new }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def note note, preview=nil\n preview ||= note[0..64]\n params = {\n contact_ids: [ self.id ],\n note: note,\n note_preview: preview\n }\n @nimble.post \"contacts/notes\", params\n end",
"def request_id\n @error['request_id']\n end",
"def build_notification_id(id)\n \"Notification-#{id}\"\n end",
"def create_notes\n end",
"def req_id(env)\n env.request.context[:request_id].to_s\n end",
"def create_deal_note(deal_id, note)\n post(\"deals/#{deal_id}/notes\", note: { note: note })\n end",
"def create\n notes_params = params[:note]\n @note = Note.new(notes_params)\n @note.created_by_id = current_user.id\n\n respond_to do |format|\n if @note.save\n format.html { redirect_to @note, notice: 'Note was successfully created.' }\n format.json { render json: @note, status: :created, location: @note }\n else\n format.html { render action: \"new\" }\n format.json { render json: @note.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_merge_request\n author_id, author_found = user_finder.author_id_for(pull_request)\n\n description = MarkdownText\n .format(pull_request.description, pull_request.author, author_found)\n\n attributes = {\n iid: pull_request.iid,\n title: pull_request.truncated_title,\n description: description,\n source_project_id: project.id,\n target_project_id: project.id,\n source_branch: pull_request.formatted_source_branch,\n target_branch: pull_request.target_branch,\n state: pull_request.state,\n milestone_id: milestone_finder.id_for(pull_request),\n author_id: author_id,\n assignee_id: user_finder.assignee_id_for(pull_request),\n created_at: pull_request.created_at,\n updated_at: pull_request.updated_at\n }\n\n create_merge_request_without_hooks(project, attributes, pull_request.iid)\n end",
"def custom_action\n :new_note\n end",
"def identifier\n \"#{user_id}:#{namespace_id}:#{journal_id}\"\n end",
"def last_request_id\n @last_response && @last_response.body.to_s[%r{<requestId>(.+?)</requestId>}] && $1\n end",
"def _appointment_request_id\n appointment_request_id\n end",
"def get_request_id\n\t\treturn @transport.get_path(\"meta\",\"id\")\n\tend",
"def comment_id\n changes['comment_id']\n end",
"def return_id(obj)\r\n if (obj.new_record?)\r\n 'new_rec'\r\n else\r\n obj.id\r\n end\r\n end",
"def add_note_with_http_info(identifier, body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AlertApi.add_note ...\"\n end\n # verify the required parameter 'identifier' is set\n if @api_client.config.client_side_validation && identifier.nil?\n fail ArgumentError, \"Missing the required parameter 'identifier' when calling AlertApi.add_note\"\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling AlertApi.add_note\"\n end\n if @api_client.config.client_side_validation && opts[:'identifier_type'] && !['id', 'alias', 'tiny'].include?(opts[:'identifier_type'])\n fail ArgumentError, 'invalid value for \"identifier_type\", must be one of id, alias, tiny'\n end\n # resource path\n local_var_path = \"/v2/alerts/{identifier}/notes\".sub('{' + 'identifier' + '}', identifier.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'identifierType'] = opts[:'identifier_type'] if !opts[:'identifier_type'].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 = @api_client.object_to_http_body(body)\n auth_names = ['GenieKey']\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 => 'SuccessResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AlertApi#add_note\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create(params = {})\n note = build(params)\n note.save\n note\n end",
"def note_create_params\n params.require(:note).permit(:project_id, :id, :title, :type, :description, :show)\n end",
"def get_note(note_id)\n @notes[note_id]\n end",
"def get_note(note_id)\n @notes[note_id]\n end",
"def new_workflow_note\n @new_workflow_note ||= ChangeSet.for(WorkflowNote.new)\n end",
"def get_note\n note = queued_email_note\n note ? note.value.to_s : nil\n end",
"def set_interview_note\n @interview_note = InterviewNote.find(params[:id])\n end",
"def note_params\n params[:note]\n end",
"def joss_id\n id = \"%05d\" % review_issue_id\n \"#{ENV['JOURNAL_ALIAS']}.#{id}\"\n end",
"def id\n reply.documents[0][ID]\n end",
"def id_from_comment_body body\n @id_from_comment_body[body] ||= begin\n CommentBody.create(body: body).id\n rescue\n CommentBody.where(body: body).first.id\n end\nend",
"def record_identifier(record)\n record.id\n end",
"def contact_note_add(id:, listid:, note:, **args)\n post(\n '/admin/api.php',\n query: {\n api_action: 'contact_note_add'\n },\n body: args.merge(\n id: id,\n listid: listid,\n note: note,\n )\n )\n end",
"def note\n @attributes[:note]\n end",
"def current_request_id\n RequestStore.store[:current_request_id] || \"NONE\"\n end",
"def add_note(identifier, body, opts = {})\n data, _status_code, _headers = add_note_with_http_info(identifier, body, opts)\n return data\n end",
"def set_communication_note\n @communication_note = CommunicationNote.find(params[:id])\n end",
"def new_note(content)\n note = Note.new({:type_id => self.id,\n :owner => 'bill',\n :content => content})\n note.save\n end",
"def new_comment\n Notifications.new_comment\n end",
"def create\n Rails.logger.info \"CREATING NEW NOTE with params #{params}\"\n receiver = find_by_type_and_id(params[:receiver_type], params[:receiver_id])\n note = Note.new(:message => params[:message], :sender => current_profile, :private => params[:private_note], :receiver => receiver)\n if (reply_to_note_id = params[:reply_to_note_id])\n note.receiver = Note.find(reply_to_note_id).sender\n note.replied_to = reply_to_note_id\n end\n note.save! \n flash[:notice] = \"Your message has ben sent.\" \n render :text => {:message => \"Messsage Sent\" }.to_json\n rescue Exception => e\n flash[:errors] = \"There was an error sending your message, please try again.\"\n render :text => {:message => \"Unable to save message.\", :error => e.message }.to_json\n end",
"def request_id\n # FIXME make this number configurable and document the probabilities of clashes\n @request_id ||= SecureRandom.hex(DEFAULT_REQUEST_ID_LENGTH)\n end",
"def note_params\n params[:note]\n end",
"def create_new_note\n note_type = params[:note_type][:note_type_id]\n new_note = keytech_note_handler.create(note_type, params[:element_key])\n new_note.subject = params[:subject]\n new_note.text = params[:body]\n response = keytech_note_handler.save(new_note)\n if response[:success] == true\n flash[:info] = 'Notiz wurde angelegt'\n else\n flash[:error] = \"Notiz konnte nicht angelegt werden: #{response[:error]}\"\n end\n redirect_to \"/element/#{params[:element_key]}/notes\"\n end",
"def create!(note)\n self.class.post('/notifications.xml', :body => note.to_xml)\n end",
"def create_id(parent)\n \"#{parent}/#{noid_service.mint}\"\n end",
"def add_note_with_http_info(id, api_note, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProjectsApi#add_note ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling add_note\" if id.nil?\n \n # verify the required parameter 'api_note' is set\n fail \"Missing the required parameter 'api_note' when calling add_note\" if api_note.nil?\n \n # resource path\n path = \"/Projects/{id}/Notes\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'text/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\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(api_note)\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'APINote')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectsApi#add_note\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def public_api_post_job_note(job_id, api_key, request, opts = {})\n data, _status_code, _headers = public_api_post_job_note_with_http_info(job_id, api_key, request, opts)\n return data\n end",
"def find_note\n\t\t@note = Note.find(params[:id])\n\tend",
"def request_id=(_); end",
"def create_note(contents, title = nil, description = nil)\n Dropio::Resource.client.create_note(self, contents, title, description)\n end",
"def note(notebook)\n @note = Note.new(notebook, @@auth_store) if @note.nil?\n @note\n end",
"def other_notes_key\n Observation.other_notes_key\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def creator_id\n return @creator_id\n end",
"def new_issue(title)\n result = YAML.load(RestClient.post(\"https://github.com/api/v2/yaml/issues/open/#{@repository}\", :login => @username,\n :token => @api_token, :title => title))\n result[\"issue\"][\"number\"]\n end",
"def record_id(record)\n record.id\n end",
"def create\n @note = current_user.notes.new(params[:note])\n @note.note = view_context.markdown(@note.note).gsub(\"\\n\",\"\").gsub(\"\\r\",\"\")\n @note.save\n $statsd.increment 'animal.note.created'\n respond_with(@note)\n end",
"def rid\n\t\treturn get_tlv_value(TLV_TYPE_REQUEST_ID)\n\tend",
"def rid\n\t\treturn get_tlv_value(TLV_TYPE_REQUEST_ID)\n\tend",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end",
"def set_note\n @note = Note.find(params[:id])\n end"
] | [
"0.6557007",
"0.649947",
"0.64493304",
"0.62286705",
"0.612455",
"0.59475327",
"0.5878396",
"0.5841053",
"0.5829433",
"0.58254474",
"0.5776873",
"0.577545",
"0.5731897",
"0.57104117",
"0.57104117",
"0.5702355",
"0.5678286",
"0.5662933",
"0.5662676",
"0.5642341",
"0.5630811",
"0.561278",
"0.560217",
"0.55894697",
"0.5573704",
"0.5564046",
"0.5516859",
"0.55121547",
"0.55097634",
"0.55031526",
"0.5487019",
"0.54867685",
"0.54679227",
"0.54385686",
"0.5432111",
"0.54187894",
"0.5407707",
"0.5406446",
"0.53970635",
"0.539694",
"0.539694",
"0.53963876",
"0.53944534",
"0.5381924",
"0.5377505",
"0.5374785",
"0.5369524",
"0.5368519",
"0.5358595",
"0.5331536",
"0.5331496",
"0.5328186",
"0.5327932",
"0.5323271",
"0.53226835",
"0.5309974",
"0.5309685",
"0.5307269",
"0.53045124",
"0.53027636",
"0.52962786",
"0.5293201",
"0.52872634",
"0.5285044",
"0.5276238",
"0.5275652",
"0.52666676",
"0.5259435",
"0.5254325",
"0.5229438",
"0.5229438",
"0.5229438",
"0.5229438",
"0.5229438",
"0.5229438",
"0.5229438",
"0.52294177",
"0.5222886",
"0.5214524",
"0.5213134",
"0.5212277",
"0.5212277",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726",
"0.5210726"
] | 0.6480564 | 2 |
end of user input | def drink_list #makes the menu
Recipe.all.each.with_index(1) do |x, index|
puts "#{index} #{x.drink_name}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_input\n\t\tinput = nil\n\t\tuntil input != nil\n\t\t\tinput = case gets.chomp.downcase\n\t\t\twhen \"yes\", \"y\" then \"yes\"\n\t\t\twhen \"no\", \"n\" then \"no\"\n\t\t\telse nil\n\t\t\tend\n\t\t\tputs \"That's not a valid option!\" if not input\n\t\tend\n\t\tinput\n\tend",
"def get_user_input\n\t\tputs \"enter json data, enter __END__ when complete\"\n\n\t\tfinal_user_input = \"\"\n\t\tuser_input = \"\"\n\t until user_input == \"__END__\" \n\t\t final_user_input += user_input\t\n\t\t user_input = gets.chomp\n\t\tend\n\t\treturn final_user_input\n\tend",
"def validate_input_last input\r\n\t\t if @console\r\n\t\t input.match(/\\A[[:alpha:][:blank:]]+\\z/) || (check_enter input)\r\n\t\t else\r\n\t\t input.match(/\\A[[:alpha:][:blank:]]+\\z/) && !(check_enter input)\r\n\t\t end\r\n\t\t end",
"def finished?\n input == 'q' || input =='quit'\n end",
"def eos?; end",
"def end_of_game\n\t\tputs \"\"\n\t\tputs \"Would you like to play again? [Y]es or [N]o\"\n\t\tinput = gets.chomp.upcase\n\t\tif input == 'Y'\n\t\t\tclear_screen\n\t\t\tinitialize\n\t\telsif input == 'N'\n\t\t\tabort(\">Exiting game<\")\n\t\telse\n\t\t\terror\n\t\t\tend_of_game\n\t\tend\n\tend",
"def input_esc\r\n return :exit\r\n end",
"def eof() end",
"def eof() end",
"def eof() end",
"def unrecognized_input\n puts \"Input not recognized or is invalid.\"\n exit_screen\n end",
"def exit_check\n if @students.count > @saved\n puts \"Students added since last save, are you sure you want to quit? (y/n)\"\n input = STDIN.gets.chomp\n while true\n if input == \"Y\" || input == \"y\" \n exit\n elsif input == \"N\" || input == \"n\"\n return\n else\n end\n end\n else\n exit\n end\nend",
"def verification_two(input)\n if input == \"exit\"\n return false\n end\n\n while input.to_i <= 0 || input.to_i > (EndangeredAnimals::Animal.all.length)\n puts \"Please enter a number between 1 and #{EndangeredAnimals::Animal.all.length} or type exit.\"\n input = gets.strip\n\n if input == \"exit\"\n return false\n end\n end\n input\n end",
"def eof?; end",
"def eof?; end",
"def exit?\n user_input == \"q\" || user_input == \"quit\"\n end",
"def continue\n puts \"Do you wish to add more? Y/N\".center(70)\n result = STDIN.gets.chomp.downcase\n if result == \"n\"\n return false\n end\nend",
"def valid?\n @input != \"exit\" && @input != \"quit\"\n end",
"def end_script?\n puts \"Please choose your action!\n\t'q' quit\n\t'm' menu\"\n answer = STDIN.gets.chomp\n\n case answer\n when \"q\" then exit\n when \"m\" then interactive_menu\n else\n puts \"Learn to type...\"\n end_script?\n end\nend",
"def input_esc\n return :exit\n end",
"def end() end",
"def check_ending(mark)\n return unless @game.result\n print_result\n key = @window.getch\n case key\n when ?Y,?y\n start_new_game(mark)\n when ?N,?n\n Kernel::exit\n else\n check_ending(mark)\n end\n @display.clear_status \n end",
"def handle_end\n if get_next_token.type != \"EOL\"\n raise @err_class, \"I don't know what you're talking about!\"\n end\n end",
"def get_user_input\n user_input = gets.chomp\n user_input == \"exit\" ? exit : user_input\nend",
"def exit\n sleep(2)\n puts \"Enter 'back' to see the full list of anime again, or enter 'exit' to quit :) \"\n puts \"\"\n input = gets.strip\n case input\n when \"back\"\n self.list_all_titles\n when \"exit\"\n puts \"\"\n puts \" Thank you for checking out this year's newest anime!!\"\n puts \"\"\n puts \" Source: Myanimelist.com\"\n puts \"\"\n else\n puts \"Invalid entry, please try again :) \"\n self.exit\n end\n end",
"def end_stdin?(line)\n line =~ /^\\\\.$/\n end",
"def eof?() end",
"def eof?() end",
"def eof?() end",
"def eof\n end",
"def fetch_input(prompt)\n\tprint prompt\n\tgets.chomp #implicit return again\nend",
"def eof\n @pushback.nil? and (@input.nil? or @input.eof)\n end",
"def validate_input(data)\n flag=true\n while flag && data==\"\"\n puts \"Invalid Input!!! \"\n puts \"Enter Again : \"\n data=gets.chomp\n end\n return data\nend",
"def ask\n gets.strip\n end",
"def gets_user_input\n input = gets.chomp\n puts \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n # binding.pry\n\n if input == \"exit\"\n exit\n end\n\n return input\n end",
"def user_input\n print '>> '.yellow\n case raw_input = gets.chomp\n when 'c', 'cancel' then tell_user \"\\n\";raise ProgramExceptions::Cancel.new\n else\n tell_user \"\\n\"\n return raw_input\n end\n rescue => error\n raise ProgramExceptions::Exit.new if\\\n error.class == ProgramExceptions::Exit ||\n (defined?(IRB) && error.class == IRB::Abort)\n raise error\n end",
"def end(p0) end",
"def get_end_line\n puts \"\\nWhat tube line will you end on?\"\n @end_line = gets.strip.chomp.downcase\n end",
"def continue\n if gets == \"\\n\"\n system \"clear\"\n main\n end\n end",
"def does_user_quit(user_input)\n quit if user_input == ''\n end",
"def user_input\n\tgets\nend",
"def process_next_input\n next_input = @input.read_next_input\n\n if next_input == :exit_command\n return :exit_command\n end\n\n validation = @validator.validate(next_input)\n unless validation.response == :valid_input\n @output.output_error(validation.response)\n return\n end\n\n if input_complete?(next_input)\n process_new_answer(InputParser.new(next_input).input)\n else\n if @last_answer\n input = InputParser.new(next_input).input\n process_new_answer(ParsedInput.new(input.numbers.push(@last_answer), input.operator))\n else\n @output.output_error(\"#{next_input} is not a complete calculation!\")\n end\n end\n end",
"def process_user_input\n command = get_user_input\n while command != \"quit\"\n perform_command(command)\n command = get_user_input\n end\n puts \"Good bye!\"\nend",
"def validate\n 2.times { puts }\n puts <<-EOF\nYou have entered the following information\nApocalypse server : #{@address}\nApocalypse server port : #{@port}\nApocalypse username : #{@username}\nApocalypse password : #{'*' *@password.length}\nThis Server' hostname : #{@hostname}\nEOF\n\n print \"Is this correct? [no]: \"\n raise Exception.new(\"Aborted by user.\") unless gets =~ /^y(?:es|)$/\n puts\n end",
"def dan\n\n puts 'What?'\n\n input = gets.chomp\n\n until input == 'exit'\n\n if input == input.upcase\n puts \"Woah, chill out!\"\n elsif input.include? \"?\"\n puts \"Sure...\"\n else\n puts \"Whatever...\"\n end\n\n input = gets.chomp\n\n end\n \nend",
"def quit(player, input)\n \t\tunless input =~ /quit/i\n \t\t\tprint_line \"You must type the entire word 'quit' to quit.\\n\"\n \t \telse\n \t\t\tprint_line \"Until next time...\"\n \t\t\t$win.refresh\n \t\t\tsleep 3\n \t\t\t$win.close\n \t\t\texit\n \t\tend\n\tend",
"def eof?\n @input.eof?\n end",
"def begin_input\n\t\tinput = nil\n\t\tuntil input != nil\n\t\t\tinput = case gets.chomp.downcase\n\t\t\twhen \"hard\", \"h\" then :hard\n\t\t\twhen \"medium\", \"m\" then :medium\n\t\t\twhen \"mom\" then :mom\n\t\t\telse nil\n\t\t\tend\n\t\t\tputs \"That is not a valid input!\" if not input\n\t\tend\n\t\tinput\n\tend",
"def eof!; end",
"def get_input\n\t\tinput_given = gets.chomp\n\t\treturn nil if input_given == \"\"\n\t\tputs \"You entered '#{input_given}', are you happy with that? Y or N\"\n\t\tconfirmation = gets.chomp\n\t\twhile confirmation.upcase == 'N'\n\t\t\tputs \"Please re-enter\"\n\t\t\tinput_given = gets.chomp\n\t\t\tputs \"You entered '#{input_given}', are you happy with that? Y or N\"\n\t\t\tconfirmation = gets.chomp\n\t\tend\n\t\tinput_given\n\tend",
"def again_or_exit?(crate)\n puts \"\\n\\nWhat would you like to do now?\\n1. View another genre.\\n2. Exit\"\n input = gets.strip\n input_i = input.to_i\n acceptable_answers = (1..2).to_a\n while acceptable_answers.none? { |answer| answer == input_i }\n puts \"\\nI'm sorry, that's not a valid option.\"\n puts \"Please enter 1 or 2.\"\n input_i = gets.strip.to_i\n end \n\n if input_i == 1\n self.start(crate)\n else\n puts \"Have a good one!\"\n end\n end",
"def after_loop\n return super if CtrldNewline.disabled?\n puts unless @input\n super\n end",
"def end?\n @cursor == @text.length\n end",
"def end?\n @cursor == @text.length\n end",
"def end?\n\t\twin?(\"x\") || win?(\"o\") || @board.count(\"-\") == 0\n\tend",
"def input_complete?(next_input)\n InputParser.new(next_input).input.complete_command?\n end",
"def get_valid_user_choice\r\n choice_ok = false\r\n choice = \"\"\r\n until choice_ok\r\n print \"> \"\r\n choice = gets.chomp\r\n choice_ok = verify_choice_ok(choice)\r\n puts \"Invalid choice.\" unless choice_ok\r\n end\r\n return choice\r\nend",
"def get_input(question)\n\t# ask question \n \t# check to make sure something has been entered:\n\n \tanswer = \"\"\n \tputs answer.empty?\n\twhile answer.empty?\n\t\tputs question\n\t\t#get input and remove NewLien character\n\t\tanswer = gets.delete(\"\\n\")\n\tend\n\treturn answer\nend",
"def end_game\n\tprint_paragraph(\"You made it out alive and all before lunch.\\nCongratulations on your victory!\")\n\tputs \"Would you like to play again? (Y/N)\"\t\n\tplay_again = gets.chomp\n\tplay_again.downcase!\n\tif play_again == \"y\"\n\t\tgame_start\n\telse\n\t\texit\n\tend\nend",
"def prompt_after_search\n puts \"\"\n puts \"--------------------| Search Completed |----------------------\"\n puts \" Type 'start' to start over or 'exit' to exit search \"\n input = gets.strip\n if input == \"exit\"\n puts \"Search Ended....\"\n elsif input == \"start\"\n puts \"Enter New Search\"\n self.define_scraper\n end\n end",
"def do_eof; end",
"def get_user_input\n user_input_valid gets.chomp\n end",
"def prompt_and_handle_exit(message)\n puts message\n user_input = gets.strip\n \n if user_input.downcase == \"exit\" \n puts \"\\nThanks for stopping by!\\n\".colorize(:color => :green) \n exit\n end \n user_input\n end",
"def end_of_the_game\n @display.throw(self)\n puts \"THIS IS THE END OF THE GAME\"\n puts ''\n if @current_board.boardcase_array.any? { |boardcase| boardcase.status == nil } == false\n puts 'I am afraid this a DRAW T_T'\n else\n puts \"Wow! #{@player_turn.name} you did win this one\"\n @player_turn == @player_one ? (@score_player_one += 1) : (@score_player_two += 1)\n end\n puts \"#{@player_one.name} :#{@score_player_one} victories\"\n puts \"#{@player_two.name} :#{@score_player_two} victories\"\n puts ''\n puts ''\n print \"DO YOU WANT TO TRY AGAIN? Y/n\"\n choice = gets.chomp\n exit unless choice == \"Y\"\n end",
"def premature_end\n token_pos = tokens.size # One-based!\n last_token = tokens[-1]\n entry_set = chart.sets[tokens.size]\n expected = entry_set.expected_terminals\n\n reason = PrematureInputEnd.new(token_pos - 1, last_token, expected)\n faulty(reason)\n end",
"def exit?(input)\n input == \"exit\"\n end",
"def getinput(question, default = '')\n askuser = question + \" ('q' to quit)\"\n askuser << (!default.empty? ? \" [#{default}]: \" : \": \")\n puts askuser\n myui = gets.chomp\n if myui.casecmp('q').zero? then\n puts \"Okay, g'bye!\"\n exit\n end\n return myui\nend",
"def get_answer\n\tprint \"please enter the keyword to 'exit': \"\n\tprint \"hint: it is one of the letters in the word 'exit' \"\n\tanswer = gets.chomp.downcase\n\treturn answer\nend",
"def check_ending(_result)\n end",
"def end_of_word; end",
"def coming_soon_message\n puts \"Feature coming soon!\"\n puts \"Return to main? (y)es (e)xit Votersim\"\n\n @input = gets.chomp.downcase\n\n case @input\n when \"y\"\n prompt_user_for_initial_choices\n when \"e\"\n exit\n else\n coming_soon_message\n end\n end",
"def read_input; end",
"def verification_one(input)\n while input != \"1\" && input != \"2\" && input != \"3\"\n if input == \"exit\"\n return false\n else\n puts \"Please enter (1-3) or type exit.\"\n print \"> \"\n input = gets.strip.downcase\n end\n end\n\n case input\n when \"1\"\n input = \"Critically Endangered\"\n when \"2\"\n input = \"Endangered\"\n when \"3\"\n input = \"Vulnerable\"\n end\n input\n end",
"def prompt\n\tputs \"Any Key to continue\"\n\tgets\nend",
"def end_of_game\n\t\tputs \"\"\n\t\tif @guess_counter == 0\n\t\t\tputs \"Sorry, but you are out of guesses!\"\n\t\t\tputs \"The answer is '#{@answer_array.join}'\"\n\t\telse\n\t\t\tputs \"Yes! You are correct! The answer is '#{@answer_array.join}'!\"\n\t\t\tputs \"Good job!\"\n\t\tend\n\tend",
"def learn_more_end_menu\n until @learn_more_input.match?(/^again$|^back$/)\n puts Spacer\n puts \"Enter 'again' to search for another type\".colorize(:light_black)\n print \"or 'back' to go back to main menu:\".colorize(:light_black)\n\n @learn_more_input = gets.chomp.downcase\n\n system(\"clear\")\n case @learn_more_input\n when \"back\"\n @search_menu_input = \"back\"\n when \"again\"\n @search_type = \"Type\"\n else \n menu_error unless @learn_more_input.match?(/^again$|^back$/)\n end\n end\n end",
"def ask_input\n\t\tputs \"where do you want to go ? N, S, W, E\"\n\t\tuser_input = gets.chomp\n\tend",
"def user_response(input)\n puts 'Please enter a letter or type \"exit!\" to save your game and exit:'\n if input == false\n gets.chomp.downcase\n else\n input\n end\n end",
"def end_hike\n menu = hike_menu_maker(@current_user.reload.incomplete_hikes)\n #if no incomplete hikes, display error and exit function. else continue\n if menu.length > 0\n menu[\"Cancel\"] = \"Cancel\"\n hike_to_end = TTY::Prompt.new.select(\"Which trail?\", menu)\n if hike_to_end != \"Cancel\"\n hike_to_end.end_hike\n puts \"Hike successfully ended on #{hike_to_end.trail.name}.\"\n @prompt.keypress(\"Press any key to continue\")\n end\n else\n puts \"No incomplete hikes found.\"\n @prompt.keypress(\"Press any key to continue\")\n end\n end",
"def continue\n if gets == \"\\n\"\n system \"clear\"\n end\nend",
"def user_input_capture\n print \">>: \"\n response = gets.chomp\n response\n end",
"def end_message\n puts \"Thanks for playing!\".center($GAME_WIDTH)\n puts\n print \"You got #{$game_session.get_correct_questions.length} questions correct with total earnings of #{$game_session.current_total_score} bear-bucks!!\".center($GAME_WIDTH)\n puts\n puts\n puts\n bear_paw\n sleep(1)\n gets.chomp\n system \"clear\"\nend",
"def prepare_input(prompt)\n line = readline(prompt)\n return unless line\n\n last_if_empty(line)\n end",
"def input_stmt()\n str = STDIN.gets(\"\\n\")\n if str\n while( str.strip() != \"\" and\n str.rstrip()[-1,1] != \";\" )\n str += STDIN.gets(\"\\n\")\n end\n\n res = str.strip()\n if res == \"\" or res == \";\"\n res = nil\n end\n\n return res\n else # nothing read(e.g the user only pressed control d)\n return nil\n end\n\n end",
"def end\n\t\t\t# Give an extra line below the output for the shell to prompt on.\n\t\t\tadd_bar(nil)\n\n\t\t\tNcurses.endwin\n\t\tend",
"def prompt\n gets.strip\nend",
"def end?\r\n\t\tif(@allLines.empty?)\r\n\t\t\treturn true\r\n\t\telse\r\n\t\t\treturn false\r\n\t\tend\r\n\tend",
"def continue\n print \"Press enter to face the next wave\"\n gets\nend",
"def action_0\nputs \"Are you ready to start a new game?\\n [ Y ] [ N ]\"\n user_input = gets.chomp.downcase\n if user_input == \"y\"\n action_1\n elsif user_input == \"n\"\n puts \"\\nSmart decision! Come back later :)\\n\\n\"\n exit\n else\n nil\n end\nend",
"def ask(&parser)\n until input = get_input(parser)\n puts @notify_invalid if @notify_invalid\n end\n puts\n input\n end",
"def continue_prompt\r\n puts \"Press enter key to continue....\"\r\n continue = gets.chomp\r\n end",
"def end; end",
"def end; end",
"def end; end",
"def get_input(question)\n\t# ask question \n \t# check to make sure something has been entered:\n \tanswer = \"\"\n\twhile answer.empty?\n\t\tputs question\n\t\t#get input and remove NewLine character\n\t\tanswer = gets.delete(\"\\n\")\n\tend\n\tanswer\nend",
"def user_input\n gets.chomp\nend",
"def user_input\n gets.chomp\nend",
"def mock_me()\n puts \"Enter your input below. Type 'quit' to exit.\"\n input = gets.chomp\n until input == \"quit\" do\n puts input\n input = gets.chomp\n end\nend",
"def user_input\n\tuser_selection = gets.strip.to_i\n\tinput_logic(user_selection)\nend",
"def get_input\n input = gets.chomp\n until valid_input?(input)\n puts \"Invalid input. Please type in an EMPTY cell number from \"\\\n \"1-9, 'quit', or 'restart'.\"\n print \">> \"\n input = gets.chomp\n end\n input\n end",
"def read_input()\n print \"> \"\n $stdout.flush\n gets\n end"
] | [
"0.7340667",
"0.68995893",
"0.6695416",
"0.66071856",
"0.6603539",
"0.65339696",
"0.64594275",
"0.64234143",
"0.64234143",
"0.64234143",
"0.63956654",
"0.63715553",
"0.6365442",
"0.63601655",
"0.63601655",
"0.63382107",
"0.63325155",
"0.6327132",
"0.63222057",
"0.63133043",
"0.62845445",
"0.62752",
"0.62569547",
"0.62209785",
"0.6192165",
"0.6166537",
"0.61647296",
"0.61647296",
"0.61647296",
"0.6163448",
"0.6158123",
"0.61506724",
"0.614685",
"0.6136619",
"0.6118454",
"0.61118424",
"0.6085784",
"0.60674024",
"0.6059096",
"0.6057947",
"0.6057871",
"0.6048101",
"0.6035069",
"0.60307246",
"0.6027661",
"0.6008681",
"0.59946233",
"0.5993026",
"0.5988329",
"0.59863174",
"0.59795946",
"0.59759676",
"0.59669775",
"0.59669775",
"0.5963901",
"0.5963345",
"0.59597903",
"0.5954604",
"0.59535056",
"0.594938",
"0.5940484",
"0.59323466",
"0.5916594",
"0.59091336",
"0.5906997",
"0.5897876",
"0.5893259",
"0.5887605",
"0.5886785",
"0.5885124",
"0.5855869",
"0.5848594",
"0.5848522",
"0.5848205",
"0.5845773",
"0.58404505",
"0.58372027",
"0.58366364",
"0.58317536",
"0.58280855",
"0.58276296",
"0.5819989",
"0.5809943",
"0.5809828",
"0.5806419",
"0.58045083",
"0.5802614",
"0.5802612",
"0.58024454",
"0.5802361",
"0.5796853",
"0.5794131",
"0.5794131",
"0.5794131",
"0.57921964",
"0.5792069",
"0.5792069",
"0.57893234",
"0.57889104",
"0.5780196",
"0.577287"
] | 0.0 | -1 |
end setup to_s should return a string representation of the graph in the dot language. most of whats added to the graph will translate to something than is in this... | def test_graph_to_s
sut_graph = Graph.new
sut_graph.name="test_graph"
sut_graph.type=:digraph
sut_graph.node_style=:ellipse
#sut_graph.add_node "TEST1"
#sut_graph.add_node "TEST2"
sut_graph.add_edge("TEST1" , "TEST2" , "take_me_to_test_2")
returned_obj = sut_graph.to_s
assert( returned_obj.instance_of?(String) , "Check to_s returns String, returns: #{returned_obj.class}" )
assert(returned_obj.scan(/test_graph/).length==1 , "Check once occurence of graph name in dot to_s.")
assert(returned_obj.scan(/digraph test_graph/).length==1 , "Check graph type and name in dot to_s.")
assert(returned_obj.scan(/shape = ellipse/).length==1 , "Check graph node style in dot to_s.")
#assert(returned_obj.scan(/TEST1\;/).length==1 , "Check that Node definition is included: TEST1;")
#assert(returned_obj.scan(/TEST2\;/).length==1 , "Check that Node definition is included: TEST2}")
assert(returned_obj.scan(/label = \"take_me_to_test_2"/).length==1 , "Check that arc label is included")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dot (params={}) to_dot_graph(params).to_s; end",
"def to_dot (params={}) to_dot_graph(params).to_s; end",
"def graph_to_s\n string = \"\"\n @nodes.each do |name, node|\n string +=\"#{name}:\\n\\t(#{node.name}, #{node.country}, #{node.continent} #{node.timezone}, #{node.coords}, #{node.pop}, #{node.region}) => #{@edges[name]} \\n\"\n end\n string\n end",
"def test_to_s\n graph = DirectedGraph.new\n vertex_a = Vertex.new('a')\n vertex_b = Vertex.new('b')\n vertex_c = Vertex.new('c')\n graph.add_vertex(vertex_a).add_vertex(vertex_b).add_vertex(vertex_c)\n graph.add_edge('a','b').add_edge('c','b')\n\n assert(graph.to_s == 'a=>b,b=>,c=>b')\n end",
"def dot\n RGL::DOT::Graph.new('elements' => dot_edges).to_s\n end",
"def test_to_s\n graph = Graph.new\n vertex_a = Vertex.new('a')\n vertex_b = Vertex.new('b')\n vertex_c = Vertex.new('c')\n graph.add_vertex(vertex_a).add_vertex(vertex_b).add_vertex(vertex_c)\n graph.add_edge('a','b').add_edge('c','b')\n\n assert(graph.to_s == 'a=>b,b=>a,b=>c,c=>b')\n end",
"def to_s\n res = \"\"\n @graph.each_pair do |key, value|\n res += key.to_s + \": \" + value.join(', ') + \"\\n\"\n end\n res\n end",
"def to_s\n str = \n%{Petri Net [#{@name}]\n----------------------------\nDescription: #{@description}\nFilename: #{@filename}\n\nPlaces\n----------------------------\n#{str = ''; @places.each_value {|p| str += @objects[p].to_s + \"\\n\"}; str }\nTransitions\n----------------------------\n#{str = ''; @transitions.each_value {|t| str += @objects[t].to_s + \"\\n\" }; str }\nArcs\n----------------------------\n#{str = ''; @arcs.each_value {|a| str += @objects[a].to_s + \"\\n\" }; str}\n}\n return str\n end",
"def test_to_s_only_vertices\n graph = Graph.new\n vertex_a = Vertex.new('a')\n vertex_b = Vertex.new('b')\n vertex_c = Vertex.new('c')\n graph.add_vertex(vertex_a).add_vertex(vertex_b).add_vertex(vertex_c)\n\n assert(graph.to_s == 'a=>,b=>,c=>')\n end",
"def to_s\n @g.to_s\n end",
"def to_s\n s = \"\"\n @nodes.each do |identifier, node|\n s += \"#{identifier} (#{node.contigs.join(\",\")}) => #{@edges[identifier]} \\n\"\n end\n s\n end",
"def to_s(symbols = {})\n return \"\" if @nodes.empty?\n @nodes.map {|node| node.to_s(symbols) }.join(self.class.format)\n end",
"def to_s\n @to_s ||= traite_to_text\n end",
"def to_dot graph\n graph.node(self, :label => production)\n child_nodes.each do |child|\n graph.edge(self, child)\n child.to_dot(graph)\n end\n end",
"def to_s\n result = ''\n\n # Return an empty string for an empty graph\n return result unless @vertices.length > 0\n\n @vertices.each do |vertex|\n added = false\n vertex.neighbours.each_with_index do |value, neighbour_index|\n if (value == true)\n added = true\n result << vertex.name << '=>' << @vertices[neighbour_index].name << ','\n end\n end\n # if there has been no edges for the vertex\n result << vertex.name << '=>,' unless added\n end\n\n # remove trailing comma\n result.chop\n end",
"def to_s\n label.to_s + ':' + rule.embed\n end",
"def to_s\n raw = \"Raw: #{@raw}\"\n puts raw\n puts\n father = \"Father: #{@father.raw if @father}\"\n puts father\n puts\n left_sentence = \"Left: #{@left_sentence.raw if @left_sentence}\"\n puts left_sentence\n puts\n operator = \"Operator: #{@operator.value if @operator}\"\n puts operator\n puts\n right_sentence = \"Right: #{@right_sentence.raw if @right_sentence}\"\n puts right_sentence\n puts\n level = \"Level: #{@level}\"\n puts level\n puts\n end",
"def to_dot(options = {})\r\n Dot::Digraph.new(:fontsize => 10, :shape => :box, :size => 5) do |g|\r\n states.each do |state|\r\n g.node(state, :label => state.items.values.collect{|item| item.to_s(options)}.join(\"\\n\"))\r\n @transitions[state].each do |symbol, dest_state|\r\n g.edge(state, dest_state, :label => symbol.name)\r\n end\r\n end\r\n end.to_dot\r\n end",
"def to_s\n if ((@p).equal?(-1))\n fill_buffer\n end\n buf = StringBuffer.new\n i = 0\n while i < @nodes.size\n t = @nodes.get(i)\n buf.append(\" \")\n buf.append(@adaptor.get_type(t))\n i += 1\n end\n return buf.to_s\n end",
"def dot\n s = \"digraph query {\\n\"\n @operators.each { |op| \n desc = op.attributes.inspect.gsub(\"\\\"\", \"\\\\\\\"\")\n label = \"[#{op.index}] #{op.name}\"\n if op.performanceData\n duration = (op.performanceData[\"endTime\"] - op.performanceData[\"startTime\"]).to_f\n label += \" (#{duration} ms)\"\n end\n s += \" #{op.index} [label=\\\"#{label}\\n #{desc}\\\", shape=box];\\n\"\n op.dependencies.each { |dep|\n s += \" #{dep.index} -> #{op.index};\\n\"\n }\n } \n s += \"}\\n\"\n end",
"def to_s\n \"#{@text} (#{@points} #{Sklonyator.sklonenie(@points, 'point', 'points', 'points')})\"\n end",
"def to_dot\n i = 0\n dot = [\"digraph G {\", \"#{i} [label=\\\"self\\\"];\"]\n _to_dot(dot, \"\", i, self, i)\n dot << \"}\"\n dot.join(\"\\n\")\n end",
"def to_s\n # \"%s <- %s (%0.01f%s, %0.01f)\" % [ consequent, \n # antecedent.join(\" \"), \n # support, \n # num_antecedent_transactions ? \"/#{num_antecedent_transactions}\" : \"\", confidence ]\n \"%s -> %s (%0.01f%s, %0.01f)\" % [ antecedent.join(\" \"),\n consequent, \n support, \n num_antecedent_transactions ? \"/#{num_antecedent_transactions}\" : \"\", confidence ]\n end",
"def nodes_to_s\n string = \"\"\n @nodes.each do |name, node|\n string +=\"#{name}:\\n\\t(#{node.name})\\n\"\n end\n string\n end",
"def to_s\n nodes.map(&:to_s).join(';')\n end",
"def graph\n \n \n @graphml = \"<graphml><key id='label' for='all' attr.name='label' attr.type='string'/><key id='link' for='all' attr.name='link' attr.type='string'/><key id='weight' for='all' attr.name='weight' attr.type='double'/><key id='edgetype' for='edge' attr.name='edgetype' attr.type='string'/><key id='nodetype' for='node' attr.name='nodetype' attr.type='string'/><graph edgedefault='directed'>\" \n @sif = ''\n \n @max = 2\n @log = Array.new\n @additional = {'cleavage' => {}, 'inverse_cleavage' => {}, 'inhibition' => {}, 'inverse_inhibition' => {}, 'interaction' => {}}\n add_nodes(nil,self.protein,nil,0,nil)\n add_additional_nodes(@additional['cleavage'],'cleavage')\n add_additional_nodes(@additional['inverse_cleavage'],'inverse_cleavage')\n add_additional_nodes(@additional['inhibition'],'inhibition')\n add_additional_nodes(@additional['inverse_inhibition'],'inverse_inhibition')\n \n @graphml << \"</graph></graphml>\"\n\n \n # f = File.open(\"#{RAILS_ROOT}/public/images/dynamic/#{self.protein.name}-#{'ppi' if ppi}network.graphml\", 'w')\n # f << @graphml\n # f.close\n\n return @graphml\n end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_dot(include_starred_states = false)\n all_states = transitions.values.map(&:to_a).flatten.uniq.reject { |t| t == \"*\" }\n\n \"\".tap do |s|\n s << \"digraph #{self.class.name.inspect} {\\n\"\n transitions.each do |signal, signal_transitions|\n signal_transitions.each do |from, to|\n next if !include_starred_states && (from == \"*\" || to == \"*\")\n\n from = from == \"*\" ? all_states : [from]\n to = to == \"*\" ? all_states : [to]\n from.product(to).each { |f, t| s << \" #{f} -> #{t} [ label=\\\"#{signal}\\\" ]\\n\" }\n end\n end\n s << \"}\\n\"\n end\n end",
"def to_s(*) end",
"def to_s(*) end",
"def to_s(*) end",
"def to_s\n # Ideally, SymbolicValues shouldn't escape into trace world, and\n # we shouldn't require this if condition. However, they do escape.\n # This is because of the symbolic values being stored in concrete\n # hashes and arrays in SymbolicResult#each or SymbolicArray#map.\n if tracer.tracing?\n return self.ast.to_s\n end\n @to_s ||= begin\n to_s_var = TraceAST::Var.new(\"to_s\")\n var = tracer.new_var_for(TraceAST::Dot.new(self.ast,to_s_var))\n # Except for nil and empty string, to_s never\n # returns an empty string.\n SymbolicNonEmptyString.new var\n end\n end",
"def to_s\n label_name.to_s + ':' + rule.embed\n end",
"def to_s()\n \"#{get_grasas()}\\n#{get_saturadas()}\\n#{get_monoin()}\\n#{get_poli()}\\n#{get_hidratos()}\\n#{get_azucares()}\\n#{get_alco()}\\n#{get_almidon()}\\n#{get_fibra()}\\n#{get_proteinas()}\\n#{get_sal()}\"\n end",
"def to_dot(opts={})\n\n s = [ \"digraph \\\"process wfid #{wfid}\\\" {\" ]\n @expressions.each { |e| s.push(*e.send(:to_dot, opts)) }\n @errors.each { |e| s.push(*e.send(:to_dot, opts)) }\n s << '}'\n\n s.join(\"\\n\")\n end",
"def test_to_s_empty_graph\n graph = Graph.new\n\n assert(graph.to_s == '')\n end",
"def to_s\n\t\t@node_string\n\tend",
"def to_dot(graph)\n graph.node(self, :label => token)\n end",
"def to_s\n @vertices.to_s\n end",
"def to_dot\n Dot::Digraph.new(:fontsize => 10, :shape => :box, :size => 5) do |g|\n parse_tree.to_dot(g)\n end.to_dot\n end",
"def to_dot(**options) = convert_to('dot', **options)",
"def test_graph_to_s_incomplete\n sut_graph = Graph.new\n sut_graph.name=\"test_graph\" \n #sut_graph.type=:digraph\n sut_graph.node_style=:ellipse\n \n sut_graph.add_edge(\"TEST1\" , \"TEST2\" , \"take_me_to_test_2\")\n assert_raises RuntimeError do\n returned_obj = sut_graph.to_s\n end # end assert\n end",
"def to_dot\n return unless gv_object\n gv_object.to_s\n end",
"def to_s\n ret = build_link\n ret << tree.to_s if tree\n\n ret\n end",
"def to_s\n\t\t\"<Node:#{@e}>\"\n\tend",
"def to_dot\n template = <<-eos\ndigraph \"<%= uid || 'graph' %>\" {\n node[ style = \"filled, solid\"];\n<% each_task do |task| -%>\n<% next unless task.name =~ dot_task_filter if dot_task_filter -%>\n<% next unless task.node.name =~ dot_node_filter if dot_node_filter and task.node -%>\n \"<%= task %>\" [label = \"<%= task %>\", fillcolor = \"<%= task.color %>\"];\n<% end -%>\n\n<% each_task do |task| -%>\n<% task.each_forward_dependency do |forward_task| -%>\n<% next unless task.name =~ dot_task_filter if dot_task_filter -%>\n<% next unless task.node.name =~ dot_node_filter if dot_node_filter and task.node -%>\n<% next unless forward_task.name =~ dot_task_filter if dot_task_filter -%>\n<% next unless forward_task.node.name =~ dot_node_filter if dot_node_filter and forward_task.node -%>\n \"<%= task %>\" -> \"<%= forward_task %>\";\n<% end -%>\n<% end -%>\n}\n eos\n ERB.new(template, nil, '-').result(binding)\n end",
"def to_s\n super + \"(#{@npmc}, #{@pmg}, #{@pg}, #{@pu}, #{@gl}, #{@pml}, #{@ds}, #{@tipo_grano}, #{@estacion_siembra})\"\n end",
"def to_s\n return @nodes.values.map{|node| node.to_s}.join\n #return @nodes.values.reduce(''){|sum, node| sum + node.to_s}\n end",
"def to_s\n @node.to_s\n end",
"def to_s\n nodes.map do |_key, node|\n node.to_s\n end.join(\"\\n\")\n end",
"def to_s\n\t\tres = @x + \" \" + @p + \" \" + @o\n\t\tres\n\tend",
"def to_s\n \"#{@lhs} -> #{rhs_str}\"\n end",
"def to_dot\n require 'graphviz_r'\n gvr = GraphvizR.new('mind_map')\n gvr.graph[:bgcolor => 'transparent']\n edges = cull()\n\n edges.flatten.uniq.each do |post|\n def post.dot_id; \"post_#{ id }\"; end\n gvr[post.dot_id][ style_node(post) ]\n end\n\n edges.each{ |from, to| gvr[from.dot_id] - gvr[to.dot_id] }\n return gvr.to_dot # that ^ declares a GraphViz edge!\n end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end"
] | [
"0.7962001",
"0.7962001",
"0.76369226",
"0.72473687",
"0.7166967",
"0.7156966",
"0.6953944",
"0.6791427",
"0.67006135",
"0.66608757",
"0.66547245",
"0.657938",
"0.65760434",
"0.65679413",
"0.6555326",
"0.65237045",
"0.65188",
"0.65093064",
"0.6476672",
"0.6450198",
"0.6442195",
"0.6441254",
"0.64054704",
"0.6383432",
"0.6375718",
"0.6373829",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.6353734",
"0.634835",
"0.63453704",
"0.63453704",
"0.63453704",
"0.6320668",
"0.6301658",
"0.629933",
"0.62944573",
"0.6294216",
"0.6277977",
"0.6274472",
"0.6266157",
"0.62431985",
"0.6241597",
"0.6240961",
"0.62289226",
"0.6228768",
"0.6225583",
"0.6224495",
"0.6224063",
"0.62211657",
"0.6217153",
"0.6208198",
"0.6200545",
"0.6173112",
"0.61594",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763",
"0.61561763"
] | 0.68478245 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.